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

[Solved] Need help with trigger that keeps track of player value

Status
Not open for further replies.
Level 2
Joined
Oct 7, 2017
Messages
11
I'm trying to make a map that displays the total value of each player, this tally's up all the units, buildings, and hero's the player owns along with their gold. Here's my trigger:
Player1Red
Events
Time - Every 0.10 seconds of game time
Conditions
(Player 1 (Red) slot status) Equal to Is playing
Actions
Player Group - Pick every player in Player Group - Player 1 (Red) and do (Set Player1RedHuman = (((Number of living Peasant units owned by (Picked player)) x 75) + (((Number of living Footman units owned by (Picked player)) x 135) + (((Number of living Knight units owned by (Picked player)) x 245) + (((Number of living Rifleman un
Player Group - Pick every player in Player Group - Player 1 (Red) and do (Set Player1RedOrc = (((Number of living Peon units owned by (Picked player)) x 75) + (((Number of living Grunt units owned by (Picked player)) x 200) + (((Number of living Raider units owned by (Picked player)) x 180) + (((Number of living Tauren units owned
Player Group - Pick every player in Player Group - Player 1 (Red) and do (Set Player1RedUndead = (((Number of living Acolyte units owned by (Picked player)) x 75) + (((Number of living Shade units owned by (Picked player)) x 75) + (((Number of living Ghoul units owned by (Picked player)) x 120) + (((Number of living Abomination un
Player Group - Pick every player in Player Group - Player 1 (Red) and do (Set Player1RedNightElf = (((Number of living Wisp units owned by (Picked player)) x 60) + (((Number of living Archer units owned by (Picked player)) x 130) + (((Number of living Huntress units owned by (Picked player)) x 195) + (((Number of living Dryad unit
Set Player1RedTotal = ((Player1RedHeros + Player1RedHuman) + ((Player1RedNightElf + Player1RedOrc) + (Player1RedUndead + (Player 1 (Red) Current gold))))
Multiboard - Set the text for (Last created multiboard) item in column 2, row Multiboard[(Player number of Player 1 (Red))] to (String(Player1RedTotal))


The problem is this creates massive memory leaks and lags after the first 2 minutes of gameplay. I don't know how to fix it without making it hella long with a million variables. Is there an easier way to do what I'm doing?
 
Level 2
Joined
Oct 7, 2017
Messages
11
Oh, my bad
So I ended up taking a different route of keeping track of value. I gave each unit a point value in the object editor equal to their bounty and gold cost. Then made this simple trigger; Game result is the players value.
  • KillsValue
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Player - Set (Owner of (Killing unit)) Game result to (((Owner of (Killing unit)) Game result) + (Point-value of (Dying unit)))
      • Player - Set (Owner of (Dying unit)) Game result to (((Owner of (Dying unit)) Game result) - (Point-value of (Dying unit)))
Doing this with heros was a little more complicated but it works;
  • HeroDies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Player - Set (Owner of (Triggering unit)) Game result to (((Owner of (Triggering unit)) Game result) - (130 + (((Hero level of (Triggering unit)) x 40) + ((((Hero level of (Triggering unit)) - 1) / 2) x 5))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Killing unit)) Not equal to (Owner of (Dying unit))
        • Then - Actions
          • Player - Add (130 + (((Hero level of (Triggering unit)) x 40) + ((((Hero level of (Triggering unit)) - 1) / 2) x 5))) to (Owner of (Killing unit)) Current gold
          • Player - Add (130 + (((Hero level of (Triggering unit)) x 40) + ((((Hero level of (Triggering unit)) - 1) / 2) x 5))) to (Owner of (Killing unit)) Game result
          • Special Effect - Create a special effect at (Position of (Triggering unit)) using UI\Feedback\GoldCredit\GoldCredit.mdl
          • Floating Text - Create floating text that reads (+ + (String((130 + (((Hero level of (Triggering unit)) x 40) + ((((Hero level of (Triggering unit)) - 1) / 2) x 5)))))) at (Position of (Triggering unit)) with Z offset 10.00, using font size 10.00, color (100.00%, 100.00%, 0.00%), and 0.00% transparency
          • Floating Text - Hide (Last created floating text) for (All players)
          • Floating Text - Show (Last created floating text) for (All players controlled by a ((Owner of (Killing unit)) controller) player)
          • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Floating Text - Change (Last created floating text): Disable permanence
          • Wait 2.00 seconds
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
The one thing I still can't figure out is I have many creeps and summons that give random bounty when killed, how can I detect what bounty is given and add that to the players value? I know I can turn off bounty and make a trigger that mimics bounty given but it's a pain to do this with 80+ units.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,232
The one thing I still can't figure out is I have many creeps and summons that give random bounty when killed, how can I detect what bounty is given and add that to the players value? I know I can turn off bounty and make a trigger that mimics bounty given but it's a pain to do this with 80+ units.
Might be possible by measuring gold change amounts.
 
Level 2
Joined
Oct 7, 2017
Messages
11
Yeah I can't figure it out, I ended up just giving every creep/summon a point value of X and changed only their base bounty to X.
I was thinking maybe if I redid all my triggers again and added the players gold along with other variables to the total value.
Then I could add a bunch of other triggers that would maintain the value as I spent gold, as the units are also counted toward value. But yeah to much work to completely redo everything and try to find something else that works. I'm lazy.
 
Level 2
Joined
Oct 7, 2017
Messages
11
Alright I'm back with another question onto this, how to I keep track of traded gold and add/subtract it to player value.
I know I can do traded gold through chat strings, but is there a way to get an even that detects the in game trading mechanic?
 
Level 2
Joined
Oct 7, 2017
Messages
11
Thank you, I ended up using this trigger;
  • Trade Gold Give P1
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
      • (Player 1 (Red) Gold Given To Allies) Greater than xREDGOLDGIVEN[1]
    • Actions
      • Player - Set Player 1 (Red) Game result to ((Player 1 (Red) Game result) - ((Player 1 (Red) Gold Given To Allies) - xREDGOLDGIVEN[1]))
      • Set xREDGOLDGIVEN[1] = (Player 1 (Red) Gold Given To Allies)
 
Level 2
Joined
Oct 7, 2017
Messages
11
I'm back, I procrastinate a lot.
How do I create a trigger that can make a player lose value when he researches something? Value lost is equal to the cost of the research.
I'm at:
Event:
A unit begins (research)

Then Idk

How do I create a trigger that increases/decreases a players value when he sells/buys an item; with this one I know how to create a trigger based on just one item, but then I have to make like 80 triggers for each item, is there a way to encompass all items with one trigger?
 
Status
Not open for further replies.
Top