git-svn-id: http://mc-server.googlecode.com/svn/trunk@10 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
625c30d8bd
commit
a26a0e3825
84
makefile
84
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
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
[Server]
|
||||
Port=25565
|
||||
Port=11111
|
||||
ServerID=-
|
||||
|
||||
[Plugins]
|
||||
|
92
source/cCavespider.cpp
Normal file
92
source/cCavespider.cpp
Normal file
@ -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);
|
||||
}
|
22
source/cCavespider.h
Normal file
22
source/cCavespider.h
Normal file
@ -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;
|
||||
};
|
90
source/cCow.cpp
Normal file
90
source/cCow.cpp
Normal file
@ -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);
|
||||
}
|
21
source/cCow.h
Normal file
21
source/cCow.h
Normal file
@ -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;
|
||||
};
|
91
source/cCreeper.cpp
Normal file
91
source/cCreeper.cpp
Normal file
@ -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);
|
||||
}
|
22
source/cCreeper.h
Normal file
22
source/cCreeper.h
Normal file
@ -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;
|
||||
};
|
94
source/cEnderman.cpp
Normal file
94
source/cEnderman.cpp
Normal file
@ -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);
|
||||
}
|
22
source/cEnderman.h
Normal file
22
source/cEnderman.h
Normal file
@ -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;
|
||||
};
|
91
source/cGhast.cpp
Normal file
91
source/cGhast.cpp
Normal file
@ -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);
|
||||
}
|
22
source/cGhast.h
Normal file
22
source/cGhast.h
Normal file
@ -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;
|
||||
};
|
90
source/cPig.cpp
Normal file
90
source/cPig.cpp
Normal file
@ -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);
|
||||
}
|
21
source/cPig.h
Normal file
21
source/cPig.h
Normal file
@ -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;
|
||||
};
|
90
source/cSheep.cpp
Normal file
90
source/cSheep.cpp
Normal file
@ -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);
|
||||
}
|
21
source/cSheep.h
Normal file
21
source/cSheep.h
Normal file
@ -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;
|
||||
};
|
91
source/cSilverfish.cpp
Normal file
91
source/cSilverfish.cpp
Normal file
@ -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);
|
||||
}
|
22
source/cSilverfish.h
Normal file
22
source/cSilverfish.h
Normal file
@ -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;
|
||||
};
|
94
source/cSkeleton.cpp
Normal file
94
source/cSkeleton.cpp
Normal file
@ -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);
|
||||
}
|
22
source/cSkeleton.h
Normal file
22
source/cSkeleton.h
Normal file
@ -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;
|
||||
};
|
91
source/cSlime.cpp
Normal file
91
source/cSlime.cpp
Normal file
@ -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);
|
||||
}
|
22
source/cSlime.h
Normal file
22
source/cSlime.h
Normal file
@ -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;
|
||||
};
|
90
source/cSquid.cpp
Normal file
90
source/cSquid.cpp
Normal file
@ -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);
|
||||
}
|
21
source/cSquid.h
Normal file
21
source/cSquid.h
Normal file
@ -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;
|
||||
};
|
91
source/cWolf.cpp
Normal file
91
source/cWolf.cpp
Normal file
@ -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);
|
||||
}
|
22
source/cWolf.h
Normal file
22
source/cWolf.h
Normal file
@ -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;
|
||||
};
|
@ -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 );
|
||||
|
94
source/cZombie.cpp
Normal file
94
source/cZombie.cpp
Normal file
@ -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);
|
||||
}
|
22
source/cZombie.h
Normal file
22
source/cZombie.h
Normal file
@ -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;
|
||||
};
|
94
source/cZombiepigman.cpp
Normal file
94
source/cZombiepigman.cpp
Normal file
@ -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);
|
||||
}
|
22
source/cZombiepigman.h
Normal file
22
source/cZombiepigman.h
Normal file
@ -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;
|
||||
};
|
Loading…
Reference in New Issue
Block a user