Skip to content

Commit

Permalink
Merge branch 'revolucas/CoC-Xray' into feature/call_of_chernobyl
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Dec 18, 2024
2 parents 7cbcf95 + 7e63b74 commit d41cabd
Show file tree
Hide file tree
Showing 147 changed files with 2,436 additions and 973 deletions.
4 changes: 3 additions & 1 deletion src/xrCore/NET_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ void NET_Packet::w_seek(u32 pos, const void* p, u32 count)
void NET_Packet::r_seek(u32 pos)
{
INI_ASSERT(r_seek)
VERIFY(pos < B.count);
//AVO: changed changed condition to <= as all net packet script utils are using r_seek(0) to read the entire packet.
VERIFY(pos <= B.count);
//VERIFY(pos < B.count);
r_pos = pos;
}

Expand Down
10 changes: 6 additions & 4 deletions src/xrEngine/xrTheora_Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,14 @@ bool CTheoraStream::Decode(u32 in_tm_play)
if (d_frame < k_frame)
{
//. dbg_log ((stderr,"%04d: preroll\n",d_frame));
VERIFY((0 != d_frame % key_rate) ||
(0 == d_frame % key_rate) && theora_packet_iskeyframe(&o_packet));
//AVO: commented out VERIFY to get COC start in Debug - something is wrong with video stream
//VERIFY((0 != d_frame % key_rate) ||
// (0 == d_frame % key_rate) && theora_packet_iskeyframe(&o_packet));
continue;
}
[[maybe_unused]] bool is_key = theora_packet_iskeyframe(&o_packet);
VERIFY((d_frame != k_frame) || ((d_frame == k_frame) && is_key));
//AVO: commented out VERIFY to get COC start in Debug - something is wrong with video stream
//[[maybe_unused]] bool is_key = theora_packet_iskeyframe(&o_packet);
//VERIFY((d_frame != k_frame) || ((d_frame == k_frame) && is_key));
// real decode
//. dbg_log ((stderr,"%04d: decode\n",d_frame));
[[maybe_unused]] int res = theora_decode_packetin(&t_state, &o_packet);
Expand Down
72 changes: 50 additions & 22 deletions src/xrGame/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@

#include "xrEngine/Rain.h"

//Alundaio
#include "script_hit.h"
//-Alundaio

//const u32 patch_frames = 50;
//const float respawn_delay = 1.f;
//const float respawn_auto = 7.f;
Expand All @@ -100,7 +104,8 @@ Flags32 psActorFlags =
AF_AUTOPICKUP |
AF_RUN_BACKWARD |
AF_IMPORTANT_SAVE |
AF_MULTI_ITEM_PICKUP
AF_MULTI_ITEM_PICKUP |
AF_USE_TRACERS
};
int psActorSleepTime = 1;

Expand Down Expand Up @@ -653,13 +658,35 @@ void CActor::Hit(SHit* pHDS)
{
HDS.power = 0.0f;
inherited::Hit(&HDS);
return;
}

