Skip to content

Commit 0f09f03

Browse files
authored
Merge pull request OpenXRay#1020 from Graff46/project2/dev
2 parents 7c6eab4 + c8fc259 commit 0f09f03

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

src/xrGame/DestroyablePhysicsObject.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ bool CDestroyablePhysicsObject::net_Spawn(CSE_Abstract* DC)
5858
m_destroy_sound.create(ini->r_string("sound", "break_sound"), st_Effect, sg_SourceType);
5959
if (ini->section_exist("particles"))
6060
m_destroy_particles = ini->r_string("particles", "destroy_particles");
61+
if (ini->section_exist("hit_from"))
62+
{
63+
CInifile::Sect& data = ini->r_section("hit_from");
64+
if (data.Data.size() > 0)
65+
{
66+
for (auto I = data.Data.cbegin(); I != data.Data.cend(); ++I)
67+
hit_object_name.push_back(I->first.c_str());
68+
}
69+
}
6170
}
6271
CParticlesPlayer::LoadParticles(K);
6372
RunStartupAnim(DC);
@@ -70,8 +79,12 @@ bool CDestroyablePhysicsObject::net_Spawn(CSE_Abstract* DC)
7079
void CDestroyablePhysicsObject::Hit(SHit* pHDS)
7180
{
7281
SHit HDS = *pHDS;
73-
callback(GameObject::eHit)(
74-
lua_game_object(), HDS.power, HDS.dir, smart_cast<const CGameObject*>(HDS.who)->lua_game_object(), HDS.bone());
82+
IGameObject* who = HDS.who;
83+
callback(GameObject::eHit)(lua_game_object(), HDS.power, HDS.dir, who->lua_game_object(), HDS.bone());
84+
85+
if (!hit_object_name.empty() && std::find(hit_object_name.begin(), hit_object_name.end(), who->Name()) == hit_object_name.end())
86+
return;
87+
7588
HDS.power = CHitImmunity::AffectHit(HDS.power, HDS.hit_type);
7689
float hit_scale = 1.f, wound_scale = 1.f;
7790
CDamageManager::HitScale(HDS.bone(), hit_scale, wound_scale);

src/xrGame/DestroyablePhysicsObject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class CDestroyablePhysicsObject : public CPhysicObject,
1313
float m_fHealth;
1414
ref_sound m_destroy_sound;
1515
shared_str m_destroy_particles;
16+
xr_vector<pcstr> hit_object_name;
1617

1718
public:
1819
CDestroyablePhysicsObject();

src/xrGame/PHCollisionDamageReceiver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void CPHCollisionDamageReceiver::CollisionHit(u16 source_id, u16 bone_id, float
4949
SHit HS;
5050

5151
HS.GenHeader(GE_HIT, ph->ID()); // ph->u_EventGen(P,GE_HIT,ph->ID());
52-
HS.whoID = ph->ID(); // P.w_u16 (ph->ID());
52+
HS.whoID = source_id; // P.w_u16 (ph->ID());
5353
HS.weaponID = source_id; // P.w_u16 (source_id);
5454
HS.dir = dir; // P.w_dir (dir);
5555
HS.power = power; // P.w_float (power);

src/xrGame/PHDestroyable.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,17 @@ void CPHDestroyable::Load(CInifile* ini, LPCSTR section)
173173
if (data.Data.size() > 0)
174174
m_flags.set(fl_destroyable, true);
175175
for (const auto& I : data.Data)
176-
if (I.first.size())
176+
{
177+
if (I.first.empty())
178+
continue;
179+
m_destroyed_obj_visual_names.push_back(I.first);
180+
u32 count = 1;
181+
if (!I.second.empty())
182+
count = atoi(I.second.c_str());
183+
184+
for (u32 i = 0; i < count; ++i)
177185
m_destroyed_obj_visual_names.push_back(I.first);
186+
}
178187
}
179188
}
180189
void CPHDestroyable::Load(LPCSTR section)

0 commit comments

Comments
 (0)