• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Cancel attack

Level 23
Joined
Dec 4, 2007
Messages
1,559
Would help to know what you are trying to achieve.
You can of course stop a unit's attack by ordering it to stop or new native "interrupt attack".
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,877
In the event EVENT_PLAYER_UNIT_DAMAGING i can set damage to 0.
Can I stop the event from propagating further? Ie can I cancel the fact of the attack so there is no EVENT_PLAYER_UNIT_DAMAGED

WC Reforged
I imagine you have multiple triggers that rely on the "DAMAGED" Event that you don't want to run in the case of "zero damage". The simple solution is to give those triggers a Condition that checks if the GetEventDamage() is Greater than 0.

You could of course take it a step further and have a system in place that would control which triggers run. IE: One central "on damage taken" trigger that runs multiple other triggers. These triggers could be registered in a database and have a boolean parameter like "RunOnZeroDamage = True/False" giving you control over when they should run. Something sort of like this:
  • Events
    • Unit - A unit Takes damage
  • Conditions
    • Check if the damage source has at least 1 "registered" damage event
  • Actions
    • Set Variable Damage_Taken = (Damage amount)
    • If all conditions are true then do actions
      • If - Conditions
        • (Damage_Taken Greater than 0.00
      • Then - Actions
        • For loop
          • Loop - Actions
            • Trigger - Run (Load X of Y from Any_Damage_Hashtable) (checking conditions)
      • Else - Actions
        • For loop
          • Loop - Actions
            • Trigger - Run (Load X of Y from Zero_Damage_Hashtable) (checking conditions)
This design will also reduce the number of processes that run during combat. A unit that doesn't have any damage events (a basic Footman for example) would never run any "damage" triggers besides this one and they would never get past the first Condition. In a heated battle between 100's of units this could be the difference between running 100 triggers per second instead of 1000 triggers per second, which is the difference between running 100 conditions instead of let's say 3000 conditions per second, most of which will likely be redundant.
 
Last edited:
Top