2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef GAME_SERVER_ENTITIES_CHARACTER_H
|
|
|
|
#define GAME_SERVER_ENTITIES_CHARACTER_H
|
|
|
|
|
|
|
|
#include <game/server/entity.h>
|
|
|
|
#include <game/generated/server_data.h>
|
|
|
|
#include <game/generated/protocol.h>
|
|
|
|
#include <game/gamecore.h>
|
|
|
|
|
2010-09-08 16:22:11 +00:00
|
|
|
class CGameTeams;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
WEAPON_GAME = -3, // team switching etc
|
|
|
|
WEAPON_SELF = -2, // console kill command
|
|
|
|
WEAPON_WORLD = -1, // death tiles etc
|
|
|
|
};
|
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
enum
|
|
|
|
{
|
2010-10-29 21:28:15 +00:00
|
|
|
DDRACE_NONE = 0,
|
|
|
|
DDRACE_STARTED,
|
2010-12-19 03:48:16 +00:00
|
|
|
DDRACE_CHEAT, // no time and won't start again unless ordered by a mod or death
|
|
|
|
DDRACE_FINISHED
|
2010-07-29 05:21:18 +00:00
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CCharacter : public CEntity
|
|
|
|
{
|
|
|
|
MACRO_ALLOC_POOL_ID()
|
2010-09-17 11:26:06 +00:00
|
|
|
void HandleFly();
|
2010-10-08 13:33:42 +00:00
|
|
|
void HandleTiles(int Index);
|
|
|
|
float m_Time;
|
2010-10-11 19:27:35 +00:00
|
|
|
int m_LastBroadcast;
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
2010-06-03 15:39:42 +00:00
|
|
|
//character's size
|
|
|
|
static const int ms_PhysSize = 28;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CCharacter(CGameWorld *pWorld);
|
|
|
|
|
|
|
|
virtual void Reset();
|
|
|
|
virtual void Destroy();
|
|
|
|
virtual void Tick();
|
|
|
|
virtual void TickDefered();
|
|
|
|
virtual void Snap(int SnappingClient);
|
|
|
|
|
|
|
|
bool IsGrounded();
|
2010-08-22 13:17:57 +00:00
|
|
|
//bool m_Paused;
|
|
|
|
|
2010-09-08 16:22:11 +00:00
|
|
|
CGameTeams* Teams();
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void SetWeapon(int W);
|
|
|
|
void HandleWeaponSwitch();
|
|
|
|
void DoWeaponSwitch();
|
|
|
|
|
|
|
|
void HandleWeapons();
|
|
|
|
void HandleNinja();
|
|
|
|
|
|
|
|
void OnPredictedInput(CNetObj_PlayerInput *pNewInput);
|
|
|
|
void OnDirectInput(CNetObj_PlayerInput *pNewInput);
|
|
|
|
void FireWeapon();
|
|
|
|
|
|
|
|
void Die(int Killer, int Weapon);
|
|
|
|
bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon);
|
|
|
|
|
|
|
|
bool Spawn(class CPlayer *pPlayer, vec2 Pos);
|
|
|
|
bool Remove();
|
|
|
|
|
|
|
|
bool IncreaseHealth(int Amount);
|
|
|
|
bool IncreaseArmor(int Amount);
|
|
|
|
|
|
|
|
bool GiveWeapon(int Weapon, int Ammo);
|
|
|
|
void GiveNinja();
|
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
void ResetPos();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
bool Freeze(int Time);
|
|
|
|
bool Freeze();
|
|
|
|
bool UnFreeze();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
void GiveAllWeapons();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
void SetEmote(int Emote, int Tick);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
bool IsAlive() const { return m_Alive; }
|
|
|
|
class CPlayer *GetPlayer() { return m_pPlayer; }
|
|
|
|
// the player core for the physics
|
|
|
|
CCharacterCore m_Core;
|
2010-05-29 07:25:38 +00:00
|
|
|
struct WeaponStat
|
|
|
|
{
|
|
|
|
int m_AmmoRegenStart;
|
|
|
|
int m_Ammo;
|
|
|
|
int m_Ammocost;
|
|
|
|
bool m_Got;
|
|
|
|
|
|
|
|
} m_aWeapons[NUM_WEAPONS];
|
|
|
|
int m_ActiveWeapon;
|
|
|
|
int m_LastWeapon;
|
2010-07-29 05:21:18 +00:00
|
|
|
// player controlling this character
|
|
|
|
class CPlayer *m_pPlayer;
|
|
|
|
|
2010-10-29 21:28:15 +00:00
|
|
|
int m_DDRaceState;
|
2010-07-29 05:21:18 +00:00
|
|
|
|
2010-08-28 20:53:42 +00:00
|
|
|
void OnFinish();
|
|
|
|
int Team();
|
2010-09-21 19:09:11 +00:00
|
|
|
bool CanCollide(int Cid);
|
|
|
|
bool SameTeam(int Cid);
|
2010-08-28 20:53:42 +00:00
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
vec2 m_ActivationDir;
|
|
|
|
int m_ActivationTick;
|
|
|
|
int m_CurrentMoveTime;
|
|
|
|
|
|
|
|
} m_Ninja;
|
|
|
|
|
|
|
|
int m_HammerType;
|
|
|
|
bool m_Super;
|
2010-10-02 00:06:42 +00:00
|
|
|
int m_TeamBeforeSuper;
|
2010-09-17 11:35:53 +00:00
|
|
|
bool m_Fly;
|
2010-07-29 05:21:18 +00:00
|
|
|
|
|
|
|
//DDRace
|
|
|
|
int m_FreezeTime;
|
|
|
|
int m_FreezeTick;
|
|
|
|
|
2010-09-10 06:55:04 +00:00
|
|
|
int m_Doored;
|
2010-07-29 05:21:18 +00:00
|
|
|
|
|
|
|
vec2 m_OldPos;
|
|
|
|
vec2 m_OlderPos;
|
|
|
|
|
|
|
|
bool m_Alive;
|
|
|
|
|
|
|
|
// weapon info
|
|
|
|
CEntity *m_apHitObjects[10];
|
|
|
|
int m_NumObjectsHit;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_QueuedWeapon;
|
|
|
|
|
|
|
|
int m_ReloadTimer;
|
2010-11-04 23:52:37 +00:00
|
|
|
int m_PainSoundTimer;
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_AttackTick;
|
|
|
|
|
|
|
|
int m_DamageTaken;
|
|
|
|
|
|
|
|
int m_EmoteType;
|
|
|
|
int m_EmoteStop;
|
|
|
|
|
|
|
|
// last tick that the player took any action ie some input
|
|
|
|
int m_LastAction;
|
|
|
|
|
|
|
|
// these are non-heldback inputs
|
|
|
|
CNetObj_PlayerInput m_LatestPrevInput;
|
|
|
|
CNetObj_PlayerInput m_LatestInput;
|
|
|
|
|
|
|
|
// input
|
|
|
|
CNetObj_PlayerInput m_PrevInput;
|
|
|
|
CNetObj_PlayerInput m_Input;
|
|
|
|
int m_NumInputs;
|
|
|
|
int m_Jumped;
|
|
|
|
|
|
|
|
int m_DamageTakenTick;
|
|
|
|
|
|
|
|
int m_Health;
|
|
|
|
int m_Armor;
|
|
|
|
|
|
|
|
// ninja
|
2010-07-29 05:21:18 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
int m_PlayerState;// if the client is chatting, accessing a menu or so
|
2010-07-29 05:21:18 +00:00
|
|
|
|
|
|
|
bool m_IsWater;
|
|
|
|
bool m_DoSplash;
|
|
|
|
int m_LastMove;
|
2010-07-29 14:53:25 +00:00
|
|
|
// DDRace var
|
2010-07-29 05:21:18 +00:00
|
|
|
int m_StartTime;
|
|
|
|
int m_RefreshTime;
|
2010-08-10 04:28:17 +00:00
|
|
|
|
2010-08-24 01:30:22 +00:00
|
|
|
int m_LastBooster;
|
2010-08-10 04:28:17 +00:00
|
|
|
vec2 m_PrevPos;
|
2010-07-29 05:21:18 +00:00
|
|
|
|
|
|
|
// checkpoints
|
|
|
|
int m_CpTick;
|
|
|
|
int m_CpActive;
|
2010-08-29 00:05:45 +00:00
|
|
|
float m_CpCurrent[25];
|
2010-07-29 05:21:18 +00:00
|
|
|
|
2010-08-27 07:09:47 +00:00
|
|
|
int m_BroadCast;
|
|
|
|
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileIndex;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileFlags;
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileFIndex;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileFFlags;
|
2010-09-25 16:39:52 +00:00
|
|
|
int m_TileSIndex;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileSFlags;
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileIndexL;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileFlagsL;
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileFIndexL;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileFFlagsL;
|
2010-09-25 16:39:52 +00:00
|
|
|
int m_TileSIndexL;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileSFlagsL;
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileIndexR;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileFlagsR;
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileFIndexR;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileFFlagsR;
|
2010-09-25 16:39:52 +00:00
|
|
|
int m_TileSIndexR;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileSFlagsR;
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileIndexT;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileFlagsT;
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileFIndexT;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileFFlagsT;
|
2010-09-25 16:39:52 +00:00
|
|
|
int m_TileSIndexT;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileSFlagsT;
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileIndexB;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileFlagsB;
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileFIndexB;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileFFlagsB;
|
2010-09-25 16:39:52 +00:00
|
|
|
int m_TileSIndexB;
|
2010-11-01 01:51:17 +00:00
|
|
|
int m_TileSFlagsB;
|
2010-09-19 09:01:54 +00:00
|
|
|
|
2010-09-10 06:55:04 +00:00
|
|
|
vec2 m_Intersection;
|
2010-09-07 05:15:24 +00:00
|
|
|
bool m_EyeEmote;
|
2010-05-29 07:25:38 +00:00
|
|
|
// info for dead reckoning
|
|
|
|
int m_ReckoningTick; // tick that we are performing dead reckoning From
|
|
|
|
CCharacterCore m_SendCore; // core that we should send
|
|
|
|
CCharacterCore m_ReckoningCore; // the dead reckoning core
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|