Matemeo
New Member
- Reaction score
- 20
I'm making a spell that shoots out orbs, and as it passes near enemies it'll randomly zap one till it gets to the end of its path. Heres the spell
When I test map to test the spell every .25 seconds I get a Double Free of Type: Orbs, error spamming on my screen. Can anyone shed some light on what this is? Any help is appreciated, thanks in advance.
JASS:
scope Orbs
globals
constant integer ORBS_AID = 039;A005039;
constant integer ORBS_UID =039;n000039;
constant integer DUMMY_UID = 039;hmpr039;
constant integer CL_AID = 039;A006039;
endglobals
struct Orbs
unit caster
unit Orb
real x
real y
endstruct
private function o_check takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit())) and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE) > .465
endfunction
private function t_callback takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit temp
local group g = CreateGroup()
local Orbs o = GetTimerStructA(t)
local real x = GetUnitX(<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite12" alt="o_O" title="Er... what? o_O" loading="lazy" data-shortname="o_O" />rb)
local real y = GetUnitY(<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite12" alt="o_O" title="Er... what? o_O" loading="lazy" data-shortname="o_O" />rb)
local unit dummy = CreateUnit(GetOwningPlayer(GetTriggerUnit()),DUMMY_UID,x,y,270.0)
call UnitAddAbility(dummy,CL_AID)
//Check to see if orb is at the end of its path
if x < o.x + 100 and x > o.x - 100 and y > o.y - 100 and y < o.y + 100 then
call PauseTimer(t)
call ClearTimerStructA(t)
call DestroyTimer(t)
set t =null
else
call GroupEnumUnitsInRange(g,x,y,300.0,Condition(function o_check))
set temp = GroupPickRandomUnit(g)
call IssueTargetOrder(dummy,"chainlightning",temp)
call RemoveUnit(dummy)
endif
set t = null
call DestroyGroup(g)
set g =null
set temp =null
call o.destroy()
set dummy = null
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == ORBS_AID
endfunction
private function Actions takes nothing returns nothing
local Orbs o = Orbs.create()
local timer t = CreateTimer()
local location l = GetSpellTargetLoc()
local unit Orb
set o.caster = GetTriggerUnit()
set o.x = GetLocationX(l)
set o.y = GetLocationY(l)
set Orb = CreateUnit(GetOwningPlayer(o.caster),ORBS_UID,GetUnitX(o.caster),GetUnitY(o.caster),270.0)
set <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite12" alt="o_O" title="Er... what? o_O" loading="lazy" data-shortname="o_O" />rb = Orb
call IssuePointOrder(Orb,"move",o.x,o.y)
call SetTimerStructA(t,o)
call o.destroy()
call TimerStart(t,.25,true,function t_callback)
set t = null
call RemoveLocation(l)
set l = null
set Orb = null
endfunction
//===========================================================================
public function InitTrig takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(t, Condition( function Conditions ) )
call TriggerAddAction(t, function Actions )
endfunction
endscope
When I test map to test the spell every .25 seconds I get a Double Free of Type: Orbs, error spamming on my screen. Can anyone shed some light on what this is? Any help is appreciated, thanks in advance.