|
研究了一天还是没有找到原因 我实在是没有头绪...
这个技能大概是创建3个单位来为自己吸收伤害
以下触发在最后一个单位吸收完伤害死亡时会崩WAR3
但是如果把ST_XS函数里最后的
set mj[0]=null
set mj[1]=null
set mj[2]=null
这3行去掉 就没有任何问题
mj是个单位数组 是个局部变量 set null应该没有任何影响啊?
还是说其他地方出了问题呢?
[jass]
function ST_DQ takes nothing returns nothing
local timer t=GetExpiredTimer()
local trigger tg=LoadTriggerHandle(udg_hs,GetHandleId(t),0)
local triggeraction ta=LoadTriggerActionHandle(udg_hs,GetHandleId(t),1)
call DestroyLightning(LoadLightningHandle(udg_hs,GetHandleId(tg),3))
call DestroyLightning(LoadLightningHandle(udg_hs,GetHandleId(tg),4))
call DestroyLightning(LoadLightningHandle(udg_hs,GetHandleId(tg),5))
call FlushChildHashtable(udg_hs,GetHandleId(tg))
call TriggerRemoveAction(tg,ta)
call DestroyTrigger(tg)
call PauseTimer(t)
call FlushChildHashtable(udg_hs,GetHandleId(t))
call DestroyTimer(t)
set t=null
set tg=null
set ta=null
endfunction
function ST_Damage takes unit u,real damage,unit tu returns real
local real sm=GetUnitState(tu,UNIT_STATE_LIFE)
if IsUnitAliveBJ(tu) then
call UnitDamageTarget(u,tu,damage,true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_WHOKNOWS)
return damage-sm
endif
return damage
endfunction
function ST_XS takes nothing returns nothing
local trigger tg=GetTriggeringTrigger()
local unit u=GetTriggerUnit()
local unit lu=GetEventDamageSource()
local real sh=GetEventDamage()
local real lx=LoadReal(udg_hs,GetHandleId(tg),6)
local real rx=LoadReal(udg_hs,GetHandleId(tg),7)
local real y=LoadReal(udg_hs,GetHandleId(tg),8)
local timer t
local unit array mj
if GetUnitX(u)>lx and GetUnitX(u)<rx and GetUnitY(u)>y and GetUnitY(u)<y+SquareRoot(3)*(GetUnitX(u)-lx) and GetUnitY(u)<y+SquareRoot(3)*(rx-GetUnitX(u)) then
set mj[0]=LoadUnitHandle(udg_hs,GetHandleId(tg),0)
set mj[1]=LoadUnitHandle(udg_hs,GetHandleId(tg),1)
set mj[2]=LoadUnitHandle(udg_hs,GetHandleId(tg),2)
call SetUnitLifeBJ(u,GetUnitState(u,UNIT_STATE_LIFE)+sh)
set sh=ST_Damage(lu,sh,mj[0])
if sh>0 then
set sh=ST_Damage(lu,sh,mj[1])
if sh>0 then
set sh=ST_Damage(lu,sh,mj[2])
if sh>0 then
call DestroyLightning(LoadLightningHandle(udg_hs,GetHandleId(tg),3))
call DestroyLightning(LoadLightningHandle(udg_hs,GetHandleId(tg),4))
call DestroyLightning(LoadLightningHandle(udg_hs,GetHandleId(tg),5))
set t=LoadTimerHandle(udg_hs,GetHandleId(tg),9)
call FlushChildHashtable(udg_hs,GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_hs,GetHandleId(tg))
call TriggerClearActions(tg)
call DestroyTrigger(tg)
endif
endif
endif
endif
set tg=null
set u=null
set lu=null
set t=null
set mj[0]=null
set mj[1]=null
set mj[2]=null
endfunction
function ST_A takes nothing returns boolean
local unit array mj
local unit u=GetTriggerUnit()
local integer i
local integer j
local trigger tg=CreateTrigger()
local triggeraction ta=TriggerAddAction(tg,function ST_XS)
local lightning array l
local timer t=CreateTimer()
if GetSpellAbilityId() == 'A000' then
set mj[0]=CreateUnit(GetOwningPlayer(u),'e000',GetUnitX(u),GetUnitY(u)+800/SquareRoot(3),0)
set mj[1]=CreateUnit(GetOwningPlayer(u),'e000',GetUnitX(u)-400,GetUnitY(u)-400/SquareRoot(3),0)
set mj[2]=CreateUnit(GetOwningPlayer(u),'e000',GetUnitX(u)+400,GetUnitY(u)-400/SquareRoot(3),0)
set i=0
loop
exitwhen i>2
set j=GetUnitAbilityLevel(u,'A000')
loop
exitwhen j<2
call UnitAddAbility(mj,'A001')
call SetUnitAbilityLevel(mj,'A001',2)
call UnitRemoveAbility(mj,'A001')
set j=j-1
endloop
call UnitApplyTimedLife(mj,'BHwe',GetUnitAbilityLevel(u,'A000')*2+3)
set i=i+1
endloop
call TriggerRegisterUnitEvent(tg,u,EVENT_UNIT_DAMAGED)
set l[0]=AddLightning("CLPB",false,GetUnitX(mj[0]),GetUnitY(mj[0]),GetUnitX(mj[1]),GetUnitY(mj[1]))
set l[1]=AddLightning("CLPB",false,GetUnitX(mj[0]),GetUnitY(mj[0]),GetUnitX(mj[2]),GetUnitY(mj[2]))
set l[2]=AddLightning("CLPB",false,GetUnitX(mj[1]),GetUnitY(mj[1]),GetUnitX(mj[2]),GetUnitY(mj[2]))
call SaveUnitHandle(udg_hs,GetHandleId(tg),0,mj[0])
call SaveUnitHandle(udg_hs,GetHandleId(tg),1,mj[1])
call SaveUnitHandle(udg_hs,GetHandleId(tg),2,mj[2])
call SaveLightningHandle(udg_hs,GetHandleId(tg),3,l[0])
call SaveLightningHandle(udg_hs,GetHandleId(tg),4,l[1])
call SaveLightningHandle(udg_hs,GetHandleId(tg),5,l[2])
call SaveReal(udg_hs,GetHandleId(tg),6,GetUnitX(mj[1]))
call SaveReal(udg_hs,GetHandleId(tg),7,GetUnitX(mj[2]))
call SaveReal(udg_hs,GetHandleId(tg),8,GetUnitY(mj[1]))
call SaveTimerHandle(udg_hs,GetHandleId(tg),9,t)
call SaveTriggerHandle(udg_hs,GetHandleId(t),0,tg)
call SaveTriggerActionHandle(udg_hs,GetHandleId(t),1,ta)
call TimerStart(t,GetUnitAbilityLevel(u,'A000')*2+3,false,function ST_DQ)
endif
set mj[0]=null
set mj[1]=null
set mj[2]=null
set u=null
set tg=null
set ta=null
set t=null
set l[0]=null
set l[1]=null
set l[2]=null
return false
endfunction
function InitTrig_ST takes nothing returns nothing
set gg_trg_ST = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ST, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_ST, Condition(function ST_A) )
endfunction
[/jass] |
|