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

Bounty from ally

Status
Not open for further replies.
Level 1
Joined
Aug 22, 2016
Messages
6
Hi
Im currently working on a TD map where I want the player to get the gold when an ally AI is killing the unit. there will be no player units killing the monsters, only AI units and I cant seem to find a way to make that ally AI give gold to the player when it kills a unit wether its player 1,2, 3 or 4 its supposed to give it to. There are up to 4 players and one AI. the AI units spawns when the wave starts where the player's(wether its player 1,2,3 or 4) units were positioned.

Its my first time making a map like this in the editor so I might have missed something obvious but idk
Also tried to find it in several forums but havent really found an answer suitable to this, though I might have missed one while browsing

Thanks in advance :D
 
Level 1
Joined
Aug 22, 2016
Messages
6
The bounty is on for the enemy, but it is given to the ally AI when it kills a unit. I want it to be given to the player from where that ally AI unit was spawned. e.g player 1 builds an archer(building), then the ally AI spawn an archer on the position of player 1's archer when the wave starts, fighting for the player(s). when that archer kills a unit, I want it to give the bounty to the player that created the archer that spawned the ally AI archer.

Sorry for being a bit unclear in the original post.
 
Level 4
Joined
Jul 26, 2016
Messages
88
Oh, you could use custom value of unit if you aren't using a unit indexing system, unit groups, or hashtables.

Custom value like so: when you create the unit for AI, save (Player number of Owner of (that built unit)) as custom value of that archer being created when you create the archer. When the archer kills a creep, add however many gold to Player (Custom value of archer)

Unit groups: make a unit group array variable with size 4, then do: When archer spawns, add the archer to Unit Group (Owner of unit that finished constrution (so your Building - archer basically)). Get the principle? All archers spawned by player 1 will be in unitgroup[1], those spawned by player two in unitgroup[2], etc.... Then when a creep gets killed, you can check: if killing unit is in unitgroup[1], add x gold to player 1, else....

Hashtables is the same principle, if you would like an explanation (since those are slightly more indepth) do ask.

The principle stays: You must have a way to save the original creator of the unit to the unit. Since the units all belong to AI we cannot use (owner) simply, so we have to save that information as: the custom value of a unit, or unit appartenance to a unit group, or as a hastable value.

Do not hesitate to ask further!
 
Level 13
Joined
Mar 24, 2013
Messages
1,105
You'll need to trigger the gold gain.

So what you need to do is, each player needs to have their own computer player. So if your map has 6 players, player 1 needs player 7, player 2 needs player 8 etc. (This could technically be changed you could do it with a single computer or even a few, to do that you would instead add the created computer units to a unit group that you would define as being the one's that fight for player 1/2/3 etc and then when it kills check which group that unit is in. If this is too complex stick with what I said first.) Edit: This is in the same vein as what was said above with Unit Groups, doing with each player requiring a computer is not really an ideal way but it is the most simple.

Then you simply need to catch when Unit Dies > Owner Of killing unit == player 7 > Get The Unit Type of the what just died. Look at a catalog to know how much gold to get (more on this in a second). Then add the value to the proper player's current gold. If you want you can also create a floating text of the gold value to see the familiar "+50" or whatever it might be.

What I mean by look at a catalog is:
In a trigger you'll need to save the correct values for each unit.
UnitId[1] = Footman
UnitId[2] = Rifleman
TotalNumberOfUnitIds = 2 (This changes as you add a Knight, Grunt etc.)
Bounty[1] = 50 (These need to be the bounty you want the respective index to mean, so here a footman is worth 50 gold.
Bounty[2] = 75

As for the actual trigger that would run... I had a minute so it should look something like this:

  • Bounty Per player
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set TempUnit = (Killing unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of TempUnit) Equal to Player 7 (Green)
        • Then - Actions
          • Set TempPlayer = Player 1 (Red)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of TempUnit) Equal to Player 8 (Pink)
            • Then - Actions
              • Set TempPlayer = Player 2 (Blue)
            • Else - Actions
      • For each (Integer TempInteger) from 1 to TotalNumberOfUnitIds, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of TempUnit) Equal to UnitId[TempInteger]
            • Then - Actions
              • Set TempInteger2 = Bounty[TempInteger]
              • Player - Set TempPlayer Current gold to ((TempPlayer Current gold) + TempInteger2)
              • Floating Text - Create floating text that reads (|c00fffc01+ + (String(TempInteger2))) at TempPoint with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Set TempFloat = (Last created floating text)
              • Floating Text - Set the velocity of TempFloat to 64.00 towards 90.00 degrees
              • Floating Text - Change TempFloat: Disable permanence
              • Floating Text - Change the lifespan of TempFloat to 4.00 seconds
              • Floating Text - Change the fading age of TempFloat to 4.00 seconds
            • Else - Actions
 
Level 1
Joined
Aug 22, 2016
Messages
6
Thanks for the replies :) I will look into this when I get back to working on the map tomorrow afternoon(for me)
 
Level 1
Joined
Aug 22, 2016
Messages
6
Unit groups: make a unit group array variable with size 4, then do: When archer spawns, add the archer to Unit Group (Owner of unit that finished constrution (so your Building - archer basically)). Get the principle? All archers spawned by player 1 will be in unitgroup[1], those spawned by player two in unitgroup[2], etc.... Then when a creep gets killed, you can check: if killing unit is in unitgroup[1], add x gold to player 1, else....

Since I already have 4 groups like this(1 for each player's towers/units) and they're all set up and ready, I guess this suggestion is the easiest to do. however, im assuming this wont show the money over a unit that gets killed like it would if a player's unit killed that enemy unit? If thats right I could combine this with p0ke's trigger where he adds a floating text over the dying unit :D

I'll try this out when I get home
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,019
Every player has 1 invulnerable builder unit right? If you don't want to make your own text you could just make more copies of the dying unit, hide them, and then cause the builder to deal lots of damage to them, which would then show the gold. Bad pseudocode:
Code:
Unit Dies
Check which player killed it
Figure out which player should get gold
Create 1 of (dying unit) at (dying unit's position)
Hide (last created unit)
Add locust to (last created unit)
Cause the right player's builder to damage (last created unit) for 9999999 damage
Note that you want to use the 'cause damage' function, not tell it to attack, since cause damage happens independent of distance and doesn't interrupt orders. Adding locust may also not be necessary (can't remember how hide unit function works atm) and that death sounds will play twice I think. It's also possible I'm completely wrong and hidden units won't show gold bounty, so probably test that first.
 
Level 4
Joined
Jul 26, 2016
Messages
88
You could do what pyro said, or simply use floating text (yellow color, default velocity towards 90 degrees, whichever size i have no idea, 1-1.5 sec lifespan should work fine)
 
Level 1
Joined
Aug 22, 2016
Messages
6
hmmm, death sound playing twice sounds like quite a downside to that solution, but if it didnt play twice that would be a good idea though
 
Level 1
Joined
Aug 22, 2016
Messages
6
Alright, so I figured out a quite easy way to fix the issue by using the groups and wave system I had already made :D

It basically checks how much gold the unit spawning in the current wave is supposed to give(which is defined by an array and the wave), gives it to the player when the unit dies and I made a floating text appear over the dying unit showing how much you earned as it usually does when your unit kills it.

Thanks a lot for the help to all of you!
now I can move on to the next issues :p (armor and damage upgrade related stuff)
 
Status
Not open for further replies.
Top