• 🏆 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] Custom Value Trigger; Able to shorten?

Status
Not open for further replies.
Level 3
Joined
May 6, 2007
Messages
66
  • Buying Units
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Unit Seller
    • Actions
      • Set buyer = (Buying unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Buying unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Unit - Change ownership of (Sold unit) to Neutral Extra and Retain color
          • Unit - Set the custom value of (Sold unit) to 1
          • Player - Add (Supply used by (Sold unit)) to Player 1 (Red) Food used
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Buying unit)) Equal to Player 2 (Blue)
            • Then - Actions
              • Unit - Change ownership of (Sold unit) to Neutral Extra and Retain color
              • Unit - Set the custom value of (Sold unit) to 2
              • Player - Add (Supply used by (Sold unit)) to Player 2 (Blue) Food used
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Buying unit)) Equal to Player 3 (Teal)
                • Then - Actions
                  • Unit - Change ownership of (Sold unit) to Neutral Extra and Retain color
                  • Unit - Set the custom value of (Sold unit) to 3
                  • Player - Add (Supply used by (Sold unit)) to Player 3 (Teal) Food used
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of (Buying unit)) Equal to Player 4 (Purple)
                    • Then - Actions
                      • Unit - Change ownership of (Sold unit) to Neutral Victim and Retain color
                      • Unit - Set the custom value of (Sold unit) to 4
                      • Player - Add (Supply used by (Sold unit)) to Player 4 (Purple) Food used
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Owner of (Buying unit)) Equal to Player 5 (Yellow)
                        • Then - Actions
                          • Unit - Change ownership of (Sold unit) to Neutral Victim and Retain color
                          • Unit - Set the custom value of (Sold unit) to 5
                          • Player - Add (Supply used by (Sold unit)) to Player 5 (Yellow) Food used
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Owner of (Buying unit)) Equal to Player 6 (Orange)
                            • Then - Actions
                              • Unit - Change ownership of (Sold unit) to Neutral Victim and Retain color
                              • Unit - Set the custom value of (Sold unit) to 6
                              • Player - Add (Supply used by (Sold unit)) to Player 6 (Orange) Food used
                            • Else - Actions
      • Unit - Order (Sold unit) to Right-Click buyer
I don't know if there are any errors, since I played only as player 1 so far. The main motive of this post is whether the above trigger could be shorter or not.
 
Level 15
Joined
Jan 31, 2007
Messages
502
This would be a bit shorter and easier i think

  • Buying Units
  • Events
  • Unit - A unit Sells a unit
  • Conditions
  • (Unit-type of (Triggering unit)) Equal to Unit Seller
  • Actions
  • Set buyer = (Buying unit)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • Or - Any (Conditions) are true
    • Conditions
    • (Owner of (Buying unit)) Equal to Player 1 (Red)
    • (Owner of (Buying unit)) Equal to Player 2 (Blue)
    • (Owner of (Buying unit)) Equal to Player 3 (Teal)
    • (Owner of (Buying unit)) Equal to Player 4 (Purpl)
    • (Owner of (Buying unit)) Equal to Player 5 (Yellow)
    • (Owner of (Buying unit)) Equal to Player 6 (Orange)
  • Then - Actions
    • Unit - Change ownership of (Sold unit) to Neutral Victim and Retain color
    • Unit - Set the custom value of (Sold unit) to Player number of (Owner of (Buying unit))
    • Player - Add (Supply used by (Sold unit)) to Owner of (Buying unit) Food used
    • Else - Actions
    • Unit - Order (Sold unit) to Right-Click buyer
 
Level 2
Joined
Apr 27, 2004
Messages
28
  • Buying Units
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Selling unit)) Equal to Unit seller
    • Actions
      • Set Buyer = (Buying unit)
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of Buyer) Equal to (Player((Integer A)))
            • Then - Actions
              • Unit - Change ownership of (Sold unit) to Neutral Victim and Retain color
              • Unit - Set the custom value of (Sold unit) to (Player number of (Owner of Buyer))
              • Player - Add (Supply used by (Sold unit)) to (Owner of Buyer) Food used
            • Else - Actions
              • Unit - Order (Sold unit) to Right-Click Buyer
 
Level 3
Joined
May 6, 2007
Messages
66
Thanks guys, pretty much gave me an idea what to do.

Too bad I needed two ifs, for two different forces. :/
 
Status
Not open for further replies.
Top