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. Shadow Daemon

    Shadow Daemon

    Joined:
    Nov 23, 2008
    Messages:
    184
    Resources:
    3
    Tools:
    3
    Resources:
    3
    @spiwn, I do know these facts, but:

    So I had a thought that he uses GUI action "Trigger - Add Event To <trigger>". That's why I noticed two variants.

    But... without event registration the trigger would not fire.

    And, by the way, "public function InitTrig" would work as initializer only if trigger has the same name, as the scope within it. But it is a matter of taste...
     
  2. SanKakU

    SanKakU

    Joined:
    May 11, 2008
    Messages:
    1,183
    Resources:
    1
    Maps:
    1
    Resources:
    1
    yeah maybe we're getting a little off-topic with this vjass with globals and stuff but i don't really understand the concept...and thankyou for clarifying how to redo the tree placement.

    so that's leakless right? wow, sweet.

    now what's all this i hear about global triggers and such?

    here was the trigger i was using to add the event...i'll cut out the irrelevant information...
    Event Adding Trigger Failed
    Code (vJASS):

    scope pickmain initializer I


    private function treedemonskills takes nothing returns nothing
        call TriggerRegisterUnitEvent( gg_trg_teleportTree, GetTrainedUnit(), EVENT_UNIT_SPELL_EFFECT )
        endfunction    

    private function A takes nothing returns nothing
            if GetUnitTypeId(GetTrainedUnit()) == 'unec' then
                call treedemonskills()
            endif
    endfunction




    //===========================================================================
    private function I takes nothing returns nothing
        local trigger t = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
        call TriggerAddAction( t, function A )
    endfunction

    endscope

     


    i think it's faster to add the specific unit does the ability rather than any unit for checking conditions takes up valuable processing i'm right about that, right? that's why enfos uses this with their system...but i didn't learn how to add them to vjass trigger because they only used gui triggers so now that i'm learning vjass i can't add the event the same way anymore... so it's at least slightly on topic because i want to use vjass to make cleaning leaks easier but it's hard using it when i run into a snag such as this.

    and while we're talking about off topic stuff what's up with the reals? sometimes they can be 0.0 sometimes 0.00 sometimes 0 like the 1 just before the random integer right? and then so finally here i see 0. which i never saw before. are the various functions picky about how you type your reals?
     
  3. Mooglefrooglian

    Mooglefrooglian

    Joined:
    Nov 28, 2008
    Messages:
    701
    Resources:
    0
    Resources:
    0
    No, reals are reals. You can type them however you want. Some people add .0 because they want to remind themselves its a real or something. I dont see the need, personally.
     
  4. Justify

    Justify

    Joined:
    Mar 16, 2008
    Messages:
    935
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    3
    Resources:
    5
    Not always. If you store it in a variable it is unimportant.
    But if you make a calculation like:
    Code (vJASS):
    myReal = 3.7-(5/3)

    This would be 2.7, because 5/3 is an integer devision with the result 1.
    Code (vJASS):
    myReal = 3.7-(5./3.)

    This would be ~2,033

    But that's the only example with problems because of the dot, Mooglefrooglian is right.
    However, I'm always typing 1. and so on to remember that it's a real :)
     
  5. SanKakU

    SanKakU

    Joined:
    May 11, 2008
    Messages:
    1,183
    Resources:
    1
    Maps:
    1
    Resources:
    1
    so is this kindof what you mean by making the trigger a global variable?
    i'm guessing no, but you didn't explain that one yet. i don't think i know what you were talking about. please show me. the only thing i can think of would be to take the functions and actions and leave their names alone after converting to custom text, and then replace the functions' bodies with the code we just came up with.

    so like this:
    Code (vJASS):
    function Trig_teleportDemontree_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A00K'
    endfunction

    function Trig_teleportDemontree_Actions takes nothing returns nothing
    local real ux = GetUnitX(GetSpellAbilityUnit())
    local real uy = GetUnitY(GetSpellAbilityUnit())
        call CreateDestructable('ITtw',ux,uy,GetRandomReal(0.00, 359.00),1,GetRandomInt(1, 10) )
        call CreateDestructable('NTtw',ux + GetRandomReal(-200.00,200.00),uy + GetRandomReal(-200.00,200.00),GetRandomReal(0.00, 359.00),1,GetRandomInt(1, 10) )
        call CreateDestructable('CTtr',ux + GetRandomReal(-200.00,200.00),uy + GetRandomReal(-200.00,200.00),GetRandomReal(0.00, 359.00),1,GetRandomInt(1, 5) )    
    endfunction

    //===========================================================================
    function InitTrig_teleportDemontree takes nothing returns nothing
        set gg_trg_teleportDemontree = CreateTrigger(  )
        call TriggerAddCondition( gg_trg_teleportDemontree, Condition( function Trig_teleportDemontree_Conditions ) )
        call TriggerAddAction( gg_trg_teleportDemontree, function Trig_teleportDemontree_Actions )
    endfunction

     

    I can't really figure out if you can add the event to the private functions or not. If not, then the above is what I want? But I thought you were talking about something else perhaps that I don't really understand. If that's the case, please show me.
     
    Last edited: Apr 9, 2009
  6. kamermanbr

    kamermanbr

    Joined:
    Oct 9, 2008
    Messages:
    132
    Resources:
    0
    Resources:
    0
    tooooo much complicated for me =(
     
  7. darkrider

    darkrider

    Joined:
    Dec 31, 2007
    Messages:
    780
    Resources:
    1
    Maps:
    1
    Resources:
    1
    hey guys... i came out with a doubt the other day... does "convert player to player group" action leak?
     
  8. Shadow Daemon

    Shadow Daemon

    Joined:
    Nov 23, 2008
    Messages:
    184
    Resources:
    3
    Tools:
    3
    Resources:
    3
    Of course.
    GUI action "convert player to player group" is "GetForceOfPlayer" function in Jass:

    Code (vJASS):
    function GetForceOfPlayer takes player whichPlayer returns force
        local force f = CreateForce()
        call ForceAddPlayer(f, whichPlayer)
        return f
    endfunction


    Yepp, it creates force, but doesn't destroy it => it leaks, obviously.
     
  9. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Yeah, every non-constant player group leaks if not destroyed.

    For destroying it in GUI, just do something like:

    Custom script: call DestroyForce(udg_<variable name here>)

    Without <>. Btw, player group is called "force" in JASS (in case you didn't figure it out). Do that when you're finished with the player group (but don't do that if you intend to use that same player group continuously :p).

    I know this post was pretty useless, but I felt like saying something :D.
     
  10. darkrider

    darkrider

    Joined:
    Dec 31, 2007
    Messages:
    780
    Resources:
    1
    Maps:
    1
    Resources:
    1
    lol thx for the explanation silvenon but i got that :p

    and thx to shadowdaemon for the reply ^^

    i'll have to store the triggering player in a player group variable and then destroy it :p
     
  11. ALiEN95

    ALiEN95

    Joined:
    Mar 4, 2009
    Messages:
    1,148
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Does action "REMOVE UNIT" leak ,if so how to fix?
     
  12. Tzirrit

    Tzirrit

    Joined:
    Jun 22, 2007
    Messages:
    12
    Resources:
    3
    Maps:
    3
    Resources:
    3
    One more question about special effect leaks: Is it possible that creating and destroying a special effect still leaks, if created like this:
    Code (vJASS):

    call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Slow\\SlowCaster.mdl", att, "origin"))
     


    If the function below gets called alot, it creates lag and even freezes the game:
    Code (vJASS):

    function Protector_TakeDmg takes unit att, unit def, real dmg returns nothing
         // Add mana based on damage taken
        call SetUnitState(def, UNIT_STATE_MANA, (GetUnitState(def, UNIT_STATE_MANA) + (dmg * 0.5)))
       
        // If Retribution is activated and attacker is enemy
        if (GetUnitAbilityLevel(def, 'prb3') > 0 and IsUnitEnemy(att, GetOwningPlayer(def))) then
            // Reflect 75% of the damage back to attacker
            call UnitDamageTarget(def, att, (dmg * 0.75), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
            // Play GFX on target
            call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Slow\\SlowCaster.mdl", att, "origin"))
        endif    
    endfunction
     


    But as soon, as I remove the special effect, everything is fine... Any hints for me?
     
  13. kkots

    kkots

    Joined:
    Jun 21, 2007
    Messages:
    534
    Resources:
    0
    Resources:
    0
    I think that too many same special effects are created due to the repeatedly happening event.
     
  14. Tzirrit

    Tzirrit

    Joined:
    Jun 22, 2007
    Messages:
    12
    Resources:
    3
    Maps:
    3
    Resources:
    3
    Probably! I'm pretty sure, the function call doesn't leak.. but if 50 or more special effects are created at once, performance still drops drasticallay :eek:
     
  15. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    That first line you showed doesn't leak. Something else must be the problem.

    I wouldn't say so, but apparently it does (sometimes). What we do is we usually remove units with the combination of expiration timers and set unit explode on death.

    You want to remove a unit, then you add to him an expiration timer of, lets say, 1.5 seconds, then you make him explode on death (all via triggers), and preferably hide him if you want him removed immediately. That way the unit won't show, but will still be on the map for 1.5 seconds, and when it dies it "explodes", which is not really explosion, but a death without a corpse (which is what you want). So no problems.

    Got everything?
     
  16. ALiEN95

    ALiEN95

    Joined:
    Mar 4, 2009
    Messages:
    1,148
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Is it enought to hide and kill the unit?
    But the problem is that unit will die.....and i have some triggers that are doing something when unit dies but i think i can solve it with condition - killing unit is alive equal to true
     
  17. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Well, it will leave the corpse that way, which might be affected by something else. If you really don't want to use an expiration timer, you can kill the unit, but I suggest you set him to explode on death (there's an action for that), bc that way it won't leave a corpse.
     
  18. ALiEN95

    ALiEN95

    Joined:
    Mar 4, 2009
    Messages:
    1,148
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Ok i will do it and i wanna know what is the problem with corpse?

    Is there any way to remove leak with costum script code and are you shure it leaks?

    In game Vampirism Fire 5.06 there is about 700-1500 units removed every game but i didnt see it lagging accept it lags a bit more after 50 minutes but i think that happens in every game.....
     
  19. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Well, nothing is wrong with the corpse, I'm just saying there might be problems with raise dead and abilities like that. I'm sure you wouldn't want an invisible corpse to be raised. If you don't have anything that might cause problems like that, than you can do whatever you want.

    Remove with custom script? Well yeah, but it is same as Unit - Remove unit in GUI. I'm just saying there are some reports on leaks related to that.

    Maybe in Vampirism Fire units are removed in a different way? I don't know, there are tons of ways to remove a unit and non of them differs much visually.
     
  20. Orochimaru1993

    Orochimaru1993

    Joined:
    May 19, 2009
    Messages:
    2
    Resources:
    0
    Resources:
    0
    Good Tutorial !