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

[General] Can't increase custom hero ability levels

Status
Not open for further replies.
Level 4
Joined
Nov 20, 2006
Messages
71
I'm using a trigger that spawns a hero at a certain level and then gets skills according to various things in the map. The problem is that the "setting" of skill levels don't work.

I tried to use "set ability level" as you can with units, but that doesn't seem to do anything with hero abilities.

There is a trigger to "learn" hero abilities, but you can't use any variables for your skills/ability codes and it would be extremely cumbersome to make that work with custom abilities.


So the question is, what is the best way to spawn a hero at level X, and then have it learn custom hero abilities in the order you choose.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
I can only think of the cumbersome approach outside of maybe AI?

It doesn't have to be too cumbersome though, ~4 abilities per hero in an Array/Hashtable.

100 custom Heroes, that's only like 400 abilities... not so bad... just put on a good movie or something in the background.
 
Level 4
Joined
Nov 20, 2006
Messages
71
well if listing 400 abilities by hand with a movie running isn't very cumbersome i don't know what is. From what I can come up with so far, that will take a ton of repetition to get working in a way where you can dictate which abilities get how many skill points too.


I did look at the AI option but that has its own problems. I don't know how it works with triggered spawned heroes but maybe it would be easier than what I'm looking at so far.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
Here's something I threw together that might be useful to you. It's a Hashtable that keeps track of a Heroes abilities. I also made some triggers to make it easy to add/load data from the Hashtable, as well as an example to show how to learn these Abilities for your Hero.

Here's the Setup trigger. This is the main trigger that you need to configure.

Set AH_None = Some ability that your Heroes will NEVER Learn.
Set AH_Hero = The Hero you want to add to the system.
Set AH_Ability[X] = The Ability you want to add to the system for that Hero. This can go up to AH_Ability[5] since Heroes can only learn up to 5 Skills.

  • Setup AH
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Create Hashtable --------
      • Hashtable - Create a hashtable
      • Set VariableSet AH_Hash = (Last created hashtable)
      • -------- --------
      • -------- ///////////////////////////////////////////////////// --------
      • -------- CONFIGURE: --------
      • -------- ///////////////////////////////////////////////////// --------
      • -------- --------
      • -------- Set this to an Ability that your Heros will NEVER Learn --------
      • Set VariableSet AH_None = No Ability (Used for AH)
      • -------- --------
      • -------- Set Default Values For Abilities --------
      • For each (Integer AH_Loop) from 1 to 7, do (Actions)
        • Loop - Actions
          • Set VariableSet AH_Ability[AH_Loop] = AH_None
      • -------- --------
      • -------- Add Heros to System: --------
      • Set VariableSet AH_Hero = Paladin
      • Set VariableSet AH_Ability[1] = Holy Light
      • Set VariableSet AH_Ability[2] = Divine Shield
      • Set VariableSet AH_Ability[3] = Devotion Aura
      • Set VariableSet AH_Ability[4] = Resurrection
      • Trigger - Run Save to AH <gen> (ignoring conditions)
      • -------- --------
      • Set VariableSet AH_Hero = Archmage
      • Set VariableSet AH_Ability[1] = Blizzard
      • Set VariableSet AH_Ability[2] = Summon Water Elemental
      • Set VariableSet AH_Ability[3] = Brilliance Aura
      • Set VariableSet AH_Ability[4] = Mass Teleport
      • Trigger - Run Save to AH <gen> (ignoring conditions)
These Save/Load Triggers are used to Save the Abilities to the Hashtable and Load them from the Hashtable. I use the Hero's Id as the Parent in the Hashtable, and save the Abilities as the Child Keys from 1 to X. Total Abilities for your Hero is saved as 0.
  • Save to AH
    • Events
    • Conditions
    • Actions
      • -------- Set Hero Id --------
      • Custom script: set udg_AH_Integers[0] = udg_AH_Hero
      • For each (Integer AH_Loop) from 1 to 5, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AH_Ability[AH_Loop] Not equal to AH_None
            • Then - Actions
              • -------- Set Ability Id --------
              • Custom script: set udg_AH_Integers[udg_AH_Loop] = udg_AH_Ability[udg_AH_Loop]
              • -------- Abilities = 1 to X --------
              • Hashtable - Save AH_Integers[AH_Loop] as AH_Loop of AH_Integers[0] in AH_Hash.
              • -------- Total Abilities = 0 --------
              • Hashtable - Save AH_Loop as 0 of AH_Integers[0] in AH_Hash.
            • Else - Actions
      • -------- --------
      • -------- Set Default Values For Abilities --------
      • For each (Integer AH_Loop) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set VariableSet AH_Ability[AH_Loop] = AH_None
  • Load from AH
    • Events
    • Conditions
    • Actions
      • -------- Set Hero Id --------
      • Custom script: set udg_AH_Integers[0] = GetUnitTypeId(udg_AH_Unit)
      • -------- --------
      • -------- Set Total Abilities --------
      • Set VariableSet AH_TotalAbilities = (Load 0 of AH_Integers[0] from AH_Hash.)
      • -------- --------
      • -------- Set Hero Abilities --------
      • For each (Integer AH_Loop) from 1 to AH_TotalAbilities, do (Actions)
        • Loop - Actions
          • -------- Set Ability Id --------
          • Set VariableSet AH_Integers[AH_Loop] = (Load AH_Loop of AH_Integers[0] from AH_Hash.)
          • Custom script: set udg_AH_Ability[udg_AH_Loop] = udg_AH_Integers[udg_AH_Loop]
This is an example of putting the system to use.

Simply set AH_Unit = the Hero you created/want to learn skills for, then Run Load from AH (ignoring conditions).

This will set AH_Ability[1] to AH_Ability[X] as your Heroes Abilities.

You can then use Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[X] ) to learn one of these Abilities.

You can also reference AH_TotalAbilities to get how the total number of abilities your Hero has (so 4 in this case).
  • Example AH
    • Events
      • Player - Player 1 (Red) types a chat message containing paladin as An exact match
    • Conditions
    • Actions
      • Unit - Create 1 Paladin for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Hero - Set (Last created unit) Hero-level to 6, Hide level-up graphics
      • -------- --------
      • -------- Load your Hero's abilities setting them as AH_Ability[1] - AH_Ability[X] --------
      • -------- Also sets AH_TotalAbilities = The # of Abilities your Hero has --------
      • Set VariableSet AH_Unit = (Last created unit)
      • Trigger - Run Load from AH <gen> (ignoring conditions)
      • -------- --------
      • -------- Then you can learn the skills like so: --------
      • Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[1] )
      • Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[1] )
      • Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[1] )
      • Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[2] )
      • Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[3] )
      • Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_Ability[4] )

Edit: Added a new version with an example of how you could assign Random Skills taking into consideration Level Skip Requirement, Levels, and Hero Level. I'm not sure if it uses the most efficient method for restructuring a table but it works. And by restructuring I mean updating the table after removing elements from it (so if you remove table element #2, 3 becomes 2, and 4 becomes 3).
  • Example AH Random
    • Events
      • Player - Player 1 (Red) types a chat message containing paladin random as An exact match
    • Conditions
    • Actions
      • Unit - Create 1 Paladin for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Hero - Set (Last created unit) Hero-level to 6, Hide level-up graphics
      • -------- --------
      • -------- Load your Hero's abilities setting them as AH_Ability[1] - AH_Ability[X] --------
      • -------- Also sets AH_TotalAbilities = The # of Abilities your Hero has --------
      • Set VariableSet AH_Unit = (Last created unit)
      • Trigger - Run Load from AH <gen> (ignoring conditions)
      • -------- --------
      • -------- Then you can learn the skills like so: --------
      • -------- --------
      • -------- Learn Random Skills --------
      • Set VariableSet AH_RandomTotal = 0
      • Set VariableSet AH_Integers[1] = (Unspent skill points of AH_Unit)
      • -------- --------
      • -------- Create Temp Table --------
      • For each (Integer AH_Loop) from 1 to AH_TotalAbilities, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability: (Load AH_Loop of AH_Integers[0] in AH_Hash.)'s Integer Field: Required Level ('arlv')) Less than or equal to (Hero level of AH_Unit)
            • Then - Actions
              • Set VariableSet AH_RandomTotal = (AH_RandomTotal + 1)
              • Set VariableSet AH_RandomAbility[AH_RandomTotal] = AH_Ability[AH_Loop]
            • Else - Actions
      • -------- --------
      • -------- Loop until the Hero is out of Skill Points (Or it can't level anything else) --------
      • Custom script: loop
      • Custom script: exitwhen udg_AH_RandomTotal == 0 or udg_AH_Integers[1] == 0
      • -------- --------
      • -------- Get Random Ability --------
      • Set VariableSet AH_Integers[2] = (Random integer number between 1 and AH_RandomTotal)
      • -------- --------
      • -------- Learn Ability (Also save the before and after level of the learned skill to see if it actually increased in rank) --------
      • Set VariableSet AH_Integers[3] = (Level of AH_RandomAbility[AH_Integers[2]] for AH_Unit)
      • Custom script: call SelectHeroSkill( udg_AH_Unit, udg_AH_RandomAbility[udg_AH_Integers[2]] )
      • Set VariableSet AH_Integers[4] = (Level of AH_RandomAbility[AH_Integers[2]] for AH_Unit)
      • -------- --------
      • -------- Check If Ability Is Max Level OR If It Couldn't Be Learned (Remove it from the Table if either of these is True) --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of AH_RandomAbility[AH_Integers[2]] for AH_Unit) Equal to (Ability: (Unit: AH_Unit's Ability with Ability Code: AH_RandomAbility[AH_Integers[2]])'s Integer Field: Levels ('alev'))
        • Then - Actions
          • -------- Only restructure the Table if it's not the last Index --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AH_Integers[2] Not equal to AH_RandomTotal
            • Then - Actions
              • For each (Integer AH_Loop) from (AH_Integers[2] + 1) to AH_RandomTotal, do (Actions)
                • Loop - Actions
                  • Set VariableSet AH_RandomAbilityNew[(AH_Loop - 1)] = AH_RandomAbility[AH_Loop]
              • Set VariableSet AH_RandomTotal = (AH_RandomTotal - 1)
              • For each (Integer AH_Loop) from 1 to AH_RandomTotal, do (Actions)
                • Loop - Actions
                  • Set VariableSet AH_RandomAbility[AH_Loop] = AH_RandomAbilityNew[AH_Loop]
            • Else - Actions
              • Set VariableSet AH_RandomTotal = (AH_RandomTotal - 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AH_Integers[3] Equal to AH_Integers[4]
            • Then - Actions
              • -------- Only restructure the Table if it's not the last Index --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AH_Integers[2] Not equal to AH_RandomTotal
                • Then - Actions
                  • For each (Integer AH_Loop) from (AH_Integers[2] + 1) to AH_RandomTotal, do (Actions)
                    • Loop - Actions
                      • Set VariableSet AH_RandomAbilityNew[(AH_Loop - 1)] = AH_RandomAbility[AH_Loop]
                  • Set VariableSet AH_RandomTotal = (AH_RandomTotal - 1)
                  • For each (Integer AH_Loop) from 1 to AH_RandomTotal, do (Actions)
                    • Loop - Actions
                      • Set VariableSet AH_RandomAbility[AH_Loop] = AH_RandomAbilityNew[AH_Loop]
                • Else - Actions
                  • Set VariableSet AH_RandomTotal = (AH_RandomTotal - 1)
            • Else - Actions
      • -------- --------
      • -------- Update Skill Point Count --------
      • Set VariableSet AH_Integers[1] = (Unspent skill points of AH_Unit)
      • -------- --------
      • Custom script: endloop
 

Attachments

  • Hero Ability Hashtable 3.w3m
    21.4 KB · Views: 12
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
Yeah, I figured it could be used as a basic concept. Also, I uploaded v3 which is just a quick fix. I deleted an unwanted condition from a few of the triggers that I had been using for Copy + Paste reasons.

Each trigger's default Conditions block should be blank.
  • Conditions
I also updated the Setup trigger as I was referencing AH_None before setting it.
 
Status
Not open for further replies.
Top