Hero Starts Game With Ability Learned
Have Barebones installed. If you don't know what that is or need some help, click here.
You have a hero that has an ability you would like them to have already learned when they spawn or are created. Prelearned.
You notice that none of the ability 'Behaviors' are able to do this...(why valve?)
Solution and Example:
Have the game check to see if your hero has the particular ability you want auto leveled and have it set the level to one(or whatever you want it to be).
Navigate to: "C:\Program Files (x86)\Steam\steamapps\common\dota 2 beta\game\dota_addons\"Your Addon Name"\scripts\vscripts" and open the 'gamemode.lua file, look for the following section:
Now paste the following in beneath it:
if hero:HasAbility("ability_name") then
Essentially, it checks the abilities of your heroes when they spawn into the game, looking for the specific one you mention in the first parentheses, then if it can find it, it will set the level to the number you choose.
Notes: This might seem like a silly tutorial to post, but honestly this took me some time to figure out, anything I struggle with, others are bound to run into the same issue. This tutorial is not for the veteran modder, it's for newbs like me who are trying to learn but do best with examples.
If my code is wrong or could be better, or someone knows a better solution, I am happy to learn it if you'll share it. :) Thanks!