Can somebody explain to me how it works using Custom Value. Like Local Player has pwned Name of Enemy Player for bla Gold / Assists: Name of Assisting Player :)
First a little disclaimer. In this mini tutorial, we're going to use the event "Unit Takes Damage". There's a lot of fogginess surrounding this event as to it's efficiency. Some people avoid it at all costs, but in my experience it's really only an issue when you have a mass amount of units fighting at the same time (like in a massing game). For arenas, RPGs, and even MOBAs, it's totally okay.
1. Storing the Data for Assists
I'm assuming this is a hero type game, so we need to have some variables for this part of the system:
Non-arrayed variable, type Unit Group, global. We'll call it, "Hero Group".
Time to get started on storing what players have damage on what heroes.
Create a new trigger. Let's call it "Assist Data Log".
For the event, put the scandalous Unit Takes Damage event. No need to change any of the default values.
For the conditions, create a condition, Unit is in Unit Group. Set it to Triggering Unit is in "Hero Group" == True.
Create another condition, Custom Unit Value (Damaging Player) of Triggering Unit == 0.
Our first action will be Set Custom Value of Unit. Set the unit to triggering unit. Set the player to damaging player. Set the value to 10.0.
There is one more action we must put in this trigger. It is a custom action, so we must make it.
We have to have a time out for the assist data. This custom action will cover that.
Create a new custom action. Let's call it "Assist Data Remove". Make sure at the top, it's checked off as Create Thread under Options.
Create two new parameters. Call one "Unit" and set it to type Unit. Call the other "Damaging Player" and set it to type Integer,
Create a new Repeat Forever action in our new custom action.
Create an If Then Else inside our repeat forever action.
For the condition, have it check Custom Value (insert our "Damaging Player" parameter here) of unit (Insert our "Unit" parameter here.) != 0.0.
Create a new Set Unit Custom Value action in the Then part. Set the unit to our parameter "Unit". Set the custom value to our "Damaging Player" and set it to an arithmetic function. For the first value, insert this custom value again. For the other part of the arithmetic, put -1.
Create a wait 1 second action.
For the else part, put skip remaining actions.
We now have data saving and removal set up. Time to go back to our trigger and add the action we just made. Create a new Assist Data Remove action for the trigger "Assist Data Log". Set "Unit" to triggering unit and "Damaging Player" to damaging player.
2. Creating the Function to Retrieve Who Has an Assist on a Unit
We're going to make a custom function. Create one by right clicking > New > New Function.
Let's call this function "Assisting Players".
Create two parameters. Name one "Unit" and set it to type unit. Name the other "Killing Player" and set it to type integer.
Create a local variable for this function, type Player Group, and name it Player Group.
Create the action Pick Each Player. Set the player group to Active Players.
Create an If Then Else action in the Pick Each Player loop.
For the if, create the condition "Custom Value of Unit". Set it to be Custom value of (Picked Player) on unit (our parameter "Unit") != 0.0.
For the then, add the action Add Player to Player Group. Add the player, picked player, to our variable Player Group.
Outside and under the Pick Each Player Loop, create the action Remove Player from Player Group. Remove our parameter "Killing Player" from our variable "Player Group".
Then create the action Return. Return our variable Player Group.
3. Checking Who Has an Assist on a Dying Unit
Create a new trigger. Event Unit Dies.
Create the trigger Display Text Message.
Use the player group that the function Assisting Players returns to create your message including the player group.
I never tested the map out so I assumed it was a problem with my triggers, however when testing I saw the problem you're likely encountering. It checks for active players, not all players. So you either need to change the active player parameters to all players or add computers to the map.
And after I wrote that whole thing, all you have to say is that it doesn't work? :p
I'm pretty sure I did , Just maybe the reason that I dont have AI's or Players to play with my Triggers wont work. I tried a Different version btw. If you could revise the map and got it working just PM me :) thanks
Can somebody explain to me how it works using Custom Value. Like Local Player has pwned Name of Enemy Player for bla Gold / Assists: Name of Assisting Player :)
@Mugen245: Go
Sure.
First a little disclaimer. In this mini tutorial, we're going to use the event "Unit Takes Damage". There's a lot of fogginess surrounding this event as to it's efficiency. Some people avoid it at all costs, but in my experience it's really only an issue when you have a mass amount of units fighting at the same time (like in a massing game). For arenas, RPGs, and even MOBAs, it's totally okay.
1. Storing the Data for Assists
I'm assuming this is a hero type game, so we need to have some variables for this part of the system:
Time to get started on storing what players have damage on what heroes.
We have to have a time out for the assist data. This custom action will cover that.
2. Creating the Function to Retrieve Who Has an Assist on a Unit
We're going to make a custom function. Create one by right clicking > New > New Function.
3. Checking Who Has an Assist on a Dying Unit
@Charysmatic: Go
Doesnt seem to work on my side :)
@Mugen245: Go
I never tested the map out so I assumed it was a problem with my triggers, however when testing I saw the problem you're likely encountering. It checks for active players, not all players. So you either need to change the active player parameters to all players or add computers to the map.
And after I wrote that whole thing, all you have to say is that it doesn't work? :p
@Charysmatic: Go
Nvm I'll check the map.
@Mugen245: Go
Well, let me know if you get it working.
And you do know you'll need to add your heroes to the hero unit group? Not sure if that got across.
@Charysmatic: Go
I'm pretty sure I did , Just maybe the reason that I dont have AI's or Players to play with my Triggers wont work. I tried a Different version btw. If you could revise the map and got it working just PM me :) thanks
@Charysmatic: Go
It doesnt work , I think I should remove this from my system instead :)
@Charysmatic: Go
It doesnt work , I think I should remove this from my system instead :)
@Mugen245: Go
It works on my side. I can take a look if you can't find any differences between our maps. This map contains testing triggers that work.
@Charysmatic: Go
Thanks :)