[JASS] A little difficultyies

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
Hey Im making a MultiFirebolt spell. Im new at this. This is what i have. My problem is, It wont show animation/stun/damage(None dealt(Yes I checked the properties of the spell.))
JASS:
function Trig_Stun_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A01C' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Stun_Actions takes nothing returns nothing
    local unit cast
    local location p
    local group g
    local unit u
    local unit dumb
    set cast = GetTriggerUnit()
    set g = GetUnitsInRangeOfLocAll(512.00, GetSpellTargetLoc())
    set u = FirstOfGroup(g)
    loop
        exitwhen u==null
        set u = FirstOfGroup(g)
        set dumb = CreateUnitAtLoc(GetOwningPlayer(cast), 'h01X', GetUnitLoc(cast), 0.00)
        call UnitAddAbilityBJ('A00F', GetTriggerUnit() )
        call IssueTargetOrderBJ(dumb, "firebolt", u)        
        call UnitApplyTimedLifeBJ(3, 'BTLF', dumb)
        call GroupRemoveUnit(g,u)
    endloop
    set g = null
    set dumb = null
    set cast = null
    set p = null
endfunction

//===========================================================================
function InitTrig_Stun takes nothing returns nothing
    set gg_trg_Stun = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Stun, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Stun, Condition( function Trig_Stun_Conditions ) )
    call TriggerAddAction( gg_trg_Stun, function Trig_Stun_Actions )
endfunction
What am I doing wrong?

EDIT - How do I remove the BJs?
 
Last edited:
Level 19
Joined
Feb 25, 2009
Messages
2,004
I don't see any usage of "p" here...
GetTriggerUnit() returns the caster, not the dummy.

JASS:
GetUnitLoc(cast)
This should be declared, maybe here you want to use "p" ?

JASS:
set g = GetUnitsInRangeOfLocAll(512.00, GetSpellTargetLoc())
This will pick dead units, mechanincals, immune and allies.
 
Here's is an optimized version of your script (removed all BJ's and fixed leaks, also fixed your loop).

It may be the solution to your problem.

JASS:
function Trig_Stun_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A01C'
endfunction

function Trig_Filter_True takes nothing returns boolean
    return true
endfunction

function Trig_Stun_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local location p = GetSpellTargetLoc()
    local group g
    local unit u
    local unit dumb
    call GroupEnumUnitsInRangeOfLoc(g, p, 512, Filter(function Trig_Filter_True))
    loop
        set u = FirstOfGroup(g)
        exitwhen u==null
        set dumb = CreateUnit(GetOwningPlayer(cast), 'h01X', GetUnitX(cast), GetUnitY(cast), 0.00)
        call UnitAddAbility(cast, 'A00F')
        call IssueTargetOrder(dumb, "firebolt", u)
        call UnitApplyTimedLife(dumb, 'BTLF', 3)
        call GroupRemoveUnit(g,u)
    endloop
    call RemoveLocation(p)
    call DestroyGroup(g)
    set g = null
    set dumb = null
    set cast = null
    set p = null
endfunction

//===========================================================================
function InitTrig_Stun takes nothing returns nothing
    set gg_trg_Stun = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Stun, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Stun, Condition( function Trig_Stun_Conditions ) )
    call TriggerAddAction( gg_trg_Stun, function Trig_Stun_Actions )
endfunction
 
Status
Not open for further replies.
Top