• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Does this leak?

Status
Not open for further replies.
Level 3
Joined
Feb 3, 2009
Messages
33
Hello, i'm working on a hack'n'slash map, and i got these triggers to spawn mobs in a zone :

How its activated
  • Plains Activation
    • Evénements
      • Unité - A unit enters Region 006 <gen>
      • Unité - A unit enters Region 007 <gen>
      • Unité - A unit enters Region 008 <gen>
      • Unité - A unit enters Region 009 <gen>
      • Unité - A unit enters Region 010 <gen>
      • Unité - A unit enters Region 011 <gen>
      • Unité - A unit enters Region 012 <gen>
      • Unité - A unit enters Region 013 <gen>
      • Unité - A unit enters Region 014 <gen>
      • Unité - A unit enters Region 015 <gen>
      • Unité - A unit enters Region 016 <gen>
      • Unité - A unit enters Region 017 <gen>
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • ((Entering unit) is Un héros) Egal à TRUE
          • (Unit-type of (Triggering unit)) Egal à Surunan Scout (Plains)
          • (Unit-type of (Triggering unit)) Egal à Surunan Patrol (Plains)
          • (Unit-type of (Triggering unit)) Egal à Surunan Militia (Plains)
    • Actions
      • Compte à rebours - Start MonstersTimer[1] as a Un coup timer that will expire in 120.00 seconds
      • Set AUnitGroup = (Units in (Entire map) matching (((Custom value of (Matching unit)) Egal à 1) and ((Owner of (Matching unit)) Egal à Neutre Hostile)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • (Number of units in AUnitGroup) Inférieur à MaxMonster[1]
        • Alors - Actions
          • Déclencheur - Run Plains Spawn <gen> (checking conditions)
        • Sinon - Actions
      • Déclencheur - Turn on Plains Spawn <gen>
      • Déclencheur - Turn on Plains Patrol <gen>

The spawner
  • Plains Spawn
    • Evénements
      • Temps - Every 15.00 seconds of game time
    • Conditions
      • (Number of units in (Units in (Playable map area) matching ((Custom value of (Matching unit)) Egal à 1))) Inférieur à MaxMonster[1]
    • Actions
      • For each (Integer Var_Integer[6]) from 1 to 3, do (Actions)
        • Boucle - Actions
          • Set tempInteger = (Random integer number between 1 and 11)
          • If (tempInteger Egal à 1) then do (Set tempUnitType = Flying Goblin (Plains)) else do (Do nothing)
          • If (tempInteger Egal à 2) then do (Set tempUnitType = Goblin (Plains)) else do (Do nothing)
          • If (tempInteger Egal à 3) then do (Set tempUnitType = Goblin (Plains)) else do (Do nothing)
          • If (tempInteger Egal à 4) then do (Set tempUnitType = Rat (Plains)) else do (Do nothing)
          • If (tempInteger Egal à 5) then do (Set tempUnitType = Thief (Plains)) else do (Do nothing)
          • If (tempInteger Egal à 6) then do (Set tempUnitType = Thief (Plains)) else do (Do nothing)
          • If (tempInteger Egal à 7) then do (Set tempUnitType = Spider (Plains)) else do (Do nothing)
          • If (tempInteger Egal à 8) then do (Set tempUnitType = Bear (Plains)) else do (Do nothing)
          • If (tempInteger Egal à 9) then do (Set tempUnitType = Wolf (Plains)) else do (Do nothing)
          • If (tempInteger Egal à 10) then do (Set tempUnitType = Wolf (Plains)) else do (Do nothing)
          • If (tempInteger Egal à 11) then do (Set tempUnitType = Eagle (Plains)) else do (Do nothing)
          • Set APoint = (Random point in Plains_Region[(Random integer number between 1 and 13)])
          • Unité - Create 1 tempUnitType for Neutre Hostile at APoint facing (Random real number between 0.00 and 360.00) degrees
          • Unité - Set the custom value of (Last created unit) to 1
          • Custom script: call RemoveLocation(udg_APoint)
          • Set APoint = (Random point in Plains_Region[(Random integer number between 1 and 13)])
          • Unité - Order (Last created unit) to Patrouille vers APoint
          • Custom script: call RemoveLocation(udg_APoint)
          • Set tempInteger2 = (Random integer number between 1 and 100)
          • If (tempInteger2 Inférieur ou égal à 5) then do (Set tempUnitType = Dryad (Plains)) else do (Do nothing)
          • Set APoint = (Random point in Plains_Region[(Random integer number between 1 and 13)])
          • Unité - Create 1 tempUnitType for Neutre Hostile at APoint facing (Random real number between 0.00 and 360.00) degrees
          • Unité - Set the custom value of (Last created unit) to 1
          • Custom script: call RemoveLocation(udg_APoint)
          • Set APoint = (Random point in Plains_Region[(Random integer number between 1 and 13)])
          • Unité - Order (Last created unit) to Patrouille vers APoint
          • Custom script: call RemoveLocation(udg_APoint)
          • -------- Giants --------
          • Set tempInteger3 = (Random integer number between 1 and 110)
          • If (tempInteger3 Egal à 1) then do (Set tempUnitType = Giant Goblin (Plains)) else do (Do nothing)
          • If (tempInteger3 Egal à 2) then do (Set tempUnitType = Giant Eagle (Plains)) else do (Do nothing)
          • If (tempInteger3 Egal à 3) then do (Set tempUnitType = Giant Spider (Plains)) else do (Do nothing)
          • If (tempInteger3 Egal à 4) then do (Set tempUnitType = Giant Wolf (A)) else do (Do nothing)
          • Set APoint = (Random point in Plains_Region[(Random integer number between 1 and 13)])
          • Unité - Create 1 tempUnitType for Neutre Hostile at APoint facing (Random real number between 0.00 and 360.00) degrees
          • Unité - Set the custom value of (Last created unit) to 1
          • Custom script: call RemoveLocation(udg_APoint)
          • Set APoint = (Random point in Plains_Region[(Random integer number between 1 and 13)])
          • Unité - Order (Last created unit) to Patrouille vers APoint
          • Custom script: call RemoveLocation(udg_APoint)

To make them patrol
  • Plains Patrol
    • Evénements
      • Temps - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Set AUnitGroup = (Units in (Entire map) matching (((Custom value of (Matching unit)) Egal à 1) and ((Owner of (Matching unit)) Egal à Neutre Hostile)))
      • Groupe unité - Pick every unit in AUnitGroup and do (Actions)
        • Boucle - Actions
          • Set APoint = (Random point in Plains_Region[(Random integer number between 1 and 12)])
          • Unité - Order (Picked unit) to Patrouille vers APoint
          • Custom script: call RemoveLocation(udg_APoint)
      • Custom script: call DestroyGroup(udg_AUnitGroup)

I also have 2 more triggers for making the monsters patrol in the zone, and a timer for clearing out the zone if empty of heroes...

I seem to get fatal errors randomly after a long period of playing the map, and i cannot consciously make it crash when i want to, so i think this may be related to leaks? I honestly don't know.

Also, sorry for the weird code, my interface is in french and copies badly...
Thanks in advance for any answer.

edit: how do u guys show the triggers in gui on the forum??
edit2: ty! here are 2 reports of crashes i get
 
Last edited:
Level 25
Joined
Sep 26, 2009
Messages
2,378
edit: how do u guys show the triggers in gui on the forum??
Use the [TRIGGER][/TRIGGER] tags.


Leaks aren't the problem. What leaks cause is a steady decrease in FPS, until the game is so laggy it may end up freezing. THEN it may crash. However if your game is without any problems (FPS-wise) and then it suddenly crashes, then there is a problem somewhere in your map (usually its in triggers).

The only two leaks I see are in
1) Plains Activation trigger, where you create AUnitGroup, but you don't destroy it.
2) Plains Spawn trigger where you create a group in condition block and enumerate it, but you don't destroy it.
For this matter, I advise using a specific unit group where you will keep all these neutral hostile units with custom value 1. You wouldn't have to destroy the group and instead of creating the group anew each time you need them (e.g. all those "Pick every unit in entire map..."), you would simply iterate through the group in which they are saved.

