Modding Discussion Help me mod! (pls!)

Discussion in 'Starbound Modding' started by PabloM, May 9, 2021.

  1. PabloM

    PabloM Pangalactic Porcupine

    So, I've had some ideas for mods, but I have only the most basic idea of how modding works.
    I've unpacked the game files and looked through them, but can't make heads or tails of most of it.

    But I think, if I knew what I needed to do, I might be able to figure out how to do it.
    It's mainly the "knowing" part of it that I'm having trouble with right now...
    So, a lil help would be awesome. :D

    To the ideas:

    Dead Bodies
    When you die in Hardcore mode, you no longer spew all your items about the place. Now you just drop a "dead body" item containing all your stuff.
    Practically, the simplest part would be the item itself, as it would be just a clone of a chest but with different graphics. But, ideally, there would be a bit more complication.
    I'd like there to be a different body/chest for each species, and also incorporate the colour customisation data so as to make the body look like the character that just died. Essentially, I'm envisioning a chest that looks like a "sleeping" player (but maybe with more blood). It would be awesome if clothing could be shown too (similar to how a mannequin works, I imagine, but obviously horizontal.)
    Then, I'd need to figure out how to spawn it on death, and then capture and store all the items.
    Some kind of Memento Mori-like beacon/detection system would be good, to help a different character locate the remains.
    And finally, a small change to the death animation, perhaps.
    This could probably work for Casual and Survival modes, too, but with an actual chest or pod (since the character would be still alive).

    Changes to Crew
    It'd be good if the crew could have their own internal inventory, so they could hold or pick up some items if needed. For example, if you give a crewmember a piece of soil, then they'll pick up any soil (and only soil) they come across.
    For this to work, pressing E on a crewmember would need to open their "inventory" rather than toggling come/stay. Perhaps this toggle, and any other useful things, could be part of the inventory UI. But better would be incorporating it into a proper crew management system like Crew Customization+.
    Another crazy idea would be if you could send crewmembers off on errands. eg: Send them to gather some resources, or collect rent for you, or harvest your crops, or maybe do some of the more menial quests for you. This would all be done off-screen, in the background, and would probably just involve that crewmember being absent until a timer runs down. At which point, he returns with any necessary loot!
    The awesomest version of this would be if you could actually see him doing the task if you're in the right place at the right time!

    Changes to Mechs & Ships
    So, in every other (NPC) ship out there, they have an energy shield allowing access for a mech. But the player ships don't have that (unless there's been a change to higher tier ships that I don't know about).
    It'd be good to have that on player ships rather than a pseudo-teleport animation.
    Also, ideally, the player ship and the other ship should be in the same "space". This would probably involve just spawning the other ship into your "space". Or perhaps the spaces could be joined seamlessly somehow.
    I haven't started building my own spacestation yet, but I'd guess the energy shield is available there.
    Perhaps the Crew Errands idea above could require that the crewmember is on your spacestation and has their own mech or small ship.

    Tenants Need Food Etc
    It might be cool if your tenants demanded more of you than just four walls, a door and a light source.
    Perhaps it could be done so that you could place a fridge or kitchen counter (or similar) in their house in order to provide them food. Basically, they'd survive anyway, but providing food like this increases the rent they'll pay!
    Each tenant could have favourite foods that they're willing to pay more for.
    Perhaps there could be some way to create a restaurant or cafe that will buy your food in exchange for increasing happiness and/or rent to local tenants.
    I'm thinking something similar along the lines of including a water source (either as a tank or via pipes; water held would decrease gradually depending on number of tenants; hydrated tenants pay more rent; healing water returns even more rent!),
    and sewage (toilets would be required otherwise poop builds up in the streets; amount produced (spawned) would depend on number of tenants; remove poop by either "processing" it by placing a purification or fertiliser machine, or burning it or piping it away somewhere; poopy areas would pay less rent :poo: :disshappy: )
    All of this would make the player have to focus on a few good happy tenants rather than just factory-farming an income source.

    To be honest, I don't know how much of all that is even possible via modding. I don't even know if I'd be able to actually do the modding even if I was told exactly what to do... :confused::(:wtf::V
    So, if anyone wants to take any of this and run with it, go for it! :megusta::up:
    Otherwise, thoughts and explanations-like-I'm-five, please. :badpokerface:
     
  2. Zaakari

    Zaakari Pangalactic Porcupine

    Well, I like those ideas. They would definitely make for some cool mods.

    The first idea--dead bodies--would probably be the easiest of the four to implement (not necessarily easy, but the easiest). You described it really well, and a lot of those features are all ready in the game (death events, item drops, mods targeting specific species).

    The second idea--changes to crew--sounds a lot more difficult. Maybe getting them to pick up items would be possible. But having them do errands for you... hm... maybe if they were "virtual" errands. For example:
    • Tell crew member to collect bounties.
    • "Yes sir, captain!"
    • *Crew member teleports away*
    • *Three days pass*
    • *Crew member returns*
    • "Here are the bounties, captain! As requested."
    Perhaps something like that. The crew member wouldn't need to actually be on a planet attacking other NPC's, but there could be code defining how long he is away, and what kind of reward/items he brings back. If that's possible, then perhaps his chance of success could be modified by the type/amount of gear he has.

    I'm not about to commit to making these. But I might try poking around to see what's possible.
     
  3. PabloM

    PabloM Pangalactic Porcupine

    Awesome!
    It sounds like you have some idea what you're dealing with, so that's at least more than I have.

    I can kind of visualise how the different aspects would have to be altered (as you said: death events, item drops, mods targeting specific species, etc) but I'm completely clueless about the actual coding, which unfortunately is the single most important part of modding.... :lod:
    Tbh, the other ideas are basically just a wishlist that'll most likely never be possible, but the first, as you said, is the most doable. That is, I can kind of fit the pieces together, if only conceptually.
    For example, when a character dies and their "body" is dropped, I wonder if it'd be possible to add a new mission to all existing and new characters: "Recover Body of <Dead Char's Name>". That way the "mission compass" would be how you find the body, and the whole Memento Mori system would be unnecessary. When found, the mission(s) would have to be removed from everywhere. Again, I can imagine that it's probably possible... ‍

    Yes, how you described the second idea is exactly how I imagine it. (Maybe not three days, but still!)
    I imagine it something like the existing missions, but ones you create by making selections in some UI, including assigning a crewman.
    It'd be better than having idle crewmen just wandering around your ship willy-nilly!
     
  4. Zaakari

    Zaakari Pangalactic Porcupine

    So, while I was struggling to find the right spot to alter the on-death events, I decided to make use of one of the Modder's best friends... other mods. I downloaded that Memento Mori mod you mentioned, and found the spot I was looking for (thanks Lunchghost). The function where we should be able to run our body placement code is called "applyDamageRequest"; and it lies in the Lua script "/stats/player_primary.lua".

    In like fashion to what the Memento Mori mod was doing, I patched in a new Lua file--named "death_handler.lua"--to the the player's primary scripts. This is done in the patch file "/player.config.patch". Note: there's a nice tutorial on patch files on this very site.

    This is what the new "death_handler" Lua file looks like:
    Code:
    require "/stats/player_primary.lua"
    
    local oldApplyDamageRequest = applyDamageRequest
    
    function applyDamageRequest(damageRequest)
      response = oldApplyDamageRequest(damageRequest)
      sb.logInfo("response = %s", response)
       
      if next(response) ~= nil and response[1].hitType == "kill" then
      sb.logInfo("Player died.")
      --[[
      player.inventoryTags()
       
      entityId = world.spawnItem
      ( ItemDescriptor item,
      Vec2F position -- mcontroller.position() ?
      )
       
      -- Loop through each item and add it to the new container.
      world.containerAddItems(entityId, ItemDescriptor items)
       
      -- Loop through each item and remove it from the player's inventory.
      player.consumeTaggedItem(string tag, int count)
      --]]
      end
       
      return response
    end
    
    Basically, it's storing the old "applyDamageRequest" function before we overwrite it, and then call it within our new function, so that we aren't losing any of the vanilla functionality. After that, it's just writing some text to Starbound's log file. Within the (one and only) if statement that checks if the player has received a killing hit, I have a comment containing some pseudo code and the names of some functions I found that we may end up using. You can find some of the information for those functions on this site.

    Anyway, I've attached a zip folder containing a working mod of the current progress. It doesn't really do anything right now other than write some messages to the log file. But I figured this way you can play around with it yourself, if you like; or ask questions, or whatever. Or if someone else feels like giving their two-cents, they can. So, it's fairly rough so far, but it's definitely looking promising. Also, I called it "death_chest" for the moment, as I figured it would be easier to start with a chest, and then we can change it to a body later.

    Oh, also in the mod there is a file "/playermodes.config.patch". This file makes it so that the player doesn't spew all his items on death--which we don't want to happen anymore.

    Yeah, that might work. At least to the current character, anyway.
    I concur. It would make them more.. hm... lively.
     

    Attached Files:

    PabloM likes this.
  5. Zaakari

    Zaakari Pangalactic Porcupine

    Hmm... I was looking into this again, and discovered that the "player" table is not available within the context of our new "death_handler" script.
    So I'm not sure how we'll be able to get rid of the player's items.

    I guess the next step would be to try to find other mods that remove items from the player's inventory (apart from quests/interfaces). I don't suppose anyone knows of any off-hand?
     

Share This Page