1. Welcome to the Starbound support forums. Please check the support FAQs before posting: http://playstarbound.com/support

Got the dreaded invulnerable/no energy regeneration bug

Discussion in 'Starbound Support' started by jje64, Jul 18, 2019.

  1. jje64

    jje64 Phantasmal Quasar

    So I was playing, and out of nowhere I stop regenerating energy. Everything was going great, and then I came across some kind of flying lightning monster, he hit me a few times, and then he couldn't hit me anymore. I shot at him and then I couldn't shoot anymore. I tried uninstalling mods with no luck, and then looking in my logs I see this:

    [22:14:40.711] [Error] Exception while invoking lua function 'update'. (LuaException) Error code 2, [string "/stats/player_primary.lua"]:161: attempt to perform arithmetic on a nil value (field 'ouchCooldown')
    stack traceback:
    [C]: in metamethod '__sub'
    [string "/stats/player_primary.lua"]:161: in function <[string "/stats/player_primary.lua"]:151>
    0 starbound 0x0000000104152560 _ZN4Star13StarExceptionC2EPKcNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEE + 128
    1 starbound 0x000000010410c52e _ZN4Star9LuaEngine11handleErrorEP9lua_Statei + 862
    2 starbound 0x000000010440c4ba _ZN4Star9LuaEngine12callFunctionIJfEEENS_7VariantINS2_INS_5EmptyEJbxdNS_9LuaStringENS_8LuaTableENS_11LuaFunctionENS_9LuaThreadENS_11LuaUserDataEEEEJNS_11LuaVariadicIS9_EEEEEiDpRKT_ + 154
    3 starbound 0x000000010440c386 _ZNK4Star11LuaFunction6invokeINS_7VariantINS_5EmptyEJbxdNS_9LuaStringENS_8LuaTableES0_NS_9LuaThreadENS_11LuaUserDataEEEEJfEEET_DpRKT0_ + 54
    4 starbound 0x000000010440bf5c _ZN4Star16LuaBaseComponent6invokeINS_7VariantINS_5EmptyEJbxdNS_9LuaStringENS_8LuaTableENS_11LuaFunctionENS_9LuaThreadENS_11LuaUserDataEEEEJfEEENS_5MaybeIT_EERKNS_6StringEDpOT0_ + 268
    5 starbound 0x00000001043d5dfb _ZN4Star25LuaActorMovementComponentINS_21LuaUpdatableComponentINS_17LuaWorldComponentINS_16LuaBaseComponentEEEEEE6updateINS_7VariantINS_5EmptyEJbxdNS_9LuaStringENS_8LuaTableENS_11LuaFunctionENS_9LuaThreadENS_11LuaUserDataEEEEJfEEENS_5MaybeIT_EEDpOT0_ + 139
    6 starbound 0x000000010470aa9d _ZN4Star16StatusController10tickMasterEv + 2301
    7 starbound 0x00000001045917c1 _ZN4Star6Player6updateEy + 7985
    8 starbound 0x0000000104878e8a _ZNSt3__110__function6__funcIZN4Star11WorldClient6updateEvE3$_9NS_9allocatorIS4_EEFvRKNS_10shared_ptrINS2_6EntityEEEEEclESB_ + 42
    9 starbound 0x000000010430fe0e _ZN4Star9EntityMap17updateAllEntitiesERKNSt3__18functionIFvRKNS1_10shared_ptrINS_6EntityEEEEEENS2_IFbS7_S7_EEE + 350
    10 starbound 0x0000000104857a46 _ZN4Star11WorldClient6updateEv + 1542
    11 starbound 0x00000001047b4f06 _ZN4Star14UniverseClient6updateEv + 2294
    12 starbound 0x000000010403e34d _ZN4Star17ClientApplication13updateRunningEv + 2125
    13 starbound 0x000000010403bf1f _ZN4Star17ClientApplication6updateEv + 959
    14 starbound 0x0000000104b0aff1 _ZN4Star11SdlPlatform3runEv + 641
    15 starbound 0x0000000104b0ac44 _ZN4Star18runMainApplicationENSt3__110unique_ptrINS_11ApplicationENS0_14default_deleteIS2_EEEENS_10StringListE + 180
    16 starbound 0x0000000104042675 main + 85
    17 libdyld.dylib 0x00007fff7545a3d5 start + 1
    18 ??? 0x0000000000000001 0x0 + 1

    seeing that it's a problem with self.ouchcooldown in player_primary.lua, I unpacked my packed.pak file and looked at the offending lines of code -

    Code:
    function update(dt)
      local minimumFallDistance = 14
      local fallDistanceDamageFactor = 3
      local minimumFallVel = 40
      local baseGravity = 80
      local gravityDiffFactor = 1 / 30.0
    
      local curYPosition = mcontroller.yPosition()
      local yPosChange = curYPosition - (self.lastYPosition or curYPosition)
    
      self.ouchCooldown = math.max(0.0, self.ouchCooldown - dt)
    
      if self.fallDistance > minimumFallDistance and -self.lastYVelocity > minimumFallVel and mcontroller.onGround() then
        local damage = (self.fallDistance - minimumFallDistance) * fallDistanceDamageFactor
        damage = damage * (1.0 + (world.gravity(mcontroller.position()) - baseGravity) * gravityDiffFactor)
        damage = damage * status.stat("fallDamageMultiplier")
        status.applySelfDamageRequest({
            damageType = "IgnoresDef",
            damage = damage,
            damageSourceKind = "falling",
            sourceEntityId = entity.id()
          })
      end
    The line in the middle "self.ouchCooldown = math.max(0.0. self.ouchCooldown - dt)" appears to be where the problem is. Anyone have any clue how to fix this??

    Update: if anyone cares. I've seen others with this issue, and haven't seen any resolutions, so I'm documenting my troubleshooting efforts here. If anyone who actually knows what they're doing can chime in, I'd appreciate it.

    SO...
    I went into player_primary.lua and commented out all of the lines involving self.ouchCooldown. That worked, for a minute, but as soon as I got hit by an enemy, the game threw an exception and back to square one.

    I downloaded a clean copy of SB and I'm going to try replacing player.config and player_primary.lua and repacking the packed.pak file, and then removing the most recently added mod (nutrient bar maker & dependency library) and see if that makes a difference.

    I'm going to hazard a guess, and I only partially know what I'm talking about because my last coding experience was in VB6, C++ and VBA. My guess is that something isn't messing with self.ouchCooldown, so maybe somewhere in a mod someone accidentally used "dt" as a variable and left it global instead of making it private? Since "nutrient bar maker" is the last mod I installed, @Sock_Bunny , maybe?
    I dunno, I'm making guesses based on programming classes from 20 years ago. Again, if anyone actually knows what they're talking about and wants to chime in, I'd be appreciative.
     
    Last edited by a moderator: Jul 20, 2019
  2. Sock_Bunny

    Sock_Bunny Existential Complex

    NBM doesn't use dt variables and doesn't do anything with player.config (except from adding a recipe) or player_primary.lua

    are you using FU? what other mods do you have installed?
     
  3. jje64

    jje64 Phantasmal Quasar

    @Sock_Bunny No FU. Too complicated.

    I’ve got a bunch of other mods... but this only cropped up in the last day. I installed your mod (which is awesome) and also a refrigerated container mod.

    Does the error above mean anything to you? Any idea what might be happening?

    If anyone cares, I found the issue. It was the mod "wired teleporters". Not sure what was going wrong, but it broke starbound.
     
    Last edited by a moderator: Jul 20, 2019
    Sock_Bunny likes this.
  4. Sock_Bunny

    Sock_Bunny Existential Complex

    that's weird! I have a similar bug with that mod too, but it only happened when I had FU. so that's why I asked if you had it
    Basically, I was constantly immortal and couldn't drain energy
     
  5. jje64

    jje64 Phantasmal Quasar

    I had the same issue. I’m going to pick through the code on it later and see if I can figure out where the conflict is.
     
  6. Iris Blanche

    Iris Blanche Pudding Paradox Forum Moderator

    Hey, please avoid double posts in the future. I merged them for you.

    Also always provide your full log when asking for support. With only a small piece of it (which might even miss necessary information) it is extremly hard to pinpoint the problem, if even possible at all.
     
  7. Catherine Franz

    Catherine Franz Spaceman Spiff

    Remove F.U. = problem solved...

    No F.U.? = try commiting SUDOKU (commit not alive)
     

Share This Page