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

Tiles

Discussion in 'Modding Help' started by GoldenGuy, Feb 21, 2017.

  1. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    I added custom tiles in my mod, but it have 2 problems. 1) how to make them show up on minimap? 2) how to make collapsed tile hit player/blob?
     
    Last edited: Feb 21, 2017
  2. 8x

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

    Messages:
    1,325
    Are they tiles or are they blobs? Where did you put them, or implement them, in your mod? at the World.png, or at the Structures folder or whatever (like trapblocks, doors, items etc)?
     
  3. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    they TILES, implemented with CustomBlocks.as and commands server_onTileHit onSetTile from this thread https://forum.thd.vg/threads/custom-tiles-not-blobs.19986/
     
  4. 8x

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

    Messages:
    1,325
  5. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    @Geti , can you help?
     
  6. 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
    the person you should be asking for help is @Skinney
     
  7. Skinney

    Skinney THD Team THD Team Forum Moderator Tester

    Messages:
    468
    There are a couple hooks for tiles that you will need to make use of.

    TileType server_onTileHit(CMap@ this, f32 damage, u32 index, TileType oldTileType)
    void onSetTile(CMap@ this, u32 index, TileType newtile, TileType oldtile)
    bool onMapTileCollapse(CMap@ this, u32 offset)

    In example, returning true for bool onMapTileCollapse(CMap@ this, u32 offset) will create a verlet.

    If I remember correctly. The minimap is mostly obfuscated from scripting. You could try setting things with void SetMinimapVars(const string&in texture, const uint16 frame, const Vec2f framesize), but I'm not sure how successful you will be in replicating the behavior you want.
     
  8. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    "TileType server_onTileHit(CMap@ this, f32 damage, u32 index, TileType oldTileType)
    void onSetTile(CMap@ this, u32 index, TileType newtile, TileType oldtile)
    bool onMapTileCollapse(CMap@ this, u32 offset)" i am using this hooks, i made tile collapsing, but its not hitting player, minimap i dont care anymore
    --- Double Post Merged, Feb 24, 2017, Original Post Date: Feb 23, 2017 ---
    also, SetMinimapVars only for blobs ::(:
    --- Double Post Merged, Feb 26, 2017 ---
    ok, i kinda find the problem, tile becoming not solid when it collapses, how to fix?
     
  9. Geti

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

    Messages:
    3,730
    Minimap isn't exposed to scripting - as you're making a mod though, you do have the option to disable it and write your own minimap. Unattractive option, but the GUI rendering stuff is pretty powerful.

    In the medium term I'll look at how feasible a binding would be for outputting a minimap colour for a modded tile.

    Out of interest, are you using the vanilla tiles and only adding your extended tiles above 255? Or are you replacing the vanilla behaviour completely (like TR does)?
     
  10. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    Adding tiles above 255
     
  11. Geti

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

    Messages:
    3,730
    ok, I made a shim for this which will be in the next build.
    Here's a look at a simple proof of concept:
    Code:
    void onInit(CMap@ this)
    {
        this.legacyTileMinimap = false; //use for all tiles
        this.MakeMiniMap(); //regenerate here because onInit is called late
    }
    
    void CalculateMinimapColour( CMap@ this, u32 offset, TileType tile, SColor &out col)
    {
        col = this.isTileSolid(tile) ? SColor(0xffa0a0a0) : SColor(0xff404040);
    }
    Results in a map like this
    [​IMG]
    Note that these are MAP scripts and are probably best put as part of your maploader which sets up all the extra tiletypes anyway. There's an issue with using onInit as well -

    legacyTileMinimap works (means it'll use the script for all tiles instead of tiles >255) - but onInit for maps isn't early enough to take part in minimap generation, so you still end up with a default minimap for tiles under 255.

    If you put the code in your map loader (as I'd suggest) then you're fine and shouldn't need the minimap regen, but you will still need the legacyTileMinimap flag if you're replacing tiles under 255.

    If you're making tiles above 255 you should be fine anyway without setting the flag or regenerating the map - but for anyone making a mode that completely replaces the tiles and wants to use the minimap stuff, that's something to keep in mind. Documenting this here but I'll need to put something in the release log too.

    There's still no support for making your own preview image for the server browser. That was a bit much of a pain to address at the moment, and I'm vaguely concerned people will use it to upload porn images or similar :/


    Now, About tiles collapsing: it looks like you just need to set the SOLID flag for the tile. The code that determines if the collapsing body does damage is just this:
    [​IMG]
     
    Pirate-Rob, 8x, GoldenGuy and 2 others like this.
  12. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    The minimap thing will be really awesome!
    "Now, About tiles collapsing: it looks like you just need to set the SOLID flag for the tile. The code that determines if the collapsing body does damage is just this:" - Where i need to add this code?
     
  13. Geti

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

    Messages:
    3,730
    Wherever you're setting tile flags, probably in your map loader (example from TR source)

    Code:
    //(Trench Run PNGLoader.as line 116)
    
    void onSetTile(CMap@ map, u32 index, TileType newtile, TileType oldtile)
    {
    	//here's where we're setting up the flags
    
    	//all tiles like this to prevent shading (not a good idea for KAG)
    	map.AddTileFlag(index, Tile::LIGHT_SOURCE | Tile::LIGHT_PASSES);
    
    	bool isSomething = false;
    	//background will render behind most objects
    	if (TWMap::isTileTypeBackground(newtile))
    	{
    		isSomething = true;
    		map.AddTileFlag(index, Tile::BACKGROUND);
    	}
    
    	//we use the ladder flag in TR for climbing, it's not used in KAG any more
    	if (TWMap::isTileTypeLadder(newtile))
    	{
    		isSomething = true;
    		map.AddTileFlag(index, Tile::LADDER);
    	}
    
    	//solid tiles are marked solid and collide, so they block raycasts
    	// and create collision lines
    	if (TWMap::isTileTypeSolid(newtile))
    	{
    		isSomething = true;
    		map.AddTileFlag(index, Tile::SOLID | Tile::COLLISION);
    	}
    
    	//if we didn't find anything, mark the tile as "water passes"
    	// - I'm not 100% why we do this in TR since we keep water static there..
    	if (!isSomething) //empty
    	{
    		map.AddTileFlag(index, Tile::WATER_PASSES);
    	}
    
    	// (then there's a bunch of stuff for flipping and rotating tiles
    	//  for autotiling)
    
    	if (newtile != oldtile)
    	{
    		// (then there's effects for destruction/tile changes:
    		//  creating particles, playing sounds, etc)
    	}
    }
    Reading the TR maploader (PNGLoader.as) might help see how custom tiles can be implemented.
     
    GoldenGuy likes this.
  14. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    "Now, About tiles collapsing: it looks like you just need to set the SOLID flag for the tile." strange, i am adding it to tile, but it still doesnt work for me :( block.gif
     
    Osmal likes this.
  15. 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
    Do a little debugging and print the flags of the tile under the cursor to double check it's actually set properly.
     
    GoldenGuy likes this.
  16. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    1) What about adding ability to change damage, taken from collapsed blocks? Like, to make wooden block deal less dmg than castle.
    2) How do i make tiles change texture, depending on tiles near them? Like with castle background, when it changes if you place block near it.
    3) Is collapsed block still counts as tile? Or it some kind of blob?
    4) How to make collapsed block fall on ground and place on it? Like with castle blocks.
     
  17. Skinney

    Skinney THD Team THD Team Forum Moderator Tester

    Messages:
    468
    You would have to fetch adjacent positions and set new tiles based on your conditions for those positions within void onSetTile(CMap@ this, u32 index, TileType newtile, TileType oldtile).
     
  18. Geti

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

    Messages:
    3,730
    Neither, it's a totally separate system - this is also the reason answer to 1 and 4 "you can't, as far as I know".

    It's a custom verlet physics system that MM wrote one weekend. There wasn't even binds for allowing custom tiles to collapse before skinney asked for them.
     
  19. GoldenGuy

    GoldenGuy Haxor Tester

    Messages:
    105
    So, what you think wrong here? If you need whole code, you can check territory control mod, they have the same problem
     
  20. Geti

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

    Messages:
    3,730
    I'm honestly not sure - as Verra said I'd make sure your flags are actually getting set, read them in your onMapTileCollapse and see if they're somehow missing/changed from what you set.

    I don't have time to debug mods at the moment I'm afraid - I'm trying to get a build out today and if I get time, then update the official modded server with another mod (provided I can get it working).

    What we did in TR about collapses was to avoid the built-in collapse system entirely and spawned crate blobs that would fall and re-settle when they hit the ground, or kill people they fell on. It wasn't perfect and doesn't have the same spectacle as the built in blocks but you have control over that, so it might be a viable workaround in the short term.

    Sorry that I can't give more insights into it at this point.
     
    GoldenGuy likes this.