• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Thunder Storm Spell

Status
Not open for further replies.
Level 8
Joined
May 21, 2008
Messages
218
JASS:
function Trig_ThunderStorm_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A006' then
        return true
    endif
    return false
endfunction

function Trig_ThunderStorm_pause_unit takes nothing returns nothing
local unit c = udg_temp_unit
call PauseUnit( c, true )
call TriggerSleepAction(1.50)
call PauseUnit( c, false )
endfunction

function Trig_ThunderStorm_function takes nothing returns nothing
local unit c = udg_temp_unit
local unit t = udg_temp_unit2
local integer maxloop = udg_temp_integer
local integer i = 0
local widget w = t
local lightning l
local location lc = GetUnitLoc(c)
local location lt = GetUnitLoc(t)
local effect e = AddSpecialEffectLoc("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl", lc)
loop
    exitwhen i == maxloop
    if GetUnitState( t, UNIT_STATE_LIFE) >= 0 then
        set lc = GetUnitLoc(c)
        set lt = GetUnitLoc(t)
        call UnitDamageTarget( c, w, 30.00, false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_LIGHTNING, WEAPON_TYPE_WHOKNOWS)
        set l = AddLightningEx( "CLPB", true, GetLocationX(lc), GetLocationY(lc), GetLocationZ(lc), GetLocationX(lt), GetLocationY(lt), GetLocationZ(lt))
        call TriggerSleepAction(0.65)
        call DestroyLightning(l)
        call TriggerSleepAction(0.35)
        else 
    endif
    set i = i + 1
endloop
set c = null
set t = null
set w = null
call DestroyLightning(l)
set l = null
call RemoveLocation(lc)
set lc = null
call RemoveLocation(lt)
set lt = null
call DestroyEffect(e)
set e = null
endfunction

function Trig_ThunderStorm_Actions takes nothing returns nothing
local unit c = GetSpellAbilityUnit()
local unit t = GetSpellTargetUnit()
local integer l = GetUnitAbilityLevel( c, 'A006')
local integer maxloop
if l == 1 then
set maxloop = 3
elseif l == 2 then
set maxloop = 5
elseif l == 3 then
set maxloop = 7
endif
set udg_temp_integer = maxloop
set udg_temp_unit = c
set udg_temp_unit2 = t
call ExecuteFunc("Trig_ThunderStorm_function")
call ExecuteFunc("Trig_ThunderStorm_pause_unit")
set c = null
set t = null
endfunction

//===========================================================================
function InitTrig_ThunderStorm takes nothing returns nothing
    set gg_trg_ThunderStorm = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_ThunderStorm, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_ThunderStorm, Condition( function Trig_ThunderStorm_Conditions ) )
    call TriggerAddAction( gg_trg_ThunderStorm, function Trig_ThunderStorm_Actions )
    call Preload("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl")
endfunction

When I use this spell it keeps going after then unit until it's dead. A clue might be the unit pauses multiple times when I only want it to pause at the beginning for casting time.

Whats wrong?
 
Level 3
Joined
Feb 20, 2007
Messages
32
You are pausing the casting during it's cast phase which is triggering EVENT_SPELL_TARGET_UNIT. Try using EVENT_PLAYER_UNIT__SPELL_FINISH.

Also, do not null the variables 't' and 'c' (Your temporary units) it will cause the handle to leak, they do not need to be nullified unless being removed.

'Hopefully that fixs the problem
-Blackroot.
 
Status
Not open for further replies.
Top