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>
|
2011-01-29 00:59:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#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
|
|
|
|
};
|
|
|
|
|
|
|
|
class CCharacter : public CEntity
|
|
|
|
{
|
|
|
|
MACRO_ALLOC_POOL_ID()
|
2011-04-13 18:37:12 +00:00
|
|
|
|
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);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void Reset();
|
|
|
|
virtual void Destroy();
|
|
|
|
virtual void Tick();
|
|
|
|
virtual void TickDefered();
|
|
|
|
virtual void Snap(int SnappingClient);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
bool IsGrounded();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void SetWeapon(int W);
|
|
|
|
void HandleWeaponSwitch();
|
|
|
|
void DoWeaponSwitch();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void HandleWeapons();
|
|
|
|
void HandleNinja();
|
|
|
|
|
|
|
|
void OnPredictedInput(CNetObj_PlayerInput *pNewInput);
|
|
|
|
void OnDirectInput(CNetObj_PlayerInput *pNewInput);
|
|
|
|
void FireWeapon();
|
|
|
|
|
|
|
|
void Die(int Killer, int Weapon);
|
2011-04-13 18:37:12 +00:00
|
|
|
bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
bool Spawn(class CPlayer *pPlayer, vec2 Pos);
|
|
|
|
bool Remove();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
bool IncreaseHealth(int Amount);
|
|
|
|
bool IncreaseArmor(int Amount);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
bool GiveWeapon(int Weapon, int Ammo);
|
|
|
|
void GiveNinja();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
void SetEmote(int Emote, int Tick);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-07-29 05:21:18 +00:00
|
|
|
bool IsAlive() const { return m_Alive; }
|
|
|
|
class CPlayer *GetPlayer() { return m_pPlayer; }
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-01-29 00:59:50 +00:00
|
|
|
private:
|
|
|
|
// player controlling this character
|
|
|
|
class CPlayer *m_pPlayer;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-01-29 00:59:50 +00:00
|
|
|
bool m_Alive;
|
|
|
|
|
|
|
|
// weapon info
|
|
|
|
CEntity *m_apHitObjects[10];
|
|
|
|
int m_NumObjectsHit;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
struct WeaponStat
|
|
|
|
{
|
|
|
|
int m_AmmoRegenStart;
|
|
|
|
int m_Ammo;
|
|
|
|
int m_Ammocost;
|
|
|
|
bool m_Got;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
} m_aWeapons[NUM_WEAPONS];
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_ActiveWeapon;
|
|
|
|
int m_LastWeapon;
|
|
|
|
int m_QueuedWeapon;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_ReloadTimer;
|
|
|
|
int m_AttackTick;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_DamageTaken;
|
|
|
|
|
|
|
|
int m_EmoteType;
|
|
|
|
int m_EmoteStop;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// 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;
|
|
|
|
|
2011-04-13 18:37:12 +00:00
|
|
|
// input
|
2010-05-29 07:25:38 +00:00
|
|
|
CNetObj_PlayerInput m_PrevInput;
|
|
|
|
CNetObj_PlayerInput m_Input;
|
|
|
|
int m_NumInputs;
|
|
|
|
int m_Jumped;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_DamageTakenTick;
|
|
|
|
|
|
|
|
int m_Health;
|
|
|
|
int m_Armor;
|
|
|
|
|
|
|
|
// ninja
|
2011-01-29 00:59:50 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
vec2 m_ActivationDir;
|
|
|
|
int m_ActivationTick;
|
|
|
|
int m_CurrentMoveTime;
|
2011-03-13 18:00:00 +00:00
|
|
|
int m_OldVelAmount;
|
2011-01-29 00:59:50 +00:00
|
|
|
} m_Ninja;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-04-13 18:37:12 +00:00
|
|
|
// the player core for the physics
|
2011-01-29 00:59:50 +00:00
|
|
|
CCharacterCore m_Core;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-01-29 00:59:50 +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
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2011-04-09 06:41:31 +00:00
|
|
|
// DDRace
|
|
|
|
|
|
|
|
|
2011-01-29 00:59:50 +00:00
|
|
|
void HandleTiles(int Index);
|
|
|
|
float m_Time;
|
|
|
|
int m_LastBroadcast;
|
|
|
|
void DDRaceInit();
|
|
|
|
void HandleSkippableTiles(int Index);
|
|
|
|
void DDRaceTick();
|
2011-01-29 23:58:47 +00:00
|
|
|
void DDRacePostCoreTick();
|
2011-01-29 00:59:50 +00:00
|
|
|
void HandleBroadcast();
|
|
|
|
public:
|
|
|
|
CGameTeams* Teams();
|
|
|
|
bool Freeze(int Time);
|
|
|
|
bool Freeze();
|
|
|
|
bool UnFreeze();
|
|
|
|
void GiveAllWeapons();
|
|
|
|
int m_DDRaceState;
|
|
|
|
int Team();
|
2011-02-13 05:35:13 +00:00
|
|
|
bool CanCollide(int ClientID);
|
|
|
|
bool SameTeam(int ClientID);
|
2011-01-29 00:59:50 +00:00
|
|
|
bool m_Super;
|
|
|
|
int m_TeamBeforeSuper;
|
|
|
|
int m_FreezeTime;
|
|
|
|
int m_FreezeTick;
|
|
|
|
bool m_DeepFreeze;
|
|
|
|
bool m_EndlessHook;
|
2011-07-19 21:33:12 +00:00
|
|
|
bool m_Hit;
|
2011-01-29 00:59:50 +00:00
|
|
|
int m_PainSoundTimer;
|
|
|
|
int m_DefEmote;
|
|
|
|
int m_DefEmoteReset;
|
2010-07-29 05:21:18 +00:00
|
|
|
int m_LastMove;
|
|
|
|
int m_StartTime;
|
|
|
|
int m_RefreshTime;
|
2010-08-10 04:28:17 +00:00
|
|
|
vec2 m_PrevPos;
|
2011-05-17 23:12:39 +00:00
|
|
|
int m_TeleCheckpoint;
|
2010-07-29 05:21:18 +00:00
|
|
|
int m_CpTick;
|
|
|
|
int m_CpActive;
|
2010-08-29 00:05:45 +00:00
|
|
|
float m_CpCurrent[25];
|
2011-01-29 00:59:50 +00:00
|
|
|
bool 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-10 06:55:04 +00:00
|
|
|
vec2 m_Intersection;
|
2010-09-07 05:15:24 +00:00
|
|
|
bool m_EyeEmote;
|
2011-01-29 14:31:50 +00:00
|
|
|
int64 m_LastStartWarning;
|
2011-01-29 00:59:50 +00:00
|
|
|
// Setters/Getters because i don't want to modify vanilla vars access modifiers
|
|
|
|
int GetLastWeapon() { return m_LastWeapon; };
|
|
|
|
void SetLastWeapon(int LastWeap) {m_LastWeapon = LastWeap; };
|
|
|
|
int GetActiveWeapon() { return m_ActiveWeapon; };
|
|
|
|
void SetActiveWeapon(int ActiveWeap) {m_ActiveWeapon = ActiveWeap; };
|
|
|
|
void SetLastAction(int LastAction) {m_LastAction = LastAction; };
|
|
|
|
int GetArmor() { return m_Armor; };
|
|
|
|
void SetArmor(int Armor) {m_Armor = Armor; };
|
|
|
|
CCharacterCore GetCore() { return m_Core; };
|
|
|
|
void SetCore(CCharacterCore Core) {m_Core = Core; };
|
|
|
|
CCharacterCore* Core() { return &m_Core; };
|
|
|
|
bool GetWeaponGot(int Type) { return m_aWeapons[Type].m_Got; };
|
|
|
|
void SetWeaponGot(int Type, bool Value) { m_aWeapons[Type].m_Got = Value; };
|
|
|
|
int GetWeaponAmmo(int Type) { return m_aWeapons[Type].m_Ammo; };
|
|
|
|
void SetWeaponAmmo(int Type, int Value) { m_aWeapons[Type].m_Ammo = Value; };
|
|
|
|
bool IsAlive() { return m_Alive; };
|
|
|
|
void SetEmoteType(int EmoteType) { m_EmoteType = EmoteType; };
|
|
|
|
void SetEmoteStop(int EmoteStop) { m_EmoteStop = EmoteStop; };
|
|
|
|
void SetNinjaActivationDir(vec2 ActivationDir) { m_Ninja.m_ActivationDir = ActivationDir; };
|
|
|
|
void SetNinjaActivationTick(int ActivationTick) { m_Ninja.m_ActivationTick = ActivationTick; };
|
|
|
|
void SetNinjaCurrentMoveTime(int CurrentMoveTime) { m_Ninja.m_CurrentMoveTime = CurrentMoveTime; };
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
2011-04-09 06:41:31 +00:00
|
|
|
enum
|
2011-01-29 00:59:50 +00:00
|
|
|
{
|
|
|
|
DDRACE_NONE = 0,
|
|
|
|
DDRACE_STARTED,
|
|
|
|
DDRACE_CHEAT, // no time and won't start again unless ordered by a mod or death
|
|
|
|
DDRACE_FINISHED
|
|
|
|
};
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
#endif
|