• 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] Simple Jass Code

Status
Not open for further replies.
Ok, I made this code is JASS and i was wondering if it will leak or not
JASS:
function Trig_Chain_Lightning_Caster_no_leak_Conditions takes nothing returns boolean
        return  ( GetUnitTypeId(GetAttacker()) == 'hC36' ) )
endfunction

function Trig_Chain_Lightning_Caster_no_leak_Actions takes nothing returns nothing
    set udg_TempLoc = GetUnitLoc(GetAttacker())
    call CreateNUnitsAtLoc( 1, 'h00I', GetOwningPlayer(GetAttacker()), udg_TempLoc, bj_UNIT_FACING )
    call UnitAddAbilityBJ( 'ACcl', GetLastCreatedUnit() )
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "chainlightning", GetAttackedUnitBJ() )
    call UnitApplyTimedLifeBJ( 0.50, 'BTLF', GetLastCreatedUnit() )
    set TempLoc = null
endfunction

//===========================================================================
function InitTrig_Chain_Lightning_Caster_no_leak takes nothing returns nothing
    set gg_trg_Chain_Lightning_Caster_no_leak = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Chain_Lightning_Caster_no_leak, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Chain_Lightning_Caster_no_leak, Condition( function Trig_Chain_Lightning_Caster_no_leak_Conditions ) )
    call TriggerAddAction( gg_trg_Chain_Lightning_Caster_no_leak, function Trig_Chain_Lightning_Caster_no_leak_Actions )
endfunction
 
Level 19
Joined
Nov 16, 2006
Messages
2,165
Meh, you just converted GUI to custom script.
Just use custom scripts if u don't know JASS.
Anyway I doubt that
JASS:
set udg_TempLoc = GetUnitLoc(GetAttacker())
and
JASS:
set TempLoc = null
will work anyway.
It should be:
JASS:
local location TempLoc = GetUnitLoc(GetAttacker())
before
JASS:
Set TempLoc = null
you should add:
JASS:
call RemoveLocation(TempLoc)
and then :
JASS:
Set TempLoc = null
 
Last edited:
Level 40
Joined
Dec 14, 2005
Messages
10,532
*Ahem* there is no such thing as a 'point' in JASS. It's called a location *Ahem*

By the way, your code seems to be cleaner than GUI in some places and messier in others.

A fully fixed up version of that would be;

JASS:
function Trig_Chain_Lightning_Caster_no_leak_Conditions takes nothing returns boolean
return GetUnitTypeId(GetAttacker()) == 'hC36'
endfunction

function Trig_Chain_Lightning_Caster_no_leak_Actions takes nothing returns nothing
local unit u = CreateUnit( GetOwningPlayer( GetAttacker() ), 'h00I', GetUnitX( GetAttacker() ), GetUnitY( GetAttacker() ), 0 )
call UnitAddAbility( u, 'ACcl' )
call IssueTargetOrder( u, "chainlightning", GetTriggerUnit() )
call UnitApplyTimedLife( u, 'BTlf', .5 )
set u = null
     endfunction

 function InitTrig_Chain_Lightning_Caster_no_leak takes nothing returns nothing
set gg_trg_Chain_Lightning_Caster_no_leak = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_Chain_Lightning_Caster_no_leak, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Chain_Lightning_Caster_no_leak, Condition( function Trig_Chain_Lightning_Caster_no_leak_Conditions ) )
call TriggerAddAction( gg_trg_Chain_Lightning_Caster_no_leak, function Trig_Chain_Lightning_Caster_no_leak_Actions )
endfunction

As you can see, we can A) avoid even touching locations, and B) use the advantages of JASS to skip globals and BJs.

If you actually plan on using JASS more, try to learn to use X/Y coordinates, as they are faster and don't leak.
 
Status
Not open for further replies.
Top