mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-18 08:22:54 +00:00
Merge pull request #325 from realffqq/dev
fix(goal): add a duration to panics
This commit is contained in:
commit
f59085c782
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue