• 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.

Weird thing about a trigger

Status
Not open for further replies.
Level 15
Joined
Oct 29, 2012
Messages
1,474
HI LOL. -_-
I have a simple trigger that works like this:
'When a farm (there are 5 types) finishes training an animal , it automatically trains another one . If the animals' number isn't max , the animals are level 1 . But if the animals' number is max ( of course after training the unit ) , one random unit from all animals with same type becomes level 2 . But the weird thing is :
it's happening to Player 1 only , All other players don't have their animals upgrades even with max animals which 200 or 300 ( depends on mode ) . Well I tried to make ' Game - Show to all players number of current animals' which is AniCount . It was O.K
AND ALSO OTHER PLAYERS HAVE THEIR ANIMALS NOT SPAWNING WHEN THEY REACH MAX ANIMALS , THEY JUST NEED TO START SPAWNING . HERE IS THE TRIGGER :

  • Spawned Animals and mercs
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Unit-type of (Trained unit)) is Undead) Equal to True
        • Then - Actions
          • Set TempPoint = (Rally-Point of (Triggering unit) as a point)
          • Set TempPoint1 = (Position of (Triggering unit))
          • Set TempPoint2 = (TempPoint1 offset by 64.00 towards (Angle from TempPoint1 to TempPoint) degrees)
          • Set TempPlayer = (Owner of (Triggering unit))
          • Set TempInteger = (Player number of TempPlayer)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Chicken
            • Then - Actions
              • Unit - Order (Triggering unit) to train/upgrade to a Chicken
              • Unit - Remove (Trained unit) from the game
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AniCount[(Player number of (Owner of (Triggering unit)))] Less than AnimalsMaximum
                • Then - Actions
                  • Unit - Create 1 Chicken for Neutral Victim at TempPoint2 facing Default building facing degrees
                  • Unit Group - Add (Last created unit) to AniChicks[(Player number of (Owner of (Triggering unit)))]
                  • Set AniCount[(Player number of (Owner of (Triggering unit)))] = (AniCount[(Player number of (Owner of (Triggering unit)))] + 1)
                  • Unit - Move (Last created unit) instantly to TempPoint2
                  • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                  • Unit - Order (Last created unit) to Move To TempPoint
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • AniCount[(Player number of (Owner of (Triggering unit)))] Greater than or equal to AnimalsMaximum
                    • Then - Actions
                      • Set TempUnit = (Random unit from AniChicks[(Player number of (Owner of (Triggering unit)))])
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • TempUnit Not equal to No unit
                        • Then - Actions
                          • Set TempPoint3 = (Position of TempUnit)
                          • Unit Group - Remove TempUnit from AniChicks[(Player number of (Owner of (Triggering unit)))]
                          • Unit - Remove TempUnit from the game
                          • Unit - Create 1 Golden Chicken (Level 2) for Neutral Victim at TempPoint3 facing Default building facing degrees
                          • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                          • Unit - Create 1 FeralSpiritEffect for Neutral Passive at TempPoint3 facing Default building facing degrees
                          • Animation - Change (Last created unit)'s size to (30.00%, 30.00%, 30.00%) of its original size
                          • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                        • Else - Actions
                    • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Trained unit)) Equal to Sheep
                • Then - Actions
                  • Unit - Order (Triggering unit) to train/upgrade to a Sheep
                  • Unit - Remove (Trained unit) from the game
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • AniCount[(Player number of (Owner of (Triggering unit)))] Less than AnimalsMaximum
                    • Then - Actions
                      • Unit - Create 1 Sheep for Neutral Victim at TempPoint2 facing Default building facing degrees
                      • Unit Group - Add (Last created unit) to AniSheep[(Player number of (Owner of (Triggering unit)))]
                      • Set AniCount[(Player number of (Owner of (Triggering unit)))] = (AniCount[(Player number of (Owner of (Triggering unit)))] + 1)
                      • Unit - Move (Last created unit) instantly to TempPoint2
                      • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                      • Unit - Order (Last created unit) to Move To TempPoint
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • AniCount[(Player number of (Owner of (Triggering unit)))] Greater than or equal to AnimalsMaximum
                        • Then - Actions
                          • Set TempUnit = (Random unit from AniSheep[(Player number of (Owner of (Triggering unit)))])
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • TempUnit Not equal to No unit
                            • Then - Actions
                              • Set TempPoint3 = (Position of TempUnit)
                              • Unit Group - Remove TempUnit from AniSheep[(Player number of (Owner of (Triggering unit)))]
                              • Unit - Remove TempUnit from the game
                              • Unit - Create 1 Black Sheep (Level 2) for Neutral Victim at TempPoint3 facing Default building facing degrees
                              • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                              • Unit - Create 1 FeralSpiritEffect for Neutral Passive at TempPoint3 facing Default building facing degrees
                              • Animation - Change (Last created unit)'s size to (30.00%, 30.00%, 30.00%) of its original size
                              • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                            • Else - Actions
                        • Else - Actions
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Trained unit)) Equal to Pig
                    • Then - Actions
                      • Unit - Order (Triggering unit) to train/upgrade to a Pig
                      • Unit - Remove (Trained unit) from the game
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • AniCount[(Player number of (Owner of (Triggering unit)))] Less than AnimalsMaximum
                        • Then - Actions
                          • Unit - Create 1 Pig for Neutral Victim at TempPoint2 facing Default building facing degrees
                          • Unit Group - Add (Last created unit) to AniPigs[(Player number of (Owner of (Triggering unit)))]
                          • Set AniCount[(Player number of (Owner of (Triggering unit)))] = (AniCount[(Player number of (Owner of (Triggering unit)))] + 1)
                          • Unit - Move (Last created unit) instantly to TempPoint2
                          • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                          • Unit - Order (Last created unit) to Move To TempPoint
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • AniCount[(Player number of (Owner of (Triggering unit)))] Greater than or equal to AnimalsMaximum
                            • Then - Actions
                              • Set TempUnit = (Random unit from AniPigs[(Player number of (Owner of (Triggering unit)))])
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • TempUnit Not equal to No unit
                                • Then - Actions
                                  • Set TempPoint3 = (Position of TempUnit)
                                  • Unit Group - Remove TempUnit from AniPigs[(Player number of (Owner of (Triggering unit)))]
                                  • Unit - Remove TempUnit from the game
                                  • Unit - Create 1 Fat Pig (Level 2) for Neutral Victim at TempPoint3 facing Default building facing degrees
                                  • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                                  • Unit - Create 1 FeralSpiritEffect for Neutral Passive at TempPoint3 facing Default building facing degrees
                                  • Animation - Change (Last created unit)'s size to (30.00%, 30.00%, 30.00%) of its original size
                                  • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                                • Else - Actions
                            • Else - Actions
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Trained unit)) Equal to Rabbit
                        • Then - Actions
                          • Unit - Order (Triggering unit) to train/upgrade to a Rabbit
                          • Unit - Remove (Trained unit) from the game
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • AniCount[(Player number of (Owner of (Triggering unit)))] Less than AnimalsMaximum
                            • Then - Actions
                              • Unit - Create 1 Rabbit for Neutral Victim at TempPoint2 facing Default building facing degrees
                              • Unit Group - Add (Last created unit) to AniRabbits[(Player number of (Owner of (Triggering unit)))]
                              • Set AniCount[(Player number of (Owner of (Triggering unit)))] = (AniCount[(Player number of (Owner of (Triggering unit)))] + 1)
                              • Unit - Move (Last created unit) instantly to TempPoint2
                              • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                              • Unit - Order (Last created unit) to Move To TempPoint
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • AniCount[(Player number of (Owner of (Triggering unit)))] Greater than or equal to AnimalsMaximum
                                • Then - Actions
                                  • Set TempUnit = (Random unit from AniRabbits[(Player number of (Owner of (Triggering unit)))])
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • TempUnit Not equal to No unit
                                    • Then - Actions
                                      • Set TempPoint3 = (Position of TempUnit)
                                      • Unit Group - Remove TempUnit from AniRabbits[(Player number of (Owner of (Triggering unit)))]
                                      • Unit - Remove TempUnit from the game
                                      • Unit - Create 1 Green Rabbit (Level 2) for Neutral Victim at TempPoint3 facing Default building facing degrees
                                      • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                                      • Unit - Create 1 FeralSpiritEffect for Neutral Passive at TempPoint3 facing Default building facing degrees
                                      • Animation - Change (Last created unit)'s size to (30.00%, 30.00%, 30.00%) of its original size
                                      • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                                    • Else - Actions
                                • Else - Actions
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Unit-type of (Trained unit)) Equal to Cow
                            • Then - Actions
                              • Unit - Order (Triggering unit) to train/upgrade to a Cow
                              • Unit - Remove (Trained unit) from the game
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • AniCount[(Player number of (Owner of (Triggering unit)))] Less than AnimalsMaximum
                                • Then - Actions
                                  • Unit - Create 1 Cow for Neutral Victim at TempPoint2 facing Default building facing degrees
                                  • Unit Group - Add (Last created unit) to AniCows[TempInteger]
                                  • Set AniCount[(Player number of (Owner of (Triggering unit)))] = (AniCount[(Player number of (Owner of (Triggering unit)))] + 1)
                                  • Unit - Move (Last created unit) instantly to TempPoint2
                                  • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                                  • Unit - Order (Last created unit) to Move To TempPoint
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • AniCount[(Player number of (Owner of (Triggering unit)))] Greater than or equal to AnimalsMaximum
                                    • Then - Actions
                                      • Set TempUnit = (Random unit from AniCows[(Player number of (Owner of (Triggering unit)))])
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • TempUnit Not equal to No unit
                                        • Then - Actions
                                          • Set TempPoint3 = (Position of TempUnit)
                                          • Unit Group - Remove TempUnit from AniCows[(Player number of (Owner of (Triggering unit)))]
                                          • Unit - Remove TempUnit from the game
                                          • Unit - Create 1 Brown Cow ( Level 2 ) for Neutral Victim at TempPoint3 facing Default building facing degrees
                                          • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
                                          • Unit - Create 1 FeralSpiritEffect for Neutral Passive at TempPoint3 facing Default building facing degrees
                                          • Animation - Change (Last created unit)'s size to (30.00%, 30.00%, 30.00%) of its original size
                                          • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                                        • Else - Actions
                                    • Else - Actions
                            • Else - Actions
          • Unit - Add Ghost (Visible) to (Last created unit)
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint1)
          • Custom script: call RemoveLocation(udg_TempPoint2)
        • Else - Actions
          • Set TempPlayer = (Owner of (Trained unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Random Mercenary
            • Then - Actions
              • Unit - Remove (Trained unit) from the game
              • Unit - Order (Triggering unit) to train/upgrade to a Random Mercenary
              • Set TempPoint2 = (Random point in revRect[(Random integer number between 1 and 30)])
              • -------- toto ma ostat ake je (jednotky) --------
              • Set TempInteger = (Random integer number between 1 and 14)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Player 10 (Light Blue) Food used) Less than 50
                • Then - Actions
                  • Unit - Create 1 mercType[TempInteger] for Player 10 (Light Blue) at TempPoint2 facing Default building facing degrees
                  • Unit - Change color of (Last created unit) to (Color of TempPlayer)
                  • AI - Ignore (Last created unit)'s guard position
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TempInteger Equal to 7
                    • Then - Actions
                      • Unit Group - Add (Last created unit) to Trappers
                    • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in MercAttackGroup) Greater than 0
                    • Then - Actions
                    • Else - Actions
                      • Set TempInt = (Random integer number between 1 and 18)
                      • Set TempPoint1 = (Random point in wayRect[TempInt])
                      • Unit - Set level of RegionWanderer (Neutral Hostile) for (Last created unit) to TempInt
                      • Unit - Order (Last created unit) to Attack-Move To TempPoint1
                      • Unit - Create 1 TeleportEffect for Neutral Passive at TempPoint2 facing Default building facing degrees
                      • Unit - Add a 6.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Neutral Hostile Food used) Less than 60
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of units in MercAttackGroup) Greater than 0
                        • Then - Actions
                        • Else - Actions
                          • Set TempInt = (Random integer number between 1 and 18)
                          • Set TempPoint1 = (Random point in wayRect[TempInt])
                          • Unit - Add RegionWanderer (Neutral Hostile) to (Triggering unit)
                          • Unit - Order (Last created unit) to Attack-Move To TempPoint1
                          • Unit - Create 1 TeleportEffect for Neutral Passive at TempPoint2 facing Default building facing degrees
                          • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
                    • Else - Actions
              • Custom script: call RemoveLocation (udg_TempPoint1)
              • Custom script: call RemoveLocation (udg_TempPoint2)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Trained unit)) Equal to Peon
                • Then - Actions
                  • Set TempPoint = (Rally-Point of (Triggering unit) as a point)
                  • Set TempPoint1 = (Position of (Triggering unit))
                  • Set TempPoint2 = (TempPoint1 offset by 64.00 towards (Angle from TempPoint1 to TempPoint) degrees)
                  • Unit - Remove (Trained unit) from the game
                  • Unit - Create 1 Peon for (Owner of (Triggering unit)) at TempPoint2 facing Default building facing degrees
                  • Custom script: call RemoveLocation(udg_TempPoint)
                  • Custom script: call RemoveLocation(udg_TempPoint1)
                  • Custom script: call RemoveLocation(udg_TempPoint2)
                • Else - Actions
      • Game - Display to (All players) the text: (String(AniCount[(Player number of (Owner of (Triggering unit)))]))
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
I'm sorry. I've never been good at MUI. But I did notice something. You have a leak.

