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

[JASS] Replace hero abilities via triggers/code without replacing the unit type

Status
Not open for further replies.
Level 25
Joined
Feb 2, 2006
Messages
1,689
Hi,
is it possible to replace hero abilities via code without replacing the unit type.
I do not want to use two unit types since I would like the player to freely select any hero abilities he wants to.
Somewhere in a forum somebody posted that you can remove hero abilities by skilling them to the maximum level and then removing them.
Something like:

JASS:
function RemoveHeroAbility takes unit hero, integer abilityId returns nothing
      local integer skillPoints = GetHeroSkillPoints(hero)
      local integer additionalSkillPoints = 100 - GetUnitAbilityLevel(hero, abilityId)
      local integer i
      call HeroAddSkillPoints(hero, additionalSkillPoints)
      set i = 0
      loop
            exitwhen (i == additionalSkillPoints)
            call LearnHeroSkill(hero, abilityId)
            set i = i + 1
      endloop
      call UnitRemoveAbility(hero, abilityId)
      call SetHeroSkillPoints(hero, additionalSkillPoints)
endfunction

I am not sure it really works.
Is it even possible to replace the hero ability? Are there some maps out there which allow you to freely choose your hero abilities?
In my map I register all hero abilities per unit type, so I know which abilities a hero has by default, to remove them.
Is there an easier way to get the hero abilities without prestoring them in some way?
 
Level 39
Joined
Feb 27, 2007
Messages
5,014
Is there an easier way to get the hero abilities without prestoring them in some way?
No. If your abilities all strictly follow the default custom ability format of A000, A001, A002, etc. then this snippet might work for you: List Unit Abilities
I am not sure it really works.
It does not. The ability will remain for training (starting again at level 1) from the hero skills menu. Even if you use UnitMakeAbilityPermanent(..., false) on the ability to un-permanent it. You could remove the ability from the hero and then disable that ability for that unit, which would make it unable to level up that ability any more... but it wouldn't replace it with anything.

Basically, you have to abuse Engineering Upgrade to replace hero abilities and keep them levelable (Adding To Hero Skills Menu). Or keep your 'levelable' hero abilities as "level up ability 1", "level up ability 2", etc. and then manually increment the real ability levels with triggers whenever a player levels up any of these dummy increment abilities.
 
Level 25
Joined
Feb 2, 2006
Messages
1,689
Does this mean I have to create a Tinker ability for every X - Y replacement of a hero ability?!
There is no way to just replace any hero ability with any other one?
I don't want to create X * Y tinker hero abilities.

A custom skill menu will not give the hero the abilities right? Only if I add custom buttons to cast them (if this is what you mean)? How can I cast the actual hero ability with a custom skill menu?
I still want to use Warcraft's hero abilities.
 
Level 18
Joined
Oct 17, 2012
Messages
821
The custom skill menu just adds hero abilities to the unit's command card and level them up via clicking custom frame buttons. So, the custom skill menu has nothing to do with how the abilities are cast or how they are displayed on the unit and to the player.

This, however, won't make getting the hero abilities any easier. You will still have to register the hero abilities or take advantage of the resource suggested by Pyrogasm.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,014
Sorry just noticed I linked the wrong thing before. Meant to link these threads which might be helpful (they also address EU being bugged in recent-ish patches):

 
Level 25
Joined
Feb 2, 2006
Messages
1,689
If the Engineering Upgrade is the only possibility to remove/add/replace hero abilities I will have to create too many variations of it since it requires a source hero ability as well as a target hero ability.
I want to replace ANY hero ability in my map so the player can reskill any hero as he/she would like to.

In my other map The Power of Fire: Talras 1.1 I have created a custom skill system where every skill is based on a unit ability and not a hero ability. With unit abilities it is no issue to replace them.
However, I do not want to use the same system and recreate all hero abilities for my other map now.

If the Engineering upgrade is the only way I guess I will just do not provide reskilling hero abilities but repicking heroes instead which somehow limits the combinations of hero abilities a bit.
 
Prior to the 1.32 bugs, the Engineering Upgrade solution allowed arbitrarily customizing the hero as long as you did the customizable before any hero skills were learned. As I understand it, if I take a hero with Storm Bolt and give him an engineering upgrade to turn it into a Flame Strike, then the hero will have a Storm Bolt behavior attached to the Flame Strike data settings. So the mana cost would be the flame strike mana cost, and the icon would say Flame Strike, but if you managed to cast the skill it would be a single-target stun skill.

This is obviously not desirable for what you're describing, but what I recall seeing was that if we add the engineering upgrade to the hero to convert Storm Bolt into Flame Strike before the hero learns the skill, then at the moment that the hero learns the skill and clicks "Flame Strike" in the skills menu, the game engine will actually add the Flame Strike behavior to the hero as a skill. And then it would be Flame Strike in every way, and work as expected.

Based on this, the arbitrarily customizable hero systems when I was younger years ago were always created in this manner. All heroes in the map had the same five skills copied from Channel, and they were named Skill 1, Skill 2, Skill 3, Skill 4, and Ultimate Skill -- or whatever. Obviously if you only want 4 skills like the melee heroes then this is even easier.

Then, prior to the player being allowed to select their hero and learn these skills, some multiboard or other system was used that allowed the players to pick of each their skills. So the extra workload per ability was just 1 engineering upgrade corresponding to that ability. Also, all the skills in slot 1 could not be used as Slot 2 skills (since doing that would've required more engineering upgrade ability copies and be crazy).

It was certainly a functional system, but the on 1.32 because of the skin system changing how this stuff works even the Tinker demolish tooltip is wrong in melee. Engineering upgrade is just broken on 1.32, so all of these customizable hero maps are most likely also broken although I'm not sure if I tested them.

If your map requires that you can just pick abilities arbitrarily, like any 3 abilities in any order for the non-ultimate skill (and not "picking a slot 1 skill" or "picking a slot 2 skill"), then yes making 3 engineering upgrades per skill would be annoying.

I thought in one of the new native lists I might have seen a native for just literally adding hero skills on 1.32. Is that not the case?
(Edit: nevermind I don't see a native like that in a quick search unless I missed it)
 
Level 25
Joined
Feb 2, 2006
Messages
1,689
Okay so if I would have used dummy hero skills, it would have always been the same 4-5 hero abilities now I get it. So I just would have need n abilities per slot but it would still be lot of work and since you mention a bug now I think I won't do that.
Maybe if you can change the icon positions via native it would work this way for any slot?

About the new natives, maybe I do not have the latest list of natives but I can only find natives like:
JASS:
native BlzUnitHideAbility                          takes unit whichUnit, integer abilId, boolean flag returns nothing
native BlzUnitDisableAbility                       takes unit whichUnit, integer abilId, boolean flag, boolean hideUI returns nothing

native BlzGetUnitAbility                           takes unit whichUnit, integer abilId returns ability
native BlzGetUnitAbilityByIndex                    takes unit whichUnit, integer index returns ability
 
Status
Not open for further replies.
Top