HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

[GUI] Show damage taken problem

09-24-2008, 01:47 PM#1
Darkrider
(I post this trigger for you to understand the whole thing)
Trigger:
Gordon attacks with bone breaker
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
Bone_Breaker_Boolean Equal to False
(Unit-type of (Attacking unit)) Equal to Minotaur Gordon
((Attacking unit) is an illusion) Not equal to True
(((Attacked unit) is A structure) Not equal to True) and (((Attacked unit) belongs to an ally of (Owner of (Attacking unit))) Not equal to True)
(Random integer number between 1 and 100) Less than or equal to Bone_Breaker_Percentage
Collapse Actions
Set Bone_Braker_target = (Attacked unit)
Trigger - Add to Gordon Deals damage with bone breaker <gen> the event (Unit - Bone_Braker_target Takes damage)
Trigger - Turn on Gordon Deals damage with bone breaker <gen>

why could this trigger

Trigger:
Gordon Deals damage with bone breaker
Events
Collapse Conditions
(Damage source) Equal to Gordon
Collapse Actions
Set Bone_Breaker_Boolean = True
Set Bone_Breaker_Extra_Damage = (Damage taken)
Set Location4[49] = (Position of Gordon)
Floating Text - Create floating text that reads (String((Integer(Bone_Breaker_Extra_Damage)))) at Location4[49] with Z offset 90.00, using font size 12.00, color (100.00%, 20.00%, 20.00%), and 10.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
Special Effect - Create a special effect attached to the chest of (Attacked unit) using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
Special Effect - Destroy (Last created special effect)
Trigger - Turn off (This trigger)
Unit - Cause Gordon to damage Bone_Braker_target, dealing Bone_Breaker_Extra_Damage damage of attack type Chaos and damage type Universal
Custom script: call RemoveLocation(udg_Location4[49])
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Random integer number between 1 and 100) Less than or equal to 30
Collapse Then - Actions
Unit - Set level of Cripple |Demonic Harp Slow for Bone_Breaker_Caster to ((Level of Bone breaker ( Minotaur Gordon ) for Gordon) + 13)
Unit - Order Bone_Breaker_Caster to Stop
Unit - Order Bone_Breaker_Caster to Undead Necromancer - Cripple Bone_Braker_target
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Bone_Braker_target has buff Broken leg ) Not equal to True
Collapse Then - Actions
Unit - Set level of Cripple |Demonic Harp Slow for Bone_Breaker_Caster to ((Level of Bone breaker ( Minotaur Gordon ) for Gordon) + 9)
Unit - Order Bone_Breaker_Caster to Stop
Unit - Order Bone_Breaker_Caster to Undead Necromancer - Cripple Bone_Braker_target
Collapse Else - Actions
Do nothing
Set Bone_Breaker_Boolean = False





be causing this




as you can see i save the damage this unit (giant arthas) is taking into a variable... then i create a floating text with the amount of damage taken and i re-damage the damaged unit with the damage taken... but for some reason a lot of times a 0 appears there (sometimes it is shown correctly)...

What could be happening?
09-24-2008, 01:57 PM#2
Anitarf
Are you casting any spells by your hero or anything of that sort? There are many cases in which damage events occur for 0 damage, spells being one of them.

Also, your spell is incredibly messy, have you even considered what can happen if a unit gets attacked multiple times by the hero?
09-24-2008, 03:43 PM#3
Darkrider
yes i have a trigger that checks if my unit casts a spell and then it turns the damage trigger off... but messy why?

how can my unit attack several times and deal damage at the same time?

you mean if i press A many times against the targeted unit?... i think it will only change the event in the damage trigger... or will something worse happen?

EDIT: how can i detect a passive mana burn ability casted by an item (modified orb of lightning that casts mana burn) cos that item is messing with the skill... there is no way to make a condition like "type of damage taken == physical"?
09-24-2008, 04:27 PM#4
TKF
Trigger:
Set Bone_Breaker_Extra_Damage = (Damage taken)

This would probably not work, since you don't have "unit takes damage" as primary event, but "unit being attacked" in previous trigger.



Hidden information:
I use periodic every 1 sec to show total damage pr sec, and using units custom value to determine damage amount pr sec. My trigger. However it's only designed for 1 hero maps only.
09-24-2008, 05:01 PM#5
Darkrider
yes it does coz in the first trigger i add the event "unit takes damage" to the second trigger... it means that after the first trigger is executed the second trigger has as event "(my attacked unit) takes damage"
09-24-2008, 05:11 PM#6
Anitarf
It won't "change" the event, it will add events.
09-24-2008, 05:19 PM#7
Darkrider
the events added wont replace the older ones?
09-24-2008, 05:27 PM#8
Blubb-Tec
no, they will 'add' the events, not 'replace' them.
A common workaround is to simply add every unit in the game(preplaced and those that enter the map while running) to that trigger, then put the unit you want to register the takes damage event for into a global variable, and in the conditions do a check (unit taking damage) == global_var, and in the actions set the global variable to (No Unit) again.
09-24-2008, 06:46 PM#9
Darkrider
im sorry but i dont see the difference into adding the units in the map 1 by 1 while beeing attacked by my unit and adding them all in 1 shot... i do store them into a global variable but i dont set the variable to "no unit" after... thats the only difference i see ... can you enlighten me?

