1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Make an ability usable on a certain unit-type only

Discussion in 'World Editor Help Zone' started by usfshihy, Jul 4, 2015.

  1. usfshihy

    usfshihy

    Joined:
    May 26, 2012
    Messages:
    165
    Resources:
    2
    Maps:
    2
    Resources:
    2
    How to make an ability only possible to be used on a certain type of unit??

    +REP and credits for helpers
     
  2. Radicool

    Radicool

    Joined:
    Mar 27, 2011
    Messages:
    1,150
    Resources:
    4
    Maps:
    4
    Resources:
    4
    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
     
  3. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    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/
     
  4. usfshihy

    usfshihy

    Joined:
    May 26, 2012
    Messages:
    165
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I am trying to make that ability an item ability, I am not sure how would that be possible for that trigger
     
  5. RobertMKD

    RobertMKD

    Joined:
    Jan 23, 2015
    Messages:
    787
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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.
     
  6. usfshihy

    usfshihy

    Joined:
    May 26, 2012
    Messages:
    165
    Resources:
    2
    Maps:
    2
    Resources:
    2
    I need it to be an item ability lads.
     
  7. RobertMKD

    RobertMKD

    Joined:
    Jan 23, 2015
    Messages:
    787
    Resources:
    1
    Maps:
    1
    Resources:
    1
    It doesn't matter..
     
  8. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Did you try any of the solutions yet? AFAIK item abilities still have orders. Pretty much everything does. As long as you can detect the order, you can stop it.

    RobertMKD's solution is probably the best and easiest to implement.
     
  9. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,641
    Resources:
    3
    Spells:
    3
    Resources:
    3
    @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.