• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Detecting peasant return gold/lumber

Status
Not open for further replies.
Level 3
Joined
Apr 29, 2009
Messages
32
You could always try use 3 triggers to detect and give resources for each peasant.

  • PeasantTrained
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Peasant
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Trained unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Set Peasants[1] = (Peasants[1] + 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Trained unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • Set Peasants[2] = (Peasants[2] + 1)
        • Else - Actions
Keep doing If Then Else for each player.
Peasant = Integer Array X amount of players
  • Resource
    • Events
      • Time - Every X seconds of game time
    • Conditions
    • Actions
      • Player - Add (Peasants[1] x Y) to Player 1 (Red) Current gold
      • Player - Add (Peasants[1] x N) to Player 1 (Red) Current lumber
      • Player - Add (Peasants[2] x Y) to Player 2 (Blue) Current gold
      • Player - Add (Peasants[2] x N) to Player 2 (Blue) Current lumber
X = Seconds
Y = Amount of gold you want to give them for each peasant.
N = Amount of lumber you want to give them for each peasant.
  • PeasentDie
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peasant
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Set Peasants[1] = (Peasants[1] - 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • Set Peasants[2] = (Peasants[2] - 1)
        • Else - Actions
Hope it was this you were looking for. :) Good luck!
 
Status
Not open for further replies.
Top