mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
reset flags and projectiles when leaving the game layer too much. Closes #385
This commit is contained in:
parent
26f7c67895
commit
df47aedbfe
|
@ -544,18 +544,12 @@ void CCharacter::Tick()
|
|||
m_Core.m_Input = m_Input;
|
||||
m_Core.Tick(true);
|
||||
|
||||
// handle death-tiles
|
||||
// handle death-tiles and leaving gamelayer
|
||||
if(GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
|
||||
GameServer()->Collision()->GetCollisionAt(m_Pos.x+m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
|
||||
GameServer()->Collision()->GetCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y-m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
|
||||
GameServer()->Collision()->GetCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH)
|
||||
{
|
||||
Die(m_pPlayer->GetCID(), WEAPON_WORLD);
|
||||
}
|
||||
|
||||
// kill player when leaving gamelayer
|
||||
if((int)m_Pos.x/32 < -200 || (int)m_Pos.x/32 > GameServer()->Collision()->GetWidth()+200 ||
|
||||
(int)m_Pos.y/32 < -200 || (int)m_Pos.y/32 > GameServer()->Collision()->GetHeight()+200)
|
||||
GameServer()->Collision()->GetCollisionAt(m_Pos.x-m_ProximityRadius/3.f, m_Pos.y+m_ProximityRadius/3.f)&CCollision::COLFLAG_DEATH ||
|
||||
GameLayerClipped(m_Pos))
|
||||
{
|
||||
Die(m_pPlayer->GetCID(), WEAPON_WORLD);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ void CProjectile::Tick()
|
|||
|
||||
m_LifeSpan--;
|
||||
|
||||
if(TargetChr || Collide || m_LifeSpan < 0)
|
||||
if(TargetChr || Collide || m_LifeSpan < 0 || GameLayerClipped(CurPos))
|
||||
{
|
||||
if(m_LifeSpan >= 0 || m_Weapon == WEAPON_GRENADE)
|
||||
GameServer()->CreateSound(CurPos, m_SoundImpact);
|
||||
|
|
|
@ -50,3 +50,9 @@ int CEntity::NetworkClipped(int SnappingClient, vec2 CheckPos)
|
|||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CEntity::GameLayerClipped(vec2 CheckPos)
|
||||
{
|
||||
return round(CheckPos.x)/32 < -200 || round(CheckPos.x)/32 > GameServer()->Collision()->GetWidth()+200 ||
|
||||
round(CheckPos.y)/32 < -200 || round(CheckPos.y)/32 > GameServer()->Collision()->GetHeight()+200 ? true : false;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,8 @@ public:
|
|||
*/
|
||||
int NetworkClipped(int SnappingClient);
|
||||
int NetworkClipped(int SnappingClient, vec2 CheckPos);
|
||||
|
||||
|
||||
bool GameLayerClipped(vec2 CheckPos);
|
||||
|
||||
/*
|
||||
Variable: proximity_radius
|
||||
|
|
|
@ -91,8 +91,8 @@ void CGameControllerCTF::Tick()
|
|||
if(!F)
|
||||
continue;
|
||||
|
||||
// flag hits death-tile, reset it
|
||||
if(GameServer()->Collision()->GetCollisionAt(F->m_Pos.x, F->m_Pos.y)&CCollision::COLFLAG_DEATH)
|
||||
// flag hits death-tile or left the game layer, reset it
|
||||
if(GameServer()->Collision()->GetCollisionAt(F->m_Pos.x, F->m_Pos.y)&CCollision::COLFLAG_DEATH || F->GameLayerClipped(F->m_Pos))
|
||||
{
|
||||
GameServer()->CreateSoundGlobal(SOUND_CTF_RETURN);
|
||||
F->Reset();
|
||||
|
|
Loading…
Reference in a new issue