2019-04-11 22:46:54 +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. */
|
|
|
|
#ifndef GAME_CLIENT_PREDICTION_ENTITIES_CHARACTER_H
|
|
|
|
#define GAME_CLIENT_PREDICTION_ENTITIES_CHARACTER_H
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <game/client/prediction/entity.h>
|
2019-04-11 22:46:54 +00:00
|
|
|
|
|
|
|
#include <game/gamecore.h>
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
WEAPON_GAME = -3, // team switching etc
|
|
|
|
WEAPON_SELF = -2, // console kill command
|
|
|
|
WEAPON_WORLD = -1, // death tiles etc
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
FAKETUNE_FREEZE = 1,
|
|
|
|
FAKETUNE_SOLO = 2,
|
|
|
|
FAKETUNE_NOJUMP = 4,
|
|
|
|
FAKETUNE_NOCOLL = 8,
|
|
|
|
FAKETUNE_NOHOOK = 16,
|
|
|
|
FAKETUNE_JETPACK = 32,
|
|
|
|
FAKETUNE_NOHAMMER = 64,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class CCharacter : public CEntity
|
|
|
|
{
|
|
|
|
friend class CGameWorld;
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2019-04-11 22:46:54 +00:00
|
|
|
public:
|
2022-05-26 17:04:13 +00:00
|
|
|
~CCharacter();
|
|
|
|
|
2019-04-11 22:46:54 +00:00
|
|
|
//character's size
|
|
|
|
static const int ms_PhysSize = 28;
|
|
|
|
|
2022-05-17 20:13:44 +00:00
|
|
|
void Tick() override;
|
|
|
|
void TickDefered() override;
|
2019-04-11 22:46:54 +00:00
|
|
|
|
|
|
|
bool IsGrounded();
|
|
|
|
|
|
|
|
void SetWeapon(int W);
|
|
|
|
void SetSolo(bool Solo);
|
2022-06-30 17:29:58 +00:00
|
|
|
void SetSuper(bool Super);
|
2019-04-11 22:46:54 +00:00
|
|
|
void HandleWeaponSwitch();
|
|
|
|
void DoWeaponSwitch();
|
|
|
|
|
|
|
|
void HandleWeapons();
|
|
|
|
void HandleNinja();
|
|
|
|
void HandleJetpack();
|
|
|
|
|
|
|
|
void OnPredictedInput(CNetObj_PlayerInput *pNewInput);
|
|
|
|
void OnDirectInput(CNetObj_PlayerInput *pNewInput);
|
2020-07-15 01:15:35 +00:00
|
|
|
void ResetInput();
|
2019-04-11 22:46:54 +00:00
|
|
|
void FireWeapon();
|
|
|
|
|
|
|
|
bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon);
|
|
|
|
|
2020-04-25 23:12:34 +00:00
|
|
|
void GiveWeapon(int Weapon, bool Remove = false);
|
2019-04-11 22:46:54 +00:00
|
|
|
void GiveNinja();
|
|
|
|
void RemoveNinja();
|
|
|
|
|
2021-05-12 16:57:50 +00:00
|
|
|
bool m_IsLocal;
|
2019-04-11 22:46:54 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
CTeamsCore *TeamsCore();
|
2022-01-22 13:12:59 +00:00
|
|
|
bool Freeze(int Seconds);
|
2019-04-11 22:46:54 +00:00
|
|
|
bool Freeze();
|
|
|
|
bool UnFreeze();
|
|
|
|
void GiveAllWeapons();
|
|
|
|
int Team();
|
|
|
|
bool CanCollide(int ClientID);
|
|
|
|
bool SameTeam(int ClientID);
|
2019-05-12 23:45:49 +00:00
|
|
|
bool m_NinjaJetpack;
|
2019-04-11 22:46:54 +00:00
|
|
|
int m_FreezeTime;
|
2020-04-25 23:12:34 +00:00
|
|
|
bool m_FrozenLastTick;
|
2019-09-08 22:53:07 +00:00
|
|
|
int m_TuneZone;
|
2019-04-11 22:46:54 +00:00
|
|
|
vec2 m_PrevPos;
|
2019-05-11 19:13:09 +00:00
|
|
|
vec2 m_PrevPrevPos;
|
2019-06-30 21:47:33 +00:00
|
|
|
int m_TeleCheckpoint;
|
2019-04-11 22:46:54 +00:00
|
|
|
|
|
|
|
int m_TileIndex;
|
|
|
|
int m_TileFIndex;
|
2018-08-15 15:47:07 +00:00
|
|
|
|
|
|
|
int m_MoveRestrictions;
|
2019-04-11 22:46:54 +00:00
|
|
|
bool m_LastRefillJumps;
|
|
|
|
|
|
|
|
// Setters/Getters because i don't want to modify vanilla vars access modifiers
|
2022-03-08 19:01:26 +00:00
|
|
|
int GetLastWeapon() { return m_LastWeapon; }
|
|
|
|
void SetLastWeapon(int LastWeap) { m_LastWeapon = LastWeap; }
|
|
|
|
int GetActiveWeapon() { return m_Core.m_ActiveWeapon; }
|
2020-07-15 00:47:51 +00:00
|
|
|
void SetActiveWeapon(int ActiveWeap);
|
2022-03-08 19:01:26 +00:00
|
|
|
CCharacterCore GetCore() { return m_Core; }
|
|
|
|
void SetCore(CCharacterCore Core) { m_Core = Core; }
|
|
|
|
CCharacterCore *Core() { return &m_Core; }
|
2022-03-21 22:50:41 +00:00
|
|
|
bool GetWeaponGot(int Type) { return m_Core.m_aWeapons[Type].m_Got; }
|
|
|
|
void SetWeaponGot(int Type, bool Value) { m_Core.m_aWeapons[Type].m_Got = Value; }
|
|
|
|
int GetWeaponAmmo(int Type) { return m_Core.m_aWeapons[Type].m_Ammo; }
|
|
|
|
void SetWeaponAmmo(int Type, int Value) { m_Core.m_aWeapons[Type].m_Ammo = Value; }
|
2022-03-24 00:05:41 +00:00
|
|
|
void SetNinjaActivationDir(vec2 ActivationDir) { m_Core.m_Ninja.m_ActivationDir = ActivationDir; }
|
|
|
|
void SetNinjaActivationTick(int ActivationTick) { m_Core.m_Ninja.m_ActivationTick = ActivationTick; }
|
|
|
|
void SetNinjaCurrentMoveTime(int CurrentMoveTime) { m_Core.m_Ninja.m_CurrentMoveTime = CurrentMoveTime; }
|
2019-04-11 22:46:54 +00:00
|
|
|
int GetCID() { return m_ID; }
|
2020-10-17 17:02:58 +00:00
|
|
|
void SetInput(CNetObj_PlayerInput *pNewInput)
|
|
|
|
{
|
|
|
|
m_LatestInput = m_Input = *pNewInput;
|
|
|
|
// it is not allowed to aim in the center
|
|
|
|
if(m_Input.m_TargetX == 0 && m_Input.m_TargetY == 0)
|
|
|
|
{
|
|
|
|
m_Input.m_TargetY = m_LatestInput.m_TargetY = -1;
|
|
|
|
}
|
|
|
|
};
|
2019-04-11 22:46:54 +00:00
|
|
|
int GetJumped() { return m_Core.m_Jumped; }
|
2019-05-04 18:24:48 +00:00
|
|
|
int GetAttackTick() { return m_AttackTick; }
|
2019-06-30 21:47:33 +00:00
|
|
|
int GetStrongWeakID() { return m_StrongWeakID; }
|
2019-04-11 22:46:54 +00:00
|
|
|
|
2022-05-24 15:26:49 +00:00
|
|
|
CCharacter(CGameWorld *pGameWorld, int ID, CNetObj_Character *pChar, CNetObj_DDNetCharacter *pExtended = 0);
|
|
|
|
void Read(CNetObj_Character *pChar, CNetObj_DDNetCharacter *pExtended, bool IsLocal);
|
2019-04-11 22:46:54 +00:00
|
|
|
void SetCoreWorld(CGameWorld *pGameWorld);
|
|
|
|
|
|
|
|
int m_LastSnapWeapon;
|
|
|
|
int m_LastJetpackStrength;
|
|
|
|
bool m_KeepHooked;
|
|
|
|
int m_GameTeam;
|
2019-05-02 20:35:08 +00:00
|
|
|
bool m_CanMoveInFreeze;
|
2019-04-11 22:46:54 +00:00
|
|
|
|
|
|
|
bool Match(CCharacter *pChar);
|
2019-05-04 01:48:17 +00:00
|
|
|
void ResetPrediction();
|
2020-07-15 00:47:51 +00:00
|
|
|
void SetTuneZone(int Zone);
|
2019-04-13 23:34:15 +00:00
|
|
|
|
2022-06-30 17:29:58 +00:00
|
|
|
bool CanNotHammerHit() { return m_Core.m_NoHammerHit; }
|
|
|
|
bool CanNotShotgunHit() { return m_Core.m_NoShotgunHit; }
|
|
|
|
bool CanNotLaserHit() { return m_Core.m_NoLaserHit; }
|
|
|
|
bool CanNotGrenadeHit() { return m_Core.m_NoGrenadeHit; }
|
|
|
|
|
|
|
|
bool IsSuper() { return m_Core.m_Super; }
|
|
|
|
|
2019-04-13 23:34:15 +00:00
|
|
|
private:
|
|
|
|
// weapon info
|
|
|
|
int m_aHitObjects[10];
|
|
|
|
int m_NumObjectsHit;
|
|
|
|
|
|
|
|
int m_LastWeapon;
|
|
|
|
int m_QueuedWeapon;
|
|
|
|
|
|
|
|
int m_ReloadTimer;
|
2019-05-04 18:24:48 +00:00
|
|
|
int m_AttackTick;
|
2019-04-13 23:34:15 +00:00
|
|
|
|
|
|
|
// these are non-heldback inputs
|
|
|
|
CNetObj_PlayerInput m_LatestPrevInput;
|
|
|
|
CNetObj_PlayerInput m_LatestInput;
|
|
|
|
|
|
|
|
// input
|
|
|
|
CNetObj_PlayerInput m_PrevInput;
|
|
|
|
CNetObj_PlayerInput m_Input;
|
|
|
|
CNetObj_PlayerInput m_SavedInput;
|
|
|
|
|
|
|
|
int m_NumInputs;
|
|
|
|
|
|
|
|
// the player core for the physics
|
|
|
|
CCharacterCore m_Core;
|
|
|
|
|
|
|
|
// DDRace
|
|
|
|
|
2018-08-15 15:47:07 +00:00
|
|
|
static bool IsSwitchActiveCb(int Number, void *pUser);
|
2019-04-13 23:34:15 +00:00
|
|
|
void HandleTiles(int Index);
|
|
|
|
void HandleSkippableTiles(int Index);
|
|
|
|
void DDRaceTick();
|
|
|
|
void DDRacePostCoreTick();
|
2019-09-08 22:53:07 +00:00
|
|
|
void HandleTuneLayer();
|
2019-06-30 21:47:33 +00:00
|
|
|
|
2021-05-12 16:57:50 +00:00
|
|
|
CTuningParams *CharacterTuning();
|
|
|
|
|
2019-06-30 21:47:33 +00:00
|
|
|
int m_StrongWeakID;
|
2020-07-15 00:47:51 +00:00
|
|
|
|
|
|
|
int m_LastWeaponSwitchTick;
|
|
|
|
int m_LastTuneZoneTick;
|
2019-04-11 22:46:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
DDRACE_NONE = 0,
|
|
|
|
DDRACE_STARTED,
|
|
|
|
DDRACE_CHEAT, // no time and won't start again unless ordered by a mod or death
|
|
|
|
DDRACE_FINISHED
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|