HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Difficulty with damage detection

08-13-2007, 10:02 PM#1
Castlemaster
I'm trying to implement damage detection systems. I've tried using Shadow1500's and Vexorian's, but both of them are confusing to me. I'm still new to JASS and I'm really confused what goes where and how to use any of it.

Does it give me a new function to call that gives me the damage of something? Is there a command to get which unit damaged it and what type? I have no idea how the algorithm works so I'm having trouble figuring out how to even use it. Any direction to make sense of this is appreciated.

Thanks ahead of time.
08-14-2007, 06:04 AM#2
Dil999
I had a hard time implementing Shadow1500's system also, and I eventually learned (the hard way).
The attacking unit is
Collapse JASS:
GetEventDamageSource()
the attacked unit is
Collapse JASS:
GetTriggerUnit()
08-17-2007, 02:35 PM#3
Castlemaster
I realized I didn't specify the different things I was confused about, so here's all the stuff I wondering.

1.Are these two commands (GetEventDamageSource() and GetTriggerUnit()) used within 1500's JASS code, or the trigger referenced in the beginning of the JASS code:
Collapse JASS:
//Your actions here

2. How do I get a real number that tells me the damage dealt? Is there a command or variable that stores that, or do I simply call a certain function?

3. If the system does not run every time a unit recieves damage, where do I specify the event that I want to detect damage? Or does this create an event that can be used (EVENT_UNIT_TAKES_DAMAGE)? If the system DOES run every time a unit takes damage, what variable does it store it to temporarily (going back to question #2).
08-17-2007, 03:22 PM#4
moyack
Quote:
Originally Posted by common.j
Collapse JASS:
// EVENT_UNIT_DAMAGED
constant native GetEventDamage takes nothing returns real
constant native GetEventDamageSource takes nothing returns unit
As you can see, GetEventDAmage returns the damage dealt and the second native returns the unit dealing the damage. Those function ONLY work with the event EVENT_UNIT_DAMAGED.
08-17-2007, 03:40 PM#5
Castlemaster
OK, so let me make sure I have this:

EVENT_UNIT_DAMAGED is the event
GetTriggerUnit() is the damaged unit
GetEventDamageSource() is the damaging unit
GetEventDamage() is the damage recieved

do these commands work only in shadow 1500's trigger, or can I make a seperate trigger that will use all these commands? Please keep in mind I'm new to JASS and do not grasp natives or handles.
08-17-2007, 03:43 PM#6
cohadar
Quote:
Originally Posted by Castlemaster
EVENT_UNIT_DAMAGED is the event
GetTriggerUnit() is the damaged unit
GetEventDamageSource() is the damaging unit
GetEventDamage() is the damage recieved

Shouldn't this be somewhere in the system documentation or something?
08-17-2007, 03:55 PM#7
Castlemaster
http://www.wc3jass.com/viewtopic.php...mage+detection
If I was more familiar with JASS I might, but to a newcomer it was overwhelming.
08-17-2007, 04:19 PM#8
cohadar
Oh yeah comments in the form of
Collapse JASS:
// part 1
// part 2
// part 3

really helpful.

Systems like that should not be approved.

EDIT:
I was just wondering...
What is the difference between unit is attacked and unit takes damadge ?
The fact that you can see how much damadge was dealt?
Why would you need that?
08-17-2007, 05:34 PM#9
moyack
Quote:
Originally Posted by cohadar
Systems like that should not be approved.
Man, if you check when the system was created:

Thu Jan 19, 2006
And in that time vJASS was barely a dream. So please don't come with that kind of comments.

Quote:
EDIT:
I was just wondering...
What is the difference between unit is attacked and unit takes damadge ?
The fact that you can see how much damadge was dealt?
Why would you need that?
The event EVENT_UNIT_DAMAGED happens exactly when the unit receive the damage, and has the advantage of getting the value of the damage. In the other hand, EVENT_UNIT_ATTACKED happens when the attacker start the attack to the unit, so it's very inaccurate in ranged attacks and you can't get the damage dealt.

Resuming:
EVENT_UNIT_DAMAGED=>Accurate, you can get damage, but it requires a trigger per unit to detect it.
EVENT_UNIT_ATTACKED=>Inaccurate, you can't get damage, but you don't have to create one trigger per unit to detect that event.


@CastleMaster:
Quote:
Originally Posted by Castlemaster
OK, so let me make sure I have this:

EVENT_UNIT_DAMAGED is the event
GetTriggerUnit() is the damaged unit
GetEventDamageSource() is the damaging unit
GetEventDamage() is the damage recieved

do these commands work only in shadow 1500's trigger, or can I make a seperate trigger that will use all these commands? Please keep in mind I'm new to JASS and do not grasp natives or handles.

The only thing that you have to do with this system is to add your custom code to this function:

Collapse JASS:
function AnyUnitTakesDamage takes nothing returns nothing
    // your actions here
    // Sample Damage display:
    call BJDebugMsg( "Damage: " + R2S(GetEventDamage()) ) // of course, you can change the code for the things you need to detect or do in your map.
endfunction

And, inside this function, if you want to get the damage, you should use the command GetEventDamage(), to get the attacker unit: GetEventDamageSource() and the affected unit GetTriggerUnit()
08-17-2007, 05:52 PM#10
cohadar
Quote:
Originally Posted by moyack
Man, if you check when the system was created:

Thu Jan 19, 2006
And in that time vJASS was barely a dream. So please don't come with that kind of comments.

What does that got to do with anything?
How is lack of comments/documentation in any way connected with vJASS
or even with the date of trigger?

People back from 1960 knew how to make proper code,
it has nothing to do with tools or anything.
08-17-2007, 07:12 PM#11
moyack
A lapsus, my apologies.

I hope the other part of my post can be useful to this thread and its starter.
08-17-2007, 08:20 PM#12
Castlemaster
Ok, I've about got it figured out, (thanks Moyack)
I'm now having trouble making the line of code that is the actual event. I keep getting a "cannot convert unitevent to unitplayerevent" and other problems when I fiddle with that line of code since there is no GUI equivalent for me to convert and look at.
08-17-2007, 09:06 PM#13
Anitarf
Shouldn't the system already handle the event? What are you trying to do?
08-17-2007, 10:23 PM#14
Castlemaster
I'm trying to make another trigger that uses Shadow 1500's DamageModify system.
http://www.wc3jass.com/viewtopic.php?t=2653
I'm trying to make a trigger whose event is "a unit takes damage" GUI does not have this event (as far as I know), but JASS does. I'm trying to write the event line of the trigger, basing it off of "a unit is attacked"
Collapse JASS:
call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_ATTACKED )
and I changed it to
Collapse JASS:
 call TriggerRegisterUnitEvent( gg_trg_Untitled_Trigger_001, EVENT_UNIT_DAMAGED ) 
I get errors, and I really don't know how I'm supposed to write the event. I really don't know anything about them.
08-17-2007, 10:54 PM#15
Anitarf
As you can see, the EVENT_PLAYER_UNIT_ATTACKED is a player unit event while EVENT_UNIT_DAMAGED is a specific unit event. The function TriggerRegisterAnyUnitEventBJ actualy creates multiple player owned unit events, one for each player (since there's actualy no such thing as a generic unit event), that's why it can use a player unit event, but can't use a specific unit event.

That's the whole reason why we need special systems to detect damage that dynamicaly create specific unit event triggers as units are created and clean them up as untis die.

The whole point of Shadow's system is that you do all damage modifying stuff in that one function that the system provides. You don't make "another trigger". You do everything there.