1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Things That Leak

Discussion in 'Triggers & Scripts' started by Ralle, Jun 10, 2007.

  1. mecatronic

    mecatronic

    Joined:
    Jun 20, 2005
    Messages:
    112
    Resources:
    1
    Maps:
    1
    Resources:
    1
    since destroying the GetPlayersAll() results in many bugs, is it ok if I do this?

    Code (vJASS):
    function example takes nothing returns nothing
    local group local_group = GetPlayersAll()
    //do stuff..
    call DestroyForce(local_group)
    set local_group = null
    endfunction
     
  2. spiwn

    spiwn

    Joined:
    Apr 27, 2008
    Messages:
    1,228
    Resources:
    0
    Resources:
    0
    No.
    First of all that is a force.
    There is no point in destroying all players force as that will result in a game crash. If you are using a local variable for it, all you have to do is null it.
     
  3. mecatronic

    mecatronic

    Joined:
    Jun 20, 2005
    Messages:
    112
    Resources:
    1
    Maps:
    1
    Resources:
    1
    but won't this only destroy the content of the local variable?

    nvm, I misread it.
     
  4. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    No game crash I think. You just will never be able to use the "All players" force again.

    The reason is:
    GetPlayersAll() returns a global variable. It doesn't create a new force each time it's called, it's only 1 initialized variable. By setting another variable to GetPlayersAll(), you merely set pointers to the same force object. So since both pointers point to the same force variable, RemovingForce on any of those pointers will still remove the same actual force variable.
     
  5. spiwn

    spiwn

    Joined:
    Apr 27, 2008
    Messages:
    1,228
    Resources:
    0
    Resources:
    0
    Well, I read it somewhere and anturally assumed it was true.
    Never really tested it ;)
     
  6. calex3

    calex3

    Joined:
    Mar 2, 2009
    Messages:
    285
    Resources:
    3
    Spells:
    3
    Resources:
    3
    where can i find array leak tutorial....no i dont need it just tell me does leak this when i use point array.... how can i remove that point by using custom script
     
  7. Justify

    Justify

    Joined:
    Mar 16, 2008
    Messages:
    935
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    3
    Resources:
    5
    The same way then normal points?
    • Custom Script: call RemoveLocation(udg_MyPointArray[Number])

    Important variables for this are
    Code (vJASS):
    bj_forLoopAIndex
    bj_forLoopBIndex
     
  8. calex3

    calex3

    Joined:
    Mar 2, 2009
    Messages:
    285
    Resources:
    3
    Spells:
    3
    Resources:
    3
    can you tell me how to make spell MUI or MPI..... i mean i dont know what is mui or mpi can you tell me what do i need to do to make somespell at least MPI
     
  9. Justify

    Justify

    Joined:
    Mar 16, 2008
    Messages:
    935
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    3
    Resources:
    5
    MPI is Multi Player Instancable, meaning that all 16 players (since 16 is the maximum in wc3) can cast the spell at the same time without bugs, with a single unit per player.
    MUI is Multi Unit Instancable, meaning that an infinite amount of units can cast it at the same time. Most spells are capped to 8191 because of array, but I've never seen a map where a spell is casted so often.

    You need arrays for this and THIS^^: http://www.hiveworkshop.com/forums/f269/triggering-scripting-tutorials-62672/
     
  10. Gamecrafter_DK

    Gamecrafter_DK

    Joined:
    Sep 25, 2007
    Messages:
    1,235
    Resources:
    3
    Maps:
    1
    Tutorials:
    2
    Resources:
    3
    I find this Kinda hard to understand, can you write WHAT a leak is? and why to prevent them? i don't either quite get all those leak codes... i think i'll just copy them into my maps... but i think what i mentioned before, is vital information.
     
  11. Wraith

    Wraith

    Joined:
    Mar 25, 2009
    Messages:
    27
    Resources:
    0
    Resources:
    0
    Hi, can i know if me using Unit(array[index]) and remove leak using Loop Action -Set Unit[integerA]=No Unit
     
  12. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    I don't understand the question...
     
  13. Justify

    Justify

    Joined:
    Mar 16, 2008
    Messages:
    935
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    3
    Resources:
    5
  14. SanKakU

    SanKakU

    Joined:
    May 11, 2008
    Messages:
    1,183
    Resources:
    1
    Maps:
    1
    Resources:
    1
    does offset leak? i know point does.

    • teleport tree
      • Events
      • Conditions
        • (Ability being cast) Equal to (==) |cffadff2fTree Blink|r (Demon Tree)
      • Actions
        • Set points = (Position of (Casting unit))
        • Destructible - Create a Icecrown Tree Wall at points facing (Random angle) with scale 1.00 and variation (Random integer number between 1 and 10)
        • Destructible - Create a Northrend Tree Wall at (points offset by ((Random real number between -200.00 and 200.00), (Random real number between -200.00 and 200.00))) facing (Random angle) with scale 1.00 and variation (Random integer number between 1 and 10)
        • Destructible - Create a Felwood Tree Wall at (points offset by ((Random real number between -200.00 and 200.00), (Random real number between -200.00 and 200.00))) facing (Random angle) with scale 1.00 and variation (Random integer number between 1 and 5)
        • Point - Remove points

    i just figured the spell would be more powerful if i added more trees so but i'm not sure how to use offset, is this ok?
     
  15. spiwn

    spiwn

    Joined:
    Apr 27, 2008
    Messages:
    1,228
    Resources:
    0
    Resources:
    0
    Yes it does.

    • teleport tree
    • Events
    • Conditions
    • (Ability being cast) Equal to (==) |cffadff2fTree Blink|r (Demon Tree)
    • Actions
    • Set points = (Position of (Casting unit))
    • Set Point2 =(points offset by ((Random real number between -200.00 and 200.00)
    • Destructible - Create a Icecrown Tree Wall at points facing (Random angle) with scale 1.00 and variation (Random integer number between 1 and 10)
    • Destructible - Create a Northrend Tree Wall at Point2, (Random real number between -200.00 and 200.00))) facing (Random angle) with scale 1.00 and variation (Random integer number between 1 and 10)
    • Custom script: call RemoveLocation(udg_Point2)
    • Set Point2= (points offset by ((Random real number between -200.00 and 200.00)
    • Destructible - Create a Felwood Tree Wall at Point2, (Random real number between -200.00 and 200.00))) facing (Random angle) with scale 1.00 and variation (Random integer number between 1 and 5)
    • Custom script: call RemoveLocation(points)
    • Custom script: call RemoveLocation(udg_Point2)
     
  16. SanKakU

    SanKakU

    Joined:
    May 11, 2008
    Messages:
    1,183
    Resources:
    1
    Maps:
    1
    Resources:
    1
    good to know...uhm by the way you left out the y reals...

    ok so how's this for a JASS rewrite of the spell?

    Code (vJASS):
    scope teleportTree initializer I

    private function C takes nothing returns boolean
        return GetSpellAbilityId() == 'A00K'
    endfunction

    private function A takes nothing returns nothing
        local unit u = GetTriggerUnit()
        local real ux = GetUnitX(u)
        local real uy = GetUnitY(u)
        local real rx
        local real ry
        call CreateDestructable('ITtw',ux,uy,GetRandomReal(0.00, 359.00),1,GetRandomInt(1, 10) )
        set rx = ux + GetRandomReal(-200.00,200.00)
        set ry = uy + GetRandomReal(-200.00,200.00)
        call CreateDestructable('NTtw',rx,ry,GetRandomReal(0.00, 359.00),1,GetRandomInt(1, 10) )
        set rx = ux + GetRandomReal(-200.00,200.00)
        set ry = uy + GetRandomReal(-200.00,200.00)
        call CreateDestructable('CTtr',rx,ry,GetRandomReal(0.00, 359.00),1,GetRandomInt(1, 10) )    
        set u = null
    endfunction

    //===========================================================================
    private function I takes nothing returns nothing
        local trigger t = CreateTrigger(  )
        call TriggerAddCondition( t, Condition( function C ) )
        call TriggerAddAction( t, function A )
    endfunction

    endscope


    edit: well obviously i broke something because now it's not working...
    maybe it has something to do with the fact that it's a scope and private functions and that handles the gui trigger add event function differently?
     
  17. spiwn

    spiwn

    Joined:
    Apr 27, 2008
    Messages:
    1,228
    Resources:
    0
    Resources:
    0
    Should be:
    Code (vJASS):

    public function InitTrig takes nothing returns nothing
        local trigger t = CreateTrigger( )
        call TriggerAddCondition( t, Condition( function C ) )
        call TriggerAddAction( t, function A )
    endfunction
     
  18. Justify

    Justify

    Joined:
    Mar 16, 2008
    Messages:
    935
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    3
    Resources:
    5
    Not rly :p Initializer can be private, no problem there.
     
  19. Shadow Daemon

    Shadow Daemon

    Joined:
    Nov 23, 2008
    Messages:
    184
    Resources:
    3
    Tools:
    3
    Resources:
    3
    Hmm... lol. Where is trigger event registration?

    Code (vJASS):
    private function I takes nothing returns nothing
        local trigger t = CreateTrigger( )
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, Condition(function C))
        call TriggerAddAction(t, function A)
    endfunction


    If you are adding event to trigger dynamically, trigger must be a global variable.

    Also, there is no such need in some local variables (rx, ry - due to inline, u - due to only two uses of function value)

    Code (vJASS):
    private function A takes nothing returns nothing
        local real ux = GetUnitX(GetTriggerUnit())
        local real uy = GetUnitY(GetTriggerUnit())
        call CreateDestructable('ITtw', ux,                              uy,                              GetRandomReal(0., 359.), 1, GetRandomInt(1, 10))
        call CreateDestructable('NTtw', ux + GetRandomReal(-200., 200.), uy + GetRandomReal(-200., 200.), GetRandomReal(0., 359.), 1, GetRandomInt(1, 10))
        call CreateDestructable('CTtr', ux + GetRandomReal(-200., 200.), uy + GetRandomReal(-200., 200.), GetRandomReal(0., 359.), 1, GetRandomInt(1, 10))
    endfunction
     
  20. spiwn

    spiwn

    Joined:
    Apr 27, 2008
    Messages:
    1,228
    Resources:
    0
    Resources:
    0
    True, if you use initializer, but it is not obligatory to do so.

    There is no need for triggers to be global. True that WE automatically generates a global trigger for every trigger you create in the format gg_trg_*trigger name*.
    But the idea of scopes is that the scope can be implemented in any map by just copy pasteing the code and changing only the scope name, so it is just simpler to use a local variable.

    The code can indeed be reduced to this:
    Code (vJASS):

    scope teleportTree

    private function C takes nothing returns boolean
        return GetSpellAbilityId() == 'A00K'
    endfunction

    private function A takes nothing returns nothing
        local real ux = GetUnitX(GetTriggerUnit())
        local real uy = GetUnitY(GetTriggerUnit())
        call CreateDestructable('ITtw', ux, uy, GetRandomReal(0., 359.), 1, GetRandomInt(1, 10))
        call CreateDestructable('NTtw', ux + GetRandomReal(-200., 200.), uy + GetRandomReal(-200., 200.), GetRandomReal(0., 359.), 1, GetRandomInt(1, 10))
        call CreateDestructable('CTtr', ux + GetRandomReal(-200., 200.), uy + GetRandomReal(-200., 200.), GetRandomReal(0., 359.), 1, GetRandomInt(1, 10))
    endfunction

    //===========================================================================
    public function InitTrig takes nothing returns nothing
        local trigger t = CreateTrigger( )
        call TriggerAddCondition( t, Condition( function C ) )
        call TriggerAddAction( t, function A )
    endfunction

    endscope
     



    Anyway doing it with an initializer is not wrong.