1
0

Fishing now uses a countdown instead of a random number each tick.

This commit is contained in:
STRWarrior 2013-12-22 14:48:22 +01:00
parent e9d1352f6e
commit 7a299f1ba6
2 changed files with 29 additions and 12 deletions

View File

@ -9,11 +9,12 @@
cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID) : cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime) :
cEntity(etFloater, a_X, a_Y, a_Z, 0.98, 0.98), cEntity(etFloater, a_X, a_Y, a_Z, 0.98, 0.98),
m_PickupCountDown(0), m_PickupCountDown(0),
m_PlayerID(a_PlayerID), m_PlayerID(a_PlayerID),
m_CanPickupItem(false) m_CanPickupItem(false),
m_CountDownTime(a_CountDownTime)
{ {
SetSpeed(a_Speed); SetSpeed(a_Speed);
} }
@ -36,17 +37,31 @@ void cFloater::Tick(float a_Dt, cChunk & a_Chunk)
HandlePhysics(a_Dt, a_Chunk); HandlePhysics(a_Dt, a_Chunk);
if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0) if (IsBlockWater(m_World->GetBlock((int) GetPosX(), (int) GetPosY(), (int) GetPosZ())) && m_World->GetBlockMeta((int) GetPosX(), (int) GetPosY(), (int) GetPosZ()) == 0)
{ {
if ((!m_CanPickupItem) && (m_World->GetTickRandomNumber(100) == 0)) if (!m_CanPickupItem)
{ {
SetPosY(GetPosY() - 1); if (m_CountDownTime <= 0)
m_CanPickupItem = true; {
m_PickupCountDown = 20; m_World->BroadcastSoundEffect("random.splash", (int) floor(GetPosX() * 8), (int) floor(GetPosY() * 8), (int) floor(GetPosZ() * 8), 1, 1);
LOGD("Floater %i can be picked up", GetUniqueID()); SetPosY(GetPosY() - 1);
} m_CanPickupItem = true;
else m_PickupCountDown = 20;
{ m_CountDownTime = 100 + m_World->GetTickRandomNumber(800);
SetSpeedY(0.7); LOGD("Floater %i can be picked up", GetUniqueID());
}
else if (m_CountDownTime == 20) // Calculate the position where the particles should spawn and start producing them.
{
LOGD("Started producing particles for floater %i", GetUniqueID());
m_ParticlePos.Set(GetPosX() + (-4 + m_World->GetTickRandomNumber(8)), GetPosY(), GetPosZ() + (-4 + m_World->GetTickRandomNumber(8)));
m_World->BroadcastParticleEffect("splash", m_ParticlePos.x, m_ParticlePos.y, m_ParticlePos.z, 0, 0, 0, 0, 15);
}
else if (m_CountDownTime < 20)
{
m_ParticlePos = (m_ParticlePos + (GetPosition() - m_ParticlePos) / 6);
m_World->BroadcastParticleEffect("splash", m_ParticlePos.x, m_ParticlePos.y, m_ParticlePos.z, 0, 0, 0, 0, 15);
}
m_CountDownTime--;
} }
SetSpeedY(0.7);
} }
SetSpeedX(GetSpeedX() * 0.95); SetSpeedX(GetSpeedX() * 0.95);
SetSpeedZ(GetSpeedZ() * 0.95); SetSpeedZ(GetSpeedZ() * 0.95);

View File

@ -14,7 +14,7 @@ class cFloater :
public: public:
cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID); cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime);
virtual void SpawnOn(cClientHandle & a_Client) override; virtual void SpawnOn(cClientHandle & a_Client) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override; virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
@ -23,7 +23,9 @@ public:
protected: protected:
Vector3d m_Speed; Vector3d m_Speed;
Vector3d m_ParticlePos;
int m_PickupCountDown; int m_PickupCountDown;
int m_PlayerID; int m_PlayerID;
int m_CountDownTime;
bool m_CanPickupItem; bool m_CanPickupItem;
} ; } ;