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

Assist system

Status
Not open for further replies.
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. :grin:

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

  • Assist System2.w3x
    27.4 KB · Views: 85
Last edited:
Hm.. shouldn't there be a timer that removes unit from the assist group after X seconds?

I haven't checked the map so it's possible that you just haven't posted them though.

Still working on it, if I can get hashtables to use variables I might be able to fix a bit.

It only removes when the unit dies, otherwise the values are set to null/0.
 
Status
Not open for further replies.
Top