mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +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() {
|
bool PanicGoal::canUse() {
|
||||||
if (mob->getLastHurtByMob() == NULL && !mob->isOnFire()) return false;
|
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(
|
auto pos = RandomPos::getPos(
|
||||||
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5,
|
std::dynamic_pointer_cast<PathfinderMob>(mob->shared_from_this()), 5,
|
||||||
4);
|
4);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue