- Joined
- Mar 15, 2012
- Messages
- 2,878
Please keep in mind the code posted below is not up to date and the reset after a while system is in place and this is a fully functional assist/damage detect system. The map to download is latest.
Since no other damage detection system wants to work I made my own crappy one for now until I figure out how to do this better. It doesn't add any lag even after 8000 instances so it should be fine.
It currently detects which unit does most damage, second most damage and whoever dealt the last hit.
There is no reset timer currently though besides hero/unit death...
There isn't a single one on hive and well if there is I bet it isn't GUI.
If anyone can explain how proper damage detect systems rebuild their triggers then I will attempt to do that. Unless of course I can get this to work another way, hash tables don't allow variables. If JASS ones do I would appreciate it if anyone said something.
Since a lot of you don't like to download and test, here's the triggers. =)
[trigger=]
Display Damage
Events
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Damage source)) Not equal to Neutral Hostile
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Damage source) is in assistgroup[(Custom value of (Triggering unit))]) Equal to False
Then - Actions
Unit Group - Add (Damage source) to assistgroup[(Custom value of (Triggering unit))]
Else - Actions
Hashtable - Save ((Load (Custom value of (Triggering unit)) of (Key (Damage source)) from table) + (Damage taken)) as (Custom value of (Triggering unit)) of (Key (Damage source)) in table
Game - Display to (All players) for 1.00 seconds the text: ((((Name of (Damage source)) + damaged ) + (Name of (Triggering unit))) + ( for + ((String((Damage taken))) + damage.)))
Game - Display to (All players) for 1.00 seconds the text: ((Name of (Damage source)) + ( has obtained + ((String((Load (Custom value of (Triggering unit)) of (Key (Damage source)) from table))) + ( total damage to + (Name of (Triggering unit))))))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Then - Actions
Unit - Set life of (Triggering unit) to 100.00%
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Max mana of (Triggering unit)) Greater than 1.00
Then - Actions
Unit - Set mana of (Triggering unit) to 100.00%
Else - Actions
Else - Actions
[/trigger]
[trigger=]
Untitled Trigger 001
Events
Unit - A unit enters (Entire map)
Conditions
((Triggering unit) is A Hero) Equal to True
Actions
Trigger - Add to Display Damage <gen> the event (Unit - (Triggering unit) Takes damage)
Unit - Set the custom value of (Triggering unit) to lol
Custom script: set udg_assistgroup[GetUnitUserData(GetTriggerUnit())] = CreateGroup()
Set lol = (lol + 1)
[/trigger]
[trigger=]
assist
Events
Unit - A unit Dies
Conditions
((Triggering unit) is A Hero) Equal to True
Actions
Set maxdmg = 0.00
Unit Group - Pick every unit in assistgroup[(Custom value of (Triggering unit))] and do (Actions)
Loop - Actions
Hashtable - Save ((Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table) + 0.00) as (Custom value of (Triggering unit)) of (Key (Picked unit)) in table
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table) Greater than maxdmg
Then - Actions
Set u = No unit
Set maxdmg = (Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table)
Set u = (Picked unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
u Not equal to No unit
Then - Actions
Game - Display to (All players) for 1.00 seconds the text: ((Name of u) + ( has obtained + ((String(maxdmg)) + ( total damage to + (Name of (Triggering unit))))))
Else - Actions
Set maxdmg = 0.00
Unit Group - Pick every unit in assistgroup[(Custom value of (Triggering unit))] and do (Actions)
Loop - Actions
Hashtable - Save ((Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table) + 0.00) as (Custom value of (Triggering unit)) of (Key (Picked unit)) in table
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table) Greater than maxdmg
(Picked unit) Not equal to u
Then - Actions
Set uu = No unit
Set maxdmg = (Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table)
Set uu = (Picked unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
uu Not equal to No unit
Then - Actions
Game - Display to (All players) for 1.00 seconds the text: ((Name of uu) + ( has obtained + ((String(maxdmg)) + ( total damage to + (Name of (Triggering unit))))))
Else - Actions
Game - Display to (All players) for 1.00 seconds the text: ((Name of (Killing unit)) + ( managed to get the last hit on + (Name of (Triggering unit))))
Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in table
Custom script: call DestroyGroup(udg_assistgroup[GetUnitUserData(GetTriggerUnit())])
Custom script: set udg_assistgroup[GetUnitUserData(GetTriggerUnit())] = null
[/trigger]
There's a few things missing, but this is the main code. The only stuff missing is like hashtable creation and a few other things that aren't really that important to post.
Credits go to Chaosy for http://www.hiveworkshop.com/forums/spells-569/gui-combat-system-256075/?prev=r=20&page=3 that isn't in yet, but should be shortly.
Since no other damage detection system wants to work I made my own crappy one for now until I figure out how to do this better. It doesn't add any lag even after 8000 instances so it should be fine.
It currently detects which unit does most damage, second most damage and whoever dealt the last hit.
There is no reset timer currently though besides hero/unit death...
There isn't a single one on hive and well if there is I bet it isn't GUI.
If anyone can explain how proper damage detect systems rebuild their triggers then I will attempt to do that. Unless of course I can get this to work another way, hash tables don't allow variables. If JASS ones do I would appreciate it if anyone said something.
Since a lot of you don't like to download and test, here's the triggers. =)
[trigger=]
Display Damage
Events
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Damage source)) Not equal to Neutral Hostile
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Damage source) is in assistgroup[(Custom value of (Triggering unit))]) Equal to False
Then - Actions
Unit Group - Add (Damage source) to assistgroup[(Custom value of (Triggering unit))]
Else - Actions
Hashtable - Save ((Load (Custom value of (Triggering unit)) of (Key (Damage source)) from table) + (Damage taken)) as (Custom value of (Triggering unit)) of (Key (Damage source)) in table
Game - Display to (All players) for 1.00 seconds the text: ((((Name of (Damage source)) + damaged ) + (Name of (Triggering unit))) + ( for + ((String((Damage taken))) + damage.)))
Game - Display to (All players) for 1.00 seconds the text: ((Name of (Damage source)) + ( has obtained + ((String((Load (Custom value of (Triggering unit)) of (Key (Damage source)) from table))) + ( total damage to + (Name of (Triggering unit))))))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Then - Actions
Unit - Set life of (Triggering unit) to 100.00%
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Max mana of (Triggering unit)) Greater than 1.00
Then - Actions
Unit - Set mana of (Triggering unit) to 100.00%
Else - Actions
Else - Actions
[/trigger]
[trigger=]
Untitled Trigger 001
Events
Unit - A unit enters (Entire map)
Conditions
((Triggering unit) is A Hero) Equal to True
Actions
Trigger - Add to Display Damage <gen> the event (Unit - (Triggering unit) Takes damage)
Unit - Set the custom value of (Triggering unit) to lol
Custom script: set udg_assistgroup[GetUnitUserData(GetTriggerUnit())] = CreateGroup()
Set lol = (lol + 1)
[/trigger]
[trigger=]
assist
Events
Unit - A unit Dies
Conditions
((Triggering unit) is A Hero) Equal to True
Actions
Set maxdmg = 0.00
Unit Group - Pick every unit in assistgroup[(Custom value of (Triggering unit))] and do (Actions)
Loop - Actions
Hashtable - Save ((Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table) + 0.00) as (Custom value of (Triggering unit)) of (Key (Picked unit)) in table
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table) Greater than maxdmg
Then - Actions
Set u = No unit
Set maxdmg = (Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table)
Set u = (Picked unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
u Not equal to No unit
Then - Actions
Game - Display to (All players) for 1.00 seconds the text: ((Name of u) + ( has obtained + ((String(maxdmg)) + ( total damage to + (Name of (Triggering unit))))))
Else - Actions
Set maxdmg = 0.00
Unit Group - Pick every unit in assistgroup[(Custom value of (Triggering unit))] and do (Actions)
Loop - Actions
Hashtable - Save ((Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table) + 0.00) as (Custom value of (Triggering unit)) of (Key (Picked unit)) in table
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table) Greater than maxdmg
(Picked unit) Not equal to u
Then - Actions
Set uu = No unit
Set maxdmg = (Load (Custom value of (Triggering unit)) of (Key (Picked unit)) from table)
Set uu = (Picked unit)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
uu Not equal to No unit
Then - Actions
Game - Display to (All players) for 1.00 seconds the text: ((Name of uu) + ( has obtained + ((String(maxdmg)) + ( total damage to + (Name of (Triggering unit))))))
Else - Actions
Game - Display to (All players) for 1.00 seconds the text: ((Name of (Killing unit)) + ( managed to get the last hit on + (Name of (Triggering unit))))
Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in table
Custom script: call DestroyGroup(udg_assistgroup[GetUnitUserData(GetTriggerUnit())])
Custom script: set udg_assistgroup[GetUnitUserData(GetTriggerUnit())] = null
[/trigger]
There's a few things missing, but this is the main code. The only stuff missing is like hashtable creation and a few other things that aren't really that important to post.
Credits go to Chaosy for http://www.hiveworkshop.com/forums/spells-569/gui-combat-system-256075/?prev=r=20&page=3 that isn't in yet, but should be shortly.
Attachments
Last edited: