mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Added lag compensation to Arena
This commit is contained in:
parent
01b2cc2997
commit
37862cf6d5
3 changed files with 49 additions and 31 deletions
|
|
@ -108,41 +108,46 @@ function mario_local_hammer_check(m)
|
||||||
local m2 = gMarioStates[i]
|
local m2 = gMarioStates[i]
|
||||||
local np2 = gNetworkPlayers[i]
|
local np2 = gNetworkPlayers[i]
|
||||||
local s2 = gPlayerSyncTable[i]
|
local s2 = gPlayerSyncTable[i]
|
||||||
if s2.item == ITEM_HAMMER and mario_hammer_is_attack(m2.action) and passes_pvp_interaction_checks(m2, m) ~= 0 and global_index_hurts_mario_state(np2.globalIndex, m) then
|
if passes_pvp_interaction_checks(m2, m) ~= 0 then
|
||||||
local pos = mario_hammer_position(m2)
|
network_player_local_set_lag_state(np2)
|
||||||
local dist = vec3f_dist(pos, m.pos)
|
if s2.item == ITEM_HAMMER and mario_hammer_is_attack(m2.action) and passes_pvp_interaction_checks(m2, m) ~= 0 and global_index_hurts_mario_state(np2.globalIndex, m) then
|
||||||
if dist <= 165 then
|
local pos = mario_hammer_position(m2)
|
||||||
local yOffset = 100
|
local dist = vec3f_dist(pos, m.pos)
|
||||||
if m2.action == ACT_JUMP_KICK then
|
if dist <= 165 then
|
||||||
yOffset = yOffset + 100
|
local yOffset = 100
|
||||||
end
|
if m2.action == ACT_JUMP_KICK then
|
||||||
|
yOffset = yOffset + 100
|
||||||
|
end
|
||||||
|
|
||||||
local vel = {
|
local vel = {
|
||||||
x = m.pos.x - m2.pos.x,
|
x = m.pos.x - m2.pos.x,
|
||||||
y = (m.pos.y + yOffset) - m2.pos.y,
|
y = (m.pos.y + yOffset) - m2.pos.y,
|
||||||
z = m.pos.z - m2.pos.z,
|
z = m.pos.z - m2.pos.z,
|
||||||
}
|
}
|
||||||
vec3f_normalize(vel)
|
vec3f_normalize(vel)
|
||||||
vec3f_mul(vel, 75 + 70 * (1 - mario_health_float(m)))
|
vec3f_mul(vel, 75 + 70 * (1 - mario_health_float(m)))
|
||||||
|
|
||||||
set_mario_action(m, ACT_BACKWARD_AIR_KB, 0)
|
network_player_local_restore_lag_state()
|
||||||
m.invincTimer = 30
|
set_mario_action(m, ACT_BACKWARD_AIR_KB, 0)
|
||||||
m.knockbackTimer = 10
|
m.invincTimer = 30
|
||||||
m.vel.x = vel.x
|
m.knockbackTimer = 10
|
||||||
m.vel.y = vel.y
|
m.vel.x = vel.x
|
||||||
m.vel.z = vel.z
|
m.vel.y = vel.y
|
||||||
m.faceAngle.y = atan2s(vel.z, vel.x) + 0x8000
|
m.vel.z = vel.z
|
||||||
s2.ammo = s2.ammo - 1
|
m.faceAngle.y = atan2s(vel.z, vel.x) + 0x8000
|
||||||
|
s2.ammo = s2.ammo - 1
|
||||||
|
|
||||||
send_arena_hammer_hit(np.globalIndex, np2.globalIndex)
|
send_arena_hammer_hit(np.globalIndex, np2.globalIndex)
|
||||||
e.lastDamagedByGlobal = np2.globalIndex
|
e.lastDamagedByGlobal = np2.globalIndex
|
||||||
|
|
||||||
if m2.action == ACT_PUNCHING or m2.action == ACT_MOVE_PUNCHING or m2.action == ACT_GROUND_POUND then
|
if m2.action == ACT_PUNCHING or m2.action == ACT_MOVE_PUNCHING or m2.action == ACT_GROUND_POUND then
|
||||||
m.hurtCounter = 12
|
m.hurtCounter = 12
|
||||||
else
|
else
|
||||||
m.hurtCounter = 8
|
m.hurtCounter = 8
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
network_player_local_restore_lag_state()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,15 @@ function bhv_arena_bobomb_init(obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
function bhv_arena_bobomb_intersects_player(obj, m, pos, radius)
|
function bhv_arena_bobomb_intersects_player(obj, m, pos, radius)
|
||||||
|
local ownerNp = network_player_from_global_index(obj.oArenaBobombGlobalOwner)
|
||||||
|
network_player_local_set_lag_state(ownerNp)
|
||||||
|
|
||||||
local mPos1 = { x = m.pos.x, y = m.pos.y + 50, z = m.pos.z }
|
local mPos1 = { x = m.pos.x, y = m.pos.y + 50, z = m.pos.z }
|
||||||
local mPos2 = { x = m.pos.x, y = m.pos.y + 150, z = m.pos.z }
|
local mPos2 = { x = m.pos.x, y = m.pos.y + 150, z = m.pos.z }
|
||||||
return (vec3f_dist(pos, mPos1) < radius or vec3f_dist(pos, mPos2) < radius)
|
local ret = (vec3f_dist(pos, mPos1) < radius or vec3f_dist(pos, mPos2) < radius)
|
||||||
|
|
||||||
|
network_player_local_restore_lag_state()
|
||||||
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
function bhv_arena_bobomb_expode(obj)
|
function bhv_arena_bobomb_expode(obj)
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,18 @@ function bhv_arena_cannon_ball_init(obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
function bhv_arena_cannon_ball_intersects_local(obj, pos)
|
function bhv_arena_cannon_ball_intersects_local(obj, pos)
|
||||||
|
|
||||||
|
local ownerNp = network_player_from_global_index(obj.oArenaBobombGlobalOwner)
|
||||||
|
network_player_local_set_lag_state(ownerNp)
|
||||||
|
|
||||||
local m = gMarioStates[0]
|
local m = gMarioStates[0]
|
||||||
local mPos1 = { x = m.pos.x, y = m.pos.y + 50, z = m.pos.z }
|
local mPos1 = { x = m.pos.x, y = m.pos.y + 50, z = m.pos.z }
|
||||||
local mPos2 = { x = m.pos.x, y = m.pos.y + 150, z = m.pos.z }
|
local mPos2 = { x = m.pos.x, y = m.pos.y + 150, z = m.pos.z }
|
||||||
local radius = clamp(obj.oArenaCannonBallSize * 250, 75, 250)
|
local radius = clamp(obj.oArenaCannonBallSize * 250, 75, 250)
|
||||||
return (vec3f_dist(pos, mPos1) < radius or vec3f_dist(pos, mPos2) < radius)
|
local ret = (vec3f_dist(pos, mPos1) < radius or vec3f_dist(pos, mPos2) < radius)
|
||||||
|
|
||||||
|
network_player_local_restore_lag_state()
|
||||||
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
function bhv_arena_cannon_ball_loop(obj)
|
function bhv_arena_cannon_ball_loop(obj)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue