Merge pull request #325 from realffqq/dev

fix(goal): add a duration to panics
This commit is contained in:
Tropical 2026-03-27 18:20:35 -05:00 committed by GitHub
commit f59085c782
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
auto pos = RandomPos::getPos(
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5,
4);