找回密码
 点一下
查看: 2170|回复: 5

set null导致的WAR3崩溃...

[复制链接]
发表于 2011-6-22 22:46:33 | 显示全部楼层 |阅读模式
研究了一天还是没有找到原因 我实在是没有头绪...
这个技能大概是创建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]
发表于 2011-6-22 23:24:01 | 显示全部楼层
难道是传说中的rpbug?
话说其实不必每次新建trigger,直接以timer的handle作为索引存参数就可以了。
回复

使用道具 举报

发表于 2011-6-22 23:39:11 | 显示全部楼层
就是被那谁成为rpbug的那个

方法1:TriggerAddCondition改成TriggerAddAction,在所有触发被干掉时就不会崩了
方法2:有过测试贴表示Condition不必手动清除,这样也不会崩
方法3:我记得再开计时器延时清除条件也不会崩
回复

使用道具 举报

 楼主| 发表于 2011-6-23 00:00:27 | 显示全部楼层
这个应该不是RPBUG吧
我也试过写到ACTION里面 还是一样
删除的是另一个触发 并没有在条件里清除条件本身
回复

使用道具 举报

发表于 2011-6-23 00:24:11 | 显示全部楼层
嗯,好像没看仔细
回复

使用道具 举报

发表于 2011-6-23 06:02:27 | 显示全部楼层
方便的话把原图贴上来吧
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-11-21 23:02 , Processed in 0.407494 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表