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

Trigger Causes Lag Spike and I don't Know Why

Status
Not open for further replies.
Level 18
Joined
Mar 16, 2008
Messages
721
It's < 1 second lag spike map wide for all players. I think it's the create event Action. Does anyone know how to stop the lag spikes? Thank you for any insight.

  • Yellow Hero Trained
    • Events
      • Unit - Altar of Knights 0352 <gen> Finishes training a unit
    • Conditions
    • Actions
      • Set VariableSet Yellow_Hero = (Trained unit)
      • Trigger - Add to Blank Ankh Used Yellow <gen> the event (Unit - Yellow_Hero's life becomes Less than or equal to 100.00)
      • Leaderboard - Change the value for Player 5 (Yellow) in Alliances_Leaderboard to 1
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 5 (Yellow) is in Group1Red.) Equal to True
        • Then - Actions
          • Unit - Change color of Yellow_Hero to Red
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 5 (Yellow) is in Group2Blue.) Equal to True
        • Then - Actions
          • Unit - Change color of Yellow_Hero to Blue
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 5 (Yellow) is in Group3Teal.) Equal to True
        • Then - Actions
          • Unit - Change color of Yellow_Hero to Teal
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 5 (Yellow) is in Group4Purp.) Equal to True
        • Then - Actions
          • Unit - Change color of Yellow_Hero to Purple
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 5 (Yellow) is in Black_Group_Var.) Equal to True
        • Then - Actions
          • Unit - Change color of Yellow_Hero to Coal
        • Else - Actions
      • Trigger - Turn on Yellow Hero Revives <gen>
      • Trigger - Turn off (This trigger)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
If these units are removed frequently then recreating the trigger periodically might help to free up all the events. Removed units do not remove all events associated with that unit, only destroying the trigger does.

When a unit is first created it is possible that some lag/stutter will happen the instant it is created. This is due to "asset stalls" as the unit, ability and buff data for the unit is loaded in. It should not happen subsequent times the unit is created.
 
Level 18
Joined
Mar 16, 2008
Messages
721
Do you know if it's possible to avoid the stall? Or can you imagine some other way to load this event? We just don't know what hero the player will pick.

Just feel like it makes my map look like it's poorly made (which may or may not be true hah) if 8 players pick heroes and everyone gets random lag spikes accordingly.

Thank you for confirming my suspicion anyway.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
It looks like you're not taking advantage of Arrays. Things like Yellow_Hero could be replaced with Hero[5], 5 being the Player number of Yellow.
  • Unit - Create 1 SomeHero for (Triggering player)...
  • Set Variable Hero[Player number of (Triggering player)] = Last created unit

Also, Adding Events like this is generally bad practice:
  • Trigger - Add to Blank Ankh Used Yellow <gen> the event (Unit - Yellow_Hero's life becomes Less than or equal to 100.00)
There's often far better solutions out there. Although, in some cases these are unavoidable.

Anyway, it looks like you're trying to detect Reincarnation. I believe I linked you the solution before: GUI Unit Event v2.5.2.0

The way it works is a hidden Defend ability is added to your units. It was discovered that a unit with the Defend ability will issue an "undefend" order when it dies (or begins reincarnating), which we can then detect using an Issued Order Event.

This is useful because a unit with an active Reincarnation ability doesn't fire a Death Event when it dies, so this Order detection is our only solution. The unit is not even even considered Dead in this situation. So if a unit issues the "undefend" order, and it's still alive, and it has this hidden Defend ability, then we know for a fact that it's Reincarnating. Bribe's system takes some extra steps to ensure that everything works properly but I think you could probably get away with using a trigger as simple as this:
  • Example
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(undefend))
      • (Level of Defend (Hidden) for (Triggering unit)) Equal to 1
      • (Triggering unit) is Alive Equal to True
    • Actions
      • -------- (Triggering unit) is reincarnating. Do whatever you want now. --------

Of course, your unit NEEDS the Defend (Hidden) ability for this to work. What you would do is copy and paste the standard Defend ability in the Object Editor and remove it's Hotkey. It may even be wise to create a new Upgrade that is inaccessible and use that as the Requirement for the ability to ensure that a unit can never cast it. To hide an ability, set it's Art Button Positions to: X: 0, Y: -11.

Lastly, if you add this ability to your Heroes through triggers you must make it permanent:
  • Custom script : call UnitMakeAbilityPermanent(udg_YourUnit, true, udg_YourAbility)
Otherwise, the ability will be lost when the Hero dies. Alternatively, you can give all of your Heroes this ability through the Object Editor which will make it permanent by default.
 
Last edited:
Status
Not open for further replies.
Top