• 🏆 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] Increasing the Nnumber of Uses (Sentinel/Flare):

Status
Not open for further replies.

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
178
I want to make it possible to increase the number of uses of any countable spell. I know two of them:
Sentinel: Data - Number of Owls
Flare: Data - Flare Count
If there is 0, it is infinitely in use. But the other numbers would be a count of uses.
It will naturally decrease in the game when the spell will be used, but:
How to make it increase by e.g. picking an item?

I try to make something like this: Flare is a hero skill and it has 2 levels: 1 lvl Data - Flare Count 1, 2 lvl Data - Flare Count 2. If you pick level 1 u have 1 flare to use, if you get the second level you will get the second flare when u pick the ability. But it doesn't work, there is still 1 flare to use. Any creative ideas on this topic?
 

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
178
I made it but it didn't work. There is a map with your proposition:
Any other ideas or am I doing something wrong in this trigger?
 

Attachments

  • Flare.w3x
    17.6 KB · Views: 28
Level 38
Joined
Feb 27, 2007
Messages
4,951
On mobile, didn't/can't look at your test map yet. My two best guesses are
  1. 1.30 broke flare stock increases. Does it work in older versions? I have 1.29 can test that later.
  2. The maximum number of charges is determined by the first level of the ability. Try giving level 1 like 5 charges, level 2 2 charges, and level 3 3 charges. Does the stock count go down when leveled up from 1 to 2?
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
Ad 2. Ye, it's true I checked it.
Yeah I tested too and even in 1.29 it seems like multiple levels of flare with different stock counts is not supported by the game. However, simply removing the ability and re-adding it does reset the current stock count to the default for that ability. It's an ugly solution, but it seems the only way to get the functionality you want is to have N different flare abilities that are all identical except the # of charges at level 1 and then manually replace the ability with the next appropriate ability when the stock should go up. It will also require you to track casts of the ability to know how many charges it actually has at any given time, since afaik there's no trigger action to get that number.

Attached test map. Press escape to remove and re-add the ability on the paladin which resets it to 4 charges.
 

Attachments

  • teeest.w3x
    23 KB · Views: 34
  • Like
Reactions: KPC
Level 38
Joined
Feb 27, 2007
Messages
4,951
Lets say FLARE_MAX is the maximum number of charges a flare spell could have in your map (a unit may have up to this many charges at once) and FLARE_LEVEL_MAX is the maximum level that your flare-based ability can be increased to. You will need FLARE_MAX+1 total abilities: FLARE_MAX different flare abilities nd 1 dummy passive ability to display when the unit has no charges (flare disappears from the command card at 0 remaining charges).

If the flare ability for units can be leveled up and either you 1) care about the tooltip being correct when the number of charges goes down or 2) the flare ability changes in some way from level to level (bigger cast radius, less delay, lowered cooldown, etc.)... then each of these abilities needs to have FLARE_LEVEL_MAX levels with the appropriate data fields matching between abilities. The dummy passive (base it on an aura or something with no valid targets) doesn't need anything special but it should inherit the tooltip from the different levels. Each flare-based ability then needs to have a different number of charges so that there is one each from 1 to FLARE_MAX.

Units in your map with this ability should start with FLARE_ABIL[1] on their ability list in the object editor. You will need to set some variables on map init for use later:

  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set FLARE_MAX = 10 //or whatever the max is
    • Set FLARE_LEVEL_MAX = 3 //or whatever the max is
    • -------- --------
    • Set FLARE_ABIL[0] = dummy passive ability
    • Set FLARE_ABIL[1] = Flare with 1 charge
    • Set FLARE_ABIL[2] = Flare with 2 charges
    • ...
    • Set FLARE_ABIL[FLARE_MAX] = Flare with FLARE_MAX charges
    • -------- set charges per level into variables too --------
    • -------- this so the game knows how many charges to give when you level up the skill --------
    • -------- this part can be simplified if the # charges between levels is constant (say each level increases max by 1) --------
    • Set FLARE_LEVEL_CHARGES[1] = 1
    • Set FLARE_LEVEL_CHARGES[2] = 2
    • Set FLARE_LEVEL_CHARGES[3] = 4
    • ...
    • Set FLARE_LEVEL_CHARGES[FLARE_LEVEL_MAX] = 30
Your cast trigger is this:

  • Events
    • Unit - A Unit starts the effect of an ability
  • Conditions
    • Or - Any conditions are true
      • (Ability being cast) equal to FLARE_ABIL[1]
      • (Ability being cast) equal to FLARE_ABIL[2]
      • (Ability being cast) equal to FLARE_ABIL[3]
      • ..
      • (Ability being cast) equal to FLARE_ABIL[FLARE_MAX]
  • Actions
    • Set FLARE_CHANGE = -1 //how many charges should this action cost? 1 charge
    • Set FLARE_UNIT = (Triggering Unit)
    • Trigger - Run (Flare Change Charges <gen>) (ignoring conditions)
You can make simple triggers to give items that increase your # of charges or to do so when anything else happens, but you didn't specify that so I didn't write one. Your learn trigger is this:

  • Events
    • Unit - A unit learns a skill
  • Conditions
    • Or - Any conditions are true
      • (Learned hero skill) equal to FLARE_ABIL[1]
      • (Learned hero skill) equal to FLARE_ABIL[2]
      • (Learned hero skill) equal to FLARE_ABIL[3]
      • ..
      • (Learned hero skill) equal to FLARE_ABIL[FLARE_MAX]
  • Actions
    • Set FLARE_UNIT = (Triggering unit)
    • Set FLARE_LEVEL = (Level of (Learned hero skill) for FLARE_UNIT)
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • FLARE_LEVEL greater than 1
        • -------- If it's not, then there's no need to change anything, since level 1 should give the right charges --------
      • Then - Actions
        • Set FLARE_CHANGE = FLARE_LEVEL_CHARGES[FLARE_LEVEL] - FLARE_LEVEL_CHARGES[FLARE_LEVEL - 1]
        • Trigger - Run (Flare Change Charges <gen>) (ignoring conditions)
      • Else - Actions
And this trigger does the meat of it all, changing the ability and setting the level:

  • Flare Change Charges
    • Events
    • Conditions
    • Actions
      • Set FLARE_WHICH = 1 //because 1 charge being used will remove the ability, if we don't match anything in the loop below it must have been 1 charge before casting
      • For each (Integer A) from 1 to FLARE_MAX do (Actions)
        • Loop - Actions
          • Set FLARE_LEVEL = (Level of FLARE_ABIL[FLARE_WHICH] for FLARE_UNIT)
          • If (All conditions are true) then do (Then actions) else do (Else actions)
            • If - Conditions
              • FLARE_LEVEL greater than 0
            • Then - Actions
              • Set FLARE_WHICH = (Integer A)
              • Custom script: exitwhen true
            • Else - Actions
      • Set FLARE_NEW = Min(FLARE_LEVEL_CHARGES[FLARE_LEVEL], Max(0, FLARE_WHICH + FLARE_CHANGE)) //can't go higher than max charges for that level, can't go lower than 0
      • Unit - Remove FLARE_ABIL[FLARE_WHICH] from FLARE_UNIT
      • Unit - Add FLARE_ABIL[FLARE_NEW] to FLARE_UNIT
      • Unit - Set level of FLARE_ABIL[FLARE_NEW] for FLARE_UNIT to FLARE_LEVEL
      • -------- Only necessary if the unit with flare can morph via bear form/chaos/whatever, so we may need to make the ability permanent --------
      • -------- There is no GUI equivalent --------
      • Custom script: call UnitMakeAbilityPermanent(udg_FLARE_UNIT, udg_FLARE_ABIL[udg_FLARE_WHICH], true) //change variable names here to match your variables, but keep the udg_ parts
 
Last edited:
  • Like
Reactions: KPC
Level 38
Joined
Feb 27, 2007
Messages
4,951
No map, I just typed those triggers out in the reply box. The variables are going to be as below(with the FLARE_ prefix), though you are certainly able to call them anything else you want to make their purpose more clear.
  • UNIT - unit variable
  • ABIL - ability array (size isn't important)
  • MAX - integer
  • LEVEL_MAX - integer (but I think I never actually used this one in the triggers)
  • LEVEL_CHARGES - integer array (size isn't important)
  • CHANGE - integer
  • LEVEL - integer
  • WHICH - integer
  • NEW - integer
This will be a learning experience for you, and if you are successful you will have increased your world editor skills! Learning to translate suggestions from people on this forum into real triggers is an essential skill. Try to recreate the triggers as I've written them, just going line-by-line. You can ignore the last custom script line for now if that confuses you, but the exitwhen true one is needed. If I made a mistake/error or if you can't find the thing I wrote in the trigger editor or you doare otherwise confused, post here and someone will help clarify or fix. In order to troubleshoot what you've done it will be best to post your trigger by right-clicking its text on the right side of the trigger editor and selecting "copy as text", then pasting here between [trigger][/trigger] tags.
 

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
178
Ok, let's say that I want to have max. 10 charges of this ability. To show 0 counts I want to make disabled ability, without number. I make Abilities and Variables Table. Check it if you can and answer some more questions, please: :)
1. What should be the Initial Value of ABIL? (which Flare (0, 1, 10 or something what I didn't create)
2. How should look "UNIT - unit variable" and what does it determines? (Unit using Flare)?
3. What abilities should be added to the current list?

I attach a screen of both lists:
 

Attachments

  • 111.png
    111.png
    51.3 KB · Views: 56
Level 38
Joined
Feb 27, 2007
Messages
4,951
You need to include the FLARE_ prefix for all of them. Or any other prefix you want. FLARE_UNIT, FLARE_ABIL[], FLARE_NEW, etc. You can call them whatever you want but giving them the same prefix makes them show up next to each other in the variable editor. And also 2 variables can't have the same name so if you use LEVEL (instead of FLARE_LEVEL) here you can never use LEVEL anywhere else.

Initial value isn't something you have to use/worry about. Basically ever. All it does is automatically assign the variable that value once, on map initialization. So for example if you set the initial value for FLARE_MAX to 10, it would be exactly the same as if you had left it as "0" and added this trigger:

  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set FLARE_MAX = 10
  1. ABIL is an array and you can't set the initial value of an array in the variable editor. You must do it in a trigger, namely the first trigger in my previous post that runs on map initialization (most variable setting triggers are run on map initialization). Each index from 1 to 10 (FLARE_MAX = 10 like you said) needs to point to a different flare ability with a different number of charges. FLARE_ABIL[1] = Flare (with 1 charge), FLARE_ABIL[2] = Flare (with 2 charges), etc. all the way up to FLARE_ABIL[10] = Flare (with 10 charges).
  2. FLARE_UNIT is a unit. It does not need an initial value, you can leave that as "no unit". It stores a reference to the unit whose flare charges we are modifying with the Flare Change Charges <gen> trigger. We set it before running that trigger manually, that way it knows which unit to add abilities to and remove abilities from.
  3. Only Flare (with 1 charge) should be in the abilities list. Well, unless you want the unit to learn the spell and then start with 0 charges (in which case I would say to give it the passive ability), but I don't think you would.
 
Last edited:
Level 38
Joined
Feb 27, 2007
Messages
4,951
Yeah, you can just ignore all the level stuff since (I expect) the ability will only have 1 level. That includes the "unit learns a skill" ability; you'll just need to make sure the unit starts the game with the flare ability that gives it the right number of charges when it is first spawned. Whether that's 0 or 3 or 10 it doesn't matter the method will work regardless.
 
Status
Not open for further replies.
Top