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

Attacking unit does not want to do anything

Level 3
Joined
Oct 5, 2016
Messages
53
Hello, I have a trigger
  • holyLightHeal
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Attacking unit) Equal to Paladin 0187 <gen>
    • Actions
      • Unit - Order Paladin 0187 <gen> to Human Paladin - Holy Light Knight 0203 <gen>
When palading is attacking someone, he should holy light the knight but instead he just freezes with holy light icon being active. If I remove the condition it works correctly.

update: problem exist when attacking hostile units
 
Level 18
Joined
Mar 16, 2008
Messages
721
I think the (attacking unit) part should be changed to something different. The attacking unit would be the one doing damage. I think for this one, you would want to use
  • Event Response - (Damage Target)
? What exactly do you want to happen here?
 
Level 12
Joined
Jan 10, 2023
Messages
191
I'm guessing what is happening is that the Paladin is being ordered to cast Holy Light at the "same time" it is carrying out orders to attack.

The Event that makes it all very easy is this one:
  • Unit - A unit Takes damage
The Paladin normally can only deal damage with its basic attack, but incase of items or added abilities, and if you only want this to happen when the Paladin uses its base attack then use this Condition:
  • (Current order of Paladin 0187 <gen>) Equal to (Order(attack))
This works fine for me:
  • holyLightHeal
    • Events
      • Unit - A unit Takes damage
    • Conditions
      • (Damage source) Equal to Paladin 0187 <gen>
      • (Current order of Paladin 0187 <gen>) Equal to (Order(attack))
    • Actions
      • Unit - Order Paladin 0187 <gen> to Human Paladin - Holy Light Knight 0203 <gen>
 
Level 3
Joined
Oct 5, 2016
Messages
53
I also found that if I add "wait" action in my original trigger - it works. I don't know how efficient is this solution though
 
Level 12
Joined
Jan 10, 2023
Messages
191
I also found that if I add "wait" action in my original trigger - it works. I don't know how efficient is this solution though
I would say in this case using the wait and your original trigger would be better because it the event will occur less often using the "Unit is Attacked" event, and you won't need the current order condition I added if you use a wait. There's no reason not to wait in this case.

Neither one would cause any noticeable performance difference, if you're on the fence, go with what visually looks better and you are more comfortable with.

Just my two cents: would it make sense to you to add a condition that checks how much health the Knight has? If it has full health it just won't cast, but if it has 99% health it's a bit of a waste..
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,569
TIL the generic Damage Event didn't exist in the initial 1.31 patch.

But you do have access to it in Jass, which could be accessed in GUI with a few variables and this code:
vJASS:
// Use the following Event in GUI to take advantage of the system:
// Game - GDE_Damage_Event becomes Equal to 1.00
// Then reference any of the GDE_ variables as if they were Event Responses.

library GUIDamageEvent initializer GUIDamageEvent_Init
    function GUIDamageEvent_Actions takes nothing returns nothing
        set udg_GDE_Damage_Source = GetEventDamageSource()
        set udg_GDE_Damage_Target = BlzGetEventDamageTarget()
        set udg_GDE_Damage_Amount = GetEventDamage()
        set udg_GDE_Attack_Type = BlzGetEventAttackType()
        set udg_GDE_Damage_Type = BlzGetEventDamageType()
        set udg_GDE_Is_Attack = BlzGetEventIsAttack()
        set udg_GDE_Damage_Event = 1.00
        set udg_GDE_Damage_Event = 0.00
    endfunction

    function GUIDamageEvent_Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DAMAGED )
        call TriggerAddAction( t, function GUIDamageEvent_Actions )
    endfunction
endlibrary

Make sure to create these variables with the same exact types and case sensitive names:
1689478906028.png


Then to use the system use this custom real Event:
  • Test
    • Events
      • Game - GDE_Damage_Event becomes Equal to 1.00
    • Conditions
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: (Name of GDE_Damage_Source)
      • Game - Display to (All players) for 30.00 seconds the text: (Name of GDE_Damage_Target)
Use the GDE variables like Event Responses.

You now have a very basic Damage Engine in your map (or use Bribes and get a ton of awesome features).
 
Last edited:
Level 12
Joined
Jan 10, 2023
Messages
191
Well I'm glad I read that, even converting it completely for Jass use could be a useful lightweight Damage Engine:

JASS:
library DamageEventResponse
    globals
        unit DER_Damage_Source
        unit DER_Damage_Target
        real DER_Damage_Amount
        attacktype DER_Attack_Type
        damagetype DER_Damage_Type
        boolean DER_Is_Attack
    endglobals

    function SetDamageEventResponses takes nothing returns nothing
        set DER_Damage_Source = GetEventDamageSource()
        set DER_Damage_Target = BlzGetEventDamageTarget()
        set DEE_Damage_Amount = GetEventDamage()
        set DER_Attack_Type = BlzGetEventAttackType()
        set DER_Damage_Type = BlzGetEventDamageType()
        set DER_Is_Attack = BlzGetEventIsAttack()
    endfunction
endlibrary

...

function DERExampleTriggerFunction takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DAMAGED )
    call TriggerAddAction( t, function SetDamageEventResponses )
    call TriggerAddAction( t, function SomeFunctionThatUsesDER )
endfunction
 
Top