1
0

Merge pull request #322 from tonibm19/master

Now chicken drop eggs
This commit is contained in:
Mattes D 2013-11-08 08:33:14 -08:00
commit 71461dccbc
2 changed files with 40 additions and 7 deletions

View File

@ -1,26 +1,51 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "Chicken.h"
#include "../World.h"
// TODO: Drop egg every 5-10 minutes
cChicken::cChicken(void) :
super("Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4)
super("Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4),
m_EggDropTimer(0)
{
}
void cChicken::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
if (m_EggDropTimer == 6000 && m_World->GetTickRandomNumber(1) == 0)
{
cItems Drops;
m_EggDropTimer = 0;
Drops.push_back(cItem(E_ITEM_EGG, 1));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
}
else if (m_EggDropTimer == 12000)
{
cItems Drops;
m_EggDropTimer = 0;
Drops.push_back(cItem(E_ITEM_EGG, 1));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
}
else
{
m_EggDropTimer++;
}
}
void cChicken::GetDrops(cItems & a_Drops, cEntity * a_Killer)
{
@ -31,3 +56,7 @@ void cChicken::GetDrops(cItems & a_Drops, cEntity * a_Killer)

View File

@ -1,4 +1,3 @@
#pragma once
#include "PassiveMonster.h"
@ -18,8 +17,13 @@ public:
CLASS_PROTODEF(cChicken);
virtual void GetDrops(cItems & a_Drops, cEntity * a_Killer = NULL) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
private:
int m_EggDropTimer;
} ;