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 | |
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 '')
-rw-r--r-- | source/Entities/Pickup.cpp | 7 | ||||
-rw-r--r-- | source/Entities/Pickup.h | 7 | ||||
-rw-r--r-- | source/Entities/Player.cpp | 2 | ||||
-rw-r--r-- | source/UI/SlotArea.cpp | 2 | ||||
-rw-r--r-- | source/World.cpp | 8 | ||||
-rw-r--r-- | source/World.h | 4 | ||||
-rw-r--r-- | source/WorldStorage/WSSAnvil.cpp | 2 |
7 files changed, 19 insertions, 13 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 } diff --git a/source/UI/SlotArea.cpp b/source/UI/SlotArea.cpp index 0a37e82b0..463e56bce 100644 --- a/source/UI/SlotArea.cpp +++ b/source/UI/SlotArea.cpp @@ -793,7 +793,7 @@ void cSlotAreaTemporary::TossItems(cPlayer & a_Player, int a_Begin, int a_End) double vX = 0, vY = 0, vZ = 0; EulerToVector(-a_Player.GetRotation(), a_Player.GetPitch(), vZ, vX, vY); vY = -vY * 2 + 1.f; - a_Player.GetWorld()->SpawnItemPickups(Drops, a_Player.GetPosX(), a_Player.GetPosY() + 1.6f, a_Player.GetPosZ(), vX * 3, vY * 3, vZ * 3); + a_Player.GetWorld()->SpawnItemPickups(Drops, a_Player.GetPosX(), a_Player.GetPosY() + 1.6f, a_Player.GetPosZ(), vX * 3, vY * 3, vZ * 3, true); // 'true' because player created } diff --git a/source/World.cpp b/source/World.cpp index a61c19d63..e2db77666 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -1470,7 +1470,7 @@ bool cWorld::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlock -void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed) +void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed, bool IsPlayerCreated) { MTRand r1; a_FlyAwaySpeed /= 1000; // Pre-divide, so that we don't have to divide each time inside the loop @@ -1482,7 +1482,7 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double cPickup * Pickup = new cPickup( a_BlockX, a_BlockY, a_BlockZ, - *itr, SpeedX, SpeedY, SpeedZ + *itr, IsPlayerCreated, SpeedX, SpeedY, SpeedZ ); Pickup->Initialize(this); } @@ -1492,13 +1492,13 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double -void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ) +void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated) { for (cItems::const_iterator itr = a_Pickups.begin(); itr != a_Pickups.end(); ++itr) { cPickup * Pickup = new cPickup( a_BlockX, a_BlockY, a_BlockZ, - *itr, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ + *itr, IsPlayerCreated, (float)a_SpeedX, (float)a_SpeedY, (float)a_SpeedZ ); Pickup->Initialize(this); } diff --git a/source/World.h b/source/World.h index a91007b17..f174a1c2c 100644 --- a/source/World.h +++ b/source/World.h @@ -348,10 +348,10 @@ public: // tolua_begin
/// Spawns item pickups for each item in the list. May compress pickups if too many entities:
- void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0);
+ void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false);
/// Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified:
- void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ);
+ void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false);
/// Spawns a new primed TNT entity at the specified block coords and specified fuse duration. Initial velocity is given based on the relative coefficient provided
void SpawnPrimedTNT(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec, double a_InitialVelocityCoeff = 1);
diff --git a/source/WorldStorage/WSSAnvil.cpp b/source/WorldStorage/WSSAnvil.cpp index 537e2f723..b2e104a78 100644 --- a/source/WorldStorage/WSSAnvil.cpp +++ b/source/WorldStorage/WSSAnvil.cpp @@ -1123,7 +1123,7 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a { return; } - std::auto_ptr<cPickup> Pickup(new cPickup(0, 0, 0, Item)); + std::auto_ptr<cPickup> Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false if (!LoadEntityBaseFromNBT(*Pickup.get(), a_NBT, a_TagIdx)) { return; |