Skip to content

Commit

Permalink
Add show_legs method export in Lua
Browse files Browse the repository at this point in the history
Added `player_hud.show_legs(val)`

AIW
  • Loading branch information
ForserX committed Nov 14, 2024
1 parent 1a2f02f commit be119e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
19 changes: 15 additions & 4 deletions src/xrGame/level_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@
#include "xrServer_Objects_ALife_Monsters.h"
#include "HUDAnimItem.h"
#include "ActorCondition.h"
#include "player_hud.h"

using namespace luabind;

void show_legs(bool val)
{
g_player_hud->m_show_legs = val;
}

void block_action_script(int cmd) {
if (g_pGameLevel == nullptr) {
return;
Expand Down Expand Up @@ -1137,11 +1143,16 @@ void CLevel::script_register(lua_State *L)
def("play", &CHUDAnimItem::PlayHudAnim)
];

module(L,"actor_stats")
module(L, "player_hud")
[
def("show_legs", &show_legs)
];

module(L, "actor_stats")
[
def("add_points", &add_actor_points),
def("add_points_str", &add_actor_points_str),
def("get_points", &get_actor_points)
def("add_points", &add_actor_points),
def("add_points_str", &add_actor_points_str),
def("get_points", &get_actor_points)
];

module(L)
Expand Down
5 changes: 3 additions & 2 deletions src/xrGame/player_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,8 @@ void player_hud::render_hud()
m_attached_items[1]->render();
}

if(Actor() && m_legs_model) {
if(m_show_legs && Actor() && m_legs_model)
{
bool isClimb = Actor()->GetMovementState(ACTOR_DEFS::EMovementStates::eReal) & mcClimb;
if(!isClimb) {
auto bHud = ::Render->get_HUD();
Expand Down Expand Up @@ -729,7 +730,7 @@ void player_hud::render_hud()
}
}

auto BoneID = m_legs_model->LL_BoneID("bip01_spine");
const u16 BoneID = m_legs_model->LL_BoneID("bip01_spine");
auto& BoneInstance = m_legs_model->LL_GetData(BoneID);
m_legs_model->Bone_Calculate(&BoneInstance, &m_legs_model->LL_GetTransform(BoneInstance.GetParentID()));

Expand Down
4 changes: 3 additions & 1 deletion src/xrGame/player_hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ class player_hud
void SetHandsVisible(bool val){m_bhands_visible=val;};
bool GetHandsVisible(){return m_bhands_visible;};

IKinematics* m_legs_model;
IKinematics* m_legs_model;
bool m_show_legs = true;

private:
void update_inertion (Fmatrix& trans);
void update_additional (Fmatrix& trans);
Expand Down

0 comments on commit be119e6

Please sign in to comment.