when notplayer, have camera on alive player. decrease notplayer boss hp bar to when he can see you, make notplayer teleportation logic a bit better

This commit is contained in:
bgkillas 2024-08-17 20:50:50 -04:00
parent 444dff3b06
commit b464490639
4 changed files with 64 additions and 15 deletions

View file

@ -282,7 +282,7 @@ local player_fns = {
local up = ComponentGetValue2(controls, "mButtonDownUp") -- boolean
local down = ComponentGetValue2(controls, "mButtonDownDown") -- boolean
local jump = ComponentGetValue2(controls, "mButtonDownJump") -- boolean
local fly = ComponentGetValue2(controls, "mButtonDownFly") -- boolean
local fly = false -- boolean
local leftClick = ComponentGetValue2(controls, "mButtonDownLeftClick") -- boolean
local rightClick = ComponentGetValue2(controls, "mButtonDownRightClick") -- boolean
local aim_x, aim_y = ComponentGetValue2(controls, "mAimingVector") -- float, float

View file

@ -55,6 +55,7 @@ local function player_died()
-- We kinda need to wait a frame for things to update.
async(function ()
wait(1)
GameSetCameraFree(true)
GameAddFlagRun("ew_flag_notplayer_active")
EntitySetName(ctx.my_player.entity, ctx.my_player.name.."?")
do_switch_effect()
@ -191,6 +192,7 @@ ctx.cap.health = {
async(function ()
wait(1)
do_switch_effect()
GameSetCameraFree(false)
end)
else
end_poly_effect(ctx.my_player.entity)

View file

@ -616,7 +616,7 @@
<InventoryGuiComponent/>
<BossHealthBarComponent gui_max_distance_visible="1500" gui="1"/>
<BossHealthBarComponent gui_max_distance_visible="512" gui="1"/>
<LuaComponent _tags="ew_remove_on_send" script_wand_fired = "mods/quant.ew/files/resource/cbs/count_times_wand_fired.lua"/>
</Entity>
</Entity>

View file

@ -155,20 +155,20 @@ local function choose_movement()
end
local function position_to_area_number(y)
if y < 1104 then
local function position_to_area_number(x, y)
if y < 1199 then
return 1
elseif y < 2640 then
elseif y < 2735 then
return 2
elseif y < 4688 then
elseif y < 4783 then
return 3
elseif y < 6224 then
elseif y < 6319 then
return 4
elseif y < 8272 then
elseif y < 8367 then
return 5
elseif y < 10320 then
elseif y < 10415 then
return 6
elseif y < 12880 then
elseif y < 12975 and (x < 2726 or x > 4135 or y < 12800) then
return 7
else
return 8
@ -234,9 +234,9 @@ local function teleport_to_next_hm()
return
end
if peer_id == ctx.my_id then
my_area_num = position_to_area_number(y)
my_area_num = position_to_area_number(x, y)
elseif is_suitable_target(player) then
local area_num = position_to_area_number(y)
local area_num = position_to_area_number(x, y)
if area_num < others_area_num then
others_area_num = area_num
end
@ -247,6 +247,40 @@ local function teleport_to_next_hm()
end
end
local camera_player = 1
local function set_camera_pos()
if camera_player < 1 then
camera_player = 1
end
local i = 0
local cam_target = nil
for _, potential_target in pairs(ctx.players) do
local entity = potential_target.entity
if is_suitable_target(entity) then
i = i + 1
if i == camera_player then
cam_target = entity
end
end
end
if i ~= 0 and i < camera_player then
camera_player = i
set_camera_pos()
end
if cam_target ~= nil then
local t_x, t_y = EntityGetFirstHitboxCenter(cam_target)
if t_x == nil then
t_x, t_y = EntityGetTransform(cam_target)
end
GameSetCameraPos(t_x, t_y)
end
end
local left_held = false
local right_held = false
local function update()
-- No taking control back, even after pressing esc.
ComponentSetValue2(state.control_component, "enabled", false)
@ -290,7 +324,6 @@ local function update()
end
end
end
local do_kick = last_length ~= nil and last_length < 100
if do_kick then
@ -330,6 +363,21 @@ local function update()
teleport_to_next_hm()
end
if ComponentGetValue2(state.control_component, "mButtonDownLeftClick") then
if not left_held then
camera_player = camera_player - 1
left_held = true
end
elseif ComponentGetValue2(state.control_component, "mButtonDownRightClick") then
if not right_held then
camera_player = camera_player + 1
right_held = true
end
else
left_held = false
right_held = false
end
set_camera_pos()
end
function module.on_world_update()
@ -344,5 +392,4 @@ function module.on_world_update()
end
end
return module