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

[General] detect when damage is taken

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Would have been a shortcut for my absorb system. I tried to work with the max hp ability but I cant get it to work. First I thought that I simply could add the ability and then edit the current health and then remove the ability. But then I noticed it changed the % hp so that screwed my idea

edit: I also noticed that no matter what I do with the ability I need to remove it. And if I remove it in the current trigger the unit will be back at 100% hp with nothing done
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
ok, I tried to import it but I get a critical/fatal error after configuring the ID of the damage reduction and hp spell.

so I could not test if it works...
  • AS absorb Copy
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • Custom script: call SetUnitLife(GetTriggerUnit(),GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE) + udg_amount)
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Hi,

ok, I tried to import it but I get a critical/fatal error after configuring the ID of the damage reduction and hp spell.

Which error? Did you spell the ID correct?

so I could not test if it works...
  • AS absorb Copy
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • Custom script: call SetUnitLife(GetTriggerUnit(),GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE) + udg_amount)

You shouldn't do that, just set the amount variable to the desired value. You just set the unit life here but the system needs to know that you actually want to modify the damage - therefore set the amount. The rest works automatic.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
1. yes.

Error message:
FATAL ERRROR
Program: path here
exception 0xC0000005 (ACCESS_VIOLATION) at 0023:6FCC504

The instruction at '0023:6FCC504' referenced memory at '0x00000020'-
the memory could not be read


bug.jpg



JASS:
function InitGlobalVariables takes nothing returns nothing
    // Put here the correct ability IDs
    set udg_DAMAGE_TYPE_DETECTOR = 'A002'
    set udg_SET_MAX_LIFE = 'A001'
    
    // Here you can configure some stuff, read the documentation for further info
    set udg_SPELL_DAMAGE_REDUCTION_ITEM = 'brac'
    set udg_SPELL_RESISTANCE_AUTO_DETECT = false
    set udg_ETHEREAL_DAMAGE_FACTOR = 1.66
    set udg_BRACERS_SPELL_DAMAGE_REDUCTION = 0.33
    set udg_TRIGGER_CLEANUP_PERIOD = 60.0
endfunction


2. what you mean? I am pretty sure I need a damage variable to do that.
 
Level 14
Joined
Dec 12, 2012
Messages
1,007

Hm ok, did you create all required variables? And what do you mean with critical error, what does the error message say?

2. what you mean? I am pretty sure I need a damage variable to do that.

Only the amount variable. Just set it for example to zero, to block all damage:

  • OnDamage
    • Ereignisse
      • Game - damageEventTrigger becomes Equal to 1.00
    • Bedingungen
      • damageType Equal to 0
    • Aktionen
      • Set amount = 0.00


EDIT:

Ok, after taking a look at your map I found the problem. It has nothing to do with the DDS as the map still crashes when you delete it ;)

But you use some custom game interface (maybe the one from the import manager?). If I disable this interface the map works without any problems
(with the DDS active of course).
 
Last edited:
Level 14
Joined
Dec 12, 2012
Messages
1,007
So you don't want damage type support?

Then the only remaining system for GUI users that allows this is Bribes DDS. Its good but unfortunatly bugged with damage events that share the same instance.

If you didn't refer on damage type detection: the rest of the system is absolutly neccessary to work flawless in all situations.
 
Just to explain, the process goes like this:

Unit takes damage event fires.
Add the ability that increases life.
Set life to current life + absorb amount
set absorb amount = absorb amount - incoming damage
Start a countdown timer (one-shot) that lasts 0.00 seconds (this will allow the damage to be taken)
Remove ability

Or something along those lines iirc.
 
Thats will just work for the regular case.

To cover all situations you have to identify which case is actually happening, as explained here. Timer informations have to get updated or considered beforehand corresponding to the case you are in. Otherwise the system will bug.

Thanks, I didn't mention that. You can simply put it in a stack and then loop through them.

size = size + 1
units[size] = unit

Then in the loop:

loop
exitwhen size == 0
// handle units[size]
set size = size - 1
endloop

It should take care of instances happening at the same time. Not sure what the other instance you mentioned is referring to.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
You got a point maker, however I will update it so it works atleast.
I got 3 reasons.
1. It is my intention to replace my jass hashtable with gui which will make it useful for gui users since lfhs system is vjass. Same with damage engine its more jass than gui
2. I want it to be a absorb system and nothing else I will make it support any dds by configing which variable the system use for damage etc.
3. A personal thing really but I fully want to understand the systems I use and understand what they are able to do. Therefore I prefer my own system.
 
Level 14
Joined
Dec 12, 2012
Messages
1,007
Not sure what the other instance you mentioned is referring to.

Oh, you are right, the third instance is only relevant for damage type detection (stacking spell damage has to be treated a bit different than stacking physical),
so if you don't care about damage type detection you can forget the last case.
 
Status
Not open for further replies.
Top