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

BuilderHittable.as

Discussion in 'Modding Help' started by Dinberg, Jul 31, 2013.

  1. Dinberg

    Dinberg Catapult Fodder

    Messages:
    1
    Hi!

    I was looking at implementing some new block types for the builders. I set about making a wooden spike variant of the metal ones, but soon ran into a problem.

    I can build the wooden spikes fine (after adding them to BuilderInventory.as). However, I found I was unable to hit them to dismantle them. After some prodding around, I found BuilderHittable.as, which appears to hold a list by name of all the different blocks a builder or drill may demolish. Adding my wooden spikes to this list resolves the issue, and I can now strike the wooden spikes to dismantle them:

    Code:
    const string[] builder_alwayshit = {
        //handmade
        //"workbench",
        //"fireplace",
        //faketiles
        "spikes",
        "woodspikes", <-- had to add this part
        //buildings
        "factory",
        //"barracks",
        //"nursery",
        //"kitchen",
        //"storage",
        "tunnel",
        //"dorm",
        "building",
        //"research",
    };
    However, this system doesn't seem very mod friendly - it took a while to find out the file even existed. Further, it prevents modders from being able to create blocks in separate mod files, and selectively choose which to incorporate into the game unless they edit some files (BuilderInventory.as also prevents this, but that doesn't have an easy solution), as the overriding builder_alwayshit list in the mods folder must be altered every time a new block is added.

    Instead of this, would it be better to use the 'tag' system? Something like this.Tag("builder alwayshit") in each of the scripts that control the structures. In BuilderHittable.as, the BuilderAlwaysHit bool could be changed to return if the blob contains the above tag, rather than compare the name of the blob to the above list.

    What do people think? I've only just started modding kag so its very possible I've massively overlooked something, as I'm still learning how it all fits together. However, I think this change could make adding new blocks simpler.

    Cheers,
    D