• 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] Leak problem in Dota spells

Status
Not open for further replies.
Guys this is a spell made by emilj3 and changed by me. umilj3 made this spell from a dota map, however the spell he made had bugs and leak problems so serious that i was forced to change it.
Here is my correction.

JASS:
function SheepStrike_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00W'         
endfunction

function SheepStrike_Actions takes nothing returns nothing
    local location l = GetUnitLoc(GetTriggerUnit())
    local location m = GetSpellTargetLoc()
    local unit u = CreateUnit( GetOwningPlayer(GetTriggerUnit()), 'h01H', GetLocationX(l), GetLocationY(l), bj_UNIT_FACING)
    call UnitAddAbility(u, 'A01A')       
    call SetUnitAbilityLevelSwapped( 'A01A', u, GetUnitAbilityLevelSwapped('A00W', GetTriggerUnit()) ) 
    call IssuePointOrder( u, "stampede", GetLocationX(m), GetLocationY(m) )
    call UnitApplyTimedLife(u, 'BTLF', 35)
    call RemoveLocation(l)
    set l = null
    call RemoveLocation(m)
    set m = null
    set u = null
endfunction

//===========================================================================
function InitTrig_SheepStrike takes nothing returns nothing
    local trigger SheepStrike = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( SheepStrike, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( SheepStrike, Condition( function SheepStrike_Conditions ) )
    call TriggerAddAction( SheepStrike, function SheepStrike_Actions )
endfunction


Guys i have 2 questions, does my correction leak ?

And by the way i was forced to add an expiration timer to the dummy unit. The question is that because the dummy unit has 45 secs expirations timer, if it is nullified correctly.


Will this trigger nullify the local even if the unit still exists ?
Is the unit nullified when the expiration time ends, or before ?

I know this is confusing, but i need to know... anyway thx to emilj3 by creating the spell. However i must correct it ...
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Should work fine, but it could use a bit of improvement; mainly, if you're going to use X/Y already, stick with x/y. I also fixed all the BJs.

JASS:
function SheepStrike_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00W'         
endfunction

function SheepStrike_Actions takes nothing returns nothing
    local unit t = GetTriggerUnit()
    local location m = GetSpellTargetLoc()
    local unit u = CreateUnit( GetOwningPlayer(GetTriggerUnit()), 'h01H', GetUnitX(t),GetUnitY(t), 0)
    call UnitAddAbility(u, 'A01A')       
    call SetUnitAbilityLevel( u, 'A01A', GetUnitAbilityLevel(t,'A00W')) 
    call IssuePointOrder( u, "stampede", GetLocationX(m), GetLocationY(m) )
    call UnitApplyTimedLife(u, 'BTlf', 35)
    call RemoveLocation(m)
    set t = null
    set m = null
    set u = null
endfunction

//===========================================================================
function InitTrig_SheepStrike takes nothing returns nothing
    local trigger SheepStrike = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( SheepStrike, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( SheepStrike, Condition( function SheepStrike_Conditions ) )
    call TriggerAddAction( SheepStrike, function SheepStrike_Actions )
endfunction
 
mmmm i understand your changes. Thx by reply, and yes, it is a different version of March of the Machines. My spell consists in calling waves of flying sheeps to damage the opponent =). Very funny spell =P.

Thx for the correction PurplePoot, i will now try to contact emilj3 and tell him about the correction, i think the Hiveworkshop will benefit from this action as free leak and improved spells are something everyone wants.

Here the post i made, hope it helps.
http://www.hiveworkshop.com/resources_new/spells/706/
 
Last edited:
Status
Not open for further replies.
Top