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

[General] Is there a delay when removing a unit?

Status
Not open for further replies.
Level 26
Joined
Feb 2, 2006
Messages
1,695
I have the following trigger to replace a hero unit:
  • Actions
    • -------- Store Data --------
    • Set VariableSet ReplaceUnitStrength = (Strength of ReplaceUnit (Exclude bonuses))
    • Set VariableSet ReplaceUnitAgility = (Agility of ReplaceUnit (Exclude bonuses))
    • Set VariableSet ReplaceUnitIntelligence = (Intelligence of ReplaceUnit (Exclude bonuses))
    • Set VariableSet ReplaceUnitProperName = (Proper name of ReplaceUnit)
    • Set VariableSet ReplaceUnitHeroAbilityLvlRob = (Level of Rob for ReplaceUnit)
    • Set VariableSet ReplaceUnitHeroAbilityLvlBlink = (Level of Blinzeln for ReplaceUnit)
    • -------- Replacement --------
    • Unit - Replace ReplaceUnit with a ReplaceUnitNewUnitType using The old unit's relative life and mana
    • Hero - Modify Strength of (Last replaced unit): Set to ReplaceUnitStrength.
    • Hero - Modify Agility of (Last replaced unit): Set to ReplaceUnitAgility.
    • Hero - Modify Intelligence of (Last replaced unit): Set to ReplaceUnitIntelligence.
    • Hero - Set Name of (Last replaced unit) to ReplaceUnitProperName
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • ReplaceUnitHeroAbilityLvlRob Greater than 0
      • Then - Actions
        • For each (Integer A) from 1 to ReplaceUnitHeroAbilityLvlRob, do (Actions)
          • Loop - Actions
            • Hero - Learn skill for (Last replaced unit): Rob
      • Else - Actions
        • Do nothing
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • ReplaceUnitHeroAbilityLvlBlink Greater than 0
      • Then - Actions
        • For each (Integer A) from 1 to ReplaceUnitHeroAbilityLvlBlink, do (Actions)
          • Loop - Actions
            • Hero - Learn skill for (Last replaced unit): Blinzeln
      • Else - Actions
        • Do nothing
    • Game - Display to (All players) the text: (Replaced + ((Name of ReplaceUnit) + ( with + (Name of (Last replaced unit)))))
    • Wait 1.00 seconds
    • Game - Display to (All players) the text: (Count healthy humans: + (String((Number of units in (Units of type Healthy Human)))))
Without the delay of 1 second at the bottom, it prints the number 2. With the delay of 1, it prints the number of 1.
I am wondering if the RemoveUnit call in the ReplaceUnit call has some delay?!
 
There are some actions in the trigger that might cause other triggers with certain events to run:
  • RemovingUnit -> triggers event "Deindex"
  • CreatingUnit -> triggers event "EntersRegion"
  • LearnHeroSkill -> triggers event "A hero learns skill"
... there are also some hidden actions one might not keep in mind when using ReplaceUnit function:
  • SetUnitState life/mana -> triggers event "A unit's life becomes ..."
  • SetHeroXP -> triggers event "A unit gains level" or is there even a "A hero gains xp" event? (not sure)
Maybe there's also just a completly other trigger that runs during this "Wait 1.00 Seconds", unrelated to the trigger above?

===

Is there a reason not to use bearform or alike? Maybe it's here an elegant way instead of using ReplaceUnit.

===

IntegerA is risky to use here for the loop, because "Hero - Learn skill" will fire triggers that are registered to "A hero learns skill" event, which might take usage/manipulate the IntegerA value in itself. A new variable for such tasks would do though. ( Interfering Problem here: [GUI] - [How-to] Loop In GUI!)

===

Is the unit type of healthy human related to the trigger?
 
Level 26
Joined
Feb 2, 2006
Messages
1,695
Yes I want to replace the unit completely since I need different hero abilities. That's why I am not using Bearform. Okay I might replace Integer A but I am pretty sure I have no trigger with the event Learn Skill.
The trigger is called with a Healty Human as ReplaceUnit and it is changed to the new type ReplacedUnitNewUnitType.
Hence, after calling this trigger BEFORE the wait the counter should be minus 1. But it is only minus 1 AFTER the wait?!
 
Status
Not open for further replies.
Top