player.setFollowing(affectedMob);
player.setStatus(Action.ATTACKING_MOB);
if (player.getRangeEquip() < 0) {
Instance.getDelayedEventHandler().add(
new WalkToMobEvent(player, affectedMob,
affectedMob instanceof Npc ? 1 : 2) {
public void arrived() {
owner.resetPath();
owner.resetFollowing();
boolean cont = false;
if (affectedMob instanceof Player) {
Player opp = (Player) affectedMob;
if (GameEngine.getTime()
- opp.getLastMineTimer() < 2000
&& opp.isBusy())
cont = true;
}
if (affectedMob instanceof Player) {
world.addEntryToSnapshots(new Activity(owner
.getUsername(), owner.getUsername()
+ " attacked a Player ("
+ ((Player) affectedMob).getUsername()
+ ")"));
} else {
world.addEntryToSnapshots(new Activity(owner
.getUsername(), owner.getUsername()
+ " attacked a NPC ("
+ ((Npc) affectedMob).getDef().name
+ ")"));
}
if (cont) {
if (owner.isBusy()
|| !owner.nextTo(affectedMob)
|| !owner.checkAttack(affectedMob,
false)
|| owner.getStatus() != Action.ATTACKING_MOB) {
return;
}
} else {
if (owner.isBusy()
|| affectedMob.isBusy()
|| !owner.nextTo(affectedMob)
|| !owner.checkAttack(affectedMob,
false)
|| owner.getStatus() != Action.ATTACKING_MOB) {
return;
}
}
if (affectedMob.getID() == 35) {
owner.getActionSender()
.sendMessage(
"Delrith can not be attacked without the Silverlight sword");
return;
}
if (affectedMob.getID() == 140
&& affectedMob.getX() > 327
&& affectedMob.getX() < 335
&& affectedMob.getY() > 433
&& affectedMob.getY() < 439) {
owner.informOfNpcMessage(new ChatMessage(
affectedMob, "a curse be upon you",
owner));
for (int i = 0; i < 3; i++) {
int stat = owner.getCurStat(i);
if (stat < 3)
owner.setCurStat(i, 0);
else
owner.setCurStat(i, stat - 3);
}
owner.getActionSender().sendStats();
}
owner.resetAll();
owner.setStatus(Action.FIGHTING_MOB);
if (affectedMob instanceof Player) {
Player affectedPlayer = (Player) affectedMob;
affectedPlayer.resetAll();
affectedPlayer.setStatus(Action.FIGHTING_MOB);
affectedPlayer.getActionSender().sendSound(
"underattack");
affectedPlayer.getActionSender().sendMessage(
"You are under attack!");
owner.setSkulledOn(affectedPlayer);
}
affectedMob.resetPath();
owner.setLocation(affectedMob.getLocation(), true);
for (Player p : owner.getViewArea()
.getPlayersInView()) {
p.removeWatchedPlayer(owner);
}
owner.setBusy(true);
owner.setSprite(9);
/*
* if(affectedMob instanceof Npc) { Npc n =
* (Npc)affectedMob; for(Fighter p : n.fighters) {
* p.useCombat = true; if(p.player == owner)
* if(p.useMagic) { p.useMagic = false; break; } } }
*/
owner.setOpponent(affectedMob);
owner.setCombatTimer();
affectedMob.setBusy(true);
affectedMob.setSprite(8);
affectedMob.setOpponent(owner);
affectedMob.setCombatTimer();
FightEvent fighting = new FightEvent(owner,
affectedMob);
fighting.setLastRun(0);
Instance.getDelayedEventHandler().add(fighting);
}
});
} else {
if (!new ProjectilePath(player.getX(), player.getY(),
affectedMob.getX(), affectedMob.getY()).isValid()) {
player.getActionSender().sendMessage(
"I can't get a clear shot from here");
player.resetPath();
return;
}
if (Config.f2pWildy && player.getLocation().inWilderness()) {
for (InvItem i : player.getInventory().getItems()) {
if (i.id == 638 || i.id == 640 || i.id == 642
|| i.id == 644 || i.id == 646) {
player.getActionSender()
.sendMessage(
"You can not have any P2P arrows in your inventory in a F2P wilderness");
return;
}
}
}
int radius = 7;
if (player.getRangeEquip() == 59 || player.getRangeEquip() == 60)
radius = 5;
if (player.getRangeEquip() == 189)
radius = 4;
Instance.getDelayedEventHandler().add(
new WalkToMobEvent(player, affectedMob, radius) {
public void arrived() {
owner.resetPath();
if (owner.isBusy()
|| !owner.checkAttack(affectedMob, true)
|| owner.getStatus() != Action.ATTACKING_MOB) {