Skip to content

Commit

Permalink
Update cluster grenade fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
tx00100xt committed Jan 7, 2024
1 parent 3a3e4dd commit d6c3f90
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
32 changes: 27 additions & 5 deletions Sources/EntitiesMP/Player.es
Original file line number Diff line number Diff line change
Expand Up @@ -3130,13 +3130,35 @@ functions:
if (IsOfClass(penInflictor, "Player") && penInflictor!=this) {
return;
}
}

// check for friendly fire (cluster grenade)
if (!GetSP()->sp_bFriendlyFire && GetSP()->sp_bCooperative) {
if (IsOfClass(penInflictor, "Projectile")) {
if (dmtType == DMT_EXPLOSION) {
{FOREACHINDYNAMICCONTAINER(_pNetwork->ga_World.wo_cenEntities, CEntity, pen) {
if(IsDerivedFromClass(pen, "Projectile")) {
// searching marked entity (not destroyed at this time)
if(((CProjectile&)*pen).m_bClusterGrenadeFound == TRUE) {
// the marked entities have not yet been destroyed - so we skip
fDamageAmmount = 0.0f;
}
}
}}
}
}
}

// check for difficulty EASY or TOURIST
if (GetSP()->sp_gdGameDifficulty<=CSessionProperties::GD_EASY) {
if (IsOfClass(penInflictor, "Projectile")) {
if (dmtType == DMT_EXPLOSION) {
{FOREACHINDYNAMICCONTAINER(_pNetwork->ga_World.wo_cenEntities, CEntity, pen) {
if(IsDerivedFromClass(pen, "Projectile")) {
if(((CProjectile&)*pen).m_strName == "ClusterGrenadeExplosion") {
// CPrintF("Skip Projectile damage: %s\n",(const char*)((CProjectile&)*pen).m_strName); // Debug messag
return;
{FOREACHINDYNAMICCONTAINER(_pNetwork->ga_World.wo_cenEntities, CEntity, pen) {
if(IsDerivedFromClass(pen, "Projectile")) {
// searching marked entity (not destroyed at this time)
if(((CProjectile&)*pen).m_bClusterGrenadeFound == TRUE) {
// the marked entities have not yet been destroyed - so we skip
fDamageAmmount = 0.0f;
}
}
}}
Expand Down
17 changes: 11 additions & 6 deletions Sources/EntitiesMP/Projectile.es
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ properties:
26 FLOAT m_tmInvisibility = 0.0f, // don't render before given time
27 INDEX m_iRebounds = 0, // how many times to rebound
28 FLOAT m_fStretch=1.0f, // stretch
29 CTString m_strName = "...Projectile...",
29 BOOL m_bClusterGrenadeFound = FALSE,

30 CSoundObject m_soEffect, // sound channel
31 CSoundObject m_soExplosion, // sound channel
Expand Down Expand Up @@ -1760,11 +1760,12 @@ void ClusterGrenadeExplosion(void) {
pl.pl_OrientationAngle(2) = AngleDeg(fPitch);

CEntityPointer penProjectile = CreateEntity(pl, CLASS_PROJECTILE);
((CProjectile&)*penProjectile.ep_pen).m_strName = "ClusterGrenadeExplosion";
ELaunchProjectile eLaunch;
eLaunch.penLauncher = this;
eLaunch.prtType = PRT_GRENADE_CLUSTERED;
eLaunch.fSpeed = fSpeed;
// mark created entitiy
((CProjectile&)*penProjectile.ep_pen).m_bClusterGrenadeFound = TRUE;
penProjectile->Initialize(eLaunch);
}
for( INDEX iDebris2=0; iDebris2<1; iDebris2++)
Expand All @@ -1781,11 +1782,12 @@ void ClusterGrenadeExplosion(void) {
pl.pl_OrientationAngle(2) = AngleDeg(fPitch);

CEntityPointer penProjectile = CreateEntity(pl, CLASS_PROJECTILE);
((CProjectile&)*penProjectile.ep_pen).m_strName = "ClusterGrenadeExplosion";
ELaunchProjectile eLaunch;
eLaunch.penLauncher = this;
eLaunch.prtType = PRT_GRENADE_CLUSTERED;
eLaunch.fSpeed = fSpeed;
// mark created entitiy
((CProjectile&)*penProjectile.ep_pen).m_bClusterGrenadeFound = TRUE;
penProjectile->Initialize(eLaunch);
}
for( INDEX iDebris3=0; iDebris3<1; iDebris3++)
Expand All @@ -1802,11 +1804,12 @@ void ClusterGrenadeExplosion(void) {
pl.pl_OrientationAngle(2) = AngleDeg(fPitch);

CEntityPointer penProjectile = CreateEntity(pl, CLASS_PROJECTILE);
((CProjectile&)*penProjectile.ep_pen).m_strName = "ClusterGrenadeExplosion";
ELaunchProjectile eLaunch;
eLaunch.penLauncher = this;
eLaunch.prtType = PRT_GRENADE_CLUSTERED;
eLaunch.fSpeed = fSpeed;
// mark created entitiy
((CProjectile&)*penProjectile.ep_pen).m_bClusterGrenadeFound = TRUE;
penProjectile->Initialize(eLaunch);
}
for( INDEX iDebris4=0; iDebris4<1; iDebris4++)
Expand All @@ -1823,11 +1826,12 @@ void ClusterGrenadeExplosion(void) {
pl.pl_OrientationAngle(2) = AngleDeg(fPitch);

CEntityPointer penProjectile = CreateEntity(pl, CLASS_PROJECTILE);
((CProjectile&)*penProjectile.ep_pen).m_strName = "ClusterGrenadeExplosion";
ELaunchProjectile eLaunch;
eLaunch.penLauncher = this;
eLaunch.prtType = PRT_GRENADE_CLUSTERED;
eLaunch.fSpeed = fSpeed;
// mark created entitiy
((CProjectile&)*penProjectile.ep_pen).m_bClusterGrenadeFound = TRUE;
penProjectile->Initialize(eLaunch);
}
for( INDEX iDebris5=0; iDebris5<1; iDebris5++)
Expand All @@ -1844,11 +1848,12 @@ void ClusterGrenadeExplosion(void) {
pl.pl_OrientationAngle(2) = AngleDeg(fPitch);

CEntityPointer penProjectile = CreateEntity(pl, CLASS_PROJECTILE);
((CProjectile&)*penProjectile.ep_pen).m_strName = "ClusterGrenadeExplosion";
ELaunchProjectile eLaunch;
eLaunch.penLauncher = this;
eLaunch.prtType = PRT_GRENADE_CLUSTERED;
eLaunch.fSpeed = fSpeed;
// mark created entitiy
((CProjectile&)*penProjectile.ep_pen).m_bClusterGrenadeFound = TRUE;
penProjectile->Initialize(eLaunch);
}
};
Expand Down

0 comments on commit d6c3f90

Please sign in to comment.