local drop_speed = FRACUNIT * 1030 / 100

local function Dropdash_Initialize(player)
  local mobj = player.mo
  player.OpenTricks.Dropdash_Falltime = 0
  player.OpenTricks.Dropdash_Lastfalltime = 0
end

local function Dropdash_Thinker(player)
  local mobj = player.mo
  
  player.OpenTricks.Dropdash_Lastfalltime = player.OpenTricks.Dropdash_Falltime
  
  if P_IsObjectOnGround(mobj)
	player.OpenTricks.Dropdash_Falltime = 0
  elseif player.OpenTricks.combo -- if was in the air and had any combo...
    player.OpenTricks.Dropdash_Falltime = $ + 1
  end
end

local function Dropdash_Success(player)
  local mobj = player.mo
  if (mobj.flags2 & MF2_OBJECTFLIP)
    mobj.momz = max(0, $) + drop_speed * player.OpenTricks.combo
  else
    mobj.momz = min(0, $) - drop_speed * player.OpenTricks.combo
  end
end

local function Dropdash_Landing(player)
  local mobj = player.mo
  S_StartSound(mobj, sfx_s23c)
  player.kartstuff[k_startboost] = $ + ((30 + player.OpenTricks.Dropdash_Lastfalltime) * (player.OpenTricks.combo ^ 2))
end

OPENTRICKS_ADD("dropdash", "fall hard, go fast", "TRXTGN3", "TRXTGN4", false, Dropdash_Initialize, Dropdash_Thinker, Dropdash_Success, Dropdash_Landing)