Browse Source

fixed profit error for NPCs

lakebane-new
FatBoy-DOTC 6 months ago
parent
commit
6fb5fce4d3
  1. 16
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/objects/Warehouse.java

16
src/engine/net/client/ClientMessagePump.java

@ -1351,6 +1351,14 @@ public class ClientMessagePump implements NetMsgHandler {
NPC npc = NPC.getFromCache(msg.getNpcID()); NPC npc = NPC.getFromCache(msg.getNpcID());
switch(npc.getContractID()){
case 900:
case 1201:
case 1202:
npc.sellPercent = 0.0f;
break;
}
if (npc == null) if (npc == null)
return; return;
@ -1411,7 +1419,7 @@ public class ClientMessagePump implements NetMsgHandler {
bargain = 0; bargain = 0;
break; break;
case 900: case 900:
cost = (int)(Warehouse.getCostForResource(ib.getUUID()) * Warehouse.getSellStackSize(ib.getUUID()) * 0.5f); cost = Warehouse.getCostForResource(ib.getUUID()) * Warehouse.getSellStackSize(ib.getUUID());
bargain = 0; bargain = 0;
break; break;
} }
@ -1440,7 +1448,7 @@ public class ClientMessagePump implements NetMsgHandler {
return; return;
} }
if(me.getItemBase().getType().equals(ItemType.RESOURCE) && npc.getContractID() == 900){ if(me.getItemBase().getType().equals(ItemType.RESOURCE) && npc.getContractID() == 900){
handleResourcePurchase(me,itemMan,npc,buy,sourcePlayer,ib); handleResourcePurchase(me,itemMan,sourcePlayer,ib);
}else { }else {
buy = Item.createItemForPlayer(sourcePlayer, ib); buy = Item.createItemForPlayer(sourcePlayer, ib);
if (buy != null) { if (buy != null) {
@ -1556,7 +1564,7 @@ public class ClientMessagePump implements NetMsgHandler {
} }
} }
public static void handleResourcePurchase(MobEquipment me, CharacterItemManager itemMan, NPC npc, Item buy, PlayerCharacter sourcePlayer, ItemBase ib){ public static void handleResourcePurchase(MobEquipment me, CharacterItemManager itemMan, PlayerCharacter sourcePlayer, ItemBase ib){
boolean stacked = false; boolean stacked = false;
int buystack = Warehouse.getSellStackSize(me.getItemBase().getUUID()); int buystack = Warehouse.getSellStackSize(me.getItemBase().getUUID());
for(Item item : itemMan.getInventory()){ for(Item item : itemMan.getInventory()){
@ -1576,7 +1584,7 @@ public class ClientMessagePump implements NetMsgHandler {
} }
} }
if(!stacked){ if(!stacked){
buy = Item.createItemForPlayer(sourcePlayer, ib); Item buy = Item.createItemForPlayer(sourcePlayer, ib);
if (buy != null) { if (buy != null) {
me.transferEnchants(buy); me.transferEnchants(buy);
itemMan.addItemToInventory(buy); itemMan.addItemToInventory(buy);

2
src/engine/objects/Warehouse.java

@ -356,7 +356,7 @@ public class Warehouse extends AbstractWorldObject {
public static int getSellStackSize(int id){ public static int getSellStackSize(int id){
if(id == 1705032) if(id == 1705032)
return 10; return 10;
return (int)(3000000 / getCostForResource(id)); return 3000000 / getCostForResource(id);
} }
public ConcurrentHashMap<ItemBase, Integer> getResources() { public ConcurrentHashMap<ItemBase, Integer> getResources() {

Loading…
Cancel
Save