Arena - allow air control when launching from spring

This commit is contained in:
MysterD 2023-06-22 11:21:33 -07:00
parent ec876be1b5
commit 7dbe045957
3 changed files with 29 additions and 0 deletions

View file

@ -15,6 +15,7 @@ for i = 0, (MAX_PLAYERS - 1) do
e.prevHurtCounter = 0
e.levelTimer = 0
e.levelTimerLevel = 0
e.springing = 0
local s = gPlayerSyncTable[i]
s.item = ITEM_NONE
@ -318,6 +319,14 @@ function on_set_mario_action(m)
e.rotFrames = 0
end
if m.playerIndex == 0 and is_player_active(m) ~= 0 then
if (m.action & ACT_FLAG_AIR) == 0 then
if e.springing == 1 then
e.springing = 0
end
end
end
if s.item == ITEM_HAMMER then
mario_hammer_on_set_action(m)
end
@ -450,6 +459,11 @@ function mario_update(m)
m.marioBodyState.modelState = MODEL_STATE_METAL
end
-- allow yaw change on springing
if e.springing == 1 then
m.faceAngle.y = m.intendedYaw - approach_s32(convert_s16(m.intendedYaw - m.faceAngle.y), 0, 0x400, 0x400)
end
-- update player items
if s.item == ITEM_HAMMER then
mario_hammer_update(m)

View file

@ -90,8 +90,11 @@ function bhv_arena_spring_launch(obj)
set_mario_action(m, ACT_TRIPLE_JUMP, 0)
m.vel.y = vel.y
m.forwardVel = 0
local e = gMarioStateExtras[0]
e.springing = 1
end
obj.oArenaSpringSprung = 15
network_send_object(obj, false)
end

View file

@ -24,6 +24,18 @@ function clamp(val, min, max)
return val
end
function convert_s16(num)
local min = -32768
local max = 32767
while (num < min) do
num = max + (num - min)
end
while (num > max) do
num = min + (num - max)
end
return num
end
function mario_health_float(m)
return clamp((m.health - 255) / (2176 - 255), 0, 1)
end