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

Make an ability usable on a certain unit-type only

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
This trigger would stop the unit casting a targeted spell on Ancient units

  • Untitled Trigger 001
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • ((Targeted unit) is An Ancient) Equal to True
    • Actions
      • Unit - Order (Triggering unit) to Stop
 
In order for it to be realistic (similar to wc3 spell behavior), it should throw an error as soon as you select the wrong target. Use the event "Unit - A unit is issued an order targeting a unit" or w/e. As the condition, check if the order is equivalent to the order string of your spell, and make sure the triggering unit has your ability.

Have an if/then/else to see if the unit is of a particular type. If he isn't, order the unit to stop and print out an error. Here is an example:
  • Restricted Ability
    • Events
      • Unit - A unit is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(stormbolt))
      • (Level of Storm Bolt for (Triggering unit)) Greater than 0
      • (Target unit of issued order) Not Equal to No unit
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Target unit of issued order)) Not Equal to Footman
        • Then - Actions
          • Unit - Order (Triggering unit) to stop
          • Custom script: call SimError("Cannot target footman.")
        • Else - Actions
If you have JassNewGenPack, you can use the SimError library (as shown above) to easily create a visual error message:
http://www.wc3c.net/showthread.php?t=101260

Or follow this tutorial if you'd prefer not to use JNGP or vJASS:
http://www.hiveworkshop.com/forums/...ls-279/creating-custom-error-messages-232494/
 
Level 11
Joined
Jan 23, 2015
Messages
788
Set the targets allowed only to ancient or mechanical (but ancient is the best).. set the unit classification of that certain unit to ancient and make sure it's the only ancient in your map. You can also change the text that says that the ability can only be cast on ancient units in the user interface options.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
@PurgeandFire
Your solution doesnt completely work.
It does in theory but not in how it is set up.
You have to overwrite the old order, which can be done in two ways:
1, disable that trigger, pause unit, order, unpause, enable.
2, wait 0 seconds (timer) and then order.
(2nd one works 100%, 1st I am not sure)

Items indeed still have orders, which you can catch using those same order events.
Otherwise maybe the event "Unit - Generic unit event -> Unit uses an item" can help.

RobertMKD's solution is indeed the easiest and buggless, but it doesnt work always.
What if there are 8 items like this?
Then you NEED some triggering.
 
Status
Not open for further replies.
Top