bring stuff

This commit is contained in:
2026-03-12 18:23:18 +03:00
parent 6185b99ca1
commit bd1cffdf7d
5 changed files with 94 additions and 16 deletions

View File

@@ -9,24 +9,27 @@ local PLAYER_PHYS_RUN_SPEED_MUL = 1.4
local PLAYER_PHYS_MOVE_SPEED_EXP = 1.0
local PLAYER_PHYS_FLY_SPEED_EXP = 4.0
local AIR_CONTROL = 0.2
local PLAYER_OFFSET_Y = 0.5
-- игрок
actor_player = inherit_table(actor_base)
actor_player.m_camera_offset_y = 0.5
actor_player.m_camera_offset_y = PLAYER_OFFSET_Y
function actor_player:on_init()
actor_base.on_init(self)
g_player = self
self.m_bobbing = 0.0
self:create_player_body(PLAYER_PHYS_RADIUS, PLAYER_PHYS_HEIGHT - PLAYER_PHYS_RADIUS * 2.0, 80.0, 0.0, 0.0)
self:activate_camera()
local ent = engine.create_entity("weapon_ump")
engine.add_entity_to_world(ent)
self.m_weapon_entity_id = ent:get_id()
--local ent = engine.create_entity("weapon_ump")
--engine.add_entity_to_world(ent)
--self.m_weapon_entity_id = ent:get_id()
--engine.play_sound_3d("data/sounds/test/test_music_64Kbps.mp3", 0.0, 0.0, 0.0)
end
@@ -48,28 +51,62 @@ function actor_player:on_update(dt)
self:update_player_movement(dt)
local ent = engine.get_entity_from_id(self.m_weapon_entity_id)
ent:set_relative_position_to_camera(self)
--local ent = engine.get_entity_from_id(self.m_weapon_entity_id)
--ent:set_relative_position_to_camera(self)
self:action_update()
end
function actor_player:action_update()
local action = self:get_action()
if action == ACTION_USE then
self:on_use_action()
end
local ent = engine.get_entity_from_id(self.m_weapon_entity_id)
if ent then
if action == ACTION_FIRE then
ent:set_state(WEAPON_FSM_STATE_ATTACK)
elseif action == ACTION_RELOAD then
ent:set_state(WEAPON_FSM_STATE_RELOAD)
--local ent = engine.get_entity_from_id(self.m_weapon_entity_id)
--if ent then
-- if action == ACTION_FIRE then
-- ent:set_state(WEAPON_FSM_STATE_ATTACK)
-- elseif action == ACTION_RELOAD then
-- ent:set_state(WEAPON_FSM_STATE_RELOAD)
-- end
--end
end
function actor_player:on_use_action()
local front_x, front_y, front_z = camera.get_front()
local ray_x, ray_y, ray_z = camera.get_position()
ray_x = ray_x + front_x
ray_y = ray_y + front_y
ray_z = ray_z + front_z
local ray_end_x, ray_end_y, ray_end_z = camera.get_position()
ray_end_x = ray_end_x + front_x * 1000
ray_end_y = ray_end_y + front_y * 1000
ray_end_z = ray_end_z + front_z * 1000
local trace = engine.trace_ray(ray_x, ray_y, ray_z, ray_end_x, ray_end_y, ray_end_z, self)
if trace.hit then
local traced_ent = engine.get_entity_from_id(trace.entity_id)
if traced_ent then
local classname = traced_ent:get_classname()
put_debug_string_to_screen(string.format("actor_player:on_use_action: %s", traced_ent:get_classname()), 1)
end
end
end
function actor_player:update_camera_bobbing(dt)
local vel_x, vel_y, vel_z = self:get_velocity()
self.m_bobbing = self.m_bobbing + dt
end
function actor_player:update_player_movement(dt)
local movement = self:get_movement()
local speed = 4.0
local speed = 2.5
local up_x, up_y, up_z = camera.get_up()
local front_x, front_y, front_z = camera.get_front()