• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Multiplicating bug

Status
Not open for further replies.
Level 17
Joined
Jan 21, 2010
Messages
2,111
I got this trigger, and it's bugging
when i tried to "mark" a monster (using skill to a unit), instead replacing it with proper unit, it's making 3 new replacer unit
1 monster + Mark = 4 pet monster

  • Some Bug occured here
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to (==) Mark (All Heroes)
              • (Unit-type of (Triggering unit)) Equal to (==) Owner[(Integer A)]
            • Then - Actions
              • Set Count[(Player number of (Owner of (Triggering unit)))] = (Count[(Player number of (Owner of (Triggering unit)))] + 1)
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Count[(Player number of (Owner of (Triggering unit)))] Greater than (>) 5
                  • Then - Actions
                    • Unit - Order (Triggering unit) to Stop
                    • Game - Display to (All players matching ((Matching player) Equal to (==) (Owner of (Triggering unit)))) the text: You can't have more...
                  • Else - Actions
            • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[1]
                • Then - Actions
                  • Unit - Replace (Target unit of ability being cast) with a Pet_Type[1] using The new unit's max life and mana
                  • Unit - Add Pet (All Pet) to (Last replaced unit)
                  • Selection - Add (Last replaced unit) to selection for (Owner of (Last replaced unit))
                  • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
                • Else - Actions
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[2]
                    • Then - Actions
                      • Unit - Replace (Target unit of ability being cast) with a Pet_Type[2] using The new unit's max life and mana
                      • Unit - Add Pet (All Pet) to (Last replaced unit)
                      • Selection - Add (Last replaced unit) to selection for (Owner of (Last replaced unit))
                      • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
                    • Else - Actions
                      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[4]
                        • Then - Actions
                          • Unit - Add Pet (All Pet) to (Target unit of ability being cast)
                          • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
                          • Unit - Remove All buffs from (Target unit of ability being cast)
                        • Else - Actions
                          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[5]
                            • Then - Actions
                              • Unit - Add Pet (All Pet) to (Target unit of ability being cast)
                              • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
                              • Unit - Remove All buffs from (Target unit of ability being cast)
                            • Else - Actions
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
like this?


  • Check the Pets
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to (==) Mark (All Heroes)
              • (Unit-type of (Triggering unit)) Equal to (==) Owner[(Integer A)]
            • Then - Actions
              • Set Count[(Player number of (Owner of (Triggering unit)))] = (Count[(Player number of (Owner of (Triggering unit)))] + 1)
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Count[(Player number of (Owner of (Triggering unit)))] Greater than (>) 5
                  • Then - Actions
                    • Unit - Order (Triggering unit) to Stop
                    • Game - Display to (All players matching ((Matching player) Equal to (==) (Owner of (Triggering unit)))) the text: You can't have more...
                  • Else - Actions
            • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[1]
                • Then - Actions
                  • Unit - Replace (Target unit of ability being cast) with a Pet_Type[1] using The new unit's max life and mana
                  • Unit - Add Pet (All Pet) to (Last replaced unit)
                  • Selection - Add (Last replaced unit) to selection for (Owner of (Last replaced unit))
                  • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
                • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[2]
                • Then - Actions
                  • Unit - Replace (Target unit of ability being cast) with a Pet_Type[2] using The new unit's max life and mana
                  • Unit - Add Pet (All Pet) to (Last replaced unit)
                  • Selection - Add (Last replaced unit) to selection for (Owner of (Last replaced unit))
                  • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
                • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[4]
                • Then - Actions
                  • Unit - Add Pet (All Pet) to (Target unit of ability being cast)
                  • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
                  • Unit - Remove All buffs from (Target unit of ability being cast)
                • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[5]
                • Then - Actions
                  • Unit - Add Pet (All Pet) to (Target unit of ability being cast)
                  • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
                  • Unit - Remove All buffs from (Target unit of ability being cast)
                • Else - Actions
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
uh oh..
sorry for that

  • Check the Pets
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to (==) Mark (All Heroes)
              • (Unit-type of (Triggering unit)) Equal to (==) Owner[(Integer A)]
            • Then - Actions
              • Set Count[(Player number of (Owner of (Triggering unit)))] = (Count[(Player number of (Owner of (Triggering unit)))] + 1)
                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Count[(Player number of (Owner of (Triggering unit)))] Greater than (>) 5
                  • Then - Actions
                    • Unit - Order (Triggering unit) to Stop
                    • Game - Display to (All players matching ((Matching player) Equal to (==) (Owner of (Triggering unit)))) the text: You can't have more...
                  • Else - Actions
            • Else - Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[1]
        • Then - Actions
          • Unit - Replace (Target unit of ability being cast) with a Pet_Type[1] using The new unit's max life and mana
          • Unit - Add Pet (All Pet) to (Last replaced unit)
          • Selection - Add (Last replaced unit) to selection for (Owner of (Last replaced unit))
          • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
        • Else - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[2]
            • Then - Actions
              • Unit - Replace (Target unit of ability being cast) with a Pet_Type[2] using The new unit's max life and mana
              • Unit - Add Pet (All Pet) to (Last replaced unit)
              • Selection - Add (Last replaced unit) to selection for (Owner of (Last replaced unit))
              • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
            • Else - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[4]
                • Then - Actions
                  • Unit - Add Pet (All Pet) to (Target unit of ability being cast)
                  • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
                  • Unit - Remove All buffs from (Target unit of ability being cast)
                • Else - Actions
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Target unit of ability being cast)) Equal to (==) Non_Pet_Type[5]
                    • Then - Actions
                      • Unit - Add Pet (All Pet) to (Target unit of ability being cast)
                      • Unit Group - Add (Target unit of ability being cast) to Pet[(Player number of (Owner of (Triggering unit)))]
                      • Unit - Remove All buffs from (Target unit of ability being cast)
                    • Else - Actions
 
Improved script.
t - unit-type variable;
u - unit variable
i - integer variable
p - player variable
force - player group variable

I'd consider replacing (Integer A) with custom integer if I were you as well.
Additionaly: I'm unsure if ordering unit to stop in way, you've done that in your trigger will work properly.
  • Check the Pets
    • Events
      • Unit - A unit Startf effect of an ability
    • Conditions
      • (Ability being cast) Equal to (==) Mark (All Heroes)
    • Actions
      • Set p = (Triggering player)
      • Set i = (Player number of p)
      • Set u = (Triggering unit)
      • Set t = (Unit-type of u)
      • Do Multiple ActionsFor each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • t Equal to (==) Owner[(Integer A)]
            • Then - Actions
              • Set Count[i] = (Count[i] + 1)
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Count[i] Greater than (>) 5
                • Then - Actions
                  • Unit - Order u to Stop
                  • Set force = (Player group(p))
                  • Game - Display to force the text: You can't have more...
                  • Custom script: call DestroyForce(udg_force)
                • Else - Actions
            • Else - Actions
      • Set u = (Target unit of ability being cast)
      • Set t = (Unit-type of u)
      • Do Multiple ActionsFor each (Integer A) from 1 to 2, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • t Equal to (==) Non_Pet_Type[(Integer A)]
            • Then - Actions
              • Unit - Replace u with a Pet_Type[(Integer A)] using The new unit's max life and mana
              • Unit - Add Pet (All Pet) to (Last replaced unit)
              • Selection - Add (Last replaced unit) to selection for (Owner of (Last replaced unit))
              • Unit Group - Add u to Pet[i]
              • Trigger - Skip remaining actions
      • Do Multiple ActionsFor each (Integer A) from 4 to 5, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • t Equal to (==) Non_Pet_Type[(Integer A)]
            • Then - Actions
              • Unit - Add Pet (All Pet) to u
              • Unit Group - Add u to Pet[i]
              • Unit - Remove All buffs from u
              • Trigger - Skip remaining actions
            • Else - Actions
 
Status
Not open for further replies.
Top