What I see that can be improved is the following:
  • If (tempInteger Egal à 1) then do (Set tempUnitType = Flying Goblin (Plains)) else do (Do nothing)
  • If (tempInteger Egal à 2) then do (Set tempUnitType = Goblin (Plains)) else do (Do nothing)
  • If (tempInteger Egal à 3) then do (Set tempUnitType = Goblin (Plains)) else do (Do nothing)
  • If (tempInteger Egal à 4) then do (Set tempUnitType = Rat (Plains)) else do (Do nothing)
  • If (tempInteger Egal à 5) then do (Set tempUnitType = Thief (Plains)) else do (Do nothing)
  • If (tempInteger Egal à 6) then do (Set tempUnitType = Thief (Plains)) else do (Do nothing)
  • If (tempInteger Egal à 7) then do (Set tempUnitType = Spider (Plains)) else do (Do nothing)
  • If (tempInteger Egal à 8) then do (Set tempUnitType = Bear (Plains)) else do (Do nothing)
  • If (tempInteger Egal à 9) then do (Set tempUnitType = Wolf (Plains)) else do (Do nothing)
  • If (tempInteger Egal à 10) then do (Set tempUnitType = Wolf (Plains)) else do (Do nothing)
  • If (tempInteger Egal à 11) then do (Set tempUnitType = Eagle (Plains)) else do (Do nothing)
