Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
I'm assuming it's done by removing the wanted ability and then adding the new one, but that doesn't work since you can't add or remove an ability that a hero hasn't learned yet so simply, also all of the attributes of the ability such as it's level doesn't transfer over. I'm wondering how any of you guys would pull it off.
Before you remove it, get the level of the ability being removed then add the new ability and set it to the level of the removed ability?
If you can't remove an ability before a skill point is put in, then when your trigger fires, give your hero a skill point, have them use on the spell you want to remove etc.
As you can't add/remove unlearned hero abilities, Your best (or only) bet is using engineering update, though that method can be buggy. If new abilities are similar (target type, channelling, ...) to replaced ones, there shouldn't be problems.
If you want to change the abilities a hero learns dynamically (they lose learnable abilities or gain new ones), your best bet might be to screw the hero abilities all together and trigger your own hero ability learning system.
It's not as hard as it sounds--the advantage is you can swap out learnable abilities anytime anywhere, but you'll lose the traditional hero ability learning interface (the red cross with points).
Basically you make a data structure that is a wrapper around a hero unit, and has a list/array of the learnable abilities. You also keep track of how points a hero has gained in an integer, which is incremented each time a hero levels. You decrease the integer each time a player learns a new ability (costs 1 point to learn an ability) or levels one up. To make it so a hero can't learn the next level of an ability until they are lvl 3, 5, etc. there are several things you can do. You can make an array for each ability of integers where the ith member denotes the minimum hero level needed. e.g.
bash[0] = 1
bash[1] = 3
bash[2] = 5
So to learn level 3 bash, a hero needs to be at least level 5. Then they can put a skill point to learn it.
Finally, to interface with your custom/virtual ability learning menu, you can use a dialog and make each ability a button. Might sound tricky but it's quite easy if you've used dialogs before.
Now this will allow you to swap out learnable abilities or add new ones or remove them. Keep in mind you will be limited by your command card, unless you have a spell book ability to put the additional hero spells.
Here's a small sample to get you started, if this is a direction that you think makes sense
JASS:
library HeroStruct
globals
constant integer MAX_ABILITIES = 10 //arbitrary value really, can be changed
endglobals
struct Hero
//learnable ability is another struct you'll need to make
LearnableAbility array[MAX_ABILITIES]
integer points = 1 //keeps track of the total points; heroes by default start with 1 point
unit u //a handle on the hero we're managing
static method create takes unit u returns thistype
…
endmethod
…
…
endstruct
and a library for abilities
JASS:
library LearnableAbilityStruct
globals
endglobals
struct LearnableAbility
integer abilityId //the raw code of the ability in question
integer array levelRequirements
//the ith member denotes the minimum hero lvl to learn the ability
//at the ith level
static method create takes integer abilityId returns thistype
…
endmethod
…
method learn takes Hero hero returns nothing
//code here to add the ability to the hero
...
endmethod
method levelUp takes Hero hero returns nothing
//sets the ability to the next level
//you need to check outside this method if the hero is at the requisite level
…
endmethod
endstruct
endlibrary
These aren't complete by any means (don't copy and paste) but just ideas if you really want a powerful, flexible, custom hero ability learning system.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.