@@ -10,17 +10,24 @@ PanicGoal::PanicGoal(PathfinderMob *mob, double speedModifier)
|
|||||||
{
|
{
|
||||||
this->mob = mob;
|
this->mob = mob;
|
||||||
this->speedModifier = speedModifier;
|
this->speedModifier = speedModifier;
|
||||||
setRequiredControlFlags(Control::MoveControlFlag);
|
Goal::setRequiredControlFlags(Control::MoveControlFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PanicGoal::canUse()
|
bool PanicGoal::canUse()
|
||||||
{
|
{
|
||||||
if (mob->getLastHurtByMob() == NULL && !mob->isOnFire()) return false;
|
if (mob->getLastHurtByMob() == nullptr && !mob->isOnFire()) return false;
|
||||||
Vec3 *pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5, 4);
|
const int hurtTimeout = mob->getLastHurtByMobTimestamp();
|
||||||
if (pos == NULL) return false;
|
if (hurtTimeout == 0) return false;
|
||||||
|
static thread_local std::mt19937 rng(std::random_device{}());
|
||||||
|
std::uniform_int_distribution<int> dist(60, 100);
|
||||||
|
const int panicDuration = dist(rng);
|
||||||
|
if (mob->tickCount - hurtTimeout > panicDuration) return false;
|
||||||
|
const Vec3* pos = RandomPos::getPos(dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5, 4);
|
||||||
|
if (pos == nullptr) return false;
|
||||||
posX = pos->x;
|
posX = pos->x;
|
||||||
posY = pos->y;
|
posY = pos->y;
|
||||||
posZ = pos->z;
|
posZ = pos->z;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,5 +38,6 @@ void PanicGoal::start()
|
|||||||
|
|
||||||
bool PanicGoal::canContinueToUse()
|
bool PanicGoal::canContinueToUse()
|
||||||
{
|
{
|
||||||
|
if (mob->getLastHurtByMob() == nullptr && !mob->isOnFire()) return false;
|
||||||
return !mob->getNavigation()->isDone();
|
return !mob->getNavigation()->isDone();
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Goal.h"
|
#include "Goal.h"
|
||||||
|
#include <random>
|
||||||
|
|
||||||
class PathfinderMob;
|
class PathfinderMob;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user