Snippet making a generic unit event for: unit takes damage

LoveTD's

New Member
Reaction score
34
I've seen lots of people asking this so I decided to post it in here :D
Code:
Damage Taken 1
    Events
        Unit - A unit Is attacked
    Conditions
    Actions
        Trigger - Add to Damage Taken 2 <gen> the event (Unit - (Triggering unit) Takes damage)

this means that Damage taken 2 has the event: a unit takes damage
and you can refer to that by using triggering unit (not attacked unit :D just a sec :S attacking unit did seem to work so maybe attacked unit too ^^ try it out if you want to :D)
 

LoveTD's

New Member
Reaction score
34
hmm your right didn't notice because it did work in my case :S maybe I should make some kind of variable that makes sure the triggering unit is added to the event only once :S
 

Flare

Stops copies me!
Reaction score
662
Code:
Damage detection init 1
    Events
        Map initialization
    Conditions
    Actions
        Set TempGroupA = (Units in (Playable map area))
        Unit Group - Pick every unit in TempGroupA and do (Actions)
            Loop - Actions
                Unit - Add Damage detection spellbook  to (Picked unit)
                Trigger - Add to All damage <gen> the event (Unit - (Picked unit) Takes damage)
                Trigger - Add to Physical damage <gen> the event (Unit - (Picked unit) Takes damage)
                Trigger - Add to Spell damage <gen> the event (Unit - (Picked unit) Takes damage)


-----------------------------------------------------

Damage detection init 2
    Events
        Unit - A unit enters (Playable map area)
    Conditions
    Actions
        Unit Group - Add (Triggering unit) to TempGroupB
        Unit Group - Remove all units of TempGroupA from TempGroupB
        Unit Group - Pick every unit in TempGroupB and do (Actions)
            Loop - Actions
                Unit - Add Damage detection spellbook  to (Picked unit)
                Trigger - Add to All damage <gen> the event (Unit - (Picked unit) Takes damage)
                Trigger - Add to Physical damage <gen> the event (Unit - (Picked unit) Takes damage)
                Trigger - Add to Spell damage <gen> the event (Unit - (Picked unit) Takes damage)
                Unit Group - Add (Picked unit) to TempGroupA
                Unit Group - Remove (Picked unit) from TempGroupB

That's the code I used for my DD initialization. It'll prevent duplicate events from being registered
 

Vestras

Retired
Reaction score
249
In JASS, it is easy to add and remove events and conditions.
And this isn't a snippet, it's a hint.
 

LoveTD's

New Member
Reaction score
34
In JASS, it is easy to add and remove events and conditions.
And this isn't a snippet, it's a hint.
sry didn't find the hint section

Code:
Damage detection init 1
    Events
        Map initialization
    Conditions
    Actions
        Set TempGroupA = (Units in (Playable map area))
        Unit Group - Pick every unit in TempGroupA and do (Actions)
            Loop - Actions
                Unit - Add Damage detection spellbook  to (Picked unit)
                Trigger - Add to All damage <gen> the event (Unit - (Picked unit) Takes damage)
                Trigger - Add to Physical damage <gen> the event (Unit - (Picked unit) Takes damage)
                Trigger - Add to Spell damage <gen> the event (Unit - (Picked unit) Takes damage)


-----------------------------------------------------

Damage detection init 2
    Events
        Unit - A unit enters (Playable map area)
    Conditions
    Actions
        Unit Group - Add (Triggering unit) to TempGroupB
        Unit Group - Remove all units of TempGroupA from TempGroupB
        Unit Group - Pick every unit in TempGroupB and do (Actions)
            Loop - Actions
                Unit - Add Damage detection spellbook  to (Picked unit)
                Trigger - Add to All damage <gen> the event (Unit - (Picked unit) Takes damage)
                Trigger - Add to Physical damage <gen> the event (Unit - (Picked unit) Takes damage)
                Trigger - Add to Spell damage <gen> the event (Unit - (Picked unit) Takes damage)
                Unit Group - Add (Picked unit) to TempGroupA
                Unit Group - Remove (Picked unit) from TempGroupB

thanks a lot for that code! b.t.w. 3 different damage types? wherefor and how? And I don't see what the use is of a damage detection spellbook :S can you explain it to me? :p
 

Flare

Stops copies me!
Reaction score
662
MCR-ELSKER said:
In JASS, it is easy to add and remove events and conditions.

Well, this isn't JASS, is it? Anyway, JASS damage detection systems are stupidly difficult to use for GUI users. Most of the ones I've seen use various things that make it almost completely unusuable in GUI (I'm sure that one can be made to cater for GUI, but who's gonna do it?) such as structs, creating new triggers internally, and what-not

And this isn't a snippet, it's a hint.

Dictionary.com says otherwise :rolleyes:
a little piece, especially of information
From the looks of it, this is little, and it's a piece of information, so it would qualify as a snippet ^^
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top