summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Effects.h30
-rw-r--r--src/Entities/ExpOrb.cpp4
-rw-r--r--src/Entities/Player.cpp42
-rw-r--r--src/Entities/Player.h14
-rw-r--r--src/Entities/TNTEntity.h8
5 files changed, 92 insertions, 6 deletions
diff --git a/src/Entities/Effects.h b/src/Entities/Effects.h
new file mode 100644
index 000000000..e7611847d
--- /dev/null
+++ b/src/Entities/Effects.h
@@ -0,0 +1,30 @@
+#pragma once
+
+// tolua_begin
+enum ENUM_ENTITY_EFFECT
+{
+ E_EFFECT_SPEED = 1,
+ E_EFFECT_SLOWNESS = 2,
+ E_EFFECT_HASTE = 3,
+ E_EFFECT_MINING_FATIGUE = 4,
+ E_EFFECT_STENGTH = 5,
+ E_EFFECT_INSTANT_HEALTH = 6,
+ E_EFFECT_INSTANT_DAMAGE = 7,
+ E_EFFECT_JUMP_BOOST = 8,
+ E_EFFECT_NAUSEA = 9,
+ E_EFFECT_REGENERATION = 10,
+ E_EFFECT_RESISTANCE = 11,
+ E_EFFECT_FIRE_RESISTANCE = 12,
+ E_EFFECT_WATER_BREATHING = 13,
+ E_EFFECT_INVISIBILITY = 14,
+ E_EFFECT_BLINDNESS = 15,
+ E_EFFECT_NIGHT_VISION = 16,
+ E_EFFECT_HUNGER = 17,
+ E_EFFECT_WEAKNESS = 18,
+ E_EFFECT_POISON = 19,
+ E_EFFECT_WITHER = 20,
+ E_EFFECT_HEALTH_BOOST = 21,
+ E_EFFECT_ABSORPTION = 22,
+ E_EFFECT_SATURATION = 23,
+} ;
+// tolua_end \ No newline at end of file
diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp
index 27d34f6ed..04ee85823 100644
--- a/src/Entities/ExpOrb.cpp
+++ b/src/Entities/ExpOrb.cpp
@@ -49,12 +49,12 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
double Distance(a_Distance.Length());
if (Distance < 0.1f)
{
+ LOGD("Player %s picked up an ExpOrb. His reward is %i", a_ClosestPlayer->GetName().c_str(), m_Reward);
a_ClosestPlayer->DeltaExperience(m_Reward);
- a_ClosestPlayer->SendExperience();
Destroy(true);
}
a_Distance.Normalize();
- a_Distance *= ((float) (5.5 - Distance));
+ a_Distance *= ((float) (5.5 - Distance));
SetSpeedX( a_Distance.x );
SetSpeedY( a_Distance.y );
SetSpeedZ( a_Distance.z );
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 85833f31d..c2a76342d 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -63,6 +63,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_IsSprinting(false)
, m_IsSwimming(false)
, m_IsSubmerged(false)
+ , m_IsFlying(false)
+ , m_CanFly(false)
, m_EatingFinishTick(-1)
, m_IsChargingBow(false)
, m_BowCharge(0)
@@ -557,9 +559,13 @@ void cPlayer::FoodPoison(int a_NumTicks)
m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
if (!HasBeenFoodPoisoned)
{
- // TODO: Send the poisoning indication to the client - how?
+ m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER);
SendHealth();
}
+ else
+ {
+ m_World->BroadcastEntityEffect(*this, E_EFFECT_HUNGER, 0, 400); // Give the player the "Hunger" effect for 20 seconds.
+ }
}
@@ -747,6 +753,36 @@ void cPlayer::SetSprint(bool a_IsSprinting)
+void cPlayer::SetCanFly(bool a_CanFly)
+{
+ if (a_CanFly == m_CanFly)
+ {
+ return;
+ }
+
+ m_CanFly = a_CanFly;
+ m_ClientHandle->SendPlayerAbilities();
+}
+
+
+
+
+
+void cPlayer::SetFlying(bool a_IsFlying)
+{
+ if (a_IsFlying == m_IsFlying)
+ {
+ return;
+ }
+
+ m_IsFlying = a_IsFlying;
+ m_ClientHandle->SendPlayerAbilities();
+}
+
+
+
+
+
void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (a_TDI.DamageType != dtInVoid)
@@ -1704,6 +1740,10 @@ void cPlayer::HandleFood(void)
m_FoodPoisonedTicksRemaining--;
m_FoodExhaustionLevel += 0.025; // 0.5 per second = 0.025 per tick
}
+ else
+ {
+ m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER); // Remove the "Hunger" effect.
+ }
// Apply food exhaustion that has accumulated:
if (m_FoodExhaustionLevel >= 4)
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 44cab7d74..f3ee841e7 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -250,6 +250,8 @@ public:
/// Returns true if the player is currently in the process of eating the currently equipped item
bool IsEating(void) const { return (m_EatingFinishTick >= 0); }
+ /// Returns true if the player is currently flying.
+ bool IsFlying(void) const { return m_IsFlying; }
// tolua_end
/// Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet
@@ -319,12 +321,20 @@ public:
/// Starts or stops sprinting, sends the max speed update to the client, if needed
void SetSprint(bool a_IsSprinting);
+ /// Flags the player as flying
+ void SetFlying(bool a_IsFlying);
+
+ /// If true the player can fly even when he's not in creative.
+ void SetCanFly(bool a_CanFly);
+
/// Returns whether the player is swimming or not
virtual bool IsSwimming(void) const{ return m_IsSwimming; }
/// Return whether the player is under water or not
virtual bool IsSubmerged(void) const{ return m_IsSubmerged; }
+ /// Returns wheter the player can fly or not.
+ virtual bool CanFly(void) const { return m_CanFly; }
// tolua_end
// cEntity overrides:
@@ -415,10 +425,12 @@ protected:
bool m_IsCrouched;
bool m_IsSprinting;
-
+ bool m_IsFlying;
bool m_IsSwimming;
bool m_IsSubmerged;
+ bool m_CanFly; // If this is true the player can fly. Even if he is not in creative.
+
/// The world tick in which eating will be finished. -1 if not eating
Int64 m_EatingFinishTick;
diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h
index eb5040e8a..d1fcae766 100644
--- a/src/Entities/TNTEntity.h
+++ b/src/Entities/TNTEntity.h
@@ -6,13 +6,14 @@
-
+// tolua_begin
class cTNTEntity :
public cEntity
{
typedef cEntity super;
public:
+ // tolua_end
CLASS_PROTODEF(cTNTEntity);
cTNTEntity(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec);
@@ -21,11 +22,14 @@ public:
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
+
+ double GetCounterTime(void) const { return m_Counter; } // tolua_export
+ double GetMaxFuseTime(void) const { return m_MaxFuseTime; } // tolua_export
protected:
double m_Counter; ///< How much time has elapsed since the object was created, in seconds
double m_MaxFuseTime; ///< How long the fuse is, in seconds
-};
+}; // tolua_export