mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
revert to double explotion plasma bullets if the bullet hits obstacle
and player at the same time
This commit is contained in:
parent
9180fa70e4
commit
71c9a49776
|
@ -66,6 +66,7 @@ class CHud : public CComponent
|
|||
void RenderLocalTime(float x);
|
||||
|
||||
static constexpr float MOVEMENT_INFORMATION_LINE_HEIGHT = 8.0f;
|
||||
|
||||
public:
|
||||
CHud();
|
||||
virtual int Sizeof() const override { return sizeof(*this); }
|
||||
|
|
|
@ -44,21 +44,9 @@ void CPlasma::Tick()
|
|||
}
|
||||
m_LifeTime--;
|
||||
Move();
|
||||
if(!HitCharacter(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();
|
||||
}
|
||||
}
|
||||
HitCharacter(pTarget);
|
||||
// Plasma bullets may explode twice if they would hit both a player and an obstacle in the next move step
|
||||
HitObstacle(pTarget);
|
||||
}
|
||||
|
||||
void CPlasma::Move()
|
||||
|
@ -95,6 +83,24 @@ bool CPlasma::HitCharacter(CCharacter *pTarget)
|
|||
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()
|
||||
{
|
||||
m_MarkedForDestroy = true;
|
||||
|
|
|
@ -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
|
||||
* 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 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:
|
||||
* - 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
|
||||
|
@ -28,8 +29,9 @@ class CPlasma : public CEntity
|
|||
int m_EvalTick;
|
||||
int m_LifeTime;
|
||||
|
||||
bool HitCharacter(CCharacter *pTarget);
|
||||
void Move();
|
||||
bool HitCharacter(CCharacter *pTarget);
|
||||
bool HitObstacle(CCharacter *pTarget);
|
||||
|
||||
public:
|
||||
CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze,
|
||||
|
|
Loading…
Reference in a new issue