Modding Help [Solved] I have a little gravity problem...

Discussion in 'Starbound Modding' started by MetaFace, Feb 14, 2017.

  1. MetaFace

    MetaFace Guest

    So this to me makes no sense why it doesn't work, I have a set of armor that is supposed to reduce fall damage but now no matter what (even with admin off and no armor) you take no fall damage, I changed no values in the player.config or the player_primary.

    My first attempt was to change the fall multiplier directly with the armor, then I changed it to be like my 'energyInhibit' stat, which works, but I still can't take fall damage.

    What did I do?
    Code:
    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.stat("fallProtection"))
        status.applySelfDamageRequest({
            damageType = "IgnoresDef",
            damage = damage,
            damageSourceKind = "falling",
            sourceEntityId = entity.id()
          })
      end
    no values where altered except where I added this 'fallProtection' stat.
     
  2. Inf_Wolf14

    Inf_Wolf14 Parsec Taste Tester

    So is this segment a script attached to the armor or a status applied to the armor?
    Each case, anyhow, changes the answer.
     
  3. MetaFace

    MetaFace Guest

    It's applied via armor, I don't know if the game is refusing to remove the effect when I take the armor off, or I'm dumb. (latter)

    Here is the part of the armor that does this...
    Code:
    {
          "levelFunction" : "baseArmorLevelgravityMultiplier",
          "stat" : "fallProtection",
          "amount" : 1.0
        }
    basically it is supposed to subtract fallProtection from the fallDamageMultiplier. This isn't working though, when I remove the armor I still don't take fall damage. I need to do something special to remove the effect don't I?
     
  4. Inf_Wolf14

    Inf_Wolf14 Parsec Taste Tester

    If the effect is being applied as a persistent effect, yes. There is a function to clear persistent effects if you check around a tiny bit.

    If not, you can still create a small portion in the armor's uninit() that manually sets the values to normal if not resetting them proper.
     
  5. MetaFace

    MetaFace Guest

    Wait a minute... my armor is using the wrong script... it's using a script which by game standards doesn't exist, using the experimental player_mod.lua file I made, I need to check that.
     
    Inf_Wolf14 likes this.
  6. The | Suit

    The | Suit Agent S. Forum Moderator

    I would also double check the math and confirm it produces an accurate number.

    put an sb.loginfo in there to check the actual outputs.
     
    MetaFace likes this.
  7. MetaFace

    MetaFace Guest

    Right. I'll do that once I get back on my home computer.
     
  8. bk3k

    bk3k Oxygen Tank

    Code:
    damage = damage * (status.stat("fallDamageMultiplier") - status.stat("fallProtection"))
    The math is indeed wrong. You're taking the multiplier - the "fallProtection" stat.
    You have that stat at 1.0
    1 - 1 = 0
    so damage = damage * 0

    And also I don't know how you are going about implementation, but I'll suggest the method I provided to author of the "No fall damage" and "Reduced fall damage" mod author. You can read that here. In particular look at the reduced fall damage section.

    Code:
      if damageRequest.damageSourceKind == "falling" and damageRequest.damage ~= 0 then 
        damageRequest.damage = damageRequest.damage / 3
      end
    
    Because of the way update is crafted, I think hooking applyDamageRequest at the front end - then calling the original(or the next hook in line) - makes more sense. I'm basically checking the incoming damage type, and if what I'm looking for, I do math on damageRequest.damage before passing it on.
     
    Last edited: Feb 14, 2017
  9. MetaFace

    MetaFace Guest

    'fallProtection' is a stat applied by armor, default on character is zero, so by logic I thought when armor is removed that it'd go back to zero, but I can't confirm until I fix the scripting problem listed above (where I accidentally had the wrong script hooked to the armor).
     
  10. MetaFace

    MetaFace Guest

    Ok, everyone slow their roll. I figured it out, it was really simple and dumb. For some reason the fall damage factor was set to zero instead of three, everything else works as intended, even the armor (which this one is supposed to eliminate fall damage completely when worn). Thanks for trying to help, but it turns out I'm just dumb.

    Opening a new thread right now to solve my next issue with this armor...
     
    Inf_Wolf14 likes this.
  11. The | Suit

    The | Suit Agent S. Forum Moderator

    Using sb.loginfo liberally when writing scripts is always best way to check parameters.
    That way you never take any value for granted.

    You can always comment out sb logs after you confirm,
     
    bk3k likes this.
  12. MetaFace

    MetaFace Guest

    I guess so, but I didn't understand the sb.logInfo command at first, so I just tested what was needed, kinda like that though.
     

Share This Page