From e9f7b4e51583c3848138d3b547fb08321528646b Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Sun, 12 Sep 2021 21:21:36 -0400 Subject: [PATCH] Improve NPC usage of protection prayers. - `NPC.hasProtectionPrayer` now accurately reflects protection prayers defined in `npc_configs.json`. - NPC protection prayers now block 100% of the damage when attacked by a player in `Entity.getFormattedHit` instead of only blocking 40%. --- Server/src/main/java/core/game/node/entity/Entity.java | 2 +- Server/src/main/java/core/game/node/entity/npc/NPC.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Server/src/main/java/core/game/node/entity/Entity.java b/Server/src/main/java/core/game/node/entity/Entity.java index 4c4045b3e..54d48c6e5 100644 --- a/Server/src/main/java/core/game/node/entity/Entity.java +++ b/Server/src/main/java/core/game/node/entity/Entity.java @@ -515,7 +515,7 @@ public abstract class Entity extends Node { Entity victim = state.getVictim(); CombatStyle type = state.getStyle(); if (state.getArmourEffect() != ArmourSet.VERAC && !entity.isIgnoreProtection(type) && victim.hasProtectionPrayer(type)) { - return hit *= entity instanceof Player ? 0.6 : 0; + return hit *= (entity instanceof Player && victim instanceof Player) ? 0.6 : 0; } return hit; } diff --git a/Server/src/main/java/core/game/node/entity/npc/NPC.java b/Server/src/main/java/core/game/node/entity/npc/NPC.java index 9486ce73f..4fcdcf23d 100644 --- a/Server/src/main/java/core/game/node/entity/npc/NPC.java +++ b/Server/src/main/java/core/game/node/entity/npc/NPC.java @@ -653,7 +653,7 @@ public class NPC extends Entity { @Override public boolean hasProtectionPrayer(CombatStyle style) { - return false; + return getProperties().getProtectStyle() == style; } /** @@ -995,4 +995,4 @@ public class NPC extends Entity { this.neverWalks = neverWalks; } -} \ No newline at end of file +}