Moon_Raven
New Member
- Reaction score
- 8
Ok, so here is one of the first spells I made by my self in JASS. So, could you please check it, by checking I primarely mean leaks, and I am unsure about using that unit array. It makes nulling easier but still does it consume too much memory? The spell should Create 1/2/3 unkillable and unselectable and immovable hydras(like in Diablo 2), so they have locust and invurnerable in the editor(like that matters anyway). So here is the code:
I also doubt the Hydras method of working(if/then/else) is the best one available...
JASS:
function Hydras takes integer n returns integer
if(n==1) then
return 039;o001039;
elseif(n==2) then
return 039;o002039;
else
return 039;o000039;
endif
endfunction
function Trig_Hydra_Actions takes nothing returns nothing
local integer n = 1
local location l = GetSpellTargetLoc()
local real x
local real y = GetLocationY(l)
local integer level = GetUnitAbilityLevel(GetTriggerUnit(),039;A003039;)
local unit array u
set u[4] = GetTriggerUnit()
loop
exitwhen(n==level+1)
set x = GetLocationX(l)
set u[n] = CreateUnitAtLoc(GetOwningPlayer(u[4]),Hydras(level),l,0)
call UnitApplyTimedLife(u[n],039;BTLF039;,30)
set n = n+1
set l = Location(x+100,y)
endloop
call RemoveLocation(l)
set u[1] = null
set u[2] = null
set u[3] = null
set u[4] = null
set l = null
endfunction
function CheckSpellHydra takes nothing returns boolean
return (GetSpellAbilityId()==039;A003039;)
endfunction
//===========================================================================
function InitTrig_Hydra takes nothing returns nothing
set gg_trg_Hydra = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg_trg_Hydra,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Hydra,Condition(function CheckSpellHydra))
call TriggerAddAction( gg_trg_Hydra, function Trig_Hydra_Actions )
set gg_trg_Hydra = null
endfunction
I also doubt the Hydras method of working(if/then/else) is the best one available...