• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Trigger] Is attacked event not firing

Status
Not open for further replies.
Level 11
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

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.
 
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
 
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
 
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.
Back
Top