Modding Help im making a functional parachute but i dont know the slow fall stat

Discussion in 'Starbound Modding' started by amirmiked12, Mar 29, 2017.

  1. amirmiked12

    amirmiked12 Parsec Taste Tester

    im making a functional parachute but i dont know the slow fall stat
    can u guyz tell me the state name that i wanna add to op add statuseffect or something similar ?
     
  2. Cyel

    Cyel Scruffy Nerf-Herder

    You could use "lowgrav", "lowgravaugment" or "staffslow", which already exist and could somewhat do what you want; but they modify the whole gravity.

    Otherwise, this, which is a status-effect adapted from the parasol item, "slowfall":
     

    Attached Files:

    amirmiked12 likes this.
  3. bk3k

    bk3k Oxygen Tank

    You're right, we do need a hang glider (vehicle). Wait... that's now what you actually meant? Fine then.

    Besides using what statuses exist, you can make your own of course. "staffslow" affects maybe more than you'd want? It affects some movement parameters. I think it would seem rather unnaturally behaving in low-g or no-g environments. Parachutes won't slow your fall
    1. when you aren't falling very fast to start with.
    2. when there is a lack of atmosphere

    I would ask is this a back item? Or an active item you have to activate? For an active item, I wouldn't bother with a status, but just do it in the item's own script. Or maybe this is a tech?

    Either way I personally would favor this function
    mcontroller.controlApproachYVelocity
    first argument is what target velocity you want. Since you're falling, this would be a negative number
    second argument is the force applied towards altering your velocity(closer to this number).

    Using that means you don't just slow down all at once. You can gradually (but relatively quickly) slow down in a way that seems natural for a parachute. So I'm thinking this for example.
    Code:
    parachute_effect = function()
      --vanilla fall damage won't start to calculate fall distance
      --until the yVelocity is -40 or faster
      local yVelocity = mcontroller.yVelocity()
      local idealSpeed = -30
        --play around with this value
      local gravity = world.gravity( mcontroller.position() )
      local maxForce = 200
        --could use tinkering
        --maybe loaded by config.getParamater instead of fixed value
          --that way you could have larger chutes that help more with higher gravity/higher masses.
      local forceMultiplier = 3
        --value could also be tinkered with
      local force = math.min(gravity * forceMultiplier, maxForce)
    
      if yVelocity < idealSpeed and is_atmosphere() then
        mcontroller.controlApproachYVelocity(idealSpeed, force)
      end
    end
    
    
    is_atmosphere = function()
      local environmentStatusEffects = world.getProperty("environmentStatusEffects") or {}
      for _, effect in ipairs(environmentStatusEffects) do
        if effect == "biomeairless" then
          return false
        end
      end
      return true
    end
    
    Instead of gravity, something like the difference in fall speed versus ideal fall speed could be used. In which case that multiplier would probably be larger. And of course you don't need to use that code. It probably works, but is mainly intended as concept code to demonstrate the idea itself.

    edit:
    I forgot something relevant.
    Code:
    windPush = world.windLevel( mcontroller.position() )
    Because the parachutes work off air resistance but essentially you have a sail turned 90 degrees. You'd be extra vulnerable to wind gusts. Let me revise that code

    Code:
    parachute_effect = function()
      if not is_atmosphere() then
        return
      end
      --vanilla fall damage won't start to calculate fall distance
      --until the yVelocity is -40 or faster
      local position = mcontroller.position()
      local velocity = mcontroller.velocity()
      local ideal_fallSpeed = -30
        --play around with this value
      local windPush = world.windLevel( position ) or 0
      local gravity = world.gravity( position )
      local maxForce = 200
        --could use tinkering
        --maybe loaded by config.getParamater instead of fixed value
          --that way you could have larger chutes that help more with higher gravity/higher masses.
      local forceMultiplier = 3
        --value could also be tinkered with
      
      local force = {
        windpush * forceMultiplier,
        (velocity[2] < ideal_fallSpeed) and math.min(gravity * forceMultiplier, maxForce) or 0
      }
    
      local idealVelocity = {
        velocity[1] + windpush,
        math.max(velocity[2], ideal_fallSpeed)
      }
    
      mcontroller.approachVelocity(idealVelocity, force)
    end
    
    
    is_atmosphere = function()
      local environmentStatusEffects = world.getProperty("environmentStatusEffects") or {}
      for _, effect in ipairs(environmentStatusEffects) do
        if effect == "biomeairless" then
          return false
        end
      end
      return true
    end
    
     
    Last edited: Mar 30, 2017
    Cyel and amirmiked12 like this.
  4. amirmiked12

    amirmiked12 Parsec Taste Tester

    I heard in the earlier versions of starbound there was a functional parachute that allows u to glide.but I just dont know why Chuckfish is deleting good features from the game
     
  5. amirmiked12

    amirmiked12 Parsec Taste Tester

    oh tnx i wanted to make a back item that is a parachute that saves u from falling
     
  6. bk3k

    bk3k Oxygen Tank

    I might look for this later. I have old assets dating back to Enraged Koala.
     

Share This Page