• 🏆 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] Order unit to cast ability

Status
Not open for further replies.
Level 8
Joined
Jul 14, 2010
Messages
235
Is it possible to order a unit to cast an ability?

I would love for a bossfight to: Make the boss after 75% HP lost, mind controll the nearest hero for 10seconds. I got the spell, but I need a trigger who sense that the boss have 75% HP, and then order the boss to cast the spell on the nearest Hero. Thanks.

- aiDer
 
Level 5
Joined
Jan 4, 2007
Messages
103
This?:

  • Events
    • Unit - A unit Is attacked
  • Conditions
    • (Attacked unit) Equal to Your Boss
    • (Life of (Attacked unit)) Less than or equal to 7500.00
  • Actions
    • Unit - Order (Attacked unit) to Human Mountain King - Storm Bolt (Attacking unit)
Life of the unit can't be put in % so 7500 of 10000, if he has that much, is 75% or put any number that is 75% of it's heath. The order is based on Storm Bolt, if your hero has a abilty based on Storm Bolt he will cast it. Put the ability that your ability is based on ect. If it's based on Storm Bolt, an active spell with a target, then it's Unit - Issue Order Targeting a Unit, if it's an active without a target, Thunder Clap, then it is Unit - Issue Order with No Target.:

  • Unit - Order (Attacked unit) to Human Mountain King - Thunder Clap
If it's an active spell with a point target, Shockwave, then it is, Unit - Issue Order Targeting a Point.:

  • Set Point = (Position of (Attacking unit))
  • Unit - Order (Attacked unit) to Orc Tauren Chieftain - Shockwave Point
  • Custom script: call RemoveLocation (udg_Point)
Hope it helps:)
 
Level 8
Joined
Jul 14, 2010
Messages
235
I've been trying your first example with Storm Bolt, since the spell is a target unit spell. But the boss dont do anything when at 75%HP (19500HP). I have learned the boss the spell at Map Initialization. I also set the spell to Default in Object Editor>Abilities, and saw that the spell really was "Death Pact". So the Action line in my trigger was:
Unit - Order (Attacked unit) to Undead Death Knight - Death Pact (Attacking unit).

Shouldn't the boss know that the spell really is based on Death Pact, and do this spell when told to if he has it learned? :p

Thanks for helping.
 
Level 8
Joined
Jul 14, 2010
Messages
235
hmm, but the spell works on all types of units. And I even tried to attack the boss with undead units. Btw, you may know the spell: http://www.hiveworkshop.com/forums/...7830/?prev=of=rating&c=114&r=20&d=list&page=6 - It's the "Mens Imperium". And I'm trying to order the boss to "Unit - Order (Attacked unit) to Undead Death Knight - Death Pact (Attacking unit)" because Undead Knight - Death Pact is the default to "Mens Imperium" ability, which activate all those triggers.
 
No, Mens Imperium is based off "Channel". Just because they bear the same icon, it doesn't mean they are "Death Pact". Channel is used for custom abilities, since it is the most flexible spell in Warcraft 3. If you want your unit to cast a Channel-based spell, use this:
  • Custom script: call IssueTargetOrder (GetTriggerUnit(), "channel", GetAttacker())
Channel is one of the abilities that you can change its Order Id, so that a unit can have multiple Channel-based abilities. If you change the "Data - Base Order Id" to anything else, so that it doesn't collide with any other Channel ability on the same unit, you will also need to change the custom script I gave you.
If the Base Order Id is "cloudoffog", as in Mens Imperium, the custom script will change to:
  • Custom script: call IssueTargetOrder (GetTriggerUnit(), "cloudoffog", GetAttacker())
 
Level 6
Joined
Oct 26, 2005
Messages
190
You know, I don't think the trigger posted at first is completely efficient, since it will ONLY trigger is he gets attacked, what if you damage him with spells? Also attacking the first unit that attacks him is not nice at all.

This is my advice, first, use a timer that checks life. And, instead of hero spells for the boss do unit spells so he doesn't need to learn them.

Second, the name of the original spell you gave him is the order you're going to use in triggers, it doesn't matter if you totally change the spell. So if you create storm bolt, order via triggers to Storm Bolt.

It would look like this so far:

Event - (Time) Every X seconds of game-time
Conditions - (Real) Percentage Life of (Variable assigned/Unit) becomes Less than or equal to X.00
Actions
Trigger - Turn off <This trigger>
Variable - Set BossPoint (Point) = Position of Boss
Variable - Set BossGroup (UnitGroup) = Units within X of BossPoint matching (conditions)
Unit group - Pick every unit in [Random 1 unit in BossGroup] and do Actions
--Order Boss to Human - Storm Bolt (Picked Unit)
Call DestroyGroup (udg_BossGroup)
Call RemoveLocaton (udg_BossPoint)

This will pick a random unit according to your conditions. Now the drawback is that you will need another trigger to turn on this trigger again.

Events - Every X seconds
Conditions - Percentage life of Boss becomes greater than X%
Actions - Turn on <First Trigger>

Hope I helped, sorry for not posting triggers properly
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
A checking timer (Time - Periodic Event) is the best to check a certain condition in a short time (0.03 would be efficient to check the condition)
Also, Real variable can be used as % rather than triggering a whole number which does not meet the thread opener's needs (he needs in %, not in a value number, which can be easily manipulated)
 
Status
Not open for further replies.
Top