1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

Read this first! The Total KAG Modders Guide

Discussion in 'Modding [KAG]' started by Verrazano, Jan 29, 2015.

Thread Status:
Not open for further replies.
  1. Verrazano

    Verrazano Flat Chested Haggy Old Souless Witchy Witch Witch THD Team Global Moderator Forum Moderator Tester
    1. Practitioners of War Extreme Revolution - POWER

    Messages:
    477
    So I hear you want to become a modder eh? Well it's no easy task, but that shouldn't scare you off. Writing code and programming takes a lot of patience and methodical work, but the rewards of others being able to have fun with your creation is high. The goal of this post is to help you find the resources you need to:
    • Find people that can help you.
    • Learn basic programming.
    • Understand the structure of KAG modding.
    • Good tools to use.
    • Locate helpful KAG modding tutorials.
    As a note this post should be regularly updated with links to new content.
    tl;dr: Click the links in the order they appear.

    Finding people that can help you - IRC
    Alright let's get started. I've found that one of the most upsetting things for modders is the amount of time they spend trying to find the answer to a question they have. Maybe you are debugging code. Or don't understand what a function in the KAG API does. Perhaps some lines in the base code are confusing and you don't know what they do. Many questions fledgling modders have may not have been answered on the forums. If they decide to post about their question it could take a while to get the solution they need. That's why we have a dedicated irc channel. #thd.modding on irc.quakenet.org. For those of you to lazy to use an irc client here is a webchat link: http://webchat.quakenet.org/?channels=thd.modding&uio=d4.
    Once on you're in the irc channel you might see some of the channel regulars: Verra ( @Verrazano ), ZeroZ30o ( @ZeroZ30o ), Skinney ( @Skinney ), Ferne ( @Fernegulus ) , cameron- ( @cameron1010 ). Feel free to bother any of us with you're questions. We are mostly always happy to help you guys out.
    If you happen to be on the irc channel and have question that has something like the following format. "Hey Verra, is there a function that does XYZ?". Please don't ask us about it. I created a bot a long time ago. If you've ever called for a guard in the main kag channel you'll be familar with her. Belagerung also serves as a modding help bot. You can use the command ".find xyz". Belagerung will promptly return with a list of possible functions that match xyz.

    Learning basic programming - C++ tutorials
    What's the next step in the learning process? Modding! ... No, it's learning. I've found that people who want to become modders often jump straight into KAG's code base with no knowledge of basic programming, angelscript or the structure of KAG modding. This to me seems like trying to solve a university level math problem while in your first year of secondary school. Staring at the code may eventually gain you some knowledge, but I feel it's much more important to build a base knowledge of it's working first.
    So how do I start learning? KAG uses a scripting language called Angelscript. It's style is heavily influenced by C++. There are many tutorials to programming in C++ my personal favorite to link to people is here: http://www.cplusplus.com/doc/tutorial/. Of course if you're goal is only to become a modder you don't need all of this tutorial. The most essential sections are. Basics of C++ and Program Structure. Another good tutorial you may want to look into if that is not enough can be found here: http://www.learncpp.com/.

    Understanding the structure of KAG modding - Blofiguleooks
    Theoretically at this point you could jump into scripting KAG and be some what ok. However I would recommend you learn about one more thing. The structure of KAG modding is not directly akin to the structure of a C++ program. It's more like writing a bunch of virtual classes and adding them to manager. In fact internally it's almost exactly that. As a quick overview here is my brief guide to the modding structure.
    • Blob - A blob is any object in the game. They have a physics body, scripts a sprite and some other less prominent data.
    • Blob Config - Essentially any config file (.cfg) found in the Entities folder is a blob config. It contains a list of data, size, sprites, animations, scripts, name, ect. This data is used to generate a type of blob. When you call server_CreateBlob("fishy", Vec2f(500, 500)) The game engine tries to figure out if it's loaded a config with "fishy" as the name variable. It then passes the info from the config to the Blob to create it.
    • Rules - The rules define how the game is played. It has scripts and manages players, teams, some object spawns and sometimes other stuff depending on how complex the game mode is. The scripts for Rules are defined in a "gamemode.cfg".
    • Hooks - A hook is how you the modder implements the logic for an object (Blob). They generally look like this onTick(CBlob@ this) or onSomething(CBlob@ this). There are many hooks with different types of data passed into them, but the main ones you have to worry about are the Blob hooks. When you create a hook the engine will pass many anonymous blobs through the hook as the this argument. Because of this creating logic that uses global variables as counters or vital info is very dangerous because it will be touched by any object that shares that hook.
    • Scripts - Scripts are the code files (.as). They may only contain at most 1 of each hook deceleration. Usually modders split logic for an entity in to multiple files i.e. ArcherAnim.as and ArcherLogic.as. In the Blob config you define what scripts the a Blob uses so remember that scripts are shared among many objects.
    The above is by no means a complete representation of the structure of KAG modding. If you want more information I have written a tutorial here: [tutorial link... when I finish it]. It will help you understand more about Angelscript and script structure.

    Some good tools to use - Just use sublime
    Once you've decided you are gonna start messing with the code. You will need a suitable text editor. Although you can edit Angelscript code in any text editor. It is highly recommend that you use one with syntax highlighting. This will help you reduce bugs before you try to run the code through the game. Here is a list of some decent editors that have syntax highlighting for C++ (Closest thing to Angelscript).

    Helpful KAG modding tutorials - learn moddin' and stuff

    Finally there are a lot of tough problems that need to be tackled when creating a mod for KAG. Here are some tutorials the will probably help you solve some of the more general problems you might encounter.

    [MORE SOON TO COME]
     
    Last edited: Mar 23, 2017
  2. FuzzyBlueBaron

    FuzzyBlueBaron Warm, Caring, Benign, Good and Kind Philanthrope Global Moderator Forum Moderator Donator Tester
    1. The Young Blood Collective - [YB]

    Messages:
    2,508
    >Last edited: Jul 24, 2015
    I demand this be enacted upon. Is there no justice in this world? :rektlord:
     
  3. Verrazano

    Verrazano Flat Chested Haggy Old Souless Witchy Witch Witch THD Team Global Moderator Forum Moderator Tester
    1. Practitioners of War Extreme Revolution - POWER

    Messages:
    477
  4. FuzzyBlueBaron

    FuzzyBlueBaron Warm, Caring, Benign, Good and Kind Philanthrope Global Moderator Forum Moderator Donator Tester
    1. The Young Blood Collective - [YB]

    Messages:
    2,508
    Oi! @Verrazano! I'm still waiting!

    Verraaaaaaaaaa!!! :rektlord:
     
Thread Status:
Not open for further replies.