Commit a9733b71 authored by Scott T's avatar Scott T

Lost city switch DelayedEvent to SingleEvent, make Functions.removeItem check...

Lost city switch DelayedEvent to SingleEvent, make Functions.removeItem check the equipment container
parent fbb47fcc
......@@ -3,7 +3,7 @@ package com.openrsc.server.plugins.quests.members;
import com.openrsc.server.Constants;
import com.openrsc.server.Constants.Quests;
import com.openrsc.server.Server;
import com.openrsc.server.event.DelayedEvent;
import com.openrsc.server.event.SingleEvent;
import com.openrsc.server.external.ItemId;
import com.openrsc.server.external.NpcId;
import com.openrsc.server.model.Skills.SKILLS;
......@@ -94,9 +94,9 @@ public class LostCity implements QuestInterface, TalkToNpcListener,
p.setBusyTimer(1800);
lepr.walk(173, 661);
try {
Server.getServer().getGameEventHandler().add(new DelayedEvent(null, 600, "Lost City Leprechaun") {
Server.getServer().getGameEventHandler().add(new SingleEvent(null, 600, "Lost City Leprechaun", true) {
@Override
public void run() {
public void action() {
lepr.walk(177, 661 + DataConversions.random(0, 10) - 5);
}
});
......
package com.openrsc.server.model.container;
import com.openrsc.server.external.ItemDefinition;
import com.openrsc.server.model.entity.player.Player;
import com.openrsc.server.net.rsc.ActionSender;
import java.util.ArrayList;
......@@ -119,5 +121,37 @@ public class Equipment {
}
}
public int remove(int id, int amount) {
synchronized (list) {
for (int i = 0; i < slots; i++) {
Item curEquip = list[i];
if (curEquip == null || curEquip.getDef() == null)
continue;
ItemDefinition curEquipDef = curEquip.getDef();
if (curEquip.getID() == id) {
int curAmount = curEquip.getAmount();
if (!curEquipDef.isStackable() && amount > 1)
return -1;
if (curAmount > amount) {
list[i].setAmount(curAmount - amount);
} else if(curAmount < amount) {
return -1;
} else {
list[i] = null;
player.updateWornItems(curEquipDef.getWieldPosition(),
player.getSettings().getAppearance().getSprite(curEquipDef.getWieldPosition()));
}
ActionSender.sendEquipmentStats(player);
return i;
}
}
return -1;
}
}
}
......@@ -282,7 +282,10 @@ public class Inventory {
}
}
}
return -1;
if (Constants.GameServer.WANT_EQUIPMENT_TAB)
return player.getEquipment().remove(id, amount);
else
return -1;
}
public int remove(int id, int amount) {
......
......@@ -1246,7 +1246,14 @@ public class Functions {
* @return
*/
public static boolean hasItem(final Player p, final int id, final int amt) {
return p.getInventory().countId(id) >= amt;
int amount = p.getInventory().countId(id);
int equipslot = -1;
if (Constants.GameServer.WANT_EQUIPMENT_TAB) {
if ((equipslot = p.getEquipment().hasEquipped(id))!=-1) {
amount += p.getEquipment().get(equipslot).getAmount();
}
}
return amount >= amt;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment