Tag Archives: dota 2

Dota 2 items.txt/npc_abilities.txt to xml/json tool v1.1 (Updated 03-02-15)

UPDATE 03-02-15

  • Added support for npc_abilities.txt file

Here is a tool that I wrote because I needed a method to get all the latest items so I could display more details for matches for my main project. Tool is pretty straight forward, open and select your items.txt/npc_abilities.txt file (see vpk extract) and it will show you what it was able to parse.

parse the items.txt file to xml or even json!
parse the items.txt file to xml or even json!

If interested, you can save a copy in both json and XML format. I need to add comments into my source and modify a few things but I will upload that over to github and share link when ready.

PSA

I am looking for someone who enjoys designing user interfaces for both windows applications and web sites. If you are interested in making some cool things, please get in touch with me! This is something that I do on the side and mainly because I love the game so I have nothing to offer except show your work to as many people that I can.

Dota 2 SteamWebAPI C# .NET

Hello dear friends, since my first post on Reddit I have learned a lot!!! My code for the Dota 2 tool is now on github and I wanted to share some of the progress I have made since I have uploaded it there. The tool now supports these features:

  • GetMatchHistory
    • This provides the latest 100 matches with a lot of the information parsed and reformatted to make sense
  • GetHeroes
    • This method grabs the latest heroes
  • GetMatchDetails [WIP]
    • This method grabs an individual match detail including player information as well as build details

Here is a bit of the output for GetMatchDetails

and here is  a sample output of GetMatchHistory:

As of now, I am only storing this data in memory but once I complete most of the these methods, I will move onto the data store phase. Currently I am leaning towards Microsoft SQL but that might not be the best approach for a long term solution. My end goal would be to keep storing data and allowing our users to use this as a database…similar to DotaBuff but hoping I could keep it free.

Stay tuned for more guides in this series!

You can find the guides here:

If you wish to contribute or see what the code looks like, check out my project on GitHub

Dota 2 .Net C# Tool pt2

Welcome back! Today I will go over some code on how to get match details and also how to cleanup some of the text that we have. Assuming that you have been following along with the previous post, I will be using those classes and code in this part as well.

Let us first start by getting the latest matches, this will allow us to set the foundation for a later time when we want to query for a match in particular. Start by creating a class that will hold our match details

(classes were generated using json2csharp: http://json2csharp.com/)

Now that we have our class created, lets get a few other methods in place which are used at a later time.

Since heroes are being added at certain times of the year, I wanted to have a somewhat generic method to pull up names based off of there index number. Thsi is my way of doing just that, this method expects a list of heroes (see part 1 of this tutorial) and then it maps the hero found in a match to one in the list.

And here is the method to get the latest 500 matches

And here are some helper methods

Once you have all of these things in place, usage is:

That is it for part 2 of this guide in this series, next step for me is to go back and do a bunch of code cleanup before I start publishing more content.

ps. I wanted to give you guys some background about me, I am a engineer by trade and I work primarily in infrastructure management. All of my coding experience is self taught, I wish I could have gone to school for this because I feel like it might be my calling but I understand that I have a lot to learn. So with that being said, please take the advice/tips that are given here with a grain of salt and do some of your own research. One day I do hope to be a master in programming but even a master fails many many times. My goal is to work together with the people of the internet and create something beautiful out of this project but I understand that it will take time to get there. Good luck with the coding guys and drop by soon for the next iteration in this series!

 

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/