doing it my way, will add the same unit more than once to the same event?
09-24-2008, 07:03 PM#10
Anitarf
Quote:
Originally Posted by Darkrider
doing it my way, will add the same unit more than once to the same event?
To the same trigger, you mean? Yes, that's the point we're trying to make.

You're best off using a damage detection system for this, I'd recommend Rising_Dusk's IDDS.
09-24-2008, 07:24 PM#11
Blubb-Tec
I suggest doing this the manual way, somehow managing to implement vJass system is not good for learning this.
If I have time tomorrow or so, I'll build you an example trigger. However, some searching might give you the same results.
09-24-2008, 08:30 PM#12
Anitarf
Quote:
Originally Posted by Blubb-Tec
I suggest doing this the manual way, somehow managing to implement vJass system is not good for learning this.
I think it will do him more good to learn how to use systems than to learn how to do crappy damage detection triggers in GUI.
09-24-2008, 09:55 PM#13
Darkrider
well... any of those will do good if i can solve this in a clean way


Thx guys for helping me on this ^^

ill take a look at the system while i wait for a reply from blubb-tech

EDIT: i have 3 problems with IDDS:

* This system is only applicable if all of the damage from spells in your map is triggered. The only way this system is useful is if the only damage units deal themselves is from attacks.
* The system requires that all damage dealt via triggers be done using a function from the system rather than UnitDamageTarget().
* Requires no orb abilities, buffs, or abilities in general.


there is also Captain Griffen's dds http://www.wc3campaigns.net/showthread.php?t=101865

and the one that caught my attention but scared the heck out of me

http://www.wc3campaigns.net/showthread.php?t=102079


Anitarf... i know that it might be too much... but... would you help to implement your system in my map?
09-25-2008, 09:54 AM#14
Anitarf
Quote:
Originally Posted by Darkrider
EDIT: i have 3 problems with IDDS:

* This system is only applicable if all of the damage from spells in your map is triggered. The only way this system is useful is if the only damage units deal themselves is from attacks.
* The system requires that all damage dealt via triggers be done using a function from the system rather than UnitDamageTarget().
Yeah, Rising_Dusk didn't really explain well what that's about. The only case when you have to do these things is when you want the system to be able to tell the difference between spell damage and attack damage. If you don't care about that and just want to detect damage, you don't have to follow these rules, the system will simply think all damage it detects is from attacks.

Quote:
* Requires no orb abilities, buffs, or abilities in general.
How is this a problem? Maybe you need to re-read it, it doesn't require you to not have any orbs, buffs, abilities etc, it just doesn't need anything like that to work (some older systems used orb-based abilities and their buffs to tell the difference between attack damage and spell damage), you can still have that sort of stuff in your map, though.

Quote:
Anitarf... i know that it might be too much... but... would you help to implement your system in my map?
You need to be aware that using my system pretty much requires all your triggers that have something to do with damage detection to be made in Jass or even vJass. I recommended Dusk's system because I believe it's the easisest to work with in GUI, it just takes a few custom script lines and you have a GUI trigger that's able to respond to any unit taking damage.

If you still want to go the ADamage route, I'll of course help the best that I can.
09-25-2008, 10:32 AM#15
Blubb-Tec
Okay, here is what I suggested, the solution consists of 3 triggers plus one for each spell that reacts to a unit takes damage event:

AddUnitsInit-Trigger:
Trigger:
AddUnitsInit
Collapse Events
Map initialization
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Collapse Loop - Actions
Trigger - Add to DamageDetection <gen> the event (Unit - (Picked unit) Takes damage)

AddUnitsRuntime-Trigger:
Trigger:
AddUnitsRuntime
Collapse Events
Unit - A unit enters (Playable map area)
Conditions
Collapse Actions
Trigger - Add to DamageDetection <gen> the event (Unit - (Entering unit) Takes damage)

DamageDetection-Trigger:
Trigger:
DamageDetection
Events
Conditions
Collapse Actions
-------- This triggers runs whenever ANY unit takes damage. --------
-------- Make an If like the following every time you want a spell to react upon a 'unit takes damage'-event --------
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Level of BoneBreaker for (Damage source)) Greater than 0
(Random integer number between 1 and 100) Less than or equal to BoneBreaker_Percentage
Collapse Then - Actions
-------- Runs the BoneBreakerDmg ONLY when the above given conditions are true. --------
-------- Note: the given conditions are just an example, you will have to use your own ones here. --------
Trigger - Run BoneBreakerDmg <gen> (ignoring conditions)
Else - Actions

BoneBreakerDmg-Trigger:
Trigger:
BoneBreakerDmg
Events
Conditions
Collapse Actions
-------- This Trigger runs when the conditions for BoneBreaker are true. --------
-------- Use the same event responses as when using the 'unit takes damage' event --------

And here is how it works:
The first two triggers, AddUnitsInit and AddUnitsRuntime add a 'unit takes damage'-event for EVERY unit in the game to the DamageDetectionTrigger.
In this trigger, you have conditions for every of your spells that uses damage-detection. In the example, the trigger BoneBreakerDmg is run, when both the level of the BoneBreaker ability of the DamageSource is > 0, and a random integer between 0 and 100 is less or equal to your BoneBreaker_Percentage variable. You will need to put your own conditions there, this is only a small example.
Then, in the BoneBreakerDmg trigger, you have all the actions that are executed when a is damaged using BoneBreaker. This is where you will want to deal damage/show your floating text to the user.

I hope its understandable, if you've still got questions, just go on and ask them :)