disable dragger beams soon, not only every 150ms

This commit is contained in:
c0d3d3v 2022-05-26 19:33:01 +02:00
parent 3b81157013
commit 62c99515d5
No known key found for this signature in database
GPG key ID: 068AF680530DFF31
3 changed files with 15 additions and 4 deletions

View file

@ -141,7 +141,7 @@ void CDragger::LookForPlayersToDrag()
// Create Dragger Beams which have not been created yet // Create Dragger Beams which have not been created yet
if(IsTarget[i] && m_apDraggerBeam[i] == nullptr) if(IsTarget[i] && m_apDraggerBeam[i] == nullptr)
{ {
m_apDraggerBeam[i] = new CDraggerBeam(&GameServer()->m_World, this, m_Pos, m_Strength, m_IgnoreWalls, i); m_apDraggerBeam[i] = new CDraggerBeam(&GameServer()->m_World, this, m_Pos, m_Strength, m_IgnoreWalls, i, m_Layer, m_Number);
} }
// Remove dragger beams that have not yet been deleted // Remove dragger beams that have not yet been deleted
else if(!IsTarget[i] && m_apDraggerBeam[i] != nullptr) else if(!IsTarget[i] && m_apDraggerBeam[i] != nullptr)

View file

@ -11,7 +11,7 @@
#include <game/server/teams.h> #include <game/server/teams.h>
CDraggerBeam::CDraggerBeam(CGameWorld *pGameWorld, CDragger *pDragger, vec2 Pos, float Strength, bool IgnoreWalls, CDraggerBeam::CDraggerBeam(CGameWorld *pGameWorld, CDragger *pDragger, vec2 Pos, float Strength, bool IgnoreWalls,
int ForClientID) : int ForClientID, int Layer, int Number) :
CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER) CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
{ {
m_pDragger = pDragger; m_pDragger = pDragger;
@ -20,6 +20,8 @@ CDraggerBeam::CDraggerBeam(CGameWorld *pGameWorld, CDragger *pDragger, vec2 Pos,
m_IgnoreWalls = IgnoreWalls; m_IgnoreWalls = IgnoreWalls;
m_ForClientID = ForClientID; m_ForClientID = ForClientID;
m_Active = true; m_Active = true;
m_Layer = Layer;
m_Number = Number;
m_EvalTick = Server()->Tick(); m_EvalTick = Server()->Tick();
GameWorld()->InsertEntity(this); GameWorld()->InsertEntity(this);
@ -40,11 +42,20 @@ void CDraggerBeam::Tick()
return; return;
} }
// The following checks are necessary, because the checks in CDragger::LookForPlayersToDrag only take place every 150ms
// When the dragger is disabled for the target player's team, the dragger beam dissolves
if(m_Layer == LAYER_SWITCH && m_Number > 0 &&
!GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pTarget->Team()])
{
Reset();
return;
}
// When the dragger can no longer reach the target player, the dragger beam dissolves
int IsReachable = int IsReachable =
m_IgnoreWalls ? m_IgnoreWalls ?
!GameServer()->Collision()->IntersectNoLaserNW(m_Pos, pTarget->m_Pos, 0, 0) : !GameServer()->Collision()->IntersectNoLaserNW(m_Pos, pTarget->m_Pos, 0, 0) :
!GameServer()->Collision()->IntersectNoLaser(m_Pos, pTarget->m_Pos, 0, 0); !GameServer()->Collision()->IntersectNoLaser(m_Pos, pTarget->m_Pos, 0, 0);
// This check is necessary because the check in CDragger::LookForPlayersToDrag only happens every 150ms
if(!IsReachable || if(!IsReachable ||
distance(pTarget->m_Pos, m_Pos) >= g_Config.m_SvDraggerRange || !pTarget->IsAlive()) distance(pTarget->m_Pos, m_Pos) >= g_Config.m_SvDraggerRange || !pTarget->IsAlive())
{ {

View file

@ -29,7 +29,7 @@ class CDraggerBeam : public CEntity
bool m_Active; bool m_Active;
public: public:
CDraggerBeam(CGameWorld *pGameWorld, CDragger *pDragger, vec2 Pos, float Strength, bool IgnoreWalls, int ForClientID); CDraggerBeam(CGameWorld *pGameWorld, CDragger *pDragger, vec2 Pos, float Strength, bool IgnoreWalls, int ForClientID, int Layer, int Number);
void SetPos(vec2 Pos); void SetPos(vec2 Pos);