mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-14 10:17:14 +00:00
fix(goal): add a duration to panics
This commit is contained in:
parent
7db2fe0318
commit
23ab4de9ac
|
|
@ -14,6 +14,14 @@ PanicGoal::PanicGoal(PathfinderMob* mob, double speedModifier) {
|
|||
|
||||
bool PanicGoal::canUse() {
|
||||
if (mob->getLastHurtByMob() == NULL && !mob->isOnFire()) return false;
|
||||
|
||||
// 4jcraft: stop entities from being eternally scared (referenced from
|
||||
// smartcmd/MinecraftConsoles #519)
|
||||
const int hurtTimeout = mob->getLastHurtByMobTimestamp();
|
||||
static thread_local Random random;
|
||||
const int panicDuration = random.nextInt(41) + 60;
|
||||
if (mob->tickCount - hurtTimeout > panicDuration) return false;
|
||||
|
||||
Vec3* pos = RandomPos::getPos(
|
||||
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5,
|
||||
4);
|
||||
|
|
|
|||
Loading…
Reference in a new issue