summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/cAggressiveMonster.cpp73
-rw-r--r--source/cAggressiveMonster.h17
-rw-r--r--source/cCavespider.cpp60
-rw-r--r--source/cCavespider.h31
-rw-r--r--source/cChicken.cpp63
-rw-r--r--source/cChicken.h17
-rw-r--r--source/cCow.cpp56
-rw-r--r--source/cCow.h11
-rw-r--r--source/cCreeper.cpp66
-rw-r--r--source/cCreeper.h12
-rw-r--r--source/cEnderman.cpp60
-rw-r--r--source/cEnderman.h17
-rw-r--r--source/cGhast.cpp62
-rw-r--r--source/cGhast.h18
-rw-r--r--source/cMonster.cpp111
-rw-r--r--source/cMonster.h3
-rw-r--r--source/cPassiveAggressiveMonster.cpp32
-rw-r--r--source/cPassiveAggressiveMonster.h13
-rw-r--r--source/cPassiveMonster.cpp37
-rw-r--r--source/cPassiveMonster.h14
-rw-r--r--source/cPig.cpp58
-rw-r--r--source/cPig.h17
-rw-r--r--source/cSheep.cpp58
-rw-r--r--source/cSheep.h17
-rw-r--r--source/cSilverfish.cpp68
-rw-r--r--source/cSilverfish.h20
-rw-r--r--source/cSkeleton.cpp61
-rw-r--r--source/cSkeleton.h18
-rw-r--r--source/cSlime.cpp65
-rw-r--r--source/cSlime.h18
-rw-r--r--source/cSpider.cpp64
-rw-r--r--source/cSpider.h18
-rw-r--r--source/cSquid.cpp58
-rw-r--r--source/cSquid.h18
-rw-r--r--source/cWolf.cpp69
-rw-r--r--source/cWolf.h20
-rw-r--r--source/cZombie.cpp61
-rw-r--r--source/cZombie.h17
-rw-r--r--source/cZombiepigman.cpp67
-rw-r--r--source/cZombiepigman.h17
40 files changed, 347 insertions, 1235 deletions
diff --git a/source/cAggressiveMonster.cpp b/source/cAggressiveMonster.cpp
new file mode 100644
index 000000000..ff8dc72c1
--- /dev/null
+++ b/source/cAggressiveMonster.cpp
@@ -0,0 +1,73 @@
+#include "cAggressiveMonster.h"
+
+#include "Vector3f.h"
+#include "cPlayer.h"
+
+
+cAggressiveMonster::cAggressiveMonster()
+ : m_ChaseTime(999999)
+{
+ m_EMPersonality = AGGRESSIVE;
+}
+
+cAggressiveMonster::~cAggressiveMonster()
+{
+}
+
+//What to do if in Chasing State
+void cAggressiveMonster::InStateChasing(float a_Dt) {
+ cMonster::InStateChasing(a_Dt);
+ m_ChaseTime += a_Dt;
+ if( m_Target )
+ {
+ if(m_Target->GetEntityType() == cEntity::E_PLAYER)
+ {
+ cPlayer * Player = (cPlayer *) m_Target;
+ if(Player->GetGameMode() == 1)
+ {
+ m_EMState = IDLE;
+ return;
+ }
+ }
+
+ 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 cAggressiveMonster::EventSeePlayer(cEntity *a_Entity)
+{
+ cMonster::EventSeePlayer(a_Entity);
+ m_EMState = CHASING;
+}
+
+void cAggressiveMonster::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+
+ m_SeePlayerInterval += a_Dt;
+
+ if(m_SeePlayerInterval > 1)
+ {
+ int rem = rand() % 3 + 1; //check most of the time but miss occasionally
+
+ m_SeePlayerInterval = 0.0;
+ if(rem >= 2)
+ {
+ if(m_EMState == CHASING){
+ CheckEventLostPlayer();
+ } else {
+ CheckEventSeePlayer();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/source/cAggressiveMonster.h b/source/cAggressiveMonster.h
new file mode 100644
index 000000000..579e712ae
--- /dev/null
+++ b/source/cAggressiveMonster.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cAggressiveMonster : public cMonster
+{
+public:
+ cAggressiveMonster();
+ ~cAggressiveMonster();
+
+ virtual void Tick(float a_Dt);
+ virtual void InStateChasing(float a_Dt);
+
+ virtual void EventSeePlayer(cEntity *);
+protected:
+ float m_ChaseTime;
+};
diff --git a/source/cCavespider.cpp b/source/cCavespider.cpp
index dc0377edf..f31f229e3 100644
--- a/source/cCavespider.cpp
+++ b/source/cCavespider.cpp
@@ -1,28 +1,7 @@
#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;
+cCavespider::cCavespider()
+{
m_MobType = 59;
GetMonsterConfig("Cavespider");
}
@@ -33,7 +12,6 @@ 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 );
}
@@ -41,7 +19,7 @@ bool cCavespider::IsA( const char* a_EntityType )
void cCavespider::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
- m_EMPersonality = (GetWorld()->GetWorldTime() < (12000 + 1000) )? PASSIVE:AGGRESSIVE;
+ m_EMPersonality = (GetWorld()->GetWorldTime() < (12000 + 1000) ) ? PASSIVE : AGGRESSIVE;
}
void cCavespider::KilledBy( cEntity* a_Killer )
@@ -52,35 +30,3 @@ void cCavespider::KilledBy( cEntity* a_Killer )
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
index 4709e3392..0630351f0 100644
--- a/source/cCavespider.h
+++ b/source/cCavespider.h
@@ -1,22 +1,15 @@
-#pragma once
-
-#include "cMonster.h"
-
-class cCavespider : public cMonster
-{
-public:
- cCavespider();
+#pragma once
+
+#include "cAggressiveMonster.h"
+
+class cCavespider : public cAggressiveMonster
+{
+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;
+ virtual bool IsA( const char* a_EntityType );
+
+ virtual void Tick(float a_Dt);
+ virtual void KilledBy( cEntity* a_Killer );
};
diff --git a/source/cChicken.cpp b/source/cChicken.cpp
index be740d6cd..33d5d0755 100644
--- a/source/cChicken.cpp
+++ b/source/cChicken.cpp
@@ -1,34 +1,10 @@
#include "cChicken.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>
-
-
-// TODO: Drop egg every 5-10 minutes
+//TODO Drop egg every 5-10 minutes
cChicken::cChicken()
- : m_ChaseTime( 999999 )
-
{
- //LOG("SPAWNING A CHICKEN!!!!!!!!!!!!!!!!!!!!!");
- m_EMPersonality = PASSIVE;
m_MobType = 93;
GetMonsterConfig("Chicken");
}
@@ -39,16 +15,10 @@ cChicken::~cChicken()
bool cChicken::IsA( const char* a_EntityType )
{
- //LOG("IsA( cChicken ) : %s", a_EntityType);
if( strcmp( a_EntityType, "cChicken" ) == 0 ) return true;
return cMonster::IsA( a_EntityType );
}
-void cChicken::Tick(float a_Dt)
-{
- cMonster::Tick(a_Dt);
-}
-
void cChicken::KilledBy( cEntity* a_Killer )
{
//Drops 0-2 Feathers
@@ -56,36 +26,7 @@ void cChicken::KilledBy( cEntity* a_Killer )
// Raw Chicken
// TODO: (Check wheather it is burning to drop cooked Chicken)
- //Drops 0-2 Lether
cMonster::DropItem(E_ITEM_RAW_CHICKEN, 1);
-
cMonster::KilledBy( a_Killer );
-}
-
-//What to do if in Idle State
-void cChicken::InStateIdle(float a_Dt) {
- cMonster::InStateIdle(a_Dt);
-}
-
-//What to do if in Chasing State
-void cChicken::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 cChicken::InStateEscaping(float a_Dt) {
- cMonster::InStateEscaping(a_Dt);
-}
+} \ No newline at end of file
diff --git a/source/cChicken.h b/source/cChicken.h
index 9da836587..1ad545828 100644
--- a/source/cChicken.h
+++ b/source/cChicken.h
@@ -1,21 +1,14 @@
#pragma once
-#include "cMonster.h"
+#include "cPassiveMonster.h"
-class cChicken : public cMonster
+class cChicken : public cPassiveMonster
{
public:
cChicken();
- ~cChicken();
-
+ ~cChicken();
+
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/cCow.cpp b/source/cCow.cpp
index 7ed21d504..3d20bf2d9 100644
--- a/source/cCow.cpp
+++ b/source/cCow.cpp
@@ -1,32 +1,9 @@
#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>
-
//TODO: Milk Cow
cCow::cCow()
- : m_ChaseTime( 999999 )
-
{
- //LOG("SPAWNING A Cow!!!!!!!!!!!!!!!!!!!!!");
- m_EMPersonality = PASSIVE;
m_MobType = 92;
GetMonsterConfig("Cow");
}
@@ -37,16 +14,10 @@ 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 )
{
//Drops 0-2 Lether
@@ -59,30 +30,3 @@ void cCow::KilledBy( cEntity* a_Killer )
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
index 512bb3ed3..83d67e1ad 100644
--- a/source/cCow.h
+++ b/source/cCow.h
@@ -1,8 +1,8 @@
#pragma once
-#include "cMonster.h"
+#include "cPassiveMonster.h"
-class cCow : public cMonster
+class cCow : public cPassiveMonster
{
public:
cCow();
@@ -10,12 +10,5 @@ public:
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
index e8410e142..02bcf0094 100644
--- a/source/cCreeper.cpp
+++ b/source/cCreeper.cpp
@@ -1,28 +1,7 @@
#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;
+cCreeper::cCreeper()
+{
m_MobType = 50;
GetMonsterConfig("Creeper");
}
@@ -33,53 +12,16 @@ 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 )
{
cMonster::RandomDropItem(E_ITEM_GUNPOWDER, 0, 2);
- //Todo: Check if killed by a skeleton then drop random music disk
+ //TODO Check if killed by a skeleton then drop random music disk
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);
-}
+} \ No newline at end of file
diff --git a/source/cCreeper.h b/source/cCreeper.h
index 66dfac2e8..4e8b4142e 100644
--- a/source/cCreeper.h
+++ b/source/cCreeper.h
@@ -1,22 +1,14 @@
#pragma once
-#include "cMonster.h"
+#include "cAggressiveMonster.h"
-class cCreeper : public cMonster
+class cCreeper : public cAggressiveMonster
{
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
index a64b3122b..c7c785a9f 100644
--- a/source/cEnderman.cpp
+++ b/source/cEnderman.cpp
@@ -1,28 +1,7 @@
#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;
+cEnderman::cEnderman()
+{
m_MobType = 58;
GetMonsterConfig("Enderman");
}
@@ -33,7 +12,6 @@ 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 );
}
@@ -41,6 +19,8 @@ bool cEnderman::IsA( const char* a_EntityType )
void cEnderman::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
+
+ //TODO Same as stated in cSkeleton
if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
}
@@ -53,35 +33,3 @@ void cEnderman::KilledBy( cEntity* a_Killer )
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
index 56d3f87bd..75b1b22a8 100644
--- a/source/cEnderman.h
+++ b/source/cEnderman.h
@@ -1,22 +1,15 @@
#pragma once
-#include "cMonster.h"
+#include "cPassiveAggressiveMonster.h"
-class cEnderman : public cMonster
+class cEnderman : public cPassiveAggressiveMonster
{
public:
cEnderman();
- ~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
index 78306095a..e08d6e29a 100644
--- a/source/cGhast.cpp
+++ b/source/cGhast.cpp
@@ -1,28 +1,7 @@
#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;
+cGhast::cGhast()
+{
m_MobType = 56;
GetMonsterConfig("Ghast");
}
@@ -33,16 +12,10 @@ 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 )
{
cMonster::RandomDropItem(E_ITEM_GUNPOWDER, 0, 2);
@@ -52,34 +25,3 @@ void cGhast::KilledBy( cEntity* a_Killer )
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
index c35e0ec19..c33d32df5 100644
--- a/source/cGhast.h
+++ b/source/cGhast.h
@@ -1,22 +1,14 @@
#pragma once
-#include "cMonster.h"
+#include "cAggressiveMonster.h"
-class cGhast : public cMonster
+class cGhast : public cAggressiveMonster
{
public:
cGhast();
- ~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/cMonster.cpp b/source/cMonster.cpp
index 7fec8fa5c..18afcf8b0 100644
--- a/source/cMonster.cpp
+++ b/source/cMonster.cpp
@@ -10,6 +10,7 @@
#include "Defines.h"
#include "cPickup.h"
#include "cItem.h"
+#include "cMonsterConfig.h"
#include "packets/cPacket_SpawnMob.h"
#include "packets/cPacket_EntityLook.h"
@@ -47,18 +48,17 @@ cMonster::cMonster()
, m_MobType( 0 )
, m_EMState(IDLE)
, m_SightDistance(25)
- ,m_SeePlayerInterval (0)
- ,m_EMPersonality(AGGRESSIVE)
- ,m_AttackDamage(1.0)
- ,m_AttackRange(5.0)
- ,m_AttackInterval(0)
- ,m_AttackRate(3)
- ,m_bPassiveAggressive(false)
- ,idle_interval(0)
- ,m_bBurnable(true)
- ,m_EMMetaState(NORMAL)
- ,m_FireDamageInterval(0)
- ,m_BurnPeriod(0)
+ , m_SeePlayerInterval (0)
+ , m_EMPersonality(AGGRESSIVE)
+ , m_AttackDamage(1.0)
+ , m_AttackRange(5.0)
+ , m_AttackInterval(0)
+ , m_AttackRate(3)
+ , idle_interval(0)
+ , m_bBurnable(true)
+ , m_EMMetaState(NORMAL)
+ , m_FireDamageInterval(0)
+ , m_BurnPeriod(0)
{
LOG("cMonster::cMonster()");
LOG("In state: %s",GetState());
@@ -77,7 +77,6 @@ cMonster::cMonster()
cMonster::~cMonster()
{
-
LOG("cMonster::~cMonster()");
delete m_Destination;
delete m_Speed;
@@ -85,7 +84,6 @@ cMonster::~cMonster()
bool cMonster::IsA( const char* a_EntityType )
{
- //LOG("IsA( cMonster ) : %s", a_EntityType);
if( strcmp( a_EntityType, "cMonster" ) == 0 ) return true;
return cPawn::IsA( a_EntityType );
}
@@ -102,7 +100,6 @@ void cMonster::SpawnOn( cClientHandle* a_Target )
Spawn.m_MetaDataSize = 1;
Spawn.m_MetaData = new char[Spawn.m_MetaDataSize];
Spawn.m_MetaData[0] = 0x7f; // not on fire/crouching/riding
- //Spawn.m_MetaData[1] = 0x7f; // terminator
if( a_Target == 0 )
{
cChunk* Chunk = GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
@@ -142,8 +139,7 @@ void cMonster::Tick(float a_Dt)
return;
}
- //a_Dt/=1000;
- a_Dt/=1000;
+ a_Dt /= 1000;
if( m_bMovingToDestination )
{
@@ -153,7 +149,7 @@ void cMonster::Tick(float a_Dt)
{
Distance.y = 0;
Distance.Normalize();
- Distance*=3;
+ Distance *= 3;
m_Speed->x = Distance.x;
m_Speed->z = Distance.z;
}
@@ -210,24 +206,6 @@ void cMonster::Tick(float a_Dt)
InStateEscaping(a_Dt);
}
- m_SeePlayerInterval += a_Dt;
- if(m_SeePlayerInterval > 1) {
- int rem = rand()%3 + 1; //check most of the time but miss occasionally
- //LOG("See Player Interval: %3.3f",m_SeePlayerInterval);
- m_SeePlayerInterval = 0.0;
- if(rem >= 2) {
- if(m_EMState == IDLE && m_EMPersonality != PASSIVE) {
- CheckEventSeePlayer();
- return;
- }
- if(m_EMState == CHASING || m_EMState == ESCAPING){
- CheckEventLostPlayer();
- return;
- }
- }
- }
-
-
}
void cMonster::ReplicateMovement()
@@ -284,6 +262,8 @@ void cMonster::ReplicateMovement()
m_LastPosZ = GetPosZ();
m_bDirtyPosition = false;
}
+
+ MoveToCorrectChunk();
}
void cMonster::HandlePhysics(float a_Dt)
@@ -350,20 +330,11 @@ void cMonster::HandlePhysics(float a_Dt)
}
}
-void cMonster::TakeDamage( int a_Damage, cEntity* a_Instigator )
+void cMonster::TakeDamage(int a_Damage, cEntity* a_Instigator)
{
cPawn::TakeDamage( a_Damage, a_Instigator );
- m_Target = a_Instigator;
- AddReference( m_Target );
- if(m_EMPersonality == AGGRESSIVE) {
- m_EMState = CHASING;
- }
- if(m_EMPersonality == COWARDLY || m_EMPersonality == PASSIVE) {
- //m_bPassiveAggressive can be set so if the monster based on time of day for example
- //so the monster will only attack if provoked
- m_EMState = (m_bPassiveAggressive)? CHASING : ESCAPING;
- }
- //LOG("Take damage");
+ m_Target = a_Instigator;
+ AddReference( m_Target );
}
void cMonster::KilledBy( cEntity* a_Killer )
@@ -392,7 +363,8 @@ const char *cMonster::GetState() {
}
//for debugging
-void cMonster::SetState(const char* a_str) {
+void cMonster::SetState(const char* a_str)
+{
std::string str = a_str;
if(str.compare("Idle") == 0 ) {
m_EMState = IDLE;
@@ -407,48 +379,38 @@ void cMonster::SetState(const char* a_str) {
//Checks to see if EventSeePlayer should be fired
//monster sez: Do I see the player
-void cMonster::CheckEventSeePlayer() {
-
- //LOG("Checking if I see any players");
+void cMonster::CheckEventSeePlayer()
+{
cMonster::ListClosePlayers(this);
-
}
-void cMonster::CheckEventLostPlayer() {
+void cMonster::CheckEventLostPlayer()
+{
Vector3f pos;
cTracer LineOfSight(GetWorld() );
- //LOG("Checking if I lost my enemy");
if(m_Target != 0) {
pos = m_Target->GetPosition();
- if((pos - *m_Pos).Length() > m_SightDistance || LineOfSight.Trace(*m_Pos,(pos - *m_Pos), (int)(pos - *m_Pos).Length())){
- //LOG("Losing Player: %5.5f",(pos - *m_Pos).Length());
+ if((pos - *m_Pos).Length() > m_SightDistance || LineOfSight.Trace(*m_Pos,(pos - *m_Pos), (int)(pos - *m_Pos).Length()))
+ {
EventLosePlayer();
}
} else {
- LOG("Enemy went poof");
EventLosePlayer();
}
}
//What to do if player is seen
//default to change state to chasing
-void cMonster::EventSeePlayer(cEntity *a_SeenPlayer) {
+void cMonster::EventSeePlayer(cEntity *a_SeenPlayer)
+{
m_Target = a_SeenPlayer;
AddReference( m_Target );
- if(m_EMPersonality == AGGRESSIVE) {
- m_EMState = CHASING;
- }
- if(m_EMPersonality == COWARDLY) {
- m_EMState = ESCAPING;
- }
- //LOG("Saw Player: %s",GetState());
}
void cMonster::EventLosePlayer(){
Dereference(m_Target);
m_Target = 0;
- //LOG("Lost Player");
m_EMState = IDLE;
}
@@ -495,7 +457,6 @@ void cMonster::InStateBurning(float a_Dt) {
cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
m_EMMetaState = NORMAL;
cPacket_Metadata md(NORMAL, GetUniqueID());
- //md.m_UniqueID = GetUniqueID();
InChunk->Broadcast(md);
m_BurnPeriod = 0;
@@ -527,9 +488,8 @@ void cMonster::InStateEscaping(float a_Dt) {
//Do attack here
//a_Dt is passed so we can set attack rate
void cMonster::Attack(float a_Dt) {
- m_AttackInterval += a_Dt*m_AttackRate;
+ m_AttackInterval += a_Dt * m_AttackRate;
if(m_Target != 0 && m_AttackInterval > 3.0) { //Setting this higher gives us more wiggle room for attackrate
- //LOG("ATTACK!");
m_AttackInterval = 0.0;
((cPawn *)m_Target)->TakeDamage((int)m_AttackDamage,this);
}
@@ -543,7 +503,6 @@ void cMonster::CheckMetaDataBurn() {
cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
if(!InChunk)
return;
- //printf("I should burn");
m_EMMetaState = BURNING;
cPacket_Metadata md(BURNING,GetUniqueID());
InChunk->Broadcast(md);
@@ -575,8 +534,8 @@ void cMonster::ListClosePlayers(cMonster *m) {
if((*itr)->GetEntityType() == cEntity::E_PLAYER){
Vector3f pos = (*itr)->GetPosition();
if((pos - *(m->m_Pos)).Length() <= m->m_SightDistance){
- if(!LineOfSight.Trace(*(m->m_Pos),(pos - *(m->m_Pos)),(int)(pos - *(m->m_Pos)).Length())){
- //LOG("I SEE PLAYER !!!!!!!!!!!!!!!!!");
+ if(!LineOfSight.Trace(*(m->m_Pos),(pos - *(m->m_Pos)),(int)(pos - *(m->m_Pos)).Length()))
+ {
m->EventSeePlayer(*itr);
return; //get the first one in sight later we can reiterate and check
//for the closest out of all that match and make it more realistic
@@ -585,8 +544,8 @@ void cMonster::ListClosePlayers(cMonster *m) {
}
}
- if(tries > 100) {
- //LOG("I Give Up");
+ if(tries > 100)
+ {
m->EventLosePlayer();
return;
}
@@ -594,7 +553,7 @@ void cMonster::ListClosePlayers(cMonster *m) {
}
void cMonster::GetMonsterConfig(const char* pm_name) {
- (void)pm_name;
+ cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this, pm_name);
}
void cMonster::SetAttackRate(int ar) {
diff --git a/source/cMonster.h b/source/cMonster.h
index 7ac8ef171..2b05c871d 100644
--- a/source/cMonster.h
+++ b/source/cMonster.h
@@ -1,5 +1,7 @@
#pragma once
#include "cPawn.h"
+#include "Defines.h"
+#include "cWorld.h"
#include "BlockID.h"
class Vector3f;
@@ -86,4 +88,5 @@ protected:
void DropItem(ENUM_ITEM_ID a_Item, unsigned int a_Count);
void RandomDropItem(ENUM_ITEM_ID a_Item, unsigned int a_Min, unsigned int a_Max);
+
}; //tolua_export
diff --git a/source/cPassiveAggressiveMonster.cpp b/source/cPassiveAggressiveMonster.cpp
new file mode 100644
index 000000000..e1a78ab36
--- /dev/null
+++ b/source/cPassiveAggressiveMonster.cpp
@@ -0,0 +1,32 @@
+#include "cPassiveAggressiveMonster.h"
+
+#include "cPlayer.h"
+
+
+cPassiveAggressiveMonster::cPassiveAggressiveMonster()
+{
+ m_EMPersonality = PASSIVE;
+}
+
+cPassiveAggressiveMonster::~cPassiveAggressiveMonster()
+{
+}
+
+void cPassiveAggressiveMonster::TakeDamage(int a_Damage, cEntity* a_Instigator)
+{
+ cMonster::TakeDamage(a_Damage, a_Instigator);
+ if(m_Target->GetEntityType() == cEntity::E_PLAYER)
+ {
+ cPlayer * Player = (cPlayer *) m_Target;
+ if(Player->GetGameMode() != 1)
+ {
+ m_EMState = CHASING;
+ }
+ }
+
+}
+
+void cPassiveAggressiveMonster::EventSeePlayer(cEntity *a_Entity)
+{
+ return cMonster::EventSeePlayer(a_Entity);
+} \ No newline at end of file
diff --git a/source/cPassiveAggressiveMonster.h b/source/cPassiveAggressiveMonster.h
new file mode 100644
index 000000000..0d1de9fd0
--- /dev/null
+++ b/source/cPassiveAggressiveMonster.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "cAggressiveMonster.h"
+
+class cPassiveAggressiveMonster : public cAggressiveMonster
+{
+public:
+ cPassiveAggressiveMonster();
+ ~cPassiveAggressiveMonster();
+
+ virtual void TakeDamage(int a_Damage, cEntity* a_Instigator);
+ void EventSeePlayer(cEntity *a_Entity);
+};
diff --git a/source/cPassiveMonster.cpp b/source/cPassiveMonster.cpp
new file mode 100644
index 000000000..bbfbc83ed
--- /dev/null
+++ b/source/cPassiveMonster.cpp
@@ -0,0 +1,37 @@
+#include "cPassiveMonster.h"
+
+
+cPassiveMonster::cPassiveMonster()
+{
+ m_EMPersonality = PASSIVE;
+}
+
+cPassiveMonster::~cPassiveMonster()
+{
+}
+
+void cPassiveMonster::TakeDamage(int a_Damage, cEntity* a_Instigator)
+{
+ cMonster::TakeDamage(a_Damage, a_Instigator);
+ m_EMState = ESCAPING;
+}
+
+void cPassiveMonster::Tick(float a_Dt)
+{
+ cMonster::Tick(a_Dt);
+
+ m_SeePlayerInterval += a_Dt;
+
+ if(m_SeePlayerInterval > 1)
+ {
+ int rem = rand() % 3 + 1; //check most of the time but miss occasionally
+
+ m_SeePlayerInterval = 0.0;
+ if(rem >= 2) {
+ if(m_EMState == ESCAPING)
+ {
+ CheckEventLostPlayer();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/source/cPassiveMonster.h b/source/cPassiveMonster.h
new file mode 100644
index 000000000..ba784b242
--- /dev/null
+++ b/source/cPassiveMonster.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "cMonster.h"
+
+class cPassiveMonster : public cMonster
+{
+public:
+ cPassiveMonster();
+ ~cPassiveMonster();
+
+ virtual void Tick(float a_Dt);
+
+ virtual void TakeDamage(int a_Damage, cEntity* a_Instigator);
+};
diff --git a/source/cPig.cpp b/source/cPig.cpp
index 926bd8df0..079b5f3e5 100644
--- a/source/cPig.cpp
+++ b/source/cPig.cpp
@@ -1,32 +1,9 @@
#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");
}
@@ -37,16 +14,10 @@ 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 )
{
//Drops 0-2 meat
@@ -55,31 +26,4 @@ void cPig::KilledBy( cEntity* a_Killer )
//TODO: Check for burning state
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);
-}
+} \ No newline at end of file
diff --git a/source/cPig.h b/source/cPig.h
index 7bc958ed0..32947c2c1 100644
--- a/source/cPig.h
+++ b/source/cPig.h
@@ -1,21 +1,14 @@
#pragma once
-#include "cMonster.h"
+#include "cPassiveMonster.h"
-class cPig : public cMonster
+class cPig : public cPassiveMonster
{
public:
cPig();
- ~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
index 8c82faa1f..6d2024d01 100644
--- a/source/cSheep.cpp
+++ b/source/cSheep.cpp
@@ -1,32 +1,9 @@
#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>
-
//Todo: Implement color
cSheep::cSheep()
- : m_ChaseTime( 999999 )
-
{
- //LOG("SPAWNING A Sheep!!!!!!!!!!!!!!!!!!!!!");
- m_EMPersonality = PASSIVE;
m_MobType = 91;
GetMonsterConfig("Sheep");
}
@@ -37,16 +14,10 @@ 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 )
{
//Todo: Check wheather it is sheared
@@ -55,31 +26,4 @@ void cSheep::KilledBy( cEntity* a_Killer )
cMonster::DropItem(E_ITEM_WHITE_CLOTH, 1);
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);
-}
+} \ No newline at end of file
diff --git a/source/cSheep.h b/source/cSheep.h
index 948df55f4..170ea93fc 100644
--- a/source/cSheep.h
+++ b/source/cSheep.h
@@ -1,21 +1,14 @@
#pragma once
-#include "cMonster.h"
+#include "cPassiveMonster.h"
-class cSheep : public cMonster
+class cSheep : public cPassiveMonster
{
public:
cSheep();
- ~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
index 6083e2756..a24c96468 100644
--- a/source/cSilverfish.cpp
+++ b/source/cSilverfish.cpp
@@ -1,28 +1,7 @@
#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;
+cSilverfish::cSilverfish()
+{
m_MobType = 60;
GetMonsterConfig("Silverfish");
}
@@ -33,50 +12,7 @@ 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 )
-{
-
- 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
index 471a0274d..0a949c7e3 100644
--- a/source/cSilverfish.h
+++ b/source/cSilverfish.h
@@ -1,22 +1,12 @@
#pragma once
-#include "cMonster.h"
+#include "cAggressiveMonster.h"
-class cSilverfish : public cMonster
+class cSilverfish : public cAggressiveMonster
{
public:
cSilverfish();
- ~cSilverfish();
-
- virtual bool IsA( const char* a_EntityType );
- virtual void GetMonsterConfig(const char* pm_name);
+ ~cSilverfish();
- 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;
-};
+ virtual bool IsA( const char* a_EntityType );
+};
diff --git a/source/cSkeleton.cpp b/source/cSkeleton.cpp
index 8958e0c44..ea1fd5a77 100644
--- a/source/cSkeleton.cpp
+++ b/source/cSkeleton.cpp
@@ -1,28 +1,7 @@
#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;
+cSkeleton::cSkeleton()
+{
m_MobType = 51;
GetMonsterConfig("Skeleton");
}
@@ -33,7 +12,6 @@ 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 );
}
@@ -41,6 +19,9 @@ bool cSkeleton::IsA( const char* a_EntityType )
void cSkeleton::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
+
+ //TODO Outsource
+ //TODO should do lightcheck, not daylight -> mobs in the dark donīt burn
if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
}
@@ -54,35 +35,3 @@ void cSkeleton::KilledBy( cEntity* a_Killer )
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
index f30ef23c4..ca7ed2fe3 100644
--- a/source/cSkeleton.h
+++ b/source/cSkeleton.h
@@ -1,22 +1,16 @@
#pragma once
-#include "cMonster.h"
+#include "cAggressiveMonster.h"
-class cSkeleton : public cMonster
+class cSkeleton : public cAggressiveMonster
{
public:
cSkeleton();
- ~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
index c2cf78061..27ecd050b 100644
--- a/source/cSlime.cpp
+++ b/source/cSlime.cpp
@@ -1,30 +1,9 @@
#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
-
//TODO Implement sized slimes
-cSlime::cSlime() : m_ChaseTime(999999) {
- m_bBurnable = true;
- m_EMPersonality = AGGRESSIVE;
- m_bPassiveAggressive = true;
- //m_AttackRate = 1;
+cSlime::cSlime()
+{
m_MobType = 55;
GetMonsterConfig("Slime");
}
@@ -35,52 +14,14 @@ 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 )
{
//TODO: only when tiny
cMonster::RandomDropItem(E_ITEM_SLIMEBALL, 0, 2);
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);
-}
+} \ No newline at end of file
diff --git a/source/cSlime.h b/source/cSlime.h
index 5f492ebe6..26953cc73 100644
--- a/source/cSlime.h
+++ b/source/cSlime.h
@@ -1,22 +1,14 @@
#pragma once
-#include "cMonster.h"
+#include "cAggressiveMonster.h"
-class cSlime : public cMonster
+class cSlime : public cAggressiveMonster
{
public:
cSlime();
- ~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/cSpider.cpp b/source/cSpider.cpp
index 5249df6d0..e05e85662 100644
--- a/source/cSpider.cpp
+++ b/source/cSpider.cpp
@@ -1,28 +1,7 @@
#include "cSpider.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
-
-cSpider::cSpider() : m_ChaseTime(999999) {
- m_bBurnable = true;
- m_EMPersonality = AGGRESSIVE;
- m_bPassiveAggressive = true;
- //m_AttackRate = 1;
+cSpider::cSpider()
+{
m_MobType = 52;
GetMonsterConfig("Spider");
}
@@ -33,17 +12,10 @@ cSpider::~cSpider()
bool cSpider::IsA( const char* a_EntityType )
{
- //LOG("IsA( cSpider ) : %s", a_EntityType);
if( strcmp( a_EntityType, "cSpider" ) == 0 ) return true;
return cMonster::IsA( a_EntityType );
}
-void cSpider::Tick(float a_Dt)
-{
- cMonster::Tick(a_Dt);
- m_EMPersonality = (GetWorld()->GetWorldTime() < (12000 + 1000) )? PASSIVE:AGGRESSIVE;
-}
-
void cSpider::KilledBy( cEntity* a_Killer )
{
cMonster::RandomDropItem(E_ITEM_STRING, 0, 2);
@@ -52,35 +24,3 @@ void cSpider::KilledBy( cEntity* a_Killer )
cMonster::KilledBy( a_Killer );
}
-
-//What to do if in Idle State
-void cSpider::InStateIdle(float a_Dt) {
- cMonster::InStateIdle(a_Dt);
-}
-
-//What to do if in Chasing State
-void cSpider::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 cSpider::InStateEscaping(float a_Dt) {
- cMonster::InStateEscaping(a_Dt);
-}
-
-void cSpider::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/cSpider.h b/source/cSpider.h
index 23600d330..7ffc818e4 100644
--- a/source/cSpider.h
+++ b/source/cSpider.h
@@ -1,22 +1,14 @@
#pragma once
-#include "cMonster.h"
+#include "cAggressiveMonster.h"
-class cSpider : public cMonster
+class cSpider : public cAggressiveMonster
{
public:
cSpider();
- ~cSpider();
-
+ ~cSpider();
+
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
index 97eba9808..b2baf462b 100644
--- a/source/cSquid.cpp
+++ b/source/cSquid.cpp
@@ -1,32 +1,7 @@
#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");
}
@@ -37,16 +12,10 @@ 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 )
{
//Drops 0-3 Ink Sacs
@@ -54,30 +23,3 @@ void cSquid::KilledBy( cEntity* a_Killer )
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
index 429bd50ac..277166517 100644
--- a/source/cSquid.h
+++ b/source/cSquid.h
@@ -1,21 +1,13 @@
#pragma once
-#include "cMonster.h"
+#include "cPassiveMonster.h"
-class cSquid : public cMonster
+class cSquid : public cPassiveMonster
{
public:
cSquid();
- ~cSquid();
-
- virtual bool IsA( const char* a_EntityType );
+ ~cSquid();
- virtual void Tick(float a_Dt);
+ virtual bool IsA( const char* a_EntityType );
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
index d317fe746..055c434ed 100644
--- a/source/cWolf.cpp
+++ b/source/cWolf.cpp
@@ -1,28 +1,7 @@
#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;
+cWolf::cWolf()
+{
m_MobType = 95;
GetMonsterConfig("Wolf");
}
@@ -33,50 +12,6 @@ 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 )
-{
-
- 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
index 5cb30700b..b3bca1e47 100644
--- a/source/cWolf.h
+++ b/source/cWolf.h
@@ -1,22 +1,12 @@
#pragma once
-#include "cMonster.h"
+#include "cPassiveAggressiveMonster.h"
-class cWolf : public cMonster
+class cWolf : public cPassiveAggressiveMonster
{
public:
cWolf();
- ~cWolf();
-
- virtual bool IsA( const char* a_EntityType );
- virtual void GetMonsterConfig(const char* pm_name);
+ ~cWolf();
- 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;
-};
+ virtual bool IsA( const char* a_EntityType );
+};
diff --git a/source/cZombie.cpp b/source/cZombie.cpp
index 5569b42ff..4530cc42f 100644
--- a/source/cZombie.cpp
+++ b/source/cZombie.cpp
@@ -1,28 +1,7 @@
#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;
+cZombie::cZombie()
+{
m_MobType = 54;
GetMonsterConfig("Zombie");
}
@@ -33,7 +12,6 @@ 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 );
}
@@ -41,6 +19,8 @@ bool cZombie::IsA( const char* a_EntityType )
void cZombie::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
+
+ //TODO Same as in cSkeleton :D
if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
}
@@ -50,38 +30,5 @@ void cZombie::KilledBy( cEntity* a_Killer )
{
cMonster::RandomDropItem(E_ITEM_ROTTEN_FLESH, 0, 2);
-
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
index fdc628822..b35ff8933 100644
--- a/source/cZombie.h
+++ b/source/cZombie.h
@@ -1,22 +1,15 @@
#pragma once
-#include "cMonster.h"
+#include "cAggressiveMonster.h"
-class cZombie : public cMonster
+class cZombie : public cAggressiveMonster
{
public:
cZombie();
- ~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
index 79b84a4a7..51e817a2b 100644
--- a/source/cZombiepigman.cpp
+++ b/source/cZombiepigman.cpp
@@ -1,28 +1,7 @@
#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;
+cZombiepigman::cZombiepigman()
+{
m_MobType = 57;
GetMonsterConfig("Zombiepigman");
}
@@ -33,7 +12,6 @@ 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 );
}
@@ -41,6 +19,8 @@ bool cZombiepigman::IsA( const char* a_EntityType )
void cZombiepigman::Tick(float a_Dt)
{
cMonster::Tick(a_Dt);
+
+ //TODO Same as noticed in cSkeleton AND Do they really burn? :D In the neather there is no sun :D
if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
}
@@ -48,43 +28,8 @@ void cZombiepigman::Tick(float a_Dt)
void cZombiepigman::KilledBy( cEntity* a_Killer )
{
- //Drops 0-1 Rottenflesh
- cMonster::RandomDropItem(E_ITEM_ROTTEN_FLESH, 0, 2);
-
- //Drops 0-1 gold nuggets
- cMonster::RandomDropItem(E_ITEM_GOLD_NUGGET, 0, 2);
+ cMonster::RandomDropItem(E_ITEM_ROTTEN_FLESH, 0, 1);
+ cMonster::RandomDropItem(E_ITEM_GOLD_NUGGET, 0, 1);
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
index 45c588dcd..1a102572b 100644
--- a/source/cZombiepigman.h
+++ b/source/cZombiepigman.h
@@ -1,22 +1,15 @@
#pragma once
-#include "cMonster.h"
+#include "cPassiveAggressiveMonster.h"
-class cZombiepigman : public cMonster
+class cZombiepigman : public cPassiveAggressiveMonster
{
public:
cZombiepigman();
- ~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;
-};
+};