This example shows a relatively simple approach to adding custom hero abilities to heroes in-game.
This is especially useful for creating maps like Custom Hero Survival, Custom Hero Line Wars, etc.
Custom hero abilities can be added to heroes in-game, for example, through shops that sell abilities (a popular approach in battle.net custom games).
During the setup of the game, the option to add custom hero abilities is enabled using:
To generate a windwalk ability that can be added during game, use:
let customWindWalk = compiletime(new CustomHeroAbility(AbilityIds.windWalk))
To add the newly created windwalk ability to a hero during the game, use:
To remove the previously added ability from a hero during the game, use:
customWindWalk.remove(hero, slot, refund)
Attach scripts to custom hero abilities using:
customWindWalk.addTrigger(EVENT_PLAYER_UNIT_SPELL_EFFECT, () -> onWindWalk())
For a demonstration, download the map directly from the Hiveworkshop.
The Wurst code can be found here
To use the system in your map, import the package CustomHeroAbility in your Wurst project.
The package Setup is used for the demonstration map.
The system demonstrates the use of the following packages from the Wurst standard library: