diff options
author | STRWarrior <niels.breuker@hotmail.nl> | 2013-11-25 21:03:26 +0100 |
---|---|---|
committer | STRWarrior <niels.breuker@hotmail.nl> | 2013-11-25 21:03:26 +0100 |
commit | dd76700d8d0491f385efee1a539462501cb41ad4 (patch) | |
tree | e8bacd6ae966bf47d51382a9ca06fce4f1ba2453 | |
parent | Implented ExpOrb class. (diff) | |
download | cuberite-dd76700d8d0491f385efee1a539462501cb41ad4.tar cuberite-dd76700d8d0491f385efee1a539462501cb41ad4.tar.gz cuberite-dd76700d8d0491f385efee1a539462501cb41ad4.tar.bz2 cuberite-dd76700d8d0491f385efee1a539462501cb41ad4.tar.lz cuberite-dd76700d8d0491f385efee1a539462501cb41ad4.tar.xz cuberite-dd76700d8d0491f385efee1a539462501cb41ad4.tar.zst cuberite-dd76700d8d0491f385efee1a539462501cb41ad4.zip |
-rw-r--r-- | source/Mobs/Monster.cpp | 53 | ||||
-rw-r--r-- | source/World.cpp | 11 | ||||
-rw-r--r-- | source/World.h | 3 |
3 files changed, 64 insertions, 3 deletions
diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index f250e1757..a74881978 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -259,9 +259,56 @@ void cMonster::KilledBy(cEntity * a_Killer) { m_World->BroadcastSoundEffect(m_SoundDeath, (int)(GetPosX() * 8), (int)(GetPosY() * 8), (int)(GetPosZ() * 8), 1.0f, 0.8f); } - // ToDo: Proper Exp per mob. - cExpOrb * ExpOrb = new cExpOrb(GetPosX(), GetPosY(), GetPosZ(), 1); - ExpOrb->Initialize(m_World); + int Exp; + switch (m_MobType) + { + // Animals + case cMonster::mtChicken: + case cMonster::mtCow: + case cMonster::mtHorse: + case cMonster::mtPig: + case cMonster::mtSheep: + case cMonster::mtSquid: + case cMonster::mtMooshroom: + case cMonster::mtOcelot: + case cMonster::mtWolf: + { + Exp = m_World->GetTickRandomNumber(2) + 1; + } + + // Monsters + case cMonster::mtCaveSpider: + case cMonster::mtCreeper: + case cMonster::mtEnderman: + case cMonster::mtGhast: + case cMonster::mtSilverfish: + case cMonster::mtSkeleton: + case cMonster::mtSpider: + case cMonster::mtWitch: + case cMonster::mtZombie: + case cMonster::mtZombiePigman: + case cMonster::mtSlime: + case cMonster::mtMagmaCube: + { + Exp = 6 + (m_World->GetTickRandomNumber(2)); + } + + // Bosses + case cMonster::mtEnderDragon: + { + Exp = 12000; + } + case cMonster::mtWither: + { + Exp = 50; + } + + default: + { + Exp = 0; + } + } + m_World->SpawnExperienceOrb(GetPosX(), GetPosY(), GetPosZ(), Exp); m_DestroyTimer = 0; } diff --git a/source/World.cpp b/source/World.cpp index 531952e37..432ab32e9 100644 --- a/source/World.cpp +++ b/source/World.cpp @@ -13,6 +13,7 @@ #include "OSSupport/Timer.h" // Entities (except mobs): +#include "Entities/ExpOrb.h" #include "Entities/Pickup.h" #include "Entities/Player.h" #include "Entities/TNTEntity.h" @@ -1561,6 +1562,16 @@ void cWorld::SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double +void cWorld::SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward) +{ + cExpOrb * ExpOrb = new cExpOrb(a_X, a_Y, a_Z, a_Reward); + ExpOrb->Initialize(this); +} + + + + + void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec, double a_InitialVelocityCoeff) { cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTimeInSec); diff --git a/source/World.h b/source/World.h index d10aa3b78..9397f8b75 100644 --- a/source/World.h +++ b/source/World.h @@ -353,6 +353,9 @@ public: /// 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, bool IsPlayerCreated = false); + /// Spawns an experience orb at the given location with the given reward. + void SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward); + /// 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); |