1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] Bug! it replaces one unit with more than one

Discussion in 'Triggers & Scripts' started by Ham, Feb 14, 2009.

  1. Ham

    Ham

    Joined:
    Jan 16, 2009
    Messages:
    132
    Resources:
    0
    Resources:
    0
    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:
     
  2. ZiggyMcjoney

    ZiggyMcjoney

    Joined:
    May 4, 2008
    Messages:
    109
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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.
     
  3. Ham

    Ham

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

    ZiggyMcjoney

    Joined:
    May 4, 2008
    Messages:
    109
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Could you post both triggers please?
     
  5. Ham

    Ham

    Joined:
    Jan 16, 2009
    Messages:
    132
    Resources:
    0
    Resources:
    0
    • 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)
     
  6. ZiggyMcjoney

    ZiggyMcjoney

    Joined:
    May 4, 2008
    Messages:
    109
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Code (Text):
    Set Mana = (Percentage mana of (Picked unit))
    There's no (Picked unit). Use (Triggering unit).
     
  7. Ham

    Ham

    Joined:
    Jan 16, 2009
    Messages:
    132
    Resources:
    0
    Resources:
    0
    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: Feb 14, 2009