• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Why does this trigger destroy FPS

Status
Not open for further replies.
Level 11
Joined
Sep 25, 2013
Messages
604
Hello, is there a way I can make a trigger with the same function as the one below that doesn't take away 15-20 fps? I don't know too much about triggers and really nothing about jass. Should i change it so the floating text moves to a point instead of a unit and make TempPoint variable which I can later remove with a custom script? Thank you for your time

  • Tradesman Text Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet tempUnitGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet PickedUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of PickedUnit) Equal to Tradesman
                  • (Unit-type of PickedUnit) Equal to Native Tradesman
            • Then - Actions
              • Floating Text - Change the position of (Load TradesmanFloatingTextNumber of (Key (Picked unit).) in TradesmanHashtable) to PickedUnit with Z offset 0.00.
            • Else - Actions
      • Custom script: call DestroyGroup (udg_tempUnitGroup)

EDIT: OK! so I did away with the tempUnitGroup and instead added the units when they were trained to a preestablished unit group. So now it looks like this and it performs a lot better. Guess checking every units in the playable map area is something that should be avoided lol. If anyone knows any ways I can optimize further, please let me know!

  • Tradesman Text Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TradesmanUnitGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet PickedUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of PickedUnit) Equal to European Tradesman
                  • (Unit-type of PickedUnit) Equal to Native Tradesman
            • Then - Actions
              • Floating Text - Change the position of (Load TradesmanFloatingTextNumber of (Key (Picked unit).) in TradesmanHashtable) to PickedUnit with Z offset 0.00.
            • Else - Actions
 
Last edited:
Level 2
Joined
Feb 14, 2020
Messages
19
What you are doing is putting every unit in the entire map in a group every 0.03 seconds. Then you iterate through every unit in said group, all units on the map for your specific unit.
What you want to do is make your group matching conditions.

  • Set VariableSet tempUnitGroup = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Footman) or ((Unit-type of (Matching unit)) Equal to Rifleman)))
This way you already have the units you wanna modify in the group. The more you can narrow it down the less its gonna cost you in computing power.

In the end it should maybe look something like this?
  • Tradesman Text Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet tempUnitGroup = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Footman) or ((Unit-type of (Matching unit)) Equal to Rifleman)))
      • Unit Group - Pick every unit in tempUnitGroup and do (Actions)
        • Loop - Actions
          • Floating Text - Change the position of (Load TradesmanFloatingTextNumber of (Key (Picked unit).) in TradesmanHashtable) to PickedUnit with Z offset 0.00.
      • Custom script: call DestroyGroup (udg_tempUnitGroup)
No need to set a variable to your picked unit, use the picked unit option
 
Last edited:
Level 42
Joined
Feb 27, 2007
Messages
5,326
You can attach floating text to a unit so it automatically moves with the unit instead of having to do this manually.
uess checking every units in the playable map area is something that should be avoided lol.
It should absolutely never be done with a frequency anywhere close to 0.03; in a large map with lots of units I would recommend not doing it at all.
 
Level 42
Joined
Feb 27, 2007
Messages
5,326
@Biglover Doing it that way is literally exactly the same. It still filters through all the units on the map to compare their unit type each time the trigger runs.
The more you can narrow it down the less its gonna cost you in computing power
In fact it's the exact opposite because the filter still has to look at every unit. Also it evaluates each condition for each unit until it finds one for that unit that isn't true (then skips it and moves on) so the more conditions you put the more checks it has to make.
 
Level 2
Joined
Feb 14, 2020
Messages
19
@Biglover Doing it that way is literally exactly the same. It still filters through all the units on the map to compare their unit type each time the trigger runs.

In fact it's the exact opposite because the filter still has to look at every unit. Also it evaluates each condition for each unit until it finds one for that unit that isn't true (then skips it and moves on) so the more conditions you put the more checks it has to make.

Yea, youre right when I think abou it
 
Status
Not open for further replies.
Top