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
|
|
|
|
|
2020-05-13 20:27:49 +00:00
|
|
|
#include <engine/antibot.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/server/entity.h>
|
2020-06-01 09:40:11 +00:00
|
|
|
#include <game/server/save.h>
|
2011-01-29 00:59:50 +00:00
|
|
|
|
2020-03-11 00:58:50 +00:00
|
|
|
class CAntibot;
|
2010-09-08 16:22:11 +00:00
|
|
|
class CGameTeams;
|
2020-03-11 00:58:50 +00:00
|
|
|
struct CAntibotCharacterData;
|
2010-09-08 16:22:11 +00:00
|
|
|
|
2014-02-19 21:30:34 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
FAKETUNE_FREEZE = 1,
|
|
|
|
FAKETUNE_SOLO = 2,
|
2014-03-01 13:29:14 +00:00
|
|
|
FAKETUNE_NOJUMP = 4,
|
2014-04-06 10:22:27 +00:00
|
|
|
FAKETUNE_NOCOLL = 8,
|
|
|
|
FAKETUNE_NOHOOK = 16,
|
2014-04-13 23:34:50 +00:00
|
|
|
FAKETUNE_JETPACK = 32,
|
2016-04-20 09:59:14 +00:00
|
|
|
FAKETUNE_NOHAMMER = 64,
|
2014-02-19 21:30:34 +00:00
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CCharacter : public CEntity
|
|
|
|
{
|
|
|
|
MACRO_ALLOC_POOL_ID()
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2014-07-26 12:46:31 +00:00
|
|
|
friend class CSaveTee; // need to use core
|
2015-07-09 00:08:14 +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();
|
2012-01-09 23:49:31 +00:00
|
|
|
virtual void TickPaused();
|
2010-05-29 07:25:38 +00:00
|
|
|
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);
|
2014-12-25 10:37:44 +00:00
|
|
|
void SetSolo(bool Solo);
|
2010-05-29 07:25:38 +00:00
|
|
|
void HandleWeaponSwitch();
|
|
|
|
void DoWeaponSwitch();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void HandleWeapons();
|
|
|
|
void HandleNinja();
|
2014-04-13 23:34:50 +00:00
|
|
|
void HandleJetpack();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
void OnPredictedInput(CNetObj_PlayerInput *pNewInput);
|
|
|
|
void OnDirectInput(CNetObj_PlayerInput *pNewInput);
|
2011-06-09 20:30:03 +00:00
|
|
|
void ResetInput();
|
2010-05-29 07:25:38 +00:00
|
|
|
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
|
|
|
|
2016-10-08 17:42:42 +00:00
|
|
|
void GiveWeapon(int Weapon, bool Remove = false);
|
2010-05-29 07:25:38 +00:00
|
|
|
void GiveNinja();
|
2016-10-08 17:42:42 +00:00
|
|
|
void RemoveNinja();
|
2020-12-26 22:09:33 +00:00
|
|
|
void SetEndlessHook(bool Enable);
|
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
|
|
|
|
2015-04-16 15:28:03 +00:00
|
|
|
void Rescue();
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
int NeededFaketuning() { return m_NeededFaketuning; }
|
2010-07-29 05:21:18 +00:00
|
|
|
bool IsAlive() const { return m_Alive; }
|
2011-12-29 13:58:39 +00:00
|
|
|
bool IsPaused() const { return m_Paused; }
|
2010-07-29 05:21:18 +00:00
|
|
|
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;
|
2011-12-29 13:58:39 +00:00
|
|
|
bool m_Paused;
|
2014-02-19 20:55:37 +00:00
|
|
|
int m_NeededFaketuning;
|
2011-01-29 00:59:50 +00:00
|
|
|
|
|
|
|
// 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_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;
|
2012-10-06 11:47:37 +00:00
|
|
|
int m_LastNoAmmoSound;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// these are non-heldback inputs
|
2020-03-11 00:58:50 +00:00
|
|
|
CNetObj_PlayerInput m_LatestPrevPrevInput;
|
2010-05-29 07:25:38 +00:00
|
|
|
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;
|
2016-08-27 15:06:52 +00:00
|
|
|
CNetObj_PlayerInput m_SavedInput;
|
2010-05-29 07:25:38 +00:00
|
|
|
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;
|
2021-01-12 23:29:20 +00:00
|
|
|
CGameTeams *m_pTeams = nullptr;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2021-01-12 23:12:08 +00:00
|
|
|
std::map<int, std::vector<vec2>> *m_pTeleOuts = nullptr;
|
|
|
|
std::map<int, std::vector<vec2>> *m_pTeleCheckOuts = nullptr;
|
|
|
|
|
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
|
|
|
|
|
2020-06-22 16:02:17 +00:00
|
|
|
void SnapCharacter(int SnappingClient, int ID);
|
2018-08-15 15:47:07 +00:00
|
|
|
static bool IsSwitchActiveCb(int Number, void *pUser);
|
2011-01-29 00:59:50 +00:00
|
|
|
void HandleTiles(int Index);
|
|
|
|
float m_Time;
|
|
|
|
int m_LastBroadcast;
|
|
|
|
void DDRaceInit();
|
|
|
|
void HandleSkippableTiles(int Index);
|
2020-06-24 19:19:46 +00:00
|
|
|
void SetRescue();
|
2011-01-29 00:59:50 +00:00
|
|
|
void DDRaceTick();
|
2011-01-29 23:58:47 +00:00
|
|
|
void DDRacePostCoreTick();
|
2011-01-29 00:59:50 +00:00
|
|
|
void HandleBroadcast();
|
2014-03-12 23:49:07 +00:00
|
|
|
void HandleTuneLayer();
|
2014-04-18 12:27:58 +00:00
|
|
|
void SendZoneMsgs();
|
2020-05-13 20:27:49 +00:00
|
|
|
IAntibot *Antibot();
|
2015-04-16 15:28:03 +00:00
|
|
|
|
|
|
|
bool m_SetSavePos;
|
2020-06-01 09:40:11 +00:00
|
|
|
CSaveTee m_RescueTee;
|
2019-04-17 21:47:32 +00:00
|
|
|
bool m_Solo;
|
2015-04-16 15:28:03 +00:00
|
|
|
|
2011-01-29 00:59:50 +00:00
|
|
|
public:
|
2021-01-12 23:29:20 +00:00
|
|
|
CGameTeams *Teams() { return m_pTeams; }
|
|
|
|
void SetTeams(CGameTeams *pTeams);
|
2021-01-12 23:12:08 +00:00
|
|
|
void SetTeleports(std::map<int, std::vector<vec2>> *pTeleOuts, std::map<int, std::vector<vec2>> *pTeleCheckOuts);
|
|
|
|
|
2020-03-11 00:58:50 +00:00
|
|
|
void FillAntibot(CAntibotCharacterData *pData);
|
2011-12-29 13:58:39 +00:00
|
|
|
void Pause(bool Pause);
|
2011-01-29 00:59:50 +00:00
|
|
|
bool Freeze(int Time);
|
|
|
|
bool Freeze();
|
|
|
|
bool UnFreeze();
|
|
|
|
void GiveAllWeapons();
|
2021-01-12 22:10:02 +00:00
|
|
|
void ResetPickups();
|
2011-01-29 00:59:50 +00:00
|
|
|
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;
|
2013-08-05 15:47:04 +00:00
|
|
|
bool m_SuperJump;
|
2013-11-22 14:10:55 +00:00
|
|
|
bool m_Jetpack;
|
2014-01-11 12:59:20 +00:00
|
|
|
bool m_NinjaJetpack;
|
2011-01-29 00:59:50 +00:00
|
|
|
int m_TeamBeforeSuper;
|
|
|
|
int m_FreezeTime;
|
|
|
|
int m_FreezeTick;
|
2019-07-31 19:08:36 +00:00
|
|
|
bool m_FrozenLastTick;
|
2011-01-29 00:59:50 +00:00
|
|
|
bool m_DeepFreeze;
|
|
|
|
bool m_EndlessHook;
|
2014-07-16 00:59:39 +00:00
|
|
|
bool m_FreezeHammer;
|
2011-07-25 20:16:20 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
HIT_ALL = 0,
|
|
|
|
DISABLE_HIT_HAMMER = 1,
|
|
|
|
DISABLE_HIT_SHOTGUN = 2,
|
|
|
|
DISABLE_HIT_GRENADE = 4,
|
|
|
|
DISABLE_HIT_LASER = 8
|
2011-07-25 20:16:20 +00:00
|
|
|
};
|
|
|
|
int m_Hit;
|
2014-03-12 23:49:07 +00:00
|
|
|
int m_TuneZone;
|
|
|
|
int m_TuneZoneOld;
|
2011-01-29 00:59:50 +00:00
|
|
|
int m_PainSoundTimer;
|
2010-07-29 05:21:18 +00:00
|
|
|
int m_LastMove;
|
|
|
|
int m_StartTime;
|
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;
|
2013-03-18 11:58:29 +00:00
|
|
|
int m_CpLastBroadcast;
|
2010-08-29 00:05:45 +00:00
|
|
|
float m_CpCurrent[25];
|
2010-09-19 09:01:54 +00:00
|
|
|
int m_TileIndex;
|
|
|
|
int m_TileFIndex;
|
2018-08-15 15:47:07 +00:00
|
|
|
|
|
|
|
int m_MoveRestrictions;
|
|
|
|
|
2010-09-10 06:55:04 +00:00
|
|
|
vec2 m_Intersection;
|
2011-01-29 14:31:50 +00:00
|
|
|
int64 m_LastStartWarning;
|
2015-06-30 16:46:36 +00:00
|
|
|
int64 m_LastRescue;
|
2014-12-29 14:54:55 +00:00
|
|
|
bool m_LastRefillJumps;
|
2014-02-09 22:31:29 +00:00
|
|
|
bool m_LastPenalty;
|
2015-03-10 21:57:40 +00:00
|
|
|
bool m_LastBonus;
|
2018-07-15 09:58:12 +00:00
|
|
|
vec2 m_TeleGunPos;
|
|
|
|
bool m_TeleGunTeleport;
|
2018-11-02 23:02:20 +00:00
|
|
|
bool m_IsBlueTeleGunTeleport;
|
2019-05-01 22:34:20 +00:00
|
|
|
int m_StrongWeakID;
|
2014-02-09 22:31:29 +00:00
|
|
|
|
2020-03-11 00:58:50 +00:00
|
|
|
int m_SpawnTick;
|
|
|
|
int m_WeaponChangeTick;
|
|
|
|
|
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; };
|
2019-09-08 17:22:12 +00:00
|
|
|
void SetLastWeapon(int LastWeap) { m_LastWeapon = LastWeap; };
|
2014-04-14 08:56:14 +00:00
|
|
|
int GetActiveWeapon() { return m_Core.m_ActiveWeapon; };
|
2019-09-08 17:22:12 +00:00
|
|
|
void SetActiveWeapon(int ActiveWeap) { m_Core.m_ActiveWeapon = ActiveWeap; };
|
|
|
|
void SetLastAction(int LastAction) { m_LastAction = LastAction; };
|
2011-01-29 00:59:50 +00:00
|
|
|
int GetArmor() { return m_Armor; };
|
2019-09-08 17:22:12 +00:00
|
|
|
void SetArmor(int Armor) { m_Armor = Armor; };
|
2011-01-29 00:59:50 +00:00
|
|
|
CCharacterCore GetCore() { return m_Core; };
|
2019-09-08 17:22:12 +00:00
|
|
|
void SetCore(CCharacterCore Core) { m_Core = Core; };
|
2020-09-26 19:41:58 +00:00
|
|
|
CCharacterCore *Core() { return &m_Core; };
|
2011-01-29 00:59:50 +00:00
|
|
|
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 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; };
|
2019-08-19 08:09:53 +00:00
|
|
|
|
2021-01-12 16:48:33 +00:00
|
|
|
int GetLastAction() const { return m_LastAction; }
|
|
|
|
|
2019-08-19 08:09:53 +00:00
|
|
|
bool HasTelegunGun() { return m_Core.m_HasTelegunGun; };
|
|
|
|
bool HasTelegunGrenade() { return m_Core.m_HasTelegunGrenade; };
|
|
|
|
bool HasTelegunLaser() { return m_Core.m_HasTelegunLaser; };
|
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
|