Code:
package server.model.players;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.Future;
import org.apache.mina.common.IoSession;
import server.Config;
import server.Server;
import server.model.items.ItemAssistant;
import server.model.shops.ShopAssistant;
import server.net.HostList;
import server.net.Packet;
import server.net.StaticPacketBuilder;
import server.util.Misc;
import server.util.Stream;
import server.model.players.skills.*;
import server.event.EventManager;
import server.event.Event;
import server.event.EventContainer;
public class Client extends Player {
public void randomEvent() {
getPA().sendFrame126(" ", 16131);
getPA().showInterface(16135);
int randomMessage = Misc.random(6);
if(randomMessage == 0) {
getPA().sendFrame126("Please select the pie for a cash reward!", 16145);
pieSelect = 1;
} else if (randomMessage == 1) {
getPA().sendFrame126("Please select the kebab for a cash reward!", 16145);
kebabSelect = 1;
} else if (randomMessage == 2) {
getPA().sendFrame126("Please select the chocolate for a cash reward!", 16145);
chocSelect = 1;
} else if (randomMessage == 3) {
getPA().sendFrame126("Please select the bagel for a cash reward!", 16145);
bagelSelect = 1;
} else if (randomMessage == 4) {
getPA().sendFrame126("Please select the triangle sandwich for a cash reward!", 16145);
triangleSandwich = 1;
} else if (randomMessage == 5) {
getPA().sendFrame126("Please select the square sandwich for a cash reward!", 16145);
squareSandwich = 1;
} else if (randomMessage == 6) {
getPA().sendFrame126("Please select the bread for a cash reward!", 16145);
breadSelect = 1;
}
}
public int pieSelect = 0;
public int kebabSelect = 0;
public int chocSelect = 0;
public int bagelSelect = 0;
public int triangleSandwich = 0;
public int squareSandwich = 0;
public int breadSelect = 0;
public byte buffer[] = null;
public Stream inStream = null, outStream = null;
private IoSession session;
private ItemAssistant itemAssistant = new ItemAssistant(this);
private ShopAssistant shopAssistant = new ShopAssistant(this);
private TradeAndDuel tradeAndDuel = new TradeAndDuel(this);
private PlayerAssistant playerAssistant = new PlayerAssistant(this);
private CombatAssistant combatAssistant = new CombatAssistant(this);
private ActionHandler actionHandler = new ActionHandler(this);
private PlayerKilling playerKilling = new PlayerKilling(this);
private DialogueHandler dialogueHandler = new DialogueHandler(this);
private Queue<Packet> queuedPackets = new LinkedList<Packet>();
private Potions potions = new Potions(this);
private PotionMixing potionMixing = new PotionMixing(this);
private Food food = new Food(this);
/**
* Skill instances
*/
private Slayer slayer = new Slayer(this);
private Runecrafting runecrafting = new Runecrafting(this);
private Woodcutting woodcutting = new Woodcutting(this);
private Mining mine = new Mining(this);
private Agility agility = new Agility(this);
private Cooking cooking = new Cooking(this);
private Fishing fish = new Fishing(this);
private Crafting crafting = new Crafting(this);
private Smithing smith = new Smithing(this);
private Prayer prayer = new Prayer(this);
private Fletching fletching = new Fletching(this);
private SmithingInterface smithInt = new SmithingInterface(this);
private Farming farming = new Farming(this);
private Thieving thieving = new Thieving(this);
private Firemaking firemaking = new Firemaking(this);
private Herblore herblore = new Herblore(this);
private int somejunk;
public int lowMemoryVersion = 0;
public int timeOutCounter = 0;
public int returnCode = 2;
private Future<?> currentTask;
public String lastKilled = "";
public boolean usingCarpet = false;
public int itemBeforeCarpet;
public int clawDelay = 0;
public int previousDamage;
public boolean usingClaws = false;
public void clueScroll(int i1, int a1, int i2, int a2, int i3, int a3, int i4,int a4,int clueID){
getPA().showInterface(6960);
getPA().sendFrame34a(6963,i1, 0,a1);
getPA().sendFrame34a(6963, i2, 1, a2);
getPA().sendFrame34a(6963, i3, 2, a3);
getPA().sendFrame34a(6963, i4, 3, a4);
/*addItem(i1,a1);
addItem(i2,a2);
addItem(i3,a3);
addItem(i4,a4);
sendMessage("Congratulations, You Have Completed Treasure Trails");
deleteItem(clueID,GetItemSlot(clueID),1);*/
}
public Client(IoSession s, int _playerId) {
super(_playerId);
this.session = s;
synchronized(this) {
outStream = new Stream(new byte[Config.BUFFER_SIZE]);
outStream.currentOffset = 0;
}
inStream = new Stream(new byte[Config.BUFFER_SIZE]);
inStream.currentOffset = 0;
buffer = new byte[Config.BUFFER_SIZE];
}
public void flushOutStream() {
if(disconnected || outStream.currentOffset == 0) return;
synchronized(this) {
StaticPacketBuilder out = new StaticPacketBuilder().setBare(true);
byte[] temp = new byte[outStream.currentOffset];
System.arraycopy(outStream.buffer, 0, temp, 0, temp.length);
out.addBytes(temp);
session.write(out.toPacket());
outStream.currentOffset = 0;
}
}
public void sendClan(String name, String message, String clan, int rights) {
outStream.createFrameVarSizeWord(217);
outStream.writeString(name);
outStream.writeString(message);
outStream.writeString(clan);
outStream.writeWord(rights);
outStream.endFrameVarSize();
}
public void walk(int EndX, int EndY, int Emote) {
walkToEmote(Emote);
getPA().walkTo2(EndX, EndY);
}
public void walkToEmote(int id) {
isRunning2 = false;
playerWalkIndex = id;
getPA().requestUpdates(); //this was needed to make the agility work
}
public void stopEmote() {
playerWalkIndex = 0x333;
agilityEmote = false;
isRunning2 = true;
getPA().requestUpdates(); //this was needed to make the agility work
}
public void obsticle(int Emote, int Req, int newX, int newY, final int agilityTimer, int amtEXP, String message) {
if (playerLevel[16] >= Req) {
agilityEmote = true;
walk(newX, newY, Emote);
getPA().addSkillXP(amtEXP, playerAgility);
EventManager.getSingleton().addEvent(new Event() {
public void execute(EventContainer c) {
stopEmote();
c.stop();
}
}, agilityTimer);
} else {
sendMessage("You Need " + Req + " Agility To Do This Obstacle");
}
}
public void agilityDelay(int Emote, final int X, final int Y, final int H, int Req, int amtEXP, String message) {
if (playerLevel[16] >= Req) {
startAnimation(Emote);
agilityEmote = true;
getPA().addSkillXP(amtEXP, playerAgility);
EventManager.getSingleton().addEvent(new Event() {
public void execute(EventContainer c) {
getPA().movePlayer(X, Y, H);
agilityEmote = false;
c.stop();
}
}, 1);
} else {
sendMessage("You Need " + Req + " Agility To Do This Obstacle");
}
}
public static final int PACKET_SIZES[] = {
0, 0, 0, 1, -1, 0, 0, 0, 0, 0, //0
0, 0, 0, 0, 8, 0, 6, 2, 2, 0, //10
0, 2, 0, 6, 0, 12, 0, 0, 0, 0, //20
0, 0, 0, 0, 0, 8, 4, 0, 0, 2, //30
2, 6, 0, 6, 0, -1, 0, 0, 0, 0, //40
0, 0, 0, 12, 0, 0, 0, 8, 8, 12, //50
8, 8, 0, 0, 0, 0, 0, 0, 0, 0, //60
6, 0, 2, 2, 8, 6, 0, -1, 0, 6, //70
0, 0, 0, 0, 0, 1, 4, 6, 0, 0, //80
0, 0, 0, 0, 0, 3, 0, 0, -1, 0, //90
0, 13, 0, -1, 0, 0, 0, 0, 0, 0,//100
0, 0, 0, 0, 0, 0, 0, 6, 0, 0, //110
1, 0, 6, 0, 0, 0, -1, 0, 2, 6, //120
0, 4, 6, 8, 0, 6, 0, 0, 0, 2, //130
0, 0, 0, 0, 0, 6, 0, 0, 0, 0, //140
0, 0, 1, 2, 0, 2, 6, 0, 0, 0, //150
0, 0, 0, 0, -1, -1, 0, 0, 0, 0,//160
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //170
0, 8, 0, 3, 0, 2, 0, 0, 8, 1, //180
0, 0, 12, 0, 0, 0, 0, 0, 0, 0, //190
2, 0, 0, 0, 0, 0, 0, 0, 4, 0, //200
4, 0, 0, 0, 7, 8, 0, 0, 10, 0, //210
0, 0, 0, 0, 0, 0, -1, 0, 6, 0, //220
1, 0, 0, 0, 6, 0, 6, 8, 1, 0, //230
0, 4, 0, 0, 0, 0, -1, 0, -1, 4,//240
0, 0, 6, 6, 0, 0, 0 //250
};
public void destruct() {
if(session == null)
return;
//PlayerSaving.getSingleton().requestSave(playerId);
getPA().removeFromCW();
if (inPits)
Server.fightPits.removePlayerFromPits(playerId);
if (inGlitchArea()) {
if (duelStatus == 5) {
}
}
if (clanId >= 0)
Server.clanChat.leaveClan(playerId, clanId);
Misc.println("LOGGED OUT: "+playerName+"");
HostList.getHostList().remove(session);
disconnected = true;
session.close();
session = null;
inStream = null;
outStream = null;
isActive = false;
buffer = null;
super.destruct();
}
public void sendMessage(String s) {
synchronized (this) {
if(getOutStream() != null) {
outStream.createFrameVarSize(253);
outStream.writeString(s);
outStream.endFrameVarSize();
}
}
}
public void setSidebarInterface(int menuId, int form) {
synchronized (this) {
if(getOutStream() != null) {
outStream.createFrame(71);
outStream.writeWord(form);
outStream.writeByteA(menuId);
}
}
}
public boolean checkVotes(String playerName) {
try {
String urlString = "http://www.runelocus.com/toplist/vote-34779.htmlaction=up&server=E-Scape?type=checkvote&username="+playerName;
urlString = urlString.replaceAll(" ", "%20");
URL url = new URL(urlString);
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String results = reader.readLine();
if(results.length() > 0) {
if(results.equals("user needs reward..."))
return true;
else
return false;
}
} catch (MalformedURLException e) {
System.out.println("Malformed URL Exception in checkVotes(String playerName)");
} catch (IOException e) {
System.out.println("IO Exception in checkVotes(String playerName)");
}
return false;
}
public void initialize() {
//mymessage();
synchronized (this) {
outStream.createFrame(249);
outStream.writeByteA(1); // 1 for members, zero for free
outStream.writeWordBigEndianA(playerId);
for (int j = 0; j < Server.playerHandler.players.length; j++) {
if (j == playerId)
continue;
if (Server.playerHandler.players[j] != null) {
if (Server.playerHandler.players[j].playerName.equalsIgnoreCase(playerName))
disconnected = true;
}
}
for (int i = 0; i < 25; i++) {
getPA().setSkillLevel(i, playerLevel[i], playerXP[i]);
getPA().refreshSkill(i);
}
for(int p = 0; p < PRAYER.length; p++) { // reset prayer glows
prayerActive[p] = false;
getPA().sendFrame36(PRAYER_GLOW[p], 0);
}
getPA().handleWeaponStyle();
getPA().handleLoginText();
accountFlagged = getPA().checkForFlags();
//getPA().sendFrame36(43, fightMode-1);
getPA().sendFrame36(108, 0);//resets autocast button
getPA().sendFrame36(172, 1);
getPA().sendFrame107(); // reset screen
getPA().setChatOptions(0, 0, 0); // reset private messaging options
setSidebarInterface(1, 3917);
setSidebarInterface(2, 638);
setSidebarInterface(3, 3213);
setSidebarInterface(4, 1644);
setSidebarInterface(5, 5608);
if(playerMagicBook == 0) {
setSidebarInterface(6, 1151); //modern
} else if (playerMagicBook == 1) {
setSidebarInterface(6, 12855); // ancient
} else if (playerMagicBook == 2) {
setSidebarInterface(6, 29999); // lunar
}
correctCoordinates();
setSidebarInterface(7, 18128);
setSidebarInterface(8, 5065);
setSidebarInterface(9, 5715);
setSidebarInterface(10, 2449);
//setSidebarInterface(11, 4445); // wrench tab
setSidebarInterface(11, 904); // wrench tab
setSidebarInterface(12, 147); // run tab
setSidebarInterface(13, -1);
setSidebarInterface(0, 2423);
sendMessage("@dbl@Welcome to @dbl@E-Scape! There are currently @dre@"+PlayerHandler.getPlayerCount()+ " @dbl@players online.");
sendMessage("@dre@Latest Update: Godwars has been finished! ");
sendMessage("@dre@Type: @gre@::bandos ::zammy ::sara ::arma");
sendMessage("@whi@ Double Exp is currently: @dre@OFF");
sendMessage("EXP Lock Status: "+expLock+"");
if(checkVotes(playerName)) {
getItems().addItem(995, 10000000);
sendMessage("Thanks for voting! You have received 10m!");
}
getPA().showOption(4, 0,"Trade", 3);
getPA().showOption(5, 0,"Follow", 4);
getItems().resetItems(3214);
getItems().sendWeapon(playerEquipment[playerWeapon], getItems().getItemName(playerEquipment[playerWeapon]));
getItems().resetBonus();
getItems().getBonus();
getItems().writeBonus();
getItems().setEquipment(playerEquipment[playerHat],1,playerHat);
getItems().setEquipment(playerEquipment[playerCape],1,playerCape);
getItems().setEquipment(playerEquipment[playerAmulet],1,playerAmulet);
getItems().setEquipment(playerEquipment[playerArrows],playerEquipmentN[playerArrows],playerArrows);
getItems().setEquipment(playerEquipment[playerChest],1,playerChest);
getItems().setEquipment(playerEquipment[playerShield],1,playerShield);
getItems().setEquipment(playerEquipment[playerLegs],1,playerLegs);
getItems().setEquipment(playerEquipment[playerHands],1,playerHands);
getItems().setEquipment(playerEquipment[playerFeet],1,playerFeet);
getItems().setEquipment(playerEquipment[playerRing],1,playerRing);
getItems().setEquipment(playerEquipment[playerWeapon],playerEquipmentN[playerWeapon],playerWeapon);
getCombat().getPlayerAnimIndex(getItems().getItemName(playerEquipment[playerWeapon]).toLowerCase());
getPA().logIntoPM();
getItems().addSpecialBar(playerEquipment[playerWeapon]);
saveTimer = Config.SAVE_TIMER;
saveCharacter = true;
Misc.println("[REGISTERED]: "+playerName+"");
handler.updatePlayer(this, outStream);
handler.updateNPC(this, outStream);
flushOutStream();
getPA().clearClanChat();
getPA().resetFollow();
if (addStarter)
getPA().addStarter();
if (addStarter)
getPA().showInterface(3559);
canChangeAppearance = true;
if (autoRet == 1)
getPA().sendFrame36(172, 1);
else
getPA().sendFrame36(172, 0);
}
}
public void update() {
synchronized (this) {
handler.updatePlayer(this, outStream);
handler.updateNPC(this, outStream);
flushOutStream();
}
}
public void logout() {
synchronized (this) {
if(System.currentTimeMillis() - logoutDelay > 10000) {
outStream.createFrame(109);
properLogout = true;
} else {
sendMessage("You must wait 10 seconds before logging out.");
}
}
}
public int packetSize = 0, packetType = -1;
public int tradeTimer;
public void process() {
getPA().sendFrame126("Players Online: "+PlayerHandler.getPlayerCount()+ " ", 640); //quest journal title
getPA().sendFrame126("Player Statistics", 663); //quest title
getPA().sendFrame126("@gre@Kill Points", 7332); //quest title
getPA().sendFrame126(" @yel@"+magePoints+" ", 7333);
getPA().sendFrame126("@gre@Current Slayer Task", 7334); //quest title
if (taskAmount == 0) {
getPA().sendFrame126(" @yel@Nothing", 7336);
} else {
getPA().sendFrame126(" @yel@"+Server.npcHandler.getNpcListName(slayerTask)+" ", 7336); //quest title
}
getPA().sendFrame126("@gre@Amount Remaining", 7383); //quest title
getPA().sendFrame126(" @yel@"+taskAmount+" ", 7339); //quest title
getPA().sendFrame126("@gre@Kill / Death Ratio ", 7338); //quest title
getPA().sendFrame126(" @yel@Kills: "+KC+" ", 7340); //quest title
getPA().sendFrame126(" @yel@Deaths: "+DC+" ", 7346); //quest title
getPA().sendFrame126("", 7342); //quest title
getPA().sendFrame126(" ", 7337); //quest title
getPA().sendFrame126(" ", 7343); //quest title
getPA().sendFrame126(" ", 7335); //quest title
getPA().sendFrame126(" ", 7341); //quest title
getPA().sendFrame126(" ", 2831); //quest title
if (wcTimer > 0 && woodcut[0] > 0) {
wcTimer--;
} else if (wcTimer == 0 && woodcut[0] > 0) {
getWoodcutting().cutWood();
} else if (miningTimer > 0 && mining[0] > 0) {
miningTimer--;
} else if (miningTimer == 0 && mining[0] > 0) {
getMining().mineOre();
} else if (smeltTimer > 0 && smeltType > 0) {
smeltTimer--;
} else if (smeltTimer == 0 && smeltType > 0) {
getSmithing().smelt(smeltType);
} else if (fishing && fishTimer > 0) {
fishTimer--;
} else if (fishing && fishTimer == 0) {
getFishing().catchFish();
}
if (tradeTimer > 0) {
tradeTimer--;
}
if (absX == 3292 && absY == 3091 || absX == 3292 && absY == 3090) {
getPA().walkTo3(-130, -64);
}
if (absX == 3274 && absY == 3072 || absX == 3275 && absY == 3073) {
getPA().walkTo3(-130, -64);
}
if (absX == 3256 && absY == 3054 || absX == 3257 && absY == 3055) {
getPA().walkTo3(-130, -64);
}
if(clawDelay > 0) {
clawDelay--;
}
if(clawDelay == 1) {
double damage4 = 0;
if(npcIndex > 0) {
getCombat().applyNpcMeleeDamage(npcIndex, 1, previousDamage / 2);
}
if(playerIndex > 0) {
getCombat().applyPlayerMeleeDamage(playerIndex, 1, previousDamage / 2);
}
damage4 = previousDamage % 2;
if(damage4 >= 0.001) {
previousDamage = previousDamage + 1;
damage4 = 0;
}
if(npcIndex > 0) {
getCombat().applyNpcMeleeDamage(npcIndex, 2, previousDamage);
}
if(playerIndex > 0) {
getCombat().applyPlayerMeleeDamage(playerIndex, 2, previousDamage);
}
clawDelay = 0;
specEffect = 0;
previousDamage = 0;
usingClaws = false;
}
if (System.currentTimeMillis() - lastPoison > 20000 && poisonDamage > 0) {
int damage = poisonDamage/2;
if (damage > 0) {
sendMessage("You feel weakened by the poison.");
if (!getHitUpdateRequired()) {
setHitUpdateRequired(true);
setHitDiff(damage);
updateRequired = true;
poisonMask = 1;
} else if (!getHitUpdateRequired2()) {
setHitUpdateRequired2(true);
setHitDiff2(damage);
updateRequired = true;
poisonMask = 2;
}
lastPoison = System.currentTimeMillis();
poisonDamage--;
dealDamage(damage);
} else {
poisonDamage = -1;
sendMessage("The poison has faded away.");
}
}
if(System.currentTimeMillis() - duelDelay > 800 && duelCount > 0) {
if(duelCount != 1) {
forcedChat(""+(--duelCount));
duelDelay = System.currentTimeMillis();
} else {
damageTaken = new int[Config.MAX_PLAYERS];
forcedChat("FIGHT!");
duelCount = 0;
}
}
if(System.currentTimeMillis() - specDelay > Config.INCREASE_SPECIAL_AMOUNT) {
specDelay = System.currentTimeMillis();
if(specAmount < 10) {
specAmount += .5;
if (specAmount > 10)
specAmount = 10;
getItems().addSpecialBar(playerEquipment[playerWeapon]);
}
}
if(clickObjectType > 0 && goodDistance(objectX + objectXOffset, objectY + objectYOffset, getX(), getY(), objectDistance)) {
if(clickObjectType == 1) {
getActions().firstClickObject(objectId, objectX, objectY);
}
if(clickObjectType == 2) {
getActions().secondClickObject(objectId, objectX, objectY);
}
if(clickObjectType == 3) {
getActions().thirdClickObject(objectId, objectX, objectY);
}
}
if((clickNpcType > 0) && Server.npcHandler.npcs[npcClickIndex] != null) {
if(goodDistance(getX(), getY(), Server.npcHandler.npcs[npcClickIndex].getX(), Server.npcHandler.npcs[npcClickIndex].getY(), 1)) {
if(clickNpcType == 1) {
turnPlayerTo(Server.npcHandler.npcs[npcClickIndex].getX(), Server.npcHandler.npcs[npcClickIndex].getY());
Server.npcHandler.npcs[npcClickIndex].facePlayer(playerId);
getActions().firstClickNpc(npcType);
}
if(clickNpcType == 2) {
turnPlayerTo(Server.npcHandler.npcs[npcClickIndex].getX(), Server.npcHandler.npcs[npcClickIndex].getY());
Server.npcHandler.npcs[npcClickIndex].facePlayer(playerId);
getActions().secondClickNpc(npcType);
}
if(clickNpcType == 3) {
turnPlayerTo(Server.npcHandler.npcs[npcClickIndex].getX(), Server.npcHandler.npcs[npcClickIndex].getY());
Server.npcHandler.npcs[npcClickIndex].facePlayer(playerId);
getActions().thirdClickNpc(npcType);
}
}
}
if(walkingToItem) {
if(getX() == pItemX && getY() == pItemY || goodDistance(getX(), getY(), pItemX, pItemY,1)) {
walkingToItem = false;
Server.itemHandler.removeGroundItem(this, pItemId, pItemX, pItemY, true);
}
}
if(followId > 0) {
getPA().followPlayer();
} else if (followId2 > 0) {
getPA().followNpc();
}
getCombat().handlePrayerDrain();
if(System.currentTimeMillis() - singleCombatDelay > 3300) {
underAttackBy = 0;
}
if (System.currentTimeMillis() - singleCombatDelay2 > 3300) {
underAttackBy2 = 0;
}
if(System.currentTimeMillis() - restoreStatsDelay > 60000) {
restoreStatsDelay = System.currentTimeMillis();
for (int level = 0; level < playerLevel.length; level++) {
if (playerLevel[level] < getLevelForXP(playerXP[level])) {
if(level != 5) { // prayer doesn't restore
playerLevel[level] += 1;
getPA().setSkillLevel(level, playerLevel[level], playerXP[level]);
getPA().refreshSkill(level);
}
} else if (playerLevel[level] > getLevelForXP(playerXP[level])) {
playerLevel[level] -= 1;
getPA().setSkillLevel(level, playerLevel[level], playerXP[level]);
getPA().refreshSkill(level);
}
}
}
if(System.currentTimeMillis() - teleGrabDelay > 1550 && usingMagic) {
usingMagic = false;
if(Server.itemHandler.itemExists(teleGrabItem, teleGrabX, teleGrabY)) {
Server.itemHandler.removeGroundItem(this, teleGrabItem, teleGrabX, teleGrabY, true);
}
}
if(inWild()) {
int modY = absY > 6400 ? absY - 6400 : absY;
wildLevel = (((modY - 3520) / 8) + 1);
getPA().walkableInterface(197);
if(Config.SINGLE_AND_MULTI_ZONES) {
if(inMulti()) {
getPA().sendFrame126("@yel@Level: "+wildLevel, 199);
} else {
getPA().sendFrame126("@yel@Level: "+wildLevel, 199);
}
} else {
getPA().multiWay(-1);
getPA().sendFrame126("@yel@Level: "+wildLevel, 199);
}
getPA().showOption(3, 0, "Attack", 1);
} else if(inPcBoat()) {
getPA().walkableInterface(21119);
} else if(inPcGame()) {
getPA().walkableInterface(21100);
} else if (inDuelArena()) {
getPA().walkableInterface(201);
if(duelStatus == 5) {
getPA().showOption(3, 0, "Attack", 1);
} else {
getPA().showOption(3, 0, "Challenge", 1);
}
} else if(inBarrows()){
getPA().sendFrame99(2);
getPA().sendFrame126("Kill Count: "+barrowsKillCount, 4536);
getPA().walkableInterface(4535);
} else if (inCwGame || inPits) {
getPA().showOption(3, 0, "Attack", 1);
} else if (getPA().inPitsWait()) {
getPA().showOption(3, 0, "Null", 1);
}else if (!inCwWait) {
getPA().sendFrame99(0);
getPA().walkableInterface(-1);
getPA().showOption(3, 0, "Null", 1);
}
if(!hasMultiSign && inMulti()) {
hasMultiSign = true;
getPA().multiWay(1);
}
if(hasMultiSign && !inMulti()) {
hasMultiSign = false;
getPA().multiWay(-1);
}
if(skullTimer > 0) {
skullTimer--;
if(skullTimer == 1) {
isSkulled = false;
attackedPlayers.clear();
headIconPk = -1;
skullTimer = -1;
getPA().requestUpdates();
}
}
if(isDead && respawnTimer == -6) {
getPA().applyDead();
}
if(respawnTimer == 7) {
respawnTimer = -6;
getPA().giveLife();
} else if(respawnTimer == 12) {
respawnTimer--;
startAnimation(0x900);
poisonDamage = -1;
}
if(respawnTimer > -6) {
respawnTimer--;
}
if(freezeTimer > -6) {
freezeTimer--;
if (frozenBy > 0) {
if (Server.playerHandler.players[frozenBy] == null) {
freezeTimer = -1;
frozenBy = -1;
} else if (!goodDistance(absX, absY, Server.playerHandler.players[frozenBy].absX, Server.playerHandler.players[frozenBy].absY, 20)) {
freezeTimer = -1;
frozenBy = -1;
}
}
}
if(hitDelay > 0) {
hitDelay--;
}
if(teleTimer > 0) {
teleTimer--;
if (!isDead) {
if(teleTimer == 1 && newLocation > 0) {
teleTimer = 0;
getPA().changeLocation();
}
if(teleTimer == 5) {
teleTimer--;
getPA().processTeleport();
}
if(teleTimer == 9 && teleGfx > 0) {
teleTimer--;
if (teleGfx == 678) {
gfx0(teleGfx);
} else {
gfx100(teleGfx);
}
}
} else {
teleTimer = 0;
}
}
if(hitDelay == 1) {
if(oldNpcIndex > 0) {
getCombat().delayedHit(oldNpcIndex);
}
if(oldPlayerIndex > 0) {
getCombat().playerDelayedHit(oldPlayerIndex);
}
}
if(attackTimer > 0) {
attackTimer--;
}
if(attackTimer == 1){
if(npcIndex > 0 && clickNpcType == 0) {
getCombat().attackNpc(npcIndex);
}
if(playerIndex > 0) {
getCombat().attackPlayer(playerIndex);
}
} else if (attackTimer <= 0 && (npcIndex > 0 || playerIndex > 0)) {
if (npcIndex > 0) {
attackTimer = 0;
getCombat().attackNpc(npcIndex);
} else if (playerIndex > 0) {
attackTimer = 0;
getCombat().attackPlayer(playerIndex);
}
}
if(timeOutCounter > Config.TIMEOUT) {
disconnected = true;
}
timeOutCounter++;
if(inTrade && tradeResetNeeded){
Client o = (Client) Server.playerHandler.players[tradeWith];
if(o != null){
if(o.tradeResetNeeded){
getTradeAndDuel().resetTrade();
o.getTradeAndDuel().resetTrade();
}
}
}
}
public void setCurrentTask(Future<?> task) {
currentTask = task;
}
public Future<?> getCurrentTask() {
return currentTask;
}
public synchronized Stream getInStream() {
return inStream;
}
public synchronized int getPacketType() {
return packetType;
}
public synchronized int getPacketSize() {
return packetSize;
}
public synchronized Stream getOutStream() {
return outStream;
}
public ItemAssistant getItems() {
return itemAssistant;
}
public PlayerAssistant getPA() {
return playerAssistant;
}
public DialogueHandler getDH() {
return dialogueHandler;
}
public ShopAssistant getShops() {
return shopAssistant;
}
public TradeAndDuel getTradeAndDuel() {
return tradeAndDuel;
}
public CombatAssistant getCombat() {
return combatAssistant;
}
public ActionHandler getActions() {
return actionHandler;
}
public PlayerKilling getKill() {
return playerKilling;
}
public IoSession getSession() {
return session;
}
public Potions getPotions() {
return potions;
}
public PotionMixing getPotMixing() {
return potionMixing;
}
public Food getFood() {
return food;
}
/**
* Skill Constructors
*/
public Slayer getSlayer() {
return slayer;
}
public Runecrafting getRunecrafting() {
return runecrafting;
}
public Woodcutting getWoodcutting() {
return woodcutting;
}
public Mining getMining() {
return mine;
}
public Cooking getCooking() {
return cooking;
}
public Agility getAgility() {
return agility;
}
public Fishing getFishing() {
return fish;
}
public Crafting getCrafting() {
return crafting;
}
public Smithing getSmithing() {
return smith;
}
public Farming getFarming() {
return farming;
}
public Thieving getThieving() {
return thieving;
}
public Herblore getHerblore() {
return herblore;
}
public Firemaking getFiremaking() {
return firemaking;
}
public SmithingInterface getSmithingInt() {
return smithInt;
}
public Prayer getPrayer() {
return prayer;
}
public Fletching getFletching() {
return fletching;
}
/**
* End of Skill Constructors
*/
public void queueMessage(Packet arg1) {
synchronized(queuedPackets) {
//if (arg1.getId() != 41)
queuedPackets.add(arg1);
//else
//processPacket(arg1);
}
}
public synchronized boolean processQueuedPackets() {
Packet p = null;
synchronized(queuedPackets) {
p = queuedPackets.poll();
}
if(p == null) {
return false;
}
inStream.currentOffset = 0;
packetType = p.getId();
packetSize = p.getLength();
inStream.buffer = p.getData();
if(packetType > 0) {
//sendMessage("PacketType: " + packetType);
PacketHandler.processPacket(this, packetType, packetSize);
}
timeOutCounter = 0;
return true;
}
public synchronized boolean processPacket(Packet p) {
synchronized (this) {
if(p == null) {
return false;
}
inStream.currentOffset = 0;
packetType = p.getId();
packetSize = p.getLength();
inStream.buffer = p.getData();
if(packetType > 0) {
//sendMessage("PacketType: " + packetType);
PacketHandler.processPacket(this, packetType, packetSize);
}
timeOutCounter = 0;
return true;
}
}
public void correctCoordinates() {
if (inPcGame()) {
getPA().movePlayer(2657, 2639, 0);
}
if (inFightCaves()) {
getPA().movePlayer(absX, absY, playerId * 4);
sendMessage("Your wave will start in 10 seconds.");
EventManager.getSingleton().addEvent(new Event() {
public void execute(EventContainer c) {
Server.fightCaves.spawnNextWave((Client)Server.playerHandler.players[playerId]);
c.stop();
}
}, 10000);
}
}
public void StartBestItemScan() {
if (isSkulled && !prayerActive[10]) {
ItemKeptInfo(0);
return;
}
FindItemKeptInfo();
ResetKeepItems();
BestItem1();
}
public void BestItem1() {
int BestValue = 0;
int NextValue = 0;
int ItemsContained = 0;
WillKeepItem1 = 0;
WillKeepItem1Slot = 0;
for (int ITEM = 0; ITEM < 28; ITEM++) {
if (playerItems[ITEM] > 0) {
ItemsContained += 1;
NextValue = (int) Math.floor(getShops().getItemShopValue(playerItems[ITEM] - 1));
if (NextValue > BestValue) {
BestValue = NextValue;
WillKeepItem1 = playerItems[ITEM] - 1;
WillKeepItem1Slot = ITEM;
if ((playerItemsN[ITEM] > 2) && !prayerActive[10]) {
WillKeepAmt1 = 3;
} else if ((playerItemsN[ITEM] > 3) && prayerActive[10]) {
WillKeepAmt1 = 4;
} else {
WillKeepAmt1 = playerItemsN[ITEM];
}
}
}
}
for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
if (playerEquipment[EQUIP] > 0) {
ItemsContained += 1;
NextValue = (int) Math.floor(getShops().getItemShopValue(playerEquipment[EQUIP]));
if (NextValue > BestValue) {
BestValue = NextValue;
WillKeepItem1 = playerEquipment[EQUIP];
WillKeepItem1Slot = EQUIP + 28;
if ((playerEquipmentN[EQUIP] > 2) && !prayerActive[10]) {
WillKeepAmt1 = 3;
} else if ((playerEquipmentN[EQUIP] > 3) && prayerActive[10]) {
WillKeepAmt1 = 4;
} else {
WillKeepAmt1 = playerEquipmentN[EQUIP];
}
}
}
}
if (!isSkulled && (ItemsContained > 1) && ((WillKeepAmt1 < 3) || (prayerActive[10] && (WillKeepAmt1 < 4)))) {
BestItem2(ItemsContained);
}
}
public void BestItem2(int ItemsContained) {
int BestValue = 0;
int NextValue = 0;
WillKeepItem2 = 0;
WillKeepItem2Slot = 0;
for (int ITEM = 0; ITEM < 28; ITEM++) {
if (playerItems[ITEM] > 0) {
NextValue = (int) Math.floor(getShops().getItemShopValue(playerItems[ITEM] - 1));
if ((NextValue > BestValue) && !((ITEM == WillKeepItem1Slot) && (playerItems[ITEM] - 1 == WillKeepItem1))) {
BestValue = NextValue;
WillKeepItem2 = playerItems[ITEM] - 1;
WillKeepItem2Slot = ITEM;
if ((playerItemsN[ITEM] > 2 - WillKeepAmt1) && !prayerActive[10]) {
WillKeepAmt2 = 3 - WillKeepAmt1;
} else if ((playerItemsN[ITEM] > 3 - WillKeepAmt1) && prayerActive[10]) {
WillKeepAmt2 = 4 - WillKeepAmt1;
} else {
WillKeepAmt2 = playerItemsN[ITEM];
}
}
}
}
for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
if (playerEquipment[EQUIP] > 0) {
NextValue = (int) Math.floor(getShops().getItemShopValue(playerEquipment[EQUIP]));
if ((NextValue > BestValue) && !((EQUIP + 28 == WillKeepItem1Slot) && (playerEquipment[EQUIP] == WillKeepItem1))) {
BestValue = NextValue;
WillKeepItem2 = playerEquipment[EQUIP];
WillKeepItem2Slot = EQUIP + 28;
if ((playerEquipmentN[EQUIP] > 2 - WillKeepAmt1) && !prayerActive[10]) {
WillKeepAmt2 = 3 - WillKeepAmt1;
} else if ((playerEquipmentN[EQUIP] > 3 - WillKeepAmt1) && prayerActive[10]) {
WillKeepAmt2 = 4 - WillKeepAmt1;
} else {
WillKeepAmt2 = playerEquipmentN[EQUIP];
}
}
}
}
if (!isSkulled && (ItemsContained > 2) && ((WillKeepAmt1 + WillKeepAmt2 < 3) || (prayerActive[10] && (WillKeepAmt1 + WillKeepAmt2 < 4)))) {
BestItem3(ItemsContained);
}
}
public void BestItem3(int ItemsContained) {
int BestValue = 0;
int NextValue = 0;
WillKeepItem3 = 0;
WillKeepItem3Slot = 0;
for (int ITEM = 0; ITEM < 28; ITEM++) {
if (playerItems[ITEM] > 0) {
NextValue = (int) Math.floor(getShops().getItemShopValue(playerItems[ITEM] - 1));
if ((NextValue > BestValue) && !((ITEM == WillKeepItem1Slot) && (playerItems[ITEM] - 1 == WillKeepItem1)) && !((ITEM == WillKeepItem2Slot) && (playerItems[ITEM] - 1 == WillKeepItem2))) {
BestValue = NextValue;
WillKeepItem3 = playerItems[ITEM] - 1;
WillKeepItem3Slot = ITEM;
if ((playerItemsN[ITEM] > 2 - (WillKeepAmt1 + WillKeepAmt2)) && !prayerActive[10]) {
WillKeepAmt3 = 3 - (WillKeepAmt1 + WillKeepAmt2);
} else if ((playerItemsN[ITEM] > 3 - (WillKeepAmt1 + WillKeepAmt2)) && prayerActive[10]) {
WillKeepAmt3 = 4 - (WillKeepAmt1 + WillKeepAmt2);
} else {
WillKeepAmt3 = playerItemsN[ITEM];
}
}
}
}
for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
if (playerEquipment[EQUIP] > 0) {
NextValue = (int) Math.floor(getShops().getItemShopValue(playerEquipment[EQUIP]));
if ((NextValue > BestValue) && !((EQUIP + 28 == WillKeepItem1Slot) && (playerEquipment[EQUIP] == WillKeepItem1)) && !((EQUIP + 28 == WillKeepItem2Slot) && (playerEquipment[EQUIP] == WillKeepItem2))) {
BestValue = NextValue;
WillKeepItem3 = playerEquipment[EQUIP];
WillKeepItem3Slot = EQUIP + 28;
if ((playerEquipmentN[EQUIP] > 2 - (WillKeepAmt1 + WillKeepAmt2)) && !prayerActive[10]) {
WillKeepAmt3 = 3 - (WillKeepAmt1 + WillKeepAmt2);
} else if ((playerEquipmentN[EQUIP] > 3 - WillKeepAmt1) && prayerActive[10]) {
WillKeepAmt3 = 4 - (WillKeepAmt1 + WillKeepAmt2);
} else {
WillKeepAmt3 = playerEquipmentN[EQUIP];
}
}
}
}
if (!isSkulled && (ItemsContained > 3) && prayerActive[10] && ((WillKeepAmt1 + WillKeepAmt2 + WillKeepAmt3) < 4)) {
BestItem4();
}
}
public void BestItem4() {
int BestValue = 0;
int NextValue = 0;
WillKeepItem4 = 0;
WillKeepItem4Slot = 0;
for (int ITEM = 0; ITEM < 28; ITEM++) {
if (playerItems[ITEM] > 0) {
NextValue = (int) Math.floor(getShops().getItemShopValue(playerItems[ITEM] - 1));
if ((NextValue > BestValue) && !((ITEM == WillKeepItem1Slot) && (playerItems[ITEM] - 1 == WillKeepItem1)) && !((ITEM == WillKeepItem2Slot) && (playerItems[ITEM] - 1 == WillKeepItem2)) && !((ITEM == WillKeepItem3Slot) && (playerItems[ITEM] - 1 == WillKeepItem3))) {
BestValue = NextValue;
WillKeepItem4 = playerItems[ITEM] - 1;
WillKeepItem4Slot = ITEM;
}
}
}
for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
if (playerEquipment[EQUIP] > 0) {
NextValue = (int) Math.floor(getShops().getItemShopValue(playerEquipment[EQUIP]));
if ((NextValue > BestValue) && !((EQUIP + 28 == WillKeepItem1Slot) && (playerEquipment[EQUIP] == WillKeepItem1)) && !((EQUIP + 28 == WillKeepItem2Slot) && (playerEquipment[EQUIP] == WillKeepItem2)) && !((EQUIP + 28 == WillKeepItem3Slot) && (playerEquipment[EQUIP] == WillKeepItem3))) {
BestValue = NextValue;
WillKeepItem4 = playerEquipment[EQUIP];
WillKeepItem4Slot = EQUIP + 28;
}
}
}
}
public void ItemKeptInfo(int Lose) {
for (int i = 17109; i < 17131; i++) {
getPA().sendFrame126("", i);
}
getPA().sendFrame126("Items you will keep on death:", 17104);
getPA().sendFrame126("Items you will lose on death:", 17105);
getPA().sendFrame126("E-Scape", 17106);
getPA().sendFrame126("Max items kept on death:", 17107);
getPA().sendFrame126("~ " + Lose + " ~", 17108);
getPA().sendFrame126("The normal amount of", 17111);
getPA().sendFrame126("items kept is three.", 17112);
switch (Lose) {
case 0 :
default :
getPA().sendFrame126("Items you will keep on death:", 17104);
getPA().sendFrame126("Items you will lose on death:", 17105);
getPA().sendFrame126("You're marked with a", 17111);
getPA().sendFrame126("@red@skull. @lre@This reduces the", 17112);
getPA().sendFrame126("items you keep from", 17113);
getPA().sendFrame126("three to zero!", 17114);
break;
case 1 :
getPA().sendFrame126("Items you will keep on death:", 17104);
getPA().sendFrame126("Items you will lose on death:", 17105);
getPA().sendFrame126("You're marked with a", 17111);
getPA().sendFrame126("@red@skull. @lre@This reduces the", 17112);
getPA().sendFrame126("items you keep from", 17113);
getPA().sendFrame126("three to zero!", 17114);
getPA().sendFrame126("However, you also have", 17115);
getPA().sendFrame126("the @red@Protect @lre@Items prayer", 17116);
getPA().sendFrame126("active, which saves you", 17117);
getPA().sendFrame126("one extra item!", 17118);
break;
case 3 :
getPA().sendFrame126("Items you will keep on death(if not skulled):", 17104);
getPA().sendFrame126("Items you will lose on death(if not skulled):", 17105);
getPA().sendFrame126("You have no factors", 17111);
getPA().sendFrame126("affecting the items you", 17112);
getPA().sendFrame126("keep.", 17113);
break;
case 4 :
getPA().sendFrame126("Items you will keep on death(if not skulled):", 17104);
getPA().sendFrame126("Items you will lose on death(if not skulled):", 17105);
getPA().sendFrame126("You have the @red@Protect", 17111);
getPA().sendFrame126("@red@Item @lre@prayer active,", 17112);
getPA().sendFrame126("which saves you one", 17113);
getPA().sendFrame126("extra item!", 17114);
break;
case 5 :
getPA().sendFrame126("Items you will keep on death(if not skulled):", 17104);
getPA().sendFrame126("Items you will lose on death(if not skulled):", 17105);
getPA().sendFrame126("@red@You are in a @red@Dangerous", 17111);
getPA().sendFrame126("@red@Zone, and will lose all", 17112);
getPA().sendFrame126("@red@if you die.", 17113);
getPA().sendFrame126("", 17114);
break;
}
}
public void ResetKeepItems() {
WillKeepItem1 = 0;
WillKeepItem1Slot = 0;
WillKeepItem2 = 0;
WillKeepItem2Slot = 0;
WillKeepItem3 = 0;
WillKeepItem3Slot = 0;
WillKeepItem4 = 0;
WillKeepItem4Slot = 0;
WillKeepAmt1 = 0;
WillKeepAmt2 = 0;
WillKeepAmt3 = 0;
}
public void FindItemKeptInfo() {
if (isSkulled && prayerActive[10]) {
ItemKeptInfo(1);
} else if (!isSkulled && !prayerActive[10]) {
ItemKeptInfo(3);
} else if (!isSkulled && prayerActive[10]) {
ItemKeptInfo(4);
} else if (inPits || inFightCaves()) {
ItemKeptInfo(5);
}
}
}
If anyone could help rather than laughing because it's simple, that would be great.