Instead of what you have now, you could create a unit-type array (for example CreepTypes[]) and set the creep unit-types into it upon map initialization. So you would have something like this:
  • Map Ini
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set CreepTypes[1] = Flying Goblin (Plains)
    • Set CreepTypes[2] = Goblin (Plains)
    • Set CreepTypes[3] = Goblin (Plains)
    • Set CreepTypes[4] = Rat (Plains)
    • ...etc.
And then in your actual trigger you would do:
  • Set tempUnitType = CreepTypes[(Random integer number between 1 and 11)]
It's much cleaner that way.

You could also do that for the giants and dryad (for example save them into the same CreepTypes[] array but with an offset - e.g. Dryad would be CreepTypes[15] and the Giants would be offset by 20 indices from their non-giant counterparts - so if a wolf is CreepTypes[10], Giant Wolf is CreepTypes[10+20]).


But that's pretty much it. I don't see anything in the triggers you posted that could cause game crash. Maybe the problem is in other triggers or in Object Editor data. Or it may be in some model - do the crashes occur after you imported new model(s)?
 
Level 3
Joined
Feb 3, 2009
Messages
33
Good idea on the creep_type variable! Argh i have so much to clean n_u

I got a lot of imported models but i've tested each one and they all work properly.. I think I have too much mess in my many triggers that i did years ago and that i HAVE to redo... im sure its something like a variable missing or some loop looping too much or w/e
 
Level 9
Joined
May 21, 2014
Messages
580
done! can my map crash because too many "for loop (integer A)..." are used simultaneously?

Nope, but if it went in an 'infinite loop', then it will crash.
EDIT: Wait... I read something about For Loops having a thread limitation or something. Let me find it.

EDIT 2:
Dr Super Good said:
In JASS loops are usually slower as every named field is resolved at runtime (no static linking). If your code is hitting the op limit it might be due to bad complexity or you simply need to run more threads. The op limit often is not helpful as one can make performance intensive triggers that hit the op limit after dropping many frames or simple triggers which hit the op limit without dropping a single frame. Bypass the oplimit by using global state and starting new threads.

Not sure what this means though but it's definitely something? lol
 
Last edited:
Level 3
Joined
Feb 3, 2009
Messages
33
a thread limitation? what is it? like integer A, B, Var ect?
and an infinite loop would be 2 loops with both conditions fulfilled?
 
Status
Not open for further replies.
Top