add ' button to spectate closest player to cursor, adjust spectate camera speed to be less jarring

This commit is contained in:
bgkillas 2024-11-23 23:55:00 -05:00
parent 4c6abf6424
commit 91c3f20747
2 changed files with 18 additions and 2 deletions

View file

@ -161,11 +161,11 @@ local function target()
end end
if GameGetIsGamepadConnected() then if GameGetIsGamepadConnected() then
mx, my = InputGetJoystickAnalogStick(0, 1) mx, my = InputGetJoystickAnalogStick(0, 1)
mx, my = mx * 256 + to_x, my * 256 + to_y mx, my = mx * 200 + to_x, my * 200 + to_y
else else
mx, my = DEBUG_GetMouseWorld() mx, my = DEBUG_GetMouseWorld()
end end
local t_x, t_y = to_x + (mx - to_x) / 3 , to_y + (my - to_y) / 3 local t_x, t_y = to_x + (mx - to_x) / 5 , to_y + (my - to_y) / 5
local dx, dy = t_x - my_x, t_y - my_y local dx, dy = t_x - my_x, t_y - my_y
local di = dx * dx + dy * dy local di = dx * dx + dy * dy
if di > 512 * 512 then if di > 512 * 512 then
@ -337,6 +337,13 @@ function spectate.on_world_update()
elseif InputIsKeyJustDown(tonumber(ModSettingGet("quant.ew.rebind_sspectate"))) then elseif InputIsKeyJustDown(tonumber(ModSettingGet("quant.ew.rebind_sspectate"))) then
camera_player_id, camera_player = get_me() camera_player_id, camera_player = get_me()
re_cam = true re_cam = true
elseif InputIsKeyJustDown(tonumber(ModSettingGet("quant.ew.rebind_mspectate"))) then
local mx, my = DEBUG_GetMouseWorld()
local ent = EntityGetClosestWithTag(mx, my, "ew_peer")
camera_player = player_fns.get_player_data_by_local_entity_id(ent)
camera_player_id = camera_player.peer_id
update_i()
re_cam = true
end end
set_camera_pos() set_camera_pos()
ctx.spectating_over_peer_id = camera_player_id ctx.spectating_over_peer_id = camera_player_id

View file

@ -135,6 +135,15 @@ local function build_settings()
is_waiting_for_input = false, is_waiting_for_input = false,
scope = MOD_SETTING_SCOPE_RUNTIME, scope = MOD_SETTING_SCOPE_RUNTIME,
}, },
{
id = "rebind_mspectate",
ui_name = "spectate near Button",
ui_description = "self.",
value_default = "52",
ui_fn = ui_get_input,
is_waiting_for_input = false,
scope = MOD_SETTING_SCOPE_RUNTIME,
},
}, },
}, },
} }