diff options
Diffstat (limited to 'source/Entities/Player.h')
-rw-r--r-- | source/Entities/Player.h | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/source/Entities/Player.h b/source/Entities/Player.h index 01efa3681..bda25715d 100644 --- a/source/Entities/Player.h +++ b/source/Entities/Player.h @@ -32,6 +32,7 @@ public: EATING_TICKS = 30, ///< Number of ticks it takes to eat an item MAX_AIR_LEVEL = 300, DROWNING_TICKS = 10, //number of ticks per heart of damage + MIN_EXPERIENCE = 0, } ; // tolua_end @@ -63,6 +64,35 @@ public: /// Returns the currently equipped boots; empty item if none virtual cItem GetEquippedBoots(void) const override { return m_Inventory.GetEquippedBoots(); } + + + // tolua_begin + + /** Sets the experience total + Returns true on success + "should" really only be called at init or player death, plugins excepted + */ + bool SetCurrentExperience(short a_XpTotal); + + /* changes Xp by Xp_delta, you "shouldn't" inc more than MAX_EXPERIENCE_ORB_SIZE + Wont't allow xp to go negative + Returns the new current experience, -1 on error + */ + short DeltaExperience(short a_Xp_delta); + + /// Gets the experience total - XpTotal for score on death + inline short GetXpLifetimeTotal(void) { return m_LifetimeTotalXp; } + + /// Gets the currrent experience + inline short GetCurrentXp(void) { return m_CurrentXp; } + + /// Gets the current level - XpLevel + short GetXpLevel(void); + + /// Gets the experience bar percentage - XpP + float GetXpPercentage(void); + + // tolua_end /// Starts charging the equipped bow void StartChargingBow(void); @@ -244,6 +274,8 @@ public: void UseEquippedItem(void); void SendHealth(void); + + void SendExperience(void); // In UI windows, the item that the player is dragging: bool IsDraggingItem(void) const { return !m_DraggingItem.IsEmpty(); } @@ -289,7 +321,7 @@ public: virtual bool IsSubmerged(void) const{ return m_IsSubmerged; } // tolua_end - + // cEntity overrides: virtual bool IsCrouched (void) const { return m_IsCrouched; } virtual bool IsSprinting(void) const { return m_IsSprinting; } @@ -308,6 +340,14 @@ protected: std::string m_PlayerName; std::string m_LoadedWorldName; + /// Xp Level stuff + enum + { + XP_TO_LEVEL15 = 255, + XP_PER_LEVEL_TO15 = 17, + XP_TO_LEVEL30 = 825 + } ; + /// Player's air level (for swimming) int m_AirLevel; @@ -378,6 +418,19 @@ protected: /// The world tick in which eating will be finished. -1 if not eating Int64 m_EatingFinishTick; + + /// Player Xp level + short int m_LifetimeTotalXp; + short int m_CurrentXp; + + // flag saying we need to send a xp update to client + bool m_bDirtyExperience; + + /// Caculates the Xp needed for a given level, ref: http://minecraft.gamepedia.com/XP + static short XpForLevel(short int a_Level); + + /// inverse of XpAtLevel, ref: http://minecraft.gamepedia.com/XP values are as per this with pre-calculations + static short CalcLevelFromXp(short int a_CurrentXp); bool m_IsChargingBow; int m_BowCharge; |