summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Behaviors
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mobs/Behaviors')
-rw-r--r--src/Mobs/Behaviors/BehaviorAttacker.cpp7
-rw-r--r--src/Mobs/Behaviors/BehaviorAttacker.h2
-rw-r--r--src/Mobs/Behaviors/BehaviorCoward.cpp3
-rw-r--r--src/Mobs/Behaviors/BehaviorCoward.h1
-rw-r--r--src/Mobs/Behaviors/BehaviorDayLightBurner.cpp12
-rw-r--r--src/Mobs/Behaviors/BehaviorDayLightBurner.h2
-rw-r--r--src/Mobs/Behaviors/BehaviorWanderer.cpp3
-rw-r--r--src/Mobs/Behaviors/BehaviorWanderer.h1
8 files changed, 9 insertions, 22 deletions
diff --git a/src/Mobs/Behaviors/BehaviorAttacker.cpp b/src/Mobs/Behaviors/BehaviorAttacker.cpp
index 031b5ddf9..2f25bd3aa 100644
--- a/src/Mobs/Behaviors/BehaviorAttacker.cpp
+++ b/src/Mobs/Behaviors/BehaviorAttacker.cpp
@@ -13,7 +13,6 @@ cBehaviorAttacker::cBehaviorAttacker() :
, m_AttackDamage(1)
, m_AttackRange(1)
, m_AttackCoolDownTicksLeft(0)
- , m_TicksSinceLastDamaged(100)
, m_IsStriking(false)
, m_Target(nullptr)
{
@@ -117,11 +116,6 @@ void cBehaviorAttacker::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
void cBehaviorAttacker::PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
- if (m_TicksSinceLastDamaged < 100)
- {
- ++m_TicksSinceLastDamaged;
- }
-
if (m_AttackCoolDownTicksLeft > 0)
{
m_AttackCoolDownTicksLeft -= 1;
@@ -143,7 +137,6 @@ void cBehaviorAttacker::DoTakeDamage(TakeDamageInfo & a_TDI)
{
SetTarget(static_cast<cPawn*>(a_TDI.Attacker));
}
- m_TicksSinceLastDamaged = 0;
}
}
diff --git a/src/Mobs/Behaviors/BehaviorAttacker.h b/src/Mobs/Behaviors/BehaviorAttacker.h
index 78ed70994..c047cde50 100644
--- a/src/Mobs/Behaviors/BehaviorAttacker.h
+++ b/src/Mobs/Behaviors/BehaviorAttacker.h
@@ -65,8 +65,6 @@ protected:
int m_AttackRange;
int m_AttackCoolDownTicksLeft;
- int m_TicksSinceLastDamaged; // How many ticks ago were we last damaged by a player?
-
bool m_IsStriking;
/** Our parent */
diff --git a/src/Mobs/Behaviors/BehaviorCoward.cpp b/src/Mobs/Behaviors/BehaviorCoward.cpp
index e1b0d2a25..55a5932cd 100644
--- a/src/Mobs/Behaviors/BehaviorCoward.cpp
+++ b/src/Mobs/Behaviors/BehaviorCoward.cpp
@@ -40,7 +40,6 @@ bool cBehaviorCoward::ControlStarting(std::chrono::milliseconds a_Dt, cChunk & a
{
UNUSED(a_Dt);
UNUSED(a_Chunk);
- m_OldDontCare = m_Parent->GetPathFinder().getDontCare();
m_Parent->GetPathFinder().setDontCare(true); // We don't care we're we are going when
// wandering. If a path is not found, the pathfinder just modifies our destination.
m_Parent->SetRelativeWalkSpeed(m_Parent->GetRelativeWalkSpeed() * 3);
@@ -53,7 +52,7 @@ bool cBehaviorCoward::ControlEnding(std::chrono::milliseconds a_Dt, cChunk & a_C
UNUSED(a_Dt);
UNUSED(a_Chunk);
m_Parent->SetRelativeWalkSpeed(m_Parent->GetRelativeWalkSpeed() / 3);
- m_Parent->GetPathFinder().setDontCare(m_OldDontCare);
+ m_Parent->GetPathFinder().setDontCare(false);
return true;
}
diff --git a/src/Mobs/Behaviors/BehaviorCoward.h b/src/Mobs/Behaviors/BehaviorCoward.h
index 16d68872c..3232f807b 100644
--- a/src/Mobs/Behaviors/BehaviorCoward.h
+++ b/src/Mobs/Behaviors/BehaviorCoward.h
@@ -19,5 +19,4 @@ public:
private:
cMonster * m_Parent; // Our Parent
cEntity * m_Attacker; // The entity we're running away from
- bool m_OldDontCare;
};
diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp b/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
index 0b0faed08..1271574fe 100644
--- a/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
+++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.cpp
@@ -4,7 +4,6 @@
#include "../Monster.h"
#include "../../Entities/Player.h"
#include "../../Entities/Entity.h"
-
#include "../../Chunk.h"
@@ -15,6 +14,7 @@ void cBehaviorDayLightBurner::AttachToMonster(cMonster & a_Parent)
{
m_Parent = &a_Parent;
m_Parent->AttachPostTickBehavior(this);
+ m_Parent->GetPathFinder().SetAvoidSunlight(true);
}
@@ -35,7 +35,7 @@ void cBehaviorDayLightBurner::PostTick(std::chrono::milliseconds a_Dt, cChunk &
return;
}
- if (!m_Parent->IsOnFire() && WouldBurnAt(m_Parent->GetPosition(), a_Chunk))
+ if (!m_Parent->IsOnFire() && WouldBurnAt(m_Parent->GetPosition(), a_Chunk, *m_Parent))
{
// Burn for 100 ticks, then decide again
m_Parent->StartBurning(100);
@@ -45,7 +45,7 @@ void cBehaviorDayLightBurner::PostTick(std::chrono::milliseconds a_Dt, cChunk &
-bool cBehaviorDayLightBurner::WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk)
+bool cBehaviorDayLightBurner::WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk, cMonster & a_Monster)
{
int RelY = FloorC(a_Location.y);
if (RelY <= 0)
@@ -67,11 +67,11 @@ bool cBehaviorDayLightBurner::WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk)
if (
(Chunk->GetBlock(Rel.x, Rel.y, Rel.z) != E_BLOCK_SOULSAND) && // Not on soulsand
- (m_Parent->GetWorld()->GetTimeOfDay() < 12000 + 1000) && // Daytime
- m_Parent->GetWorld()->IsWeatherSunnyAt(static_cast<int>(m_Parent->GetPosX()), static_cast<int>(m_Parent->GetPosZ())) // Not raining
+ (a_Monster.GetWorld()->GetTimeOfDay() < 12000 + 1000) && // Daytime
+ a_Monster.GetWorld()->IsWeatherSunnyAt(static_cast<int>(a_Monster.GetPosX()), static_cast<int>(a_Monster.GetPosZ())) // Not raining
)
{
- int MobHeight = CeilC(a_Location.y + m_Parent->GetHeight()) - 1; // The height of the mob head
+ int MobHeight = CeilC(a_Location.y + a_Monster.GetHeight()) - 1; // The height of the mob head
if (MobHeight >= cChunkDef::Height)
{
return true;
diff --git a/src/Mobs/Behaviors/BehaviorDayLightBurner.h b/src/Mobs/Behaviors/BehaviorDayLightBurner.h
index 07812b9db..920f9d5c7 100644
--- a/src/Mobs/Behaviors/BehaviorDayLightBurner.h
+++ b/src/Mobs/Behaviors/BehaviorDayLightBurner.h
@@ -9,7 +9,7 @@ class cBehaviorDayLightBurner : cBehavior
public:
void AttachToMonster(cMonster & a_Parent);
void PostTick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
- bool WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk);
+ static bool WouldBurnAt(Vector3d a_Location, cChunk & a_Chunk, cMonster & a_Monster);
private:
cMonster * m_Parent; // Our Parent
diff --git a/src/Mobs/Behaviors/BehaviorWanderer.cpp b/src/Mobs/Behaviors/BehaviorWanderer.cpp
index a37609aa4..cc03d55cb 100644
--- a/src/Mobs/Behaviors/BehaviorWanderer.cpp
+++ b/src/Mobs/Behaviors/BehaviorWanderer.cpp
@@ -39,7 +39,6 @@ bool cBehaviorWanderer::ControlStarting(std::chrono::milliseconds a_Dt, cChunk &
{
UNUSED(a_Dt);
UNUSED(a_Chunk);
- m_OldDontCare = m_Parent->GetPathFinder().getDontCare();
m_Parent->GetPathFinder().setDontCare(true); // We don't care we're we are going when
// wandering. If a path is not found, the pathfinder just modifies our destination.
return true;
@@ -50,7 +49,7 @@ bool cBehaviorWanderer::ControlEnding(std::chrono::milliseconds a_Dt, cChunk & a
{
UNUSED(a_Dt);
UNUSED(a_Chunk);
- m_Parent->GetPathFinder().setDontCare(m_OldDontCare);
+ m_Parent->GetPathFinder().setDontCare(false);
return true;
}
diff --git a/src/Mobs/Behaviors/BehaviorWanderer.h b/src/Mobs/Behaviors/BehaviorWanderer.h
index 219ad32c3..24c8885bf 100644
--- a/src/Mobs/Behaviors/BehaviorWanderer.h
+++ b/src/Mobs/Behaviors/BehaviorWanderer.h
@@ -21,5 +21,4 @@ public:
private:
cMonster * m_Parent; // Our Parent
std::chrono::milliseconds m_IdleInterval;
- bool m_OldDontCare;
};