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

[Trigger] Is attacked event not firing

Status
Not open for further replies.
Level 10
Joined
Mar 31, 2009
Messages
732
I based a spell off Roar... Only so it could apply a self-buff and play a caster animation (otherwise would have used channel... anyway).

  • Footman defense
    • Events
      • Unit - A unit owned by Player 6 (Orange) Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to Human Footman
    • Actions
      • Unit - Order (Attacked unit) to Night Elf Druid Of The Claw - Roar
Doesn't seem to work. The unit is never ordered to do anything. The function never seems to fire.

Every single attack on my map only does damage via triggers, using the UnitDamageTarget function.

(Uploaded the map, just in case. Saved with NewGen).
 

Attachments

  • karachess.w3x
    397.2 KB · Views: 43
Level 6
Joined
Sep 13, 2008
Messages
261
I'm not completely sure on this. Do your units actually attack or is it scripted abilities? Because unit is attacked only works if there is an attack.
 
Level 10
Joined
Mar 31, 2009
Messages
732
Its scripted damage.
Except for the buttoned abilities, but the damage is still calculated according to various modifiers, and the damage is then scripted anyway.

Is there something else I can do that will work?
 
Level 4
Joined
Mar 14, 2009
Messages
98
Try damage detection. There's no player event for unit takes damage, but you can work around it. Here's an example which you might find useful.

JASS:
function FootmenDamagedActions takes nothing returns nothing
    call IssueImmediateOrder(GetTriggerUnit(), "roar")
endfunction

function FootmenDamageDetection takes nothing returns nothing
    call TriggerRegisterUnitEvent(gg_trg_Footmen_Damaged, GetTriggerUnit(), EVENT_UNIT_DAMAGED)
endfunction

function FootmenDamageEnum takes nothing returns nothing
    call TriggerRegisterUnitEvent(gg_trg_Footmen_Damaged, GetEnumUnit(), EVENT_UNIT_DAMAGED)
endfunction

function FootmenOnly takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == 'hfoo'
endfunction

//===========================================================================
function InitTrig_Footmen_Damaged takes nothing returns nothing
    local trigger AddFootmen = CreateTrigger()
    local region Map = CreateRegion()
    local group Temp = CreateGroup()
    //This is the trigger which triggers when footmen take damage.
    set gg_trg_Footmen_Damaged = CreateTrigger()
    call TriggerAddAction( gg_trg_Footmen_Damaged, function FootmenDamagedActions )
    //Groups all footmen in the map and adds them to the trigger.
    call GroupEnumUnitsInRect(Temp, GetWorldBounds(), Filter(function FootmenOnly))
    call ForGroup(Temp, function FootmenDamageEnum)
    call DestroyGroup(Temp)
    set Temp = null
    //Adds all new footmen to the trigger.
    call RegionAddRect(Map, GetWorldBounds())
    call TriggerRegisterEnterRegion(AddFootmen, Map, Filter(function FootmenOnly))
    call TriggerAddAction(AddFootmen, function FootmenDamageDetection)
endfunction
 
Level 6
Joined
Sep 13, 2008
Messages
261
In your damage_unit_at_location function add in a script that checks unit type. If unittype of unit unit = unit type footmen issue order with no target roar. that simple
 
Level 10
Joined
Mar 31, 2009
Messages
732
In your damage_unit_at_location function add in a script that checks unit type. If unittype of unit unit = unit type footmen issue order with no target roar. that simple

Yeah thats exactly what I'm going to do. I realised later yesterday that since I have isolated the damage call out as a library, it wouldn't be too hard to put the AI calls in after it too. No need to use a trigger that way.

Thanks.
 
Status
Not open for further replies.
Top