Skip to content

Commit 0fe21c1

Browse files
revolucasXottab-DUTY
authored andcommitted
New callbacks and more
* alife_storage_manager.cpp makes direct engine call to script alife_storage_manager.script to pass the save game filename. alife_storage_manager.CALifeStorageManager_save alife_storage_manager.CALifeStorageManager_load * smooth crouch fix + callback.weapon_zoom_in + callback.weapon_zoom_out + callback.weapon_jammed + game_object:get_artefact_health(); + game_object:get_artefact_radiation(); + game_object:get_artefact_satiety(); + game_object:get_artefact_power(); + game_object:get_artefact_bleeding(); + game_object:set_artefact_health(float value); + game_object:set_artefact_radiation(float value); + game_object:set_artefact_satiety(float value); + game_object:set_artefact_power(float value); + game_object:set_artefact_bleeding(float value); + game_object:attach_vehicle(gameobject veh) *actor only* + game_object:detach_vehicle() *actor only* + game_object:force_set_position(vector3)
1 parent 8949dd2 commit 0fe21c1

13 files changed

+244
-14
lines changed

src/xrGame/Actor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ CActor::CActor() : CEntityAlive(), current_ik_cam_shift(0)
200200

201201
m_disabled_hitmarks = false;
202202
m_inventory_disabled = false;
203+
204+
// Alex ADD: for smooth crouch fix
205+
CurrentHeight = 0.f;
203206
}
204207

205208
CActor::~CActor()
@@ -440,6 +443,9 @@ void CActor::Load(LPCSTR section)
440443
m_sInventoryBoxUseAction = "inventory_box_use";
441444
//---------------------------------------------------------------------
442445
m_sHeadShotParticle = READ_IF_EXISTS(pSettings, r_string, section, "HeadShotParticle", 0);
446+
447+
// Alex ADD: for smooth crouch fix
448+
CurrentHeight = CameraHeight();
443449
}
444450

445451
void CActor::PHHit(SHit& H) { m_pPhysics_support->in_Hit(H, false); }

src/xrGame/Actor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ class CActor : public CEntityAlive,
390390
bool CanJump();
391391
bool CanMove();
392392
float CameraHeight();
393+
// Alex ADD: for smooth crouch fix
394+
float CurrentHeight;
393395
bool CanSprint();
394396
bool CanRun();
395397
void StopAnyMove();

src/xrGame/ActorCameras.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,14 @@ void CActor::cam_Update(float dt, float fFOV)
311311
else
312312
current_ik_cam_shift = 0;
313313

314-
Fvector point = {0, CameraHeight() + current_ik_cam_shift, 0};
314+
// Alex ADD: smooth crouch fix
315+
float HeightInterpolationSpeed = 4.f;
316+
317+
if (CurrentHeight != CameraHeight())
318+
CurrentHeight = (CurrentHeight * (1.0f - HeightInterpolationSpeed*dt)) + (CameraHeight() * HeightInterpolationSpeed*dt);
319+
320+
Fvector point = { 0, CurrentHeight + current_ik_cam_shift, 0 };
321+
315322
Fvector dangle = {0, 0, 0};
316323
Fmatrix xform;
317324
xform.setXYZ(0, r_torso.yaw, 0);

src/xrGame/ActorVehicle.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ void CActor::detach_Vehicle()
9090
car->PPhysicsShell()->SplitterHolderActivate();
9191
m_holder->detach_Actor(); //
9292

93+
// Real Wolf: колбек на высадку из машины. 01.08.2014.
94+
this->callback(GameObject::eDetachVehicle)(car->lua_game_object());
95+
9396
character_physics_support()->movement()->SetPosition(m_holder->ExitPosition());
9497
character_physics_support()->movement()->SetVelocity(m_holder->ExitVelocity());
9598

@@ -106,9 +109,6 @@ void CActor::detach_Vehicle()
106109

107110
//. SetWeaponHideState(whs_CAR, FALSE);
108111
SetWeaponHideState(INV_STATE_CAR, false);
109-
110-
// Real Wolf: колбек на высадку из машины. 01.08.2014.
111-
this->callback(GameObject::eDetachVehicle)(car->lua_game_object());
112112
}
113113

