• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] A unit is attacked problem

Status
Not open for further replies.
Level 1
Joined
Sep 6, 2016
Messages
2
Hi! Let me start with 'Sorry for grammar'. Also I'm new here and I hope i did everything with the thread alright :) Anyway, I started to work a lot with triggering spells. This is the passive ability I made instead of passive lifesteal:

Xvub2UY.png

It's actually working as intended, every third hit deals bonus dmg versus living units and heals the attacker, but i realized that using 'A unit is attacked' event is not the best idea, but I can't find better solution. You may wonder why i added 'Wait 0.50 seconds' action. I did it because this event triggers after the unit WANTS to attack, not after it finishes an attack, so by adding 0.50 seconds I made it look almost perfectly fine. The problem is that you can abuse this ability by constantly clicking S while the unit wants to attack. The attack is stopped but this trigger starts, leading to healing and damaging a lot more than intended.

Is there any way to stop this? Different event? Or can I somehow wait until the unit is actually damaged by an attack? Thank you in advance for help :)
 
Last edited:
Level 4
Joined
Jul 26, 2016
Messages
88
Damage detection systems. As you noticed there is no "unit takes damage event" for Any unit events, but for specific units there is. All you have to do is have a trigger that has no events and handles your on-damage events, and then with another trigger, do Trigger - Add events, and add the event "specific unit is damaged" (this could run for example whenever a unit enters the playable map area)

Unit enters region - A unit enters Playable Map Area

Trigger - add event to trigger (OnDamageEffects):
Specific unit event - (Triggering unit) is damaged

Or you could browse the hive for one of the few damage detection systems that are prebuilt.

The one drawback with damage detection, is that you have to make a few checks here and there for which damage source the damage came from, and there's no check to differentiate between damage coming from spells and basic attacks. What I do in my map for example, is i have a dummy unit and all my spells triggered, when a unit should receive damage from a spell, i change the owner of the dummy to the owner of the caster, and make the dummy damage target(s), and therefore check: is the unit type of the damaging unit that of the dummy? If yes, it is spell damage, if not, it is attack damage. Anyways, GL!
 
Level 1
Joined
Sep 6, 2016
Messages
2
Oh my, that's a lot of work :/ But I think it's worth it. I'm not sure if i understand everything, but I'll try :D Anyway thank you :)
 
Level 14
Joined
Nov 17, 2010
Messages
1,265
There are a few good damage detection systems in the spells section. Bribe made a really good GUI one. Looking_for_help made a GUI-friendly one too. That is the one I use in my maps.
 
Status
Not open for further replies.
Top