summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--makefile84
-rw-r--r--settings.ini2
-rw-r--r--source/cCavespider.cpp92
-rw-r--r--source/cCavespider.h22
-rw-r--r--source/cCow.cpp90
-rw-r--r--source/cCow.h21
-rw-r--r--source/cCreeper.cpp91
-rw-r--r--source/cCreeper.h22
-rw-r--r--source/cEnderman.cpp94
-rw-r--r--source/cEnderman.h22
-rw-r--r--source/cGhast.cpp91
-rw-r--r--source/cGhast.h22
-rw-r--r--source/cPig.cpp90
-rw-r--r--source/cPig.h21
-rw-r--r--source/cSheep.cpp90
-rw-r--r--source/cSheep.h21
-rw-r--r--source/cSilverfish.cpp91
-rw-r--r--source/cSilverfish.h22
-rw-r--r--source/cSkeleton.cpp94
-rw-r--r--source/cSkeleton.h22
-rw-r--r--source/cSlime.cpp91
-rw-r--r--source/cSlime.h22
-rw-r--r--source/cSquid.cpp90
-rw-r--r--source/cSquid.h21
-rw-r--r--source/cWolf.cpp91
-rw-r--r--source/cWolf.h22
-rw-r--r--source/cWorld.cpp130
-rw-r--r--source/cZombie.cpp94
-rw-r--r--source/cZombie.h22
-rw-r--r--source/cZombiepigman.cpp94
-rw-r--r--source/cZombiepigman.h22
31 files changed, 1792 insertions, 11 deletions
diff --git a/makefile b/makefile
index af097c5dd..f52c99a32 100644
--- a/makefile
+++ b/makefile
@@ -55,6 +55,20 @@ MCServer : \
build/cAuthenticator.o\
build/cLuaCommandBinder.o\
build/cChicken.o\
+ build/cCow.o\
+ build/cPig.o\
+ build/cSheep.o\
+ build/cSquid.o\
+ build/cWolf.o\
+ build/cZombie.o\
+ build/cEnderman.o\
+ build/cCreeper.o\
+ build/cGhast.o\
+ build/cCavespider.o\
+ build/cZombiepigman.o\
+ build/cSkeleton.o\
+ build/cSlime.o\
+ build/cSilverfish.o\
build/md5.o\
build/cReferenceManager.o\
build/Bindings.o\
@@ -221,6 +235,20 @@ MCServer : \
build/cAuthenticator.o\
build/cLuaCommandBinder.o\
build/cChicken.o\
+ build/cCow.o\
+ build/cPig.o\
+ build/cSheep.o\
+ build/cSquid.o\
+ build/cWolf.o\
+ build/cZombie.o\
+ build/cEnderman.o\
+ build/cCreeper.o\
+ build/cGhast.o\
+ build/cCavespider.o\
+ build/cZombiepigman.o\
+ build/cSkeleton.o\
+ build/cSlime.o\
+ build/cSilverfish.o\
build/md5.o\
build/cReferenceManager.o\
build/Bindings.o\
@@ -390,6 +418,20 @@ clean :
build/cAuthenticator.o\
build/cLuaCommandBinder.o\
build/cChicken.o\
+ build/cCow.o\
+ build/cPig.o\
+ build/cSheep.o\
+ build/cSquid.o\
+ build/cWolf.o\
+ build/cZombie.o\
+ build/cEnderman.o\
+ build/cCreeper.o\
+ build/cGhast.o\
+ build/cCavespider.o\
+ build/cZombiepigman.o\
+ build/cSkeleton.o\
+ build/cSlime.o\
+ build/cSilverfish.o\
build/md5.o\
build/cReferenceManager.o\
build/Bindings.o\
@@ -1220,6 +1262,48 @@ build/cThread.o: source/cThread.cpp
build/cSpider.o: source/cSpider.cpp
$(CC) $(CC_OPTIONS) source/cSpider.cpp -c $(INCLUDE) -o build/cSpider.o
+build/cCow.o: source/cCow.cpp
+ $(CC) $(CC_OPTIONS) source/cCow.cpp -c $(INCLUDE) -o build/cCow.o
+
+build/cPig.o: source/cPig.cpp
+ $(CC) $(CC_OPTIONS) source/cPig.cpp -c $(INCLUDE) -o build/cPig.o
+
+build/cSheep.o: source/cSheep.cpp
+ $(CC) $(CC_OPTIONS) source/cSheep.cpp -c $(INCLUDE) -o build/cSheep.o
+
+build/cSquid.o: source/cSquid.cpp
+ $(CC) $(CC_OPTIONS) source/cSquid.cpp -c $(INCLUDE) -o build/cSquid.o
+
+build/cWolf.o: source/cWolf.cpp
+ $(CC) $(CC_OPTIONS) source/cWolf.cpp -c $(INCLUDE) -o build/cWolf.o
+
+build/cZombie.o: source/cZombie.cpp
+ $(CC) $(CC_OPTIONS) source/cZombie.cpp -c $(INCLUDE) -o build/cZombie.o
+
+build/cEnderman.o: source/cEnderman.cpp
+ $(CC) $(CC_OPTIONS) source/cEnderman.cpp -c $(INCLUDE) -o build/cEnderman.o
+
+build/cCreeper.o: source/cCreeper.cpp
+ $(CC) $(CC_OPTIONS) source/cCreeper.cpp -c $(INCLUDE) -o build/cCreeper.o
+
+build/cGhast.o: source/cGhast.cpp
+ $(CC) $(CC_OPTIONS) source/cGhast.cpp -c $(INCLUDE) -o build/cGhast.o
+
+build/cCavespider.o: source/cCavespider.cpp
+ $(CC) $(CC_OPTIONS) source/cCavespider.cpp -c $(INCLUDE) -o build/cCavespider.o
+
+build/cZombiepigman.o: source/cZombiepigman.cpp
+ $(CC) $(CC_OPTIONS) source/cZombiepigman.cpp -c $(INCLUDE) -o build/cZombiepigman.o
+
+build/cSkeleton.o: source/cSkeleton.cpp
+ $(CC) $(CC_OPTIONS) source/cSkeleton.cpp -c $(INCLUDE) -o build/cSkeleton.o
+
+build/cSlime.o: source/cSlime.cpp
+ $(CC) $(CC_OPTIONS) source/cSlime.cpp -c $(INCLUDE) -o build/cSlime.o
+
+build/cSilverfish.o: source/cSilverfish.cpp
+ $(CC) $(CC_OPTIONS) source/cSilverfish.cpp -c $(INCLUDE) -o build/cSilverfish.o
+
build/cMonsterConfig.o: source/cMonsterConfig.cpp
$(CC) $(CC_OPTIONS) source/cMonsterConfig.cpp -c $(INCLUDE) -o build/cMonsterConfig.o
diff --git a/settings.ini b/settings.ini
index 9952dfb5a..cf3e26e16 100644
--- a/settings.ini
+++ b/settings.ini
@@ -1,5 +1,5 @@
[Server]
-Port=25565
+Port=11111
ServerID=-
[Plugins]
diff --git a/source/cCavespider.cpp b/source/cCavespider.cpp
new file mode 100644
index 000000000..75673d5ec
--- /dev/null
+++ b/source/cCavespider.cpp
@@ -0,0 +1,92 @@
+#include "cCavespider.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cCavespider::cCavespider() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = AGGRESSIVE;
+ m_bPassiveAggressive = true;
+ //m_AttackRate = 1;
+ m_MobType = 59;
+ GetMonsterConfig("Cavespider");
+}
+
+cCavespider::~cCavespider()
+{
+}
+
+bool cCavespider::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cCavespider ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cCavespider" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cCavespider::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+ m_EMPersonality = (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) )? PASSIVE:AGGRESSIVE;
+}
+
+void cCavespider::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cCavespider::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cCavespider::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cCavespider::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cCavespider::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cCavespider.h b/source/cCavespider.h
new file mode 100644
index 000000000..4709e3392
--- /dev/null
+++ b/source/cCavespider.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cCavespider : public cMonster
+{
+public:
+ cCavespider();
+ ~cCavespider();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cCow.cpp b/source/cCow.cpp
new file mode 100644
index 000000000..3f6286dec
--- /dev/null
+++ b/source/cCow.cpp
@@ -0,0 +1,90 @@
+#include "cCow.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+#include <string>
+
+
+
+cCow::cCow()
+ : m_ChaseTime( 999999 )
+
+{
+ //LOG("SPAWNING A Cow!!!!!!!!!!!!!!!!!!!!!");
+ m_EMPersonality = PASSIVE;
+ m_MobType = 92;
+ GetMonsterConfig("Cow");
+}
+
+cCow::~cCow()
+{
+}
+
+bool cCow::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cCow ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cCow" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cCow::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+}
+
+void cCow::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cCow::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cCow::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cCow::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
diff --git a/source/cCow.h b/source/cCow.h
new file mode 100644
index 000000000..512bb3ed3
--- /dev/null
+++ b/source/cCow.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cCow : public cMonster
+{
+public:
+ cCow();
+ ~cCow();
+
+ virtual bool IsA( const char* a_EntityType );
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cCreeper.cpp b/source/cCreeper.cpp
new file mode 100644
index 000000000..ffebc2c58
--- /dev/null
+++ b/source/cCreeper.cpp
@@ -0,0 +1,91 @@
+#include "cCreeper.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cCreeper::cCreeper() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = AGGRESSIVE;
+ m_bPassiveAggressive = true;
+ //m_AttackRate = 1;
+ m_MobType = 50;
+ GetMonsterConfig("Creeper");
+}
+
+cCreeper::~cCreeper()
+{
+}
+
+bool cCreeper::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cCreeper ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cCreeper" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cCreeper::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+}
+
+void cCreeper::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cCreeper::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cCreeper::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cCreeper::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cCreeper::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cCreeper.h b/source/cCreeper.h
new file mode 100644
index 000000000..66dfac2e8
--- /dev/null
+++ b/source/cCreeper.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cCreeper : public cMonster
+{
+public:
+ cCreeper();
+ ~cCreeper();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cEnderman.cpp b/source/cEnderman.cpp
new file mode 100644
index 000000000..42a57a613
--- /dev/null
+++ b/source/cEnderman.cpp
@@ -0,0 +1,94 @@
+#include "cEnderman.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cEnderman::cEnderman() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = PASSIVE;
+ m_bPassiveAggressive = true;
+ //m_AttackRate = 1;
+ m_MobType = 58;
+ GetMonsterConfig("Enderman");
+}
+
+cEnderman::~cEnderman()
+{
+}
+
+bool cEnderman::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cEnderman ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cEnderman" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cEnderman::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+ if (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
+ m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
+ }
+}
+
+void cEnderman::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cEnderman::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cEnderman::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cEnderman::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cEnderman::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cEnderman.h b/source/cEnderman.h
new file mode 100644
index 000000000..56d3f87bd
--- /dev/null
+++ b/source/cEnderman.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cEnderman : public cMonster
+{
+public:
+ cEnderman();
+ ~cEnderman();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cGhast.cpp b/source/cGhast.cpp
new file mode 100644
index 000000000..54c89a279
--- /dev/null
+++ b/source/cGhast.cpp
@@ -0,0 +1,91 @@
+#include "cGhast.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cGhast::cGhast() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = AGGRESSIVE;
+ m_bPassiveAggressive = true;
+ //m_AttackRate = 1;
+ m_MobType = 56;
+ GetMonsterConfig("Ghast");
+}
+
+cGhast::~cGhast()
+{
+}
+
+bool cGhast::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cGhast ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cGhast" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cGhast::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+}
+
+void cGhast::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cGhast::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cGhast::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cGhast::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cGhast::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cGhast.h b/source/cGhast.h
new file mode 100644
index 000000000..c35e0ec19
--- /dev/null
+++ b/source/cGhast.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cGhast : public cMonster
+{
+public:
+ cGhast();
+ ~cGhast();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cPig.cpp b/source/cPig.cpp
new file mode 100644
index 000000000..fa86949ab
--- /dev/null
+++ b/source/cPig.cpp
@@ -0,0 +1,90 @@
+#include "cPig.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+#include <string>
+
+
+
+cPig::cPig()
+ : m_ChaseTime( 999999 )
+
+{
+ //LOG("SPAWNING A Pig!!!!!!!!!!!!!!!!!!!!!");
+ m_EMPersonality = PASSIVE;
+ m_MobType = 90;
+ GetMonsterConfig("Pig");
+}
+
+cPig::~cPig()
+{
+}
+
+bool cPig::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cPig ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cPig" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cPig::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+}
+
+void cPig::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cPig::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cPig::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cPig::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
diff --git a/source/cPig.h b/source/cPig.h
new file mode 100644
index 000000000..7bc958ed0
--- /dev/null
+++ b/source/cPig.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cPig : public cMonster
+{
+public:
+ cPig();
+ ~cPig();
+
+ virtual bool IsA( const char* a_EntityType );
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cSheep.cpp b/source/cSheep.cpp
new file mode 100644
index 000000000..98d17e4d4
--- /dev/null
+++ b/source/cSheep.cpp
@@ -0,0 +1,90 @@
+#include "cSheep.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+#include <string>
+
+
+
+cSheep::cSheep()
+ : m_ChaseTime( 999999 )
+
+{
+ //LOG("SPAWNING A Sheep!!!!!!!!!!!!!!!!!!!!!");
+ m_EMPersonality = PASSIVE;
+ m_MobType = 91;
+ GetMonsterConfig("Sheep");
+}
+
+cSheep::~cSheep()
+{
+}
+
+bool cSheep::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cSheep ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cSheep" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cSheep::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+}
+
+void cSheep::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cSheep::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cSheep::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cSheep::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
diff --git a/source/cSheep.h b/source/cSheep.h
new file mode 100644
index 000000000..948df55f4
--- /dev/null
+++ b/source/cSheep.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cSheep : public cMonster
+{
+public:
+ cSheep();
+ ~cSheep();
+
+ virtual bool IsA( const char* a_EntityType );
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cSilverfish.cpp b/source/cSilverfish.cpp
new file mode 100644
index 000000000..25a3befa6
--- /dev/null
+++ b/source/cSilverfish.cpp
@@ -0,0 +1,91 @@
+#include "cSilverfish.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cSilverfish::cSilverfish() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = AGGRESSIVE;
+ m_bPassiveAggressive = true;
+ //m_AttackRate = 1;
+ m_MobType = 60;
+ GetMonsterConfig("Silverfish");
+}
+
+cSilverfish::~cSilverfish()
+{
+}
+
+bool cSilverfish::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cSilverfish ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cSilverfish" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cSilverfish::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+}
+
+void cSilverfish::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cSilverfish::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cSilverfish::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cSilverfish::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cSilverfish::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cSilverfish.h b/source/cSilverfish.h
new file mode 100644
index 000000000..471a0274d
--- /dev/null
+++ b/source/cSilverfish.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cSilverfish : public cMonster
+{
+public:
+ cSilverfish();
+ ~cSilverfish();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cSkeleton.cpp b/source/cSkeleton.cpp
new file mode 100644
index 000000000..84de27d7a
--- /dev/null
+++ b/source/cSkeleton.cpp
@@ -0,0 +1,94 @@
+#include "cSkeleton.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cSkeleton::cSkeleton() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = AGGRESSIVE;
+ m_bPassiveAggressive = false;
+ //m_AttackRate = 1;
+ m_MobType = 51;
+ GetMonsterConfig("Skeleton");
+}
+
+cSkeleton::~cSkeleton()
+{
+}
+
+bool cSkeleton::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cSkeleton ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cSkeleton" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cSkeleton::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+ if (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
+ m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
+ }
+}
+
+void cSkeleton::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cSkeleton::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cSkeleton::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cSkeleton::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cSkeleton::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cSkeleton.h b/source/cSkeleton.h
new file mode 100644
index 000000000..f30ef23c4
--- /dev/null
+++ b/source/cSkeleton.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cSkeleton : public cMonster
+{
+public:
+ cSkeleton();
+ ~cSkeleton();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cSlime.cpp b/source/cSlime.cpp
new file mode 100644
index 000000000..c568ac78c
--- /dev/null
+++ b/source/cSlime.cpp
@@ -0,0 +1,91 @@
+#include "cSlime.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cSlime::cSlime() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = AGGRESSIVE;
+ m_bPassiveAggressive = true;
+ //m_AttackRate = 1;
+ m_MobType = 55;
+ GetMonsterConfig("Slime");
+}
+
+cSlime::~cSlime()
+{
+}
+
+bool cSlime::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cSlime ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cSlime" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cSlime::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+}
+
+void cSlime::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cSlime::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cSlime::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cSlime::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cSlime::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cSlime.h b/source/cSlime.h
new file mode 100644
index 000000000..5f492ebe6
--- /dev/null
+++ b/source/cSlime.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cSlime : public cMonster
+{
+public:
+ cSlime();
+ ~cSlime();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cSquid.cpp b/source/cSquid.cpp
new file mode 100644
index 000000000..e528e7e95
--- /dev/null
+++ b/source/cSquid.cpp
@@ -0,0 +1,90 @@
+#include "cSquid.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+#include <string>
+
+
+
+cSquid::cSquid()
+ : m_ChaseTime( 999999 )
+
+{
+ //LOG("SPAWNING A Squid!!!!!!!!!!!!!!!!!!!!!");
+ m_EMPersonality = PASSIVE;
+ m_MobType = 94;
+ GetMonsterConfig("Squid");
+}
+
+cSquid::~cSquid()
+{
+}
+
+bool cSquid::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cSquid ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cSquid" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cSquid::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+}
+
+void cSquid::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cSquid::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cSquid::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cSquid::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
diff --git a/source/cSquid.h b/source/cSquid.h
new file mode 100644
index 000000000..429bd50ac
--- /dev/null
+++ b/source/cSquid.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cSquid : public cMonster
+{
+public:
+ cSquid();
+ ~cSquid();
+
+ virtual bool IsA( const char* a_EntityType );
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cWolf.cpp b/source/cWolf.cpp
new file mode 100644
index 000000000..5a2c14f83
--- /dev/null
+++ b/source/cWolf.cpp
@@ -0,0 +1,91 @@
+#include "cWolf.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cWolf::cWolf() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = PASSIVE;
+ m_bPassiveAggressive = true;
+ //m_AttackRate = 1;
+ m_MobType = 95;
+ GetMonsterConfig("Wolf");
+}
+
+cWolf::~cWolf()
+{
+}
+
+bool cWolf::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cWolf ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cWolf" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cWolf::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+}
+
+void cWolf::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cWolf::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cWolf::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cWolf::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cWolf::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cWolf.h b/source/cWolf.h
new file mode 100644
index 000000000..5cb30700b
--- /dev/null
+++ b/source/cWolf.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cWolf : public cMonster
+{
+public:
+ cWolf();
+ ~cWolf();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
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 );
diff --git a/source/cZombie.cpp b/source/cZombie.cpp
new file mode 100644
index 000000000..23953f274
--- /dev/null
+++ b/source/cZombie.cpp
@@ -0,0 +1,94 @@
+#include "cZombie.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cZombie::cZombie() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = AGGRESSIVE;
+ m_bPassiveAggressive = false;
+ //m_AttackRate = 1;
+ m_MobType = 54;
+ GetMonsterConfig("Zombie");
+}
+
+cZombie::~cZombie()
+{
+}
+
+bool cZombie::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cZombie ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cZombie" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cZombie::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+ if (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
+ m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
+ }
+}
+
+void cZombie::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cZombie::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cZombie::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cZombie::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cZombie::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cZombie.h b/source/cZombie.h
new file mode 100644
index 000000000..fdc628822
--- /dev/null
+++ b/source/cZombie.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cZombie : public cMonster
+{
+public:
+ cZombie();
+ ~cZombie();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cZombiepigman.cpp b/source/cZombiepigman.cpp
new file mode 100644
index 000000000..5ace226af
--- /dev/null
+++ b/source/cZombiepigman.cpp
@@ -0,0 +1,94 @@
+#include "cZombiepigman.h"
+
+#include "Vector3f.h"
+#include "Vector3d.h"
+
+#include "Defines.h"
+
+#include "cRoot.h"
+#include "cWorld.h"
+#include "cPickup.h"
+#include "cItem.h"
+#include "cMonsterConfig.h"
+
+#include "cMCLogger.h"
+
+#ifndef _WIN32
+#include <stdlib.h> // rand()
+#include <cstring>
+#endif
+
+cZombiepigman::cZombiepigman() : m_ChaseTime(999999) {
+ m_bBurnable = true;
+ m_EMPersonality = PASSIVE;
+ m_bPassiveAggressive = true;
+ //m_AttackRate = 1;
+ m_MobType = 57;
+ GetMonsterConfig("Zombiepigman");
+}
+
+cZombiepigman::~cZombiepigman()
+{
+}
+
+bool cZombiepigman::IsA( const char* a_EntityType )
+{
+ //LOG("IsA( cZombiepigman ) : %s", a_EntityType);
+ if( strcmp( a_EntityType, "cZombiepigman" ) == 0 ) return true;
+ return cMonster::IsA( a_EntityType );
+}
+
+void cZombiepigman::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+ if (cRoot::Get()->GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
+ m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
+ }
+}
+
+void cZombiepigman::KilledBy( cEntity* a_Killer )
+{
+ if( (rand() % 5) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
+ Pickup->Initialize();
+ }
+ if( (rand() % 1) == 0 )
+ {
+ cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
+ Pickup->Initialize();
+ }
+ cMonster::KilledBy( a_Killer );
+}
+
+//What to do if in Idle State
+void cZombiepigman::InStateIdle(float a_Dt) {
+ cMonster::InStateIdle(a_Dt);
+}
+
+//What to do if in Chasing State
+void cZombiepigman::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ Vector3f Pos = Vector3f( m_Pos );
+ Vector3f Their = Vector3f( m_Target->GetPosition() );
+ if( (Their - Pos).Length() <= m_AttackRange) {
+ cMonster::Attack(a_Dt);
+ }
+ MoveToPosition( Their + Vector3f(0, 0.65f, 0) );
+ } else if( m_ChaseTime > 5.f ) {
+ m_ChaseTime = 0;
+ m_EMState = IDLE;
+ }
+}
+
+void cZombiepigman::InStateEscaping(float a_Dt) {
+ cMonster::InStateEscaping(a_Dt);
+}
+
+void cZombiepigman::GetMonsterConfig(const char* pm_name) {
+ LOG("I am gettin my attributes: %s", pm_name);
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this,pm_name);
+}
diff --git a/source/cZombiepigman.h b/source/cZombiepigman.h
new file mode 100644
index 000000000..45c588dcd
--- /dev/null
+++ b/source/cZombiepigman.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cZombiepigman : public cMonster
+{
+public:
+ cZombiepigman();
+ ~cZombiepigman();
+
+ virtual bool IsA( const char* a_EntityType );
+ virtual void GetMonsterConfig(const char* pm_name);
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
+ virtual void InStateIdle(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+ virtual void InStateEscaping(float a_Dt);
+ //float m_ChaseTime;
+protected:
+ float m_ChaseTime;
+};