}
// incExp
player.resetAll();
Point location = Point.location(p.readShort(), p.readShort());
int id = p.readShort();
final ActiveTile tile = world.getTile(location);
if (tile == null)
return;
final InvItem myItem = player.getInventory().getSlot(p.readShort());
if (myItem == null)
return;
if (tile.hasGameObject() && myItem.id != 135) {
player.getActionSender().sendMessage(
"You cannot do that here, please move to a new area.");
return;
}
final Item item = getItem(id, tile, player);
if (item == null || myItem == null) {
player.setSuspiciousPlayer(true);
player.resetPath();
return;
}
world.addEntryToSnapshots(new Activity(player.getUsername(), player
.getUsername()
+ " used item "
+ myItem.getDef().getName()
+ "("
+ myItem.id
+ ")"
+ " [CMD: "
+ myItem.getDef().getCommand()
+ "] ON A GROUND ITEM "
+ myItem.getDef().getName()
+ "("
+ myItem.id
+ ")"
+ " [CMD: "
+ myItem.getDef().getCommand()
+ "] at: "
+ player.getX() + "/" + player.getY()));
player.setStatus(Action.USING_INVITEM_ON_GITEM);
Instance.getDelayedEventHandler().add(
new WalkToPointEvent(player, location, 1, false) {
public void arrived() {
if (owner.isBusy()
|| owner.isRanging()
|| !tile.hasItem(item)
|| !owner.nextTo(item)
|| owner.getStatus() != Action.USING_INVITEM_ON_GITEM) {
return;
}
if (myItem == null || item == null)
return;
switch (item.getID()) {
case 23:
if (myItem.id == 135) {
if (owner.getInventory().remove(myItem.id,
myItem.amount, false))
return;
owner.getActionSender().sendMessage(
"You put the flour in the pot.");
Bubble bubble = new Bubble(owner, 135);
for (Player p : owner.getViewArea()
.getPlayersInView()) {
p.informOfBubble(bubble);
}
world.unregisterItem(item);
owner.getInventory().add(136, 1, false);
owner.getActionSender().sendInventory();
return;
}
case 14:
case 632:
case 633:
case 634:
case 635:
case 636:
handleFireMaking();
break;
default:
owner.getActionSender().sendMessage(
"Nothing interesting happens.");
return;
}
}
private void handleFireMaking() {
handleFireMaking((int) Math.ceil(owner
.getMaxStat(11) / 10));
}
private void handleFireMaking(int tries) {
final int retries = --tries;
final FiremakingDef def = EntityHandler
.getFiremakingDef(item.getID());
if (!itemId(new int[] { 166 }) || def == null) {
owner.getActionSender().sendMessage(
"Nothing interesting happens.");
return;
}
if (owner.getCurStat(11) < def.getRequiredLevel()) {
owner.getActionSender()
.sendMessage(
"You need at least "
+ def.getRequiredLevel()
+ " firemaking to light these logs.");
return;
}
owner.setBusy(true);
Bubble bubble = new Bubble(owner, 166);
for (Player p : owner.getViewArea()
.getPlayersInView()) {
p.informOfBubble(bubble);
}
owner.getActionSender().sendMessage(
"You attempt to light the logs...");
Instance.getDelayedEventHandler().add(
new ShortEvent(owner) {
public void action() {
if (Formulae.lightLogs(def,
owner.getCurStat(11))) {
owner.getActionSender()
.sendMessage(
"They catch fire and start to burn.");
world.unregisterItem(item);
final GameObject fire = new GameObject(
item.getLocation(), 97,
0, 0);
world.registerGameObject(fire);
world.getDelayedEventHandler()
.add(new DelayedEvent(
null,
def.getLength()) {
public void run() {
if (tile.hasGameObject()
&& tile.getGameObject()
.equals(fire)) {
world.unregisterGameObject(fire);
world.registerItem(new Item(
181,
tile.getX(),
tile.getY(),
1,
null));
}
matchRunning = false;
}