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.

Making an ability with limited casts

Discussion in 'Triggers & Scripts' started by Linaze, Apr 6, 2011.

  1. Linaze

    Linaze

    Joined:
    Feb 28, 2007
    Messages:
    2,991
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    Hello.

    I am trying to make an ability which can only be cast a limited amount of times (like the Sentinel), but I've ran into problems.

    First thing, to make it easy for the player to see how many casts of the ability is left, we've made separate icons with an integer on them representing just how many casts are left. To use these icons, I made one ability per icon. Object editor part done.

    As for coding, when you cast the first spell, it's removed and adds the one with the "next" icon and so on until you cast the ability with a "1" on it. Because when that's cast, the spell is removed from the unit and no other is added.

    This works just fine for one unit. When you've selected several units, though, and order them to cast this ability, they'll end up with different abilities because one has the one with a "2" on it, one has a "3" on it etc. This means if you select two units with a different amount of casts left, the ability won't show up in the command panel. I've tried stuff but I haven't gotten anywhere. Care to help?

    Also, the spell should be point target, so basing it off of Sentinel won't work.

    Thanks in advance.
     
  2. Pharaoh_

    Pharaoh_

    Joined:
    Nov 6, 2008
    Messages:
    8,127
    Resources:
    11
    Icons:
    3
    Skins:
    1
    Spells:
    6
    Tutorials:
    1
    Resources:
    11
    You need to use a hashtable:
    You will set the abilities, create the hashtable and, in case the bearers of the ability are preset, you will be using the unit group pick, else, the Det one trigger will check whenever such a unit enters the game to add the ability to them.
    The loading part checks how many times the unit has casted the ability and accordingly switches it to the next level.
    • Melee Initialization
      • Events
        • Map initialization
      • Conditions
      • Actions
        • Custom script: set udg_Hash = InitHashtable()
        • Custom script: set bj_wantDestroyGroup = true
        • Set Abilities[1] = Reveal (3 uses left)
        • Set Abilities[2] = Reveal (2 uses left)
        • Set Abilities[3] = Reveal (1 use left)
        • Unit Group - Pick every unit in (Units of type Priest) and do (Actions)
          • Loop - Actions
            • Hashtable - Save 1 as (Key uses) of (Key (Picked unit)) in Hash

    • Det one
      • Events
        • Unit - A unit enters (Playable map area)
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to Priest
      • Actions
        • Hashtable - Save 1 as (Key uses) of (Key (Triggering unit)) in Hash

    • Ability
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • Or - Any (Conditions) are true
          • Conditions
            • (Ability being cast) Equal to Reveal (1 use left)
            • (Ability being cast) Equal to Reveal (2 uses left)
            • (Ability being cast) Equal to Reveal (3 uses left)
      • Actions
        • Set UsesLoad = (Load (Key uses) of (Key (Triggering unit)) from Hash)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • UsesLoad Less than 3
          • Then - Actions
            • Unit - Remove Abilities[UsesLoad] from (Triggering unit)
            • Unit - Add Abilities[(UsesLoad + 1)] to (Triggering unit)
            • Hashtable - Save (UsesLoad + 1) as (Key uses) of (Key (Triggering unit)) in Hash
          • Else - Actions
            • Unit - Remove Reveal (1 use left) from (Triggering unit)


    I have made a test map as well ;]
     

    Attached Files:

  3. Linaze

    Linaze

    Joined:
    Feb 28, 2007
    Messages:
    2,991
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    Awesome, except it doesn't work.
    Select two priests, cast reveal, they'll have different abilities so neither will show up.
     
  4. Pharaoh_

    Pharaoh_

    Joined:
    Nov 6, 2008
    Messages:
    8,127
    Resources:
    11
    Icons:
    3
    Skins:
    1
    Spells:
    6
    Tutorials:
    1
    Resources:
    11
    Well, I wouldn't want to create ten or so abilities, just for the sake of a test map. It is totally MUI, import it in your map and change the abilities' list.

    So, you have made levels for each ability? How do you represent the difference between one level of uses with the other one?
     
  5. Deolrin

    Deolrin

    Joined:
    Apr 18, 2008
    Messages:
    7,210
    Resources:
    57
    Models:
    48
    Icons:
    6
    Packs:
    2
    Tutorials:
    1
    Resources:
    57
    That is not his point, afaik.
    He means that, he selects multiple priests and casts "Reveal". Since this changes one of their abilities, they are no longer exactly the same, thus they no longer have the exact same spells, thus the "Reveal" spell is completely invisible.
     
  6. Linaze

    Linaze

    Joined:
    Feb 28, 2007
    Messages:
    2,991
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    If you select a footman and a priest, you won't see either of the two's abilities, simply because they have different abilities. Same goes for your test map, if you select two priest with different variations of reveal, neither will show up.
     
  7. Pharaoh_

    Pharaoh_

    Joined:
    Nov 6, 2008
    Messages:
    8,127
    Resources:
    11
    Icons:
    3
    Skins:
    1
    Spells:
    6
    Tutorials:
    1
    Resources:
    11
    I got that; I asked how YOU represent the variations of abilities' levels in your map.
     
  8. Linaze

    Linaze

    Joined:
    Feb 28, 2007
    Messages:
    2,991
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    With one ability per variation. Each ability has a different icon with an integer on it representing number of casts left. This didn't work however, as I said in the first post. So basically it needs to be one ability, but then we can't have different icons.
     
  9. Deolrin

    Deolrin

    Joined:
    Apr 18, 2008
    Messages:
    7,210
    Resources:
    57
    Models:
    48
    Icons:
    6
    Packs:
    2
    Tutorials:
    1
    Resources:
    57
    They have no level, they're regular unit abilities. Not hero abilities. :p
     
  10. Axarion

    Axarion

    Joined:
    Sep 30, 2009
    Messages:
    675
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Non Hero skills can have levels too.
     
  11. HaniBon

    HaniBon

    Joined:
    Apr 25, 2009
    Messages:
    464
    Resources:
    0
    Resources:
    0
    You could also make it really easy.
    Such as:

    "Event - A Unit begins casting a ability"
    "Condition -
    And
    Ability being cast Equal to <your spell>"
    AbilityInteger Less than <number>"
    "Action - Set AbilityInteger Equal to (AbilityInteger + 1)"

    What does this do?
    Well, the event checks when a unit wants to begin casting a ability.
    The ability/trigger will only start if the "AbilityInteger" is less than X.
    Every time a unit cast the spell, the X will increase by 1.
    In other words, if the X becomes over the maximum amount, the trigger wont start.

    Might be hard to understand but I can help you more if needed.
    Just send me a PM.
    Thanks for reading.
     
  12. wolfman

    wolfman

    Joined:
    May 31, 2008
    Messages:
    696
    Resources:
    0
    Resources:
    0
    Just make one ability with different levels and change the level when its casted. Put the number of remaining casts in the tooltip or something
     
  13. defskull

    defskull

    Joined:
    Mar 27, 2008
    Messages:
    7,978
    Resources:
    17
    Spells:
    17
    Resources:
    17
    That trigger is pretty easy if you're not making it MUI :)
     
  14. Weep

    Weep

    Joined:
    Jul 12, 2009
    Messages:
    316
    Resources:
    3
    Models:
    2
    Spells:
    1
    Resources:
    3
    So, base it on Flare? :grin: