- Fixed Bug #99 -> Mobs no longer bother you in creative mode
- refactored many things in the Monster system git-svn-id: http://mc-server.googlecode.com/svn/trunk@112 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
adb4dbc904
commit
e8f230f24e
@ -214,6 +214,7 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\source\cAggressiveMonster.cpp" />
|
||||||
<ClCompile Include="..\Source\cAuthenticator.cpp" />
|
<ClCompile Include="..\Source\cAuthenticator.cpp" />
|
||||||
<ClCompile Include="..\source\cBlockingTCPLink.cpp" />
|
<ClCompile Include="..\source\cBlockingTCPLink.cpp" />
|
||||||
<ClCompile Include="..\source\cCavespider.cpp" />
|
<ClCompile Include="..\source\cCavespider.cpp" />
|
||||||
@ -246,6 +247,8 @@
|
|||||||
<ClCompile Include="..\Source\cMonster.cpp" />
|
<ClCompile Include="..\Source\cMonster.cpp" />
|
||||||
<ClCompile Include="..\source\cMonsterConfig.cpp" />
|
<ClCompile Include="..\source\cMonsterConfig.cpp" />
|
||||||
<ClCompile Include="..\source\cNoise.cpp" />
|
<ClCompile Include="..\source\cNoise.cpp" />
|
||||||
|
<ClCompile Include="..\source\cPassiveAggressiveMonster.cpp" />
|
||||||
|
<ClCompile Include="..\source\cPassiveMonster.cpp" />
|
||||||
<ClCompile Include="..\Source\cPawn.cpp" />
|
<ClCompile Include="..\Source\cPawn.cpp" />
|
||||||
<ClCompile Include="..\source\cPig.cpp" />
|
<ClCompile Include="..\source\cPig.cpp" />
|
||||||
<ClCompile Include="..\source\cPiston.cpp" />
|
<ClCompile Include="..\source\cPiston.cpp" />
|
||||||
@ -353,6 +356,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\Source\BlockID.h" />
|
<ClInclude Include="..\Source\BlockID.h" />
|
||||||
|
<ClInclude Include="..\source\cAggressiveMonster.h" />
|
||||||
<ClInclude Include="..\Source\cAuthenticator.h" />
|
<ClInclude Include="..\Source\cAuthenticator.h" />
|
||||||
<ClInclude Include="..\source\cBlockingTCPLink.h" />
|
<ClInclude Include="..\source\cBlockingTCPLink.h" />
|
||||||
<ClInclude Include="..\source\cCavespider.h" />
|
<ClInclude Include="..\source\cCavespider.h" />
|
||||||
@ -383,6 +387,8 @@
|
|||||||
<ClInclude Include="..\Source\cMonster.h" />
|
<ClInclude Include="..\Source\cMonster.h" />
|
||||||
<ClInclude Include="..\source\cMonsterConfig.h" />
|
<ClInclude Include="..\source\cMonsterConfig.h" />
|
||||||
<ClInclude Include="..\source\cNoise.h" />
|
<ClInclude Include="..\source\cNoise.h" />
|
||||||
|
<ClInclude Include="..\source\cPassiveAggressiveMonster.h" />
|
||||||
|
<ClInclude Include="..\source\cPassiveMonster.h" />
|
||||||
<ClInclude Include="..\Source\cPawn.h" />
|
<ClInclude Include="..\Source\cPawn.h" />
|
||||||
<ClInclude Include="..\source\cPig.h" />
|
<ClInclude Include="..\source\cPig.h" />
|
||||||
<ClInclude Include="..\source\cPiston.h" />
|
<ClInclude Include="..\source\cPiston.h" />
|
||||||
|
@ -406,6 +406,18 @@
|
|||||||
<Filter Include="cFluidSimulator\cLavaSimulator">
|
<Filter Include="cFluidSimulator\cLavaSimulator">
|
||||||
<UniqueIdentifier>{b0401fd9-4021-4ab7-bf61-c8de112b4196}</UniqueIdentifier>
|
<UniqueIdentifier>{b0401fd9-4021-4ab7-bf61-c8de112b4196}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="cEntity\cPawn\cMonster\Personalities">
|
||||||
|
<UniqueIdentifier>{b0f7c883-e2ca-4bba-89e3-c36656c3de39}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="cEntity\cPawn\cMonster\Personalities\Aggressive">
|
||||||
|
<UniqueIdentifier>{dd40c965-2dae-451b-8c78-8946b428a0b8}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="cEntity\cPawn\cMonster\Personalities\Passive">
|
||||||
|
<UniqueIdentifier>{be4ace95-e07a-4aca-ac63-912de68ba01d}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="cEntity\cPawn\cMonster\Personalities\PassiveAggressive">
|
||||||
|
<UniqueIdentifier>{71574b1c-a518-4a17-92c1-e3ea340f73bc}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\source\cServer.cpp">
|
<ClCompile Include="..\source\cServer.cpp">
|
||||||
@ -814,6 +826,15 @@
|
|||||||
<ClCompile Include="..\source\cFluidSimulator.cpp">
|
<ClCompile Include="..\source\cFluidSimulator.cpp">
|
||||||
<Filter>cFluidSimulator</Filter>
|
<Filter>cFluidSimulator</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\source\cAggressiveMonster.cpp">
|
||||||
|
<Filter>cEntity\cPawn\cMonster\Personalities\Aggressive</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\source\cPassiveAggressiveMonster.cpp">
|
||||||
|
<Filter>cEntity\cPawn\cMonster\Personalities\PassiveAggressive</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\source\cPassiveMonster.cpp">
|
||||||
|
<Filter>cEntity\cPawn\cMonster\Personalities\Passive</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\source\cServer.h">
|
<ClInclude Include="..\source\cServer.h">
|
||||||
@ -1257,6 +1278,15 @@
|
|||||||
<ClInclude Include="..\source\cFluidSimulator.h">
|
<ClInclude Include="..\source\cFluidSimulator.h">
|
||||||
<Filter>cFluidSimulator</Filter>
|
<Filter>cFluidSimulator</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\source\cAggressiveMonster.h">
|
||||||
|
<Filter>cEntity\cPawn\cMonster\Personalities\Aggressive</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\source\cPassiveAggressiveMonster.h">
|
||||||
|
<Filter>cEntity\cPawn\cMonster\Personalities\PassiveAggressive</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\source\cPassiveMonster.h">
|
||||||
|
<Filter>cEntity\cPawn\cMonster\Personalities\Passive</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\source\AllToLua.pkg">
|
<None Include="..\source\AllToLua.pkg">
|
||||||
|
73
source/cAggressiveMonster.cpp
Normal file
73
source/cAggressiveMonster.cpp
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
17
source/cAggressiveMonster.h
Normal file
17
source/cAggressiveMonster.h
Normal file
@ -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;
|
||||||
|
};
|
@ -1,28 +1,7 @@
|
|||||||
#include "cCavespider.h"
|
#include "cCavespider.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
cCavespider::cCavespider()
|
||||||
#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;
|
m_MobType = 59;
|
||||||
GetMonsterConfig("Cavespider");
|
GetMonsterConfig("Cavespider");
|
||||||
}
|
}
|
||||||
@ -33,7 +12,6 @@ cCavespider::~cCavespider()
|
|||||||
|
|
||||||
bool cCavespider::IsA( const char* a_EntityType )
|
bool cCavespider::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cCavespider ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cCavespider" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cCavespider" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
@ -52,35 +30,3 @@ void cCavespider::KilledBy( cEntity* a_Killer )
|
|||||||
|
|
||||||
cMonster::KilledBy( 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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cAggressiveMonster.h"
|
||||||
|
|
||||||
class cCavespider : public cMonster
|
class cCavespider : public cAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cCavespider();
|
cCavespider();
|
||||||
~cCavespider();
|
~cCavespider();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
virtual bool IsA( const char* a_EntityType );
|
||||||
virtual void GetMonsterConfig(const char* pm_name);
|
|
||||||
|
|
||||||
virtual void Tick(float a_Dt);
|
virtual void Tick(float a_Dt);
|
||||||
virtual void KilledBy( cEntity* a_Killer );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,34 +1,10 @@
|
|||||||
#include "cChicken.h"
|
#include "cChicken.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
//TODO Drop egg every 5-10 minutes
|
||||||
#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
|
|
||||||
|
|
||||||
|
|
||||||
cChicken::cChicken()
|
cChicken::cChicken()
|
||||||
: m_ChaseTime( 999999 )
|
|
||||||
|
|
||||||
{
|
{
|
||||||
//LOG("SPAWNING A CHICKEN!!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
m_EMPersonality = PASSIVE;
|
|
||||||
m_MobType = 93;
|
m_MobType = 93;
|
||||||
GetMonsterConfig("Chicken");
|
GetMonsterConfig("Chicken");
|
||||||
}
|
}
|
||||||
@ -39,16 +15,10 @@ cChicken::~cChicken()
|
|||||||
|
|
||||||
bool cChicken::IsA( const char* a_EntityType )
|
bool cChicken::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cChicken ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cChicken" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cChicken" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
|
|
||||||
void cChicken::Tick(float a_Dt)
|
|
||||||
{
|
|
||||||
cMonster::Tick(a_Dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cChicken::KilledBy( cEntity* a_Killer )
|
void cChicken::KilledBy( cEntity* a_Killer )
|
||||||
{
|
{
|
||||||
//Drops 0-2 Feathers
|
//Drops 0-2 Feathers
|
||||||
@ -56,36 +26,7 @@ void cChicken::KilledBy( cEntity* a_Killer )
|
|||||||
|
|
||||||
// Raw Chicken
|
// Raw Chicken
|
||||||
// TODO: (Check wheather it is burning to drop cooked Chicken)
|
// TODO: (Check wheather it is burning to drop cooked Chicken)
|
||||||
//Drops 0-2 Lether
|
|
||||||
cMonster::DropItem(E_ITEM_RAW_CHICKEN, 1);
|
cMonster::DropItem(E_ITEM_RAW_CHICKEN, 1);
|
||||||
|
|
||||||
|
|
||||||
cMonster::KilledBy( a_Killer );
|
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);
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cPassiveMonster.h"
|
||||||
|
|
||||||
class cChicken : public cMonster
|
class cChicken : public cPassiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cChicken();
|
cChicken();
|
||||||
@ -10,12 +10,5 @@ public:
|
|||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
virtual bool IsA( const char* a_EntityType );
|
||||||
|
|
||||||
virtual void Tick(float a_Dt);
|
|
||||||
virtual void KilledBy( cEntity* a_Killer );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,32 +1,9 @@
|
|||||||
#include "cCow.h"
|
#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
|
//TODO: Milk Cow
|
||||||
|
|
||||||
cCow::cCow()
|
cCow::cCow()
|
||||||
: m_ChaseTime( 999999 )
|
|
||||||
|
|
||||||
{
|
{
|
||||||
//LOG("SPAWNING A Cow!!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
m_EMPersonality = PASSIVE;
|
|
||||||
m_MobType = 92;
|
m_MobType = 92;
|
||||||
GetMonsterConfig("Cow");
|
GetMonsterConfig("Cow");
|
||||||
}
|
}
|
||||||
@ -37,16 +14,10 @@ cCow::~cCow()
|
|||||||
|
|
||||||
bool cCow::IsA( const char* a_EntityType )
|
bool cCow::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cCow ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cCow" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cCow" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
|
|
||||||
void cCow::Tick(float a_Dt)
|
|
||||||
{
|
|
||||||
cMonster::Tick(a_Dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cCow::KilledBy( cEntity* a_Killer )
|
void cCow::KilledBy( cEntity* a_Killer )
|
||||||
{
|
{
|
||||||
//Drops 0-2 Lether
|
//Drops 0-2 Lether
|
||||||
@ -59,30 +30,3 @@ void cCow::KilledBy( cEntity* a_Killer )
|
|||||||
|
|
||||||
cMonster::KilledBy( 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);
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cPassiveMonster.h"
|
||||||
|
|
||||||
class cCow : public cMonster
|
class cCow : public cPassiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cCow();
|
cCow();
|
||||||
@ -10,12 +10,5 @@ public:
|
|||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
virtual bool IsA( const char* a_EntityType );
|
||||||
|
|
||||||
virtual void Tick(float a_Dt);
|
|
||||||
virtual void KilledBy( cEntity* a_Killer );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
#include "cCreeper.h"
|
#include "cCreeper.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
cCreeper::cCreeper()
|
||||||
#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;
|
m_MobType = 50;
|
||||||
GetMonsterConfig("Creeper");
|
GetMonsterConfig("Creeper");
|
||||||
}
|
}
|
||||||
@ -33,53 +12,16 @@ cCreeper::~cCreeper()
|
|||||||
|
|
||||||
bool cCreeper::IsA( const char* a_EntityType )
|
bool cCreeper::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cCreeper ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cCreeper" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cCreeper" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
|
|
||||||
void cCreeper::Tick(float a_Dt)
|
|
||||||
{
|
|
||||||
cMonster::Tick(a_Dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cCreeper::KilledBy( cEntity* a_Killer )
|
void cCreeper::KilledBy( cEntity* a_Killer )
|
||||||
{
|
{
|
||||||
cMonster::RandomDropItem(E_ITEM_GUNPOWDER, 0, 2);
|
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 );
|
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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cAggressiveMonster.h"
|
||||||
|
|
||||||
class cCreeper : public cMonster
|
class cCreeper : public cAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cCreeper();
|
cCreeper();
|
||||||
~cCreeper();
|
~cCreeper();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
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 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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
#include "cEnderman.h"
|
#include "cEnderman.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
cEnderman::cEnderman()
|
||||||
#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;
|
m_MobType = 58;
|
||||||
GetMonsterConfig("Enderman");
|
GetMonsterConfig("Enderman");
|
||||||
}
|
}
|
||||||
@ -33,7 +12,6 @@ cEnderman::~cEnderman()
|
|||||||
|
|
||||||
bool cEnderman::IsA( const char* a_EntityType )
|
bool cEnderman::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cEnderman ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cEnderman" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cEnderman" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
@ -41,6 +19,8 @@ bool cEnderman::IsA( const char* a_EntityType )
|
|||||||
void cEnderman::Tick(float a_Dt)
|
void cEnderman::Tick(float a_Dt)
|
||||||
{
|
{
|
||||||
cMonster::Tick(a_Dt);
|
cMonster::Tick(a_Dt);
|
||||||
|
|
||||||
|
//TODO Same as stated in cSkeleton
|
||||||
if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
|
if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
|
||||||
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
|
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
|
||||||
}
|
}
|
||||||
@ -53,35 +33,3 @@ void cEnderman::KilledBy( cEntity* a_Killer )
|
|||||||
|
|
||||||
cMonster::KilledBy( 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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cPassiveAggressiveMonster.h"
|
||||||
|
|
||||||
class cEnderman : public cMonster
|
class cEnderman : public cPassiveAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cEnderman();
|
cEnderman();
|
||||||
~cEnderman();
|
~cEnderman();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
virtual bool IsA( const char* a_EntityType );
|
||||||
virtual void GetMonsterConfig(const char* pm_name);
|
|
||||||
|
|
||||||
virtual void Tick(float a_Dt);
|
virtual void Tick(float a_Dt);
|
||||||
virtual void KilledBy( cEntity* a_Killer );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
#include "cGhast.h"
|
#include "cGhast.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
cGhast::cGhast()
|
||||||
#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;
|
m_MobType = 56;
|
||||||
GetMonsterConfig("Ghast");
|
GetMonsterConfig("Ghast");
|
||||||
}
|
}
|
||||||
@ -33,16 +12,10 @@ cGhast::~cGhast()
|
|||||||
|
|
||||||
bool cGhast::IsA( const char* a_EntityType )
|
bool cGhast::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cGhast ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cGhast" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cGhast" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
|
|
||||||
void cGhast::Tick(float a_Dt)
|
|
||||||
{
|
|
||||||
cMonster::Tick(a_Dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cGhast::KilledBy( cEntity* a_Killer )
|
void cGhast::KilledBy( cEntity* a_Killer )
|
||||||
{
|
{
|
||||||
cMonster::RandomDropItem(E_ITEM_GUNPOWDER, 0, 2);
|
cMonster::RandomDropItem(E_ITEM_GUNPOWDER, 0, 2);
|
||||||
@ -52,34 +25,3 @@ void cGhast::KilledBy( cEntity* a_Killer )
|
|||||||
cMonster::KilledBy( 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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cAggressiveMonster.h"
|
||||||
|
|
||||||
class cGhast : public cMonster
|
class cGhast : public cAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cGhast();
|
cGhast();
|
||||||
~cGhast();
|
~cGhast();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
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 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;
|
|
||||||
};
|
};
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "Defines.h"
|
#include "Defines.h"
|
||||||
#include "cPickup.h"
|
#include "cPickup.h"
|
||||||
#include "cItem.h"
|
#include "cItem.h"
|
||||||
|
#include "cMonsterConfig.h"
|
||||||
|
|
||||||
#include "packets/cPacket_SpawnMob.h"
|
#include "packets/cPacket_SpawnMob.h"
|
||||||
#include "packets/cPacket_EntityLook.h"
|
#include "packets/cPacket_EntityLook.h"
|
||||||
@ -53,7 +54,6 @@ cMonster::cMonster()
|
|||||||
, m_AttackRange(5.0)
|
, m_AttackRange(5.0)
|
||||||
, m_AttackInterval(0)
|
, m_AttackInterval(0)
|
||||||
, m_AttackRate(3)
|
, m_AttackRate(3)
|
||||||
,m_bPassiveAggressive(false)
|
|
||||||
, idle_interval(0)
|
, idle_interval(0)
|
||||||
, m_bBurnable(true)
|
, m_bBurnable(true)
|
||||||
, m_EMMetaState(NORMAL)
|
, m_EMMetaState(NORMAL)
|
||||||
@ -77,7 +77,6 @@ cMonster::cMonster()
|
|||||||
|
|
||||||
cMonster::~cMonster()
|
cMonster::~cMonster()
|
||||||
{
|
{
|
||||||
|
|
||||||
LOG("cMonster::~cMonster()");
|
LOG("cMonster::~cMonster()");
|
||||||
delete m_Destination;
|
delete m_Destination;
|
||||||
delete m_Speed;
|
delete m_Speed;
|
||||||
@ -85,7 +84,6 @@ cMonster::~cMonster()
|
|||||||
|
|
||||||
bool cMonster::IsA( const char* a_EntityType )
|
bool cMonster::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cMonster ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cMonster" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cMonster" ) == 0 ) return true;
|
||||||
return cPawn::IsA( a_EntityType );
|
return cPawn::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
@ -102,7 +100,6 @@ void cMonster::SpawnOn( cClientHandle* a_Target )
|
|||||||
Spawn.m_MetaDataSize = 1;
|
Spawn.m_MetaDataSize = 1;
|
||||||
Spawn.m_MetaData = new char[Spawn.m_MetaDataSize];
|
Spawn.m_MetaData = new char[Spawn.m_MetaDataSize];
|
||||||
Spawn.m_MetaData[0] = 0x7f; // not on fire/crouching/riding
|
Spawn.m_MetaData[0] = 0x7f; // not on fire/crouching/riding
|
||||||
//Spawn.m_MetaData[1] = 0x7f; // terminator
|
|
||||||
if( a_Target == 0 )
|
if( a_Target == 0 )
|
||||||
{
|
{
|
||||||
cChunk* Chunk = GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
|
cChunk* Chunk = GetWorld()->GetChunk( m_ChunkX, m_ChunkY, m_ChunkZ );
|
||||||
@ -142,7 +139,6 @@ void cMonster::Tick(float a_Dt)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//a_Dt/=1000;
|
|
||||||
a_Dt /= 1000;
|
a_Dt /= 1000;
|
||||||
|
|
||||||
if( m_bMovingToDestination )
|
if( m_bMovingToDestination )
|
||||||
@ -210,24 +206,6 @@ void cMonster::Tick(float a_Dt)
|
|||||||
InStateEscaping(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()
|
void cMonster::ReplicateMovement()
|
||||||
@ -284,6 +262,8 @@ void cMonster::ReplicateMovement()
|
|||||||
m_LastPosZ = GetPosZ();
|
m_LastPosZ = GetPosZ();
|
||||||
m_bDirtyPosition = false;
|
m_bDirtyPosition = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MoveToCorrectChunk();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMonster::HandlePhysics(float a_Dt)
|
void cMonster::HandlePhysics(float a_Dt)
|
||||||
@ -355,15 +335,6 @@ void cMonster::TakeDamage( int a_Damage, cEntity* a_Instigator )
|
|||||||
cPawn::TakeDamage( a_Damage, a_Instigator );
|
cPawn::TakeDamage( a_Damage, a_Instigator );
|
||||||
m_Target = a_Instigator;
|
m_Target = a_Instigator;
|
||||||
AddReference( m_Target );
|
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMonster::KilledBy( cEntity* a_Killer )
|
void cMonster::KilledBy( cEntity* a_Killer )
|
||||||
@ -392,7 +363,8 @@ const char *cMonster::GetState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//for debugging
|
//for debugging
|
||||||
void cMonster::SetState(const char* a_str) {
|
void cMonster::SetState(const char* a_str)
|
||||||
|
{
|
||||||
std::string str = a_str;
|
std::string str = a_str;
|
||||||
if(str.compare("Idle") == 0 ) {
|
if(str.compare("Idle") == 0 ) {
|
||||||
m_EMState = IDLE;
|
m_EMState = IDLE;
|
||||||
@ -407,48 +379,38 @@ void cMonster::SetState(const char* a_str) {
|
|||||||
|
|
||||||
//Checks to see if EventSeePlayer should be fired
|
//Checks to see if EventSeePlayer should be fired
|
||||||
//monster sez: Do I see the player
|
//monster sez: Do I see the player
|
||||||
void cMonster::CheckEventSeePlayer() {
|
void cMonster::CheckEventSeePlayer()
|
||||||
|
{
|
||||||
//LOG("Checking if I see any players");
|
|
||||||
cMonster::ListClosePlayers(this);
|
cMonster::ListClosePlayers(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMonster::CheckEventLostPlayer() {
|
void cMonster::CheckEventLostPlayer()
|
||||||
|
{
|
||||||
Vector3f pos;
|
Vector3f pos;
|
||||||
cTracer LineOfSight(GetWorld() );
|
cTracer LineOfSight(GetWorld() );
|
||||||
|
|
||||||
//LOG("Checking if I lost my enemy");
|
|
||||||
if(m_Target != 0) {
|
if(m_Target != 0) {
|
||||||
pos = m_Target->GetPosition();
|
pos = m_Target->GetPosition();
|
||||||
if((pos - *m_Pos).Length() > m_SightDistance || LineOfSight.Trace(*m_Pos,(pos - *m_Pos), (int)(pos - *m_Pos).Length())){
|
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());
|
{
|
||||||
EventLosePlayer();
|
EventLosePlayer();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG("Enemy went poof");
|
|
||||||
EventLosePlayer();
|
EventLosePlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//What to do if player is seen
|
//What to do if player is seen
|
||||||
//default to change state to chasing
|
//default to change state to chasing
|
||||||
void cMonster::EventSeePlayer(cEntity *a_SeenPlayer) {
|
void cMonster::EventSeePlayer(cEntity *a_SeenPlayer)
|
||||||
|
{
|
||||||
m_Target = a_SeenPlayer;
|
m_Target = a_SeenPlayer;
|
||||||
AddReference( m_Target );
|
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(){
|
void cMonster::EventLosePlayer(){
|
||||||
Dereference(m_Target);
|
Dereference(m_Target);
|
||||||
m_Target = 0;
|
m_Target = 0;
|
||||||
//LOG("Lost Player");
|
|
||||||
m_EMState = IDLE;
|
m_EMState = IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +457,6 @@ void cMonster::InStateBurning(float a_Dt) {
|
|||||||
cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
|
cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
|
||||||
m_EMMetaState = NORMAL;
|
m_EMMetaState = NORMAL;
|
||||||
cPacket_Metadata md(NORMAL, GetUniqueID());
|
cPacket_Metadata md(NORMAL, GetUniqueID());
|
||||||
//md.m_UniqueID = GetUniqueID();
|
|
||||||
InChunk->Broadcast(md);
|
InChunk->Broadcast(md);
|
||||||
m_BurnPeriod = 0;
|
m_BurnPeriod = 0;
|
||||||
|
|
||||||
@ -529,7 +490,6 @@ void cMonster::InStateEscaping(float a_Dt) {
|
|||||||
void cMonster::Attack(float a_Dt) {
|
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
|
if(m_Target != 0 && m_AttackInterval > 3.0) { //Setting this higher gives us more wiggle room for attackrate
|
||||||
//LOG("ATTACK!");
|
|
||||||
m_AttackInterval = 0.0;
|
m_AttackInterval = 0.0;
|
||||||
((cPawn *)m_Target)->TakeDamage((int)m_AttackDamage,this);
|
((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 );
|
cChunk* InChunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
|
||||||
if(!InChunk)
|
if(!InChunk)
|
||||||
return;
|
return;
|
||||||
//printf("I should burn");
|
|
||||||
m_EMMetaState = BURNING;
|
m_EMMetaState = BURNING;
|
||||||
cPacket_Metadata md(BURNING,GetUniqueID());
|
cPacket_Metadata md(BURNING,GetUniqueID());
|
||||||
InChunk->Broadcast(md);
|
InChunk->Broadcast(md);
|
||||||
@ -575,8 +534,8 @@ void cMonster::ListClosePlayers(cMonster *m) {
|
|||||||
if((*itr)->GetEntityType() == cEntity::E_PLAYER){
|
if((*itr)->GetEntityType() == cEntity::E_PLAYER){
|
||||||
Vector3f pos = (*itr)->GetPosition();
|
Vector3f pos = (*itr)->GetPosition();
|
||||||
if((pos - *(m->m_Pos)).Length() <= m->m_SightDistance){
|
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())){
|
if(!LineOfSight.Trace(*(m->m_Pos),(pos - *(m->m_Pos)),(int)(pos - *(m->m_Pos)).Length()))
|
||||||
//LOG("I SEE PLAYER !!!!!!!!!!!!!!!!!");
|
{
|
||||||
m->EventSeePlayer(*itr);
|
m->EventSeePlayer(*itr);
|
||||||
return; //get the first one in sight later we can reiterate and check
|
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
|
//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) {
|
if(tries > 100)
|
||||||
//LOG("I Give Up");
|
{
|
||||||
m->EventLosePlayer();
|
m->EventLosePlayer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -594,7 +553,7 @@ void cMonster::ListClosePlayers(cMonster *m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cMonster::GetMonsterConfig(const char* pm_name) {
|
void cMonster::GetMonsterConfig(const char* pm_name) {
|
||||||
(void)pm_name;
|
cRoot::Get()->GetMonsterConfig()->Get()->AssignAttributes(this, pm_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cMonster::SetAttackRate(int ar) {
|
void cMonster::SetAttackRate(int ar) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "cPawn.h"
|
#include "cPawn.h"
|
||||||
|
#include "Defines.h"
|
||||||
|
#include "cWorld.h"
|
||||||
#include "BlockID.h"
|
#include "BlockID.h"
|
||||||
|
|
||||||
class Vector3f;
|
class Vector3f;
|
||||||
@ -86,4 +88,5 @@ protected:
|
|||||||
|
|
||||||
void DropItem(ENUM_ITEM_ID a_Item, unsigned int a_Count);
|
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);
|
void RandomDropItem(ENUM_ITEM_ID a_Item, unsigned int a_Min, unsigned int a_Max);
|
||||||
|
|
||||||
}; //tolua_export
|
}; //tolua_export
|
||||||
|
32
source/cPassiveAggressiveMonster.cpp
Normal file
32
source/cPassiveAggressiveMonster.cpp
Normal file
@ -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);
|
||||||
|
}
|
13
source/cPassiveAggressiveMonster.h
Normal file
13
source/cPassiveAggressiveMonster.h
Normal file
@ -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);
|
||||||
|
};
|
37
source/cPassiveMonster.cpp
Normal file
37
source/cPassiveMonster.cpp
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
source/cPassiveMonster.h
Normal file
14
source/cPassiveMonster.h
Normal file
@ -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);
|
||||||
|
};
|
@ -1,32 +1,9 @@
|
|||||||
#include "cPig.h"
|
#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()
|
cPig::cPig()
|
||||||
: m_ChaseTime( 999999 )
|
|
||||||
|
|
||||||
{
|
{
|
||||||
//LOG("SPAWNING A Pig!!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
m_EMPersonality = PASSIVE;
|
|
||||||
m_MobType = 90;
|
m_MobType = 90;
|
||||||
GetMonsterConfig("Pig");
|
GetMonsterConfig("Pig");
|
||||||
}
|
}
|
||||||
@ -37,16 +14,10 @@ cPig::~cPig()
|
|||||||
|
|
||||||
bool cPig::IsA( const char* a_EntityType )
|
bool cPig::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cPig ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cPig" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cPig" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
|
|
||||||
void cPig::Tick(float a_Dt)
|
|
||||||
{
|
|
||||||
cMonster::Tick(a_Dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cPig::KilledBy( cEntity* a_Killer )
|
void cPig::KilledBy( cEntity* a_Killer )
|
||||||
{
|
{
|
||||||
//Drops 0-2 meat
|
//Drops 0-2 meat
|
||||||
@ -56,30 +27,3 @@ void cPig::KilledBy( cEntity* a_Killer )
|
|||||||
|
|
||||||
cMonster::KilledBy( a_Killer );
|
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);
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cPassiveMonster.h"
|
||||||
|
|
||||||
class cPig : public cMonster
|
class cPig : public cPassiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cPig();
|
cPig();
|
||||||
@ -10,12 +10,5 @@ public:
|
|||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
virtual bool IsA( const char* a_EntityType );
|
||||||
|
|
||||||
virtual void Tick(float a_Dt);
|
|
||||||
virtual void KilledBy( cEntity* a_Killer );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,32 +1,9 @@
|
|||||||
#include "cSheep.h"
|
#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
|
//Todo: Implement color
|
||||||
|
|
||||||
cSheep::cSheep()
|
cSheep::cSheep()
|
||||||
: m_ChaseTime( 999999 )
|
|
||||||
|
|
||||||
{
|
{
|
||||||
//LOG("SPAWNING A Sheep!!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
m_EMPersonality = PASSIVE;
|
|
||||||
m_MobType = 91;
|
m_MobType = 91;
|
||||||
GetMonsterConfig("Sheep");
|
GetMonsterConfig("Sheep");
|
||||||
}
|
}
|
||||||
@ -37,16 +14,10 @@ cSheep::~cSheep()
|
|||||||
|
|
||||||
bool cSheep::IsA( const char* a_EntityType )
|
bool cSheep::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cSheep ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cSheep" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cSheep" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSheep::Tick(float a_Dt)
|
|
||||||
{
|
|
||||||
cMonster::Tick(a_Dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cSheep::KilledBy( cEntity* a_Killer )
|
void cSheep::KilledBy( cEntity* a_Killer )
|
||||||
{
|
{
|
||||||
//Todo: Check wheather it is sheared
|
//Todo: Check wheather it is sheared
|
||||||
@ -56,30 +27,3 @@ void cSheep::KilledBy( cEntity* a_Killer )
|
|||||||
|
|
||||||
cMonster::KilledBy( a_Killer );
|
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);
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cPassiveMonster.h"
|
||||||
|
|
||||||
class cSheep : public cMonster
|
class cSheep : public cPassiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cSheep();
|
cSheep();
|
||||||
@ -10,12 +10,5 @@ public:
|
|||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
virtual bool IsA( const char* a_EntityType );
|
||||||
|
|
||||||
virtual void Tick(float a_Dt);
|
|
||||||
virtual void KilledBy( cEntity* a_Killer );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
#include "cSilverfish.h"
|
#include "cSilverfish.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
cSilverfish::cSilverfish()
|
||||||
#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;
|
m_MobType = 60;
|
||||||
GetMonsterConfig("Silverfish");
|
GetMonsterConfig("Silverfish");
|
||||||
}
|
}
|
||||||
@ -33,50 +12,7 @@ cSilverfish::~cSilverfish()
|
|||||||
|
|
||||||
bool cSilverfish::IsA( const char* a_EntityType )
|
bool cSilverfish::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cSilverfish ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cSilverfish" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cSilverfish" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cAggressiveMonster.h"
|
||||||
|
|
||||||
class cSilverfish : public cMonster
|
class cSilverfish : public cAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cSilverfish();
|
cSilverfish();
|
||||||
~cSilverfish();
|
~cSilverfish();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
#include "cSkeleton.h"
|
#include "cSkeleton.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
cSkeleton::cSkeleton()
|
||||||
#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;
|
m_MobType = 51;
|
||||||
GetMonsterConfig("Skeleton");
|
GetMonsterConfig("Skeleton");
|
||||||
}
|
}
|
||||||
@ -33,7 +12,6 @@ cSkeleton::~cSkeleton()
|
|||||||
|
|
||||||
bool cSkeleton::IsA( const char* a_EntityType )
|
bool cSkeleton::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cSkeleton ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cSkeleton" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cSkeleton" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
@ -41,6 +19,9 @@ bool cSkeleton::IsA( const char* a_EntityType )
|
|||||||
void cSkeleton::Tick(float a_Dt)
|
void cSkeleton::Tick(float a_Dt)
|
||||||
{
|
{
|
||||||
cMonster::Tick(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
|
if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
|
||||||
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
|
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
|
||||||
}
|
}
|
||||||
@ -54,35 +35,3 @@ void cSkeleton::KilledBy( cEntity* a_Killer )
|
|||||||
|
|
||||||
cMonster::KilledBy( 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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cAggressiveMonster.h"
|
||||||
|
|
||||||
class cSkeleton : public cMonster
|
class cSkeleton : public cAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cSkeleton();
|
cSkeleton();
|
||||||
~cSkeleton();
|
~cSkeleton();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
virtual bool IsA( const char* a_EntityType );
|
||||||
virtual void GetMonsterConfig(const char* pm_name);
|
|
||||||
|
|
||||||
virtual void Tick(float a_Dt);
|
virtual void Tick(float a_Dt);
|
||||||
virtual void KilledBy( cEntity* a_Killer );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,30 +1,9 @@
|
|||||||
#include "cSlime.h"
|
#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
|
//TODO Implement sized slimes
|
||||||
|
|
||||||
cSlime::cSlime() : m_ChaseTime(999999) {
|
cSlime::cSlime()
|
||||||
m_bBurnable = true;
|
{
|
||||||
m_EMPersonality = AGGRESSIVE;
|
|
||||||
m_bPassiveAggressive = true;
|
|
||||||
//m_AttackRate = 1;
|
|
||||||
m_MobType = 55;
|
m_MobType = 55;
|
||||||
GetMonsterConfig("Slime");
|
GetMonsterConfig("Slime");
|
||||||
}
|
}
|
||||||
@ -35,16 +14,10 @@ cSlime::~cSlime()
|
|||||||
|
|
||||||
bool cSlime::IsA( const char* a_EntityType )
|
bool cSlime::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cSlime ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cSlime" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cSlime" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSlime::Tick(float a_Dt)
|
|
||||||
{
|
|
||||||
cMonster::Tick(a_Dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cSlime::KilledBy( cEntity* a_Killer )
|
void cSlime::KilledBy( cEntity* a_Killer )
|
||||||
{
|
{
|
||||||
//TODO: only when tiny
|
//TODO: only when tiny
|
||||||
@ -52,35 +25,3 @@ void cSlime::KilledBy( cEntity* a_Killer )
|
|||||||
|
|
||||||
cMonster::KilledBy( a_Killer );
|
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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cAggressiveMonster.h"
|
||||||
|
|
||||||
class cSlime : public cMonster
|
class cSlime : public cAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cSlime();
|
cSlime();
|
||||||
~cSlime();
|
~cSlime();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
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 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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
#include "cSpider.h"
|
#include "cSpider.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
cSpider::cSpider()
|
||||||
#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;
|
|
||||||
m_MobType = 52;
|
m_MobType = 52;
|
||||||
GetMonsterConfig("Spider");
|
GetMonsterConfig("Spider");
|
||||||
}
|
}
|
||||||
@ -33,17 +12,10 @@ cSpider::~cSpider()
|
|||||||
|
|
||||||
bool cSpider::IsA( const char* a_EntityType )
|
bool cSpider::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cSpider ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cSpider" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cSpider" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
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 )
|
void cSpider::KilledBy( cEntity* a_Killer )
|
||||||
{
|
{
|
||||||
cMonster::RandomDropItem(E_ITEM_STRING, 0, 2);
|
cMonster::RandomDropItem(E_ITEM_STRING, 0, 2);
|
||||||
@ -52,35 +24,3 @@ void cSpider::KilledBy( cEntity* a_Killer )
|
|||||||
|
|
||||||
cMonster::KilledBy( 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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cAggressiveMonster.h"
|
||||||
|
|
||||||
class cSpider : public cMonster
|
class cSpider : public cAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cSpider();
|
cSpider();
|
||||||
~cSpider();
|
~cSpider();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
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 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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,32 +1,7 @@
|
|||||||
#include "cSquid.h"
|
#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()
|
cSquid::cSquid()
|
||||||
: m_ChaseTime( 999999 )
|
|
||||||
|
|
||||||
{
|
{
|
||||||
//LOG("SPAWNING A Squid!!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
m_EMPersonality = PASSIVE;
|
|
||||||
m_MobType = 94;
|
m_MobType = 94;
|
||||||
GetMonsterConfig("Squid");
|
GetMonsterConfig("Squid");
|
||||||
}
|
}
|
||||||
@ -37,16 +12,10 @@ cSquid::~cSquid()
|
|||||||
|
|
||||||
bool cSquid::IsA( const char* a_EntityType )
|
bool cSquid::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cSquid ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cSquid" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cSquid" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
|
|
||||||
void cSquid::Tick(float a_Dt)
|
|
||||||
{
|
|
||||||
cMonster::Tick(a_Dt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cSquid::KilledBy( cEntity* a_Killer )
|
void cSquid::KilledBy( cEntity* a_Killer )
|
||||||
{
|
{
|
||||||
//Drops 0-3 Ink Sacs
|
//Drops 0-3 Ink Sacs
|
||||||
@ -54,30 +23,3 @@ void cSquid::KilledBy( cEntity* a_Killer )
|
|||||||
|
|
||||||
cMonster::KilledBy( 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);
|
|
||||||
}
|
|
||||||
|
@ -1,21 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cPassiveMonster.h"
|
||||||
|
|
||||||
class cSquid : public cMonster
|
class cSquid : public cPassiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cSquid();
|
cSquid();
|
||||||
~cSquid();
|
~cSquid();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
virtual bool IsA( const char* a_EntityType );
|
||||||
|
|
||||||
virtual void Tick(float a_Dt);
|
|
||||||
virtual void KilledBy( cEntity* a_Killer );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
#include "cWolf.h"
|
#include "cWolf.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
cWolf::cWolf()
|
||||||
#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;
|
m_MobType = 95;
|
||||||
GetMonsterConfig("Wolf");
|
GetMonsterConfig("Wolf");
|
||||||
}
|
}
|
||||||
@ -33,50 +12,6 @@ cWolf::~cWolf()
|
|||||||
|
|
||||||
bool cWolf::IsA( const char* a_EntityType )
|
bool cWolf::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cWolf ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cWolf" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cWolf" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cPassiveAggressiveMonster.h"
|
||||||
|
|
||||||
class cWolf : public cMonster
|
class cWolf : public cPassiveAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cWolf();
|
cWolf();
|
||||||
~cWolf();
|
~cWolf();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
#include "cZombie.h"
|
#include "cZombie.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
cZombie::cZombie()
|
||||||
#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;
|
m_MobType = 54;
|
||||||
GetMonsterConfig("Zombie");
|
GetMonsterConfig("Zombie");
|
||||||
}
|
}
|
||||||
@ -33,7 +12,6 @@ cZombie::~cZombie()
|
|||||||
|
|
||||||
bool cZombie::IsA( const char* a_EntityType )
|
bool cZombie::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cZombie ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cZombie" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cZombie" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
@ -41,6 +19,8 @@ bool cZombie::IsA( const char* a_EntityType )
|
|||||||
void cZombie::Tick(float a_Dt)
|
void cZombie::Tick(float a_Dt)
|
||||||
{
|
{
|
||||||
cMonster::Tick(a_Dt);
|
cMonster::Tick(a_Dt);
|
||||||
|
|
||||||
|
//TODO Same as in cSkeleton :D
|
||||||
if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
|
if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
|
||||||
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
|
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::RandomDropItem(E_ITEM_ROTTEN_FLESH, 0, 2);
|
||||||
|
|
||||||
|
|
||||||
cMonster::KilledBy( a_Killer );
|
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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cAggressiveMonster.h"
|
||||||
|
|
||||||
class cZombie : public cMonster
|
class cZombie : public cAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cZombie();
|
cZombie();
|
||||||
~cZombie();
|
~cZombie();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
virtual bool IsA( const char* a_EntityType );
|
||||||
virtual void GetMonsterConfig(const char* pm_name);
|
|
||||||
|
|
||||||
virtual void Tick(float a_Dt);
|
virtual void Tick(float a_Dt);
|
||||||
virtual void KilledBy( cEntity* a_Killer );
|
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;
|
|
||||||
};
|
};
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
#include "cZombiepigman.h"
|
#include "cZombiepigman.h"
|
||||||
|
|
||||||
#include "Vector3f.h"
|
cZombiepigman::cZombiepigman()
|
||||||
#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;
|
m_MobType = 57;
|
||||||
GetMonsterConfig("Zombiepigman");
|
GetMonsterConfig("Zombiepigman");
|
||||||
}
|
}
|
||||||
@ -33,7 +12,6 @@ cZombiepigman::~cZombiepigman()
|
|||||||
|
|
||||||
bool cZombiepigman::IsA( const char* a_EntityType )
|
bool cZombiepigman::IsA( const char* a_EntityType )
|
||||||
{
|
{
|
||||||
//LOG("IsA( cZombiepigman ) : %s", a_EntityType);
|
|
||||||
if( strcmp( a_EntityType, "cZombiepigman" ) == 0 ) return true;
|
if( strcmp( a_EntityType, "cZombiepigman" ) == 0 ) return true;
|
||||||
return cMonster::IsA( a_EntityType );
|
return cMonster::IsA( a_EntityType );
|
||||||
}
|
}
|
||||||
@ -41,6 +19,8 @@ bool cZombiepigman::IsA( const char* a_EntityType )
|
|||||||
void cZombiepigman::Tick(float a_Dt)
|
void cZombiepigman::Tick(float a_Dt)
|
||||||
{
|
{
|
||||||
cMonster::Tick(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
|
if (GetWorld()->GetWorldTime() < (12000 + 1000) ) { //if daylight
|
||||||
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
|
m_EMMetaState = BURNING; // BURN, BABY, BURN! >:D
|
||||||
}
|
}
|
||||||
@ -48,43 +28,8 @@ void cZombiepigman::Tick(float a_Dt)
|
|||||||
|
|
||||||
void cZombiepigman::KilledBy( cEntity* a_Killer )
|
void cZombiepigman::KilledBy( cEntity* a_Killer )
|
||||||
{
|
{
|
||||||
//Drops 0-1 Rottenflesh
|
cMonster::RandomDropItem(E_ITEM_ROTTEN_FLESH, 0, 1);
|
||||||
cMonster::RandomDropItem(E_ITEM_ROTTEN_FLESH, 0, 2);
|
cMonster::RandomDropItem(E_ITEM_GOLD_NUGGET, 0, 1);
|
||||||
|
|
||||||
//Drops 0-1 gold nuggets
|
|
||||||
cMonster::RandomDropItem(E_ITEM_GOLD_NUGGET, 0, 2);
|
|
||||||
|
|
||||||
cMonster::KilledBy( a_Killer );
|
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);
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "cMonster.h"
|
#include "cPassiveAggressiveMonster.h"
|
||||||
|
|
||||||
class cZombiepigman : public cMonster
|
class cZombiepigman : public cPassiveAggressiveMonster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cZombiepigman();
|
cZombiepigman();
|
||||||
~cZombiepigman();
|
~cZombiepigman();
|
||||||
|
|
||||||
virtual bool IsA( const char* a_EntityType );
|
virtual bool IsA( const char* a_EntityType );
|
||||||
virtual void GetMonsterConfig(const char* pm_name);
|
|
||||||
|
|
||||||
virtual void Tick(float a_Dt);
|
virtual void Tick(float a_Dt);
|
||||||
virtual void KilledBy( cEntity* a_Killer );
|
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