Tuesday, September 1, 2015

Dota 2 Workshop Tools modding tutorial part 2. (starting scripting)

This part of the tutorial is about how to actually edit the script of your Dota 2 mod/addon


1. Getting an editor

We'll need a decent editor - I would recommend using the program Sublime Text.


This is the tutorial I used to install Sublime Text:

https://moddota.com/forums/discussion/135/beginners-guide-to-dota-scripting



2. Opening addon_game_mode.lua

When we built the map in the previous tutorial it created 2 directories for our project.

C:\Program Files (x86)\Steam\steamapps\common\dota 2 beta\game\dota_addons\d2tutorial\
and
C:\Program Files (x86)\Steam\steamapps\common\dota 2 beta\content\dota_addons\d2tutorial\

We're going to use the game directory because this is where you edit the scripts

The file we're going to edit is addon_game_mode.lua. (was created automatically)

it should be located in
...\dota 2 beta\game\dota_addons\d2tutorial\scripts\vscripts


3. Actually scripting guys!
3.1
This is what you should see:

3.2
Delete this part (useless for us)



3.3
Add this line





What this line does is checking with the game when a player picked an hero .

this part ("dota_player_pick_hero") is the specific event, Dota has many events you can use to build your mod .

List of the events
https://developer.valvesoftware.com/wiki/Dota_2_Workshop_Tools/Scripting/Built-In_Engine_Events

this part (CAddonTemplateGameMode, "OnNPCSpawned") determins the name of the function that will run when the event happens

3.4
Lets add the function that level up the hero when he spawns


















Save the file ...

4. Lets see how it works!

In the Asset Browser open the console. (or press ~)


to re load the scrip we just wrote type in the console:
script_reload

and then to load the map we built before type:
dota_launch_custom_game d2tutorial d2map



Now it should load the map in the game. start the game like a normal lobby and pick a hero.



to see the console type ~ 


Dota 2 Workshop Tools modding tutorial part 1. (2015)

This tutorial will show how to create a simple Dota 2 mod that makes every hero that loads level 25 and all the skills are leveled up.

I am no professional modder, I only started learning this yesterday. but the lack of tutorials on this subject has led me to make me this guide .

I will focus on the scripting side because there are plenty of tutorials on level designing . I will not use barebones (a tool that helps with scripting) becuase I want to make this more simple and if you follow this tutorial you'll know how to work with barebones. if you want to learn how to use barebones use this tutorial, it helped me a lot.

Lets go
  
1. Download Dota 2 Reborn. this will allow you to run Dota 2 Workshop tools. 



2. 

Create an empty addon (1)
name it d2tutorial (2)
make sure its default and selected and launch it (3, 4)

3.
on this screen you can select wich map your mod will be on. we will use the regular dota map
type in dota in the search bar
double click dota.vmap

this will load the map in the Hammer tool

4.
save the map (first image)
and build it (second image)





the build should take some time, you'll know its done when the map is loaded in the dota2 client that it opened automatically earlier.

I'm not really going into details because these steps are not really important for this tutorial.
OK. now we have the addon ready for editing.

PART 2 - SCRIPTING