114114
bool CActor::use_Vehicle(CHolderCustom* object)

src/xrGame/Artefact.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ class CArtefact : public CHudItemObject, public CPHUpdateObject
3636
virtual void create_physic_shell();
3737

3838
virtual CArtefact* cast_artefact() { return this; }
39+
40+
float GetHealthPower() const { return m_fHealthRestoreSpeed; }
41+
float GetRadiationPower() const { return m_fRadiationRestoreSpeed; }
42+
float GetSatietyPower() const { return m_fSatietyRestoreSpeed; }
43+
float GetPowerPower() const { return m_fPowerRestoreSpeed; }
44+
float GetBleedingPower() const { return m_fBleedingRestoreSpeed; }
45+
46+
void SetHealthPower(const float value) { m_fHealthRestoreSpeed = value; }
47+
void SetRadiationPower(const float value) { m_fRadiationRestoreSpeed = value; }
48+
void SetSatietyPower(const float value) { m_fSatietyRestoreSpeed = value; }
49+
void SetPowerPower(const float value) { m_fPowerRestoreSpeed = value; }
50+
void SetBleedingPower(const float value) { m_fBleedingRestoreSpeed = value; }
51+
3952
protected:
4053
virtual void UpdateCLChild(){};
4154
virtual void CreateArtefactActivation();

src/xrGame/WeaponMagazined.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ void CWeaponMagazined::FireStart()
171171
}
172172
else
173173
{ // misfire
174+
//Alundaio
175+
CGameObject *object = smart_cast<CGameObject*>(H_Parent());
176+
if (object)
177+
object->callback(GameObject::eOnWeaponJammed)(object->lua_game_object(), this->lua_game_object());
178+
//-Alundaio
179+
174180
if (smart_cast<CActor*>(this->H_Parent()) && (Level().CurrentViewEntity() == H_Parent()))
175181
CurrentGameUI()->AddCustomStatic("gun_jammed", true);
176182

@@ -1167,6 +1173,12 @@ void CWeaponMagazined::OnZoomIn()
11671173
if (GetState() == eIdle)
11681174
PlayAnimIdle();
11691175

1176+
//Alundaio: callback not sure why vs2013 gives error, it's fine
1177+
CGameObject *object = smart_cast<CGameObject*>(H_Parent());
1178+
if (object)
1179+
object->callback(GameObject::eOnWeaponZoomIn)(object->lua_game_object(),this->lua_game_object());
1180+
//-Alundaio
1181+
11701182
CActor* pActor = smart_cast<CActor*>(H_Parent());
11711183
if (pActor)
11721184
{
@@ -1190,6 +1202,12 @@ void CWeaponMagazined::OnZoomOut()
11901202
if (GetState() == eIdle)
11911203
PlayAnimIdle();
11921204

1205+
//Alundaio
1206+
CGameObject *object = smart_cast<CGameObject*>(H_Parent());
1207+
if (object)
1208+
object->callback(GameObject::eOnWeaponZoomOut)(object->lua_game_object(), this->lua_game_object());
1209+
//-Alundaio
1210+
11931211
CActor* pActor = smart_cast<CActor*>(H_Parent());
11941212

11951213
if (pActor)

src/xrGame/alife_storage_manager.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include "string_table.h"
2323
#include "xrEngine/IGame_Persistent.h"
2424
#include "autosave_manager.h"
25+
//Alundaio
26+
#include "pch_script.h"
27+
#include "xrScriptEngine/script_engine.hpp"
28+
//-Alundaio
2529

2630
XRCORE_API string_path g_bug_report_file;
2731

@@ -90,12 +94,26 @@ void CALifeStorageManager::save(LPCSTR save_name_no_check, bool update_name)
9094
Msg("* Game %s is successfully saved to file '%s'", m_save_name, temp);
9195
#endif // DEBUG
9296

97+
//Alundaio: To get the savegame fname to make our own custom save states
98+
luabind::functor<void> funct;
99+
ai().script_engine().functor("alife_storage_manager.CALifeStorageManager_save", funct);
100+
if (funct)
101+
funct(static_cast<pcstr>(m_save_name));
102+
//-Alundaio
103+
93104
if (!update_name)
94105
xr_strcpy(m_save_name, save);
95106
}
96107

97108
void CALifeStorageManager::load(void* buffer, const u32& buffer_size, LPCSTR file_name)
98109
{
110+
//Alundaio: So we can get the fname to make our own custom save states
111+
luabind::functor<void> funct;
112+
ai().script_engine().functor("alife_storage_manager.CALifeStorageManager_load", funct);
113+
if (funct)
114+
funct(file_name);
115+
//-Alundaio
116+
99117
IReader source(buffer, buffer_size);
100118
header().load(source);
101119
time_manager().load(source);

src/xrGame/game_object_space.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ enum ECallbackType
7474
eDetachVehicle,
7575
eUseVehicle,
7676

77+
// weapon
78+
eOnWeaponZoomIn,
79+
eOnWeaponZoomOut,
80+
eOnWeaponJammed,
81+
7782
eDummy = u32(-1),
7883
};
7984
};

