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

"Purchasing" Spells & "Ability Code"

Status
Not open for further replies.
Level 4
Joined
Jul 28, 2019
Messages
75
Hi,
1) What is the easiest way to do this? Currently I only have a dozen or so spells, so my way is manageable, but it would be a headache with more. I can handle basic JASS if that is worth it.
Spells (3 level max) are sold as a dummy unit that costs resource saved in int array "INT_ability_point_resource." There doesn't seem to be an "ability-type" command or way to reference the ability's rawcode. Pyrogasm suggested hashtables but I do not understand the ways of hashtables.
2) What does "Ability Code" mean? Hoping it would be a way to refer to the rawcode but it requires reference to a unit(??). (https://i.imgur.com/GHmcoaz.png)

  • Buys ability
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Entangling Roots (Dummy ability unit)
          • (Unit-type of (Triggering unit)) Equal to Silence (Dummy ability unit)
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set TempPlayer = (Owner of (Triggering unit))
      • Set TempUnit = Player_Heroes[TempInt]
      • Unit - Remove (Triggering unit) from the game
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • INT_ability_point_resource[TempInt] Equal to 0
        • Then - Actions
          • Game - Display to (Player group((Player(TempInt)))) for 4.00 seconds the text: |cff00ff00Not enoug...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to Entangling Roots (Dummy ability unit)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Entangling Roots (custom version) for Player_Heroes[TempInt]) Equal to 3
                • Then - Actions
                  • Game - Display to (Player group((Player(TempInt)))) for 4.00 seconds the text: |cff00ff00Ability a...
                • Else - Actions
                  • Set INT_ability_point_resource[TempInt] = (INT_ability_point_resource[TempInt] - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of Entangling Roots (custom version) for Player_Heroes[TempInt]) Greater than 0
                    • Then - Actions
                      • Unit - Set level of Entangling Roots (custom version) for TempUnit to ((Level of Entangling Roots (custom version) for TempUnit) + 1)
                      • Game - Display to (Player group((Player(TempInt)))) for 4.00 seconds the text: |cff00ff00Ability p...
                    • Else - Actions
                      • Unit - Add Entangling Roots (custom version) to Player_Heroes[TempInt]
                      • Hero - Modify unspent skill points of Player_Heroes[TempInt]: Add 1 points
                      • Hero - Learn skill for (Triggering unit): Entangling Roots (custom version)
                      • Game - Display to (Player group((Player(TempInt)))) for 4.00 seconds the text: |cff00ff00Ability p...
            • Else - Actions
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
4,989
You might be able to do this with tomes instead of units but idk.
  • Events
    • Time - Elapsed game time is 0.50 seconds
  • Conditions
  • Actions
    • Hashtable - Create a hashtable
    • Set BuySpellHash = (Last created hashtable)
    • -------- --------
    • Set BuyUnit = Entangling Roots (Dummy ability unit) //unit type variable
    • Set BuySpell = Entangling Roots (custom version) //Ability code variable
    • Custom script: set udg_BuyUnitInt = udg_BuyUnit //necessary because even though ability code/unit type variables are integers, GUI doesn't want you to assign an integer variable = them
    • Custom script: set udg_BuySpellInt = udg_BuySpell
    • Hashtable - Save BuySpellInt as 0 of BuyUnitInt in BuySpellHash //save integer
    • -------- --------
    • Set BuyUnit = Silence (Dummy ability unit)
    • Set BuySpell = Silence (custom version)
    • Custom script: set udg_BuyUnitInt = udg_BuyUnit
    • Custom script: set udg_BuySpellInt = udg_BuySpell
    • Hashtable - Save BuySpellInt as 0 of BuyUnitInt in BuySpellHash
  • Events
    • Unit - A unit enters (playable map area)
  • Conditions
    • (Level of SOME_ABILITY_THAT_ALL_SPELL_BUYING_DUMMIES_HAVE_SO_YOU_KNOW_THEY_ARE_SPELL_DUMMIES) for (Triggering Unit) greater than 0
  • Actions
    • Set BuyUnit = (Unit-type of (Triggering Unit))
    • Custom script: set udg_BuyUnitInt = udg_BuyUnit
    • Set BuySpellInt = Load 0 of BuyUnitInt in BuySpellHash //load integer
    • Custom script: set udg_BuySpell = udg_BuySpellInt
    • -------- BuySpell is now the ability code variable of the spell they are trying to buy --------
 
Level 4
Joined
Jul 28, 2019
Messages
75
I got it! Here's what worked.
e: updated with lv2 abilities req hero lv3 and lv3 abilities req hero lv5. Cleaned up everything else.
Currently every ability tome has to be added to the item-type condition. The only alternative I can think of is to make ability tomes level 0 and all other items level 1+. Fortunately there aren't more than a couple dozen spells, but in the name of elegance, an alternative would be nice, if you can think of one, please let me know.
This does not check for the max of 6-7 abilities.
INT_ability_point_resource[TempInt]=int array storing points each player has to spend on abilities.

  • Initialization Define Ability Tomes
    • Events
      • Time - Elapsed game time is 0.50 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set HASHT_BuySpell = (Last created hashtable)
      • -------- --------
      • Set ITEMTYPE_BuySpell = Entangling Roots
      • Set ABILITYCODE_BuySpell = Entangling Roots (custom version)
      • Custom script: set udg_INT_BuyItem = udg_ITEMTYPE_BuySpell
      • Custom script: set udg_INT_BuySpell = udg_ABILITYCODE_BuySpell
      • Hashtable - Save INT_BuySpell as 0 of INT_BuyItem in HASHT_BuySpell
      • Game - Display to (All players) the text: (debug~ ability name = + (Name of ABILITYCODE_BuySpell))
      • -------- --------
      • Set ITEMTYPE_BuySpell = Silence
      • Set ABILITYCODE_BuySpell = Silence (custom version)
      • Game - Display to (All players) the text: (debug~ ability name = + (Name of ABILITYCODE_BuySpell))
      • Custom script: set udg_INT_BuyItem = udg_ITEMTYPE_BuySpell
      • Custom script: set udg_INT_BuySpell = udg_ABILITYCODE_BuySpell
      • Hashtable - Save INT_BuySpell as 0 of INT_BuyItem in HASHT_BuySpell
      • Game - Display to (All players) the text: (debug~ ability name = + (Name of ABILITYCODE_BuySpell))
  • Buy Ability as Tome
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Cluster Arrows
          • (Item-type of (Item being manipulated)) Equal to Dark Rage
          • (Item-type of (Item being manipulated)) Equal to Entangling Roots
          • (Item-type of (Item being manipulated)) Equal to Explosive Trap
          • (Item-type of (Item being manipulated)) Equal to Fast Arrows
          • (Item-type of (Item being manipulated)) Equal to Owl Guardian
          • (Item-type of (Item being manipulated)) Equal to Pocket Burrow
          • (Item-type of (Item being manipulated)) Equal to Scatter Shot
          • (Item-type of (Item being manipulated)) Equal to Silence
          • (Item-type of (Item being manipulated)) Equal to Starfall
          • (Item-type of (Item being manipulated)) Equal to Summon Bear
          • (Item-type of (Item being manipulated)) Equal to Trueshot Aura
          • (Item-type of (Item being manipulated)) Equal to Ambush
    • Actions
      • Set ITEMTYPE_BuySpell = (Item-type of (Item being manipulated))
      • Custom script: set udg_INT_BuyItem = udg_ITEMTYPE_BuySpell
      • Set INT_BuySpell = (Load 0 of INT_BuyItem from HASHT_BuySpell)
      • Custom script: set udg_ABILITYCODE_BuySpell = udg_INT_BuySpell
      • -------- HASHT_BuySpell is now the ability code variable of the spell they are trying to buy --------
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set TempPlayer = (Owner of (Triggering unit))
      • Set TempUnit = Player_Heroes[TempInt]
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • INT_ability_point_resource[TempInt] Equal to 0
        • Then - Actions
          • Game - Display to (Player group((Player(TempInt)))) for 4.00 seconds the text: |cff00ff00Not enoug...
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of ABILITYCODE_BuySpell for Player_Heroes[TempInt]) Equal to 3
            • Then - Actions
              • Game - Display to (Player group((Player(TempInt)))) for 4.00 seconds the text: |cff00ff00Ability a...
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of ABILITYCODE_BuySpell for Player_Heroes[TempInt]) Greater than 0
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Level of TempUnit) Less than 3
                      • (Level of ABILITYCODE_BuySpell for TempUnit) Equal to 1
                    • Then - Actions
                      • Game - Display to (Player group((Player(TempInt)))) for 4.00 seconds the text: (|cff00ff00 + ((Name of ABILITYCODE_BuySpell) + ( level + (2 + |cffff0000requires|r |cff00ff00hero level 3.|r))))
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Level of TempUnit) Less than 5
                          • (Level of ABILITYCODE_BuySpell for TempUnit) Equal to 2
                        • Then - Actions
                          • Game - Display to (Player group((Player(TempInt)))) for 4.00 seconds the text: (|cff00ff00 + ((Name of ABILITYCODE_BuySpell) + ( level + (3 + |cffff0000requires|r |cff00ff00hero level 5.|r))))
                        • Else - Actions
                          • Set INT_ability_point_resource[TempInt] = (INT_ability_point_resource[TempInt] - 1)
                          • Unit - Set level of ABILITYCODE_BuySpell for TempUnit to ((Level of ABILITYCODE_BuySpell for TempUnit) + 1)
                          • Game - Display to (Player group((Player(TempInt)))) for 4.00 seconds the text: (|cff00ff00 + ((Name of ABILITYCODE_BuySpell) + ( level + ((String((Level of ABILITYCODE_BuySpell for TempUnit))) + acquired.))))
                • Else - Actions
                  • Set INT_ability_point_resource[TempInt] = (INT_ability_point_resource[TempInt] - 1)
                  • Unit - Add ABILITYCODE_BuySpell to Player_Heroes[TempInt]
                  • Game - Display to (Player group((Player(TempInt)))) for 4.00 seconds the text: (|cff00ff00 + ((Name of ABILITYCODE_BuySpell) + ( level + ((String((Level of ABILITYCODE_BuySpell for TempUnit))) + acquired.))))
 
Last edited:
Status
Not open for further replies.
Top