Modding Help So...what causes you to "drown" when buried alive?

Discussion in 'Starbound Modding' started by BlueLeafeon, Oct 31, 2016.

  1. BlueLeafeon

    BlueLeafeon Cosmic Narwhal

    It has come to my attention that my Playable Cat mod apparently starts losing oxygen when in a space less than for tiles tall. The only thing I can think of to cause this is that the game thinks the cat is "buried," despite the collision boxes being sufficiently small enough to allow entry in 2-tile-high space.

    While this won't be much of a big deal once an EPP is obtained, it kind of is for the first few hours of gameplay, so I kind of want to fix it. But I have no idea of where to look. Any ideas?
     
  2. lazarus78

    lazarus78 The Waste of Time

    Probably a hard coded mechanic to use the upper portion of the default character space for testing if you are "underwater".
     
  3. BlueLeafeon

    BlueLeafeon Cosmic Narwhal

    Probably.

    I've done some searching around, and there's this in the player _primary.lua:
    Code:
     local mouthPosition = vec2.add(mcontroller.position(), status.statusProperty("mouthPosition"))
      if status.statPositive("breathProtection") or world.breathable(mouthPosition) then
      status.modifyResource("breath", status.stat("breathRegenerationRate") * dt)
      else
      status.modifyResource("breath", -status.stat("breathDepletionRate") * dt)
      end
    
    If I'm understanding this correctly, the mouth's position is where it decides whether or not to apply the suffocation status effect...

    But I've altered the catoid file so that the mouth is located at 0, -20 (same as the feet) and I'm still getting this issue.
    Code:
     "mouthOffset" : [0, -20],
      "feetOffset" : [0, -20],
     
  4. bk3k

    bk3k Oxygen Tank

    Your offset might not be correct to solve the problem.

    The question being what location does mcontroller.position() return?
    bottom of the bound box, center of the bound box(by actual calculation), or perhaps bottom of bound box + [0, 2] (assumed 4 tile height)
    so do this to find out. Make a dummy tech to get info that you can trigger at will. When it triggers(however you decide to do that) -
    Code:
    local pos = mcontroller.position()
    sb.logInfo("\nmcontroller.position() returned (" .. tostring(pos[1]) .. ", " .. tostring(pos[2]) .. ")\n)
    Go into debug mode so you can see the exact coordinates of your cursor(pointing at your mouth) and activate the tech. Then look at your log and do the math to determine the correct mouth offset.
     
  5. Chofranc

    Chofranc Pangalactic Porcupine

    "mouthOffset" : [0, -20], from my testing is for the position of the dialog cloud in the head of the character.

    In the player.config there is a parameter called mouthposition:

    "statusProperties" : {
    "targetMaterialKind" : "organic",
    "mouthPosition" : [0, 0.75],
    "breathHealthPenaltyPercentageRate" : 0.05,
    "hitInvulnerabilityThreshold" : 0.1,
    "hitInvulnerabilityTime" : 1,
    "hitInvulnerabilityFlash" : 0.15,
    "shieldHitInvulnerabilityTime" : 1.0,
    "damageFlashOnDirectives" : "",
    "damageFlashOffDirectives" : "multiply=ffffff00=0.85"
    }

    It can be changed through lua, attach this lua script in the status effect value in your .specie file, and in that lua add this code.

    Code:
    function init()
         status.setStatusProperty("mouthPosition", {0,0.75})
          script.setUpdateDelta(0)
    end
    The 0.75 is the Y axis, that value is the one that you need to change, 0.75 is the vanilla value,lower it in small quantities until your race don't suffocate under tiles, that will be your max value, then you must test this value under water to check if your race can breath well at the limit, for example if there is 1 tile free between the water and the roof while you are swimming, if you begin to suffocate then you need to lower the value.

    My race for example is 3 tiles tall, 1 tile shorter than vanilla races, from my testing, the max value that i can set up so my race doesn't start suffocating is at 0.49, but under water this value didn't work well, for example with 1 tile free between the water and the roof i began to suffocate which shouldn't happen since there is enough space to breath, so i lower it in small quantities until i get a value that suits my needs that was of 0.10.

    Edit: I didn't noticed that i have this problem too xD, since my race have breathProtection as passive.

    In multiplayer i don't know if is used only a global player.config or if there is one for every client connected to the server and if they can be different with each other without affecting the other.
     
    Last edited: Nov 7, 2016

Share This Page