float hit_power = HitArtefactsOnBelt(HDS.damage(), HDS.hit_type);
HDS.power = hit_power;
HDS.power = HitArtefactsOnBelt(HDS.damage(), HDS.hit_type);
HDS.add_wound = true;
if (g_Alive())
{
CScriptHit tLuaHit;

tLuaHit.m_fPower = HDS.power;
tLuaHit.m_fImpulse = HDS.impulse;
tLuaHit.m_tDirection = HDS.direction();
tLuaHit.m_tHitType = HDS.hit_type;
tLuaHit.m_tpDraftsman = smart_cast<const CGameObject*>(HDS.who)->lua_game_object();

luabind::functor<bool> funct;
if (GEnv.ScriptEngine->functor("_G.CActor__BeforeHitCallback", funct))
{
if (!funct(smart_cast<CGameObject*>(this->lua_game_object()), &tLuaHit, HDS.boneID))
return;
}

HDS.power = tLuaHit.m_fPower;
HDS.impulse = tLuaHit.m_fImpulse;
HDS.dir = tLuaHit.m_tDirection;
HDS.hit_type = (ALife::EHitType)(tLuaHit.m_tHitType);
//HDS.who = smart_cast<CObject*>(tLuaHit.m_tpDraftsman->object());
//HDS.whoID = tLuaHit.m_tpDraftsman->ID();

/* AVO: send script callback*/
callback(GameObject::eHit)(
this->lua_game_object(),
Expand Down Expand Up @@ -780,13 +807,13 @@ void CActor::HitMark(float P, Fvector dir, IGameObject* who_object, s16 element,

void CActor::HitSignal(float perc, Fvector& vLocalDir, IGameObject* who, s16 element)
{
//AVO: get bone names from IDs
//cpcstr bone_name = smart_cast<IKinematics*>(this->Visual())->LL_BoneName_dbg(element);
//Msg("Bone [%d]->[%s]", element, bone_name);
//-AVO

if (g_Alive())
{
/* AVO: to get bone names from IDs*/
/*Log("hit info");
Log("bone ID = %s", element);
Log("bone Name = %s", smart_cast<IKinematics*>(this->Visual())->LL_BoneName_dbg(element));
Log("hit info END");*/
// check damage bone
Fvector D;
XFORM().transform_dir(D, vLocalDir);
Expand Down Expand Up @@ -1541,7 +1568,7 @@ void CActor::shedule_Update(u32 DT)
}
else if (m_pVehicleWeLookingAt)
{
m_sDefaultObjAction = m_sCarCharacterUseAction;
m_sDefaultObjAction = m_pVehicleWeLookingAt->m_sUseAction != nullptr ? m_pVehicleWeLookingAt->m_sUseAction : m_sCarCharacterUseAction;
}
else if (m_pObjectWeLookingAt && m_pObjectWeLookingAt->cast_inventory_item() &&
m_pObjectWeLookingAt->cast_inventory_item()->CanTake())
Expand Down Expand Up @@ -1928,18 +1955,19 @@ void CActor::UpdateArtefactsOnBeltAndOutfit()
const auto artefact = smart_cast<CArtefact*>(it);
if (artefact)
{
conditions().ChangeBleeding(artefact->m_fBleedingRestoreSpeed * f_update_time);
conditions().ChangeHealth(artefact->m_fHealthRestoreSpeed * f_update_time);
conditions().ChangePower(artefact->m_fPowerRestoreSpeed * f_update_time);
conditions().ChangeSatiety(artefact->m_fSatietyRestoreSpeed * f_update_time);
if (artefact->m_fRadiationRestoreSpeed > 0.0f)
const float art_cond = artefact->GetCondition();
conditions().ChangeBleeding((artefact->m_fBleedingRestoreSpeed * art_cond) * f_update_time);
conditions().ChangeHealth((artefact->m_fHealthRestoreSpeed * art_cond) * f_update_time);
conditions().ChangePower((artefact->m_fPowerRestoreSpeed * art_cond) * f_update_time);
conditions().ChangeSatiety((artefact->m_fSatietyRestoreSpeed * art_cond) * f_update_time);
if (artefact->m_fRadiationRestoreSpeed * art_cond > 0.0f)
{
float val = artefact->m_fRadiationRestoreSpeed - conditions().GetBoostRadiationImmunity();
float val = (artefact->m_fRadiationRestoreSpeed * art_cond) - conditions().GetBoostRadiationImmunity();
clamp(val, 0.0f, val);
conditions().ChangeRadiation(val * f_update_time);
}
else
conditions().ChangeRadiation(artefact->m_fRadiationRestoreSpeed * f_update_time);
conditions().ChangeRadiation((artefact->m_fRadiationRestoreSpeed * art_cond) * f_update_time);
}
}

Expand Down Expand Up @@ -1986,7 +2014,7 @@ float CActor::GetProtection_ArtefactsOnBelt(ALife::EHitType hit_type)
{
const auto artefact = smart_cast<CArtefact*>(it);
if (artefact)
sum += artefact->m_ArtefactHitImmunities.AffectHit(1.0f, hit_type);
sum += artefact->m_ArtefactHitImmunities.AffectHit(1.0f, hit_type) * artefact->GetCondition();
}
return sum;
}
Expand Down Expand Up @@ -2141,7 +2169,7 @@ float CActor::GetRestoreSpeed(ALife::EConditionRestoreType const& type)
{
const auto artefact = smart_cast<CArtefact*>(it);
if (artefact)
res += artefact->m_fHealthRestoreSpeed;
res += artefact->m_fHealthRestoreSpeed * artefact->GetCondition();
}

const auto outfit = GetOutfit();
Expand All @@ -2156,7 +2184,7 @@ float CActor::GetRestoreSpeed(ALife::EConditionRestoreType const& type)
{
const auto artefact = smart_cast<CArtefact*>(it);
if (artefact)
res += artefact->m_fRadiationRestoreSpeed;
res += artefact->m_fRadiationRestoreSpeed * artefact->GetCondition();
}

const auto outfit = GetOutfit();
Expand All @@ -2173,7 +2201,7 @@ float CActor::GetRestoreSpeed(ALife::EConditionRestoreType const& type)
{
const auto artefact = smart_cast<CArtefact*>(it);
if (artefact)
res += artefact->m_fSatietyRestoreSpeed;
res += artefact->m_fSatietyRestoreSpeed * artefact->GetCondition();
}

const auto outfit = GetOutfit();
Expand All @@ -2190,7 +2218,7 @@ float CActor::GetRestoreSpeed(ALife::EConditionRestoreType const& type)
{
const auto artefact = smart_cast<CArtefact*>(it);
if (artefact)
res += artefact->m_fPowerRestoreSpeed;
res += artefact->m_fPowerRestoreSpeed * artefact->GetCondition();
}
auto outfit = GetOutfit();
if (outfit)
Expand All @@ -2212,7 +2240,7 @@ float CActor::GetRestoreSpeed(ALife::EConditionRestoreType const& type)
{
const auto artefact = smart_cast<CArtefact*>(it);
if (artefact)
res += artefact->m_fBleedingRestoreSpeed;
res += artefact->m_fBleedingRestoreSpeed * artefact->GetCondition();
}

const auto outfit = GetOutfit();
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class CActor : public CEntityAlive,
void detach_Vehicle();
void steer_Vehicle(float angle);
void attach_Vehicle(CHolderCustom* vehicle);
bool use_MountedWeapon(CHolderCustom* object);
bool use_HolderEx(CHolderCustom* object, bool bForce);
virtual bool can_attach(const CInventoryItem* inventory_item) const;

protected:
Expand Down
8 changes: 4 additions & 4 deletions src/xrGame/ActorInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ bool CActor::use_Holder(CHolderCustom* holder)

if (smart_cast<CCar*>(holderGO))
b = use_Vehicle(0);
else if (holderGO->CLS_ID == CLSID_OBJECT_W_STATMGUN)
b = use_MountedWeapon(0);
else if (holderGO->CLS_ID == CLSID_OBJECT_W_STATMGUN || holderGO->CLS_ID==CLSID_OBJECT_HOLDER_ENT)
b = use_HolderEx(0, false);

if (inventory().ActiveItem())
{
Expand All @@ -596,8 +596,8 @@ bool CActor::use_Holder(CHolderCustom* holder)
if (smart_cast<CCar*>(holder))
b = use_Vehicle(holder);

if (holderGO->CLS_ID == CLSID_OBJECT_W_STATMGUN)
b = use_MountedWeapon(holder);
if (holderGO->CLS_ID == CLSID_OBJECT_W_STATMGUN || holderGO->CLS_ID==CLSID_OBJECT_HOLDER_ENT)
b = use_HolderEx(holder, false);

if (b)
{ // used succesfully
Expand Down
71 changes: 48 additions & 23 deletions src/xrGame/ActorMountedWeapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,61 @@
#include "xrEngine/CameraBase.h"
#include "ActorEffector.h"
#include "CharacterPhysicsSupport.h"
#include "holder_custom.h"
#include "Car.h"

bool CActor::use_MountedWeapon(CHolderCustom* object)
bool CActor::use_HolderEx(CHolderCustom* object, bool bForce)
{
/*
CHolderCustom* wpn =object;
if(m_holder){
if(!wpn||(m_holder==wpn)){
if (m_holder)
{
if (smart_cast<CCar*>(m_holder))
{
detach_Vehicle();
return true;
}
if (!m_holder->ExitLocked())
{
if (!object || (m_holder == object))
{
m_holder->detach_Actor();

if (const CGameObject* go = smart_cast<CGameObject*>(m_holder))
callback(GameObject::eDetachVehicle)(go->lua_game_object());

character_physics_support()->movement()->CreateCharacter();
m_holder=NULL;
m_holder = nullptr;
}
return true;
}else{
if(wpn){
Fvector center; Center(center);
if(wpn->Use(Device.vCameraPosition, Device.vCameraDirection,center)){
if(wpn->attach_Actor(this)){
// destroy actor character
character_physics_support()->movement()->DestroyCharacter();
PickupModeOff();
m_holder=wpn;
if (pCamBobbing){
Cameras().RemoveCamEffector(eCEBobbing);
pCamBobbing = NULL;
}
return true;
}
}
return true;
}
if (smart_cast<CCar*>(m_holder))
{
attach_Vehicle(object);
return true;
}
if (object && !object->EnterLocked())
{
Fvector center;
Center(center);
if (object->Use(Device.vCameraPosition, Device.vCameraDirection, center))
{
if (object->attach_Actor(this))
{
// destroy actor character
character_physics_support()->movement()->DestroyCharacter();

m_holder = object;
if (pCamBobbing)
{
Cameras().RemoveCamEffector(eCEBobbing);
pCamBobbing = nullptr;
}

if (const CGameObject* go = smart_cast<CGameObject*>(m_holder))
callback(GameObject::eAttachVehicle)(go->lua_game_object());
return true;
}
}
*/
}
return false;
}
5 changes: 4 additions & 1 deletion src/xrGame/ActorVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ void CActor::attach_Vehicle(CHolderCustom* vehicle)
if(!vehicle || m_holder)
return;

CCar* car = smart_cast<CCar*>(vehicle);
if (!car)
return;

//PickupModeOff();
m_holder=vehicle;

Expand All @@ -44,7 +48,6 @@ void CActor::attach_Vehicle(CHolderCustom* vehicle)
}

// temp play animation
CCar* car = smart_cast<CCar*>(m_holder);
u16 anim_type = car->DriverAnimationType();
SVehicleAnimCollection& anims = m_vehicle_anims->m_vehicles_type_collections[anim_type];
V->PlayCycle(anims.idles[0], false);
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/Actor_Flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum
AF_MULTI_ITEM_PICKUP = (1 << 11),
AF_LOADING_STAGES = (1 << 12),
AF_ALWAYS_USE_ATTITUDE_SENSORS = (1 << 13), // or only when zooming if false
AF_USE_TRACERS = (1 << 14)
};

extern Flags32 psActorFlags;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Actor_Movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ float CActor::get_additional_weight() const
{
CArtefact* artefact = smart_cast<CArtefact*>(*it);
if (artefact)
res += artefact->AdditionalInventoryWeight();
res += artefact->AdditionalInventoryWeight() * artefact->GetCondition();
}

return res;
Expand Down
1 change: 0 additions & 1 deletion src/xrGame/AmebaZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "CharacterPhysicsSupport.h"
#include "entity_alive.h"


CAmebaZone::CAmebaZone() : m_fVelocityLimit(1.f) {}

CAmebaZone::~CAmebaZone() {}
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Artefact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ bool CArtefact::net_Spawn(CSE_Abstract* DC)
StartLights();
m_CarringBoneID = u16(-1);
IKinematicsAnimated* K = smart_cast<IKinematicsAnimated*>(Visual());
if (K)
if (K && K->ID_Cycle_Safe("idle"))
K->PlayCycle("idle");

o_fastmode = FALSE; // start initially with fast-mode enabled
Expand Down
6 changes: 4 additions & 2 deletions src/xrGame/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,8 @@ target_sources(xrGame PRIVATE
hit_memory_manager.cpp
hit_memory_manager.h
hit_memory_manager_inline.h
HolderEntityObject.cpp
HolderEntityObject.h
holder_custom.cpp
holder_custom.h
holder_custom_script.cpp
Expand Down Expand Up @@ -1508,8 +1510,6 @@ target_sources(xrGame PRIVATE
weaponBM16.cpp
weaponBM16.h
Weapon.cpp
WeaponCustomPistolAuto.cpp
WeaponCustomPistolAuto.h
WeaponCustomPistol.cpp
WeaponCustomPistol.h
WeaponDispersion.cpp
Expand Down Expand Up @@ -2315,6 +2315,8 @@ target_sources(xrGame PRIVATE
ui/UIRankFaction.h
ui/UIRankIndicator.cpp
ui/UIRankIndicator.h
ui/UIRankingsCoC.cpp
ui/UIRankingsCoC.h
ui/UIRankingWnd.cpp
ui/UIRankingWnd.h
ui/UIScriptWnd.cpp
Expand Down
Loading

0 comments on commit d41cabd

Please sign in to comment.