2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "Pawn.h"
|
2013-08-19 05:39:13 -04:00
|
|
|
#include "../Inventory.h"
|
|
|
|
#include "../Defines.h"
|
2013-11-02 12:44:55 -04:00
|
|
|
#include "../World.h"
|
2014-02-07 13:58:52 -05:00
|
|
|
#include "../ClientHandle.h"
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-05-11 07:57:06 -04:00
|
|
|
#include "../Statistics.h"
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cWindow;
|
|
|
|
class cClientHandle;
|
2014-01-19 07:20:57 -05:00
|
|
|
class cTeam;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
// tolua_begin
|
|
|
|
class cPlayer :
|
|
|
|
public cPawn
|
|
|
|
{
|
2012-12-21 07:21:20 -05:00
|
|
|
typedef cPawn super;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
public:
|
2014-08-10 20:13:14 -04:00
|
|
|
static const int MAX_HEALTH;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-08-10 20:13:14 -04:00
|
|
|
static const int MAX_FOOD_LEVEL;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-08-03 01:42:53 -04:00
|
|
|
/** Number of ticks it takes to eat an item */
|
2014-08-10 20:13:14 -04:00
|
|
|
static const int EATING_TICKS;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2012-12-21 06:04:08 -05:00
|
|
|
// tolua_end
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2012-12-21 07:21:20 -05:00
|
|
|
CLASS_PROTODEF(cPlayer)
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2015-01-24 14:17:00 -05:00
|
|
|
cPlayer(cClientHandlePtr a_Client, const AString & a_PlayerName);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
virtual ~cPlayer();
|
|
|
|
|
2012-08-24 03:58:26 -04:00
|
|
|
virtual void SpawnOn(cClientHandle & a_Client) override;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2015-01-11 16:12:26 -05:00
|
|
|
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2015-01-11 16:12:26 -05:00
|
|
|
virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk &) override { UNUSED(a_Dt); }
|
2013-04-22 03:18:03 -04:00
|
|
|
|
2015-12-08 15:58:20 -05:00
|
|
|
/** Returns the currently equipped weapon; empty item if none */
|
2012-12-21 06:04:08 -05:00
|
|
|
virtual cItem GetEquippedWeapon(void) const override { return m_Inventory.GetEquippedItem(); }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns the currently equipped helmet; empty item if none */
|
2012-12-21 06:04:08 -05:00
|
|
|
virtual cItem GetEquippedHelmet(void) const override { return m_Inventory.GetEquippedHelmet(); }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns the currently equipped chestplate; empty item if none */
|
2012-12-21 06:04:08 -05:00
|
|
|
virtual cItem GetEquippedChestplate(void) const override { return m_Inventory.GetEquippedChestplate(); }
|
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns the currently equipped leggings; empty item if none */
|
2012-12-21 06:04:08 -05:00
|
|
|
virtual cItem GetEquippedLeggings(void) const override { return m_Inventory.GetEquippedLeggings(); }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns the currently equipped boots; empty item if none */
|
2012-12-21 06:04:08 -05:00
|
|
|
virtual cItem GetEquippedBoots(void) const override { return m_Inventory.GetEquippedBoots(); }
|
2013-11-13 08:50:47 -05:00
|
|
|
|
2013-11-14 00:20:27 -05:00
|
|
|
|
|
|
|
// tolua_begin
|
|
|
|
|
2013-11-13 12:25:47 -05:00
|
|
|
/** Sets the experience total
|
2013-11-13 08:50:47 -05:00
|
|
|
Returns true on success
|
2013-11-13 15:07:57 -05:00
|
|
|
"should" really only be called at init or player death, plugins excepted
|
2013-11-13 08:50:47 -05:00
|
|
|
*/
|
2015-02-28 11:33:41 -05:00
|
|
|
bool SetCurrentExperience(int a_XpTotal);
|
2013-11-13 08:50:47 -05:00
|
|
|
|
2013-11-16 06:43:42 -05:00
|
|
|
/* changes Xp by Xp_delta, you "shouldn't" inc more than MAX_EXPERIENCE_ORB_SIZE
|
|
|
|
Wont't allow xp to go negative
|
2013-11-16 04:29:57 -05:00
|
|
|
Returns the new current experience, -1 on error
|
2013-11-13 08:50:47 -05:00
|
|
|
*/
|
2015-02-28 11:33:41 -05:00
|
|
|
int DeltaExperience(int a_Xp_delta);
|
2013-11-16 05:38:57 -05:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Gets the experience total - XpTotal for score on death */
|
2015-02-28 11:33:41 -05:00
|
|
|
inline int GetXpLifetimeTotal(void) { return m_LifetimeTotalXp; }
|
2013-11-16 04:29:57 -05:00
|
|
|
|
2015-12-08 15:58:20 -05:00
|
|
|
/** Gets the current experience */
|
2015-02-28 11:33:41 -05:00
|
|
|
inline int GetCurrentXp(void) { return m_CurrentXp; }
|
2013-11-13 08:50:47 -05:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Gets the current level - XpLevel */
|
2015-02-28 11:33:41 -05:00
|
|
|
int GetXpLevel(void);
|
2013-11-13 08:50:47 -05:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Gets the experience bar percentage - XpP */
|
2013-11-16 04:29:57 -05:00
|
|
|
float GetXpPercentage(void);
|
2013-11-14 00:20:27 -05:00
|
|
|
|
2015-12-08 15:58:20 -05:00
|
|
|
/** Calculates the amount of XP needed for a given level
|
2014-03-20 11:14:40 -04:00
|
|
|
Ref: http://minecraft.gamepedia.com/XP
|
|
|
|
*/
|
2015-02-28 11:33:41 -05:00
|
|
|
static int XpForLevel(int a_Level);
|
2013-11-21 16:09:11 -05:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Inverse of XpForLevel
|
|
|
|
Ref: http://minecraft.gamepedia.com/XP
|
|
|
|
values are as per this with pre-calculations
|
|
|
|
*/
|
2015-02-28 11:33:41 -05:00
|
|
|
static int CalcLevelFromXp(int a_CurrentXp);
|
2013-11-21 16:09:11 -05:00
|
|
|
|
2013-11-14 00:20:27 -05:00
|
|
|
// tolua_end
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Starts charging the equipped bow */
|
2013-08-30 08:24:03 -04:00
|
|
|
void StartChargingBow(void);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Finishes charging the current bow. Returns the number of ticks for which the bow has been charged */
|
2013-08-30 08:24:03 -04:00
|
|
|
int FinishChargingBow(void);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Cancels the current bow charging */
|
2013-08-30 08:24:03 -04:00
|
|
|
void CancelChargingBow(void);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns true if the player is currently charging the bow */
|
2013-08-30 11:29:46 -04:00
|
|
|
bool IsChargingBow(void) const { return m_IsChargingBow; }
|
2012-12-21 06:04:08 -05:00
|
|
|
|
2015-07-21 16:25:37 -04:00
|
|
|
void SetTouchGround(bool a_bTouchGround);
|
|
|
|
inline void SetStance(const double a_Stance) { m_Stance = a_Stance; }
|
2014-07-17 17:15:53 -04:00
|
|
|
double GetEyeHeight(void) const; // tolua_export
|
|
|
|
Vector3d GetEyePosition(void) const; // tolua_export
|
2015-02-06 15:45:29 -05:00
|
|
|
virtual bool IsOnGround(void) const override { return m_bTouchGround; }
|
2015-05-03 13:56:37 -04:00
|
|
|
inline double GetStance(void) const { return m_Stance; } // tolua_export
|
2014-07-17 17:15:53 -04:00
|
|
|
inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export
|
2012-09-20 09:25:54 -04:00
|
|
|
inline const cInventory & GetInventory(void) const { return m_Inventory; }
|
2014-06-29 06:36:38 -04:00
|
|
|
|
|
|
|
/** Gets the contents of the player's associated enderchest */
|
|
|
|
cItemGrid & GetEnderChestContents(void) { return m_EnderChestContents; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-05-19 14:22:37 -04:00
|
|
|
inline const cItem & GetEquippedItem(void) const { return GetInventory().GetEquippedItem(); } // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-06-04 13:59:56 -04:00
|
|
|
/** Returns whether the player is climbing (ladders, vines etc.) */
|
2014-05-20 08:52:59 -04:00
|
|
|
bool IsClimbing(void) const;
|
|
|
|
|
2013-07-01 06:39:56 -04:00
|
|
|
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-07-28 16:55:09 -04:00
|
|
|
// tolua_begin
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2015-12-24 05:37:32 -05:00
|
|
|
/** Prevent the player from moving and lock him into a_Location. */
|
|
|
|
void Freeze(const Vector3d & a_Location);
|
|
|
|
|
|
|
|
/** Is the player frozen? */
|
|
|
|
bool IsFrozen();
|
|
|
|
|
|
|
|
/** How long has the player been frozen? */
|
|
|
|
int GetFrozenDuration();
|
|
|
|
|
|
|
|
/** Cancels Freeze(...) and allows the player to move naturally. */
|
|
|
|
void Unfreeze();
|
|
|
|
|
2014-04-04 17:06:47 -04:00
|
|
|
/** Sends the "look" packet to the player, forcing them to set their rotation to the specified values.
|
|
|
|
a_YawDegrees is clipped to range [-180, +180),
|
|
|
|
a_PitchDegrees is clipped to range [-180, +180) but the client only uses [-90, +90]
|
|
|
|
*/
|
|
|
|
void SendRotation(double a_YawDegrees, double a_PitchDegrees);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns the position where projectiles thrown by this player should start, player eye position + adjustment */
|
2013-08-30 11:29:46 -04:00
|
|
|
Vector3d GetThrowStartPos(void) const;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns the initial speed vector of a throw, with a 3D length of a_SpeedCoeff. */
|
2013-08-30 11:29:46 -04:00
|
|
|
Vector3d GetThrowSpeed(double a_SpeedCoeff) const;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns the current gamemode. Partly OBSOLETE, you should use IsGameModeXXX() functions wherever applicable */
|
2013-07-28 16:55:09 -04:00
|
|
|
eGameMode GetGameMode(void) const { return m_GameMode; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns the current effective gamemode (inherited gamemode is resolved before returning) */
|
2013-11-02 12:44:55 -04:00
|
|
|
eGameMode GetEffectiveGameMode(void) const { return (m_GameMode == gmNotSet) ? m_World->GetGameMode() : m_GameMode; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-07-28 16:55:09 -04:00
|
|
|
/** Sets the gamemode for the player.
|
|
|
|
The gamemode may be gmNotSet, in that case the player inherits the world's gamemode.
|
|
|
|
Updates the gamemode on the client (sends the packet)
|
|
|
|
*/
|
|
|
|
void SetGameMode(eGameMode a_GameMode);
|
|
|
|
|
2015-05-23 14:31:33 -04:00
|
|
|
// Sets the current gamemode, doesn't check validity, doesn't send update packets to client
|
|
|
|
void LoginSetGameMode(eGameMode a_GameMode);
|
|
|
|
|
|
|
|
// Updates player's capabilities - flying, visibility, etc. from their gamemode.
|
|
|
|
void SetCapabilities();
|
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns true if the player is in Creative mode, either explicitly, or by inheriting from current world */
|
2013-07-28 05:30:54 -04:00
|
|
|
bool IsGameModeCreative(void) const;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns true if the player is in Survival mode, either explicitly, or by inheriting from current world */
|
2013-07-28 05:30:54 -04:00
|
|
|
bool IsGameModeSurvival(void) const;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns true if the player is in Adventure mode, either explicitly, or by inheriting from current world */
|
2013-07-28 05:30:54 -04:00
|
|
|
bool IsGameModeAdventure(void) const;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-09-16 14:02:27 -04:00
|
|
|
/** Returns true if the player is in Spectator mode, either explicitly, or by inheriting from current world */
|
|
|
|
bool IsGameModeSpectator(void) const;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-07-28 16:55:09 -04:00
|
|
|
AString GetIP(void) const { return m_IP; } // tolua_export
|
|
|
|
|
2014-10-20 16:55:07 -04:00
|
|
|
/** Returns the associated team, nullptr if none */
|
2014-07-17 16:15:34 -04:00
|
|
|
cTeam * GetTeam(void) { return m_Team; } // tolua_export
|
2014-01-19 07:20:57 -05:00
|
|
|
|
2014-10-20 16:55:07 -04:00
|
|
|
/** Sets the player team, nullptr if none */
|
2014-01-20 09:10:39 -05:00
|
|
|
void SetTeam(cTeam * a_Team);
|
|
|
|
|
2014-10-01 11:24:02 -04:00
|
|
|
// tolua_end
|
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Forces the player to query the scoreboard for his team */
|
2014-01-20 09:10:39 -05:00
|
|
|
cTeam * UpdateTeam(void);
|
2014-01-19 07:20:57 -05:00
|
|
|
|
2014-05-11 07:57:06 -04:00
|
|
|
/** Return the associated statistic and achievement manager. */
|
|
|
|
cStatManager & GetStatManager() { return m_Stats; }
|
2014-05-12 10:05:09 -04:00
|
|
|
|
|
|
|
/** Awards the player an achievement.
|
2014-05-13 07:53:15 -04:00
|
|
|
If all prerequisites are met, this method will award the achievement and will broadcast a chat message.
|
|
|
|
If the achievement has been already awarded to the player, this method will just increment the stat counter.
|
|
|
|
Returns the _new_ stat value. (0 = Could not award achievement) */
|
2014-05-12 10:05:09 -04:00
|
|
|
unsigned int AwardAchievement(const eStatistic a_Ach);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2012-08-19 15:42:32 -04:00
|
|
|
void SetIP(const AString & a_IP);
|
2013-07-28 16:55:09 -04:00
|
|
|
|
2014-07-17 16:50:58 -04:00
|
|
|
/** Forces the player to move in the given direction.
|
2014-06-16 10:12:50 -04:00
|
|
|
@deprecated Use SetSpeed instead. */
|
2014-07-17 16:15:34 -04:00
|
|
|
void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export
|
2013-12-15 12:54:54 -05:00
|
|
|
|
2013-05-30 15:34:09 -04:00
|
|
|
cWindow * GetWindow(void) { return m_CurrentWindow; } // tolua_export
|
2013-05-24 03:30:39 -04:00
|
|
|
const cWindow * GetWindow(void) const { return m_CurrentWindow; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Opens the specified window; closes the current one first using CloseWindow() */
|
2013-05-30 15:34:09 -04:00
|
|
|
void OpenWindow(cWindow * a_Window); // Exported in ManualBindings.cpp
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-05-30 15:34:09 -04:00
|
|
|
// tolua_begin
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Closes the current window, resets current window to m_InventoryWindow. A plugin may refuse the closing if a_CanRefuse is true */
|
2013-06-02 17:59:25 -04:00
|
|
|
void CloseWindow(bool a_CanRefuse = true);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Closes the current window if it matches the specified ID, resets current window to m_InventoryWindow */
|
2013-06-02 17:59:25 -04:00
|
|
|
void CloseWindowIfID(char a_WindowID, bool a_CanRefuse = true);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2015-01-24 14:17:00 -05:00
|
|
|
/** Returns the raw client handle associated with the player. */
|
|
|
|
cClientHandle * GetClientHandle(void) const { return m_ClientHandle.get(); }
|
|
|
|
|
|
|
|
// tolua_end
|
|
|
|
|
|
|
|
/** Returns the SharedPtr to client handle associated with the player. */
|
|
|
|
cClientHandlePtr GetClientHandlePtr(void) const { return m_ClientHandle; }
|
|
|
|
|
|
|
|
// tolua_begin
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2015-06-02 13:59:46 -04:00
|
|
|
void SendMessage (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtCustom); }
|
|
|
|
void SendMessageInfo (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtInformation); }
|
|
|
|
void SendMessageFailure (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); }
|
|
|
|
void SendMessageSuccess (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtSuccess); }
|
|
|
|
void SendMessageWarning (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtWarning); }
|
|
|
|
void SendMessageFatal (const AString & a_Message) { m_ClientHandle->SendChat(a_Message, mtFailure); }
|
|
|
|
void SendMessagePrivateMsg (const AString & a_Message, const AString & a_Sender) { m_ClientHandle->SendChat(a_Message, mtPrivateMessage, a_Sender); }
|
|
|
|
void SendMessage (const cCompositeChat & a_Message) { m_ClientHandle->SendChat(a_Message); }
|
2015-12-24 05:37:32 -05:00
|
|
|
|
2015-06-02 13:59:46 -04:00
|
|
|
void SendSystemMessage (const AString & a_Message) { m_ClientHandle->SendChatSystem(a_Message, mtCustom); }
|
|
|
|
void SendAboveActionBarMessage(const AString & a_Message) { m_ClientHandle->SendChatAboveActionBar(a_Message, mtCustom); }
|
|
|
|
void SendSystemMessage (const cCompositeChat & a_Message) { m_ClientHandle->SendChatSystem(a_Message); }
|
|
|
|
void SendAboveActionBarMessage(const cCompositeChat & a_Message) { m_ClientHandle->SendChatAboveActionBar(a_Message); }
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-05-30 15:34:09 -04:00
|
|
|
const AString & GetName(void) const { return m_PlayerName; }
|
|
|
|
void SetName(const AString & a_Name) { m_PlayerName = a_Name; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-05-30 15:34:09 -04:00
|
|
|
// tolua_end
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-08-19 11:34:11 -04:00
|
|
|
bool HasPermission(const AString & a_Permission); // tolua_export
|
2012-10-18 17:54:56 -04:00
|
|
|
|
2014-08-19 11:34:11 -04:00
|
|
|
/** Returns true iff a_Permission matches the a_Template.
|
|
|
|
A match is defined by either being exactly the same, or each sub-item matches until there's a wildcard in a_Template.
|
|
|
|
Ie. {"a", "b", "c"} matches {"a", "b", "*"} but doesn't match {"a", "b"} */
|
|
|
|
static bool PermissionMatches(const AStringVector & a_Permission, const AStringVector & a_Template); // Exported in ManualBindings with AString params
|
|
|
|
|
|
|
|
/** Returns all the permissions that the player has assigned to them. */
|
2015-04-25 13:40:44 -04:00
|
|
|
const AStringVector & GetPermissions(void) const { return m_Permissions; } // Exported in ManualBindings.cpp
|
|
|
|
|
|
|
|
/** Returns all the restrictions that the player has assigned to them. */
|
|
|
|
const AStringVector & GetRestrictions(void) const { return m_Restrictions; } // Exported in ManualBindings.cpp
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2013-10-24 05:05:43 -04:00
|
|
|
// tolua_begin
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-08-19 11:34:11 -04:00
|
|
|
/** Returns the full color code to use for this player, based on their rank.
|
|
|
|
The returned value either is empty, or includes the cChatColor::Delimiter. */
|
2013-10-24 05:05:43 -04:00
|
|
|
AString GetColor(void) const;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-09-23 08:39:49 -04:00
|
|
|
/** Returns the name that is used in the playerlist. */
|
|
|
|
AString GetPlayerListName(void) const;
|
2014-09-02 13:12:35 -04:00
|
|
|
|
2014-01-23 21:54:00 -05:00
|
|
|
/** tosses the item in the selected hotbar slot */
|
2014-01-23 02:27:39 -05:00
|
|
|
void TossEquippedItem(char a_Amount = 1);
|
|
|
|
|
2014-01-23 21:54:00 -05:00
|
|
|
/** tosses the item held in hand (when in UI windows) */
|
2014-01-23 02:27:39 -05:00
|
|
|
void TossHeldItem(char a_Amount = 1);
|
|
|
|
|
2014-01-23 21:54:00 -05:00
|
|
|
/** tosses a pickup newly created from a_Item */
|
2014-01-23 02:27:39 -05:00
|
|
|
void TossPickup(const cItem & a_Item);
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Heals the player by the specified amount of HPs (positive only); sends health update */
|
2014-06-07 21:48:33 -04:00
|
|
|
virtual void Heal(int a_Health) override;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-07-12 16:01:25 -04:00
|
|
|
int GetFoodLevel (void) const { return m_FoodLevel; }
|
|
|
|
double GetFoodSaturationLevel (void) const { return m_FoodSaturationLevel; }
|
|
|
|
int GetFoodTickTimer (void) const { return m_FoodTickTimer; }
|
|
|
|
double GetFoodExhaustionLevel (void) const { return m_FoodExhaustionLevel; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns true if the player is satiated, i. e. their foodlevel is at the max and they cannot eat anymore */
|
2013-07-28 16:55:09 -04:00
|
|
|
bool IsSatiated(void) const { return (m_FoodLevel >= MAX_FOOD_LEVEL); }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-07-12 16:01:25 -04:00
|
|
|
void SetFoodLevel (int a_FoodLevel);
|
|
|
|
void SetFoodSaturationLevel (double a_FoodSaturationLevel);
|
|
|
|
void SetFoodTickTimer (int a_FoodTickTimer);
|
2013-08-19 16:48:13 -04:00
|
|
|
void SetFoodExhaustionLevel (double a_FoodExhaustionLevel);
|
2012-07-17 08:02:03 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Adds to FoodLevel and FoodSaturationLevel, returns true if any food has been consumed, false if player "full" */
|
2013-07-12 16:01:25 -04:00
|
|
|
bool Feed(int a_Food, double a_Saturation);
|
2012-07-17 08:02:03 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Adds the specified exhaustion to m_FoodExhaustion. Expects only positive values. */
|
2014-07-31 17:04:00 -04:00
|
|
|
void AddFoodExhaustion(double a_Exhaustion);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns true if the player is currently in the process of eating the currently equipped item */
|
2013-07-28 16:55:09 -04:00
|
|
|
bool IsEating(void) const { return (m_EatingFinishTick >= 0); }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns true if the player is currently flying. */
|
2013-12-15 08:48:17 -05:00
|
|
|
bool IsFlying(void) const { return m_IsFlying; }
|
2013-12-19 11:33:21 -05:00
|
|
|
|
2014-03-08 19:17:23 -05:00
|
|
|
/** Returns if a player is sleeping in a bed */
|
|
|
|
bool IsInBed(void) const { return m_bIsInBed; }
|
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** returns true if the player has thrown out a floater. */
|
2013-12-19 11:33:21 -05:00
|
|
|
bool IsFishing(void) const { return m_IsFishing; }
|
|
|
|
|
2015-07-29 11:04:03 -04:00
|
|
|
void SetIsFishing(bool a_IsFishing, UInt32 a_FloaterID = cEntity::INVALID_ID) { m_IsFishing = a_IsFishing; m_FloaterID = a_FloaterID; }
|
2013-12-19 11:33:21 -05:00
|
|
|
|
2015-07-29 11:04:03 -04:00
|
|
|
UInt32 GetFloaterID(void) const { return m_FloaterID; }
|
2013-12-19 11:33:21 -05:00
|
|
|
|
2013-07-12 16:01:25 -04:00
|
|
|
// tolua_end
|
2014-03-08 19:17:23 -05:00
|
|
|
|
2015-02-08 16:21:48 -05:00
|
|
|
/** Sets a player's in-bed state
|
|
|
|
We can't be sure plugins will keep this value updated, so no exporting
|
|
|
|
If value is false (not in bed), will update players of the fact that they have been ejected from the bed
|
|
|
|
*/
|
|
|
|
void SetIsInBed(bool a_Flag)
|
|
|
|
{
|
|
|
|
m_bIsInBed = a_Flag;
|
|
|
|
if (!a_Flag)
|
|
|
|
{
|
|
|
|
GetWorld()->BroadcastEntityAnimation(*this, 2);
|
|
|
|
}
|
|
|
|
}
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet */
|
2013-07-28 13:15:03 -04:00
|
|
|
void StartEating(void);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Finishes eating the currently equipped item. Consumes the item, updates health and broadcasts the packets */
|
2013-07-28 13:15:03 -04:00
|
|
|
void FinishEating(void);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Aborts the current eating operation */
|
2013-07-28 13:15:03 -04:00
|
|
|
void AbortEating(void);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-07-04 05:55:09 -04:00
|
|
|
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
|
2014-05-12 10:05:09 -04:00
|
|
|
|
|
|
|
virtual void Killed(cEntity * a_Victim) override;
|
2014-07-18 15:10:51 -04:00
|
|
|
|
2014-07-17 17:15:53 -04:00
|
|
|
void Respawn(void); // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-07-21 09:19:48 -04:00
|
|
|
void SetVisible( bool a_bVisible); // tolua_export
|
2014-07-17 17:15:53 -04:00
|
|
|
bool IsVisible(void) const { return m_bVisible; } // tolua_export
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-06-06 16:31:16 -04:00
|
|
|
/** Moves the player to the specified world.
|
|
|
|
Returns true if successful, false on failure (world not found). */
|
2015-05-26 21:35:28 -04:00
|
|
|
virtual bool DoMoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn, Vector3d a_NewPosition) override;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-06-04 13:59:56 -04:00
|
|
|
/** Saves all player data, such as inventory, to JSON */
|
2012-12-21 06:04:08 -05:00
|
|
|
bool SaveToDisk(void);
|
2014-06-04 13:59:56 -04:00
|
|
|
|
2014-06-15 23:27:27 -04:00
|
|
|
typedef cWorld * cWorldPtr;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-07-20 05:46:45 -04:00
|
|
|
/** Loads the player data from the disk file
|
2014-07-23 16:12:59 -04:00
|
|
|
Sets a_World to the world where the player will spawn, based on the stored world name or the default world by calling LoadFromFile()
|
2014-07-20 05:46:45 -04:00
|
|
|
Returns true on success, false on failure
|
|
|
|
*/
|
2014-06-15 23:27:27 -04:00
|
|
|
bool LoadFromDisk(cWorldPtr & a_World);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-07-20 05:46:45 -04:00
|
|
|
/** Loads the player data from the specified file
|
2014-07-23 16:12:59 -04:00
|
|
|
Sets a_World to the world where the player will spawn, based on the stored world name or the default world
|
2014-07-20 05:46:45 -04:00
|
|
|
Returns true on success, false on failure
|
|
|
|
*/
|
|
|
|
bool LoadFromFile(const AString & a_FileName, cWorldPtr & a_World);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
const AString & GetLoadedWorldName() { return m_LoadedWorldName; }
|
|
|
|
|
2014-07-23 10:32:09 -04:00
|
|
|
void UseEquippedItem(int a_Amount = 1);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-05-30 04:40:13 -04:00
|
|
|
void SendHealth(void);
|
2013-11-15 10:23:50 -05:00
|
|
|
|
|
|
|
void SendExperience(void);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-06-21 15:42:10 -04:00
|
|
|
/** In UI windows, get the item that the player is dragging */
|
2012-09-20 09:25:54 -04:00
|
|
|
cItem & GetDraggingItem(void) {return m_DraggingItem; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-05-30 04:40:13 -04:00
|
|
|
// In UI windows, when inventory-painting:
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Clears the list of slots that are being inventory-painted. To be used by cWindow only */
|
2013-05-30 04:40:13 -04:00
|
|
|
void ClearInventoryPaintSlots(void);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Adds a slot to the list for inventory painting. To be used by cWindow only */
|
2013-05-30 04:40:13 -04:00
|
|
|
void AddInventoryPaintSlot(int a_SlotNum);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns the list of slots currently stored for inventory painting. To be used by cWindow only */
|
2013-05-30 04:40:13 -04:00
|
|
|
const cSlotNums & GetInventoryPaintSlots(void) const;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-07-07 10:13:43 -04:00
|
|
|
// tolua_begin
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns the current relative maximum speed (takes current sprinting / flying state into account) */
|
2013-07-07 10:13:43 -04:00
|
|
|
double GetMaxSpeed(void) const;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Gets the normal relative maximum speed */
|
2013-07-07 10:13:43 -04:00
|
|
|
double GetNormalMaxSpeed(void) const { return m_NormalMaxSpeed; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Gets the sprinting relative maximum speed */
|
2013-07-07 10:13:43 -04:00
|
|
|
double GetSprintingMaxSpeed(void) const { return m_SprintingMaxSpeed; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Gets the flying relative maximum speed */
|
|
|
|
double GetFlyingMaxSpeed(void) const { return m_FlyingMaxSpeed; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Sets the normal relative maximum speed. Sends the update to player, if needed. */
|
2013-07-07 10:13:43 -04:00
|
|
|
void SetNormalMaxSpeed(double a_Speed);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Sets the sprinting relative maximum speed. Sends the update to player, if needed. */
|
2013-07-07 10:13:43 -04:00
|
|
|
void SetSprintingMaxSpeed(double a_Speed);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Sets the flying relative maximum speed. Sends the update to player, if needed. */
|
|
|
|
void SetFlyingMaxSpeed(double a_Speed);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Sets the crouch status, broadcasts to all visible players */
|
2013-06-04 10:18:03 -04:00
|
|
|
void SetCrouch(bool a_IsCrouched);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Starts or stops sprinting, sends the max speed update to the client, if needed */
|
2013-07-07 10:13:43 -04:00
|
|
|
void SetSprint(bool a_IsSprinting);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Flags the player as flying */
|
2013-12-15 08:48:17 -05:00
|
|
|
void SetFlying(bool a_IsFlying);
|
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** If true the player can fly even when he's not in creative. */
|
2013-12-15 08:48:17 -05:00
|
|
|
void SetCanFly(bool a_CanFly);
|
|
|
|
|
2014-09-02 13:20:59 -04:00
|
|
|
/** Returns true if the player has a custom name. */
|
2014-09-02 13:12:35 -04:00
|
|
|
bool HasCustomName(void) const { return !m_CustomName.empty(); }
|
|
|
|
|
|
|
|
/** Returns the custom name of this player. If the player hasn't a custom name, it will return an empty string. */
|
|
|
|
const AString & GetCustomName(void) const { return m_CustomName; }
|
|
|
|
|
|
|
|
/** Sets the custom name of this player. If you want to disable the custom name, simply set an empty string.
|
|
|
|
The custom name will be used in the tab-list, in the player nametag and in the tab-completion. */
|
|
|
|
void SetCustomName(const AString & a_CustomName);
|
|
|
|
|
2014-06-21 15:42:10 -04:00
|
|
|
/** Gets the last position that the player slept in
|
|
|
|
This is initialised to the world spawn point if the player has not slept in a bed as of yet
|
|
|
|
*/
|
2014-06-01 13:46:59 -04:00
|
|
|
Vector3i GetLastBedPos(void) const { return m_LastBedPos; }
|
|
|
|
|
|
|
|
/** Sets the player's bed (home) position */
|
|
|
|
void SetBedPos(const Vector3i & a_Pos) { m_LastBedPos = a_Pos; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-10-01 11:24:02 -04:00
|
|
|
// tolua_end
|
2014-06-01 13:46:59 -04:00
|
|
|
|
2014-05-12 14:38:52 -04:00
|
|
|
/** Update movement-related statistics. */
|
2015-07-21 16:25:37 -04:00
|
|
|
void UpdateMovementStats(const Vector3d & a_DeltaPos, bool a_PreviousIsOnGround);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-10-01 11:24:02 -04:00
|
|
|
// tolua_begin
|
2014-05-12 14:38:52 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Returns wheter the player can fly or not. */
|
2013-12-15 08:48:17 -05:00
|
|
|
virtual bool CanFly(void) const { return m_CanFly; }
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-08-03 05:57:26 -04:00
|
|
|
/** Returns the UUID (short format) that has been read from the client, or empty string if not available. */
|
|
|
|
const AString & GetUUID(void) const { return m_UUID; }
|
2014-06-01 13:46:59 -04:00
|
|
|
|
2014-08-19 11:34:11 -04:00
|
|
|
/** (Re)loads the rank and permissions from the cRankManager.
|
|
|
|
Expects the m_UUID member to be valid.
|
|
|
|
Loads the m_Rank, m_Permissions, m_MsgPrefix, m_MsgSuffix and m_MsgNameColorCode members. */
|
|
|
|
void LoadRank(void);
|
|
|
|
|
2014-12-24 01:20:17 -05:00
|
|
|
/** Calls the block-placement hook and places the block in the world, unless refused by the hook.
|
|
|
|
If the hook prevents the placement, sends the current block at the specified coords back to the client.
|
2014-12-24 14:02:51 -05:00
|
|
|
Assumes that the block is in a currently loaded chunk.
|
|
|
|
Returns true if the block is successfully placed. */
|
2014-12-24 01:20:17 -05:00
|
|
|
bool PlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
|
|
|
|
|
|
|
/** Sends the block in the specified range around the specified coord to the client
|
|
|
|
as a block change packet.
|
|
|
|
The blocks in range (a_BlockX - a_Range, a_BlockX + a_Range) are sent (NY-metric). */
|
|
|
|
void SendBlocksAround(int a_BlockX, int a_BlockY, int a_BlockZ, int a_Range = 1);
|
|
|
|
|
2014-08-20 14:37:51 -04:00
|
|
|
// tolua_end
|
|
|
|
|
2014-12-24 01:20:17 -05:00
|
|
|
/** Calls the block placement hooks and places the blocks in the world.
|
|
|
|
First the "placing" hooks for all the blocks are called, then the blocks are placed, and finally
|
|
|
|
the "placed" hooks are called.
|
|
|
|
If the any of the "placing" hooks aborts, none of the blocks are placed and the function returns false.
|
|
|
|
Returns true if all the blocks are placed.
|
|
|
|
Assumes that all the blocks are in currently loaded chunks. */
|
|
|
|
bool PlaceBlocks(const sSetBlockVector & a_Blocks);
|
|
|
|
|
2016-01-22 13:55:46 -05:00
|
|
|
/** Notify nearby wolves that the player or one of the player's wolves took damage or did damage to an entity
|
|
|
|
@param a_Opponent the opponent we're fighting.
|
|
|
|
@param a_IsPlayerInvolved Should be true if the player took or did damage, and false if one of the player's wolves took or did damage.
|
|
|
|
*/
|
|
|
|
void NotifyNearbyWolves(cPawn * a_Opponent, bool a_IsPlayerInvolved);
|
2016-01-11 14:34:41 -05:00
|
|
|
|
2013-06-04 10:18:03 -04:00
|
|
|
// cEntity overrides:
|
2015-05-23 07:56:08 -04:00
|
|
|
virtual bool IsCrouched (void) const override { return m_IsCrouched; }
|
|
|
|
virtual bool IsSprinting(void) const override { return m_IsSprinting; }
|
|
|
|
virtual bool IsRclking (void) const override { return IsEating() || IsChargingBow(); }
|
2014-01-12 18:23:36 -05:00
|
|
|
|
2015-05-23 07:56:08 -04:00
|
|
|
virtual void Detach(void) override;
|
2015-01-24 14:17:00 -05:00
|
|
|
|
|
|
|
/** Called by cClientHandle when the client is being destroyed.
|
|
|
|
The player removes its m_ClientHandle ownership so that the ClientHandle gets deleted. */
|
|
|
|
void RemoveClientHandle(void);
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
protected:
|
|
|
|
|
2014-08-19 11:34:11 -04:00
|
|
|
typedef std::vector<std::vector<AString> > AStringVectorVector;
|
|
|
|
|
|
|
|
/** The name of the rank assigned to this player. */
|
|
|
|
AString m_Rank;
|
|
|
|
|
|
|
|
/** All the permissions that this player has, based on their rank. */
|
|
|
|
AStringVector m_Permissions;
|
|
|
|
|
2015-04-25 13:40:44 -04:00
|
|
|
/** All the restrictions that this player has, based on their rank. */
|
|
|
|
AStringVector m_Restrictions;
|
|
|
|
|
2014-08-19 11:34:11 -04:00
|
|
|
/** All the permissions that this player has, based on their rank, split into individual dot-delimited parts.
|
|
|
|
This is used mainly by the HasPermission() function to optimize the lookup. */
|
|
|
|
AStringVectorVector m_SplitPermissions;
|
|
|
|
|
2015-04-25 13:40:44 -04:00
|
|
|
/** All the restrictions that this player has, based on their rank, split into individual dot-delimited parts.
|
|
|
|
This is used mainly by the HasPermission() function to optimize the lookup. */
|
|
|
|
AStringVectorVector m_SplitRestrictions;
|
|
|
|
|
|
|
|
|
2014-08-19 11:34:11 -04:00
|
|
|
// Message visuals:
|
|
|
|
AString m_MsgPrefix, m_MsgSuffix;
|
|
|
|
AString m_MsgNameColorCode;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-03-08 19:17:23 -05:00
|
|
|
AString m_PlayerName;
|
|
|
|
AString m_LoadedWorldName;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Xp Level stuff */
|
2014-07-17 16:50:58 -04:00
|
|
|
enum
|
2013-11-13 12:25:47 -05:00
|
|
|
{
|
|
|
|
XP_TO_LEVEL15 = 255,
|
|
|
|
XP_PER_LEVEL_TO15 = 17,
|
|
|
|
XP_TO_LEVEL30 = 825
|
|
|
|
} ;
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
bool m_bVisible;
|
|
|
|
|
2013-07-12 16:01:25 -04:00
|
|
|
// Food-related variables:
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Represents the food bar, one point equals half a "drumstick" */
|
2013-07-12 16:01:25 -04:00
|
|
|
int m_FoodLevel;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** "Overcharge" for the m_FoodLevel; is depleted before m_FoodLevel */
|
2013-07-12 16:01:25 -04:00
|
|
|
double m_FoodSaturationLevel;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Count-up to the healing or damaging action, based on m_FoodLevel */
|
2014-07-16 17:22:45 -04:00
|
|
|
int m_FoodTickTimer;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */
|
2013-07-12 16:01:25 -04:00
|
|
|
double m_FoodExhaustionLevel;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
double m_Stance;
|
2014-06-29 06:36:38 -04:00
|
|
|
|
|
|
|
/** Stores the player's inventory, consisting of crafting grid, hotbar, and main slots */
|
2012-09-20 09:25:54 -04:00
|
|
|
cInventory m_Inventory;
|
2014-06-29 06:36:38 -04:00
|
|
|
|
|
|
|
/** An item grid that stores the player specific enderchest contents */
|
|
|
|
cItemGrid m_EnderChestContents;
|
|
|
|
|
2012-09-20 09:25:54 -04:00
|
|
|
cWindow * m_CurrentWindow;
|
|
|
|
cWindow * m_InventoryWindow;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-06-01 13:46:59 -04:00
|
|
|
/** The player's last saved bed position */
|
|
|
|
Vector3i m_LastBedPos;
|
|
|
|
|
2012-06-14 09:06:06 -04:00
|
|
|
eGameMode m_GameMode;
|
2014-01-25 14:02:13 -05:00
|
|
|
AString m_IP;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** The item being dragged by the cursor while in a UI window */
|
2012-09-20 09:25:54 -04:00
|
|
|
cItem m_DraggingItem;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2014-10-20 13:59:40 -04:00
|
|
|
std::chrono::steady_clock::time_point m_LastPlayerListTime;
|
2012-06-14 09:06:06 -04:00
|
|
|
|
2015-01-24 14:17:00 -05:00
|
|
|
cClientHandlePtr m_ClientHandle;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-05-30 04:40:13 -04:00
|
|
|
cSlotNums m_InventoryPaintSlots;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2015-12-24 05:37:32 -05:00
|
|
|
/** if m_IsFrozen is true, we lock m_Location to this position. */
|
|
|
|
Vector3d m_FrozenPosition;
|
|
|
|
|
|
|
|
/** If true, we are locking m_Position to m_FrozenPosition. */
|
|
|
|
bool m_IsFrozen;
|
|
|
|
|
|
|
|
/** */
|
|
|
|
int m_FreezeCounter;
|
|
|
|
|
|
|
|
/** Was the player frozen manually by a plugin or automatically by the server? */
|
|
|
|
bool m_IsManuallyFrozen;
|
|
|
|
|
2014-03-20 10:45:42 -04:00
|
|
|
/** Max speed, relative to the game default.
|
|
|
|
1 means regular speed, 2 means twice as fast, 0.5 means half-speed.
|
|
|
|
Default value is 1. */
|
2013-07-07 10:13:43 -04:00
|
|
|
double m_NormalMaxSpeed;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Max speed, relative to the game default max speed, when sprinting.
|
2014-03-20 10:45:42 -04:00
|
|
|
1 means regular speed, 2 means twice as fast, 0.5 means half-speed.
|
2014-03-20 11:14:40 -04:00
|
|
|
Default value is 1.3. */
|
2013-07-07 10:13:43 -04:00
|
|
|
double m_SprintingMaxSpeed;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Max speed, relative to the game default flying max speed, when flying.
|
|
|
|
1 means regular speed, 2 means twice as fast, 0.5 means half-speed.
|
|
|
|
Default value is 1. */
|
|
|
|
double m_FlyingMaxSpeed;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2013-06-04 10:18:03 -04:00
|
|
|
bool m_IsCrouched;
|
2013-07-07 10:13:43 -04:00
|
|
|
bool m_IsSprinting;
|
2013-12-15 08:48:17 -05:00
|
|
|
bool m_IsFlying;
|
2013-08-09 03:37:39 -04:00
|
|
|
bool m_IsSwimming;
|
|
|
|
bool m_IsSubmerged;
|
2013-12-19 11:33:21 -05:00
|
|
|
bool m_IsFishing;
|
2013-08-09 03:37:39 -04:00
|
|
|
|
2013-12-15 08:48:17 -05:00
|
|
|
bool m_CanFly; // If this is true the player can fly. Even if he is not in creative.
|
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** The world tick in which eating will be finished. -1 if not eating */
|
2013-07-28 13:15:03 -04:00
|
|
|
Int64 m_EatingFinishTick;
|
2013-11-13 08:50:47 -05:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Player Xp level */
|
2015-02-28 11:33:41 -05:00
|
|
|
int m_LifetimeTotalXp;
|
|
|
|
int m_CurrentXp;
|
2013-11-16 04:29:57 -05:00
|
|
|
|
|
|
|
// flag saying we need to send a xp update to client
|
|
|
|
bool m_bDirtyExperience;
|
2013-11-13 08:50:47 -05:00
|
|
|
|
2013-08-30 08:24:03 -04:00
|
|
|
bool m_IsChargingBow;
|
|
|
|
int m_BowCharge;
|
2013-07-28 13:15:03 -04:00
|
|
|
|
2015-07-29 11:04:03 -04:00
|
|
|
UInt32 m_FloaterID;
|
2013-11-21 16:09:11 -05:00
|
|
|
|
2014-03-08 19:17:23 -05:00
|
|
|
cTeam * m_Team;
|
2014-01-19 07:20:57 -05:00
|
|
|
|
2014-05-11 07:57:06 -04:00
|
|
|
cStatManager m_Stats;
|
|
|
|
|
2014-07-11 07:13:10 -04:00
|
|
|
/** Flag representing whether the player is currently in a bed
|
|
|
|
Set by a right click on unoccupied bed, unset by a time fast forward or teleport */
|
|
|
|
bool m_bIsInBed;
|
|
|
|
|
|
|
|
/** How long till the player's inventory will be saved
|
|
|
|
Default save interval is #defined in PLAYER_INVENTORY_SAVE_INTERVAL */
|
|
|
|
unsigned int m_TicksUntilNextSave;
|
|
|
|
|
|
|
|
/** Flag used by food handling system to determine whether a teleport has just happened
|
|
|
|
Will not apply food penalties if found to be true; will set to false after processing
|
|
|
|
*/
|
|
|
|
bool m_bIsTeleporting;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2015-02-28 11:39:36 -05:00
|
|
|
/** The short UUID (no dashes) of the player, as read from the ClientHandle.
|
2014-07-11 07:13:10 -04:00
|
|
|
If no ClientHandle is given, the UUID is initialized to empty. */
|
|
|
|
AString m_UUID;
|
|
|
|
|
2014-09-02 13:12:35 -04:00
|
|
|
AString m_CustomName;
|
|
|
|
|
2014-06-16 10:12:50 -04:00
|
|
|
/** Sets the speed and sends it to the client, so that they are forced to move so. */
|
|
|
|
virtual void DoSetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ) override;
|
|
|
|
|
2013-12-20 10:39:20 -05:00
|
|
|
void ResolvePermissions(void);
|
|
|
|
void ResolveGroups(void);
|
|
|
|
|
2015-05-23 07:56:08 -04:00
|
|
|
virtual void Destroyed(void) override;
|
2012-12-21 06:04:08 -05:00
|
|
|
|
2015-05-09 03:25:09 -04:00
|
|
|
/** Filters out damage for creative mode / friendly fire */
|
2014-04-25 18:32:30 -04:00
|
|
|
virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
|
2014-02-04 18:27:13 -05:00
|
|
|
|
|
|
|
/** Stops players from burning in creative mode */
|
|
|
|
virtual void TickBurning(cChunk & a_Chunk) override;
|
2015-05-23 14:31:33 -04:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Called in each tick to handle food-related processing */
|
2013-07-12 16:01:25 -04:00
|
|
|
void HandleFood(void);
|
2013-12-21 11:31:05 -05:00
|
|
|
|
2014-03-20 11:14:40 -04:00
|
|
|
/** Called in each tick if the player is fishing to make sure the floater dissapears when the player doesn't have a fishing rod as equipped item. */
|
2013-12-21 11:31:05 -05:00
|
|
|
void HandleFloater(void);
|
2013-08-08 05:32:34 -04:00
|
|
|
|
2014-05-12 14:38:52 -04:00
|
|
|
/** Tosses a list of items. */
|
|
|
|
void TossItems(const cItems & a_Items);
|
|
|
|
|
2015-12-24 05:37:32 -05:00
|
|
|
/** Pins the player to a_Location until Unfreeze() is called.
|
|
|
|
If ManuallyFrozen is false, the player will unfreeze when the chunk is loaded. */
|
|
|
|
void FreezeInternal(const Vector3d & a_Location, bool a_ManuallyFrozen);
|
|
|
|
|
2014-07-11 07:13:10 -04:00
|
|
|
/** Returns the filename for the player data based on the UUID given.
|
|
|
|
This can be used both for online and offline UUIDs. */
|
|
|
|
AString GetUUIDFileName(const AString & a_UUID);
|
2014-07-17 16:15:34 -04:00
|
|
|
} ; // tolua_export
|