-
Notifications
You must be signed in to change notification settings - Fork 15
How to develop a new hero
Bountysouce $100 reward - Awarded to Xinton - Congratulations! Read More
Introduction
The most crucial part of developing a new hero is how to adapt his skills into the FODA game system. This can be trivial, like the direct damage of Lina's ultimate (Laguna Blade) or really tricky, like Magnus ultimate (Reverse Polarity). The card turn based system implemented has the objective of keeping possible a real match with actual cards, a 10-sided dice, a paper and a pencil, so try to keep this in mind (in other words: keep the math simple).
Hero values are based on lvl 15, skill values are based on lvl 4, and ultimate values are based on lvl 2, which should reflect a mid/late game. The armor and magic resistance have been adapted to absolute damage reduction values in order to make damage calculation easier in a real match.
Once you are clear on how to implement all hero skills you are extremely advised to open an issue titled with the hero name and explaining how you intend to adapt his skills just to be sure your work will be quickly accepted. And I will get in touch with Dopatwo in order to make some real nice images for your hero cards!
Now it's time to write some actual code, you must know basic javascript and jQuery. That might sound hard but there are lots of free web courses out there (or just go to MDN). All static values (database) are stored in JSON files inside the game "client/json" folder. First edit heroes.json and include your hero and his attributes. All attack speed related bonus should be translated into damage bonus. This should be really straight forward and you here are some guides on how to get some reasonable starting numbers:
Damage = (Hero lvl 15 damage * 0.1) + ATS
ATS = (1 + ATS%) / BAT (avarage BAT = 1.7)
HP = Hero lvl 15 hp * 0.05
Mana = Hero lvl 15 mana * 0.005
Skills = All values based on skill lvl 4
Ults = All values based on ult lvl 2
Skill card count = 50/cooldown + 50/manacost
Now you must add the skills and their values in skills.json along with all buffs.
Next is the hard part, implement the skills in game. If you are following this carefully and explored a little the client directory, you should know by now that the skill should be coded in the skills directory.
A good way to learn how to code the skills is to read other heroes skills in order to understand the logic behind skills in DotaCard. Of course you might need methods and properties from other files and it might even be the case of creating new functions in order to be able to implement the new hero. But don't worry, if that's the case I will do all the hard work for you if you need it! But if there's no issue about your hero's skills and you have it all figured out, go on and finish one up all by yourself (I dare you!)
Here is an example to keep you going, Crystal Maiden - Frostbite (game.skills.cm.freeze):
game.skills.cm = {
// ...
freeze: {
cast: function (skill, source, target) { // Crystal Maiden is the cast source
var buff = source.addBuff(target, skill); // buffs added with addBuff will auto expire
target.addClass('rooted disarmed'); // addClass is a [jQuery](https://api.jquery.com/addclass/) method
target.on('turnend.cm-freeze', this.turnend); // attach turnend event - on is a [jQuery](https://api.jquery.com/on/) method
target.stopChanneling();
},
turnend: function (event, eventdata) { // the turn end event
var target = eventdata.target;
var buff = target.getBuff('cm-freeze');
var source = buff.data('source'); // Crystal Maiden is the buff source
if (target.hasBuff('cm-freeze')) {
source.damage(buff.data('dot'), target, buff.data('damage type'));
} else { // end of the buff effect
target.removeClass('rooted disarmed'); // removeClass is a [jQuery](https://api.jquery.com/removeClass/) method
target.off('turnend.cm-freeze'); // detach the event - off is a [jQuery](https://api.jquery.com/off/) method
}
}
},
// ...
}You can use node server.js to setup your localhost, and debug the game with your new hero after including the skill file script in the debug.html file at http://localhost:5000/debug.html and all changes will be applied after a simple browser reload. As soon as your code is done you should use the command grunt in the game root directory in order to bundle everything up and make some final tests at http://localhost:5000. I like to use Yez! to be able to run this commands from chrome developer tools but it can be done in a terminal/prompt as well.
Don't forget to take a break and just play!
If you think your hero have skills that will require extra methods, you should tell me in the corresponding hero's issue so I can give you some help. But if you are like me, and want to do it all by yourself, it really ain't that hard. In order to accomplish this, you will have to learn the available methods in the game javascript directory. Since this is a huge amount of data that contains all game logics, in order to make it easier and faster, here are the most important files for you to focus:
-
game.card, where you can find methods like
game.card.select,game.card.moveand ,game.card.discard; -
game.player and game.enemy, where you can find methods like
game.player.attack,game.player.castandgame.player.buyCard. -
game.map, where you can find methods like
game.map.getX,game.card.inRangeandgame.card.mirrorPosition; -
game.skill, where you can find methods like
game.skill.cast,game.skill.opponentsInRangeandgame.skill.summon;
I promise I'll write a full documentation soon... in the mean time, check out the Venge commit, it's a great example: https://github.com/rafaelcastrocouto/foda/commit/ce831d7e207e0aa83e6c484886c793ca4a2c3e5e
