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

Blocks that aren't blobs - TRENCH RUN KEY IF ANYONE MANAGES TO GET IT TO WORK

Discussion in 'Requests' started by bunnie, Jul 18, 2016.

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

    bunnie Haxor Tester

    Messages:
    1,319
    I'm wondering if anyone ever got to making a proper BLOCK that isn't a fake one (not a blob). i'd like one that you can place, just a new look to stone block for example. (Look into Example New Block in Mods/ or something like that)

    Also, i'd like to add it to builder menu.

    If you will make one then please post one and i will praise u and make u VIP on my servers or something

    Also if you will do a good job and i will be able to make lots of blocks like that, i'll give you one trench run key
     
  2. bunnie

    bunnie Haxor Tester

    Messages:
    1,319
    Last edited: Jul 19, 2016
  3. Geti

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

    Messages:
    3,730
    You missed the guy who's been actually doing this, @8x - its fiddly stuff, and TR makes it simpler by "removing" all the vanilla blocks and starting fresh, but I believe 8x's mod has custom tiles and vanilla ones, so he's probably the guy to ask.
     
    bunnie, JaytleBee and PUNK123 like this.
  4. Eluded

    Eluded Haxor Official Server Admin

    Messages:
    132
    I know how to do this by coding the tile as a blob and have an example of that I can give you. There doesn't seem to be any disadvantage in doing so apart from maybe efficiency since I guess the engine is optimized in some way for tiles. It can snap to the game grid and behave exactly like a regular tile.
    I had a go a while ago at coding in an actual tile and wasn't able to work out how to do it but it is an interesting challenge.
     
    bunnie likes this.
  5. Geti

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

    Messages:
    3,730
    Blobs collide a bit differently but can have logic.
    Tiles use tile collision and can affect lighting properly. Attaching logic to them requires a lot of extra code.
    Basically for something dynamic (doors etc) a blob is the way to go but if you just want coloured floor or something else en masse then a tile would be better - you dont want 10000 blobs just to fill a 100x100 area solid.
     
    bunnie likes this.
  6. bunnie

    bunnie Haxor Tester

    Messages:
    1,319
    I don't want blobs. They're annoying and buggy. It'd be great if you would figure out how to make a true block, though.
    --- Double Post Merged, Jul 19, 2016, Original Post Date: Jul 19, 2016 ---
    Also, one more question - Would it be possible to make 2x1 BLOCKS? (not blobs). Or for anything that isn't 1x1 (8x8), I'll have to make blobs?
     
  7. Geti

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

    Messages:
    3,730
    You could do it by changing the hitter code and having custom tile destruction logic (so when you hit one tile it damages the "other half" - but no, 2x1 tiles are not supported by the tilemap "natively" - the whole point of a tilemap is that it just renders simply based on whatever is in each tile, so you dont need any special logic to look up if it's a 2x1 tile and do more clever things. Those systems unfortunately have to be built on top (or as blobs) to keep it fast.
     
    bunnie likes this.
  8. Frikman

    Frikman Bison Rider

    Messages:
    162
    I'm not sure how to make new "true" blocks, but if you manage to get them to work and want to add them to the builder's inventory you need the edit BuilderInventory.as and CommonBuilderBlocks.as to get them to be chooseable. On the first file you'll want to search to the following line
    Code:
    Vec2f MENU_SIZE(3, 5);
    The first number (3) determines how much horizontal space the builder has on his inventory, the second number (5) is the vertical space. You'll want to edit this values if you want new blocks to have a space on the inventory.

    On the 2nd file you'll want to search this kind of lines
    Code:
        {
            BuildBlock b(CMap::tile_castle, "stone_block", "$stone_block$", "Stone Block\nBasic building block");
            AddRequirement(b.reqs, "blob", "mat_stone", "Stone", 10);
            blocks[0].push_back(b);
        }
        {
            BuildBlock b(0, "team_bridge", "$team_bridge$", "Trap Bridge\nEnemies fall through this.");
            AddRequirement(b.reqs, "blob", "mat_wood", "Wood", 20);
            blocks[0].push_back(b);
        }
    
    These lines determine the kind of block that will appear on the builder's inventory. The first one is a vanilla stone block for example (it's requirements are on the 2nd line), the second one is a modded trap bridge. I don't know that much about modding so this is as far as my assitance can go, hope it helps c:
     
    bunnie likes this.
  9. Pirate-Rob

    Pirate-Rob Haxor Staff Alumni Tester

    Messages:
    270
    I've tried doing this like 3-5 times already, and only managed to get it working once. I might try again, seeing as learning how to do it proper will be quite helpful.
     
    bunnie and PUNK123 like this.
  10. 8x

    8x Elimination Et Choix Traduisant la Realité Forum Moderator Staff Alumni Tester
    1. The Young Blood Collective - [YB]

    Messages:
    1,325
    Questions are:
    what function do you want the block to have? cosmetic only? will it be solid or background? do you want it to be destructible by explosives? can it be digged by builders or knights? what resources do you need for laying it? how much support will it offer to tiles above it?

    What I managed to do is cosmetic tiles, none of them can be placeable via builder menu (I never tried to implement it at the menu however) or give you resources when you dig, hell they're actually undestructible somehow :D. These also are a bit fishy in terms of support, sometimes they will fall if they're standing on a specific tile-like blob. @Osmal might help here as well

    For TWK I did solid blocks and non solid blocks, both in background and frontground. For 2x2 or higher tiles you can always simply make 4 or more different tiles and auto-tile them when you build them up (something like old cata building in Classic). For this, as I wasn't able to make the autotiling for the map loaders, I put pixels one by one at the maps (yeah, it's a torture, but I liked it).

    A great thing (or simply good :>) for modders would be the possibility of copy/paste vanilla tiles and make their "support value - resource count - damage count - tile flags" easily moddable.

    Moreover:
    The CustomBlock example from MM is a bit misleading. I made this thread to clarify things: https://forum.thd.vg/threads/implementing-custom-tiles-not-blobs-at-the-map-loaders.25694/
     
    bunnie and PUNK123 like this.
  11. bunnie

    bunnie Haxor Tester

    Messages:
    1,319
    Yeah, i've added things to builder menu already, but I have no idea where do you get CMap::tile_castle from.


    I want cosmetic both solid and background blocks, digged by builders, destructible by explosives - doesn't matter, and 0 resources. Can you even change support-related things? If yes, then as much as wood. Thanks for that tutorial, will look into it. ::)::wink:
     
  12. Pirate-Rob

    Pirate-Rob Haxor Staff Alumni Tester

    Messages:
    270
    Go to the manual folder, there'll be a file called enums there. In there is a list of all things like CMap::tile_castle.
     
  13. Eluded

    Eluded Haxor Official Server Admin

    Messages:
    132
    @Geti while you're here are you able to say whether/where the 'health' of tiles is defined in the code? For example if I wanted to make wooden blocks take twice as long to destroy what would I change?
     
  14. Geti

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

    Messages:
    3,730
    Not possible currently. The health of tiles is totally misleading. The amount of hits it can take is defined by how many frames of damage we had.

    It's possible to store damage externally in a custom tileset implementation but its not done in vanilla at all.

    @8x and other interested parties
    Re: would be nice to copy-paste vanilla tiles - the vanilla tiles are "defined" in a ~1300 line cpp file of spaghetti logic. The code at the moment basically checks the following:
    • If vanilla tiles are completely turned off - if so it goes straight to script hooks
    • If vanilla tiles are on, if the tile is <=255, use legacy hooks
    • else use script hooks
    The most important script hooks available:
    Code:
    //when the hitter functions are called - damage is passed in but storing it is fiddly and best done outside the tilemap
    //returns the tile to be placed at `index`, given that `oldTileType` was hit with `damage`
    //only called serverside so dont do any visual/audio effects here.
    TileType server_onTileHit(CMap@ this, f32 damage, u32 index, TileType oldTileType)
    //for making sounds and effects based on tile changes - called on both server and client
    void onSetTile(CMap@ map, u32 index, TileType newtile, TileType oldtile)
    
    Note: these hooks HAVE TO go in the map loader file (and are best put in an included file so you can easily add more map formats).

    You're better off looking at trench run map code (PNGLoader in particular) than trying to "reinvent" vanilla.

    Re: builder placing them
    The builder can place whatever tile numbers it likes into the tilemap, the issue is setting up those numbers to be something meaningful.
    If you look at MapCommon.as in trench run as well, you'll see that we've defined a big enum of all the blocks - you can do this for your custom tiles that "live in harmony" with the vanilla tiles as well, you just need to start from 256 instead of 0.
     
    Eluded, Pirate-Rob and bunnie like this.
  15. bunnie

    bunnie Haxor Tester

    Messages:
    1,319
    not interested in this anymore, 8x gets a key
     
    PUNK123 likes this.
  16. makmoud98

    makmoud98 You are already DEAD Forum Moderator Staff Alumni Tester

    Messages:
    586
    sounds good, locking thread.
     
    PUNK123 likes this.
Thread Status:
Not open for further replies.