src/xrGame/script_game_object.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "character_info_defs.h"
1616
#include "xrAICore/Navigation/game_graph_space.h"
1717
#include "game_location_selector.h"
18+
#include "ui/UIWindow.h" //Alundaio
1819

1920
enum EPdaMsg;
2021
enum ESoundTypes;
@@ -109,6 +110,7 @@ class CScriptGameObject;
109110
class CZoneCampfire;
110111
class CPhysicObject;
111112
class CArtefact;
113+
class CUIWindow; //Alundaio: For ScopeTexture
112114

113115
#ifdef DEBUG
114116
template <typename _object_type>
@@ -399,8 +401,14 @@ class CScriptGameObject
399401
int Weapon_Scope_Status();
400402
int Weapon_Silencer_Status();
401403

402-
void Weapon_AddonAttach(CScriptGameObject& item); //Alundaio
403-
void Weapon_AddonDetach(pcstr item_section); //Alundaio
404+
//Alundaio
405+
void Weapon_AddonAttach(CScriptGameObject* item);
406+
void Weapon_AddonDetach(pcstr item_section);
407+
408+
void AttachVehicle(CScriptGameObject* veh);
409+
void DetachVehicle();
410+
void ForceSetPosition(Fvector3 pos);
411+
//-Alundaio
404412

405413
LPCSTR ProfileName();
406414
LPCSTR CharacterName();
@@ -606,6 +614,20 @@ class CScriptGameObject
606614
float GetAnomalyPower();
607615
void SetAnomalyPower(float p);
608616

617+
//Alundaio
618+
float GetArtefactHealthRestoreSpeed();
619+
float GetArtefactRadiationRestoreSpeed();
620+
float GetArtefactSatietyRestoreSpeed();
621+
float GetArtefactPowerRestoreSpeed();
622+
float GetArtefactBleedingRestoreSpeed();
623+
624+
void SetArtefactHealthRestoreSpeed(float value);
625+
void SetArtefactRadiationRestoreSpeed(float value);
626+
void SetArtefactSatietyRestoreSpeed(float value);
627+
void SetArtefactPowerRestoreSpeed(float value);
628+
void SetArtefactBleedingRestoreSpeed(float value);
629+
//-Alundaio
630+
609631
// HELICOPTER
610632
CHelicopter* get_helicopter();
611633
// CAR

src/xrGame/script_game_object3.cpp

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
#include "sound_player.h"
3939
#include "stalker_decision_space.h"
4040
#include "space_restriction_manager.h"
41+
//Alundaio
42+
#include "Artefact.h"
43+
#include "holder_custom.h"
44+
#include "Actor.h"
45+
//-Alundaio
4146

