Replace random Float Generation and broadcast the Exp Pickup Sound
This commit is contained in:
parent
f3bd288f02
commit
707916b404
@ -4,8 +4,6 @@
|
|||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "../ClientHandle.h"
|
#include "../ClientHandle.h"
|
||||||
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
|
|
||||||
cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward) :
|
cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward) :
|
||||||
cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98),
|
cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98),
|
||||||
@ -54,10 +52,9 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
LOGD("Player %s picked up an ExpOrb. His reward is %i", a_ClosestPlayer->GetName().c_str(), m_Reward);
|
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->DeltaExperience(m_Reward);
|
||||||
|
|
||||||
srand (static_cast <unsigned> (time(0)));
|
float r1 = (float) (0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64); // Random Float Value
|
||||||
float r1 = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); // Random Float Value (Java: random.nextFloat())
|
float r2 = (float) (0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64); // Random Float Value
|
||||||
float r2 = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); // Random Float Value (Java: random.nextFloat())
|
m_World->BroadcastSoundEffect("random.orb", (int) (GetPosX() * 8.0F), (int) (GetPosY() * 8.0F), (int) (GetPosZ() * 8.0F), 0.1F, 0.5F * ((r1 - r2) * 0.7F + 1.8F));
|
||||||
a_ClosestPlayer->PlaySoundEffect("random.orb", 0.1F, 0.5F * ((r1 - r2) * 0.7F + 1.8F));
|
|
||||||
|
|
||||||
Destroy(true);
|
Destroy(true);
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
#include "../ChunkMap.h"
|
#include "../ChunkMap.h"
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -682,7 +680,7 @@ super(pkExpBottle, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
|
|||||||
void cExpBottleEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
|
void cExpBottleEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
|
||||||
{
|
{
|
||||||
// Spawn an experience orb with a reward between 3 and 11.
|
// Spawn an experience orb with a reward between 3 and 11.
|
||||||
m_World->BroadcastSoundParticleEffect(2002, (int) round(GetPosX()), (int) round(GetPosY()), (int) round(GetPosZ()), 0);
|
m_World->BroadcastSoundParticleEffect(2002, POSX_TOINT, POSY_TOINT, POSZ_TOINT, 0);
|
||||||
m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), 3 + m_World->GetTickRandomNumber(8));
|
m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), 3 + m_World->GetTickRandomNumber(8));
|
||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
|
Loading…
Reference in New Issue
Block a user