Skip to content

Commit

Permalink
Add export is_ladder method in Lua
Browse files Browse the repository at this point in the history
Co-authored-by: Drombeys <dima.zolotov02@gmail.com>
  • Loading branch information
ForserX and Drombeys committed Nov 13, 2024
1 parent 14e7097 commit f87e641
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/xrGame/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,11 @@ virtual void _BCL HideAllWeapons ( bool v ){ SetWeaponHideState(INV_STATE_B
bool m_inventory_disabled;
//static CPhysicsShell *actor_camera_shell;

DECLARE_SCRIPT_REGISTER_FUNCTION
DECLARE_SCRIPT_REGISTER_FUNCTION

public:
bool OnLadder = false;
IC bool is_ladder() const { return OnLadder; };
};

extern bool isActorAccelerated (u32 mstate, bool ZoomMode);
Expand Down
7 changes: 6 additions & 1 deletion src/xrGame/ActorCameras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ void CActor::cam_SetLadder()
C->lim_yaw[1] = hi;
C->bClampYaw = true;
}

OnLadder = true;
}
void CActor::camUpdateLadder(float dt)
{
Expand Down Expand Up @@ -94,7 +96,10 @@ void CActor::cam_UnsetLadder()
C->lim_yaw[0] = 0;
C->lim_yaw[1] = 0;
C->bClampYaw = false;

OnLadder = false;
}

float cammera_into_collision_shift = 0.05f;
float CActor::CameraHeight()
{
Expand Down Expand Up @@ -399,7 +404,7 @@ void CActor::cam_Update(float dt, float fFOV)
fCurAVelocity = vPrevCamDir.sub(cameras[eacFirstEye]->vDirection).magnitude()/Device.fTimeDelta;
vPrevCamDir = cameras[eacFirstEye]->vDirection;

// Âûñ÷èòûâàåì ðàçíèöó ìåæäó ïðåäûäóùèì è òåêóùèì Yaw \ Pitch îò 1-ãî ëèöà //--#SM+ Begin#--
// Высчитываем разницу между предыдущим и текущим Yaw \ Pitch от 1-го лица //--#SM+ Begin#--
float& cam_yaw_cur = cameras[eacFirstEye]->yaw;
static float cam_yaw_prev = cam_yaw_cur;

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/script_game_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ class CScriptGameObject {
void SetActorRunBackCoef(float run_back_coef);

void IterateFeelTouch(const luabind::functor<bool>& functor);

bool IsActorLadder() const;
doors::door* m_door;

DECLARE_SCRIPT_REGISTER_FUNCTION
Expand Down
12 changes: 12 additions & 0 deletions src/xrGame/script_game_object2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,15 @@ bool CScriptGameObject::is_there_items_to_pickup () const
}
return (!!stalker->memory().item().selected());
}

bool CScriptGameObject::IsActorLadder() const
{
CActor* actor = smart_cast<CActor*>(&object());
if (actor == nullptr)
{
ai().script_engine().script_log(ScriptStorage::eLuaMessageTypeError, "ScriptGameObject : attempt to call IsActorLadder method for non-actor object");
return false;
}

return actor->is_ladder();
}
1 change: 1 addition & 0 deletions src/xrGame/script_game_object_script3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ class_<CScriptGameObject> script_register_game_object2(class_<CScriptGameObject>

.def("location_on_path", &CScriptGameObject::location_on_path)
.def("is_there_items_to_pickup", &CScriptGameObject::is_there_items_to_pickup)
.def("is_ladder", &CScriptGameObject::IsActorLadder)

.def("wounded", (bool (CScriptGameObject::*)() const)(&CScriptGameObject::wounded))
.def("wounded", (void (CScriptGameObject::*)(bool))(&CScriptGameObject::wounded))
Expand Down

0 comments on commit f87e641

Please sign in to comment.