• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Damage System Request

Status
Not open for further replies.
Level 8
Joined
Jun 18, 2007
Messages
214
Guys I need a Damage Counter system. It should count which hero dealt most damage in a round and then to show it in a multiboard. That kind of system is used in map called: WoW Arena. Please, if anyone can help I would be grateful and would put him/her in credits area and give rep. Thank you.
 
Level 30
Joined
Sep 2, 2007
Messages
3,723
  • damage system
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) is A Hero) Equal to True
      • ((Owner of (Attacked unit)) is an enemy of (Owner of (Attacking unit))) Equal to True
    • Actions
      • Set dmg[(Player number of (Owner of (Attacking unit)))] = (dmg[(Player number of (Owner of (Attacking unit)))] + (Integer((Damage taken))))
      • Game - Display to (All players) the text: (String(dmg[(Player number of (Owner of (Attacking unit)))]))
This is all i have. It doesnt work but i can't see why. You'l probably find the answer
 
Level 5
Joined
May 21, 2006
Messages
174
  • damage system
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Attacking unit) is A Hero) Equal to True
      • ((Owner of (Attacked unit)) is an enemy of (Owner of (Attacking unit))) Equal to True
    • Actions
      • Set dmg[(Player number of (Owner of (Attacking unit)))] = (dmg[(Player number of (Owner of (Attacking unit)))] + (Integer((Damage taken))))
      • Game - Display to (All players) the text: (String(dmg[(Player number of (Owner of (Attacking unit)))]))
This is all i have. It doesnt work but i can't see why. You'l probably find the answer

For starters Damage Taken does not respond to A unit Is attacked.
The problem is the event which must point at a specific unit, not a generic one.
The second problem arise once you've changed the event to a specific unit, since Attacking Unit does not work with Damage Taken, you'll have a hard time getting the Attacking Unit without using JASS.
 
Level 5
Joined
Jul 24, 2007
Messages
199
Maybe we need to add each created unit on the map into a trigger as an event that this unit takes damage (one trigger, many events). And then, referring to the Damage Source, we check whether it is a Hero with dmg counter (maybe having all such Heroes added to a special group) and, if so, add the damage to its counter. Should I write this triggerly?
 
Level 5
Joined
May 21, 2006
Messages
174
Maybe we need to add each created unit on the map into a trigger as an event that this unit takes damage (one trigger, many events). And then, referring to the Damage Source, we check whether it is a Hero with dmg counter (maybe having all such Heroes added to a special group) and, if so, add the damage to its counter. Should I write this triggerly?
That would work with pre-spawned units, but what about units created/bought/trained at a later stage of the map?
 
Level 5
Joined
Jul 24, 2007
Messages
199
So, we need one more trigger like that: when a unit is summoned/trained or what, add its 'dmg taken' event to the main trigger. I meant that in the previous post...

The problem now is, how to clean the trigger when the unit has died? NewGen could do this, but I don't use NewGen.
 
  • Unit Attacked
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set Target[(Player number of (Owner of (Attacking unit)))] = (Attacked unit)
      • Trigger - Add to Count Damage <gen> the event (Unit - Target[(Player number of (Owner of (Attacking unit)))] Takes damage)
      • Trigger - Add to Clear Damage <gen> the event (Unit - Target[(Player number of (Owner of (Attacking unit)))] Dies)
  • Count Damage
    • Events
    • Conditions
    • Actions
      • Set DamageTaken[(Player number of (Owner of (Attacking unit)))] = (Damage taken)
  • Clear Damage
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Dying unit) Equal to Target[(Player number of (Owner of (Attacking unit)))]
    • Actions
      • Set DamageTaken[(Player number of (Owner of (Attacking unit)))] = 0.00
Can this work ? :xxd:
 
Level 5
Joined
Jul 24, 2007
Messages
199
Er, I think that rather must look like this.

  • Unit Attacked
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set Target[(Player number of (Owner of (Attacking unit)))] = (Attacked unit)
      • Trigger - Add to Count Damage <gen> the event (Unit - Target[(Player number of (Owner of (Attacking unit)))] Takes damage)
  • Count Damage
    • Events
    • Conditions
    • Actions
      • Set DamageTaken[(Player number of (Owner of (Attacking unit)))] = DamageTaken[(Player number of (Owner of (Attacking unit)))] + (Damage taken)
However, this is also not too clear. It will make some trash.
 
Level 5
Joined
Jul 24, 2007
Messages
199
what called? NewGen has ABC system and HSAS system developed for these purposes, that's all I know. For the JASS function, actually, I meant to create another trigger for each unit and call DestroyTrigger(...), but it anyway can't link together trigger and unit. The only handle-linking may be GetTriggeringTrigger(). (didn't think somebody will pay attention to removing events from triggers :/)
 
Level 5
Joined
Jul 24, 2007
Messages
199
Honestly, I didn't get all of what you said, but actually I meant in-game creating triggers:

JASS:
function AddTrigger takes unit u returns nothing
    local trigger trig = CreateTrigger( )
    call TriggerRegisterUnitEvent(trig, u, EVENT_UNIT_DAMAGE)
    call TriggerAddCondition(trig, Condition(function Trig_SomeConditions))
    call TriggerAddAction(trig, function Trig_SomeActions)
    set trig = null
endfunction

, where SomeConditions and SomeActions can be taken from the needed trigger converted to JASS (each unit will have a trigger), and UnitIsAttacked event-reacting trigger generates the local trigger, calling AddTrigger(GetAttackedUnit()) to wait until it is attacked damaged. In SomeActions, we should call DestroyTrigger(GetTriggeringTrigger()) and add to Damage Source's counter the Damage Taken value.
 
Last edited:
Status
Not open for further replies.
Top