- Joined
- Jan 12, 2010
- Messages
- 321
Hi can somebody look over this spell it is my first attempt to make a spell in jass so please don't moan about the style of writing. Okay the problem is that the spell only functions well when used first time and it only damages 3 instead of 4 units.
JASS:
function Trig_Nether_Swap_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'AOw2'
endfunction
function Trig_Nether_Swap_Actions takes nothing returns nothing
local unit c = GetTriggerUnit()
local real xc = GetUnitX(c)
local real yc = GetUnitY(c)
local real array life
local integer level = GetHeroLevel(c)
local real damage = level*500
local rect spellrect = Rect(xc-1000,yc-1000,xc+1000,yc+1000)
local unit array dummys
local group damagedunits = GetUnitsInRangeOfLocAll(512,GetUnitLoc(c))
local integer maxdamagedunits = level *4
local integer loophelp = 0
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 36
loop
exitwhen loophelp>=maxdamagedunits
set damagedunits = GetUnitsInRangeOfLocAll(512,GetUnitLoc(c))
set dummys[loophelp] = GroupPickRandomUnit(damagedunits)
set life[loophelp] = GetUnitState(dummys[loophelp],UNIT_STATE_LIFE)
call SetUnitState (dummys[loophelp],UNIT_STATE_LIFE,life[loophelp]-damage)
call GroupRemoveUnit (damagedunits,dummys[loophelp])
set dummys[loophelp] = null
set loophelp = loophelp+1
endloop
set loophelp = 0
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), PolarProjectionBJ(GetRectCenter(spellrect), 50.00, I2R(( GetForLoopIndexA() * ( 360 / 36 ) ))), bj_UNIT_FACING )
set dummys[bj_forLoopAIndex] = GetLastCreatedUnit()
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
loop
exitwhen bj_forLoopAIndexEnd < 0
call KillUnit(dummys[bj_forLoopAIndexEnd])
set dummys[bj_forLoopAIndexEnd] = null
set bj_forLoopAIndexEnd = bj_forLoopAIndexEnd - 1
endloop
set c = null
endfunction
//===========================================================================
function InitTrig_Nether_Swap takes nothing returns nothing
set gg_trg_Nether_Swap = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Nether_Swap, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Nether_Swap, Condition(function Trig_Nether_Swap_Conditions))
call TriggerAddAction(gg_trg_Nether_Swap, function Trig_Nether_Swap_Actions)
endfunction