1
0
Fork 0

Added cWorld::SpawnExperienceOrb function.

Most mobs now give proper Exp.
This commit is contained in:
STRWarrior 2013-11-25 21:03:26 +01:00
parent 6641db0583
commit dd76700d8d
3 changed files with 64 additions and 3 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);