1. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  2. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  3. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  4. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

Crash (Memory Leak?)

Discussion in 'Triggers & Scripts' started by Donnerkoettel, May 6, 2019.

  1. Donnerkoettel

    Donnerkoettel

    Joined:
    Oct 1, 2018
    Messages:
    63
    Resources:
    0
    Resources:
    0
    Edit: My game Freezes after some time, if the RaidCamera is active even sooner. It's periodic and focuses the Unit next to the enemys tower. If Player 2 units (Dummys for player 1) are all dead, the cam focuses the enemy units the same way. I know, that removing points is one important thing, so i did. (Well, i think i did) Also there is not a single wait function in my entire map. It is and will stay singleplayer, if that info does matter. Here is the trigger. I dont know whats wrong with it.

    Previous Trigger:
    RaidCam.JPG

    Updated Trigger

    RaidCamUpdated.JPG

    Here i edited the Unit Groups. I cant tell a difference in performance but as told in this Thread:
    Things That Leak

    they should not leak anymore. Howerver active or not, the Game still freezes after some Time. If it's active, it freezes sooner.

    I also edited the Event of my Multiboard Trigger, wich was Periodic 00,3 Sek too. Now it just get's an update, if anything happens.

    So at this Point, i am absolutly lost. I dont know what could couse the game to freeze.
    Here is my Nemesis, it wont let me sleep...
     

    Attached Files:

    Last edited: May 6, 2019
  2. Donnerkoettel

    Donnerkoettel

    Joined:
    Oct 1, 2018
    Messages:
    63
    Resources:
    0
    Resources:
    0
  3. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,104
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Posting triggers makes it easier for all: How To Post Your Trigger

    In your code, locations aren't correctly removed. This is what you do:
    Code ( (Unknown Language)):

    loc = new Location( ... ) // create location

    if ( ... )
        // do stuff
        RemoveLocation(loc) // destroy location
    endif
    So you remove the location only if the condition is true. Else, it leaks. Do always remove the location at the end when not needed anymore, and do so on same nesting-depth:
    Code ( (Unknown Language)):

    loc = new Location( ... ) // create location

    if ( ... )
        // do stuff
    endif

    RemoveLocation(loc) // destroy location
    Also, you don't even use your "P_UnitLocations" variable, but instead you create a new location with using "(Position of ( Unit )", in the distance checks.

    Furthermore, inside the second "Pick All Units ( ... )" the custom script line tries to remove P_UnitLocations1, but should remove P_UnitLocations2.

    The priodic timeout should be reduced from 0.03 to something higher, like minimum 0.1-0.2 seconds (personal suggestion). Because working with unit groups, especilly picking the units from map each time imight be very resource costly for the computer.

    There might be similar issue sin other triggers, I haven't checked the map.
     
  4. Donnerkoettel

    Donnerkoettel

    Joined:
    Oct 1, 2018
    Messages:
    63
    Resources:
    0
    Resources:
    0

    Thank you for pointing out that tiping failure in the custom script.

    So you'r telling me i dont even use the P_UnitLocations instead creating more with the function
    "Set R_ShortestDistance1 = (Distance between P_Tower2 and P_UnitLocation1)"
    i check wich unit is the nearest to the enemys tower. And that works. but does this funtion create a new point?
    I will take your advise and slow that trigger down.

    The cam is not the main problem, there must be another reasen the game freezes.

    I have tested nearly everything. I deactivated everything unnesseccary for spawning units.
    Meanwhile i let the trigger give textmessages at the start and end. (including alternate ends like the Unit dies trigger)

    Disabling the "add Ablility" If/Then/Else's in the spawn mercenary Trigger gave me huge time before the freeze finally happened again.
    I dont understand whats going on. I have made tons of maps before with dummy units but they never had a freeze.
    I always try to keep it simple by naming the triggers after activation method just in case i cannot fix a problem like this one now.

    Can it have something to do with the units beeing all heroes?
     
  5. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,104
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    (Position of (unit)) does always create a (new) location. That's why it's not directly used in a distance check, for example. Instead you need to store in into a variable first, then use the variable for distance check, and then destroy it after usage. The variable becomes useless, if you again use (Position of (unit)) instead of the variable, and it will leak.

    You can post the updated code, to ensure you did it right.
     
  6. Donnerkoettel

    Donnerkoettel

    Joined:
    Oct 1, 2018
    Messages:
    63
    Resources:
    0
    Resources:
    0
    this sounds complicate to me.
    so i have to create a point anywhere and after that setting this point to the units location?
    Like this?
    CorrectPointing.JPG

    Or if thats false too, how do i set the point to units position without using "position of unit".
    I dont think i can follow.
     
  7. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,104
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Read my posts and tutorials again, slowly. Also read how to post triggers.
     
  8. Donnerkoettel

    Donnerkoettel

    Joined:
    Oct 1, 2018
    Messages:
    63
    Resources:
    0
    Resources:
    0
    Sorry, i havent seen the failer. I think it's ok now isn't it?
    • RaidCam
      • Ereignisse
        • Zeit - Every 0.25 seconds of game time
      • Bedingungen
      • Aktionen
        • Set R_ShortestDistance1 = 1000000000.00
        • Set R_ShortestDistance2 = 1000000000.00
        • Set UG_Destroy1 = (Units owned by Spieler 2 (Blau) matching ((((Matching unit) is alive) Gleich True) and (((Matching unit) is Mechanisch) Gleich False)))
        • Einheitengruppe - Pick every unit in UG_Destroy1 and do (Actions)
          • Schleifen - Aktionen
            • Set U_PickedUnit1 = (Picked unit)
            • Set P_UnitLocation1 = (Position of U_PickedUnit1)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • (Distance between P_Tower2 and P_UnitLocation1) Kleiner als R_ShortestDistance1
              • 'THEN'-Aktionen
                • Set U_Spotlight1 = U_PickedUnit1
                • Set R_ShortestDistance1 = (Distance between P_Tower2 and P_UnitLocation1)
                • Custom script: call RemoveLocation(udg_P_UnitLocation1)
              • 'ELSE'-Aktionen
        • Custom script: call DestroyGroup(udg_UG_Destroy1)
        • Set UG_Destroy2 = (Units owned by Spieler 3 (Blaugrau) matching ((((Matching unit) is alive) Gleich True) and (((Matching unit) is Mechanisch) Gleich False)))
        • Einheitengruppe - Pick every unit in UG_Destroy2 and do (Actions)
          • Schleifen - Aktionen
            • Set U_PickedUnit2 = (Picked unit)
            • Set P_UnitLocation2 = (Position of U_PickedUnit2)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • (Distance between P_Tower1 and P_UnitLocation2) Kleiner als R_ShortestDistance2
              • 'THEN'-Aktionen
                • Set U_Spotlight2 = U_PickedUnit2
                • Set R_ShortestDistance2 = (Distance between P_Tower1 and P_UnitLocation2)
                • Custom script: call RemoveLocation(udg_P_UnitLocation2)
              • 'ELSE'-Aktionen
        • Custom script: call DestroyGroup(udg_UG_Destroy2)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (U_Spotlight1 is alive) Gleich True
          • 'THEN'-Aktionen
            • Kamera - Lock camera target for Spieler 1 (Rot) to U_Spotlight1, offset by (0.00, 0.00) using Vorgabe-Drehung
          • 'ELSE'-Aktionen
            • Kamera - Lock camera target for Spieler 1 (Rot) to U_Spotlight2, offset by (0.00, 0.00) using Vorgabe-Drehung
        • Kamera - Set Spieler 1 (Rot)'s camera Entfernung zum Ziel to 800.00 over 0.00 seconds
        • Kamera - Set Spieler 1 (Rot)'s camera Drehung to 90.00 over 0.00 seconds
        • Kamera - Set Spieler 1 (Rot)'s camera Perspektive to 345.00 over 0.00 seconds
        • Kamera - Set Spieler 1 (Rot)'s camera Fernes Z to 5000.00 over 0.00 seconds
        • Kamera - Set Spieler 1 (Rot)'s camera Höhen-Offset to 300.00 over 0.00 seconds


    I have deaktivatet all triggers and functions that arent necessary to test if and why it freezes.
    The only thing i could shut down else would be the multiboard. That i've already tested, the game will freeze, becouse of this triggers:

    • Initialization
      • Ereignisse
        • Map initialization
      • Bedingungen
      • Aktionen
        • Set I_HeroLevel = 1
        • Set I_Gold = 0
        • Set I_Wood = 0
        • Set I_Glitch = 0
        • Set R_Ebene = 1.00
        • Set R_MBSpace = 15.00
        • Set UT_Mercenary[1] = Soldat [T1]
        • Set UT_Mercenary[2] = Bogenschützin [T2]
        • Set UT_Mercenary[3] = Priester [T3]
        • Set UT_Mercenary[4] = Drachenfalkenreiter [T4]
        • Set UT_Mercenary[5] = Zauberbrecher [T5]
        • Set UT_Mercenary[6] = Wächter [T1]
        • Set UT_Mercenary[7] = Bogenschützin [T2]
        • Set UT_Mercenary[8] = Klauen-Druide [T3]
        • Set UT_Mercenary[9] = Hippogryph-Reiterin [T4]
        • Set UT_Mercenary[10] = Assassine [T5]
        • Set UT_Mercenary[11] = Berserker [T1]
        • Set UT_Mercenary[12] = Voodoo-Priester [T2]
        • Set UT_Mercenary[13] = Hexenmeister [T3]
        • Set UT_Mercenary[14] = Windreiter [T4]
        • Set UT_Mercenary[15] = Schamane [T5]
        • Set UT_Mercenary[16] = Skelett-Ork [T1]
        • Set UT_Mercenary[17] = Skelett-Bogenschütze [T2]
        • Set UT_Mercenary[18] = Banshee [T3]
        • Set UT_Mercenary[19] = Geisterflügeldrache [T4]
        • Set UT_Mercenary[20] = Poltergeist [T5]
        • Set P_Tower1 = (Spieler 2 (Blau) start location)
        • Set P_Tower2 = (Spieler 3 (Blaugrau) start location)
        • Spieler - Change color of Spieler 2 (Blau) to Blau, Farbe wird gewechselt ... of existing units
        • Spieler - Change color of Spieler 3 (Blaugrau) to Rot, Farbe wird gewechselt ... of existing units
        • Spieler - Make Spieler 2 (Blau) treat Spieler 3 (Blaugrau) as an Feind
        • Spieler - Make Spieler 3 (Blaugrau) treat Spieler 2 (Blau) as an Feind
        • Umgebung - Set sky to Standard-Himmel
        • Spiel - Turn the day/night cycle Aus
        • Spiel - Set the time of day to 24.00
        • Sichtbarkeit - Disable fog of war
        • Sichtbarkeit - Disable black mask

    • Time Elapsed
      • Ereignisse
        • Zeit - Elapsed game time is 0.00 seconds
      • Bedingungen
      • Aktionen
        • Einheit - Create 1 Nachtelf for Spieler 1 (Rot) at (Center of Revive Hero <gen>) facing Vorgabe für Gebäude-Ausrichtung degrees
        • Set U_Hero = (Last created unit)
        • Einheit - Create 1 Wächter [T1] for Spieler 1 (Rot) at (Center of Dummy 1 <gen>) facing Vorgabe für Gebäude-Ausrichtung degrees
        • Set U_MercenaryDummy[1] = (Last created unit)
        • Einheit - Create 1 Bogenschützin [T2] for Spieler 1 (Rot) at (Center of Dummy 2 <gen>) facing Vorgabe für Gebäude-Ausrichtung degrees
        • Set U_MercenaryDummy[2] = (Last created unit)
        • Einheit - Create 1 Klauen-Druide [T3] for Spieler 1 (Rot) at (Center of Dummy 3 <gen>) facing Vorgabe für Gebäude-Ausrichtung degrees
        • Set U_MercenaryDummy[3] = (Last created unit)
        • Einheit - Make Oger-Magier 0017 <gen> Schlafen when unprovoked
        • Set I_UnitGoldLevel[1] = 299
        • Set I_UnitGoldLevel[2] = 299
        • Set I_UnitGoldLevel[3] = 299
        • Auslöser - Run Update <gen> (checking conditions)
        • Auslöser - Run Spawn Units <gen> (checking conditions)

    • Attack
      • Ereignisse
        • Einheit - A unit enters Battleground <gen>
      • Bedingungen
      • Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Owner of (Entering unit)) Gleich Spieler 2 (Blau)
          • 'THEN'-Aktionen
            • Einheit - Order (Entering unit) to Patrouillieren nach (Center of P2Tower <gen>)
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Owner of (Entering unit)) Gleich Spieler 3 (Blaugrau)
          • 'THEN'-Aktionen
            • Einheit - Order (Entering unit) to Angreifen/Bewegen nach (Center of P1Tower <gen>)
          • 'ELSE'-Aktionen

    • Unit dies
      • Ereignisse
        • Einheit - A unit Stirbt
      • Bedingungen
      • Aktionen
        • Set U_DyingUnit = (Dying unit)
        • -------- Gold+ --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Owner of U_DyingUnit) Gleich Spieler 3 (Blaugrau)
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • (U_DyingUnit is Mechanisch) Gleich False
              • 'THEN'-Aktionen
                • Set I_Gold = (I_Gold + (((Integer(R_Ebene)) x 2) x I_HeroLevel))
                • Auslöser - Run Update <gen> (checking conditions)
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • -------- Ebene Up --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (U_DyingUnit is Mechanisch) Gleich True
            • And - All (Conditions) are true
              • Bedingungen
                • (Owner of U_DyingUnit) Gleich Spieler 3 (Blaugrau)
          • 'THEN'-Aktionen
            • Set R_Ebene = (R_Ebene + 1.00)
            • If ((Random integer number between I_Glitch and 99) Gleich 50) then do (Set R_Ebene = (R_Ebene + 1.00)) else do (Do nothing)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_Glitch Größer als 0
                • And - All (Conditions) are true
                  • Bedingungen
                    • (Random integer number between I_Glitch and 99) Gleich 50
              • 'THEN'-Aktionen
                • Set R_Ebene = (R_Ebene + 1.00)
                • Spiel - Display to (All players) the text: |c0000FF00Unauffäl...
              • 'ELSE'-Aktionen
            • Auslöser - Run Update <gen> (checking conditions)
            • Video - Ausblenden und wieder einblenden over 6.00 seconds using texture Weiße Maske and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
            • Countdown-Timer - Start T_SpawnUnits as a Einmalig timer that will expire in 3.00 seconds
          • 'ELSE'-Aktionen
        • -------- Ebene Down --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (U_DyingUnit is Mechanisch) Gleich True
            • And - All (Conditions) are true
              • Bedingungen
                • (Owner of U_DyingUnit) Gleich Spieler 2 (Blau)
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • R_Ebene Kleiner als 2.00
              • 'THEN'-Aktionen
                • Set R_Ebene = 1.00
                • Video - Ausblenden und wieder einblenden over 6.00 seconds using texture Weiße Maske and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
                • Countdown-Timer - Start T_SpawnUnits as a Einmalig timer that will expire in 3.00 seconds
                • Auslöser - Run Update <gen> (checking conditions)
              • 'ELSE'-Aktionen
                • Set R_Ebene = (R_Ebene - 1.00)
                • Video - Ausblenden und wieder einblenden over 6.00 seconds using texture Weiße Maske and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
                • Countdown-Timer - Start T_SpawnUnits as a Einmalig timer that will expire in 3.00 seconds
                • Auslöser - Run Update <gen> (checking conditions)
          • 'ELSE'-Aktionen

    • Spawn Units
      • Ereignisse
        • Zeit - T_SpawnUnits expires
      • Bedingungen
      • Aktionen
        • -------- Clean Up --------
        • Einheitengruppe - Pick every unit in UG_P1 and do (Actions)
          • Schleifen - Aktionen
            • Einheit - Remove (Picked unit) from the game
        • Custom script: call DestroyGroup(udg_UG_P1)
        • Einheitengruppe - Pick every unit in UG_P2 and do (Actions)
          • Schleifen - Aktionen
            • Einheit - Remove (Picked unit) from the game
        • Custom script: call DestroyGroup(udg_UG_P2)
        • -------- IZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZI --------
        • Set I_Race = (Random integer number between 1 and 4)
        • Set I_Counter = 1
        • Einheit - Create 1 Kristall for Spieler 2 (Blau) at P_Tower1 facing Vorgabe für Gebäude-Ausrichtung degrees
        • Animation - Change (Last created unit)'s animation speed to 200.00% of its original speed
        • Held - Set (Last created unit) Hero-level to (Integer(R_Ebene)), Verbergen level-up graphics
        • Held - Deaktivieren experience gain for (Last created unit)
        • Set UG_P1 = (Units owned by Spieler 2 (Blau))
        • Einheitengruppe - Add (Last created unit) to UG_P1
        • Einheit - Create 1 Kristall for Spieler 3 (Blaugrau) at P_Tower2 facing Vorgabe für Gebäude-Ausrichtung degrees
        • Animation - Change (Last created unit)'s animation speed to 200.00% of its original speed
        • Held - Set (Last created unit) Hero-level to (Integer(R_Ebene)), Verbergen level-up graphics
        • Held - Deaktivieren experience gain for (Last created unit)
        • Set UG_P2 = (Units owned by Spieler 2 (Blau))
        • Einheitengruppe - Add (Last created unit) to UG_P2
        • Countdown-Timer - Start T_SpawnMercenary as a Einmalig timer that will expire in 2.00 seconds

    • Spawn Mercenary
      • Ereignisse
        • Zeit - T_SpawnMercenary expires
      • Bedingungen
      • Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • I_Counter Kleiner als 8
          • 'THEN'-Aktionen
            • Do nothing
          • 'ELSE'-Aktionen
            • Skip remaining actions
        • Set P_RandomPoint = (Random point in P1Tower <gen>)
        • Einheit - Create 1 (Unit-type of U_MercenaryDummy[I_Counter]) for Spieler 2 (Blau) at P_RandomPoint facing Vorgabe für Gebäude-Ausrichtung degrees
        • Custom script: call RemoveLocation(udg_P_RandomPoint)
        • Set U_Mercenary[I_Counter] = (Last created unit)
        • Einheitengruppe - Add (Last created unit) to UG_P1
        • -------- Hero Level Bonus --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Hero) Gleich Blutelf
            • And - All (Conditions) are true
              • Bedingungen
                • Or - Any (Conditions) are true
                  • Bedingungen
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Soldat [T1]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Bogenschützin [T2]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Priester [T3]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Drachenfalkenreiter [T4]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Zauberbrecher [T5]
          • 'THEN'-Aktionen
            • Set I_P1UnitLevel[I_Counter] = ((I_UnitGoldLevel[I_Counter] + I_UnitWoodLevel[I_Counter]) + (I_HeroLevel + 1))
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Hero) Gleich Nachtelf
            • And - All (Conditions) are true
              • Bedingungen
                • Or - Any (Conditions) are true
                  • Bedingungen
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Wächter [T1]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Bogenschützin [T2]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Klauen-Druide [T3]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Hippogryph-Reiterin [T4]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Assassine [T5]
          • 'THEN'-Aktionen
            • Set I_P1UnitLevel[I_Counter] = ((I_UnitGoldLevel[I_Counter] + I_UnitWoodLevel[I_Counter]) + (I_HeroLevel + 1))
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Hero) Gleich Orc
            • And - All (Conditions) are true
              • Bedingungen
                • Or - Any (Conditions) are true
                  • Bedingungen
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Berserker [T1]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Voodoo-Priester [T2]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Hexenmeister [T3]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Windreiter [T4]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Schamane [T5]
          • 'THEN'-Aktionen
            • Set I_P1UnitLevel[I_Counter] = ((I_UnitGoldLevel[I_Counter] + I_UnitWoodLevel[I_Counter]) + (I_HeroLevel + 1))
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Hero) Gleich Untoter
            • And - All (Conditions) are true
              • Bedingungen
                • (Unit-type of U_Mercenary[I_Counter]) Gleich Skelett-Ork [T1]
                • Or - Any (Conditions) are true
                  • Bedingungen
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Skelett-Bogenschütze [T2]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Banshee [T3]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Geisterflügeldrache [T4]
                    • (Unit-type of U_Mercenary[I_Counter]) Gleich Poltergeist [T5]
          • 'THEN'-Aktionen
            • Set I_P1UnitLevel[I_Counter] = ((I_UnitGoldLevel[I_Counter] + I_UnitWoodLevel[I_Counter]) + (I_HeroLevel + 1))
          • 'ELSE'-Aktionen
        • -------- Set Level --------
        • Held - Set U_Mercenary[I_Counter] Hero-level to I_P1UnitLevel[I_Counter], Verbergen level-up graphics
        • Held - Deaktivieren experience gain for U_Mercenary[I_Counter]
        • Held - Set U_MercenaryDummy[I_Counter] Hero-level to I_P1UnitLevel[I_Counter], Verbergen level-up graphics
        • -------- Add Ability --------
        • -------- Bloodelf --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Soldat [T1]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Inneres Feuer (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Bogenschützin [T2]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Ausweichen (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Priester [T3]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Heiliges Licht (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Drachenfalkenreiter [T4]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Luftfesseln (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Zauberbrecher [T5]
          • 'THEN'-Aktionen
            • Einheit - Add Manabrand (Mensch) to U_Mercenary[I_Counter]
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 199
              • 'THEN'-Aktionen
                • Einheit - Add Zauberdiebstahl (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Zauberdiebstahl (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • -------- Nightelf --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Wächter [T1]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Reinigen (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Bogenschützin [T2]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Kritischer Schlag (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Klauen-Druide [T3]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Wucherwurzeln (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Assassine [T5]
          • 'THEN'-Aktionen
            • Einheit - Add Ausweichen (Mensch) to U_Mercenary[I_Counter]
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 199
              • 'THEN'-Aktionen
                • Einheit - Add Kritischer Schlag (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Windlauf (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • -------- Orc --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Berserker [T1]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Pulverisieren (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Voodoo-Priester [T2]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Durchblick (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Hexenmeister [T3]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Hexerei (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Windreiter [T4]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Langsam (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Schamane [T5]
          • 'THEN'-Aktionen
            • Einheit - Add Kettenblitz (Mensch) to U_Mercenary[I_Counter]
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 199
              • 'THEN'-Aktionen
                • Einheit - Add Gebrüll (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Kampfrausch (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • -------- Undead --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Skelett-Ork [T1]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Reinkarnation (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Skelett-Bogenschütze [T2]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Reinkarnation (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Banshee [T3]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Fluch (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Mercenary[I_Counter]) Gleich Poltergeist [T5]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 199
              • 'THEN'-Aktionen
                • Einheit - Add Schlaf (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P1UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Aufspießen (Mensch) to U_Mercenary[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • -------- Spawn Enemy --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • I_Race Gleich 1
          • 'THEN'-Aktionen
            • Auslöser - Run Spawn Enemy Bloodelf <gen> (checking conditions)
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • I_Race Gleich 2
          • 'THEN'-Aktionen
            • Auslöser - Run Spawn Enemy Nightelf <gen> (checking conditions)
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • I_Race Gleich 3
          • 'THEN'-Aktionen
            • Auslöser - Run Spawn Enemy Orc <gen> (checking conditions)
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • I_Race Gleich 4
          • 'THEN'-Aktionen
            • Auslöser - Run Spawn Enemy Undead <gen> (checking conditions)
          • 'ELSE'-Aktionen

    • Spawn Enemy Bloodelf
      • Ereignisse
      • Bedingungen
      • Aktionen
        • Set I_P2UnitLevel[I_Counter] = (Integer(R_Ebene))
        • Set P_RandomPoint = (Random point in P2Tower <gen>)
        • Einheit - Create 1 UT_Mercenary[(Random integer number between 1 and 5)] for Spieler 3 (Blaugrau) at P_RandomPoint facing Vorgabe für Gebäude-Ausrichtung degrees
        • Custom script: call RemoveLocation(udg_P_RandomPoint)
        • Set U_Enemy[I_Counter] = (Last created unit)
        • Held - Set U_Enemy[I_Counter] Hero-level to (Integer(R_Ebene)), Verbergen level-up graphics
        • Held - Deaktivieren experience gain for U_Enemy[I_Counter]
        • Einheitengruppe - Add (Last created unit) to UG_P2
        • -------- Bloodelf --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Enemy[I_Counter]) Gleich Soldat [T1]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P2UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Inneres Feuer (Mensch) to U_Enemy[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Enemy[I_Counter]) Gleich Bogenschützin [T2]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P2UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Ausweichen (Mensch) to U_Enemy[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Enemy[I_Counter]) Gleich Priester [T3]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P2UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Heiliges Licht (Mensch) to U_Enemy[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Enemy[I_Counter]) Gleich Drachenfalkenreiter [T4]
          • 'THEN'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P2UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Luftfesseln (Mensch) to U_Enemy[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • 'IF'-Bedingungen
            • (Unit-type of U_Enemy[I_Counter]) Gleich Zauberbrecher [T5]
          • 'THEN'-Aktionen
            • Einheit - Add Manabrand (Mensch) to U_Enemy[I_Counter]
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P2UnitLevel[I_Counter] Größer als 199
              • 'THEN'-Aktionen
                • Einheit - Add Zauberdiebstahl (Mensch) to U_Enemy[I_Counter]
              • 'ELSE'-Aktionen
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • 'IF'-Bedingungen
                • I_P2UnitLevel[I_Counter] Größer als 99
              • 'THEN'-Aktionen
                • Einheit - Add Zauberdiebstahl (Mensch) to U_Enemy[I_Counter]
              • 'ELSE'-Aktionen
          • 'ELSE'-Aktionen
        • -------- Next Wave --------
        • Set I_Counter = (I_Counter + 1)
        • Countdown-Timer - Start (Last started timer) as a Einmalig timer that will expire in 1.00 seconds


    I have 3 more triggers like "spawn enemy bloodelf" for the 3 other races. They are exact the same.
    I also update the map above right now.

    Edit: its updated
     
  9. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,104
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Yes, the trigger looks better.
    (Center of Dummy 2 <gen>) => this is also a location. If you get locations to work with, it basically always leaks, if you haven't already stored it into variable.

    ps: it's no leak, but you don't have to do the work to create too many temp variables of same type with numbers 1/2 etc, if you don't need them at same time.
    For example it looks like Set U_PickedUnit1/Set U_PickedUnit2 could be just one variable. Just to remember for further triggers..

    Can't really spot other leaks right now.
     
  10. Donnerkoettel

    Donnerkoettel

    Joined:
    Oct 1, 2018
    Messages:
    63
    Resources:
    0
    Resources:
    0
    Thank you.
    i will upgrade the map soon, removing all locations and see which variables i can put together with arrays instead of having 2 of them for each player.

    A friend of mine mentioned that the freeze could have to do with my pc.
    Does it freeze if you test it?
    Can you test the map and wait, till the "Ebene" variable displayed in the multiboard reaches 50? in the updated version you dont need to do a thing, the levels of the units are 300 becouse of testing phase.
    (Ebene is a german word for level, but not like hero level. more like ground level or next floor. Ebene up happens, when the enemy tower gets killed.)

    May be a stuped request but i hope im not the only one having it freeze.
     
  11. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,104
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    Attack Trigger + Time Elapsed Trigger have location leaks.

    I let it run until Ebene 27, no fps drop. I also watched computer RAM usage, and it decreased only very slowly (only minimal leaks, and some can't be prevented during game process) So I guess the demo works pretty ok.

    What you always can do is to optimize. Example:
    • Avoid "Pick All Units", but instead add/remove all units, or even more efficient would be to use unit[array] (but more advanced)
    • Avoid same function calls over and over again. Functions calls in GUI can be regocnized with brackets () around a statement.
      For example (Unit-type of Unit) is a function call. If used 20x in a trigger for one unit, it makes ... a lot function calls in the game.
      You can store the unit type into a variable, so you finally only always call a function once. From then on, the variable can be used.
      Reading a variable's value is a lot faster than calling, and eventually computing a function.
    • Try to optimize code structure, to make code more efficient, and possibly faster. I haven't analysed triggers, but some ifs look a bit messy... maybe it can be optimized.
     
  12. Donnerkoettel

    Donnerkoettel

    Joined:
    Oct 1, 2018
    Messages:
    63
    Resources:
    0
    Resources:
    0
    This part of filtering wich unit type (of My Units) shall be spawned (including add ability functions) will be the most confusing part for me. It was a bit difficult to create this trigger as it is right now but i know what you mean.
    Fixing this part will give my map the greatest performance boost so far.
    I'm sure i can handle this!

    With this problems i had and have, i learned a lot about leaks and some functions. I felt frustrated the last days but it is all worth the effort.
    I havent learned that much about triggering the last 2 jears.
    I will update everithing that can be improved, this will take some time.

    You are a very patient teacher, thanks for the lessons.
     
  13. IcemanBo

    IcemanBo

    Joined:
    Sep 6, 2013
    Messages:
    6,104
    Resources:
    22
    Maps:
    3
    Spells:
    11
    Template:
    1
    Tutorials:
    4
    JASS:
    3
    Resources:
    22
    I don't reallly want to analyse wanted map behaviours to optimize concepty by myself, but you can add me on discord IcemanBo#5874 if you want discuss such things for optimization.