TempPoint3 is never removed.

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • TempUnit Not equal to No unit
    • Then - Actions
    • Set TempPoint3 = (Position of TempUnit)
  • Unit Group - Remove TempUnit from AniCows[(Player number of (Owner of (Triggering unit)))]
  • Unit - Remove TempUnit from the game
  • Unit - Create 1 Brown Cow ( Level 2 ) for Neutral Victim at TempPoint3 facing Default building facing degrees
  • Unit - Set the custom value of (Last created unit) to (Player number of (Owner of (Triggering unit)))
  • Unit - Create 1 FeralSpiritEffect for Neutral Passive at TempPoint3 facing Default building facing degrees
  • Animation - Change (Last created unit)'s size to (30.00%, 30.00%, 30.00%) of its original size
  • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
 

Rheiko

Spell Reviewer
Level 25
Joined
Aug 27, 2013
Messages
4,121
Set TempPlayer = (Owner of (Triggering unit)) use triggering player instead
AniCount[(Player number of (Owner of (Triggering unit)))] Less than AnimalsMaximum why don't AniCount[TempInteger]?

sorry, but the rest will catch up tomorrow
it's 9:52 PM now (maybe you think it's still early) and i am really tired
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Add this to a variable: (Player number of (Owner of (Triggering unit)))

On the variable editor, set the default size of the Animals Unit Groups to 12, else, it's size is "1" and the rest of the indexes returns null since they're not initialized.

Your triggering... is really bad. There's many, many, a lot, plenty room for improvement.

You could nest all this with a Hashtable using Farms and Animals id's to make it work automatically. ITE chains are almost never the correct way to achieve stuff.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Add this to a variable: (Player number of (Owner of (Triggering unit)))

On the variable editor, set the default size of the Animals Unit Groups to 12, else, it's size is "1" and the rest of the indexes returns null since they're not initialized

What do you mean ? :O
I think I already have 'Player number..' in a variable..
The second hing ,, umm I don't know
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
In fact, you have... but

  • t
    • AniCount[(Player number of (Owner of (Triggering unit)))] Less than AnimalsMaximum
    • Unit Group - Remove TempUnit from AniChicks[(Player number of (Owner of (Triggering unit)))]
    • Set AniCount[(Player number of (Owner of (Triggering unit)))] = (AniCount[(Player number of (Owner of (Triggering unit)))] + 1)
    • AniCount[(Player number of (Owner of (Triggering unit)))] Greater than or equal to AnimalsMaximum
  • and so on...
Not using it is like not having it.
 
Status
Not open for further replies.
Top