• 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.

If unit type in range then...

Status
Not open for further replies.
Level 6
Joined
Jun 11, 2009
Messages
151
You would have to create a dummy unit with a dummy spell tranq, because a unit can't cast spells that don't have o.o
 
Level 12
Joined
Mar 10, 2008
Messages
869
You would have to create a dummy unit with a dummy spell tranq, because a unit can't cast spells that don't have o.o

Also, they can't cast them when they're dead.
  • Footman Dies
    • Events
      • Unit - A unit dies
    • Conditions
      • If (Dying Unit) is Equal to Footman
    • Actions
      • Set RemoveLocation = (Position of (Dying Unit))
      • Unit Group - Pick every unit in (Units within 500.00 of RemoveLocation and do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dummy Unit for (Owner of (Dying Unit)) at RemoveLocation facing Default building facing degreese
          • Unit - Add a 2 second Generic expiration timer to (Last Created Unit)
          • Unit - Order (Last Created Unit) to Night elf - Tranquility (Picked Unit)
      • Custom script: call RemoveLocation(udg_RemoveLocation)
Maybe?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
If the unit doesn't have the ability, just give him the dummy treatment.
  • Untitled Trigger 021
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set Temp_Loc_1 = (Position of (Triggering unit))
      • Set Temp_Group_1 = (Units within 512.00 of Temp_Loc_1 matching ((((Matching unit) is alive) Equal to True) and ((Unit-type of (Matching unit)) Equal to Footman)))
      • Unit Group - Pick every unit in Temp_Group_1 and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Human Mountain King - Thunder Clap
      • Custom script: call DestroyGroup(udg_Temp_Group_1)
      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
 
Level 12
Joined
Mar 10, 2008
Messages
869
Guys you're missing the point here, it's just an example.

The problem is that I can't find a way to trigger a unit to cast an ability when a unit dies in range of the caster.

Example: If any unit were to die in range of the Voodoo Priest, he would cast Big Bad Voodoo.

Then you make a dummy unit and give the dummy unit the spell you want it to cast and order the dummy unit to cast the spell. Dead units can't cast spells.
 
Hm I think I'm confusing you.

I'm trying to order the unit that is still alive to cast the spell, not the unit that died.

Specifically what I'm trying to do is this:

I have a unit with Carrion Beetles. This unit follows the attack group into battle. When enemy units die around the unit with Carrion Beetles, I want the unit to be forced to cast Carrion Beetles.

This is necessary because AI players do not ever stop ordering their units. As the unit with Carrion Beetles does not have an attack, it never becomes idle during the battle - thus it is necessary to force the unit to cast Carrion Beetles.
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
Maker's method should work with some adjustments to your preference.
However, there are some weird annoying flaws with this method:

  1. For some reason, this trigger will seriously fail with Computer units. In my testing, they cannot be ordered the standard "carrionscarabsinstant" order that Players would issue to use the ability. I'm sure there is probably a way to make them cast this skill since the Melee AI is able to use Carrion Scarabs. If you give up on using Carrion Scarabs, you could substitute it with Raise Dead or make your own custom spell.
  2. The event for this trigger won't really work that well since the trigger fires exactly when a unit dies, causing the ability to not work because the corpse hasn't decayed enough yet. You could add the
    • Unit - A unit Decays
    event but even that won't work unless you add a little wait/delay.
By the way, you could also enumerate the units that should cast this spell based on whether they actually have the ability which I think is much easier than checking for unit type.
 
Last edited:
I found a way around it using a buff, however I have trouble with this trigger.
  • AIGive
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Race of (Owner of (Killing unit))) Equal to Night Elf
    • Actions
      • Unit - Create 1 Wisp for (Owner of (Killing unit)) at (Position of (Dying unit)) facing Default building facing degrees
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Last created unit) has buff AI Beetles ) Equal to False
        • Then - Actions
          • Unit - Remove (Last created unit) from the game
        • Else - Actions
          • Animation - Play (Last created unit)'s birth animation
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
The problem with that method is that the Wisp may not actually get the Aura buff when the condition checks for it.
I'm not sure why'd you use that
  • (Race of (Owner of (Killing unit))) Equal to Night Elf
either as it's kind of impractical unless it achieves the effect you want.

Here's a modified way of doing it that involves the usage of abilities:
  • Test
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set TempLoc = (Position of (Triggering unit))
      • Set TempGroup = (Units within 600.00 of TempLoc matching (((Level of Moon Glaive for (Matching unit)) Greater than 0) and (((Matching unit) is alive) Equal to True)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) Greater than 0
        • Then - Actions
          • Unit - Create 1 UNIT for (Owner of (Random unit from TempGroup)) at TempLoc facing Default building facing degrees
          • Animation - Play (Last created unit)'s birth animation
          • -------- OPTIONAL --------
          • Animation - Queue (Last created unit)'s stand animation
        • Else - Actions
      • -------- Remove leaks --------
      • Custom script: call RemoveLocation(udg_TempLoc)
      • Custom script: call DestroyGroup(udg_TempGroup)
Things that the trigger does not account for:

  • Making the caster play a spell animation
  • Checking for mana cost
  • Spell cooldown
 
Status
Not open for further replies.
Top