• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[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