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

Portals in Kag

Discussion in 'Modding Help' started by ccnc, Mar 23, 2014.

  1. ccnc

    ccnc Catapult Fodder

    Messages:
    67
    >>not be confused with the 'tunnel' mechanics

    I'm pretty new with the Kag -Scripts/-modding. I couldn't figure out how I can copy an optical part of the map. To make it more clearly what I mean; I want to create a portal (shop or something) which displays a different part of the map, like below (gold is portal)
    :blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::gold_bullion::gold_bullion::gold_bullion::gold_bullion::gold_bullion::gold_bullion::gold_bullion:
    :castle_wall::castle_bg::castle_bg::castle_bg::castle_wall::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::gold_bullion::castle_bg::castle_bg::castle_bg::castle_wall::blank::gold_bullion:
    :castle_wall::castle_bg::castle_bg::castle_bg::castle_wall::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::gold_bullion::castle_bg::castle_bg::castle_bg::castle_wall::blank::gold_bullion:
    :castle_wall::knight::spam::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::gold_bullion::knight::spam::gold_bullion:
    :castle_wall::dirt::dirt::dirt::dirt::dirt::dirt::dirt::dirt::dirt::dirt::dirt::dirt::dirt::dirt::dirt_bg::dirt_bg::dirt_bg::dirt_bg::dirt_bg::gold_bullion::dirt::dirt::dirt::dirt::dirt::gold_bullion:
    :blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::blank::gold_bullion::gold_bullion::gold_bullion::gold_bullion::gold_bullion::gold_bullion::gold_bullion:

    I wonder if this is even possible by editing/writing scripts
     
  2. ZeroZ30o

    ZeroZ30o Haxor

    Messages:
    119
    It is possible, for sure. You don't copy. You delete a blob and create the same blob type with the same speed and orientation. You'd probably have to do this for all blobs you want to be able to pass through though. Background-portal sounds like a very bad idea though... but you might just prove me wrong :P.
     
  3. ccnc

    ccnc Catapult Fodder

    Messages:
    67
    Arghh, you mean I have to carry those blob's one by one with my bare hands to the portal. Thats gonna take like forever + 1 and all I have so far are 8 Lines of Code plus a tasty egg liquer with waffles.

    I guess the next 35 days i dont get shit down (private reasons), still try my best.
     
  4. ZeroZ30o

    ZeroZ30o Haxor

    Messages:
    119
    Well... yeah, unless the blob moves by itself. Or just make a portal gun thing, though I recomend making a portal blob first and later making a portal gun.
     
  5. ccnc

    ccnc Catapult Fodder

    Messages:
    67
    how am I able to load maps with mapcycle from mod directory
    Mods/XY/Base/Maps/mapcycle.cfg
    Mods/XY/Base/Maps/test_ctf/test_ctf3.png


    mapcycle.cfg looks like this
    Code:
    mapcycle = Maps/test_ctf/test_ctf3.png;
    map is a CTF map
    set gamemode to "CTF"
    and mapcycle to "Maps/mapcycle.cfg"

    inb4 missusing my own thread

    Edit: wow I tried everything
    -using mapcycle.cfg in /mods/base/maps/mapcycle.cfg
    -using mapcycle.cfg in /base/maps/mapcycle.cfg
    -tried different paths also "/base" or "./base/" or "base/" or "../base"
    -tried different map (.png) files
    -even removed comments fields
    -studied other mapcycle.cfg files
    -drank some orange juice
    ᕕ(´◓⌓◔)ᕗ this shit s killing me
    Edit2: solved by using ../mods/mymod/base/maps/mapcycle.cfg
    thanks to Ferne
     
    Last edited: Apr 3, 2014
  6. LightTab2

    LightTab2 Drill Rusher
    1. Zen Laboratories

    Messages:
    83
    Small help with building.as
    Code:
    // Genreic building
    
    #include "Requirements.as"
    #include "ShopCommon.as";
    #include "Descriptions.as";
    #include "WARCosts.as";
    #include "CheckSpam.as";
    void onRestart(CRules@ this)
    {
    this.set_u32("portal", 0);
    this.Sync("portal", true);
    }
    //are builders the only ones that can finish construction?
    const bool builder_only = false;
    
    void onInit( CBlob@ this )
    {
        this.set_TileType("background tile", CMap::tile_wood_back);
        //this.getSprite().getConsts().accurateLighting = true;
    
        this.getSprite().SetZ(-50); //background
        this.getShape().getConsts().mapCollisions = false;
    
        // SHOP
        this.set_Vec2f("shop offset", Vec2f(0, 0));
        this.set_Vec2f("shop menu size", Vec2f(4,4));
        this.set_string("shop description", "Construct");
        this.set_u8("shop icon", 12);
        this.Tag(SHOP_AUTOCLOSE);
    
        {
            ShopItem@ s = addShopItem( this, "Builder Shop", "$buildershop$", "buildershop", descriptions[54] );
            AddRequirement( s.requirements, "blob", "mat_wood", "Wood", COST_WOOD_FACTORY );
        }
        //!!!
    
        {
            ShopItem@ s = addShopItem( this, "Portal", "$portal$", "portal", descriptions[54] );
            AddRequirement( s.requirements, "blob", "mat_wood", "Wood", COST_WOOD_FACTORY );
        }
        {
            ShopItem@ s = addShopItem( this, "Quarters", "$quarters$", "quarters", descriptions[59] );
            AddRequirement( s.requirements, "blob", "mat_wood", "Wood", COST_WOOD_FACTORY );
        }
        {
            ShopItem@ s = addShopItem( this, "Knight Shop", "$knightshop$", "knightshop", descriptions[55] );
            AddRequirement( s.requirements, "blob", "mat_wood", "Wood", COST_WOOD_FACTORY );
        }
        {
            ShopItem@ s = addShopItem( this, "Archer Shop", "$archershop$", "archershop", descriptions[56] );
            AddRequirement( s.requirements, "blob", "mat_wood", "Wood", COST_WOOD_FACTORY );
        }
        {
            ShopItem@ s = addShopItem( this, "Boat Shop", "$boatshop$", "boatshop", descriptions[58] );
            AddRequirement( s.requirements, "blob", "mat_wood", "Wood", 100 );
            AddRequirement( s.requirements, "blob", "mat_gold", "Gold", 50 );
        }
        {
            ShopItem@ s = addShopItem( this, "Vehicle Shop", "$vehicleshop$", "vehicleshop", descriptions[57] );
            AddRequirement( s.requirements, "blob", "mat_wood", "Wood", 100 );
            AddRequirement( s.requirements, "blob", "mat_gold", "Gold", 50 );
        }
        {
            ShopItem@ s = addShopItem( this, "Storage Cache", "$storage$", "storage", descriptions[60] );
            AddRequirement( s.requirements, "blob", "mat_stone", "Stone", 50);
            AddRequirement( s.requirements, "blob", "mat_wood", "Wood", 50);
        }
        {
            ShopItem@ s = addShopItem( this, "Transport Tunnel", "$tunnel$", "tunnel", descriptions[34] );
            AddRequirement( s.requirements, "blob", "mat_stone", "Stone", 100 );
            AddRequirement( s.requirements, "blob", "mat_wood", "Wood", 50 );
        }
    }
    
    void GetButtonsFor( CBlob@ this, CBlob@ caller )
    {
        if(this.isOverlapping(caller))
            this.set_bool("shop available", !builder_only || caller.getName() == "builder" );
        else
            this.set_bool("shop available", false );
    }
    
    void onCommand( CBlob@ this, u8 cmd, CBitStream @params )
    {
        bool isServer = getNet().isServer();
        if (cmd == this.getCommandID("shop made item"))
        {
            this.Tag("shop disabled"); //no double-builds
        
            CBlob@ caller = getBlobByNetworkID( params.read_netid() );
            CBlob@ item = getBlobByNetworkID( params.read_netid() );
            if (item !is null && caller !is null)
            {
                this.getSprite().PlaySound("/Construct.ogg" );
                this.getSprite().getVars().gibbed = true;
                this.server_Die();
    
                // open factory upgrade menu immediately
                if (item.getName() == "factory")
                {
                    CBitStream factoryParams;
                    factoryParams.write_netid( caller.getNetworkID() );
                    item.SendCommand( item.getCommandID("upgrade factory menu"), factoryParams );
                }
                if (item.getName() == "portal") //Make sure this function is working, else do in portal.as code like this.
                {
                CRules@ rules = getRules();
                int portal = rules.get_u32("portal")
                portal += 1;
                rules.set_u32("portal", portal);
                rules.Sync("portal", true);
                this.set_u8("dest", portal);
                }
            }
        }
    }
    
    Do in your portal.as something like in suddengib.as (searchblobsinradious) with onTick and just copy blobs. Portals should be big (better lock them [this.getShape().getConsts().mapCollisions = true;])

    EDIT: I may do mistakes in code, you should fix it (to track them click "home" button on your keyboard).
     
  7. acromatic

    acromatic Catapult Fodder

    Messages:
    13
    old thread but interesting. in the current 1337 build or the next, you could probably hook rendering into a new blob type. then add your theater blobs on a custom map. Don't know if rendering can be hooked but you could crop a full screen manually using the blobs as individual pieces of a screen. Lots of math and headache, have fun with that.
     
  8. LightTab2

    LightTab2 Drill Rusher
    1. Zen Laboratories

    Messages:
    83
    On linking portals(special code, not hard) set_Vec2f of linked to it portal, player usage = command send, then change our player position [ blob.setPosition(portal.getPosition()); ]

    EDIT: If it'd be a zone on a map, then Teleporting.as, include to classes. Teleporting will just check per 5 tick to optimize, if player is in teleporting zone.
     
  9. ccnc

    ccnc Catapult Fodder

    Messages:
    67
    just to let you know, the initial idea was creating a borderless left/right map -> and the threads purpose was to know if it is even possible to realize a major part of this mod idea.

    My specification were/are
    -circle maps (ever played asteroids?)
    -more Teams (round circular maps elminate imbalance of team positions) [mods for more teams already exist]
    -portal blocks to clone one edge of the map (the picture below might be a better explanation)
    [​IMG]maybe that is something shiprekt modder should think about too (on the other hand map borders, are a good way to flee from an enemy)
    Code:
    the map used for this mod needs to be atleast twice as wide as the max screen width (monitor resolution x-axis).
    the far left part of the map gets stripped off and filled with the "portal" (a impassable part of the map which is just to extend the optical part of the map, mocking a borderless game)
    same happens for the other side of the map (not in the picture for not making it unecessary complicated) someone/something who touches the physical border of the map switches the x-position to physicalmapendXposition -1 or physicalmapbeginXposition +1.
    side note: red barrier and shops placed on the border are a little tricky
    
    not guaranteed to be the best approach

    Why is this still not a thing?
    short on time, couldn't get warm with the script language and KAG code structure, loose interest in the game. I'didn't completly abondoned the idea of finishing it in the future, but I don't have great hope for it.
     
    LightTab2 and Asu like this.
  10. acromatic

    acromatic Catapult Fodder

    Messages:
    13
    In saying circle maps, I'm thinking that's a very bad description.
     
  11. LightTab2

    LightTab2 Drill Rusher
    1. Zen Laboratories

    Messages:
    83
    The teleporting is possible - of course, but I affraid about resizing images. You can do screenshot of beggining map and in OnRender function

    if (getLocalPlayer().getBlob().getPosition().x > map.getSize().x - getScreenResolution().x) //Saving on GPU memory
    {
    [renderimagefunction](getScreenResolution().x - (getLocalPlayer().getBlob().getPosition().x - map.getSize().x), 0)
    }
    I may do a mistake, I'm not able to obtain KAG's code now.

    Without resizing it'd look unreal, I don't know if irrlicht has a this function like sfml.
     
  12. acromatic

    acromatic Catapult Fodder

    Messages:
    13
    As someone who is an autodidact indie dev who learned most of what I know from Irrlicht, I can tell, it does not have a simple way to extract render passes other than what's used in RTT render to texture.

    it seems like messing with the rendering is far beyond what's necessary, couldn't you just reposition the player rather than infinitely render the scene based on position? That is how asteroids works, the screen doesn't keep going and going the player is simply warped to the other side.

    Now if you wanted to do it like a side scroller you would need that. but that is an awful lot of work to achieve something that many would just find confusing. not just that but it's a mechanic that favors running away over standing your ground. I really don't see why you would really want that.