4247
namespace MemorySpace
4348
{
@@ -924,6 +929,7 @@ float CScriptGameObject::GetAnomalyPower()
924929
THROW(zone);
925930
return zone->GetMaxPower();
926931
}
932+
927933
void CScriptGameObject::SetAnomalyPower(float p)
928934
{
929935
CCustomZone* zone = smart_cast<CCustomZone*>(&object());
@@ -1214,3 +1220,115 @@ bool CScriptGameObject::is_weapon_going_to_be_strapped(CScriptGameObject const*
12141220

12151221
return stalker->is_weapon_going_to_be_strapped(&object->object());
12161222
}
1223+
1224+
//Alundaio: Taken from Radium
1225+
float CScriptGameObject::GetArtefactHealthRestoreSpeed()
1226+
{
1227+
CArtefact* artefact = smart_cast<CArtefact*>(&object());
1228+
THROW(artefact);
1229+
1230+
return artefact->GetHealthPower();
1231+
}
1232+
1233+
float CScriptGameObject::GetArtefactRadiationRestoreSpeed()
1234+
{
1235+
CArtefact* artefact = smart_cast<CArtefact*>(&object());
1236+
THROW(artefact);
1237+
1238+
return artefact->GetRadiationPower();
1239+
}
1240+
1241+
float CScriptGameObject::GetArtefactSatietyRestoreSpeed()
1242+
{
1243+
CArtefact* artefact = smart_cast<CArtefact*>(&object());
1244+
THROW(artefact);
1245+
1246+
return artefact->GetSatietyPower();
1247+
}
1248+
1249+
float CScriptGameObject::GetArtefactPowerRestoreSpeed()
1250+
{
1251+
CArtefact* artefact = smart_cast<CArtefact*>(&object());
1252+
THROW(artefact);
1253+
1254+
return artefact->GetPowerPower();
1255+
}
1256+
1257+
float CScriptGameObject::GetArtefactBleedingRestoreSpeed()
1258+
{
1259+
CArtefact* artefact = smart_cast<CArtefact*>(&object());
1260+
THROW(artefact);
1261+
1262+
return artefact->GetBleedingPower();
1263+
}
1264+
1265+
void CScriptGameObject::SetArtefactHealthRestoreSpeed(float value)
1266+
{
1267+
CArtefact* artefact = smart_cast<CArtefact*>(&object());
1268+
THROW(artefact);
1269+
1270+
artefact->SetHealthPower(value);
1271+
}
1272+
1273+
void CScriptGameObject::SetArtefactRadiationRestoreSpeed(float value)
1274+
{
1275+
CArtefact* artefact = smart_cast<CArtefact*>(&object());
1276+
THROW(artefact);
1277+
1278+
artefact->SetRadiationPower(value);
1279+
}
1280+
1281+
void CScriptGameObject::SetArtefactSatietyRestoreSpeed(float value)
1282+
{
1283+
CArtefact* artefact = smart_cast<CArtefact*>(&object());
1284+
THROW(artefact);
1285+
1286+
artefact->SetSatietyPower(value);
1287+
}
1288+
1289+
void CScriptGameObject::SetArtefactPowerRestoreSpeed(float value)
1290+
{
1291+
CArtefact* artefact = smart_cast<CArtefact*>(&object());
1292+
THROW(artefact);
1293+
1294+
artefact->SetPowerPower(value);
1295+
}
1296+
1297+
void CScriptGameObject::SetArtefactBleedingRestoreSpeed(float value)
1298+
{
1299+
CArtefact* artefact = smart_cast<CArtefact*>(&object());
1300+
THROW(artefact);
1301+
1302+
artefact->SetBleedingPower(value);
1303+
}
1304+
1305+
//Alundaio
1306+
void CScriptGameObject::AttachVehicle(CScriptGameObject* veh)
1307+
{
1308+
CActor *actor = smart_cast<CActor*>(&object());
1309+
if (actor)
1310+
{
1311+
CHolderCustom* vehicle = smart_cast<CHolderCustom*>(veh);
1312+
if (vehicle)
1313+
actor->attach_Vehicle(vehicle);
1314+
}
1315+
}
1316+
1317+
void CScriptGameObject::DetachVehicle()
1318+
{
1319+
CActor *actor = smart_cast<CActor*>(&object());
1320+
if (actor)
1321+
actor->detach_Vehicle();
1322+
}
1323+
1324+
void CScriptGameObject::ForceSetPosition(Fvector3 pos)
1325+
{
1326+
CPhysicsShellHolder* P = smart_cast<CPhysicsShellHolder*>(this);
1327+
if (!P)
1328+
return;
1329+
1330+
Fmatrix M = P->XFORM();
1331+
M.translate(pos);
1332+
P->ForceTransform(M);
1333+
}
1334+
//-Alundaio

0 commit comments

Comments
 (0)