Skip to content

Commit

Permalink
Merge pull request OpenXRay#1020 from Graff46/project2/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY authored Feb 6, 2025
2 parents 7c6eab4 + c8fc259 commit 0f09f03
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/xrGame/DestroyablePhysicsObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ bool CDestroyablePhysicsObject::net_Spawn(CSE_Abstract* DC)
m_destroy_sound.create(ini->r_string("sound", "break_sound"), st_Effect, sg_SourceType);
if (ini->section_exist("particles"))
m_destroy_particles = ini->r_string("particles", "destroy_particles");
if (ini->section_exist("hit_from"))
{
CInifile::Sect& data = ini->r_section("hit_from");
if (data.Data.size() > 0)
{
for (auto I = data.Data.cbegin(); I != data.Data.cend(); ++I)
hit_object_name.push_back(I->first.c_str());
}
}
}
CParticlesPlayer::LoadParticles(K);
RunStartupAnim(DC);
Expand All @@ -70,8 +79,12 @@ bool CDestroyablePhysicsObject::net_Spawn(CSE_Abstract* DC)
void CDestroyablePhysicsObject::Hit(SHit* pHDS)
{
SHit HDS = *pHDS;
callback(GameObject::eHit)(
lua_game_object(), HDS.power, HDS.dir, smart_cast<const CGameObject*>(HDS.who)->lua_game_object(), HDS.bone());
IGameObject* who = HDS.who;
callback(GameObject::eHit)(lua_game_object(), HDS.power, HDS.dir, who->lua_game_object(), HDS.bone());

if (!hit_object_name.empty() && std::find(hit_object_name.begin(), hit_object_name.end(), who->Name()) == hit_object_name.end())
return;

HDS.power = CHitImmunity::AffectHit(HDS.power, HDS.hit_type);
float hit_scale = 1.f, wound_scale = 1.f;
CDamageManager::HitScale(HDS.bone(), hit_scale, wound_scale);
Expand Down
1 change: 1 addition & 0 deletions src/xrGame/DestroyablePhysicsObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CDestroyablePhysicsObject : public CPhysicObject,
float m_fHealth;
ref_sound m_destroy_sound;
shared_str m_destroy_particles;
xr_vector<pcstr> hit_object_name;

public:
CDestroyablePhysicsObject();
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/PHCollisionDamageReceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void CPHCollisionDamageReceiver::CollisionHit(u16 source_id, u16 bone_id, float
SHit HS;

HS.GenHeader(GE_HIT, ph->ID()); // ph->u_EventGen(P,GE_HIT,ph->ID());
HS.whoID = ph->ID(); // P.w_u16 (ph->ID());
HS.whoID = source_id; // P.w_u16 (ph->ID());
HS.weaponID = source_id; // P.w_u16 (source_id);
HS.dir = dir; // P.w_dir (dir);
HS.power = power; // P.w_float (power);
Expand Down
11 changes: 10 additions & 1 deletion src/xrGame/PHDestroyable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,17 @@ void CPHDestroyable::Load(CInifile* ini, LPCSTR section)
if (data.Data.size() > 0)
m_flags.set(fl_destroyable, true);
for (const auto& I : data.Data)
if (I.first.size())
{
if (I.first.empty())
continue;
m_destroyed_obj_visual_names.push_back(I.first);
u32 count = 1;
if (!I.second.empty())
count = atoi(I.second.c_str());

for (u32 i = 0; i < count; ++i)
m_destroyed_obj_visual_names.push_back(I.first);
}
}
}
void CPHDestroyable::Load(LPCSTR section)
Expand Down

0 comments on commit 0f09f03

Please sign in to comment.