• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Trigger (lag)

Status
Not open for further replies.
Level 12
Joined
Jun 1, 2009
Messages
576
hi guys, this is trigger that i use in my map. I want to know what in this trigger couse so much lag and how to fix this:

  • Pick Cat
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • ((Sold unit) is A Hero) Equal to True
    • Actions
      • Unit - Remove (Random unit from (Units owned by (Owner of (Sold unit)) of type Pick Cat)) from the game
      • Unit - Remove (Sold unit) from the game
      • Unit - Create 1 (Unit-type of (Sold unit)) for (Owner of (Sold unit)) at (Random point in Center <gen>) facing (Position of (Triggering unit))
      • Camera - Pan camera for (Owner of (Last created unit)) to (Position of (Last created unit)) over 0.00 seconds
      • Selection - Select (Last created unit) for (Owner of (Last created unit))
      • If (Add_Santa Equal to True) then do (Hero - Create |cffFF0000Santa Hat and give it to (Last created unit)) else do (Do nothing)
      • Game - Display to (All players) for 5.00 seconds the text: (Player_Colors[(Player number of (Owner of (Buying unit)))] + ((Name of (Owner of (Buying unit))) + (|r + ( |cffC0C0C0picked|r + (|cff8080FF + ((Proper name of (Sold unit)) + |r))))))
 
OF MY GARD. XD. Man it is rly laggy, I havent opened we for more than halgf year but so obvios that you have Location leaks, allso use variables, set variables for unit, set unit-variable = sold unit, player variable = owner of unit-variable, not sold unit, location variable to position of unit-variable, also delete locations after using them, i dont remember screeps but I think it was call removelocation(udg_nameofvariable).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Unit - Remove (Sold unit) from the game
Unit - Create 1 (Unit-type of (Sold unit)) for (Owner of (Sold unit)) at (Random point in Center <gen>) facing (Position of (Triggering unit))
Seeing how you just removed "Sold unit" it is illogical that "(Unit-type of (Sold unit))" will return anything meaningful. You need to either store the unit type in a local variable or remove the unit after create a new one.

If it is the first time the unit is being sold it may not be preloaded and will cause some frame drops due to a resource stall (where the game main thread is forced to stop execution and wait for I/O to finish).
 
Variables can be your best friend. ;)

As above was said remove your leaks

Leaks:
  • Unit - Remove (Random unit from (Units owned by (Owner of (Sold unit)) of type Pick Cat)) from the game
  • Unit - Create 1 (Unit-type of (Sold unit)) for (Owner of (Sold unit)) at (Random point in Center <gen>) facing (Position of (Triggering unit))
  • Camera - Pan camera for (Owner of (Last created unit)) to (Position of (Last created unit)) over 0.00 seconds
Also, is following line working well?
  • Game - Display to (All players) for 5.00 seconds the text: (Player_Colors[(Player number of (Owner of (Buying unit)))] + ((Name of (Owner of (Buying unit))) + (|r + ( |cffC0C0C0picked|r + (|cff8080FF + ((Proper name of (Sold unit)) + |r))))))
I'm just asking because you remove 'Sold unit' before out of game.
 
Status
Not open for further replies.
Top