This commit is contained in:
2026-03-05 15:20:18 +03:00
parent 70c3459703
commit f8f69d3b88
25 changed files with 261 additions and 31 deletions

View File

@@ -1,6 +1,8 @@
-- игрок
actor_player = inherit_table(actor_base)
actor_player.m_camera_offset_y = 0.5
function actor_player:on_init()
actor_base.on_init(self)
@@ -14,7 +16,7 @@ function actor_player:on_init()
self.m_weapon_entity_id = ent:get_id()
self.m_in_reload = false
--local ent2 = engine.get_entity_from_id(self.m_weapon_entity_id)
--console.print(ent2:get_classname())
end
@@ -35,14 +37,15 @@ function actor_player:on_update(dt)
if self:get_action() == ACTION_FIRE and self.m_in_reload == false then
ent:play_animation(ent:find_animation("shoot1"), ANIM_PLAYBACK_NONE)
engine.play_sound("data/sounds/weapons/ump45_shoot.wav")
end
if self:get_action() == ACTION_RELOAD and self.m_in_reload == false then
ent:play_animation(ent:find_animation("reload"), ANIM_PLAYBACK_NONE)
self.m_in_reload = true
engine.play_sound("data/sounds/weapons/ump45_reload.wav")
self.m_in_reload = true
end
if ent:get_current_animation() == ent:find_animation("shoot1") and
ent:get_current_animation_time() >= ent:get_animation_time(ent:find_animation("shoot1")) then
ent:play_animation(ent:find_animation("idle1"), ANIM_PLAYBACK_REPEAT)
@@ -61,7 +64,3 @@ end
function actor_player:on_collide(other)
console.print(string.format("actor_player:on_collide: %s", other:get_classname()))
end
function play_sound( filename, is_3d, posx, posy, posz )
-- body
end

65
data/scripts/help.lua Normal file
View File

@@ -0,0 +1,65 @@
Globals:
ACTION_FIRE = 0
ACTION_ALT_FIRE = 1
ACTION_RELOAD = 2
ANIM_PLAYBACK_NONE = 0
ANIM_PLAYBACK_REPEAT = 1
engine.error(string message)
engine.warning(string message)
engine.create_entity(string classname) -- return an table to the new entity
engine.add_entity_to_world(entity) -- add entity to the world
engine.get_entity_from_id(integer id) -- return an entity table from
engine.play_sound(string filename) -- play 2d sound
camera.get_position() -- return x, y, z
camera.get_front() -- return x, y, z
camera.get_right() -- return x, y, z
camera.get_up() -- return float
camera.get_pitch() -- return float
console.print(string message)
Entity properties:
string m_name
integer m_id
Entity methods:
load_model(string filename)
update_transform()
translate(float x, float y, float z) -- addition to the current position
set_position(float x, float y, float z) -- setting the position
get_position() -- return x, y, z
set_rotation(float x, float y, float z) -- setting the euler rotation
set_rotation_from_vectors(float frontx, float fronty, float frontz,
float rightx, float righty, float rightz,
float upx, float upy, float upz) -- rotate around axis
get_classname() -- return the classname of the entity
get_id() -- return the id of the entity
find_animation(string name) -- find a animation in the model
play_animation(integer id, integer mode) -- play a animation with specified mode (ANIM_PLAYBACK_NONE, ANIM_PLAYBACK_REPEAT)
get_current_animation() -- return the id to the current playing animation
get_current_animation_time() -- return the current time of the current playing animation
get_animation_time(integer id) -- return the time of a animation
ActorBase methods:
activate_camera()
update_camera_look()
update_camera_movement(float nubmer)
create_body()
update_body_movement(float nubmer)
get_action() -- return an current mode (ACTION_FIRE, ACTION_ALT_FIRE, ACTION_RELOAD)

View File

@@ -27,10 +27,9 @@ function test_object:set_relative_position_to_camera( ent )
local rightX, rightY, rightZ = camera.get_right()
local upX, upY, upZ = camera.get_up()
local yaw = camera.get_yaw()
local pitch = camera.get_pitch()
self:set_rotation(pitch, -yaw, 0.0)
self:set_rotation_from_vectors(frontX, frontY, frontZ,
rightX, rightY, rightZ,
upX, upY, upZ)
local offsetx = 0.0
local offsety = 0.0