diff options
author | Howaner <franzi.moos@googlemail.com> | 2014-02-14 22:49:23 +0100 |
---|---|---|
committer | Howaner <franzi.moos@googlemail.com> | 2014-02-16 01:19:30 +0100 |
commit | f3bd288f020a8f004179513c0e260ac0f2855767 (patch) | |
tree | 174babd6e46d2979bb9d00124ac4cb3109d3e6c7 | |
parent | Set max. Players in the Tablist to 60 (diff) | |
download | cuberite-f3bd288f020a8f004179513c0e260ac0f2855767.tar cuberite-f3bd288f020a8f004179513c0e260ac0f2855767.tar.gz cuberite-f3bd288f020a8f004179513c0e260ac0f2855767.tar.bz2 cuberite-f3bd288f020a8f004179513c0e260ac0f2855767.tar.lz cuberite-f3bd288f020a8f004179513c0e260ac0f2855767.tar.xz cuberite-f3bd288f020a8f004179513c0e260ac0f2855767.tar.zst cuberite-f3bd288f020a8f004179513c0e260ac0f2855767.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Entities/ExpOrb.cpp | 10 | ||||
-rw-r--r-- | src/Entities/Player.cpp | 9 | ||||
-rw-r--r-- | src/Entities/Player.h | 2 | ||||
-rw-r--r-- | src/Entities/ProjectileEntity.cpp | 3 |
4 files changed, 23 insertions, 1 deletions
diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp index 04ee85823..8b0838d27 100644 --- a/src/Entities/ExpOrb.cpp +++ b/src/Entities/ExpOrb.cpp @@ -4,6 +4,8 @@ #include "Player.h" #include "../ClientHandle.h" +#include <ctime> + 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), @@ -51,6 +53,12 @@ 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); a_ClosestPlayer->DeltaExperience(m_Reward); + + srand (static_cast <unsigned> (time(0))); + float r1 = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); // Random Float Value (Java: random.nextFloat()) + float r2 = static_cast <float> (rand()) / static_cast <float> (RAND_MAX); // Random Float Value (Java: random.nextFloat()) + a_ClosestPlayer->PlaySoundEffect("random.orb", 0.1F, 0.5F * ((r1 - r2) * 0.7F + 1.8F)); + Destroy(true); } a_Distance.Normalize(); @@ -61,4 +69,4 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk) BroadcastMovementUpdate(); } HandlePhysics(a_Dt, a_Chunk); -}
\ No newline at end of file +} diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 6e3db5194..be26e4f6e 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -1059,6 +1059,15 @@ void cPlayer::CloseWindowIfID(char a_WindowID, bool a_CanRefuse) +void cPlayer::PlaySoundEffect(const AString & a_SoundName, float a_Volume, float a_Pitch) +{ + m_ClientHandle->SendSoundEffect(a_SoundName, (int) (GetPosX() * 8.0), (int) (GetPosY() * 8.0), (int) (GetPosZ() * 8.0), a_Volume, a_Pitch); +} + + + + + void cPlayer::SetLastBlockActionTime() { if (m_World != NULL) diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 53e4b56db..838f0301d 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -208,6 +208,8 @@ public: const AString & GetName(void) const { return m_PlayerName; } void SetName(const AString & a_Name) { m_PlayerName = a_Name; } + void PlaySoundEffect(const AString & a_SoundName, float a_Volume, float a_Pitch); + // tolua_end typedef std::list< cGroup* > GroupList; diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp index a3fa9d557..718a04baf 100644 --- a/src/Entities/ProjectileEntity.cpp +++ b/src/Entities/ProjectileEntity.cpp @@ -12,6 +12,8 @@ #include "../ChunkMap.h" #include "../Chunk.h" +#include <math.h> + @@ -680,6 +682,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) { // 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->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), 3 + m_World->GetTickRandomNumber(8)); Destroy(); |