From 1e29971b3c5208a81861b74d494f3f9f093fb3b0 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 31 Aug 2024 19:29:03 -0500 Subject: [PATCH] safe NPC profits --- src/engine/net/client/ClientMessagePump.java | 13 ++++++------- src/engine/objects/NPC.java | 12 ++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index a48a0dbf..5cd1039d 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1435,14 +1435,13 @@ public class ClientMessagePump implements NetMsgHandler { bargain = 0; break; } - float profit = npc.getSellPercent(sourcePlayer) - bargain; - if(me.getItemBase().getType().equals(ItemType.POTION)) - profit -= 1.0f; - if (profit < 1) - profit = 1; - if(ZoneManager.findSmallestZone(npc.loc) != null && ZoneManager.findSmallestZone(npc.loc).getSafeZone() == 1){ + float profit; + + if(npc.isInSafeZone()) profit = 0; - } + else + profit = npc.getSellPercent(sourcePlayer) - bargain; + if(profit > 0) cost *= profit; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index ee2096ab..49ed5ac9 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -193,6 +193,18 @@ public class NPC extends AbstractCharacter { serializeForClientMsgOtherPlayer(npc, writer); } + public boolean isInSafeZone() { + + Zone zone = ZoneManager.findSmallestZone(this.getLoc()); + + if (zone != null) { + return zone.getSafeZone() == (byte) 1; + } + + return false; + //return this.safeZone; + } + public static void serializeForClientMsgOtherPlayer(NPC npc, ByteBufferWriter writer) throws SerializationException {