From 963205fad6971255580ea1e81a5f1b02b2d29089 Mon Sep 17 00:00:00 2001 From: Jade Date: Sat, 28 Nov 2020 03:09:25 +0000 Subject: [PATCH] Added Nullptr check + Made mob abilities less frequent --- src/MobManager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MobManager.cpp b/src/MobManager.cpp index 1689928..4ba1590 100644 --- a/src/MobManager.cpp +++ b/src/MobManager.cpp @@ -556,8 +556,12 @@ void MobManager::combatStep(Mob *mob, time_t currTime) { int distance = hypot(plr->x - mob->appearanceData.iX, plr->y - mob->appearanceData.iY); int mobRange = (int)mob->data["m_iAtkRange"] + (int)mob->data["m_iRadius"]; - if (currTime >= mob->nextAttack) - useAbilities(mob, currTime); + if (currTime >= mob->nextAttack) { + if (mob->nextAttack != 0 || rand()%4 == 0) + useAbilities(mob, currTime); + if (mob->target == nullptr) + return; + } /* * If the mob is close enough to attack, do so. If not, get closer. * No, I'm not 100% sure this is how it's supposed to work.