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

Shiprekt Islands

Discussion in 'Modding Help' started by Tsilliev, Aug 6, 2014.

  1. Tsilliev

    Tsilliev Haxor

    Messages:
    414
    As the title says I tried to edit the shallowwaters.png map, I put sand color blocks, dirt color blocks, grass and tree color blocks, started server to see changes, and there was nothing, then I remember that if there would be something it would be real tree, sand and dirt blocks like in CTF gamemode. (now I remember that there isnt sand but anyway)

    So I was thinking to use the background dirt, stone etc but of course nothing, so I was looking around how the water is generated and I found custommap.as and there we have 3 things.

    Code:
    namespace CMap
    {
        // tiles
        const SColor color_water(255, 77, 133, 188);
        const SColor color_tree(255, 43, 85, 67);
        // objects
        const SColor color_main_spawn(255, 0, 255, 255);
    
        enum Blocks {
            water = 0,
            grass_1 = 1,
            grass_2 = 2,
            grass_3 = 3,
            tree = 4
        };
    
        //
        void SetupMap( CMap@ map, int width, int height )
        {
            map.CreateTileMap( width, height, 8.0f, "SpriteSheet.png" );
            map.CreateSky( color_water );
            map.topBorder = map.bottomBorder = map.rightBorder = map.leftBorder = true;
        }
    
        //
        void handlePixel( CMap@ map, SColor pixel, int offset)
        {
            if (pixel == CMap::color_water)
            {
                map.AddTileFlag( offset, Tile::BACKGROUND );
                map.AddTileFlag( offset, Tile::LIGHT_PASSES );
                //map.SetTile(offset, CMap::grass + random % 3 );
    
            }
            else if (pixel == CMap::color_tree)
            {
                map.SetTile(offset, CMap::tree );
                map.AddTileFlag( offset, Tile::BACKGROUND );
                map.AddTileFlag( offset, Tile::SOLID );
            }
            else if (pixel == CMap::color_main_spawn) {
                AddMarker( map, offset, "spawn" );
                PlaceMostLikelyTile(map, offset);
            }
        }
    
    }
    
    water, tree and spawn.
    Water and spawn are used but tree is not, so my idea was can I put the tree by editing the map, but then I didnt knew which color was because these color codes are different than the pallet for normal ctf/war gamemode, or I am mistaken?

    And my other question would be, how can I put a certain color to a custom tile, and put it in the map and later when I start the server it will be generated like the water is?
    edit:
    I will try to put
    Code:
    const SColor color_tile_wood_back(255, 85, 42, 17);
    
    else if (pixel == color_tile_wood_back) {
                map.SetTile(offset, CMap::tile_wood_back );
            }
    in custommap.as and put the wood background block in the map and see what happens. I am trying things out as I wait for some replies. ::D:

    edit2: nope nothing appeared

    edit3: with the help of Skinney on irc ::D: ::D: ::D:
    [​IMG]

    Later will add more texture blocks and put them more naturally looking like an island not just one big block ::D: but first i need to assign the collision and other properties on the block that will enable me to walk on it.

    Camera rotation must be disabled or they disappear, ie not rendered properly.

    edit4: so far the custommap.as in shiprekt -> scripts -> maploaders
    is
    Code:
    namespace CMap
    {
        // tiles
        const SColor color_water(255, 77, 133, 188);
        const SColor color_tree(255, 43, 85, 67);
        // objects
        const SColor color_main_spawn(255, 0, 255, 255);
        const SColor color_dirt(255, 51, 85, 102);
    
        enum Blocks {
            water = 0,
            grass_1 = 1,
            dirt = 2,
            grass_3 = 3,
            tree = 4
        };
    
        //
        void SetupMap( CMap@ map, int width, int height )
        {
            map.CreateTileMap( width, height, 8.0f, "SpriteSheet.png" );
            map.CreateSky( color_water );
            map.topBorder = map.bottomBorder = map.rightBorder = map.leftBorder = true;
        }
    
        //
        void handlePixel( CMap@ map, SColor pixel, int offset)
        {
            if (pixel == CMap::color_water)
            {     
                map.AddTileFlag( offset, Tile::BACKGROUND );
                map.AddTileFlag( offset, Tile::LIGHT_PASSES );
                //map.SetTile(offset, CMap::grass + random % 3 );
    
            }
            else if (pixel == CMap::color_tree)
            {
                map.SetTile(offset, CMap::tree );
                map.AddTileFlag( offset, Tile::BACKGROUND );
                map.AddTileFlag( offset, Tile::SOLID );
            }
            else if (pixel == CMap::color_main_spawn) {
                AddMarker( map, offset, "spawn" );
                PlaceMostLikelyTile(map, offset);
            }
            else if (pixel == color_dirt) {
            map.SetTile(offset, CMap::dirt );
                map.AddTileFlag( offset, Tile::BACKGROUND );
                map.AddTileFlag( offset, Tile::SOLID );
     
            }
        }
    
    }
    
    and also
    [​IMG]

    You can see the dirt at the 3rd space
    And I understand that addtileflag actually ads the properties because when I add addtileflag solid, I cannot pass trought the dirt, my question would be what other properties are there?
    What are their names?
    Or I am looking at the wrong direction and should make a dirt.cfg or dirt.as and specify the properties there?

    edit5:
    I google kag addtileflag
    and I found this post
    https://forum.kag2d.com/threads/custom-tiles-not-blobs.19986/
    luckily there are as I think all property types and I made the island solid where I cannot pass trought it, will try to break the ship on it, but still there is a problem, cannot walk on it.
    edit6:
    I tried a crash test, but the ship goes trough the dirt ::D:

    edit7: tried another crash test and actually the ships breaks, but like 2-3 blocks per passing trough the dirt, not everything at once, funny.

    edit8: added simple textures for sand and grass but still looking how to make the island walkable
    [​IMG]

    Thanks to notrayne!!!
    [​IMG]
    Because I made the island to spawn so near the base, it got stuck to the ship, I palced a motor and I could move the island, I also placed a bomb!:
    [​IMG]
    ::D: ::D: ::D:
    [​IMG]

    Now will find a way to make island blocks immobile.
    Here is the custommap.as
    Code:
    #include "MakeBlock.as"
    namespace CMap
    {
        const SColor color_water(255, 77, 133, 188);
        // tiles
        const SColor color_sand(255,236, 213, 144);
        const SColor color_dirt(255, 51, 85, 102);
        const SColor color_tree(255, 13, 103, 34);
        // objects
        const SColor color_main_spawn(255, 0, 255, 255);
    
    
        enum Blocks {
            water = 0,
        };
    
        //
        void SetupMap( CMap@ map, int width, int height )
        {
            map.CreateTileMap( width, height, 8.0f, "SpriteSheet.png" );
            map.CreateSky( color_water );
            map.topBorder = map.bottomBorder = map.rightBorder = map.leftBorder = true;
        }
    void handlePixel( CMap@ map, SColor pixel, int offset)
            {
                    if (pixel == CMap::color_water)
                    {        
                            map.AddTileFlag( offset, Tile::BACKGROUND );
                            //map.SetTile(offset, CMap::water );    
                    }        
                      
                    else if (pixel == CMap::color_main_spawn) {
                            AddMarker( map, offset, "spawn" );
                            PlaceMostLikelyTile(map, offset);
                    }
                    else if (pixel == CMap::color_sand) {
                            CBlob@ b = makeBlock( map.getTileWorldPosition( offset ), Block::SAND, -1 );
                            b.Tag("land");
                            b.getSprite().SetZ(-5.0f);
                    }
                    else if (pixel == CMap::color_tree) {
                            CBlob@ b = makeBlock( map.getTileWorldPosition( offset ), Block::TREE, -1 );
                            b.Tag("land");
                            b.getSprite().SetZ(-5.0f);
                    }
                    else if (pixel == CMap::color_dirt) {
                            CBlob@ b = makeBlock( map.getTileWorldPosition( offset ), Block::DIRT, -1 );
                            b.Tag("land");
                            b.getSprite().SetZ(-5.0f);
                    }
            }
      
    }        
    And declare the blocks in blockcommon.as
    Code:
    namespace Block
    {
        const int size = 8;
    
        enum Type
        {
      
            PLATFORM = 0,
            PLATFORM2 = 1,
            DIRT = 2,
            TREE = 3,
            SOLID = 4,
            SAND = 7,
    And also put them in the block.png the textures.

    Thanks to everyone that I talked with at IRC!
    Norill,Notrayne,Geti,AsuMagic and maybe someone else whom name I dont remember ::D:

    edit:
    Moved the island little to the right so it doesnt stick to the mothership and also you can see which colors I use.
    [​IMG]

    Some more testing
    [​IMG] [​IMG] [​IMG]

    ::D: ::D: ::D:
    Note: to make island blocks invulnerable too.

    edit:
    more testing
    :D
    [​IMG] [​IMG]
    [​IMG]
    And I got fps drop because there are around a few hundread blobs :D
    [​IMG]


    I was suggested to use tiles not blobs to remove these kind of problems, but then as stated above the tiles have renreding problem when rotating the camera or steering the ship.
    So the islands can be used as of now in small maps with small numbers.
    I also heard from Geti that the rendering problem as I understood will be fixed in the future patches.

    I also found that at blockcommon.as
    you need to have
    Code:
    bool isSolid( const uint blockType )
        {
            return (blockType == Block::SOLID || blockType == Block::PROPELLER||Block::DIRT||blockType == Block::SAND||blockType == Block::TREE);
        }
    In order to make the island blocks crush the ship but they get destroyed too.
     
    Last edited: Aug 7, 2014
  2. um, so you are making this?
    [​IMG]
     
    Asu and Klokinator like this.
  3. Tsilliev

    Tsilliev Haxor

    Messages:
    414
    :eek: You already made it? :D
    You can walk on the island?
     
    Asu likes this.
  4. Asu

    Asu THD Team THD Team Forum Moderator

    Messages:
    1,580
    Rayne did, and yes, i forgot it
     
  5. Tsilliev

    Tsilliev Haxor

    Messages:
    414
    Yeah me, Norill, and Rayne talked in irc 2 hours ago.
     
    Asu likes this.
  6. i did
     
    Klokinator and Asu like this.
  7. Klokinator

    Klokinator Such Beta
    1. Aphelion's Roleplay

    Messages:
    1,443
    Yeah the game could use islands for some variety. Maybe some islands could have spawning blocks, so people could hop off a miniship and buy parts they need? Would be pretty sweet IMO.
     
  8. Tsilliev

    Tsilliev Haxor

    Messages:
    414
    Wohooo! Made it, main post updated :D
    --- Double Post Merged, Aug 7, 2014, Original Post Date: Aug 7, 2014 ---
    Or villiges that when conquered give tax to the conquerer and the villige haves trader as well for parts, but I heard that too big islands may pose a problem so I will test a little.
     
    Asu likes this.