ddnet/src/game/server/entities/plasma.h
Robert Müller aa08cfabc2 Fix swapping with dragger beams and plasmas
The client ID referenced by dragger beams and plasmas must also be swapped when two clients are swapped, as those entities should refer to the same character entity as before the swap.

For dragger beams, swapping previously caused the active beams to switch target to another character.

For plasmas, swapping previously caused already shot plasmas to not have an effect on their original target character.

Closes #5865.
2023-04-04 20:07:17 +02:00

47 lines
1.9 KiB
C++

/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
#ifndef GAME_SERVER_ENTITIES_PLASMA_H
#define GAME_SERVER_ENTITIES_PLASMA_H
#include <game/server/entity.h>
/**
* Plasma Bullets are projectiles fired from turrets at a specific target
*
* When hitting a tee, plasma bullets can either freeze or unfreeze the player
* Also, plasma projectiles can explode on impact. However, the player affected by the explosion is not necessarily the
* one the plasma collided with, but if the affected player is not a solo player, then the team-mate with the lowest
* ClientId within the explosion range. Furthermore, the affected player does not feel the explosion at the point of
* 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
* - Their life time of 1.5 seconds has expired
*/
class CPlasma : public CEntity
{
vec2 m_Core;
int m_Freeze;
bool m_Explosive;
int m_ForClientID;
int m_EvalTick;
int m_LifeTime;
void Move();
bool HitCharacter(CCharacter *pTarget);
bool HitObstacle(CCharacter *pTarget);
public:
CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Dir, bool Freeze,
bool Explosive, int ForClientId);
void Reset() override;
void Tick() override;
void Snap(int SnappingClient) override;
void SwapClients(int Client1, int Client2) override;
};
#endif // GAME_SERVER_ENTITIES_PLASMA_H