Dota 2 Last Hit Exercises Steam Workshop ModOctober 2015|Tags: game, lua, mod, programming
About Dota 2
In the game Dota 2, a multiplayer action real time strategy game developed by valve, you need to land the killing blow on creeps (enemy soldier/footman-like units) in order to get gold. This gold is used to buy items for your hero to make him/her more powerful. The level/map of the game contains defense towers that do far more damage than your hero and attack the incoming enemy creep waves, making it hard to get last hits (the tower has higher damage, so it can kill the creep before you can), so my mod/map recreates these scenarios to let you practice them. It is a very important skill to have, distinguishing experienced from average players.
About the Mod / Custom Map
If you've ever played Starcraft or Warcraft 3, you've probably heard of custom maps, or basically user created levels/content/gameplay using the game's own tools and map maker. The mod has a user interface for viewing last hit accuracy and customizable options for the training exercises. The mod's description can be found at the workshop link here.
Video of how the mod/custom map plays:
How I Made It
Following some guides and examples, I made a simple map using the Hammer Editor (used for making maps in counter-strike / half-life) containing a tower and a lane where waves of allies / enemies will spawn. After learning a little bit of lua, I then used my Dota 2 knowledge to procedurally generate different scenarios of last hitting situations under the tower. The logic of creep spawning the mod is controlled by a finite state machine. Each time a wave is spawned, I vary the relative position of the creeps in the lane, the creeps position relative to each other, the number of creeps, the current health of each creep, and also the general 'type' of the creep wave. Everything combined gives you an accurate representation of last hitting under the tower and also a lot of replayability so that you simply aren't recognizing one pattern for last hitting.
The mod was originally created with unofficial tools created by the modding community. The old version of this project can be found on github here. After Valve released the Dota 2 workshop tools, I ported my code and added many new features.