summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities/Player.h')
-rw-r--r--src/Entities/Player.h44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 05377a117..b2142a18b 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -7,6 +7,8 @@
#include "../World.h"
#include "../ClientHandle.h"
+#include "../Statistics.h"
+
@@ -125,6 +127,9 @@ public:
inline const cItem & GetEquippedItem(void) const { return GetInventory().GetEquippedItem(); } // tolua_export
+ /** Returns whether the player is climbing (ladders, vines e.t.c). */
+ bool IsClimbing(void) const;
+
virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override;
// tolua_begin
@@ -174,14 +179,24 @@ public:
cTeam * UpdateTeam(void);
// tolua_end
+
+ /** Return the associated statistic and achievement manager. */
+ cStatManager & GetStatManager() { return m_Stats; }
+
+ /** Awards the player an achievement.
+ 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) */
+ unsigned int AwardAchievement(const eStatistic a_Ach);
void SetIP(const AString & a_IP);
// Sets the current gamemode, doesn't check validity, doesn't send update packets to client
void LoginSetGameMode(eGameMode a_GameMode);
- /** Forces the player to move in the given direction. */
- void ForceSetSpeed(Vector3d a_Direction); // tolua_export
+ /** Forces the player to move in the given direction.
+ @deprecated Use SetSpeed instead. */
+ void ForceSetSpeed(const Vector3d & a_Speed); // tolua_export
/** Tries to move to a new position, with attachment-related checks (y == -999) */
void MoveTo(const Vector3d & a_NewPos); // tolua_export
@@ -306,12 +321,16 @@ public:
void AbortEating(void);
virtual void KilledBy(cEntity * a_Killer) override;
+
+ virtual void Killed(cEntity * a_Victim) override;
void Respawn(void); // tolua_export
void SetVisible( bool a_bVisible ); // tolua_export
bool IsVisible(void) const { return m_bVisible; } // tolua_export
+ /** Moves the player to the specified world.
+ Returns true if successful, false on failure (world not found). */
bool MoveToWorld(const char * a_WorldName); // tolua_export
bool SaveToDisk(void);
@@ -375,6 +394,9 @@ public:
/** If true the player can fly even when he's not in creative. */
void SetCanFly(bool a_CanFly);
+ /** Update movement-related statistics. */
+ void UpdateMovementStats(const Vector3d & a_DeltaPos);
+
/** Returns wheter the player can fly or not. */
virtual bool CanFly(void) const { return m_CanFly; }
// tolua_end
@@ -423,9 +445,6 @@ protected:
/** Number of ticks remaining for the foodpoisoning effect; zero if not foodpoisoned */
int m_FoodPoisonedTicksRemaining;
- /** Last position that has been recorded for food-related processing: */
- Vector3d m_LastFoodPos;
-
float m_LastJumpHeight;
float m_LastGroundHeight;
bool m_bTouchGround;
@@ -443,7 +462,6 @@ protected:
cItem m_DraggingItem;
long long m_LastPlayerListTime;
- static const unsigned short PLAYER_LIST_TIME_MS = 1000; // 1000 = once per second
cClientHandle * m_ClientHandle;
@@ -490,7 +508,12 @@ protected:
cTeam * m_Team;
+ cStatManager m_Stats;
+
+
+ /** 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;
void ResolvePermissions(void);
void ResolveGroups(void);
@@ -498,7 +521,7 @@ protected:
virtual void Destroyed(void);
/** Filters out damage for creative mode/friendly fire */
- virtual void DoTakeDamage(TakeDamageInfo & TDI) override;
+ virtual bool DoTakeDamage(TakeDamageInfo & TDI) override;
/** Stops players from burning in creative mode */
virtual void TickBurning(cChunk & a_Chunk) override;
@@ -509,6 +532,9 @@ protected:
/** 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. */
void HandleFloater(void);
+ /** Tosses a list of items. */
+ void TossItems(const cItems & a_Items);
+
/** Adds food exhaustion based on the difference between Pos and LastPos, sprinting status and swimming (in water block) */
void ApplyFoodExhaustionFromMovement();
@@ -516,6 +542,10 @@ protected:
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;
+
} ; // tolua_export