diff options
Diffstat (limited to 'source/cWorld.cpp')
-rw-r--r-- | source/cWorld.cpp | 130 |
1 files changed, 120 insertions, 10 deletions
diff --git a/source/cWorld.cpp b/source/cWorld.cpp index e634ea112..aa1c8ba22 100644 --- a/source/cWorld.cpp +++ b/source/cWorld.cpp @@ -15,6 +15,20 @@ #include "cWaterSimulator.h"
#include "cChicken.h"
#include "cSpider.h"
+#include "cCow.h" //cow
+#include "cSquid.h" //Squid
+#include "cWolf.h" //wolf
+#include "cSlime.h" //slime
+#include "cSkeleton.h" //Skeleton
+#include "cSilverfish.h" //Silverfish
+#include "cPig.h" //pig
+#include "cSheep.h" //sheep
+#include "cZombie.h" //zombie
+#include "cEnderman.h" //enderman
+#include "cCreeper.h" //creeper
+#include "cCavespider.h" //cavespider
+#include "cGhast.h" //Ghast
+#include "cZombiepigman.h" //Zombiepigman
#include "cGenSettings.h"
@@ -316,8 +330,29 @@ void cWorld::Tick(float a_Dt) m_SpawnMonsterTime = m_Time;
if( m_pState->m_Players.size() > 0 )
{
- cChicken *Chicken;
- cSpider *Spider;
+
+ cChicken *Chicken;
+ cCow *Cow;
+ cPig *Pig;
+ cSheep *Sheep;
+ cSquid *Squid;
+ cWolf *Wolf;
+
+ cSpider *Spider;
+ cZombie *Zombie;
+ cEnderman *Enderman;
+ cCreeper *Creeper;
+ cGhast *Ghast;
+ cCavespider *Cavespider;
+ cZombiepigman *Zombiepigman;
+ cSkeleton *Skeleton;
+ cSlime *Slime;
+ cSilverfish *Silverfish;
+
+ srand ( time(NULL) ); //added mob code
+ int dayRand = rand() % 6; //added mob code
+ int nightRand = rand() % 10; //added mob code
+
int RandomPlayerIdx = rand() & m_pState->m_Players.size();
PlayerList::iterator itr = m_pState->m_Players.begin();
for( int i = 1; i < RandomPlayerIdx; i++ )
@@ -330,15 +365,90 @@ void cWorld::Tick(float a_Dt) //cMonster* Monster = new cChicken();
if(m_WorldTime >= 12000 + 1000) {
- Spider = new cSpider();
- Spider->Initialize();
- Spider->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
- Spider->SpawnOn( 0 );
+ if (nightRand == 0) { //random percent to spawn for night
+ Spider = new cSpider();
+ Spider->Initialize();
+ Spider->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Spider->SpawnOn( 0 );
+ } else if (nightRand == 1) {
+ Zombie = new cZombie();
+ Zombie->Initialize();
+ Zombie->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Zombie->SpawnOn( 0 );
+ } else if (nightRand == 2) {
+ Enderman = new cEnderman();
+ Enderman->Initialize();
+ Enderman->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Enderman->SpawnOn( 0 );
+ } else if (nightRand == 3) {
+ Creeper = new cCreeper();
+ Creeper->Initialize();
+ Creeper->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Creeper->SpawnOn( 0 );
+ } else if (nightRand == 4) {
+ Cavespider = new cCavespider();
+ Cavespider->Initialize();
+ Cavespider->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Cavespider->SpawnOn( 0 );
+ } else if (nightRand == 5) {
+ Ghast = new cGhast();
+ Ghast->Initialize();
+ Ghast->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Ghast->SpawnOn( 0 );
+ } else if (nightRand == 6) {
+ Zombiepigman = new cZombiepigman();
+ Zombiepigman->Initialize();
+ Zombiepigman->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Zombiepigman->SpawnOn( 0 );
+ } else if (nightRand == 7) {
+ Slime = new cSlime();
+ Slime->Initialize();
+ Slime->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Slime->SpawnOn( 0 );
+ } else if (nightRand == 8) {
+ Silverfish = new cSilverfish();
+ Silverfish->Initialize();
+ Silverfish->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Silverfish->SpawnOn( 0 );
+ } else if (nightRand == 9) {
+ Skeleton = new cSkeleton();
+ Skeleton->Initialize();
+ Skeleton->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Skeleton->SpawnOn( 0 );
+ } //end random percent to spawn for night
+
} else {
- Chicken = new cChicken();
- Chicken->Initialize();
- Chicken->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
- Chicken->SpawnOn( 0 );
+ if (dayRand == 0) { //random percent to spawn for day
+ Chicken = new cChicken();
+ Chicken->Initialize();
+ Chicken->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Chicken->SpawnOn( 0 );
+ } else if (dayRand == 1) {
+ Cow = new cCow();
+ Cow->Initialize();
+ Cow->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Cow->SpawnOn( 0 );
+ } else if (dayRand == 2) {
+ Pig = new cPig();
+ Pig->Initialize();
+ Pig->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Pig->SpawnOn( 0 );
+ } else if (dayRand == 3) {
+ Sheep = new cSheep();
+ Sheep->Initialize();
+ Sheep->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Sheep->SpawnOn( 0 );
+ } else if (dayRand == 4) {
+ Squid = new cSquid();
+ Squid->Initialize();
+ Squid->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Squid->SpawnOn( 0 );
+ } else if (dayRand == 5) {
+ Wolf = new cWolf();
+ Wolf->Initialize();
+ Wolf->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
+ Wolf->SpawnOn( 0 );
+ } //end random percent to spawn for day
}
//Monster->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
//Monster->SpawnOn( 0 );
|