• 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] My spell is 50/50

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2008
Messages
253
I'm making a spell called Static Disruption, based on thunder clap and all enemy units that are in 600 range should get Static Disruption Debuff (based on cripple).

The problem is that when I use the spell it sometimes works but sometimes it doesn't and I have no idea why it does that...

Could someone help me?

JASS:
function Trig_Static_Disruption_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A009' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Static_Disruption_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location loc = GetUnitLoc(caster)
    local group g = GetUnitsInRangeOfLocAll(600, loc)
    local unit u
    local unit dumb
    loop
        set u = FirstOfGroup(g)
        exitwhen u==null
        if IsUnitEnemy(u, GetOwningPlayer(caster))==true then
            call GroupRemoveUnit(g,u)
            set dumb = CreateUnitAtLoc(GetOwningPlayer(caster), 'h00B', GetUnitLoc(u), 0.00)
            call IssueTargetOrderBJ(dumb, "frostarmor" , u)
            set dumb = null
        endif
    endloop
    call TriggerSleepAction(0.5)
    call RemoveLocation(loc)
    call DestroyGroup(g)
    call RemoveUnit(dumb)
    set dumb = null
    set g = null
    set u = null
    set caster = null
endfunction

//===========================================================================
function InitTrig_Static_Disruption takes nothing returns nothing
    set gg_trg_Static_Disruption = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Static_Disruption, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Static_Disruption, Condition( function Trig_Static_Disruption_Conditions ) )
    call TriggerAddAction( gg_trg_Static_Disruption, function Trig_Static_Disruption_Actions )
endfunction
 
this should do it...
JASS:
function Trig_Static_Disruption_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A009' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Static_Disruption_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()//set caster = the triggering unit
    //using coordinates instead of location
    local real x = GetUnitX(caster)//x coordinate
    local real y = GetUnitY(caster)//y coordinate
    local group g = CreateGroup()//for loop
    local unit u//for loop
    local integer i = 0//for loop
    local unit array dumb//dummy units
    
    call GroupEnumUnitsInRange(g, x, y, 600, null)//get all the units within 600
    //of (x,y) (the coordinates)
    
    loop
    
        set u = FirstOfGroup(g)//performing actions on this unit
        
        exitwhen u==null//exit when u is null, no more units to
        //perform actions on
        
        if IsUnitEnemy(u, GetOwningPlayer(caster)) then//check that u is an enemy
            set dumb[i] = CreateUnit(GetOwningPlayer(caster), 'h00B', GetUnitX(u), GetUnitY(u) 0.00)
            //create dummy unit at position of target
            call IssueTargetOrder(dumb[i], "frostarmor" , u) //make the dummy cast
            //the dummy spell
            set i = i+1 //increase the index
        endif
        
        call GroupRemoveUnit(g,u)//remove the unit from the group to advance the loop
        
    endloop
    
    call TriggerSleepAction(0.5)//wait 0.5 seconds before removing the dummy
    
    loop
    
        exitwhen i == 0//exit when we have run through all the indexes
        
        call RemoveUnit(dumb[i])//remove the dummy at current index
        set dumb[i] = null//null the dummy to avoid leaks
        set i = i-1//reduce i to advance the loop
        
    endloop
    
    
    call DestroyGroup(g)//destroy the group used
    set g = null//null the group to avoid leaks
    set u = null//null unit to avoid leaks
    set caster = null//null the caster variable to avoid leaks
endfunction

//===========================================================================
function InitTrig_Static_Disruption takes nothing returns nothing
    set gg_trg_Static_Disruption = CreateTrigger( )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Static_Disruption, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Static_Disruption, Condition( function Trig_Static_Disruption_Conditions ) )
    call TriggerAddAction( gg_trg_Static_Disruption, function Trig_Static_Disruption_Actions )
endfunction
 
Level 9
Joined
Dec 26, 2007
Messages
202
JASS:
function Trig_Static_Disruption_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='A009'
endfunction

function Trig_Static_Disruption_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local location loc = GetUnitLoc(caster)
    local group g=CreateGroup()
    local unit u
    local unit dumb
    local boolexpr b=null
    call GroupEnumUnitsInRange(g,GetLocationX(loc),GetLocationY(loc),600,b)
    loop
        set u = FirstOfGroup(g)
        exitwhen u==null
        if IsUnitEnemy(u, GetOwningPlayer(caster))==true then
            call GroupRemoveUnit(g,u)
            set dumb = CreateUnitAtLoc(GetOwningPlayer(caster), 'h00B', GetUnitLoc(u), 0.00)
            call IssueTargetOrder(dumb, "frostarmor" , u)
            set dumb = null
        endif
    endloop
    call TriggerSleepAction(0.5)
    call RemoveLocation(loc)
    call DestroyGroup(g)
    call RemoveUnit(dumb)
    set dumb = null
    set g = null
    set u = null
    set caster = null
endfunction

//===========================================================================
function InitTrig_Static_Disruption takes nothing returns nothing
    set gg_trg_Static_Disruption = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Static_Disruption, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Static_Disruption, Condition( function Trig_Static_Disruption_Conditions ) )
    call TriggerAddAction( gg_trg_Static_Disruption, function Trig_Static_Disruption_Actions )
endfunction

Look ma user title.
 
Status
Not open for further replies.
Top