冲锋技能jass脚本重写

优化前的脚本:

//冲锋技能
function Trig_ChongFengB_Conditions takes nothing returns boolean
if(not(GetSpellAbilityId()=='A06B'))then
return false
endif
return true
endfunction
function Trig_ChongFengB_Actions takes nothing returns nothing
set udg_ChongFeng_Unit[3]=GetTriggerUnit()
set udg_ChongFeng_Jiaodu[3]=AngleBetweenPoints(GetUnitLoc(udg_ChongFeng_Unit[3]),GetSpellTargetLoc())
call CreateNUnitsAtLoc(1,'o00W',Player(3),GetUnitLoc(udg_ChongFeng_Unit[3]),bj_UNIT_FACING)
call IssuePointOrderLoc(GetLastCreatedUnit(),"impale",GetSpellTargetLoc())
call UnitApplyTimedLife(GetLastCreatedUnit(),'BHwe',2.00)
call SetUnitPathing(udg_ChongFeng_Unit[3],false)
call ShowUnitHide(udg_ChongFeng_Unit[3])
call PolledWait(0.90)
call SetUnitPositionLoc(udg_ChongFeng_Unit[3],PolarProjectionBJ(GetUnitLoc(udg_ChongFeng_Unit[3]),900.00,udg_ChongFeng_Jiaodu[3]))
call SetUnitPathing(udg_ChongFeng_Unit[3],true)
call ShowUnitShow(udg_ChongFeng_Unit[3])
call SelectUnitForPlayerSingle(udg_ChongFeng_Unit[3],Player(3))
endfunction
function InitTrig_ChongFengB takes nothing returns nothing
set gg_trg_ChongFengB=CreateTrigger()
call TriggerRegisterPlayerUnitEventSimple(gg_trg_ChongFengB,Player(3),EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_ChongFengB,Condition(function Trig_ChongFengB_Conditions))
call TriggerAddAction(gg_trg_ChongFengB,function Trig_ChongFengB_Actions)
endfunction
优化前对每个玩家都要写一遍上面的代码,而且容易出错。


优化后的脚本:

//冲锋技能触发器
function ChongFeng_actions takes nothing returns nothing
	//发动技能的玩家
	local player fadong_player  = GetTriggerPlayer()
	//施法单位,也就是发动冲锋技能的武将
	local unit fadong_unit = GetTriggerUnit()
	//施法目标坐标
	local location mubiao_loc = GetSpellTargetLoc()
	local real jiaodu = AngleBetweenPoints(GetUnitLoc(fadong_unit),mubiao_loc)
	call CreateNUnitsAtLoc(1,'o00W',fadong_player,GetUnitLoc(fadong_unit),bj_UNIT_FACING)
	//给单位发送命令到 点  impale命令
	call IssuePointOrderLoc(GetLastCreatedUnit(),"impale", mubiao_loc)
	//设置单位生命计时器
	call UnitApplyTimedLife(GetLastCreatedUnit(),'BHwe',2.00)
	//关闭施法单位碰撞效果,即可以穿人效果
	call SetUnitPathing(fadong_unit,false)
	//隐藏施法单位
	call ShowUnitHide(fadong_unit)
	//等待0.9秒
	call PolledWait(0.90)
	//移动单位 到指定坐标(立刻)。PolarProjectionBJ向指定方向位移900
	call SetUnitPositionLoc(fadong_unit,PolarProjectionBJ(GetUnitLoc(fadong_unit),900.00,jiaodu))
	//开启施法单位碰撞效果,即不能穿人
	call SetUnitPathing(fadong_unit,true)
	//显示单位
	call ShowUnitShow(fadong_unit)
	//玩家选定指定单位
	call SelectUnitForPlayerSingle(fadong_unit,fadong_player)
endfunction
//判断是否是发动了冲锋技能
function ChongFeng_Conditions takes nothing returns boolean
	if(GetSpellAbilityId()=='A06B')then
		return true
	endif
	return false
endfunction

//冲锋技能触发器
set gg_jn_chongfeng = CreateTrigger()
call TriggerRegisterPlayerUnitEventSimple(gg_jn_chongfeng,Player(1),EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterPlayerUnitEventSimple(gg_jn_chongfeng,Player(2),EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterPlayerUnitEventSimple(gg_jn_chongfeng,Player(3),EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterPlayerUnitEventSimple(gg_jn_chongfeng,Player(4),EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterPlayerUnitEventSimple(gg_jn_chongfeng,Player(5),EVENT_PLAYER_UNIT_SPELL_EFFECT)

call TriggerRegisterPlayerUnitEventSimple(gg_jn_chongfeng,Player(7),EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterPlayerUnitEventSimple(gg_jn_chongfeng,Player(8),EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterPlayerUnitEventSimple(gg_jn_chongfeng,Player(9),EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterPlayerUnitEventSimple(gg_jn_chongfeng,Player(10),EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterPlayerUnitEventSimple(gg_jn_chongfeng,Player(11),EVENT_PLAYER_UNIT_SPELL_EFFECT)

call TriggerAddCondition(gg_jn_chongfeng,Condition(function ChongFeng_Conditions))
call TriggerAddAction(gg_jn_chongfeng,function ChongFeng_actions)


  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值