• 🏆 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] Bug! it replaces one unit with more than one

Status
Not open for further replies.

Ham

Ham

Level 5
Joined
Jan 16, 2009
Messages
132
anyone knows why this bugs and it replaces 1 unit with more than 1??

here:

  • Ressurect
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set HumanImpaled = (Units of type Human Impaled)
      • Unit Group - Pick every unit in HumanImpaled and do (Actions)
        • Loop - Actions
          • Trigger - Add to Ressurect2 <gen> the event (Unit - (Picked unit)'s mana becomes Greater than or equal to 1.00)
      • Custom script: call DestroyGroup (udg_HumanImpaled)
  • Ressurect2
    • Events
    • Conditions
    • Actions
      • Set Mana = (Percentage mana of (Triggering unit))
      • Unit - Remove (Triggering unit) from the game
      • Set Ethereal = (Units of type Explorer (Ethereal))
      • Unit Group - Pick every unit in Ethereal and do (Actions)
        • Loop - Actions
          • Unit - Replace (Picked unit) with a Explorer (Corporeal) using The old unit's relative life and mana
          • Unit - Set mana of (Picked unit) to Mana%
      • Custom script: call DestroyGroup (udg_Ethereal)
1.jpg
2.jpg
3.jpg

:confused:
 
Level 4
Joined
May 4, 2008
Messages
113
It's because your periodic trigger is continually adding events to your trigger, and if the same event is added twice, then the trigger will run twice. If it's added 3 times, then same thing goes.

So the solution: Make a unit group variable called DontAdd or something. Then do this with your trigger:

  • Ressurect
  • Events
    • Time - Every 1.00 seconds of game time
  • Conditions
  • Actions
    • Set HumanImpaled = (Units of type Human Impaled)
    • Unit Group - Pick every unit in HumanImpaled and do (Actions)
      • Loop - Actions
        • If all conditions are true then do (Then actions) else do (Else actions):
          • If:
            • (Picked unit) is in DontAdd Equal to False
          • Then:
            • Unit Group - Add (Picked unit) to DontAdd
            • Trigger - Add to Ressurect2 <gen> the event (Unit - (Picked unit)'s mana becomes Greater than or equal to 1.00)
          • Else:
  • Custom script: call DestroyGroup (udg_HumanImpaled)
Trigger looks a little messy cause I handwrote it but hope that helps.
 

Ham

Ham

Level 5
Joined
Jan 16, 2009
Messages
132
Thanks this really worked, but now the replaced unit's is not taking the value of the impaled human's mana :S
 

Ham

Ham

Level 5
Joined
Jan 16, 2009
Messages
132
  • Ressurect
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set HumanImpaled = (Units of type Human Impaled)
      • Unit Group - Pick every unit in HumanImpaled and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in DontAdd) Equal to False
            • Then - Actions
              • Unit Group - Add (Picked unit) to DontAdd
              • Trigger - Add to Ressurect2 <gen> the event (Unit - (Picked unit)'s mana becomes Greater than or equal to 1.00)
            • Else - Actions
      • Custom script: call DestroyGroup (udg_HumanImpaled)
  • Ressurect2
    • Events
    • Conditions
    • Actions
      • Set Mana = (Percentage mana of (Picked unit))
      • Unit - Remove (Triggering unit) from the game
      • Set Ethereal = (Units of type Explorer (Ethereal))
      • Unit Group - Pick every unit in Ethereal and do (Actions)
        • Loop - Actions
          • Unit - Replace (Picked unit) with a Explorer (Corporeal) using The old unit's relative life and mana
          • Unit - Set mana of (Picked unit) to Mana%
      • Custom script: call DestroyGroup (udg_Ethereal)
 

Ham

Ham

Level 5
Joined
Jan 16, 2009
Messages
132
Unit - Set mana of (Picked unit) to Mana%

this was the trouble, it's not picked, it's last replaced ^^

EDIT: ok now that i've tested it with two friends, and when both of them has an ImpaledBody (unit) the trigger picks both units and not the owners one :S why?
 
Last edited:
Status
Not open for further replies.
Top