• 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] Spell Help

Status
Not open for further replies.
Level 6
Joined
Sep 4, 2007
Messages
157
Im making a spell where a wisp is created and sending a chain Lighting effect to the units around the hero. Now my problem is the effect is not showing up but the units are damaged any help will be great. heres my code
JASS:
function NatureLightning_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A012'
endfunction

function Lighting_Filter takes nothing returns boolean
    return IsPlayerEnemy(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetFilterUnit())) and GetWidgetLife(GetFilterUnit()) > 0.405 and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)
endfunction

function NatureLightning_Actions takes nothing returns nothing
    local unit u1 = GetTriggerUnit()
    local unit u
    local unit f
    local integer i = GetUnitAbilityLevel(u1, 'A012')
    local effect e
    local lightning l
    local real x = GetUnitX(u1)
    local real y = GetUnitY(u1)
    local real x1
    local real y1
    local real x2
    local real y2
    local boolexpr b = Condition(function Lighting_Filter)
    local group g = CreateGroup()
    set e = AddSpecialEffectTarget("Abilities\\Spells\\Human\\MassTeleport\\MassTeleportCaster.mdl", u1, "origin")
    call GroupEnumUnitsInRange(g, x, y, 300.00, b)
    set u = CreateUnit(GetOwningPlayer(u1), 'e000', x, y, bj_UNIT_FACING)
    set x1 = GetUnitX(u)
    set y1 = GetUnitY(u)
    loop
        set f = FirstOfGroup(g)
        set x2 = GetUnitX(f)
        set y2 = GetUnitY(f)
        exitwhen f == null
        set l = AddLightning("CLPB", false, x1, y1, x2, y2)
        call MoveLightning(l, true, x1, y1, x2, y2)
        call UnitDamageTarget(u, f, 25*i, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null)
        call GroupRemoveUnit(g, f)
        call DestroyLightning(l)
    endloop
    call RemoveUnit(u)
    set u = null
    set u1 = null
    call DestroyEffect(e)
    set e = null
    set l = null
    set g = null
    call DestroyGroup(g)
    set g = null
    call DestroyBoolExpr(b)
    set b = null
endfunction

//===========================================================================
function InitTrig_NatureLighting takes nothing returns nothing
    set gg_trg_NatureLighting = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_NatureLighting, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_NatureLighting, Condition( function NatureLightning_Conditions ) )
    call TriggerAddAction( gg_trg_NatureLighting, function NatureLightning_Actions )
endfunction
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Maybe because you destroy them immediately after creating them.
P.s. Be careful with destroying variables of type boolexpr, if you do not know you are doing it may have bad side effects.
 
Level 5
Joined
Jan 6, 2006
Messages
106
Probably it's because you destroyed the lightning effect immediately after you created it. Try to assign a timer to it and see if it fixes it.

For me, I run the lightning effects in a looping function, and I only destroy the effect on the next loop of the function instead of the same loop.

If it still does not work try moving the lightning instead of destroying it. Then destroy it after your spell finished running entirely.
 
Status
Not open for further replies.
Top