Dota 2 .Net C# Tool pt1

Hello everybody!

Not too long ago I started writing up my own custom methods using Steam Dota 2 API to obtain match details. My end goal is to calculate who has the best ratio between all of my friends who play this game, so far I’ve written up most the logic and then something crazy happened, I lost all of my code 🙁

No worries! This gives me a chance to share the code as I write it…from the beginning 🙂

I will be programming this in C# using Visual Studio 2012 as my coding environment, I’m going to assume you already know how to create a new project in VS2012 (if not, check out this link)

Ok, now on to the fun part…lets start off by getting just the hero data, such as name/ID/moves.

We will need a couple of things initially that are crucial in order for us to fetch the data:

  1. Steam API key
  2. Particular URL for data that we are grabbing, in this example we will be using: https://api.steampowered.com/IEconDOTA2_570/GetHeroes/v0001/?key=
  3. A object class to fill up with all of the info so we can enumerate through it
  4. Newtonsoft.Json reference to work with json response

Lets begin!

Create a new project and add a new class, I am calling mine “HeroesClass”.

Now that are class is ready for data, lets start writing up code that will get us to where want to go. What I did is made some global variables for my API key and URL which I could call from anywhere, that way I don’t have to worry too much about always providing input parameters for my methods.

BUT WAIT, ARN’T GLOBAL VARIABLES A BAD IDEA?!?!?! (thanks redditors!)

I think some global variables have there place, in this scenario the API key never changes so I opted to make it global and assign it to variable name API. A bad example of using a global variable would be a match ID, mainly because that changes from match to match and if I was to run a bunch of threads for different matches, it would give me duplicate data depending on what the “matchid” variable was holding during time of thread execution…..

The below method will get a list of all the current heroes and return you an object that you could enumerate through.

And this is how you would use it…

GetHeroes enumerable object

Thats it! E Z GAME

Next time, we will clean up the names and also obtain hero moves. Stay tuned

Find this post on Reddit

https://www.reddit.com/r/DotA2/comments/2vt1zb/programming_for_dota_2_in_c_part_1/

 

AutoIP Config

Main Screen

I wrote up this tool because I was tired of bringing up CMD prompt and doing an ipconfig /all. The program will loop through all of your active network interfaces and provide you an up to date snapshot of your current settings.

It didn’t take me long to reach my original goal so I decided to add more features to it such as troubleshooting scenarios that involve interface gateway and DNS resolution.

Automatically convert DHCP assigned address to Static

 

The software also lets you convert a DHCP assigned IP address to static without you having to remember all the settings!

 

 

 

For those interested, this tool queries WMI to gather all of this information. I will soon start posting more code examples and even complete source code.

VisusTotal Scan results