1. 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

Some questions regarding entities

Discussion in 'Modding Help' started by Vermilicious, Dec 30, 2014.

  1. Vermilicious

    Vermilicious Ballista Bolt Thrower

    Messages:
    232
    Okay, so I've started looking a bit into entities in KAG. There are a couple of things that are a bit confusing. I've intentionally not strayed much into KAG modding before because I immediately saw how things function was difficult to grasp and not well documented. I do have programming background. I hope someone can shed some light on this topic for me.

    I understand from comments inside some of the .cfg files that $ represents strings and @ arrays. I'm confused as to why other lines have types asociated with them, such as u8 and f32. Is this just inconsistencies in type naming? I mean, why have some "obscure" symbols for strings and arrays if you need other type names anyway?

    However, these data type semantics reminds me more of a script than a config file. Why require type names for simple config values?

    Also, what values are really available to be set? Can I look them up somewhere?

    Especially the animation parameter naming convention baffles me. Is for example "sprite_animation_walk_name" a pre-defined parameter or is it referred as input in a script somewhere?

    These config files typically refer to several script files. What is the difference between "@$scripts" and for example "@$movement_scripts"? Why isn't there a "@$brain_scripts"? Why are certain scripts referred several times in the same config file? How exactly are these scripts handled - are they pasted in, are they called immidiately, are they called at a certain time, or what?

    When there are separate scripts for movement and sprites for example, why would both scripts have onInit with CBlob parameter? Aren't their jobs supposed to be different? Is it really necessary to split the scripts like this anyway? I mean, does this particular split make sense in all cases, and should this therefore be "forced"?

    Those are the things that come to mind right away. I don't have very high hopes for good input on this, but I thought it was worth a shot. If I don't get any further here, I'm not sure if I want to invest any more time into it, basically. Sigh.

    (I'm not typically one to advocate the overuse of class-based modularity and inheritance, but the chosen approach has me puzzled. I also think there's a lot of redundant code in many of these files. I think it would be a lot "cleaner" to use some sort of inheritance like was used for rule cores and respawn systems.)
     
    Last edited: Dec 30, 2014
  2. Fernegulus

    Fernegulus Bison Rider

    Messages:
    400
    Eh just
    1. get on #kag.modding
    2. start actually coding
    3. get used to it
    4. get to know where are certain things used
    5. profit
     
  3. Vermilicious

    Vermilicious Ballista Bolt Thrower

    Messages:
    232
    Just diving into it is a valid approach, and I did try that. However, I have limits to the amount of time I want to spend on something so unrewarding as making a small mod for an already narrow game. Also, if doing so demands "getting used to" difficult and or annoying patterns and systems, I feel even more reluctant.

    Anyway, you didn't really help much.
     
    Blubahub likes this.
  4. Fernegulus

    Fernegulus Bison Rider

    Messages:
    400
    Well I have no idea why do you even start with that kind of attitude
     
    norill likes this.
  5. Geti

    Geti Please avoid PMing me (poke a mod instead) THD Team Administrator Global Moderator

    Messages:
    3,730
    Welcome to games programming, where everything is either incredibly verbose or ad-hoc, with some cryptic spice thrown on top. Enjoy your stay.

    Before I continue - the entity config system is really one of the more cryptic parts of the engine. It's been around since before KAG existed, which should give you some idea of why it's so crusty.

    u8 - 8 bit unsigned int
    f32 - 32 bit float
    and so on.
    $ and @ are used because MM hates typing, presumably.
    Reminds a little of perl/php-like sigils, which is an extra layer of confusion if you have that kind of background.

    The type prefixes are required in blob configs because they aren't sent to clients as whole config files (kilobytes in size), they are serialised to a bitstream for a compact representation over the net. This has been in place long, long, long before modding was an intended use for these.

    This is why the order matters 100%. You cannot modify the order of any of the variables in a blob config, other than completely removing certain components (replacing their factory with the empty string)

    Anything that fits into the given format. I need more info on what property you're interested in if I'm going to help more here. The order fits, the name doesn't matter (other than the type)

    Doesn't really matter as long as the types are right (same as literally everything else). Making it consistent with the value you assigned the animation is convention though. The animation section (as you've probably noticed) starts and ends with "magic" values.

    there is a brain_scripts (though again, the name doesn't technically matter) - the object in question must have a brain component though. Have a look at the animal configs (sharks and fish are better examples than the wisent, which is a hacky mess).

    Scripts are attached to the component in question, or the blob itself, and then specific hooks are looked up by name and signature and called at appropriate times (onTick of the correct type every update, onInit on initialisation of the object, onHit when hit by something, etc). It's a little more complicated than that for performance reasons but that's the interface.

    I'll deal with multiples of the same script below.

    Scripts are called differently depending on what they're attached to - a script with void onInit(CBlob@ this) can be attached to whatever you like, but that hook will only be called when the script is attached to blobs, on intialisation. Similarly for (eg) void onInit(CMovement@ this) in a movement scripts list.

    The script organisation is ad hoc at best. Most of the splitting is likely due to the file hitting some critical mass where it became annoying to work with.

    Nothing is forced other than that you use at least one of those hooks appropriately, or your code will never be run.


    NOTE: config files themselves (eg the rules configs, and kaggen map generator files) are indexed by name and do have default values and aren't order-dependent. Only the blob configs are serialised to a bitstream based on naming patterns and are subject to all of these "scary" rules.

    https://doc.kag2d.com <- hit this up, its ever-slowly-expanding.

    Honestly inheritance would make this even more cancerous, partly due to the way reloading code in angelscript works, and partly due to OOP being shit for games. To make reloading work for shared class inheritance we'd have to nuke the entire script engine and recompile everything every time any file changed, making iteration no fun at all. An inheritance based approach would not make sense in 99% of the code either, as most of the functionality is disparate. If you really want you can think of each script as an extension on top of the existing component interface, but with the ability to mix and match different extensions as you build an object out of a handful of scripts.

    What's going on in KAG is technically a half-baked component oriented/entity component system approach. We're well aware that it's not perfect by any stretch of the imagination, but we're also not going to rewrite the game or engine because of 20:20 hindsight, as the game is "done". The engine provides a fully networked, scriptable game system with everything you need to build any top down or sidescrolling 2d game, and the backbone required to go further than that.

    You might actually have to (gasp) do some work to get anywhere with it, but we're not interested in facilitating lazy modders anyway.
     
  6. Vermilicious

    Vermilicious Ballista Bolt Thrower

    Messages:
    232
    You purposely didn't take any standpoint to my actual questions, while at the same time telling me to basically just stop complaining and get my hands dirty, like my troubles weren't relevant enough. What useful thing you provided was to mention an IRC channel (which I for different reasons think isn't the ideal place). I did not mean anything personal, but you did in fact go against the rules of this forum; replying without anything useful to say.

    ---

    Thank you for taking the time, Geti. I think I got a much better understanding now.

    I think I understand where you're coming from, and that it's fair enough not to do any major rework on it. I think there's quite some distance between being a current KAG modder and a "lazy" modder though.

    I mean, I get it; when you are "modding" you'll have to adapt. However, there's a certain threshold where the technical challenges just simply becomes hindrances in the way of great ideas. I loved KAG the moment I saw a gameplay video of it, and after trying the game for a while, lots of cool ideas popped into my head (and other people's heads). Don't take this the wrong way, but really, those ideas were never really considered good enough to make it into the official game. Fortunately, you did at some point open up for modding, which I am grateful for. However, I think the barrier is a bit high.

    I think that, in addition to the fact that players are leaving the game (be it of boredom or annoyance at changes made), is why we haven't seen a lot of good mods for KAG. The most radical one (Shipwrecked?) was an official proof-of-modding (I wish the time had been spent on other things). The other more successful and noticeable ones are the zombie mod and roleplay mod. The zombie mod is trying to bring back a mode that was cut from Classic, so it's not that "new" or "creative". Aphelion's done some cool stuff with his Roleplay mod though; much credit to him, but even he uses as many official assets as possible, and has mentioned technical limits hindering some of his ideas.

    I just mean that there hasn't been any really great mods. Apart from the relatively small player base with an even smaller quantity of people with the skill and will to mod (which is the primary reason of course), is that due to people being "lazy", or just because it's hard to? (Food for thought)
     
    Last edited: Dec 31, 2014
  7. Geti

    Geti Please avoid PMing me (poke a mod instead) THD Team Administrator Global Moderator

    Messages:
    3,730
    I feel like the "technical challenges" in modding KAG compared to modding, say, Quake are far, far more trivial.

    Modding in KAG is "hard" because you're writing code, and writing code isn't especially easy. There's not much magic in between you and the game engine, once you understand how to hook everything up - the only way we could give more direct access would essentially be providing an official mechanism for injecting native code into user's computers, something we aren't exactly excited about.

    We could make things "easier" by obscuring access to the internals - ie providing something akin to classic modding where you just fiddle with config variables and have a grand old time until you need some new functionality, which you have to provide by hacking the binaries (again, as is the case in classic modding).

    Honestly, I don't see the attraction at all. I feel that resistance to the "write code" approach is, at it's core, laziness or unwillingness to learn. This is coming from actively modding cortex command; a game that had a very active modding community despite having an obtuse, often underdocumented, piecemeal modding system for the majority of its life - I and others struggled with it for years before getting interested in standalone game development.

    Those that have earnestly applied themselves (@Skinney, @norill, @Aphelion3371, @Strathos, heck, even @AsuMagic ) have generally had a genuinely hard time only when there's something that needs to be added engine-side that we're not providing, and we've been as accommodating as we can, there.

    Feel free to suggest concrete ways we could improve the modding experience without hindering freedom to implement whatever you like; our current plans are largely limited to improvements to documentation and the way code can interact with the tilemap.
     
    LightTab2, Fernegulus and Asu like this.
  8. Fernegulus

    Fernegulus Bison Rider

    Messages:
    400
    good that you're aware
    now go do the tile hooks