• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Why doesn't this trigger work?!

Status
Not open for further replies.
Level 5
Joined
Nov 13, 2008
Messages
41
So the key is to split an equal amount of gold among players.
Example: Team 1: 5 players. Each player gets 1000 gold. Team 2: 2 players. Each player gets 2500 gold. Oh and it needs to skip players 1 and 7 since they are computers.

attachment.php
 

Attachments

  • trigger.jpg
    trigger.jpg
    519.7 KB · Views: 156
1. count how many players are in the team.
2. calculate the gold per player (total/number in team).
3. itterate through the players in the team giving them the gold per player amount of gold.

Repeat for both teams.

What I would do is make a function that takes a force and the gold to share and then does the above 3 steps.
I would then generate 2 forces (1 for each team) in my initialization function.

Your slot layout makes it prety easy. Players 1-5 are in the first force while players 7-11 are in the second force (remember that players are in the range of 0 to 15 (inclusive) with 0 to 11 being the 12 human players).

These 2 forces I would then process to check if the players they contain are actually present in the game. Another custom function that takes a force and returns a new force could be made which itterates through all players in the force and transfers only those that are present to the new force before destroying the old force and returning the new.

Finally 2 calls with those forces to the share function I described would suffice.

Final program flow...
1. Divide players into two teams.
2. Filter inactive players from both teams.
3. Share gold between members of a team for both teams.

1 and 2 could be combined so that it filters before adding to the initial teams but you risk incresed procedural coupling.
 
  • Save gold
    • Events
      • Unit - Your event here
    • Conditions
    • Actions
      • Set yourGold = The amount of gold you want
  • Gold
    • Events
      • Unit - Your event here
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is A structure) Equal YourCondition
        • Then - Actions
          • Unit Group - Add (YourUnit) to group1
          • Set playersInGroup = (playersInGroup + 1)
          • Player - Add (yourGold / playersInGroup) to (Owner of (YourUnit)) Current gold
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is A structure) Equal to YourCOndition
        • Then - Actions
          • Unit Group - Add (yourunit) to group2
          • Set playersInGroup = (playersInGroup + 1)
          • Player - Add (yourGold / playersInGroup2) to (Owner of (yourunit)) Current gold
        • Else - Actions
Do something like the triggers above! :)
 
Status
Not open for further replies.
Back
Top