冲锋技能jass脚本重写
程序员文章站
2024-03-17 19:34:04
...
优化前的脚本:
//冲锋技能
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)
推荐阅读