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. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. The results are out! Check them out.
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. 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.

"Purchasing" Spells & "Ability Code"

Discussion in 'Triggers & Scripts' started by Jahjahbinks, Aug 8, 2019.

  1. Jahjahbinks

    Jahjahbinks

    Joined:
    Jul 28, 2019
    Messages:
    18
    Resources:
    0
    Resources:
    0
    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: Aug 8, 2019
  2. Pyrogasm

    Pyrogasm

    Joined:
    Feb 27, 2007
    Messages:
    2,895
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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 --------
     
  3. Jahjahbinks

    Jahjahbinks

    Joined:
    Jul 28, 2019
    Messages:
    18
    Resources:
    0
    Resources:
    0
    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: Aug 9, 2019