revert to double explotion plasma bullets if the bullet hits obstacle

and player at the same time
This commit is contained in:
c0d3d3v 2022-05-17 14:28:37 +02:00
parent 9180fa70e4
commit 71c9a49776
No known key found for this signature in database
GPG key ID: 068AF680530DFF31
3 changed files with 25 additions and 16 deletions

View file

@ -66,6 +66,7 @@ class CHud : public CComponent
void RenderLocalTime(float x); void RenderLocalTime(float x);
static constexpr float MOVEMENT_INFORMATION_LINE_HEIGHT = 8.0f; static constexpr float MOVEMENT_INFORMATION_LINE_HEIGHT = 8.0f;
public: public:
CHud(); CHud();
virtual int Sizeof() const override { return sizeof(*this); } virtual int Sizeof() const override { return sizeof(*this); }

View file

@ -44,21 +44,9 @@ void CPlasma::Tick()
} }
m_LifeTime--; m_LifeTime--;
Move(); Move();
if(!HitCharacter(pTarget)) HitCharacter(pTarget);
{ // Plasma bullets may explode twice if they would hit both a player and an obstacle in the next move step
// Check if the plasma bullet is stopped by a solid block or a laser stopper HitObstacle(pTarget);
int HasIntersection = GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Pos + m_Core, 0, 0);
if(HasIntersection)
{
if(m_Explosive)
{
// Even in the case of an explosion due to a collision with obstacles, only one player is affected
GameServer()->CreateExplosion(
m_Pos, m_ForClientID, WEAPON_GRENADE, true, pTarget->Team(), pTarget->TeamMask());
}
Reset();
}
}
} }
void CPlasma::Move() void CPlasma::Move()
@ -95,6 +83,24 @@ bool CPlasma::HitCharacter(CCharacter *pTarget)
return true; return true;
} }
bool CPlasma::HitObstacle(CCharacter *pTarget)
{
// Check if the plasma bullet is stopped by a solid block or a laser stopper
int HasIntersection = GameServer()->Collision()->IntersectNoLaser(m_Pos, m_Pos + m_Core, 0, 0);
if(HasIntersection)
{
if(m_Explosive)
{
// Even in the case of an explosion due to a collision with obstacles, only one player is affected
GameServer()->CreateExplosion(
m_Pos, m_ForClientID, WEAPON_GRENADE, true, pTarget->Team(), pTarget->TeamMask());
}
Reset();
return true;
}
return false;
}
void CPlasma::Reset() void CPlasma::Reset()
{ {
m_MarkedForDestroy = true; m_MarkedForDestroy = true;

View file

@ -14,6 +14,7 @@
* impact but at the last position of the plasma bullet. The same applies if a plasma bullet explodes due to a collision * impact but at the last position of the plasma bullet. The same applies if a plasma bullet explodes due to a collision
* with a laser stopper or a solid block * with a laser stopper or a solid block
* Plasma bullets move every tick in the assigned direction and then accelerate by the factor PLASMA_ACCEL * Plasma bullets move every tick in the assigned direction and then accelerate by the factor PLASMA_ACCEL
* Plasma bullets can explode twice if they would hit both a player and an obstacle in the next movement step
* Plasma bullets will stop existing as soon as: * Plasma bullets will stop existing as soon as:
* - The player they were created for do no longer exist * - The player they were created for do no longer exist
* - They have had a collision with a player, a solid block or a laser stopper * - They have had a collision with a player, a solid block or a laser stopper
@ -28,8 +29,9 @@ class CPlasma : public CEntity
int m_EvalTick; int m_EvalTick;
int m_LifeTime; int m_LifeTime;
bool HitCharacter(CCharacter *pTarget);
void Move(); void Move();
bool HitCharacter(CCharacter *pTarget);
bool HitObstacle(CCharacter *pTarget);
public: public:
CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze, CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze,