From 074a799d01cbcf7975171cd4ebc84645b321a8d0 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 22 Aug 2023 20:58:52 -0500 Subject: [PATCH] added health recovery to mobs --- src/engine/mobileAI/MobAI.java | 36 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/engine/mobileAI/MobAI.java b/src/engine/mobileAI/MobAI.java index 777afddb..b4543321 100644 --- a/src/engine/mobileAI/MobAI.java +++ b/src/engine/mobileAI/MobAI.java @@ -693,6 +693,8 @@ public class MobAI { DefaultLogic(mob); break; } + if(mob.isAlive()) + RecoverHealth(mob); } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: DetermineAction" + " " + e.getMessage()); } @@ -1095,22 +1097,6 @@ public class MobAI { CheckMobMovement(mob); CheckForAttack(mob); - - //recover health - - if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false) - mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); - - if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000) - if (mob.getHealth() < mob.getHealthMax()) { - - float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f); - mob.setHealth(mob.getHealth() + recoveredHealth); - mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); - - if (mob.getHealth() > mob.getHealthMax()) - mob.setHealth(mob.getHealthMax()); - } } catch (Exception e) { Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: PetLogic" + " " + e.getMessage()); } @@ -1364,4 +1350,22 @@ public class MobAI { } return null; } + + public static void RecoverHealth(Mob mob){ + //recover health + + if (mob.getTimestamps().containsKey("HEALTHRECOVERED") == false) + mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); + + if (mob.isSit() && mob.getTimeStamp("HEALTHRECOVERED") < System.currentTimeMillis() + 3000) + if (mob.getHealth() < mob.getHealthMax()) { + + float recoveredHealth = mob.getHealthMax() * ((1 + mob.getBonuses().getFloatPercentAll(Enum.ModType.HealthRecoverRate, Enum.SourceType.None)) * 0.01f); + mob.setHealth(mob.getHealth() + recoveredHealth); + mob.getTimestamps().put("HEALTHRECOVERED", System.currentTimeMillis()); + + if (mob.getHealth() > mob.getHealthMax()) + mob.setHealth(mob.getHealthMax()); + } + } } \ No newline at end of file