• 🏆 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!

Question regarding efficiency.

Status
Not open for further replies.
Level 3
Joined
Nov 22, 2014
Messages
50
I have a map in which players can have a lot of triggered items with a bunch of them responding to damage done. It's a hero survival, so every player has just a single hero.

I am using a damage detection system:
GUI-Friendly Damage Detection -- v1.2.1 -- by Weep

And now I wonder if having a shitload of trigers responding to damage instances will really hurt game performances.
Now I could keep track wether a player has one of the items, and turn the trigger off if nobody has the said item, or I can just not mind.

Example of a 'reduces all damage by 20%' item:
Keeping track of items:
  • EquilibriumAcquired
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Equilibrium
    • Actions
      • Set EquilibriumAmount[(Player number of (Owner of (Triggering unit)))] = (EquilibriumAmount[(Player number of (Owner of (Triggering unit)))] + 1)
      • If (((Triggering unit) is in EquilibriumOwners) Equal to False) then do (Unit Group - Add (Triggering unit) to EquilibriumOwners) else do (Do nothing)
      • Trigger - Turn on EquilibriumDamage <gen>
      • Trigger - Turn on EquilibriumLost <gen>
  • EquilibriumDamage
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamagedUnit is in EquilibriumOwners) Equal to True
    • Actions
      • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + (0.20 x GDD_Damage))
  • EquilibriumLost
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Equilibrium
    • Actions
      • Set EquilibriumAmount[(Player number of (Owner of (Triggering unit)))] = (EquilibriumAmount[(Player number of (Owner of (Triggering unit)))] - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • EquilibriumAmount[(Player number of (Owner of (Triggering unit)))] Equal to 0
        • Then - Actions
          • Unit Group - Remove (Triggering unit) from EquilibriumOwners
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (EquilibriumOwners is empty) Equal to True
            • Then - Actions
              • Trigger - Turn off (This trigger)
              • Trigger - Turn off EquilibriumDamage <gen>
            • Else - Actions
        • Else - Actions

Or I can just:
  • EquilibriumDamage Copy
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamagedUnit has an item of type Equilibrium) Equal to True
    • Actions
      • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + (0.20 x GDD_Damage))
Which is less triggers, but will be running al game long.

What would be better in regard to game performance?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
You would be better off using DamageEngine for this. If the unit has full health and gets damaged, it will be damaged for the full amount.

  • On Damage
    • Events
      • Game - DamageModifierEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventTarget has an item of type Equilibrium) Equal to True
    • Actions
      • Set DamageEventAmount = (DamageEventAmount x 0.80)
You can turn off/on the trigger if you want to, but I would keep the unit-has-item check and not use the unit group option nevertheless.

If a bunch of damage events firing at once will cause an issue, one of the best things you can do is to add a bunch of if/then/else actions in a smaller number of damage triggers. That will drastically improve performance.
 
Level 3
Joined
Nov 22, 2014
Messages
50
You can turn off/on the trigger if you want to, but I would keep the unit-has-item check and not use the unit group option nevertheless.

I guess that simplifies it... just keeping track of the total amount of items picked up and dropped.
I would get this:

  • EquilibriumAcquired
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Equilibrium
    • Actions
      • Set EquilibriumAmount = (EquilibriumAmount + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • EquilibriumAmount Equal to 1
        • Then - Actions
          • Trigger - Turn on EquilibriumDamage <gen>
          • Trigger - Turn on EquilibriumLost <gen>
        • Else - Actions
  • EquilibriumDamage
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamagedUnit has an item of type Equilibrium) Equal to True
    • Actions
      • Unit - Set life of GDD_DamagedUnit to ((Life of GDD_DamagedUnit) + (0.20 x GDD_Damage))
  • EquilibriumLost
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Equilibrium
    • Actions
      • Set EquilibriumAmount = (EquilibriumAmount - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • EquilibriumAmount Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Trigger - Turn off EquilibriumDamage <gen>
        • Else - Actions

If a bunch of damage events firing at once will cause an issue, one of the best things you can do is to add a bunch of if/then/else actions in a smaller number of damage triggers. That will drastically improve performance.

I don't really want to put everything in response to a damage event in a single trigger because I fear that might make the trigger to chaotic to find anything back.

I understand there is a flaw in this damage reduction, but I have done everything with weeps damage detection system and I am reluctant to change the whole map.

But in regard to the topic, may I conclude that it is a good idea to close any damage event trigger that is not needed at the time?
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
Yes, if the damage trigger won't need to be on and it's easy enough to turn it off and on when needed, then do so.

Damage Engine is backwards-compatible with Weep's system so you will not have to change anything in your scripts. Just install damage engine (I made a video tutorial how to do it) and replace Weep's GDD with the cross-compatibility version of it I made.
 

Ardenian

A

Ardenian

  • Trigger - Turn off (This trigger)
  • Trigger - Turn off EquilibriumDamage <gen>
Is this safe ? Does the trigger finishes its actions even after being turned off ?
I would reverse these two actions in order.
 
Status
Not open for further replies.
Top