Cokemonkey11
Spell Reviewer
- Joined
- May 9, 2006
- Messages
- 3,575
The title should be AKA what's wrong with this script?
Something wonderfully peculiar happens with this script.
Let's follow the following sequence of events:
* TestRecycle_get() 10 times
* TestRecycle_release() all 10 instances
* TestRecycle_get() 10 times
But what happens when I do that is peculiar:
* I get 10 "Got NEW ...." messages as expected
* I get 10 "Releaased ...." messages as expected
* I get 6 "Got ...." messages as expected - followed by 4 "Got <BLANK>" messages! Indicies 3->0 contain no unit!
I tried hooking RemoveUnit to see if some other code is obscuring this script but the heroes in indicies 3->0 (the first 4 heroes _release()'d) disappear.
I am completely perplexed now. I also made a test to verify that creating/killing 20 heroes does NOT remove them from the game.
Edit: Here's the script I use it in:
JASS:
library TestRecycler requires Orianna
globals
private unit array oris
private integer index=-1
endglobals
public function release takes unit u returns nothing
if UnitAlive(u) then
call KillUnit(u)
endif
set index=index+1
set oris[index]=u
call BJDebugMsg("index = "+I2S(index)+"; Released: "+GetUnitName(oris[index]))
endfunction
public function get takes player owner returns unit
local unit u
if index>-1 then
set u=oris[index]
call SetUnitOwner(u,owner,true)
set index=index-1
call BJDebugMsg("index = "+I2S(index)+"; Got: "+GetUnitName(u))
else
set u=CreateUnit(owner,Orianna.ID,0.,0.,0.)
call KillUnit(u)
call BJDebugMsg("index = "+I2S(index)+"; Got NEW: "+GetUnitName(u))
endif
return u
endfunction
endlibrary
Something wonderfully peculiar happens with this script.
Let's follow the following sequence of events:
* TestRecycle_get() 10 times
* TestRecycle_release() all 10 instances
* TestRecycle_get() 10 times
But what happens when I do that is peculiar:
* I get 10 "Got NEW ...." messages as expected
* I get 10 "Releaased ...." messages as expected
* I get 6 "Got ...." messages as expected - followed by 4 "Got <BLANK>" messages! Indicies 3->0 contain no unit!
I tried hooking RemoveUnit to see if some other code is obscuring this script but the heroes in indicies 3->0 (the first 4 heroes _release()'d) disappear.
I am completely perplexed now. I also made a test to verify that creating/killing 20 heroes does NOT remove them from the game.
Edit: Here's the script I use it in:
JASS:
//Big Fling Test
//10 Oriannas Command: Attack to a location near a unit, and they all
//Command: Shockwave at the same time, sending it flying
scope test2 initializer i
globals
private constant integer DH_ID='Edem'
private constant real NEW_X=-785.
private constant real NEW_Y=-585.
private constant real CLOCK_PERIOD=1./30.
private boolean ready=true
private unit array oris[10]
private unit dh
private timer time=CreateTimer()
private integer kf
endglobals
private function p takes nothing returns nothing
local integer index=0
set kf=kf+1
if kf==15 then
loop
exitwhen index>9
call IssuePointOrder(oris[index],"absorb",NEW_X-128.,NEW_Y-256.)
set index=index+1
endloop
elseif kf==45 then
loop
exitwhen index>9
call IssueImmediateOrder(oris[index],"ambush")
set index=index+1
endloop
elseif kf==150 then
call RemoveUnit(dh)
loop
exitwhen index>9
call TestRecycler_release(oris[index])
set index=index+1
endloop
call PauseTimer(time)
set ready=true
endif
endfunction
private function c takes nothing returns boolean
local integer index=0
if Game.singlePlayer and ready then
set ready=false
call PanCameraToTimed(NEW_X,NEW_Y,0.)
loop
exitwhen index>9
set oris[index]=TestRecycler_get(Player(1))
if index<5 then
call ReviveHero(oris[index],NEW_X-100*index,NEW_Y+490.,false)
else
call ReviveHero(oris[index],NEW_X-100*(index-5),NEW_Y+390.,false)
endif
call UnitRemoveAbility(oris[index],'Aatk')
call SetHeroLevel(oris[index],6,false)
call SelectHeroSkill(oris[index],Orianna.COMMAND_SHOCKWAVE_ID)
call SelectHeroSkill(oris[index],Orianna.COMMAND_ATTACK_ID)
set index=index+1
endloop
set dh=CreateUnit(Player(2),DH_ID,NEW_X-256.,NEW_Y-256.,270.)
call UnitRemoveAbility(dh,'Aatk')
set kf=0
call TimerStart(time,CLOCK_PERIOD,true,function p)
endif
return false
endfunction
private function i takes nothing returns nothing
local trigger t=CreateTrigger()
call TriggerRegisterPlayerChatEvent(t,Player(0),"-test2",true)
call TriggerAddCondition(t,Condition(function c))
set t=null
endfunction
endscope
Last edited by a moderator: