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

Possible to use spell book by trigger?

Status
Not open for further replies.
Level 39
Joined
Feb 27, 2007
Messages
5,013
Yes. Spellbook (along with Channel) is one of the only abilities whose base order/orderstring you can actually change (which allows multiple spellbooks on the same unit), so change it to something (like Roar) and order the unit to use that spell like you normally would:

  • Unit - Order (Triggering Unit) to Night Elf Druid of the Claw - Roar
That will open the spellbook.
 

KPC

KPC

Level 7
Joined
Jun 15, 2018
Messages
178
Thx a lot, You are also helping me with a flare counting system. To develop this I need:
A system which provides replacement specific abilities:
If I had X it will be removed and Y will be added.
Also If I had Y it will be replaced by Z (of course, when something happens - event, condition)
X, Y, Z are abilities
Any ideas?
 
Level 9
Joined
Apr 23, 2011
Messages
527
Something of this sort.

  • check
    • Events
      • <your event here>
    • Conditions
      • <your condition here>
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of X for (Triggering unit)) Greater than 0
        • Then - Actions
          • Unit - Remove X from (Triggering unit)
          • Unit - Add Y to (Triggering unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Y for (Triggering unit)) Greater than 0
            • Then - Actions
              • Unit - Remove Y from (Triggering unit)
              • Unit - Add Z to (Triggering unit)
            • Else - Actions
 
Level 39
Joined
Feb 27, 2007
Messages
5,013
Something of this sort.

[trigger]
In the other thread:
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
          • If (All conditions are true) then do (Then actions) else do (Else actions)
            • If - Conditions
              • (Level of FLARE_ABIL[(Integer A)] for FLARE_UNIT) greater than 0
            • Then - Actions
              • Set FLARE_WHICH = (Integer A)
              • Custom script: exitwhen true
            • Else - Actions
      • Set FLARE_LEVEL = (Level of FLARE_ABIL[FLARE_WHICH] for FLARE_UNIT)
      • 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
That's precisely why I said the OP should use that thread for that problem, not this one.
 
Status
Not open for further replies.
Top