diff options
author | Alexander Harkness <bearbin@gmail.com> | 2013-10-24 08:36:25 +0200 |
---|---|---|
committer | Alexander Harkness <bearbin@gmail.com> | 2013-10-24 08:36:25 +0200 |
commit | 54f5f71c9a3eb1d7d7516cc750e4bffba86bd585 (patch) | |
tree | 1ff9d4a148086e34f5b78751ec51d470928448ca /source/Entities | |
parent | APIDump: Added cChatColor constants. (diff) | |
parent | Pickups now have collection delay when vomited (diff) | |
download | cuberite-54f5f71c9a3eb1d7d7516cc750e4bffba86bd585.tar cuberite-54f5f71c9a3eb1d7d7516cc750e4bffba86bd585.tar.gz cuberite-54f5f71c9a3eb1d7d7516cc750e4bffba86bd585.tar.bz2 cuberite-54f5f71c9a3eb1d7d7516cc750e4bffba86bd585.tar.lz cuberite-54f5f71c9a3eb1d7d7516cc750e4bffba86bd585.tar.xz cuberite-54f5f71c9a3eb1d7d7516cc750e4bffba86bd585.tar.zst cuberite-54f5f71c9a3eb1d7d7516cc750e4bffba86bd585.zip |
Diffstat (limited to 'source/Entities')
-rw-r--r-- | source/Entities/Pickup.cpp | 7 | ||||
-rw-r--r-- | source/Entities/Pickup.h | 7 | ||||
-rw-r--r-- | source/Entities/Player.cpp | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/source/Entities/Pickup.cpp b/source/Entities/Pickup.cpp index 075f93449..50431f52e 100644 --- a/source/Entities/Pickup.cpp +++ b/source/Entities/Pickup.cpp @@ -24,11 +24,12 @@ -cPickup::cPickup(double a_X, double a_Y, double a_Z, const cItem & a_Item, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */) +cPickup::cPickup(double a_X, double a_Y, double a_Z, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */) : cEntity(etPickup, a_X, a_Y, a_Z, 0.2, 0.2) , m_Timer( 0.f ) , m_Item(a_Item) , m_bCollected( false ) + , m_bIsPlayerCreated( IsPlayerCreated ) { m_MaxHealth = 5; m_Health = 5; @@ -126,8 +127,8 @@ bool cPickup::CollectedBy(cPlayer * a_Dest) return false; // It's already collected! } - // 800 is to long - if (m_Timer < 500.f) + // Two seconds if player created the pickup (vomiting), half a second if anything else + if (m_Timer < (m_bIsPlayerCreated ? 2000.f : 500.f)) { // LOG("Pickup %d cannot be collected by \"%s\", because it is not old enough.", m_UniqueID, a_Dest->GetName().c_str()); return false; // Not old enough diff --git a/source/Entities/Pickup.h b/source/Entities/Pickup.h index 488f91fb2..e4154f1d4 100644 --- a/source/Entities/Pickup.h +++ b/source/Entities/Pickup.h @@ -24,7 +24,7 @@ class cPickup : public: CLASS_PROTODEF(cPickup); - cPickup(double a_X, double a_Y, double a_Z, const cItem & a_Item, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); // tolua_export + cPickup(double a_MicroPosX, double a_MicroPosY, double a_MicroPosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f); // tolua_export cItem & GetItem(void) {return m_Item; } // tolua_export const cItem & GetItem(void) const {return m_Item; } @@ -40,6 +40,9 @@ public: /// Returns true if the pickup has already been collected bool IsCollected(void) const { return m_bCollected; } // tolua_export + + /// Returns true if created by player (i.e. vomiting), used for determining picking-up delay time + bool IsPlayerCreated(void) const { return m_bIsPlayerCreated; } // tolua_export private: Vector3d m_ResultingSpeed; //Can be used to modify the resulting speed for the current tick ;) @@ -52,6 +55,8 @@ private: cItem m_Item; bool m_bCollected; + + bool m_bIsPlayerCreated; }; // tolua_export diff --git a/source/Entities/Player.cpp b/source/Entities/Player.cpp index d93b45614..e06281998 100644 --- a/source/Entities/Player.cpp +++ b/source/Entities/Player.cpp @@ -1183,7 +1183,7 @@ void cPlayer::TossItem( double vX = 0, vY = 0, vZ = 0; EulerToVector(-GetRotation(), GetPitch(), vZ, vX, vY); vY = -vY * 2 + 1.f; - m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY() + 1.6f, GetPosZ(), vX * 3, vY * 3, vZ * 3); + m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY() + 1.6f, GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because created by player } |