Im trying to make a trigger to get the last attacking unit but cant figure it out.
example(well really its a certain spell casted on the unit)
player 1 hits player 2(player 1 I want to be the killing unit)
if someone else hits player 2 before player 2 dies though, I want them to become the killing unit unit
The reason why I say killing unit is because, when a unit dies in my map, Only the person who last targeted that unit with my custom spell, will get credit. This ability doesnt do damage or anything.
I need this for mulitple players 12 infact
so I just need a trigger that whenever you cast my ability on a target, you become the killing unit of that target(so you could be the killing unit of player 1-2-3-4 all at the same time). Then whenever that target happens to die, the killing unit player will get 1 point.
Just have a unit type variable (name it somethign like killing_unit)
And then go into your trigger that deals damage, and set this variable to the unit that is casting the ability
This way the trigger will stop being activated for the targeted unit once it dies and you are left with the variable listing the last attacking unit.
If you wanna be extra sure that the variable is 100% right, then make two if loops (one in side the other and set them to be true)
First one, check to see if target's health is above 0, and 2 check to see if the units health is below zero after you factor in the damage dealt, If both return true then you can add a score to whichever unit/player who killed the targeted unit.
Wow and i did all this without opening the editor XD let me know if this works!
Don't I need some other variable? Since multiple units can have it?
example: player 1 and player 4 have both used my ability I made, player 1 used it on player2, and player4 used it on player5
so now when player5 dies I need +1point to player4, and whenever player2 dies, I need player1 to get +1point.(long as no one attacked after them)
I'm guessing with your way when player5 dies, both player 1 and 4 would get +1point which I dont want, however your probably a lot smarter then me on triggers so im not sure.
well when the damaging trigger is initiated the targeted player takes the damage instantly, so using the unit variable (i just realized i said unit type, dont use unit type lol, just use unit) you should be able to determine the last unit who dealt damage to the target unit before it dies, unless your damage type is dealt over a period of time.
But yah like i said before throw in the set variable function, and then throw in those two triggers and test it in your map (just place two units in the center of the map owned by different players for which you have control over, and give it a go.
hmm Maybe the trigger for the last hit is working, its just the point thing isn't can you help on that?
My 1st trigger is
E. unit uses ability fire at generic6 complete stage
A. set killing player(owner of triggering unit)=target unit for triggering order
thats like what you said right?
Im stuck on how to make it so when that target unit later dies to give points to the right person though. What would I put for action
set variable
I know I need to make an integer variable named points or something but how would I set it up?
You could just make an integer array where when ever a player casts the spell on another player, their number fills the slot' and when ever a player dies, it just checks the array to see who gets the point. So for example...
Player one casts spell on player 2, set the 2nd integer in the array to 1
When player 2 dies, check 2nd integer in array, its 1... player 1 gets the point..
No, well when you die you get the same type of unit back, does that matter?
Like everyone starts with a zealot, and the last person to attack each zealot, should get +1 point when that zealot dies, then that dying unit is replaced by a new zealot.
So if you last attack player 2's zealot, then player 2 dies, you get +1 point, player 2 now has another zealot spawn, or
Player 5 attacks player 3's zealot, then player player 4 attacks player 3's zealot, later player 3's zealot dies, only player 4 would get +1 point.
Im probably going to have it be 11 players(10+1 computer)Players are not on the same team though.
Make a player array variable called "LASTATTACKER" and set its index to the maximum you want (according to what you said, 11 should be enough)
You can then make so that when an enemy attack a zealot, set "LASTATTACKER[owning the attacked zealot] = Owner of Attacking Zealot
For example, if the player 4 use your special ability on player 6's zealot : "LASTATTACKER[6] = Player 4"
To do so you'll have to use an event detecing the use of your ability and to store ATTACKING UNITS and ATTACKED UNITS.
Then you can do a global "LASTATTACKER[Attacked Unit] = Owner of Attacking unit"
Then you can reuse LASTATTACKER variable to determine who get the reward.
Actions - Give 1 point to last_attacker(Player number(Owner of dying unit))
Points is an integer variable right?
so set points=(I cant do last attacker because its not an integer, and I can't find any conversion)
Unless I'm missing something... I just don't see how you made that trigger
As I said, the LASTATTACKER Variable is a player variable (not a player group or player color), and you need to check the array box to make it an array variable.
You don't seems to be familiar with triggers so I'll explain it to you.
LASTATTACKER is a variable that will stock the player that last attacked a player.
As there is 11 players, the LASTATTACKER variable is divided to fit every player : LASTATTACKER[1] will save the last player to have attacked player 1.
LASTATTACKER[2] will save the last player to have attacked player 2 and so on. So let's say the Player 4 attacked Player 2's unit :
Set LASTATTACKER[2] = Player 4
To make a general trigger, you will have to "Set LASTATTACKER[Owner of attacked unit] = Owner of attacking unit"
To give a reward, you'll then need to set an event that detect when an unit dies.
You can then use your variable "LASTATTACKER" to get who get the reward.
To add a point, you can set "POINT = POINT + 1" using arithmetic function.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Im trying to make a trigger to get the last attacking unit but cant figure it out. example(well really its a certain spell casted on the unit)
player 1 hits player 2(player 1 I want to be the killing unit) if someone else hits player 2 before player 2 dies though, I want them to become the killing unit unit
The reason why I say killing unit is because, when a unit dies in my map, Only the person who last targeted that unit with my custom spell, will get credit. This ability doesnt do damage or anything.
I need this for mulitple players 12 infact so I just need a trigger that whenever you cast my ability on a target, you become the killing unit of that target(so you could be the killing unit of player 1-2-3-4 all at the same time). Then whenever that target happens to die, the killing unit player will get 1 point.
@threeleven: Go
Just have a unit type variable (name it somethign like killing_unit)
And then go into your trigger that deals damage, and set this variable to the unit that is casting the ability
This way the trigger will stop being activated for the targeted unit once it dies and you are left with the variable listing the last attacking unit.
If you wanna be extra sure that the variable is 100% right, then make two if loops (one in side the other and set them to be true)
First one, check to see if target's health is above 0, and 2 check to see if the units health is below zero after you factor in the damage dealt, If both return true then you can add a score to whichever unit/player who killed the targeted unit.
Wow and i did all this without opening the editor XD let me know if this works!
@Dumorah: Go
Don't I need some other variable? Since multiple units can have it?
example: player 1 and player 4 have both used my ability I made, player 1 used it on player2, and player4 used it on player5
so now when player5 dies I need +1point to player4, and whenever player2 dies, I need player1 to get +1point.(long as no one attacked after them)
I'm guessing with your way when player5 dies, both player 1 and 4 would get +1point which I dont want, however your probably a lot smarter then me on triggers so im not sure.
@threeleven: Go
well when the damaging trigger is initiated the targeted player takes the damage instantly, so using the unit variable (i just realized i said unit type, dont use unit type lol, just use unit) you should be able to determine the last unit who dealt damage to the target unit before it dies, unless your damage type is dealt over a period of time.
But yah like i said before throw in the set variable function, and then throw in those two triggers and test it in your map (just place two units in the center of the map owned by different players for which you have control over, and give it a go.
@Dumorah: Go
Still don't understand. Also my spell does no damage, is that why?
@threeleven: Go
hmm Maybe the trigger for the last hit is working, its just the point thing isn't can you help on that?
My 1st trigger is E. unit uses ability fire at generic6 complete stage A. set killing player(owner of triggering unit)=target unit for triggering order thats like what you said right?
Im stuck on how to make it so when that target unit later dies to give points to the right person though. What would I put for action set variable
I know I need to make an integer variable named points or something but how would I set it up?
@threeleven: Go
does the damaging trigger work in the first place?
@Dumorah: Go
I ment my spell doesn't do damage, like it isn't suppose to. There is no trigger to damage. My spell works fine though
You could just make an integer array where when ever a player casts the spell on another player, their number fills the slot' and when ever a player dies, it just checks the array to see who gets the point. So for example...
Player one casts spell on player 2, set the 2nd integer in the array to 1
When player 2 dies, check 2nd integer in array, its 1... player 1 gets the point..
@c0nnick: Go
Ya thats what I want to do, but for some reason cant figure out the exact trigger, or its not working, not sure if I'm missing something or what
Are there multiple units per player?
@c0nnick: Go
No, well when you die you get the same type of unit back, does that matter? Like everyone starts with a zealot, and the last person to attack each zealot, should get +1 point when that zealot dies, then that dying unit is replaced by a new zealot.
So if you last attack player 2's zealot, then player 2 dies, you get +1 point, player 2 now has another zealot spawn, or Player 5 attacks player 3's zealot, then player player 4 attacks player 3's zealot, later player 3's zealot dies, only player 4 would get +1 point. Im probably going to have it be 11 players(10+1 computer)Players are not on the same team though.
@threeleven: Go
Seems like an easy trigger not sure why I cant figure it out
@threeleven: Go
any help so I can have map ready on launch?
Make a player array variable called "LASTATTACKER" and set its index to the maximum you want (according to what you said, 11 should be enough)
You can then make so that when an enemy attack a zealot, set "LASTATTACKER[owning the attacked zealot] = Owner of Attacking Zealot For example, if the player 4 use your special ability on player 6's zealot : "LASTATTACKER[6] = Player 4"
To do so you'll have to use an event detecing the use of your ability and to store ATTACKING UNITS and ATTACKED UNITS. Then you can do a global "LASTATTACKER[Attacked Unit] = Owner of Attacking unit"
Then you can reuse LASTATTACKER variable to determine who get the reward.
@Yaos01: Go
Unit - Any Unit uses Fire at Generic6 - Complete stage (Include shared abilities)
Variable - Set last attacker[(Owner of (Target unit for (Triggering order)))] = (Player group((Owner of (Triggering unit))))
Is that right for trigger 1?
Im still lost on how to do the points, and I'm not sure if that is right^ I dunno how to tell
My last attacker variable is a player group array of 11(I tried player color but it doesn't seem right, when I try to set it) is this right?
Last_Attacker is a player array with a size of 11..
Event 1 - Unit casts Your_Spell
Actions - Set last_attacker(player number(Owner of targeted unit)) = Owner of Casting unit
Event 2 - Unit Dies
Actions - Give 1 point to last_attacker(Player number(Owner of dying unit))
@c0nnick: Go
Still have no idea how you are doing
Actions - Give 1 point to last_attacker(Player number(Owner of dying unit))
Points is an integer variable right? so set points=(I cant do last attacker because its not an integer, and I can't find any conversion) Unless I'm missing something... I just don't see how you made that trigger
@threeleven: Go
I don't get what you don't understand.
As I said, the LASTATTACKER Variable is a player variable (not a player group or player color), and you need to check the array box to make it an array variable. You don't seems to be familiar with triggers so I'll explain it to you.
LASTATTACKER is a variable that will stock the player that last attacked a player.
As there is 11 players, the LASTATTACKER variable is divided to fit every player : LASTATTACKER[1] will save the last player to have attacked player 1. LASTATTACKER[2] will save the last player to have attacked player 2 and so on. So let's say the Player 4 attacked Player 2's unit :
Set LASTATTACKER[2] = Player 4
To make a general trigger, you will have to "Set LASTATTACKER[Owner of attacked unit] = Owner of attacking unit"
To give a reward, you'll then need to set an event that detect when an unit dies. You can then use your variable "LASTATTACKER" to get who get the reward.
To add a point, you can set "POINT = POINT + 1" using arithmetic function.