Fixed #627
- Attack() is now called from cAggressive instead of cMonster * Monsters can no longer attack through walls * Should fix last remnants of player damage after teleporting (that both STR and bearbin contributed fixes to :P)
This commit is contained in:
parent
c53406f0d4
commit
06239c8336
@ -1122,8 +1122,8 @@ void cPlayer::SetIP(const AString & a_IP)
|
|||||||
|
|
||||||
void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
|
void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
|
||||||
{
|
{
|
||||||
SetPosition( a_PosX, a_PosY, a_PosZ );
|
SetPosition(a_PosX, a_PosY, a_PosZ);
|
||||||
m_LastGroundHeight = (float)a_PosY;
|
m_LastGroundHeight, m_LastJumpHeight = (float)a_PosY;
|
||||||
|
|
||||||
m_World->BroadcastTeleportEntity(*this, GetClientHandle());
|
m_World->BroadcastTeleportEntity(*this, GetClientHandle());
|
||||||
m_ClientHandle->SendPlayerMoveLook();
|
m_ClientHandle->SendPlayerMoveLook();
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "../World.h"
|
#include "../World.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
#include "../MersenneTwister.h"
|
#include "../Tracer.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -73,6 +73,13 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
{
|
{
|
||||||
CheckEventSeePlayer();
|
CheckEventSeePlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cTracer LineOfSight(GetWorld());
|
||||||
|
if (ReachedFinalDestination() && (m_Target != NULL) && !LineOfSight.Trace(GetPosition(), (m_Target->GetPosition() - GetPosition()), (int)(m_Target->GetPosition() - GetPosition()).Length()))
|
||||||
|
{
|
||||||
|
// Attack if reached destination, target isn't null, and have a clear line of sight to target (so won't attack through walls)
|
||||||
|
Attack(a_Dt / 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +88,7 @@ void cAggressiveMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
|
|
||||||
void cAggressiveMonster::Attack(float a_Dt)
|
void cAggressiveMonster::Attack(float a_Dt)
|
||||||
{
|
{
|
||||||
super::Attack(a_Dt);
|
m_AttackInterval += a_Dt * m_AttackRate;
|
||||||
|
|
||||||
if ((m_Target != NULL) && (m_AttackInterval > 3.0))
|
if ((m_Target != NULL) && (m_AttackInterval > 3.0))
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@ public:
|
|||||||
virtual void InStateChasing(float a_Dt) override;
|
virtual void InStateChasing(float a_Dt) override;
|
||||||
|
|
||||||
virtual void EventSeePlayer(cEntity *) override;
|
virtual void EventSeePlayer(cEntity *) override;
|
||||||
virtual void Attack(float a_Dt) override;
|
virtual void Attack(float a_Dt);
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -311,9 +311,6 @@ void cMonster::Tick(float a_Dt, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReachedFinalDestination() && (m_Target != NULL))
|
|
||||||
Attack(a_Dt);
|
|
||||||
|
|
||||||
SetPitchAndYawFromDestination();
|
SetPitchAndYawFromDestination();
|
||||||
HandleFalling();
|
HandleFalling();
|
||||||
|
|
||||||
@ -657,17 +654,6 @@ void cMonster::InStateEscaping(float a_Dt)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Do attack here
|
|
||||||
// a_Dt is passed so we can set attack rate
|
|
||||||
void cMonster::Attack(float a_Dt)
|
|
||||||
{
|
|
||||||
m_AttackInterval += a_Dt * m_AttackRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cMonster::GetMonsterConfig(const AString & a_Name)
|
void cMonster::GetMonsterConfig(const AString & a_Name)
|
||||||
{
|
{
|
||||||
cRoot::Get()->GetMonsterConfig()->AssignAttributes(this, a_Name);
|
cRoot::Get()->GetMonsterConfig()->AssignAttributes(this, a_Name);
|
||||||
|
@ -112,8 +112,6 @@ public:
|
|||||||
virtual void InStateChasing (float a_Dt);
|
virtual void InStateChasing (float a_Dt);
|
||||||
virtual void InStateEscaping(float a_Dt);
|
virtual void InStateEscaping(float a_Dt);
|
||||||
|
|
||||||
virtual void Attack(float a_Dt);
|
|
||||||
|
|
||||||
int GetAttackRate() { return (int)m_AttackRate; }
|
int GetAttackRate() { return (int)m_AttackRate; }
|
||||||
void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; }
|
void SetAttackRate(float a_AttackRate) { m_AttackRate = a_AttackRate; }
|
||||||
void SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; }
|
void SetAttackRange(int a_AttackRange) { m_AttackRange = a_AttackRange; }
|
||||||
|
Loading…
Reference in New Issue
Block a user