Player buildable/buyable Shield Generator

Discussion in 'Mechanics' started by GammaNu, Sep 9, 2016.


This should be in vanilla experience or only as a mod ?

  1. Vanilla

    16 vote(s)
  2. Mod

    1 vote(s)
  1. GammaNu

    GammaNu Scruffy Nerf-Herder

    If player can lock there creation, building dungeon take a new dimension !

    How to do it ?
    The best behavior i see could be :
    • as default behavior : lock every tiles within some range around any active not wired generator. (look simple and usable)
    • as advanced usage : lock tiles delimited by a custom shape. The player use a specific chain wireable delimiter to mark the area to lock, then, he link one of the delimiter to the generator to make it switch from basic circular area lock to custom user shape defined area lock.
  2. GammaNu

    GammaNu Scruffy Nerf-Herder

  3. bk3k

    bk3k Oxygen Tank

    The in-game shield generator implementation doesn't rely on distance, but on dungeonID. The regular generated world has one, each dungeons have their own, and stuff placed by the player have their own. The protection is turned on per dungeonID. All or nothing.

    As part of a dungeon, it has the dungeonID of the dungeon and therefore protects that dungeon.
    A shield generator which was placed by the player would protect the blocks which that player has placed.
    If it generated as part of biome generation etc, then it would protect the world itself(minus blocks the player has placed or dungeons).

    If you are wanting to make your own dungeons, there are two main ways.
    1. The old way is making blockImages etc. There are tutorials and I believe this is still supported if you preferred this way.
    2. Tiled. A while back Starbound added proper support for this program. I haven't really looked at it yet, but it is intended to make the whole process easier I believe. Again tutorials do exist.

    You could technically also use the Base in a Box mod. You build stuff in game. Scan it to receive an object which would roll out your structure. So you could pass it along via multiplayer as long as that's part of the server. Better than that - there is an option within the mod's config files somewhere that will dump the builder object's JSON so you can save it to a file. In turn you can distribute that file to either
    1. Just add into the Base in a Box's folder which is reserved for custom creations.
    2. Distribute as a mod(Requiring Base in a Box).

    But as awesome as that is, there are some limitations. Last I recall, it won't save wire connections. And honestly I'm not sure restoring those is even possible within the confines of Starbound's LUA. Or at least I know of no function to establish a wire connection between two objects. Also the whole built structure will have the dungeonID of yourself. So if you have a shield in there, it will turn on protection for all your tiles on the planet - rather than just the structure you placed.

    There is a newer tech mod out there that does something similar. I haven't really checked it out yet and I forget the name.
    GammaNu likes this.
  4. GammaNu

    GammaNu Scruffy Nerf-Herder

    If i want a radius or custom lock feature for player placable shield generator, it look possible to me with a lua :
    - a specific dungeonID for the mod/feature (with nameIt gid (generator id)
    the lua do :
    - first select form the generator all contigus tiles with the the gid, and change them back to default world id.
    - then, if no wire, select all tiles in a radius with default world id or player id and set the id to gid.
    - or, if there is wire, folow them to make and ordered list of points. calculate tiles inside the shape and set all the default or player id tiles to gid.
    that's it !
    and run the script on generator placement, linking and why not on state change (activation/desactivation) and you have the behaviour.
    Isn't it ?
  5. GammaNu

    GammaNu Scruffy Nerf-Herder

    but i will definitly look closer to Base in a Box mod, perhaps also on tiled, and perhapse to the misterious newer tech mod you speak about ;)
  6. bk3k

    bk3k Oxygen Tank

    Sure but I don't know how to set the actual dungeonId. They have a function which returns the dungeonId at a location, but I don't see one to set it - they probably SHOULD have one, but don't. I'm afraid this probably happens at the C++ engine side too.

    Now you can place a dungeon with world.placeDungeon() and you can even specify the dungeonId in the process.. so maybe something creative.
    The dungeon is 1x1 containing just an object(which has the dungeonID of the dungeon - which you may have specified).
    Perhaps your shield generator, or maybe a temporary object that does stuff before self-destructing.
    That object gets a readout of all tiles and objects in an area(which is what you want to do, right?).
    The object destroys all these things.
    There are options to not actually drop anything, but to simply destroy.
    And you could skip destroying anything that already has the desired dungeonId.
    The object then places those same tiles and objects in the same positions.
    If the object was a temporary object, it places the shield generator(which then shares the dungeon ID)

    2 major downfalls of this method.
    1. A player probably doesn't want to stand there while it works. Neither do you want NPCs, monsters, etc.
    2. It would lag badly until finished - but once done won't need re-done ever, unless you intend to expand the zone.

    It may be most efficient to modify BIAB code, but I believe you'd need permission. I can tell you that trying to build super-large structures with it can crash the script, or at least this was the case last time I attempted to do so. Could be an engine limitation, or likely hitting the LUA instruction limit(per script delta tick) that Starbound has imposed. So dividing it into chucks handled one at at time per pass of update() may help. Maybe I should be giving that advise to them LOL.

    That would all be unnecessary if they had a function to just change the dungeon ID of a tile (or area as defined by 2 points assumed as opposing corners). And I haven't really played with dungeons to tell you what would happen, but maybe a mostly empty dungeon placed over existing tiles will just change the dungeon ID of those tiles? I expect they'd be destroyed instead. But if I'm wrong.. then this becomes easy.

    as for the tech mod I spoke of - found it

Share This Page