- Joined
- Sep 25, 2005
- Messages
- 71
[Fixed]Issue with Instancing?
Ahoy. I uh, mostly got together timer usage in JASS but am now starting to hit a bit of a pickle. When there are multiple instances of the ability (which has various text commands to check what's going up,) the current instance of the ability overrides the previous, finishing up, then the last instance finishes, etc.
I used abomination model files for the dummies just to visually check what was going on, and yeah, sometimes they spawn on dead creeps because the target died after a current usage of the ability happened.
The ability is supposed to periodically spawn dummies which mana burn the target.
Could someone point out where I went wrong in terms of keeping it multi-use?
Ahoy. I uh, mostly got together timer usage in JASS but am now starting to hit a bit of a pickle. When there are multiple instances of the ability (which has various text commands to check what's going up,) the current instance of the ability overrides the previous, finishing up, then the last instance finishes, etc.
I used abomination model files for the dummies just to visually check what was going on, and yeah, sometimes they spawn on dead creeps because the target died after a current usage of the ability happened.
The ability is supposed to periodically spawn dummies which mana burn the target.
Could someone point out where I went wrong in terms of keeping it multi-use?
JASS:
function Trig_Zap_Test_Conditions takes nothing returns boolean//GUI setup
if ( not ( GetSpellAbilityId() == 'Awfb' ) ) then
return false
endif
return true
endfunction
globals
timer burnTimer=CreateTimer() //Timer for our stuff
real INTERVAL=0.50 //Half-second intervals between burns
target array targetArray //Array of the target struct
integer instancesOfBurn=0 //Necessary to avoid bad things, keeps track of whether stuff is happening
endglobals
struct target
unit t
unit caster
integer burnsNumber
endstruct
function BurnInitiate takes nothing returns nothing //Actual part that does something
local target targetUnit
local integer i=0
local integer burns
local unit dummy
call DisplayTextToForce( GetPlayersAll(),"Timer elapsed"+R2S(INTERVAL))
loop
exitwhen i>=instancesOfBurn
set i=i+1
endloop
set targetUnit=targetArray[i]
set burns=targetArray[i].burnsNumber
set dummy=CreateUnitAtLoc(GetOwningPlayer(targetUnit.caster),'o000',GetUnitLoc(targetUnit.t),GetUnitFacing(targetUnit.t))
call UnitApplyTimedLife(dummy, 'B001', 2.0)
call IssueTargetOrder(dummy, "manaburn",targetUnit.t)
set targetArray[i].burnsNumber=targetArray[i].burnsNumber-1
call DisplayTextToForce( GetPlayersAll(),"loop, (burns left, iteration) "+I2S(burns)+" "+I2S(i))
if burns<=0 then
set instancesOfBurn=instancesOfBurn-1
set targetArray[i]=targetArray[instancesOfBurn-1]
call targetUnit.destroy()
endif
if instancesOfBurn==0 then
call PauseTimer(burnTimer)
endif
call DisplayTextToForce( GetPlayersAll(),"Instances after:"+" "+I2S(instancesOfBurn))
endfunction
function Trig_Zap_Test_Actions takes nothing returns nothing //GUI converted
local target targetUnit=target.create()
set targetUnit.t=GetSpellTargetUnit()
set targetUnit.caster=GetTriggerUnit()
set targetUnit.burnsNumber=12
call DisplayTextToForce( GetPlayersAll(),"Triggered")
if instancesOfBurn<=0 then
call TimerStart(burnTimer, INTERVAL, true, function BurnInitiate)
endif
set instancesOfBurn=instancesOfBurn+1
set targetArray[instancesOfBurn]=targetUnit
call DisplayTextToForce( GetPlayersAll(),"Instances, burns:"+" "+I2S(instancesOfBurn)+" "+I2S(targetUnit.burnsNumber))
endfunction
//===========================================================================
function InitTrig_Zap_Test takes nothing returns nothing//GUI setup
set gg_trg_Zap_Test = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Zap_Test, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Zap_Test, Condition( function Trig_Zap_Test_Conditions ) )
call TriggerAddAction( gg_trg_Zap_Test, function Trig_Zap_Test_Actions )
endfunction
Attachments
Last edited: