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

Allocate Skill Point via Variables

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
Is it possible to make a hero level up an ability with an "Ability" variable? I thought this might make my life easier for the AI in my map but it doesn't look like you can get them to level up the ability using the variable (for some reason).

Any workarounds?
 
You mean you want to store hero skill picks in a variable?
You can use an ability variable, and reference it using the jass version of hero learn skill.
Like this:

-------------------------------------------------
  • AISkillTree
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Custom script: call SelectHeroSkill( GetTriggerUnit(), udg_ComputerSkillTree[GetHeroLevel(GetTriggerUnit())] )
Where ComputerSkillTree is an array ability variable.

This, like 'Hero - Learn Skill', requires the hero to have a skill point to spend.

-------------------------------------------------
It is weird the GUI version does not accept variables.
 
Level 13
Joined
Jun 23, 2009
Messages
300
What you're asking is normally done inside .ai files, common.ai has a bunch of functions and variables that are used just for that, there is integer array skill that is used to store what skills a hero should learn by leveling up using their ID, then there is SetSkillArray(integer, integer) that is used to give the skill list you set up using skill to the first, second or third hero. The first integer is used to specify which hero it is (1,2,3) and the second integer is the hero ID.

Example using an Archmage:
JASS:
function SetSkills takes nothing returns nothing
   set skill[ 1] = 'AHbz' //Blizzard
   set skill[ 2] = 'AHab' //Brilliance Aura
   set skill[ 3] = 'AHwe' //Water Elemental
   set skill[ 4] = 'AHbz'
   set skill[ 5] = 'AHab'
   set skill[ 6] = 'AHmt' //Mass Teleport
   set skill[ 7] = 'AHwe'
   set skill[ 8] = 'AHbz'
   set skill[ 9] = 'AHab'
   set skill[10] = 'AHwe'

   call SetSkillArray(1, 'Hamg') //First hero, Archmage
endfunction
After calling the function I wrote above, the leveling is taken care of by another common.ai function, SkillArrays, that can be used in 3 ways, the simplest one is call SetHeroLevels(function SkillArrays).

The other ones are:
call StandardAI(function SkillArrays, function, function), where the second function sets gathering and building/upgrading for the AI and the third sets the attack patterns.
call CampaignAI(integer, function SkillArrays), where the first integer is the ID of the racial farm.

I'm not 100% sure you can use the variable and these functions outside of an ai file though. If that's the case or you want to do it in GUI/inside the trigger editor, The_Silent's method should work.

EDIT: Another thing to note about this method: it can also be adjusted to randomize skill gains and hero order for a potentially unlimited number of hero types (I can elaborate on that if you need), but it still assumes the ai will control at most 3 heroes so if that's not the case... nevermind this post.
 
Last edited:
Status
Not open for further replies.
Top