• 🏆 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!

gold distribution {like in DotA?}

Status
Not open for further replies.
Level 5
Joined
Jul 24, 2008
Messages
106
hey guys. I need a gold distribution system like that of dota. it takes into account the number of present players in sentinel then divides equally X amount of gold between them. then it does the same for the scourge.

how do i do this? HELP PLEASE. THANKS! :) :goblin_yeah:
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Dont have editor right now around, but it should look like this:
Variables: goldinc - Integer variable -> amount of gold added to Sentforce within each second.
Sentforce - player group variable. tempgold - integer variable for calculating amount of gold every player will get.
Remember to add conditions, like if given player is controlled by User, and if his status is Playing.

  • init
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Set goldinc = 100
      • Set Sentforce = <set players you want to be in Sent player group>
      • Trigger - Turn on (gold loop <gen>)
  • gold loop
    • Events
      • Game - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set tempgold = (goldinc / (Number of players in Sentforce))
      • Player GroupPlayer - Pick every player in Sentforce and do actions
        • Loop - Actions
          • Player - Set Gold for (Picked player) to ((Current gold for (Picked player)) + tempgold)
      • If (All conditions are true) then do (then actions) else do (Else actions)
        • If - Condition
          • (Number of players in Sentforce) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Spinnaker, you should filter out leavers.
Since leavers in DotA will stop getting money per second, bear that in mind.

  • SGDS Dies
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) is an enemy of Player 1 (Red)) Equal to True
        • Then - Actions
          • For each (Integer LoopingInteger) from 1 to 5, do (Actions)
            • Loop - Actions
              • Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked player) slot status) Equal to Is playing
                    • Then - Actions
                      • Player - Add 1000 to (Picked player) Current gold
                    • Else - Actions
        • Else - Actions
          • For each (Integer LoopingInteger) from 7 to 11, do (Actions)
            • Loop - Actions
              • Player Group - Pick every player in (All allies of Player 7 (Green)) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked player) slot status) Equal to Is playing
                    • Then - Actions
                      • Player - Add 1000 to (Picked player) Current gold
                    • Else - Actions
Trigger above shows that if the player has left, it filters out the money, and only gives it to the remaining player (currently playing the game).

As for thread starter, you should be specific in stating your problem because in DotA, we can obtain gold in many ways, you should mention which method of obtaining gold is it (Sentinel/Scourge Kill, Neutral Kill, bla bla)

If for instance, we assume that Sentinel/Scourge Kill method,

  • SGDS Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • *Your Suitable Conditions*
    • Actions
      • Set GoldGain = (Random integer number between 225 and 250)
      • Set PlayerGroup = (All players matching ((((Matching player) slot status) Equal to Is playing) and (((Matching player) is an ally of (Owner of (Killing unit))) Equal to True)))
      • Set CurrentPlayers = (Number of players in PlayerGroup)
      • Set GoldGainPerPlayer = ((Real(GoldGain)) / (Real(CurrentPlayers)))
      • Player Group - Pick every player in PlayerGroup and do (Actions)
        • Loop - Actions
          • Player - Add (Integer(GoldGainPerPlayer)) to (Picked player) Current gold
      • Custom script: call DestroyForce(udg_PlayerGroup)
Trigger above will divide equally between players.
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
Spinnaker said:
Sentforce - player group variable. tempgold - integer variable for calculating amount of gold every player will get.
Remember to add conditions, like if given player is controlled by User, and if his status is Playing.

@defskull I haven't got editor around yesterday, so I said about conditions by words, NOT with triggers since I dont learn by heart every code.
 
Status
Not open for further replies.
Top