Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 137.26 KB | None | 0 0
  1. /*
  2.  * Class Player
  3.  *
  4.  * Version 1.0
  5.  *
  6.  * Thursday, August 14, 2008
  7.  *
  8.  * Created by Palidino76 Codeusa
  9.  */
  10.  
  11. package net.com.codeusa.model;
  12.  
  13. import java.io.FileWriter;
  14. import java.io.BufferedReader;
  15. import java.io.BufferedWriter;
  16. import java.io.FileReader;
  17. import java.io.IOException;
  18. import java.net.Socket;
  19. import java.util.*;
  20. import java.lang.*;
  21. import net.com.codeusa.util.UserInput;
  22. import net.com.codeusa.test.TestWorldLoader;
  23. import net.com.codeusa.model.misc.*;
  24. import net.com.codeusa.model.combat.*;
  25. import net.com.codeusa.*;
  26. import net.com.codeusa.io.*;
  27. import net.com.codeusa.net.PlayerSocket;
  28. import net.com.codeusa.util.ByteVector;
  29. import net.com.codeusa.util.Misc;
  30. import net.com.codeusa.npcs.NPC;
  31. import net.com.codeusa.model.items.*;
  32. import net.com.codeusa.model.PlayerSave;
  33. import net.com.codeusa.event.*;
  34. import net.com.codeusa.net.packethandler.MagicOnPlayer;
  35. import net.com.codeusa.model.items.PlayerWeapon;
  36. import net.com.codeusa.content.*;
  37.  
  38. public class Player implements Entity {
  39.  
  40.     public UserInput input = new UserInput(this);
  41.     public int buryDelay = 0;
  42.     public boolean noteItems = false;
  43.     public int poisonTicks;
  44.     public List<Long> friends = new ArrayList<Long>(200);
  45.     public boolean spellCharged;
  46.     public List<Long> ignores = new ArrayList<Long>(100);
  47.     public int autocastSpell = 0;
  48.     public boolean autocast = false;
  49.     public int stunned;
  50.     public int autocastSpellbook = 0;
  51.     public boolean maging;
  52.     public boolean hitOne;
  53.     public int count;
  54.     public boolean usedLogout;
  55.     public boolean switching;
  56.     public boolean hitTwo;
  57.     public boolean hitThree;
  58.     public boolean hitFour;
  59.     public double hit1;
  60.     public double hit2;
  61.     public double hit3;
  62.     public double hit4;
  63.     public int specials;
  64.     public int alchDelay = 0;
  65.     public long stairsDelay = System.currentTimeMillis();
  66.     public long picklockDelay = System.currentTimeMillis();
  67.     public double rangedMax;
  68.     public String OriginalAttacker;
  69.     public int startChatting;
  70.     public int attackedByCount;
  71.     public String attacking;
  72.     public String attackedBy;
  73.     public int spell;
  74.     public int spell2;
  75.     public int cuedSpell;
  76.     public int cuedSpells;
  77.     public int magicOppIndex;
  78.     public int graphicMSDelay;
  79.     public int magicGraphicDelay = -1;
  80.     public int magicDamageDelay = -1;
  81.     public int magicAffectDelay = -1;
  82.     public int[] ikod = new int[3];
  83.     public boolean successfulCast;
  84.     public boolean usingMage;
  85.     public boolean orb;
  86.     public int weapon;
  87.     public int strengthBonus;
  88.     public int oppIndex;
  89.     public int hitIndex;
  90.     public boolean getExperience = true;
  91.     public int NPCspecDelay = -1;
  92.     public int secondNPCSpecDelay = -1;
  93.     public int damageNPCDelay = -1;
  94.     public int combatNPCDelay = -1;
  95.     public int rangeNPCDmgDelay;
  96.     public int rangeNPCDmgDelay2;
  97.     public int lastIndex;
  98.     public int justSwitched;
  99.     public boolean alreadyAttacked;
  100.     public boolean bountyInterface = false;
  101.     public int BhTimer;
  102.     public int teleMenu;
  103.     public int leftBhTimer = 0;
  104.     public int attackedByNpcCount;
  105.     public int bhPickup;
  106.     public int optionId;
  107.     public int bhLeave;
  108.     public int shops;
  109.     public int checking;
  110.     public int getIndex;
  111.     public int waitShit;
  112.     public int bhTarget = 0;
  113.     public int switchSpells = 0;
  114.     public int fleeTimer = 0;
  115.     public int bhLeave1;
  116.     public int amount;
  117.     public boolean inBounty = false;
  118.     public int serverMsg;
  119.     public int skullId;
  120.     public int pickedUp;
  121.     public int InBounty = 0;
  122.     public transient int hitDelay = 0;
  123.     public int direction = 0;
  124.     public int followPlayer;
  125.     public boolean followingPlayer;
  126.     public int playFollow;
  127.     public boolean DFSSpecial;
  128.     public long lastDFS;
  129.     public int DFSDelay = -1;
  130.     public int points = 0; //bandos
  131.     public int apoints = 0; //armadyl
  132.     public int spoints = 0; //saradomin
  133.     public int zpoints = 0; //zamorak  
  134.     public boolean wildWarned = false;
  135.     public boolean swapAsNote = false;
  136.     public boolean initialAttack;
  137.     public int attackedInSingle;
  138.     public int PlayerItems;
  139.     public boolean dboltspecial;
  140.     public boolean diamondboltspecial;
  141.     public boolean morriganjavs;
  142.     public boolean morriganaxes;
  143.     public String nameSet;
  144.     public int setDrop;
  145.     public int KC;
  146.     public int DC;
  147.     public int summoningon = 0;
  148.     public boolean underAttack = false;
  149.     public boolean inWild = false;
  150.     public boolean safed = false;
  151.     public boolean summoning = false;
  152.     public String chatName;
  153.     public final String ACTIVE_CHAT_DEFAULT = "Reborn525";
  154.     public String activeChat = ACTIVE_CHAT_DEFAULT;
  155.     public final String ACTIVE_CHAT_OWNER_DEFAULT = "Public Channel";
  156.     public String activeChatOwner = ACTIVE_CHAT_OWNER_DEFAULT;
  157.     public double bhkills;
  158.     public int totalKills;
  159.     public int kills;
  160.     public boolean teleblocked;
  161.     public int teleblockTimer;
  162.     public boolean teletab;
  163.     public int leverTeleportX;
  164.     public int leverTeleportY;
  165.     public int totalDamageRecoiled;
  166.     public int leverTeleportH;
  167.     public int leverTeleportDelay = -1;
  168.     public boolean lever;
  169.     public int Donator;
  170.     public int miasmicSpell;
  171.     public int myBonus;
  172.     public int meleeDef;
  173.     public int waitDeathDelay = -1;
  174.     public boolean randomVariable;
  175.     public int deathDelay = -1;
  176.     public boolean isDead;
  177.     public int specDelay = -1;
  178.     public boolean specdeleh;
  179.     public int secondSpecDelay = -1;
  180.     public int delayedDamageDelay = -1;
  181.     public int delayedDamageHit = -1;
  182.     public boolean expectSpec;
  183.     public boolean autoRetaliate = false;
  184.     public int specFillDelay = 50;
  185.     public boolean usingSpecial;
  186.     public int specAmount;
  187.     public int damageDelay;
  188.     public boolean damagePending;
  189.     public int combatDelay;
  190.     public int enemyIndex;
  191.     public boolean attackingPlayer;
  192.     public int freezeDelay;
  193.     public int vengeanceDelay;
  194.     public int lunarDelay;
  195.     public boolean vengeance;
  196.     public int spellbookSwapTimer;
  197.     public boolean spellbookSwap;
  198.     public boolean usedSpellbookSwap;
  199.     public int mageDelay;
  200.     public boolean fadeAway;
  201.     public int enemyFadeAwayDelay = -1;
  202.     public int fightStyle = 1;
  203.     public int headIconSkull = -1;
  204.     public boolean isSkulled;
  205.     public int skullVanishDelay;
  206.     public int rangeDmgDelay = -1;
  207.     public int rangeDmgDelay2 = -1;
  208.     public boolean timerStarted;
  209.     public long PVPTimer;
  210.     public boolean timerStarted2;
  211.     public int wildTimer = 0;
  212.     public int wildLevel;
  213.     public boolean updatedLevel;
  214.     public int savedLevel;
  215.     public int maxArrays = 10;
  216.     public boolean[] optionArray = new boolean[maxArrays];
  217.     public TestWorldLoader worldLoader = new TestWorldLoader(this);
  218.     public int nextDamageDelay = -1;
  219.     public int nextGraphicDelay = -1;
  220.     public int wildernessLevel;
  221.     public int autoCastDmgDelay = -1;
  222.     public int autoCastDelay;
  223.     public int[] autoCast = new int[3];
  224.     public boolean castAuto;
  225.     public boolean usingAutoCast;
  226.     public boolean disturbSara;
  227.     public int deathEmoteDelay = -1;
  228.     public int crystalShots;
  229.     public int equipSpecDelay;
  230.     public boolean isBanking;
  231.     public int[] godWarsKills = new int[5];
  232.     public int watchId = -1;
  233.     public int spellType;
  234.     public int playerStart;
  235.     public boolean muteExpect, muteExpect2;
  236.     public int muteType;
  237.     public int mute;
  238.     public int slayerAmount1;
  239.     public int slayerType1;
  240.     public int slayerAmount;
  241.     public int damageSpecDelay = -1;
  242.     public boolean enableSpecDamage;
  243.     public int damageDelay1 = -1;
  244.     public boolean enableDamage;
  245.     public int atkDelay;
  246.     public boolean attackingNpc;
  247.     public int attackNpc;
  248.     public int npcClick2;
  249.     public int wildyLevel;
  250.     public int statDelay = 100;
  251.     public int hpDelay = 100;
  252.     public int animClickDelay;
  253.     public boolean usingPrayer;
  254.     public int drainDelay;
  255.     public boolean rangedPrayer;
  256.     public boolean meleePrayer;
  257.     public boolean magicPrayer;
  258.     public boolean retriPrayer;
  259.     public boolean redempPrayer;
  260.     public int slayerTask;
  261.     public int headIconPrayer = -1;
  262.     public double drainCount = 0;
  263.     public int playerId = 0;
  264.     public ByteVector stream = new ByteVector(500, 5000);
  265.     public PlayerSocket socket;
  266.     public boolean online = false;
  267.     public String username = "null";
  268.     public String password = "";
  269.     public int rights = 0;
  270.     public int jailed = 0;
  271.     public int starter = 0;
  272.     public boolean[] disconnected = new boolean[2];
  273.     public int mapRegionX = 0;
  274.     public int mapRegionY = 0;
  275.     public int currentX = 0;
  276.     public int currentY = 0;
  277.     public int absX = 0;
  278.     public int absY = 0;
  279.     public int heightLevel = 0;
  280.     public int spellbook = 192;
  281.     public int walkDir = -1;
  282.     public int runDir = -1;
  283.     public boolean isRunning = false;
  284.     public boolean mapRegionDidChange = false;
  285.     public boolean didTeleport = false;
  286.     public int teleportToX = -1;
  287.     public int teleportToY = -1;
  288.     public boolean updateReq = false;
  289.     public int walkingQueueSize = 50;
  290.     public int wQueueReadPtr = 0;
  291.     public int wQueueWritePtr = 0;
  292.     public int[] walkingQueueX = new int[walkingQueueSize];
  293.     public int[] walkingQueueY = new int[walkingQueueSize];
  294.     public int[] walkingQueue = new int[walkingQueueSize];
  295.     public Player[] playerList = new Player[Engine.players.length];
  296.     public byte[] playersInList = new byte[Engine.players.length];
  297.     public int playerListSize = 0;
  298.     public boolean chatTextUpdateReq = false;
  299.     public String chatText = "";
  300.     public int chatTextEffects = 0;
  301.     public boolean appearanceUpdateReq = false;
  302.     public boolean animUpdateReq = false;
  303.     public int animReq = -1;
  304.     public int animDelay = 0;
  305.     public boolean gfxUpdateReq = false;
  306.     public int gfxReq = -1;
  307.     public int gfxDelay = 0;
  308.     public boolean faceToUpdateReq = false;
  309.     public int faceToReq = -1;
  310.     public boolean hit1UpdateReq = false;
  311.     public boolean hit2UpdateReq = false;
  312.     public int hitDiff1 = 0;
  313.     public int hitDiff2 = 0;
  314.     public int poisonHit1 = 0;
  315.     public int poisonHit2 = 0;
  316.     public int[] skillLvl = new int[25];
  317.     public int[] skillXP = new int[25];
  318.     public int combatLevel = 0;
  319.     public int[] equipment = new int[14];
  320.     public int[] equipmentN = new int[14];
  321.     public int[] equipmentBonus = new int[12];
  322.     public int[] color = new int[5];
  323.     public int[] look = new int[7];
  324.     public int npcType = -1;
  325.     public int gender = 0;
  326.     public int runEmote = 0x338;
  327.     public int walkEmote = 0x333;
  328.     public int standEmote = 0x328;
  329.     public NPC[] npcList = new NPC[Engine.npcs.length];
  330.     public byte[] npcsInList = new byte[Engine.npcs.length];
  331.     public int npcListSize = 0;
  332.     public boolean rebuildNPCList = false;
  333.     public int[] items = new int[28];
  334.     public int[] itemsN = new int[28];
  335.     public int interfaceId = -1;
  336.     public int chatboxInterfaceId = -1;
  337.     public int loginStage = 0;
  338.     public int clickX = 0;
  339.     public int clickY = 0;
  340.     public int clickId = 0;
  341.     public int eatDelay;
  342.     public int drinkDelay;
  343.     public boolean itemPickup = false;
  344.     public boolean runEnergyUpdateReq = false;
  345.     public int runEnergy = 100;
  346.     public int runEnergyDelay = 0;
  347.     public boolean playerOption1 = false;
  348.     public boolean playerOption2 = false;
  349.     public boolean playerOption3 = false;
  350.     public boolean npcOption1 = false;
  351.     public boolean objectOption1 = false;
  352.     public PrayerSystem prayerSystem = new PrayerSystem(this);
  353.     public PlayerWeapon playerWeapon = new PlayerWeapon(this);
  354.     public boolean objectOption2 = false;
  355.     public boolean npcOption2 = false;
  356.     public String forceChat = "";
  357.     public boolean forceChatUpdateReq = false;
  358.     public int teleX = -1;
  359.     public int teleY = -1;
  360.     public int teleH = -1;
  361.     public int teleDelay = -1;
  362.     public int teleFinishGFX = 0;
  363.     public int teleFinishGFXHeight = 0;
  364.     public int teleFinishAnim = 0;
  365.     public int clickDelay = -1;
  366.     public long loginTimeout = System.currentTimeMillis();
  367.     public int[] bankItems = new int[500];
  368.     public int[] bankItemsN = new int[500];
  369.     public double immunityTimer;
  370.     public int logoutTimer;
  371.     public int restoreSpecialTimer;
  372.     public String attackedByNpc;
  373.  
  374.     public void spellCharging(final Player p) {
  375.         EventManager.getSingleton().addEvent(
  376.                 new Event() {
  377.                     public void execute(EventContainer c) {
  378.                         p.spellCharged = false;
  379.                         p.message("Your charge on your godspells has ended.");
  380.                         c.stop();
  381.                     }
  382.                 }, 300000);
  383.     };
  384.  
  385.     public boolean npcHitPlayerRange(NPC n) {  
  386.         return Math.random() <= npcRangeAccuracy(n);
  387.     }
  388.  
  389.     public boolean hitNPC(NPC n) {
  390.         return Math.random() <= npcMeleeAccuracy(n);
  391.     }
  392.  
  393.     public void setShop(Player p, int shopId) {
  394.         ShopHandler sh = new ShopHandler();
  395.         p.getActionSender().removeShownInterface(p);
  396.         getActionSender().showInterface(p, 620);
  397.         getActionSender().setInventory(p, 621);
  398.         getActionSender().setTab(p, 80, 621);
  399.         Object[] setshopparams = new Object[]{shopId, 93};
  400.         int shi = 621 << 16;
  401.         int ship = (620 << 16) + 24;
  402.         Object[] invparams = new Object[]{"", "", "", "", "Sell X", "Sell 10", "Sell 5", "Sell 1", "Value", -1, 0, 7, 4, 93, shi};
  403.         Object[] shopparams = new Object[]{"", "", "", "", "Buy X", "Buy 10", "Buy 5", "Buy 1", "Value", -1, 0, 4, 10, 31, ship};
  404.         getActionSender().runScript(p, 25, setshopparams, "vg");
  405.         getActionSender().runScript(p, 150, invparams, "IviiiIsssssssss");
  406.         getActionSender().runScript(p, 150, shopparams, "IviiiIsssssssss");
  407.         getActionSender().setAccessMask(p, 1278, 0, 621, 0, 28);
  408.         getActionSender().setInterfaceConfig(p, 620, 23, true);
  409.         getActionSender().setInterfaceConfig(p, 620, 24, false);
  410.         getActionSender().setInterfaceConfig(p, 620, 29, true);
  411.         getActionSender().setInterfaceConfig(p, 620, 25, false);
  412.         getActionSender().setInterfaceConfig(p, 620, 27, false);
  413.         getActionSender().setInterfaceConfig(p, 620, 26, true);
  414.         getActionSender().setAccessMask(p, 1278, 24, 620, 0, 40);
  415.     }
  416.     public double npcMeleeAccuracy(NPC n) {
  417.         if (n == null || this.isDead || n.isDead || this.disconnected[0]) {
  418.             return 1;
  419.         }
  420.         double attack = skillLvl[0];
  421.         int activeAttackBonus = weaponStyle(equipment[3]) - 1;
  422.         int activeDefenceBonus = activeAttackBonus + 5;
  423.         double attackBonus = equipmentBonus[activeAttackBonus];
  424.         if (usingPrayer(2)) {
  425.             attack *= 1.05;
  426.         }
  427.         if (usingPrayer(7)) {
  428.             attack *= 1.10;
  429.         }
  430.         if (usingPrayer(15)) {
  431.             attack *= 1.15;
  432.         }
  433.         if (usingPrayer(25)) {
  434.             attack *= 1.15;
  435.         }
  436.         if (usingPrayer(26)) {
  437.             attack *= 1.20;
  438.         }
  439.         if (attackStyle() == 4) {
  440.             attack += 1;
  441.         }
  442.         if (attackStyle() == 1) {
  443.             attack += 3;
  444.         }
  445.         if (attackBonus < 0) {
  446.             attackBonus = 0;
  447.         }
  448.         if (defile) {
  449.         }
  450.         double offensiveAttribute = (attack * 1.5) + attackBonus;
  451.         double difference = Math.abs(offensiveAttribute);
  452.         boolean positive = true;
  453.         double interval = difference * 0.0015;
  454.         double percentage = 0.55;
  455.         if (!positive) {
  456.             percentage -= interval;
  457.         }
  458.         if (positive) {
  459.             percentage += interval;
  460.         }
  461.         if (accuracy != 1) {
  462.             percentage *= accuracy;
  463.             accuracy = 1;
  464.         }
  465.         return percentage;
  466.     }
  467.  
  468.     public double npcRangeAccuracy(NPC n) {
  469.         if (n == null || this.isDead || n.isDead || this.disconnected[0]) {
  470.             return 1;
  471.         }
  472.         double range = skillLvl[4];
  473.         double rangeBonus = equipmentBonus[4];
  474.         if (usingPrayer(3)) {
  475.             range *= 1.05;
  476.         }
  477.         if (usingPrayer(11)) {
  478.             range *= 1.10;
  479.         }
  480.         if (usingPrayer(20)) {
  481.             range *= 1.15;
  482.         }
  483.         if (attackStyle() == 5) {
  484.             range += 1;
  485.         }
  486.         if (rangeBonus < 0) {
  487.             rangeBonus = 0;
  488.         }
  489.         double offensiveAttribute = range + rangeBonus;
  490.         double difference = Math.abs(offensiveAttribute);
  491.         boolean positive = true;
  492.         double interval = difference * 0.00175;
  493.         double percentage = 0.50;
  494.         if (!positive) {
  495.             percentage -= interval;
  496.         }
  497.         if (positive) {
  498.             percentage += interval;
  499.         }
  500.         if (accuracy != 1) {
  501.             percentage *= accuracy;
  502.             accuracy = 1;
  503.         }
  504.         return percentage;
  505.     }
  506.  
  507.     String[][] itemPrices = {{"Warrior helm", "536"}, {"Purple sweets", "12"}, {"Armadyl godsword", "1500000"}, {"Statius's warhammer", "50000"}, {"Dragon med helm", "605"}, {"Statius's platelegs", "0"}, {"Statius's full helm", "0"}, {"Statius's platebody", "0"},  {"Black dragonhide", "33"}, {"Dragon med helm", "605"}, {"Vesta's longsword", "0"},  {"Dragon bones", "30"}, {"Enchanted robe", "495"}, {"Dragonfire shield", "212000"}, {"Mystic robe top", "720"}, {"Enchanted top", "741"}, {"Enchanted hat", "89"}, {"Adamant knife", "2"}, {"Adamant knife(p)", "4"}, {"Draconic visage", "217000"}, {"Mystic hat", "92"},{"Mystic robe bottom", "480"}, {"Mystic boots", "59"}, {"Mystic gloves", "59"}, {"Adamant knife(p+)", "5"}, {"Adamant knife(p++)", "13"}, {"Adamant dart", "1"}, {"Adamant dart(p)", "3"}, {"Adamant dart(p+)", "4"}, {"Adamant dart(p++)", "12"}, {"Tzhaar-ket-em", "891"}, {"Barrelchest anchor", "2300"}, {"Crystal bow full", "9000"}, {"Crystal shield full", "9000"}, {"Rune chainbody", "315"}, {"Zamorakian spear", "14395"}, {"Saradomin staff", "800"}, {"Guthix staff", "800"}, {"Zamorak staff", "800"}, {"Bolt rack", "2"}, {"Santa hat", "131601"}, {"Tuna potato", "20"}, {"Wizard boots", "3319"}, {"Regen bracelet", "2570"}, {"Combat bracelet", "137"}, {"Combat bracelet(1)", "137"}, {"Combat bracelet(2)", "137"}, {"Combat bracelet(3)", "137"}, {"Combat bracelet(4)", "137"}, {"Splitbark body", "271"}, {"Splitbark boots", "28"}, {"Splitbark gauntlets", "28"}, {"Splitback helm", "59"}, {"Splitback legs", "240"}, {"Dwarven helmet", "358"}, {"Abyssal whip", "14570"}, {"Fire Cape", "15000"}, {"Fighter Torso", "15000"}, {"Armadyl godsword", "675018"}, {"Bandos godsword", "188580"}, {"Saradomin godsword", "496437"}, {"Zamorak godsword", "267983"}, {"Dragon med helm", "885"}, {"Dragon sq shield", "5630"}, {"Dragon dagger", "292"}, {"Dragon dagger(p)", "305"}, {"Dragon dagger(p+)", "312"}, {"Drag dagger(p++)", "350"}, {"Dragon spear", "451"}, {"Dragon spear(p)", "460"}, {"Dragon spear(p+)", "465"}, {"Dragon spear(p++)", "506"}, {"Dragon longsword", "956"}, {"Dragon battleaxe", "1200"}, {"Dragon mace", "298"}, {"Dragon claws", "563332"}, {"Dragon chainbody", "50565"}, {"Dragon halberd", "1948"}, {"Dragon platelegs", "6323"}, {"Dragon plateskirt", "1979"}, {"Dragon scimitar", "998"}, {"Dragon platebody", "99230"}, {"Dragon axe", "16880"}, {"Dragon 2h sword", "8921"}, {"Dragon bolts (e)", "46"}, {"Diamond bolts (e)", "8"}, {"Dragon arrow", "29"}, {"Dragon arrow(p)", "31"}, {"Dragon arrow(p+)", "32"}, {"Dragon arrow(p++)", "40"}, {"Dragon fire arrows", "26"}, {"Dragonfire shield", "177038"}, {"Dragon full helm", "125349"}, {"Dragon boots", "2407"}, {"Dragon dart", "6"}, {"Dragon dart(p)", "8"}, {"Dragon dart(p+)", "9"}, {"Dragon dart(p++)", "17"}, {"Dragon bones", "24"}, {"Big bones", "3"}, {"Astral rune", "1"}, {"Blood rune", "3"}, {"Death rune", "3"}, {"Law rune", "3"}, {"Nature rune", "2"}, {"Soul rune", "3"}, {"Rune arrow", "2"}, {"Rune arrow(p)", "4"}, {"Rune arrow(p+)", "5"}, {"Rune arrow(p++)", "13"}, {"Rune fire arrows", "2"}, {"Rune c'bow", "95"}, {"Rune dart", "2"}, {"Rune dart(p)", "4"}, {"Rune dart(p+)", "5"}, {"Rune dart(p++)", "13"}, {"Rune fire arrows", "2"}, {"Rune full helm (t)", "3160"}, {"Rune full helm(g)", "4792"}, {"Rune kiteshield (g)", "4307"}, {"Rune kiteshield (t)", "2838"}, {"Rune platebody (g)", "6296"}, {"Rune platebody (t)", "3995"}, {"Rune platelegs (g)", "6296"}, {"Rune platelegs (t)", "2076"}, {"Rune plateskirt (g)", "639"}, {"Rune plateskirt (t)", "569"}, {"Rune full helm", "211"}, {"Rune boots", "460"}, {"Rune kiteshield", "499"}, {"Rune med helm", "114"}, {"Rune platebody", "578"}, {"Rune platelegs", "507"}, {"Rune plateskirt", "443"}, {"Rune sq shield", "230"}, {"Rune thrownaxe", "3"}, {"Gilded full helm", "3957"}, {"Gilded kiteshield", "4460"}, {"Gilded platebody", "15019"}, {"Gilded platelegs", "5902"}, {"Gilded plateskirt", "1618"}, {"Guthix full helm", "38888"}, {"Guthix kiteshield", "3763"}, {"Guthix platebody", "6185"}, {"Guthix platelegs", "2935"}, {"Guthix plateskirt", "577"}, {"Saradomin full", "8430"}, {"Saradomin kite", "8776"}, {"Saradomin plate", "16213"}, {"Saradomin legs", "3694"}, {"Saradomin skirt", "1003"}, {"Zamorak full helm", "5814"}, {"Zamorak kiteshield", "6221"}, {"Zamorak platebody", "11047"}, {"Zamorak platelegs", "3534"}, {"Zamorak plateskirt", "991"}, {"Adam full helm(g)", "1121"}, {"Adam full helm(t)", "601"}, {"Adam kiteshield (g)", "1159"}, {"Adam kiteshield (t)", "414"}, {"Adam platebody (g)", "2009"}, {"Adam platebody (t)", "908"}, {"Adam platelegs (g)", "792"}, {"Adam plateskirt (t)", "152"}, {"Adamant arrow", "1"}, {"Adamant arrow(p)", "3"}, {"Adamant arrow(p+)", "4"}, {"Adamant arrow(p++)", "12"}, {"Adamant fire arrows", "9"}, {"Adamant javelin", "1"}, {"Adamant javelin(p)", "3"}, {"Adamant javelin(p+)", "4"}, {"Adamant javelin(p++)", "12"}, {"Adamant chainbody", "27"}, {"Adamant boots", "20"}, {"Adamant full helm", "23"}, {"Adamant kiteshield", "31"}, {"Adamant platebody", "98"}, {"Adamant platelegs", "37"}, {"Adamant plateskirt", "37"}, {"Adamant med helm", "12"}, {"Adamant thrownaxe", "1"}, {"Adamant spear", "10"}, {"Adamant spear(p)", "20"}, {"Adamant spear(p+)", "25"}, {"Adamant spear(p++)", "66"}, {"Spined boots", "36"}, {"Spined gloves", "17"}, {"Spined body", "45"}, {"Spined chaps", "21"}, {"Spined helm", "358"}, {"Rock-shell boots", "11"}, {"Rock-shell gloves", "28"}, {"Rock-shell helm", "209"}, {"Rock-shell legs", "486"}, {"Rock-shell plate", "397"}, {"Skeletal boots", "194"}, {"Skeletal bottoms", "238"}, {"Skeletal gloves", "432"}, {"Skeletal helm", "58"}, {"Skeletal top", "267"}, {"Archers ring", "5783"}, {"Berserker ring", "18367"}, {"Seer's ring", "599"}, {"Warrior ring", "1163"}, {"Toktz-xil-ul", "3"}, {"Toktz-ket-xil", "2108"}, {"Toktz-mej-tal", "1092"}, {"Toktz-xil-ak", "1231"}, {"Toktz-xil-ek", "739"}, {"Toktz-ket-em", "935"}, {"Tzhaar-ket-om", "1579"}, {"Obsidian cape", "1864"}, {"Berserker necklace", "1787"}, {"Granite maul", "1458"}, {"Granite body", "490"}, {"Granite helm", "274"}, {"Granite legs", "1999"}, {"Granite shield", "348"}, {"Amulet of defence", "7"}, {"Amulet of fury", "25823"}, {"Amulet of glory", "386"}, {"Amulet of glory(1)", "386"}, {"Amulet of glory(2)", "386"}, {"Amulet of glory(3)", "386"}, {"Amulet of glory(4)", "386"}, {"Amulet of glory(t)", "2090"}, {"Amulet of glory(t1)", "2090"}, {"Amulet of glory(t2)", "2090"}, {"Amulet of glory(t3)", "2090"}, {"Amulet of glory(t4)", "2090"}, {"Amulet glory(t2)", "2090"}, {"Amulet glory(t3)", "2090"}, {"Amulet glory(t4)", "2090"}, {"Amulet of magic", "5"}, {"Amulet of magic(t)", "1042"}, {"Amulet of power", "31"}, {"Amulet of strength", "15"}, {"3rd age amulet", "561623"}, {"Strength amulet(t)", "5439"}, {"Antipoison(1)", "1"}, {"Antipoison(2)", "3"}, {"Antipoison(3)", "4"}, {"Antipoison(4)", "5"}, {"Antipoison+(1)", "23"}, {"Antipoison+(2)", "45"}, {"Antipoison+(3)", "68"}, {"Antipoison+(4)", "90"}, {"Antipoison++(1)", "37"}, {"Antipoison++(2)", "74"}, {"Antipoison++(3)", "110"}, {"Antipoison++(4)", "147"}, {"Super attack(1)", "2"}, {"Super attack(2)", "4"}, {"Super attack(3)", "5"}, {"Super attack(4)", "7"}, {"Super strength(1)", "10"}, {"Super strength(2)", "20"}, {"Super strength(3)", "30"}, {"Super strength(4)", "40"}, {"Super defence(1)", "2"}, {"Super defence(2)", "4"}, {"Super defence(3)", "5"}, {"Super defence(4)", "8"}, {"Saradomin brew(1)", "7"}, {"Saradomin brew(2)", "15"}, {"Saradomin brew(3)", "22"}, {"Saradomin brew(4)", "29"}, {"Zamorak brew(1)", "12"}, {"Zamorak brew(2)", "24"}, {"Zamorak brew(3)", "36"}, {"Zamorak brew(4)", "48"}, {"Super restore(1)", "36"}, {"Super restore(2)", "72"}, {"Super restore(3)", "108"}, {"Super restore(4)", "144"}, {"Super antipoison(1)", "3"}, {"Super antipoison(2)", "6"}, {"Super antipoison(3)", "9"}, {"Super antipoison(4)", "11"}, {"Prayer potion(1)", "21"}, {"Prayer potion(2)", "42"}, {"Prayer potion(3)", "64"}, {"Prayer potion(4)", "85"}, {"3rd age mage hat", "40672"}, {"3rd age robe", "42061"}, {"3rd age robe top", "64426"}, {"3rd age full helmet", "55938"}, {"3rd age kiteshield", "84861"}, {"3rd age platebody", "84993"}, {"3rd age platelegs", "75609"}, {"3rd age range coif", "28814"}, {"3rd age range legs", "42202"}, {"Pottery statuette", "25014"}, {"Stone statuette", "25014"}, {"3rd age range top", "501644"}, {"Golden statuette", "13046"}, {"Imp statue", "25015"}, {"3rd age vambraces", "210575"}, {"Ahrim's hood", "608"}, {"Ahrim's robeskirt", "7747"}, {"Ahrim's robetop", "3582"}, {"Ahrim's staff", "511"}, {"Torag's hammers", "960"}, {"Torag's helm", "4919"}, {"Torag's platebody", "2196"}, {"Torag's platelegs", "3563"}, {"Karil's coif", "428"}, {"Karil's crossbow", "1265"}, {"Karil's leatherskirt", "2165"}, {"Karil's leathertop", "11627"}, {"Dharok's greataxe", "2181"}, {"Dharok's helm", "32601"}, {"Dharok's platebody", "2247"}, {"Dharok's platelegs", "3242"}, {"Verac's brassard", "2181"}, {"Verac's flail", "1592"}, {"Verac's helm", "19233"}, {"Verac's plateskirt", "5590"}, {"Guthan's chainskirt", "2090"}, {"Guthan's helm", "21675"}, {"Guthan's platebody", "2160"}, {"Guthan's warspear", "13720"}, {"Saradomin sword", "71022"}, {"Ava's accumulator", "113"}, {"Archer helm", "553"}, {"Berserker helm", "773"}, {"Farseer helm", "536"}, {"Helm of neitiznot", "521"}, {"Infinity boots", "8277"}, {"Infinity bottoms", "3089"}, {"Infinity gloves", "1957"}, {"Infinity hat", "6382"}, {"Infinity top", "4317"}, {"Master wand", "4265"}, {"Teacher wand", "432"}, {"Mage's book", "19198"}, {"Initiate cuisse", "47"}, {"Initiate hauberk", "59"}, {"Initiate sallet", "34"}, {"Proselyte cuisse", "61"}, {"Proselyte hauberk", "75"}, {"Proselyte sallet", "46"}, {"Proselyte tasset", "61"}, {"Bandos boots", "8567"}, {"Bandos chestplate", "137022"}, {"Bandos tassets", "119478"}, {"Armadyl chestplate", "110821"}, {"Large statues", "30085"}, {"Medium statues", "35086"}, {"Small statues", "5247"},  {"Guardian statue", "7500"},  {"Statuette", "53086"}, {"Armadyl helmet", "48086"}, {"Armadyl plateskirt", "119685"}, {"Black d'hide body", "80"}, {"Black d'hide chaps", "62"}, {"Black d'hide vamb", "25"}, {"Zamorak d'hide", "12302"}, {"Zamorak chaps", "1175"}, {"Zamorak bracers", "5754"}, {"Zamorak coif", "2072"}, {"Saradomin d'hide", "9908"}, {"Saradomin chaps", "1005"}, {"Saradomin bracers", "4112"}, {"Saradomin coif", "1172"}, {"Guthix chaps", "279"}, {"Guthix coif", "1044"}, {"Guthix dragonhide", "949"}, {"Guthix bracers", "138"}, {"Guthix cloak", "6229"}, {"Guthix crozier", "29"}, {"Guthix mitre", "972"}, {"Guthix mjolnir", "60"}, {"Guthix robe legs", "993"}, {"Guthix robe top", "1095"}, {"Guthix stole", "144"}, {"Zamorak cloak", "10332"}, {"Zamorak crozier", "54"}, {"Zamorak mitre", "1382"}, {"Zamorak mjolnir", "91"}, {"Zamorak robe legs", "1626"}, {"Zamorak robe top", "1967"}, {"Zamorak stole", "864"}, {"Saradomin cloak", "9206"}, {"Saradomin crozier", "51"}, {"Saradomin mitre", "1634"}, {"Saradomin mjolnir", "113"}, {"Saradomin robe legs", "1071"}, {"Saradomin robe top", "1242"}, {"Saradomin stole", "650"}, {"Dark bow", "7900"}, {"Blue partyhat", "3166068"}, {"Green partyhat", "971385"}, {"Purple partyhat", "833622"}, {"Red partyhat", "1173043"}, {"White partyhat", "1638634"}, {"Yellow partyhat", "928302"}, {"Blue h'ween mask", "123047"}, {"Green h'ween mask", "102486"}, {"Red h'ween mask", "166275"}, {"Scythe", "273844"}, {"Bunny ears", "170376"}, {"Easter egg", "46282"}, {"Pumpkin", "53056"}, {"Raw manta ray", "10"}, {"Shark", "8"}, {"Cooked karambwan", "6"}, {"Rune knife", "5"}, {"Rune knife(p)", "7"}, {"Rune knife(p+)", "8"}, {"Rune knife(p++)", "16"}, {"Attack cape(t)", "990"}, {"Attack cape(t)", "990"}, {"Attack hood", "10"}, {"Strength cape", "990"}, {"Strength cape(t)", "990"}, {"Strength hood", "10"}, {"Defence cape", "990"}, {"Defence cape(t)", "990"}, {"Defence hood", "10"}, {"Ranging cape", "990"}, {"Ranging cape(t)", "990"}, {"Ranging hood", "10"}, {"Prayer cape", "990"}, {"Prayer cape(t)", "990"}, {"Prayer hood", "10"}, {"Magic cape", "990"}, {"Magic cape(t)", "990"}, {"Magic hood", "10"}, {"Runecraft cape", "990"}, {"Runecraft cape(t)", "990"}, {"Runecrafting hood", "10"}, {"Hitpoints cape", "990"}, {"Hitpoints cape(t)", "990"}, {"Hitpoints hood", "10"}, {"Agility cape", "990"}, {"Agility cape(t)", "990"}, {"Agility hood", "10"}, {"Herblore cape", "990"}, {"Herblore cape(t)", "990"}, {"Herblore hood", "10"}, {"Thieving cape", "990"}, {"Thieving cape(t)", "990"}, {"Thieving hood", "10"}, {"Crafting cape", "990"}, {"Crafting cape(t)", "990"}, {"Crafting hood", "10"}, {"Fletching cape", "990"}, {"Fletching cape(t)", "990"}, {"Fletching hood", "10"}, {"Slayer cape", "990"}, {"Slayer cape(t)", "990"}, {"Slayer hood", "10"}, {"Construct. cape", "990"}, {"Construct. cape(t)", "990"}, {"Construct. hood", "10"}, {"Mining cape", "990"}, {"Mining cape(t)", "990"}, {"Mining hood", "10"}, {"Smithing cape", "990"}, {"Smithing cape(t)", "990"}, {"Smithing hood", "10"}, {"Fishing cape", "990"}, {"Fishing cape(t)", "990"}, {"Fishing hood", "10"}, {"Cooking cape", "990"}, {"Cooking cape(t)", "990"}, {"Cooking hood", "10"}, {"Firemaking cape", "990"}, {"Firemaking cape(t)", "990"}, {"Firemaking hood", "10"}, {"Woodcutting cape", "990"}, {"Woodcut. cape(t)", "990"}, {"Woodcutting hood", "10"}, {"Farming cape", "990"}, {"Farming cape(t)", "990"}, {"Farming hood", "10"}, {"Quest point cape", "990"}, {"Quest point hood", "10"}, {"Summoning cape", "990"}, {"Summoning cape(t)", "990"}, {"Summoning hood", "10"}, {"Robin hood hat", "20395"}, {"Ranger boots", "66372"}, {"Arcane spirit shield", "100536"}, {"Blessed spirit shield", "4138700"}, {"Spirit Terrorbird", "80"}, {"Divine spirit shield", "4439090"}, {"Elysian spirit shield", "4027272"}, {"Spectral spirit shield", "0"}, {"Holy elixir", "60000"}, {"Spirit shield", "626"}, {"Vesta's longsword", "0"}, {"Pack yack pouch", "10000"}, {"Spirit wolf pouch", "500"}};
  508.     String[][] killPrices = {{"Void knight top", "20"}, {"Void knight robe", "20"}, {"Void knight mace", "5"}, {"Void knight gloves", "0"}, {"Void mage helm", "0"}, {"Void ranger helm", "10"}, {"Void melee helm", "10"}, {"Runner hat", "10"}, {"Healer hat", "10"}, {"Ranger hat", "10"}, {"Runner boots", "10"}, {"Penance gloves", "10"}, {"Penance skirt", "10"}, {"Fighter torso", "30"}, {"Fire cape", "40"}, {"Zuriel's staff", "20"}, {"Zuriel's hood", "20"}, {"Zuriel's robe bottom", "20"}, {"Zuriel's robe top", "20"}, {"Statius's platelegs", "20"}, {"Statius's platelegs", "26"}, {"Statius's platebody", "28"}, {"Statius's full helm", "29"}, {"Statius's warhammer", "45"}, {"Statius's platelegs", "45"}, {"Bandos tassets", "0"}, {"Vesta's chainbody", "50"}, {"Vesta's plateskirt", "50"}, {"Vesta's longsword", "150"}, {"Armadyl chestplate", "0"}, {"Armadyl plateskirt", "0"}, {"Armadyl helmet", "0"}, {"Morrigan's leather body", "20"}, {"Corrupt Zuriel's hood", "20"}, {"Corrupt Zuriel's robetop", "20"}, {"Corrupt Zuriel's robebottom", "20"}, {"Corrupt Zuriel's staff", "20"}, {"Corrupt Vesta's chainbody", "50"}, {"Corrupt Vesta's plateskirt", "50"}, {"Corrupt Statius's hammer", "20"}, {"Corrupt Statius's full helm", "20"}, {"Corrupt Statius's platebody", "20"}, {"Corrupt Statius's platelegs", "20"}, {"Morrigan's leather chaps", "20"}, {"Morrigan's coif", "20"}, {"Infinity boots", "0"}, {"Master wand", "0"}, {"Mage's book", "0"}, {"Amulet of fury", "0"}, {"Rune defender", "0"}, {"Adamant defender", "0"}, {"Mithril defender", "0"}};
  509.     int[][] otherPrices = {{6572, 20000}, {4089, 203},{4090, 203}, {4091, 513}, {12007, 900}, {12008, 900}, {389, 10}, {383, 8}, {377, 3}, {371, 3}, {363, 2}, {335, 2}, {317, 2}, {331, 3}, {4092, 513},{4093, 313}, {4094, 313},{4095, 902},{4096, 902},{4097, 402},{4098, 402}, {12480, 100000}, {11286, 150000}, {1632, 2500}, {1624, 120}, {1622, 250}, {1620, 400}, {1618, 550}, {6571, 20000}, {12094, 50000}, {12093, 50000}, {12047, 500}, {12048, 500}, {1631, 2500}, {1623, 120}, {1621, 250}, {1619, 400}, {1617, 550}, {13742, 3816000}, {13743, 3816000}, {13736, 35000}, {13737, 35000}, {13740, 3816000}, {13741, 3816000}, {13738, 1168008}, {13739, 1168008}, {13734, 1000}, {13735, 1000}, {7456, 3}, {7457, 5}, {7458, 10}, {7459, 15}, {7460, 20}, {7461, 1000}, {7462, 1000}, {10551, 10000}};
  510.     int[][] killRequirments = {{8844, 0}, {8845, 0}, {8846, 0}, {8847, 0}, {8848, 0}, {8849, 0}, {8850, 0}, {10887, 0}, {4214, 0}, {4225, 0}, {2412, 0}, {2413, 0}, {2414, 0}, {2415, 0}, {2416, 0}, {2417, 0}, {7453, 0}, {7454, 0}, {7455, 0}, {7456, 0}, {7457, 0}, {7458, 0}, {7459, 0}, {7460, 0}, {7461, 0}, {7462, 0}};
  511.     public int getItemValue(int item) {
  512.         if (item == 995) {
  513.             return 1;
  514.         }
  515.         int value = 0;
  516.         for (String[] s : itemPrices) {
  517.             String name = Engine.items.getItemName(item);
  518.             if (name.equals(s[0])) {
  519.                 value = 100 * Integer.parseInt(s[1]);
  520.             }
  521.         }
  522.         for (int[] i : otherPrices) {
  523.             if (item == i[0]) {
  524.                 value = 100 * i[1];
  525.             }
  526.         }
  527.         if (Engine.items.stackable(item) && value == 0) {
  528.             value = 1;
  529.         }
  530.         return value;
  531.     }
  532.  
  533.     public int getXPForLevel(int level) {
  534.         int points = 0;
  535.         int output = 0;
  536.         for (int lvl = 1; lvl <= level; lvl++) {
  537.             points += Math.floor((double) lvl + 300.0 * Math.pow(2.0, (double) lvl / 7.0));
  538.             if (lvl >= level) {
  539.                 return output;
  540.             }
  541.             output = (int) Math.floor(points / 4);
  542.         }
  543.         return 0;
  544.     }
  545.  
  546.     public int getKillRequirment(int item) {
  547.         int requirment = 0;
  548.         for (int[] i : killRequirments) {
  549.             if (item == i[0]) {
  550.                 requirment = i[1];
  551.             }
  552.         }
  553.         return requirment;
  554.     }
  555.  
  556.     public int getKillCost(int item) {
  557.         int cost = 0;
  558.         for (String[] s : killPrices) {
  559.             String name = Engine.items.getItemName(item);
  560.             if (name.equals(s[0])) {
  561.                 cost = Integer.parseInt(s[1]);
  562.             }
  563.         }
  564.         return cost;
  565.     }
  566.  
  567.     public long getItemValue2(int item) {
  568.         if (item == 995) {
  569.             return 1;
  570.         }
  571.         int value = 0;
  572.         long value2 = 0;
  573.         for (String[] s : itemPrices) {
  574.             String name = Engine.items.getItemName(item);
  575.             if (name.equals(s[0])) {
  576.                 value = 100 * Integer.parseInt(s[1]);
  577.                 value2 = 100 * Integer.parseInt(s[1]);
  578.             }
  579.         }
  580.         for (int[] i : otherPrices) {
  581.             if (item == i[0]) {
  582.                 value = 100 * i[1];
  583.                 value2 = 100 * i[1];
  584.             }
  585.         }
  586.         if (Engine.items.stackable(item) && value == 0) {
  587.             value = 1;
  588.             value2 = 1;
  589.         }
  590.         return value2;
  591.     }
  592.  
  593.     public void message(String message) {
  594.         getActionSender().sendMessage(this, message);
  595.     }
  596.  
  597.     public void leverTeleport(String location) {
  598.         if (teleblockTimer >= 0) {
  599.             getActionSender().sendMessage(this, "You are teleport blocked!");
  600.             return;
  601.         }
  602.         if (jailed > 0) {
  603.             getActionSender().sendMessage(this, "You are jailed!");
  604.             return;
  605.         }
  606.         int x = absX;
  607.         int y = absY;
  608.         int h = heightLevel;
  609.         if (location != null) {
  610.             if (location.equals("Deep Wilderness")) {
  611.                 x = 3153;
  612.                 y = 3923;
  613.             }
  614.             if (location.equals("Ardougne Lever")) { //Changed To Edge
  615.                 x = 3090;//x = 2561;
  616.                 y = 3474;//y = 3311;
  617.             }
  618.             if (location.equals("Mage Bank (Inside)")) {
  619.                 x = 2539;
  620.                 y = 4712;
  621.             }
  622.             if (location.equals("Mage Bank (Outside)")) {
  623.                 x = 3090;
  624.                 y = 3956;
  625.                 h = 0;
  626.             }
  627.             if (location.equals("Mage Arena (Inside)")) {
  628.                 x = 3105;
  629.                 y = 3951;
  630.             }
  631.             if (location.equals("Mage Arena (Outside)")) {
  632.                 x = 3105;
  633.                 y = 3956;
  634.             }
  635.         }
  636.         getActionSender().removeShownInterface(this);
  637.         requestAnim(2140, 0);
  638.         leverTeleportX = x;
  639.         leverTeleportY = y;
  640.         leverTeleportH = h;
  641.         leverTeleportDelay = 2;
  642.         lever = true;
  643.     }
  644.  
  645.     public void teletab(String city) {
  646.         int x = absX;
  647.         int y = absY;
  648.         int h = heightLevel;
  649.         int r = 0;
  650.         teletab = true;
  651.         if (teleblockTimer >= 0) {
  652.             getActionSender().sendMessage(this, "You are teleport blocked!");
  653.             return;
  654.         }
  655.         if (getWildernessLevel2() >= 21) {
  656.             getActionSender().sendMessage(this, "A magical force stops you from teleporting.");
  657.             return;
  658.         }
  659.         if (city != null) {
  660.             if (city.equals("Varrock")) {
  661.                 x = 3210;
  662.                 y = 3421;
  663.                 r = 4;
  664.             }
  665.             if (city.equals("Home")) {
  666.                 x = 3093;//p.setCoords(3222, 3219, 0);
  667.                 y = 3490;
  668.                 ;
  669.                 r = 0;
  670.             }
  671.             if (city.equals("Lumbridge")) {
  672.                 x = 3221;
  673.                 y = 3218;
  674.                 r = 2;
  675.             }
  676.             if (city.equals("Falador")) {
  677.                 x = 2964;
  678.                 y = 3378;
  679.                 r = 3;
  680.             }
  681.             if (city.equals("Camelot")) {
  682.                 x = 2756;
  683.                 y = 3476;
  684.                 r = 3;
  685.             }
  686.             if (city.equals("Ardougne")) {
  687.                 x = 2660;
  688.                 y = 3301;
  689.                 r = 4;
  690.             }
  691.             if (city.equals("WatchTower")) {
  692.                 x = 2547;
  693.                 y = 3112;
  694.                 r = 1;
  695.             }
  696.         }
  697.         getActionSender().removeShownInterface(this);
  698.         x += getRandom(r);
  699.         y += getRandom(r);
  700.         teletabTo(x, y, h, 3, 0, 9597, 4071, 1680, 0, 678, 0);
  701.     }
  702.  
  703.     public void teletabTo(int x, int y, int height, int delay, int distance, int emoteStart, int emoteEnd, int gfxStart,
  704.             int gfxStartH, int gfxEnd, int gfxEndH) {
  705.         if (isDead) {
  706.             return;
  707.         }
  708.         if (teleblockTimer >= 0) {
  709.             getActionSender().sendMessage(this, "You are teleport blocked!");
  710.             return;
  711.         }
  712.         if (jailed > 0) {
  713.             getActionSender().sendMessage(this, "You are jailed!");
  714.             return;
  715.         }
  716.         itemPickup = false;
  717.         playerOption1 = false;
  718.         playerOption2 = false;
  719.         playerOption3 = false;
  720.         npcOption1 = false;
  721.         npcOption2 = false;
  722.         objectOption1 = false;
  723.         objectOption2 = false;
  724.         attackingPlayer = false;
  725.         clickDelay = delay + 2;
  726.         teleDelay = delay;
  727.         if (distance > 0) {
  728.             int xType = Misc.random(1);
  729.             int yType = Misc.random(1);
  730.             int xOffset = Misc.random(distance);
  731.             int yOffset = Misc.random(distance);
  732.             if (xType == 1)
  733.                 x += -xOffset;
  734.             else
  735.                 x += xOffset;
  736.             if(yType == 1)
  737.                 y += -yOffset;
  738.             else
  739.                 y += yOffset;
  740.         }
  741.         teleX = x;
  742.         teleY = y;
  743.         teleH = height;
  744.         Engine.playerMovement.resetWalkingQueue(this);
  745.         requestAnim(emoteStart, 0);
  746.         requestGFX(gfxStart, gfxStartH);
  747.         teleFinishGFX = gfxEnd;
  748.         teleFinishGFXHeight = gfxEndH;
  749.         teleFinishAnim = emoteEnd;
  750.     }
  751.  
  752.     public void statSpy(Player other) {
  753.         int[] strings = {1, 25, 13, 5, 37, 49, 61, 45, 69, 65, 33, 57, 53, 21, 9, 29, 17, 41, 77, 81, 73, 85, 89, 93};
  754.         getActionSender().setString(this, other.username.substring(0, 1).toUpperCase() + other.username.substring(1), 523, 99);
  755.         for (int i = 0; i < strings.length; i++) {
  756.             getActionSender().setString(this, ""+other.skillLvl[i], 523, strings[i]);
  757.             getActionSender().setString(this, ""+other.getLevelForXP(i), 523, strings[i] + 1);
  758.         }
  759.         getActionSender().setTab(this, 79, 523);
  760.     }
  761.  
  762.     public void clearItem(int item) {
  763.         for (int i = 0; i < bankItems.length; i++) {
  764.             if (item == bankItems[i]) {
  765.                 bankItems[i] = -1;
  766.                 bankItemsN[i] = 0;
  767.             }
  768.         }
  769.         for (int i = 0; i < equipment.length; i++) {
  770.             if (item == equipment[i]) {
  771.                 equipment[i] = -1;
  772.                 equipmentN[i] = 0;
  773.             }
  774.         }
  775.         for (int i = 0; i < items.length; i++) {
  776.             if (item == items[i]) {
  777.                 items[i] = -1;
  778.                 itemsN[i] = 0;
  779.             }
  780.         }
  781.     }
  782.  
  783.     public void clearItem(String item) {
  784.         String name = item;
  785.         for (int i = 0; i < bankItems.length; i++) {
  786.             if (name.equals(Engine.items.getItemName(bankItems[i]))) {
  787.                 bankItems[i] = -1;
  788.                 bankItemsN[i] = 0;
  789.             }
  790.         }
  791.         for (int i = 0; i < equipment.length; i++) {
  792.             if (name.equals(Engine.items.getItemName(equipment[i]))) {
  793.                 equipment[i] = -1;
  794.                 equipmentN[i] = 0;
  795.             }
  796.         }
  797.         for (int i = 0; i < items.length; i++) {
  798.             if (name.equals(Engine.items.getItemName(items[i]))) {
  799.                 items[i] = -1;
  800.                 itemsN[i] = 0;
  801.             }
  802.         }
  803.     }
  804.  
  805.  
  806.     public boolean isPVP() {
  807.         return heightLevel == 0;
  808.     }
  809.  
  810.     public boolean DoorArea(int x, int y) {
  811.         if ((x >= 2794 && x <= 2794 && y >= 5650 && y <= 5650) ||
  812.                 (x >= 2826 && x <= 2826 && y >= 5665 && y <= 5665) ||
  813.                 (x == 2843 && y == 5680) ||
  814.                 (x == 2851 && y == 5685) ||
  815.                 (x == 2860 && y == 5692) ||
  816.                 (x == 2862 && y == 5696) ||
  817.                 (x == 2866 && y == 5716) ||
  818.                 (x == 2864 && y == 5738) ||
  819.                 (x == 2861 && y == 5768) ||
  820.                 (x == 2851 && y == 5785) ||
  821.                 (x == 2850 && y == 5794) ||
  822.                 (x == 2815 && y == 5806) ||
  823.                 (x == 2773 && y == 5808) ||
  824.                 (x == 2757 && y == 5808) ||
  825.                 (x == 2737 && y == 5802) ||
  826.                 (x == 2843 && y == 5801) ||
  827.                 (x == 2726 && y == 5795) ||
  828.                 (x == 2707 && y == 5783) ||
  829.                 (x == 2702 && y == 5765) ||
  830.                 (x == 2705 && y == 5759) ||
  831.                 (x == 2740 && y == 5649) ||
  832.                 (x == 2752 && y == 5652) ||
  833.                 (x == 2772 && y == 5648) ||
  834.                 (x == 2703 && y == 5717) ||
  835.                 (x == 2702 && y == 5704) ||
  836.                 (x == 2707 && y == 5690) ||
  837.                 (x == 2703 && y == 5717) ||
  838.                 (x >= 3163 && x <= 3163 && y >= 3696 && y <= 3696) ||
  839.                 (x >= 3180 && x <= 3180 && y >= 3708 && y <= 3708) ||
  840.                 (x >= 3181 && x <= 3181 && y >= 3720 && y <= 3720) ||
  841.                 (x >= 3171 && x <= 3171 && y >= 3737 && y <= 3737) ||
  842.                 (x >= 3101 && x <= 3101 && y >= 3682 && y <= 3682) ||
  843.                 (x >= 3170 && x <= 3170 && y >= 3746 && y <= 3746) ||
  844.                 (x >= 3163 && x <= 3163 && y >= 3753 && y <= 3753) ||
  845.                 (x >= 3147 && x <= 3147 && y >= 3758 && y <= 3758) ||
  846.                 (x >= 3135 && x <= 3135 && y >= 3758 && y <= 3758) ||
  847.                 (x >= 3121 && x <= 3121 && y >= 3754 && y <= 3754) ||
  848.                 (x >= 3110 && x <= 3110 && y >= 3747 && y <= 3747) ||
  849.                 (x >= 3091 && x <= 3091 && y >= 3735 && y <= 3735) ||
  850.                 (x >= 3086 && x <= 3086 && y >= 3717 && y <= 3717) ||
  851.                 (x >= 3091 && x <= 3091 && y >= 3706 && y <= 3706) ||
  852.                 (x >= 3096 && x <= 3096 && y >= 3692 && y <= 3692) ||
  853.                 (x >= 3108 && x <= 3108 && y >= 3670 && y <= 3670) ||
  854.                 (x >= 3171 && x <= 3171 && y >= 3701 && y <= 3701)) {
  855.             return true;
  856.         }
  857.         return false;
  858.     }
  859.  
  860.     public boolean Safezone(int x, int y) {
  861.         if ((x >= 3091 && x <= 3098 && y >= 3488 && y <= 3499) ||
  862.                 (x >= 3135 && x <= 3192 && y >= 3652 && y <= 3702) ||
  863.                 (x >= 3179 && x <= 3194 && y >= 3432 && y <= 3446) ||
  864.                 (x >= 3250 && x <= 3257 && y >= 3416 && y <= 3423) ||
  865.                 (x >= 2943 && x <= 2947 && y >= 2946 && y <= 3373) ||
  866.                 (x >= 2943 && x <= 2949 && y >= 3368 && y <= 3368) ||
  867.                 (x >= 3009 && x <= 3018 && y >= 3353 && y <= 3358) ||
  868.                 (x >= 3009 && x <= 3022 && y >= 3353 && y <= 3356) ||
  869.                 (x >= 2649 && x <= 2658 && y >= 3280 && y <= 3287) ||
  870.                 (x >= 2612 && x <= 2621 && y >= 3330 && y <= 3335) ||
  871.                 (x >= 3201 && x <= 3229 && y >= 3217 && y <= 3220) ||
  872.                 (x >= 3201 && x <= 3226 && y >= 3209 && y <= 3228) ||
  873.                 (x >= 3201 && x <= 3225 && y >= 3208 && y <= 3229) ||
  874.                 (x >= 3201 && x <= 3224 && y >= 3207 && y <= 3230) ||
  875.                 (x >= 3201 && x <= 3223 && y >= 3206 && y <= 3231) ||
  876.                 (x >= 3201 && x <= 3222 && y >= 3205 && y <= 3232) ||
  877.                 (x >= 3201 && x <= 3221 && y >= 3204 && y <= 3233) ||
  878.                 (x >= 3201 && x <= 3220 && y >= 3203 && y <= 3234) ||
  879.                 (x >= 3201 && x <= 3213 && y >= 3202 && y <= 3235) ||
  880.                 (x >= 3201 && x <= 3212 && y >= 3201 && y <= 3236) ||
  881.                 (x >= 3201 && x <= 3203 && y >= 3202 && y <= 3235) ||
  882.                 (x >= 3201 && x <= 3202 && y >= 3203 && y <= 3234) ||
  883.                 (x >= 2526 && x <= 2550 && y >= 4709 && y <= 4725) ||
  884.                 (x >= 3201 && x <= 3201 && y >= 3204 && y <= 3233)) {
  885.             return true;
  886.         }
  887.         return false;
  888.     }
  889.  
  890.     public String getKillMessage(String player) {
  891.         String[][] selection = {{"You just took a steamy shit on ", "'s forehead."},
  892.                 {"You cum in ", "'s eye."},
  893.                 {"Well done, you've slayed ", "."},
  894.                 {"You gwas all over ", "."},
  895.                 {"", "'s nan was clearly no match for you."},
  896.                 {"You wipe your ass with ", "."},
  897.                 {"Ooh, ", "'s nan just bent over and took it hard."},
  898.                 {"", " has fallen before your mighty penis."},
  899.                 {"", " is now your african slave."}};
  900.         int index = (int)Math.floor(Math.random() * 9);
  901.         return selection[index][0] + player + selection[index][1];
  902.     }
  903.  
  904.     public boolean falseBh() {
  905.         return absX >= 3071 && absX <= 3197 && absY >= 3668 && absY <= 3779;
  906.     }
  907.  
  908.     public boolean falseBh1() {
  909.         return absX >= 2650 && absX <= 2890 && absY >= 5640 && absY <= 5900;
  910.     }
  911.  
  912.     public boolean multiwayCombatZone(int x, int y) {
  913.         if ((x > 3072 && x < 3107 && y > 3401 && y < 3448) ||
  914.                 (x > 2946 && x < 3004 && y > 3333 && y < 3424) ||
  915.                 (x > 3193 && x < 3332 && y > 3667 && y < 3752) ||
  916.                 (x > 3203 && x < 3331 && y > 3519 && y < 3666) ||
  917.                 (x > 3134 && x < 3328 && y > 3519 && y < 3667) ||
  918.                 (x > 2945 && x < 2961 && y > 3812 && y < 3828) ||
  919.                 (x > 3145 && x < 3217 && y > 3904 && y < 3966) ||//Deserted Keep
  920.                 (x > 2982 && x < 3010 && y > 3913 && y < 3929) ||
  921.                 (x > 3203 && x < 3392 && y > 3904 && y < 4031) ||
  922.                 (x > 3149 && x < 3331 && y > 3799 && y < 3850) ||
  923.                 (x > 3064 && x < 3391 && y > 3864 && y < 3903) ||
  924.                 (x > 2497 && x < 2549 && y > 4680 && y < 4725) ||
  925.                 (x > 3265 && x < 3330 && y > 3710 && y < 3840) ||
  926.                 (x > 2923 && x < 2973 && y > 4359 && y < 4412) ||
  927.                 (x > 3006 && x < 3072 && y > 3601 && y < 3713)) {
  928.             return true;
  929.         }
  930.         return false;
  931.     }
  932.  
  933.     public boolean picklock() {
  934.         return absX >= 3038 && absX <= 3044 && absY >= 3949 && absY <= 3959;
  935.     }
  936.  
  937.     public boolean wildernessZone(int x, int y) {
  938.         if (!isPVP()) {
  939.             if ((x >= 3042 && x <= 3263 && y >= 3525 && y <= 3667) ||
  940.                     (x >= 3042 && x <= 3395 && y >= 3702 && y <= 4000) ||
  941.                     (x >= 3280 && x <= 3395 && y >= 3671 && y <= 4000) ||
  942.                     (x >= 3193 && x <= 3279 && y >= 3667 && y <= 3671) ||
  943.                     (x >= 3195 && x <= 3263 && y >= 3672 && y <= 4000) ||
  944.                     (x >= 3042 && x <= 3147 && y >= 3663 && y <= 4000) ||
  945.                     (x >= 3042 && x <= 3196 && y >= 3703 && y <= 4000) ||
  946.                     (x >= 3047 && x <= 3175 && y >= 3704 && y <= 4000) ||
  947.                     (x >= 3264 && x <= 3279 && y >= 3525 && y <= 3671) ||
  948.                     (x >= 3325 && x <= 33395 && y >= 3525 && y <= 4000) ||
  949.                     (x >= 3005 && x <= 3068 && y >= 10303 && y <= 10359) ||
  950.                     (x >= 3325 && x <= 3275 && y >= 3525 && y <= 3534) ||                  
  951.                     (x >= 3264 && x <= 3378 && y >= 3530 && y <= 3671) ||
  952.                     (x >= 2946 && x <= 3041 && y >= 3525 && y <= 4000) ||
  953.                     (x >= 2495 && x <= 2525 && y >= 4680 && y <= 4736)) {
  954.                 return true;
  955.             }
  956.             return false;
  957.         }
  958.         if (isPVP()) {
  959.             if ((x >= 3091 && x <= 3098 && y >= 3488 && y <= 3499) ||
  960.                     (x >= 3135 && x <= 3192 && y >= 3668 && y <= 3702) ||
  961.                     (x >= 3179 && x <= 3194 && y >= 3432 && y <= 3446) ||
  962.                     (x >= 2526 && x <= 2551 && y >= 4709 && y <= 4726) ||
  963.                     (x >= 3250 && x <= 3257 && y >= 3416 && y <= 3423) ||
  964.                     (x >= 2943 && x <= 2947 && y >= 2946 && y <= 3373) ||
  965.                     (x >= 2943 && x <= 2949 && y >= 3368 && y <= 3368) ||
  966.                     (x >= 3009 && x <= 3018 && y >= 3353 && y <= 3358) ||
  967.                     (x >= 3009 && x <= 3022 && y >= 3353 && y <= 3356) ||
  968.                     (x >= 2721 && x <= 2730 && y >= 3490 && y <= 3493) ||
  969.                     (x >= 2724 && x <= 2727 && y >= 3487 && y <= 3489) ||
  970.                     (x >= 2649 && x <= 2658 && y >= 3280 && y <= 3287) ||
  971.                     (x >= 2612 && x <= 2621 && y >= 3330 && y <= 3335) ||
  972.                     (x >= 3201 && x <= 3229 && y >= 3217 && y <= 3220) ||
  973.                     (x >= 3201 && x <= 3226 && y >= 3209 && y <= 3228) ||
  974.                     (x >= 3201 && x <= 3225 && y >= 3208 && y <= 3229) ||
  975.                     (x >= 3201 && x <= 3224 && y >= 3207 && y <= 3230) ||
  976.                     (x >= 3201 && x <= 3223 && y >= 3206 && y <= 3231) ||
  977.                     (x >= 3201 && x <= 3222 && y >= 3205 && y <= 3232) ||
  978.                     (x >= 3201 && x <= 3221 && y >= 3204 && y <= 3233) ||
  979.                     (x >= 3201 && x <= 3220 && y >= 3203 && y <= 3234) ||
  980.                     (x >= 3201 && x <= 3213 && y >= 3202 && y <= 3235) ||
  981.                     (x >= 3201 && x <= 3212 && y >= 3201 && y <= 3236) ||
  982.                     (x >= 3201 && x <= 3203 && y >= 3202 && y <= 3235) ||
  983.                     (x >= 3201 && x <= 3202 && y >= 3203 && y <= 3234) ||
  984.                     (x >= 2526 && x <= 2550 && y >= 4709 && y <= 4725) ||
  985.                     (x >= 3367 && x <= 3379 && y >= 3082 && y <= 3083) ||
  986.                     (x >= 3371 && x <= 3374 && y >= 3081 && y <= 3084) ||
  987.                     (x >= 2883 && x <= 2965 && y >= 4372 && y <= 4417) ||//corp
  988.                     (x >= 2806 && x <= 2812 && y >= 3438 && y <= 3445) ||//Catherby Bank
  989.                     (x >= 2609 && x <= 2616 && y >= 3088 && y <= 3097) ||//Yanille Bank
  990.                     (x >= 3265 && x <= 3272 && y >= 3161 && y <= 3173) ||//Al Karid Bank
  991.                     (x >= 3201 && x <= 3201 && y >= 3204 && y <= 3233)) {
  992.                 if ((attacking == null && attackedBy == null) || (timerStarted && System.currentTimeMillis() - PVPTimer >= 10000)) {
  993.                     if (timerStarted) {
  994.                         removeWilderness();
  995.                         timerStarted = false;
  996.                         attackedBy = null;
  997.                         attacking = null;
  998.                     }
  999.                     return false;
  1000.                 } else if (!timerStarted && (attacking == null || attackedBy != null || attacking != null || attackedBy == null)) {
  1001.                     PVPTimer = System.currentTimeMillis();
  1002.                     timerStarted = true;
  1003.                 }
  1004.             }
  1005.             return true;
  1006.         }
  1007.         return false;
  1008.     }  
  1009.  
  1010.     public void Hello13(final Player p) {
  1011.         EventManager.getSingleton().addEvent(new Event() {
  1012.             public void execute(EventContainer c) {
  1013.                 if (wildTimer > 0) {
  1014.                     wildTimer--;
  1015.                     getActionSender().setString(p, "                   Time left: "+wildTimer, 494, 2);
  1016.                 }
  1017.                 if (!p.Safezone(absX, absY)) {
  1018.                     timerStarted2 = false;
  1019.                     wildTimer = 0;
  1020.                     int max = combatLevel + wildyLevel;
  1021.                     if (max > 138)
  1022.                         max = 138;
  1023.                     int min = (combatLevel - wildyLevel) + (((combatLevel % 10 >= 5) && ((combatLevel - wildyLevel) % 10 < 5) || (combatLevel >= 114)) ? 2 : 1);
  1024.                     if (min < 3)
  1025.                         min = 3;
  1026.                     String range = +min+" - "+max;
  1027.                     getActionSender().setString(p,"                   "+range, 494, 2);
  1028.                     c.stop();
  1029.                 }
  1030.                 if (wildTimer == 0 && p.Safezone(absX, absY)) {
  1031.                     getActionSender().setString(p, "", 494, 2);
  1032.                     c.stop();
  1033.                 }
  1034.             }
  1035.         }, 1000);
  1036.     };
  1037.  
  1038.     public int getWildernessLevel() {
  1039.         int level = 0;
  1040.         if (absY >= 3525 && absY <= 3527) {
  1041.             level = 1;
  1042.         } else if (absY >= 3526 && absY <= 3535) {
  1043.             level = 2;
  1044.         } else {
  1045.             level = 3 + (int)Math.ceil((absY - 3536) / 8);
  1046.         }
  1047.         if (level < 0 || absY < 3525) {
  1048.             level = 0;
  1049.         }
  1050.         if (level < 0 || absX < 2945) {
  1051.             level = 0;
  1052.         }
  1053.         if (level < 0 || absY > 4000 && absY < 8000) {
  1054.             level = 0;
  1055.         }
  1056.         if (level < 0 || absX > 3390) {
  1057.             level = 0;
  1058.         }
  1059.         if (!isPVP()) {
  1060.             //getActionSender().setPlayerOption(this, "Null", 1, true);
  1061.             return level;
  1062.         }
  1063.         if (isPVP()) {
  1064.             double base = 5 + (combatLevel * 0.10);
  1065.             int total = (int)Math.round(base) + level;
  1066.             if (wildernessZone(absX, absY)) {
  1067.                 return total;
  1068.             } else {
  1069.                 return 0;
  1070.             }
  1071.         }
  1072.         return level;  
  1073.     }
  1074.     public int getWildernessLevel2() {
  1075.         int level = 0;
  1076.         if (absY >= 3525 && absY <= 3527) {
  1077.             level = 1;
  1078.         } else if (absY >= 3526 && absY <= 3535) {
  1079.             level = 2;
  1080.         } else {
  1081.             level = 3 + (int)Math.ceil((absY - 3536) / 8);
  1082.         }
  1083.         if (level < 0 || absY < 3525) {
  1084.             level = 0;
  1085.         }
  1086.         if (level < 0 || absX < 2945) {
  1087.             level = 0;
  1088.         }
  1089.         if (level < 0 || absY > 4000 && absY < 8000) {
  1090.             level = 0;
  1091.         }
  1092.         if (level < 0 || absX > 3390) {
  1093.             level = 0;
  1094.         }
  1095.         if (!isPVP()) {
  1096.             //getActionSender().setPlayerOption(this, "Null", 1, true);
  1097.             return level;
  1098.         }
  1099.         return level;  
  1100.     }
  1101.  
  1102.     public boolean properWildernessLevel(int thisCombat, int opponentCombat) {
  1103.         int difference = thisCombat >= opponentCombat ? thisCombat - opponentCombat : opponentCombat - thisCombat;
  1104.         return getWildernessLevel() >= difference;
  1105.     }
  1106.  
  1107.     public void restoreTabs(Player p) {
  1108.         for (int b = 16; b <= 21; b++) {
  1109.             p.getActionSender().setInterfaceConfig(p, 548, b, false);
  1110.         }
  1111.  
  1112.         for (int a = 32; a <= 38; a++) {
  1113.             p.getActionSender().setInterfaceConfig(p, 548, a, false);
  1114.         }
  1115.         p.calculateEquipmentBonus();
  1116.  
  1117.         p.getActionSender().setInterfaceConfig(p, 548, 14, false);
  1118.         p.getActionSender().setInterfaceConfig(p, 548, 31, false);
  1119.         p.getActionSender().setInterfaceConfig(p, 548, 63, false);
  1120.  
  1121.         p.getActionSender().setInterfaceConfig(p, 548, 72, false);
  1122.     }
  1123.  
  1124.     public void hideTabs(Player p) {
  1125.         for (int b = 16; b <= 21; b++) {
  1126.             p.getActionSender().setInterfaceConfig(p, 548, b, true);
  1127.         }
  1128.  
  1129.         for (int a = 32; a <= 38; a++) {
  1130.             p.getActionSender().setInterfaceConfig(p, 548, a, true);
  1131.         }
  1132.         p.calculateEquipmentBonus();
  1133.  
  1134.         p.getActionSender().setInterfaceConfig(p, 548, 14, true);
  1135.         p.getActionSender().setInterfaceConfig(p, 548, 31, true);
  1136.         p.getActionSender().setInterfaceConfig(p, 548, 63, true);
  1137.  
  1138.         p.getActionSender().setInterfaceConfig(p, 548, 72, true);
  1139.     }
  1140.  
  1141.     public int[] economyItems = {
  1142.             11696, 11698, 11700, 11694, 11730, 3140, 11718, 11720, 11722, 11724, 11726, 11728,
  1143.             11690, 11702, 11704, 11706, 11708, 10581, 10566, 10637, 385, 391, 2440, 2434, 6685,
  1144.             11235, 4151, 12670, 12671, 4153
  1145.     };
  1146.     /**
  1147.      * Summoning variables
  1148.      */
  1149.     public int summonTeleDelay = -1;
  1150.     public int summonDrainDelay = -1;
  1151.     public boolean callFamiliar;
  1152.     public boolean familiarDissMiss;
  1153.     public boolean summonedFamiliar;
  1154.     public int[] regularStaffs = {
  1155.             1381
  1156.     };
  1157.     public int[] otherStaffs = {
  1158.             4675
  1159.     };
  1160.     public int[] hugeNpcs = {
  1161.             50, 1155, 1157, 1158, 1160, 2745, 6222, 6203
  1162.     };
  1163.     public int[] slayerType = {
  1164.             1615, 5363, 55, 54, 941, 2783
  1165.     };
  1166.     public int[] slayerArray = {
  1167.             Misc.random(49)
  1168.     };
  1169.     public boolean canPray(int prayer) {
  1170.         if (skillLvl[5] > 0 && getLevelForXP(5) >= prayers[prayer][0]) {
  1171.             return true;
  1172.         }
  1173.         return false;
  1174.     }
  1175.  
  1176.     public boolean usingPrayer(int prayer) {
  1177.         return prayers[prayer][1] == 1;
  1178.     }
  1179.  
  1180.     public double[][] prayers = {{1, 0, 5}, {4, 0, 5}, {7, 0, 5}, {8, 0, 5}, {9, 0, 5}, {10, 0, 10}, {13, 0, 10}, {16, 0, 10}, {19, 0, 1.67}, {22, 0, 3.33}, {25, 0, 3.33}, {26, 0, 10}, {27, 0, 10}, {28, 0, 20}, {31, 0, 20}, {34, 0, 20}, {36, 0, 20}, {37, 0, 20}, {40, 0, 20}, {43, 0, 20}, {44, 0, 20}, {45, 0, 20}, {46, 0, 5}, {49, 0, 10}, {52, 0, 30}, {60, 0, 38.33}, {70, 0, 38.33}};
  1181.     public boolean usingPrayer() {
  1182.         int i = 0;
  1183.         while (i <= 26) {
  1184.             if (prayers[i][1] == 1) return true;
  1185.             i++;
  1186.         }
  1187.         return false;
  1188.     }
  1189.  
  1190.     public void togglePrayer(int prayer, int toggle) {
  1191.         int[] configuration = {83, 84, 85, 862, 863, 86, 87, 88, 89, 90, 91, 864, 865, 92, 93, 94, 1168, 95, 96, 97, 866, 867, 98, 99, 100, 1052, 1053};
  1192.         prayers[prayer][1] = toggle;
  1193.         getActionSender().setConfig(this, configuration[prayer], toggle);
  1194.     }
  1195.  
  1196.     public double prayerDrain() {
  1197.         int i = 0;
  1198.         double drainPerMinute = 0;
  1199.         while (i <= 26) {
  1200.             if (usingPrayer(i)) drainPerMinute += prayers[i][2];
  1201.             i++;
  1202.         }
  1203.         drainPerMinute *= 1 + (equipmentBonus[11] / 30);
  1204.         return drainPerMinute / 175;
  1205.     }
  1206.  
  1207.     public void switchPrayers(int[] prayers, int prayer) {
  1208.         if (!canPray(prayer)) {
  1209.             return;
  1210.         }
  1211.         for (int i : prayers) {
  1212.             if (usingPrayer(i)) {
  1213.                 togglePrayer(i, 0);
  1214.             }
  1215.         }
  1216.     }
  1217.     public void prayerSounds(int prayer) {
  1218.         int sound = 0;
  1219.         switch (prayer) {
  1220.         case 0: sound = 2690; break;
  1221.         case 1: sound = 2688; break;
  1222.         case 2: sound = 2664; break;
  1223.         case 3: sound = 2685; break;
  1224.         case 4: sound = 2668; break;
  1225.         case 5: sound = 2684; break;
  1226.         case 6: sound = 2689; break;
  1227.         case 7: sound = 2662; break;
  1228.         case 8: sound = 2679; break;
  1229.         case 9: sound = 2678; break;
  1230.         case 10: sound = 0; break;
  1231.         case 11: sound = 2666; break;
  1232.         case 12: sound = 2670; break;
  1233.         case 13: sound = 2687; break;
  1234.         case 14: sound = 2691; break;
  1235.         case 15: sound = 2667; break;
  1236.         case 16: sound = 0; break;
  1237.         case 17: sound = 2675; break;
  1238.         case 18: sound = 2677; break;
  1239.         case 19: sound = 2676; break;
  1240.         case 20: sound = 2665; break;
  1241.         case 21: sound = 2669; break;
  1242.         case 22: sound = 2682; break;
  1243.         case 23: sound = 2680; break;
  1244.         case 24: sound = 2686; break;
  1245.         case 25: sound = 3826; break;
  1246.         case 26: sound = 3825; break;
  1247.         }
  1248.         if (sound != 0) {
  1249.             getActionSender().addSoundEffect(this, sound, 1, 0, 0);
  1250.         }
  1251.     }
  1252.     public void resetPrayer() {
  1253.         int i = 0;
  1254.         while (i <= 26) {
  1255.             togglePrayer(i, 0);
  1256.             i++;
  1257.         }
  1258.         drainCount = 0;
  1259.         headIconPrayer = -1;
  1260.         updateReq = true;
  1261.         appearanceUpdateReq = true;
  1262.     }
  1263.     public int[] strangeItems = {
  1264.             6570
  1265.     };
  1266.     public int[] rangeBows = {
  1267.             841, 843, 845, 847, 849, 851, 853,
  1268.             855, 857, 859, 861,6724, 9174, 9176, 9177,
  1269.             9179, 9181, 9183, 9185
  1270.     };
  1271.     public int[] rangeArrows = {
  1272.             882, 884, 886, 888, 890, 892
  1273.     };
  1274.     public int[] godSwords = {
  1275.             11694, 11696, 11698, 11700
  1276.     };
  1277.     public Player(Socket socket, int id) {
  1278.         this.socket = new PlayerSocket(this, socket);
  1279.         playerId = id;
  1280.         look[0] = 0;
  1281.         look[1] = 10;
  1282.         look[2] = 18;
  1283.         look[3] = 26;
  1284.         look[4] = 33;
  1285.         look[5] = 36;
  1286.         look[6] = 42;
  1287.         for (int i = 0; i < skillLvl.length; i++) {
  1288.             skillLvl[i] = 1;
  1289.             skillXP[i] = 0;
  1290.             skillLvl[3] = 10;
  1291.             skillXP[3] = 1155;
  1292.         }
  1293.         for (int i = 0; i < items.length; i++) {
  1294.             items[i] = -1;
  1295.             itemsN[i] = 0;
  1296.         }
  1297.         for (int i = 0; i < equipment.length; i++) {
  1298.             equipment[i] = -1;
  1299.         }
  1300.         for (int i = 0; i < bankItems.length; i++) {
  1301.             bankItems[i] = -1;
  1302.         }
  1303.     }
  1304.  
  1305.     public boolean skillCapeEquiped() {
  1306.         for (int i = 10639; i < 10663; i++) {
  1307.             for (int j = 9747; j < 9812; j++) {
  1308.                 if (equipment[1] == i || equipment[1] == j || equipment[1] == 12169 || equipment[1] == 12170) {
  1309.                     return true;
  1310.                 }
  1311.             }
  1312.         }
  1313.         return false;
  1314.     }
  1315.  
  1316.     public void processTimers() { //Processes evenly at 1000 milliseconds
  1317.         if (freezeDelay > 0) {
  1318.             freezeDelay--;
  1319.             if (freezeDelay == 0) {
  1320.                 immunityTimer = 2.5;
  1321.                 freezeDelay = -1;
  1322.             }
  1323.         }
  1324.         if (immunityTimer > 0)
  1325.             immunityTimer--;
  1326.         if (vengeanceDelay > 0)
  1327.             vengeanceDelay--;
  1328.         if (spellbookSwap) {
  1329.             getActionSender().setTab(this, 79, spellbook);
  1330.             spellbookSwap = false;
  1331.             usedSpellbookSwap = false;
  1332.         }
  1333.         if (attackedByNpc != null) {
  1334.             count++;
  1335.             if (count == 4) {
  1336.                 NPC n = Server.engine.npcs[attackNpc];
  1337.                 if (n != null) {
  1338.                     if (attackedByNpcCount >= 1)
  1339.                         attackedByNpcCount = 0;
  1340.                     attackedByNpc = null;
  1341.                     n.underAttack = false;
  1342.                     n.playerIndex = 0;
  1343.                     count = 0;
  1344.                 }
  1345.             }
  1346.         }
  1347.         if (attackedBy != null) {
  1348.             count++;
  1349.             if (count == 6) {
  1350.                 NPC n = Server.engine.npcs[attackNpc];
  1351.                 if (n != null) {
  1352.                     if (attackedByNpc != null)
  1353.                         attackedByNpc = null;
  1354.                     if (n.playerIndex != 0)
  1355.                         n.playerIndex = 0;
  1356.                 }
  1357.                 attacking = null;
  1358.                 attackedBy = null;
  1359.                 attackedByCount--;
  1360.                 count = 0;
  1361.             }      
  1362.         }
  1363.         if (cantPray > 0)
  1364.             cantPray--;
  1365.         if (stunned > 0)
  1366.             stunned--;
  1367.         if (logoutTimer > 0)
  1368.             logoutTimer--;
  1369.         if (restoreSpecialTimer > 0)
  1370.             restoreSpecialTimer--;
  1371.     }
  1372.  
  1373.     public int cantPray;
  1374.     public void attackPlayer() {
  1375.         PlayerCombat pc = new PlayerCombat(this);
  1376.         pc.attackPlayer();
  1377.     }
  1378.  
  1379.     private int getAttackingDistance() {
  1380.         return 7;
  1381.     }
  1382.  
  1383.     public void process() {
  1384.  
  1385.         if (alchDelay > 0) {
  1386.             alchDelay--;
  1387.         }
  1388.         if (teleblockTimer > 0)
  1389.             teleblockTimer--;
  1390.         if (teleblockTimer == 0) {
  1391.             teleblocked = false;
  1392.             teleblockTimer = -1;
  1393.             getActionSender().sendMessage(this, "The teleport block has worn off.");
  1394.         }
  1395.         if (justSwitched >= 0)
  1396.             justSwitched--;
  1397.         if (justSwitched == 0) {
  1398.             getActionSender().setItems(this, 387, 28, 94, equipment, equipmentN);
  1399.             calculateEquipmentBonus();
  1400.             setEquipmentBonus();
  1401.         }
  1402.         if (leverTeleportDelay > 0)
  1403.             leverTeleportDelay--;
  1404.         if (leverTeleportDelay == 0) {
  1405.             teleportTo(leverTeleportX, leverTeleportY, leverTeleportH, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
  1406.             lever = false;
  1407.             leverTeleportDelay--;
  1408.         }
  1409.         if (followingPlayer)
  1410.             Engine.playerFollow.followPlayer(this);
  1411.         if (magicGraphicDelay > 0) {
  1412.             magicGraphicDelay--;
  1413.         } else if (magicGraphicDelay == 0) {
  1414.             Player opp = Server.engine.players[magicOppIndex];
  1415.             PlayerMagic playerMagic = new PlayerMagic(this);
  1416.             playerMagic.appendGraphic(spellbook, spell);
  1417.             /*if (opp != null) {
  1418.                 if (Misc.getDistance(absX, absY, opp.absX, opp.absY) > getAttackingDistance() - 1) {
  1419.                     if (freezeDelay == 0) {
  1420.                         if (opp.absX - absX > 7 && opp.absY - absY > 7) {
  1421.                             playerWalk(absX + ((opp.absX - absX) - 7), absY + ((opp.absY - absY) - 7), 0, 0);
  1422.                         } else if (opp.absX - absX > 7 && absY - opp.absY > 7) {
  1423.                             playerWalk(absX + ((opp.absX - absX) - 7), absY - ((absY - opp.absY) - 7), 0, 0);
  1424.                         } else if (absX - opp.absX > 7 && opp.absY - absY > 7) {
  1425.                             playerWalk(absX - ((absX - opp.absX) - 7), absY + ((opp.absY - absY) - 7), 0, 0);
  1426.                         } else if (absX - opp.absX > 7 && absY - opp.absY > 7) {
  1427.                             playerWalk(absX - ((absX - opp.absX) - 7), absY - ((absY - opp.absY) - 7), 0, 0);
  1428.                         } else if (opp.absX - absX > 7) {
  1429.                             playerWalk(absX + ((opp.absX - absX) - 7), absY, 0, 0);
  1430.                         } else if (absX - opp.absX > 7) {
  1431.                             playerWalk(absX - ((absX - opp.absX) - 7), absY, 0, 0);
  1432.                         } else if (opp.absY - absY > 7) {
  1433.                             playerWalk(absX, absY + ((opp.absY - absY) - 7), 0, 0);
  1434.                         } else if (absY - opp.absY > 7) {
  1435.                             playerWalk(absX, absY - ((absY - opp.absY) - 7), 0, 0);
  1436.                         }
  1437.                     }
  1438.                 }
  1439.             }*/
  1440.             magicGraphicDelay--;
  1441.         }
  1442.         if (magicDamageDelay > 0) {
  1443.             magicDamageDelay--;
  1444.         } else if (magicDamageDelay == 0) {
  1445.             Player opp = Server.engine.players[magicOppIndex];
  1446.             PlayerMagic playerMagic = new PlayerMagic(this);
  1447.             playerMagic.appendDamage(spellbook, spell);
  1448.             /*if (opp != null) {
  1449.                 if (Misc.getDistance(absX, absY, opp.absX, opp.absY) > getAttackingDistance() - 1) {
  1450.                     if (freezeDelay == 0) {
  1451.                         if (opp.absX - absX > 7 && opp.absY - absY > 7) {
  1452.                             playerWalk(absX + ((opp.absX - absX) - 7), absY + ((opp.absY - absY) - 7), 0, 0);
  1453.                         } else if (opp.absX - absX > 7 && absY - opp.absY > 7) {
  1454.                             playerWalk(absX + ((opp.absX - absX) - 7), absY - ((absY - opp.absY) - 7), 0, 0);
  1455.                         } else if (absX - opp.absX > 7 && opp.absY - absY > 7) {
  1456.                             playerWalk(absX - ((absX - opp.absX) - 7), absY + ((opp.absY - absY) - 7), 0, 0);
  1457.                         } else if (absX - opp.absX > 7 && absY - opp.absY > 7) {
  1458.                             playerWalk(absX - ((absX - opp.absX) - 7), absY - ((absY - opp.absY) - 7), 0, 0);
  1459.                         } else if (opp.absX - absX > 7) {
  1460.                             playerWalk(absX + ((opp.absX - absX) - 7), absY, 0, 0);
  1461.                         } else if (absX - opp.absX > 7) {
  1462.                             playerWalk(absX - ((absX - opp.absX) - 7), absY, 0, 0);
  1463.                         } else if (opp.absY - absY > 7) {
  1464.                             playerWalk(absX, absY + ((opp.absY - absY) - 7), 0, 0);
  1465.                         } else if (absY - opp.absY > 7) {
  1466.                             playerWalk(absX, absY - ((absY - opp.absY) - 7), 0, 0);
  1467.                         }
  1468.                     } else {
  1469.                         return;
  1470.                     }
  1471.                 }
  1472.             }*/
  1473.             magicDamageDelay--;
  1474.         }
  1475.         if (magicAffectDelay > 0) {
  1476.             magicAffectDelay--;
  1477.         } else if (magicAffectDelay == 0) {
  1478.             Player opp = Server.engine.players[magicOppIndex];
  1479.             PlayerMagic playerMagic = new PlayerMagic(this);
  1480.             playerMagic.appendAffect(spellbook, spell);
  1481.             /*if (opp != null) {
  1482.                 if (Misc.getDistance(absX, absY, opp.absX, opp.absY) > getAttackingDistance() - 1) {
  1483.                     if (freezeDelay == 0) {
  1484.                         if (opp.absX - absX > 7 && opp.absY - absY > 7) {
  1485.                             playerWalk(absX + ((opp.absX - absX) - 7), absY + ((opp.absY - absY) - 7), 0, 0);
  1486.                         } else if (opp.absX - absX > 7 && absY - opp.absY > 7) {
  1487.                             playerWalk(absX + ((opp.absX - absX) - 7), absY - ((absY - opp.absY) - 7), 0, 0);
  1488.                         } else if (absX - opp.absX > 7 && opp.absY - absY > 7) {
  1489.                             playerWalk(absX - ((absX - opp.absX) - 7), absY + ((opp.absY - absY) - 7), 0, 0);
  1490.                         } else if (absX - opp.absX > 7 && absY - opp.absY > 7) {
  1491.                             playerWalk(absX - ((absX - opp.absX) - 7), absY - ((absY - opp.absY) - 7), 0, 0);
  1492.                         } else if (opp.absX - absX > 7) {
  1493.                             playerWalk(absX + ((opp.absX - absX) - 7), absY, 0, 0);
  1494.                         } else if (absX - opp.absX > 7) {
  1495.                             playerWalk(absX - ((absX - opp.absX) - 7), absY, 0, 0);
  1496.                         } else if (opp.absY - absY > 7) {
  1497.                             playerWalk(absX, absY + ((opp.absY - absY) - 7), 0, 0);
  1498.                         } else if (absY - opp.absY > 7) {
  1499.                             playerWalk(absX, absY - ((absY - opp.absY) - 7), 0, 0);
  1500.                         }
  1501.                     } else {
  1502.                         return;
  1503.                     }
  1504.                 }
  1505.             }*/
  1506.             magicAffectDelay--;
  1507.         }
  1508.         if (cuedSpells > 0 && combatDelay == 0) {
  1509.             try {
  1510.                 Player opp = Server.engine.players[magicOppIndex];
  1511.                 PlayerMagic playerMagic = new PlayerMagic(this);
  1512.                 playerMagic.combatMagic(opp, spellbook, cuedSpell);
  1513.                 /*if (opp != null) {
  1514.                     if (Misc.getDistance(absX, absY, opp.absX, opp.absY) > getAttackingDistance() - 1) {
  1515.                         if (freezeDelay == 0) {
  1516.                             if (opp.absX - absX > 7 && opp.absY - absY > 7) {
  1517.                                 playerWalk(absX + ((opp.absX - absX) - 7), absY + ((opp.absY - absY) - 7), 0, 0);
  1518.                             } else if (opp.absX - absX > 7 && absY - opp.absY > 7) {
  1519.                                 playerWalk(absX + ((opp.absX - absX) - 7), absY - ((absY - opp.absY) - 7), 0, 0);
  1520.                             } else if (absX - opp.absX > 7 && opp.absY - absY > 7) {
  1521.                                 playerWalk(absX - ((absX - opp.absX) - 7), absY + ((opp.absY - absY) - 7), 0, 0);
  1522.                             } else if (absX - opp.absX > 7 && absY - opp.absY > 7) {
  1523.                                 playerWalk(absX - ((absX - opp.absX) - 7), absY - ((absY - opp.absY) - 7), 0, 0);
  1524.                             } else if (opp.absX - absX > 7) {
  1525.                                 playerWalk(absX + ((opp.absX - absX) - 7), absY, 0, 0);
  1526.                             } else if (absX - opp.absX > 7) {
  1527.                                 playerWalk(absX - ((absX - opp.absX) - 7), absY, 0, 0);
  1528.                             } else if (opp.absY - absY > 7) {
  1529.                                 playerWalk(absX, absY + ((opp.absY - absY) - 7), 0, 0);
  1530.                             } else if (absY - opp.absY > 7) {
  1531.                                 playerWalk(absX, absY - ((absY - opp.absY) - 7), 0, 0);
  1532.                             }
  1533.                         } else {
  1534.                             return;
  1535.                         }
  1536.                     }
  1537.                 }*/
  1538.                 cuedSpells = 0;
  1539.             } catch (Exception e) {
  1540.             }
  1541.         }
  1542.  
  1543.         if (usingPrayer()) {
  1544.             drainCount += prayerDrain();
  1545.             if (!isDead) {
  1546.                 if (drainCount >= 1) {
  1547.                     skillLvl[5]--;
  1548.                     getActionSender().setSkillLvl(this, 5);
  1549.                     drainCount--;
  1550.                 }
  1551.             }
  1552.             if (skillLvl[5] <= 0) {
  1553.                 skillLvl[5] = 0;
  1554.                 getActionSender().addSoundEffect(this, 2672, 1, 0, 0);
  1555.                 getActionSender().setSkillLvl(this, 5);
  1556.                 getActionSender().sendMessage(this, "You have run out of Prayer points; you must recharge at an altar.");
  1557.                 resetPrayer();
  1558.             }
  1559.         }
  1560.         if (disconnected[0] && !disconnected[1] && attackedBy != null) {
  1561.             logoutTimer = 9999;
  1562.         }
  1563.         if (disconnected[0] && !disconnected[1] && (isDead || attackedBy == null && logoutTimer > 15)) {
  1564.             logoutTimer = 15;
  1565.         }
  1566.         if (disconnected[0] && (usedLogout || logoutTimer == 0)) {
  1567.             try {
  1568.                 if (heightLevel != 0) heightLevel = heightLevel;
  1569.                 Engine.fileManager.saveCharacter(this);
  1570.             } catch (Exception e) {
  1571.             }
  1572.             disconnected[1] = true;
  1573.         }
  1574.         if (deathEmoteDelay > 0) {
  1575.             deathEmoteDelay--;
  1576.         }
  1577.         if (deathEmoteDelay == 0) {
  1578.             requestAnim(9055, 0); //836, 2261
  1579.             if (usingPrayer(22)) {
  1580.                 requestGFX(437, 0);
  1581.                 if (multiwayCombatZone(absX, absY)) {
  1582.                     try {
  1583.                         for (Player player : Server.engine.players) {
  1584.                             if (Misc.getDistance(absX, absY, player.absX, player.absY) <= 1) {
  1585.                                 player.append1Hit(getRandom((int)Math.floor(getLevelForXP(5) * 0.25)), 0);
  1586.                             }
  1587.                         }
  1588.                     } catch (Exception e) {
  1589.                     }
  1590.                 } else {
  1591.                     try {
  1592.                         Server.engine.players[hitIndex].append1Hit(getRandom((int)Math.floor(getLevelForXP(5) * 0.25)), 0);
  1593.                     } catch (Exception e) {
  1594.                     }
  1595.                 }
  1596.             }
  1597.  
  1598.             isDead = true;
  1599.             deathDelay = 4;
  1600.             deathEmoteDelay = -1;
  1601.         }
  1602.         if (clickDelay > 0) {
  1603.             clickDelay--;
  1604.         }
  1605.         if (teleDelay > 0) {
  1606.             teleDelay--;
  1607.         }
  1608.         if (equipSpecDelay > 0) {
  1609.             equipSpecDelay--;
  1610.         }
  1611.  
  1612.         if (rangeDmgDelay > 0) {
  1613.             rangeDmgDelay--;
  1614.         }
  1615.         if (rangeDmgDelay == 0) {
  1616.             PlayerCombat PC2 = new PlayerCombat(this);
  1617.             PC2.appendRangeDamage();
  1618.         }
  1619.         if (rangeDmgDelay2 > 0) {
  1620.             rangeDmgDelay2--;
  1621.         }
  1622.         if (rangeDmgDelay2 == 0) {
  1623.             PlayerCombat PC2 = new PlayerCombat(this);
  1624.             PC2.appendRangeDamage();
  1625.         }
  1626.         if (damageDelay1 > 0) {
  1627.             damageDelay1--;
  1628.         }
  1629.         if (damageDelay1 == 0 && enableDamage) {
  1630.             PlayerCombat playerCb = new PlayerCombat(this);
  1631.             playerCb.appendNpcDamageMelee();
  1632.         }
  1633.         if (atkDelay > 0) {
  1634.             atkDelay--;
  1635.         }
  1636.         if (atkDelay == 0 && attackingNpc) {
  1637.             PlayerCombat playCb = new PlayerCombat(this);
  1638.             playCb.attackNpc();
  1639.         }
  1640.         if (eatDelay > 0) {
  1641.             eatDelay--;
  1642.         }
  1643.         if (drinkDelay > 0) {
  1644.             drinkDelay--;
  1645.         }
  1646.  
  1647.         if (statDelay > 0) {
  1648.             statDelay -= usingPrayer(8) ? 2 : 1;
  1649.         } else {
  1650.             updateStats();
  1651.         }
  1652.         if (hpDelay > 0) {
  1653.             hpDelay -= usingPrayer(9) ? 2 : 1;
  1654.         } else {
  1655.             restoreHP();
  1656.         }
  1657.         if (specFillDelay > 0) {
  1658.             if (specAmount < 1000) {
  1659.                 specFillDelay--;
  1660.             } else {
  1661.                 specFillDelay = 50;
  1662.             }
  1663.         } else {
  1664.             if (specAmount < 1000) {
  1665.                 if (specAmount - 100 > 900) {
  1666.                     specAmount = 1000;
  1667.                 } else {
  1668.                     specAmount += 100;
  1669.                 }
  1670.                 getActionSender().setConfig2(this, 300, specAmount);
  1671.             }
  1672.             specFillDelay = 50;
  1673.         }
  1674.  
  1675.         if (animClickDelay > 0) {
  1676.             animClickDelay--;
  1677.         }
  1678.         if (waitDeathDelay > 0) {
  1679.             waitDeathDelay--;
  1680.         }
  1681.  
  1682.         if (deathDelay > 0) {
  1683.             deathDelay--;
  1684.         }
  1685.         if (deathDelay == 0 && isDead) {
  1686.             appendDeath();
  1687.         }
  1688.         if (combatDelay > 0) {
  1689.             combatDelay--;
  1690.         }
  1691.         if (attackingPlayer) {
  1692.             attackPlayer();
  1693.         }
  1694.         if (damageDelay > 0) {
  1695.             damageDelay--;
  1696.         }
  1697.         if (damageDelay == 0) {
  1698.             PlayerCombat PC = new PlayerCombat(this);
  1699.             PC.appendDamages();
  1700.         }
  1701.         if (mageDelay > 0) {
  1702.             mageDelay--;
  1703.         }
  1704.         if (specDelay > 0) {
  1705.             specDelay--;
  1706.         }
  1707.         if (specDelay == 0) {
  1708.             PlayerCombat PC1 = new PlayerCombat(this);
  1709.             PC1.appendSpecDamage();
  1710.         }
  1711.         if (secondSpecDelay > 0) {
  1712.             secondSpecDelay--;
  1713.         }
  1714.         if (secondSpecDelay == 0) {
  1715.             PlayerCombat PC1 = new PlayerCombat(this);
  1716.             PC1.appendSecondSpecDamage();
  1717.         }
  1718.         if (delayedDamageDelay > 0) {
  1719.             delayedDamageDelay--;
  1720.         }
  1721.         if (delayedDamageDelay == 0) {
  1722.             PlayerCombat PC1 = new PlayerCombat(this);
  1723.             PC1.appendDelayedDamage(delayedDamageHit);
  1724.         }
  1725.         if (runEnergyDelay > 0) {
  1726.             runEnergyDelay--;
  1727.         } else {
  1728.             if (runEnergy < 100) {
  1729.                 runEnergy++;
  1730.                 runEnergyUpdateReq = true;
  1731.             }
  1732.             runEnergyDelay = 4;
  1733.         }
  1734.         if (itemPickup) {
  1735.             Engine.packets.pickupItem.handlePacket(this, 0, 0);
  1736.         }
  1737.         if (playerOption1) {
  1738.             Engine.packets.playerOption1.handlePacket(this, 0, 0);
  1739.         }
  1740.         if (playerOption2) {
  1741.             Engine.packets.playerOption2.handlePacket(this, 0, 0);
  1742.         }
  1743.         if (playerOption3) {
  1744.             Engine.packets.playerOption3.handlePacket(this, 0, 0);
  1745.         }
  1746.         if (npcOption1) {
  1747.             Engine.packets.npcOption1.handlePacket(this, 0, 0);
  1748.         }
  1749.         if (npcOption2) {
  1750.             Engine.packets.npcOption2.handlePacket(this, 0, 0);
  1751.         }
  1752.         if (objectOption1) {
  1753.             Engine.packets.objectOption1.handlePacket(this, 0, 0);
  1754.         }
  1755.         if (objectOption2) {
  1756.             Engine.packets.objectOption2.handlePacket(this, 0, 0);
  1757.         }
  1758.         if (runEnergyUpdateReq) {
  1759.             getActionSender().setEnergy(this);
  1760.             runEnergyUpdateReq = false;
  1761.         }
  1762.         appendWilderness();
  1763.         if (teleDelay == 0) {
  1764.             teleDelay = -1;
  1765.             if (teletab) {
  1766.                 requestAnim(teleFinishAnim, 0);
  1767.                 requestGFX(teleFinishGFX, teleFinishGFXHeight);
  1768.                 teleDelay = 2;
  1769.                 teleFinishAnim = playerWeapon.getStandEmote(equipment[3]);
  1770.                 teleFinishGFX = -1;
  1771.             } else {
  1772.                 setCoords(teleX, teleY, teleH);
  1773.                 loadStaticObjects();
  1774.                 if (teleFinishAnim != -1) {
  1775.                     requestAnim(teleFinishAnim, 0);
  1776.                 }
  1777.                 if (teleFinishGFX != -1) {
  1778.                     requestGFX(teleFinishGFX, teleFinishGFXHeight);
  1779.                 }
  1780.             }
  1781.             if (!teletab) {
  1782.                 teleX = teleY = -1;
  1783.             }
  1784.             teletab = false;
  1785.         }
  1786.         if (clickDelay == 0) {
  1787.             clickDelay = -1;
  1788.             Engine.items.saveItems(this);
  1789.             //loadStaticObjects();
  1790.         }
  1791.     }
  1792.  
  1793.  
  1794.     public void potion(int potionID) {
  1795.         int root = 0;
  1796.         int toAdd = 0;
  1797.         int i = 0;
  1798.         switch (potionID) {
  1799.         case 2436:
  1800.         case 145:
  1801.         case 147:
  1802.         case 149:
  1803.             root = getLevelForXP(0);
  1804.             toAdd = 5 + (int)Math.round(root * 0.1414141414);
  1805.             if ((skillLvl[0] + toAdd) > (root + toAdd)) {
  1806.                 skillLvl[0] = root + toAdd;
  1807.             } else {
  1808.                 skillLvl[0] += toAdd;
  1809.             }
  1810.             getActionSender().setSkillLvl(this, 0);
  1811.             break;
  1812.  
  1813.         case 2440:
  1814.         case 157:
  1815.         case 159:
  1816.         case 161:
  1817.             root = getLevelForXP(2);
  1818.             toAdd = 5 + (int)Math.round(root * 0.1414141414);
  1819.             if ((skillLvl[2] + toAdd) > (root + toAdd)) {
  1820.                 skillLvl[2] = root + toAdd;
  1821.             } else {
  1822.                 skillLvl[2] += toAdd;
  1823.             }
  1824.             getActionSender().setSkillLvl(this, 2);
  1825.             break;
  1826.  
  1827.         case 2442:
  1828.         case 163:
  1829.         case 165:
  1830.         case 167:
  1831.             root = getLevelForXP(1);
  1832.             toAdd = 5 + (int)Math.round(root * 0.1414141414);
  1833.             if ((skillLvl[1] + toAdd) > (root + toAdd)) {
  1834.                 skillLvl[1] = root + toAdd;
  1835.             } else {
  1836.                 skillLvl[1] += toAdd;
  1837.             }
  1838.             getActionSender().setSkillLvl(this, 1);
  1839.             break;
  1840.  
  1841.         case 2446:
  1842.         case 175:
  1843.         case 177:
  1844.         case 179:
  1845.             Engine.poison.startPoison(this, 0);
  1846.             break;
  1847.  
  1848.         case 2444:
  1849.         case 169:
  1850.         case 171:
  1851.         case 173:
  1852.             root = getLevelForXP(4);
  1853.             toAdd = 4 + (int)Math.round(root * 0.0909090909);
  1854.             if ((skillLvl[4] + toAdd) > (root + toAdd)) {
  1855.                 skillLvl[4] = root + toAdd;
  1856.             } else {
  1857.                 skillLvl[4] += toAdd;
  1858.             }
  1859.             getActionSender().setSkillLvl(this, 4);
  1860.             break;
  1861.  
  1862.         case 3040:
  1863.         case 3042:
  1864.         case 3044:
  1865.         case 3046:
  1866.             if (skillLvl[6] + 4 > getLevelForXP(6) + 4) {
  1867.                 skillLvl[6] = getLevelForXP(6) + 4;
  1868.             } else {
  1869.                 skillLvl[6] += 4;
  1870.             }
  1871.             getActionSender().setSkillLvl(this, 6);
  1872.             break;
  1873.  
  1874.         case 2428:
  1875.         case 121:
  1876.         case 123:
  1877.         case 125:
  1878.             root = getLevelForXP(0);
  1879.             toAdd = 3 + (int)Math.round(root * 0.0909090909);
  1880.             if ((skillLvl[0] + toAdd) > (root + toAdd)) {
  1881.                 skillLvl[0] = root + toAdd;
  1882.             } else {
  1883.                 skillLvl[0] += toAdd;
  1884.             }
  1885.             getActionSender().setSkillLvl(this, 0);
  1886.             break;
  1887.  
  1888.         case 113:
  1889.         case 115:
  1890.         case 117:
  1891.         case 119:
  1892.             root = getLevelForXP(2);
  1893.             toAdd = 3 + (int)Math.round(root * 0.0909090909);
  1894.             if ((skillLvl[2] + toAdd) > (root + toAdd)) {
  1895.                 skillLvl[2] = root + toAdd;
  1896.             } else {
  1897.                 skillLvl[2] += toAdd;
  1898.             }
  1899.             getActionSender().setSkillLvl(this, 2);
  1900.             break;
  1901.  
  1902.         case 2432:
  1903.         case 133:
  1904.         case 135:
  1905.         case 137:
  1906.             root = getLevelForXP(1);
  1907.             toAdd = 3 + (int)Math.round(root * 0.0909090909);
  1908.             if ((skillLvl[1] + toAdd) > (root + toAdd)) {
  1909.                 skillLvl[1] = root + toAdd;
  1910.             } else {
  1911.                 skillLvl[1] += toAdd;
  1912.             }
  1913.             getActionSender().setSkillLvl(this, 1);
  1914.             break;
  1915.  
  1916.         case 2434:
  1917.         case 139:
  1918.         case 141:
  1919.         case 143:
  1920.             root = getLevelForXP(5);
  1921.             toAdd = 7 + (int)Math.round(root * 0.2424242424);
  1922.             if ((skillLvl[5] + toAdd) > root) {
  1923.                 if (skillLvl[5] < root) {
  1924.                     skillLvl[5] = root;
  1925.                 }
  1926.             } else {
  1927.                 skillLvl[5] += toAdd;
  1928.             }
  1929.             getActionSender().setSkillLvl(this, 5);
  1930.             break;
  1931.  
  1932.         case 2430:
  1933.         case 127:
  1934.         case 129:
  1935.         case 131:
  1936.             while (i <= 6) {
  1937.                 if (i == 3 || i == 5) {
  1938.                     i++;
  1939.                 }
  1940.                 root = getLevelForXP(i);
  1941.                 toAdd = 10 + (int)Math.round(root * 0.2929292929);
  1942.                 if ((skillLvl[i] + toAdd) > root) {
  1943.                     if (skillLvl[i] < root) {
  1944.                         skillLvl[i] = root;
  1945.                     }
  1946.                 } else {
  1947.                     skillLvl[i] += toAdd;
  1948.                 }
  1949.                 getActionSender().setSkillLvl(this, i);
  1950.                 i++;
  1951.             }
  1952.             break;
  1953.  
  1954.         case 3024:
  1955.         case 3026:
  1956.         case 3028:
  1957.         case 3030:
  1958.             while (i <= 23) {
  1959.                 if (i == 3) {
  1960.                     i++;
  1961.                 }
  1962.                 root = getLevelForXP(i);
  1963.                 toAdd = 8 + (int)Math.round(root * 0.2424242424);
  1964.                 if ((skillLvl[i] + toAdd) > root) {
  1965.                     if (skillLvl[i] < root) {
  1966.                         skillLvl[i] = root;
  1967.                     }
  1968.                 } else {
  1969.                     skillLvl[i] += toAdd;
  1970.                 }
  1971.                 getActionSender().setSkillLvl(this, i);
  1972.                 i++;
  1973.             }
  1974.             break;
  1975.  
  1976.         case 6685:
  1977.         case 6687:
  1978.         case 6689:
  1979.         case 6691:
  1980.             while (i <= 6) {
  1981.                 if (i == 5) {
  1982.                     i++;
  1983.                 }
  1984.                 root = getLevelForXP(i);
  1985.                 if (i == 0 || i == 2 || i == 4 || i == 6) {
  1986.                     toAdd = -1 * (2 + (int)Math.round(root * 0.0707070707));
  1987.                     if ((skillLvl[i] + toAdd) < 0) {
  1988.                         skillLvl[i] = 0;
  1989.                     } else {
  1990.                         skillLvl[i] += toAdd;
  1991.                     }
  1992.                 } else {
  1993.                     toAdd = 2 + (int)Math.round(root * (i == 1 ? 0.1919191919 : 0.1414141414));
  1994.                     if (skillLvl[i] + toAdd > root + toAdd) {
  1995.                         skillLvl[i] = root + toAdd;
  1996.                     } else {
  1997.                         skillLvl[i] += toAdd;
  1998.                     }
  1999.                 }
  2000.                 getActionSender().setSkillLvl(this, i);
  2001.                 i++;
  2002.             }
  2003.             break;
  2004.  
  2005.         case 2450:
  2006.         case 189:
  2007.         case 191:
  2008.         case 193:
  2009.             while (i <= 5) {
  2010.                 if (i == 4) {
  2011.                     i++;
  2012.                 }
  2013.                 root = getLevelForXP(i);
  2014.                 if (i == 5) {
  2015.                     toAdd = 9;
  2016.                     if (skillLvl[i] + toAdd > root) {
  2017.                         if (skillLvl[i] < root) {
  2018.                             skillLvl[i] = root;
  2019.                         }
  2020.                     } else {
  2021.                         skillLvl[i] += toAdd;
  2022.                     }
  2023.                     break;
  2024.                 }
  2025.                 if (i == 1 || i == 3) {
  2026.                     toAdd = -1 * (2 + (int)Math.round(root * 0.0909090909));
  2027.                     if (i == 3) {
  2028.                         append1Hit(-1 * toAdd, 0);
  2029.                     } else {
  2030.                         if ((skillLvl[i] + toAdd) < 0) {
  2031.                             skillLvl[i] = 0;
  2032.                         } else {
  2033.                             skillLvl[i] += toAdd;
  2034.                         }
  2035.                     }
  2036.                 } else {
  2037.                     toAdd = 2 + (int)Math.round(root * (i == 0 ? 0.1919191919 : 0.1111111111));
  2038.                     if (skillLvl[i] + toAdd > root + toAdd) {
  2039.                         skillLvl[i] = root + toAdd;
  2040.                     } else {
  2041.                         skillLvl[i] += toAdd;
  2042.                     }
  2043.                 }
  2044.                 getActionSender().setSkillLvl(this, i);
  2045.                 i++;
  2046.             }
  2047.             break;
  2048.         }
  2049.         requestAnim(829, 0);
  2050.         getActionSender().addSoundEffect(this, 2401, 1, 0, 0);
  2051.         combatDelay = 4;
  2052.         eatDelay = 3;
  2053.         drinkDelay = 2;
  2054.     }
  2055.     private int multi;
  2056.     private int savedEP = -1;
  2057.     private int savedEP2 = -1;
  2058.     public void appendWilderness() {
  2059.         wildyLevel = getWildernessLevel();
  2060.         if (savedLevel != wildyLevel) {
  2061.             savedLevel = wildyLevel;
  2062.             if (wildyLevel > 0) {
  2063.                 addWilderness();
  2064.             } else {
  2065.                 savedEP = -1;
  2066.                 removeWilderness();
  2067.             }
  2068.         }
  2069.  
  2070.  
  2071.  
  2072.         if (!wildernessZone(absX, absY) && (savedEP == -1 || savedEP2 != EPAmount)) {
  2073.             getActionSender().setOverlay(this, 494);
  2074.             if (EPAmount >= 0 && EPAmount <= 20)
  2075.                 getActionSender().setString(this, "<col=8B0000>EP: "+EPAmount+"<col=8B0000>%",494,1);
  2076.             if (EPAmount >= 21 && EPAmount <= 40)
  2077.                 getActionSender().setString(this, "<col=FF4500>EP: "+EPAmount+"<col=FF4500>%",494,1);
  2078.             if (EPAmount >= 41 && EPAmount <= 60)
  2079.                 getActionSender().setString(this, "<col=FFFF00>EP: "+EPAmount+"<col=FFFF00>%",494,1);
  2080.             if (EPAmount >= 61 && EPAmount <= 80)
  2081.                 getActionSender().setString(this, "<col=9ACD32>EP: "+EPAmount+"<col=9ACD32>%",494,1);
  2082.             if (EPAmount >= 81 && EPAmount <= 100)
  2083.                 getActionSender().setString(this, "<col=00FF00>EP: "+EPAmount+"<col=00FF00>%",494,1);
  2084.             getActionSender().setString(this, "", 494, 0);
  2085.             getActionSender().setString(this,"", 494, 2);
  2086.             savedEP = 0;
  2087.             savedEP2 = EPAmount;
  2088.             if (EPAmount > 100)
  2089.                 EPAmount = 100;
  2090.         }
  2091.         if (multiwayCombatZone(absX, absY) && multi == 0) {
  2092.             getActionSender().setInterfaceConfig(this, 745, 1, false);
  2093.             multi = 1;
  2094.         }
  2095.         if (!multiwayCombatZone(absX, absY) && multi == 1) {
  2096.             getActionSender().setInterfaceConfig(this, 745, 1, true);
  2097.             multi = 0;
  2098.         }
  2099.     }
  2100.     public void food(int foodID) {
  2101.         int healAmount = 0;
  2102.         int toDelayCombat = 6;
  2103.         int toDelayEat = 3;
  2104.         switch (foodID) {
  2105.         case 373: healAmount = 14; break;
  2106.         case 379: healAmount = 12; break;
  2107.         case 385: healAmount = 20; break;
  2108.         case 391: healAmount = 22; break;
  2109.         case 3144:
  2110.             healAmount = 18;
  2111.             toDelayCombat = combatDelay;
  2112.             drinkDelay = 3;
  2113.             break;
  2114.         case 7060: healAmount = 22; break;
  2115.         case 7946: healAmount = 16; break;
  2116.         case 10476:
  2117.             healAmount = 1 + Misc.random(2);
  2118.             runEnergy += runEnergy * .10;
  2119.             runEnergyUpdateReq = true;
  2120.             if (runEnergy + (runEnergy * .10) > 100) {
  2121.                 runEnergy = 100;
  2122.             }
  2123.             break;
  2124.         }
  2125.         requestAnim(829, 0);
  2126.         getActionSender().addSoundEffect(this, 2393, 1, 0, 0);
  2127.         updateHP(healAmount, true);
  2128.         getActionSender().sendMessage(this, "You eat the "+Engine.items.getItemName(foodID)+".");
  2129.         combatDelay = toDelayCombat;
  2130.         eatDelay = toDelayEat;
  2131.     }
  2132.  
  2133.     public boolean receivesPVPDrop(Player p, Player opp) {
  2134.         if (Server.socketListener.getAddress(p.socket.socket).equals(Server.socketListener.getAddress(opp.socket.socket))) {
  2135.             return false;
  2136.         }
  2137.         return true;
  2138.     }
  2139.  
  2140.     public void appendDeath() {
  2141.         if (deathDelay == 0 && isDead) {
  2142.             Player opp = Server.engine.players[hitIndex];
  2143.             String killer = getDealtDamage().getKiller();
  2144.             try {
  2145.                 if (rights < 4) {
  2146.                     dropStuff(opp.username);
  2147.                 }
  2148.                 getActionSender().sendMessage(opp, "You have defeated " +username+".");
  2149.                 if (receivesPVPDrop(this, opp)) {
  2150.                     opp.kills++;
  2151.                     opp.totalKills++;
  2152.                     opp.bhkills++;
  2153.                     DC++;
  2154.                     opp.KC++;
  2155.                 }
  2156.             } catch (Exception e) {
  2157.             }
  2158.  
  2159.             for (int i = 0; i < skillLvl.length; i++) {
  2160.                 skillLvl[i] = getLevelForXP(i);
  2161.                 getActionSender().setSkillLvl(this, i);
  2162.             }
  2163.             for (int i = 0; i < 1000; i++) {
  2164.                 requestAnim(playerWeapon.getStandEmote(equipment[3]), 0);
  2165.             }
  2166.  
  2167.             if (opp != null) {
  2168.                 opp.attacking = null;
  2169.                 opp.attackedBy = null;
  2170.                 opp.oppIndex = 0;
  2171.                 opp.hitIndex = 0;
  2172.                 opp.resetAttack();
  2173.                 opp.requestFaceTo(65535);
  2174.             }  
  2175.             attackNpc = 0;
  2176.             attackedInSingle = 0;
  2177.             attacking = null;
  2178.             attackedBy = null;
  2179.             oppIndex = 0;
  2180.             hitIndex = 0;
  2181.             resetAttack();
  2182.             setCoords(3093, 3490, 0);
  2183.             Engine.poison.startPoison(this, 0);
  2184.             getActionSender().sendMessage(this, "Oh dear, you have died.");
  2185.             magicGraphicDelay = -1;
  2186.             magicDamageDelay = -1;
  2187.             teleblockTimer = -1;
  2188.             deathDelay = -1;
  2189.             isDead = false;
  2190.             initialAttack = false;
  2191.             isSkulled = false;
  2192.             resetPrayer();
  2193.             headIconSkull = -1;
  2194.             skullVanishDelay = 0;
  2195.             specAmount = 1000;
  2196.             getActionSender().setConfig2(this, 300, 1000);
  2197.             getActionSender().removeOverlay(this);         
  2198.             appearanceUpdateReq = true;
  2199.             updateReq = true;
  2200.         }
  2201.     }
  2202.  
  2203.     public void resetAttack() {
  2204.         attackingPlayer = false;
  2205.         enemyIndex = 0;
  2206.         oppIndex = 0;
  2207.         hitOne = false;
  2208.         hitTwo = false;
  2209.         hitThree = false;
  2210.         hitFour = false;
  2211.         hit1 = 0;
  2212.         hit2 = 0;
  2213.         hit3 = 0;
  2214.         hit4 = 0;
  2215.         specDelay = -1;
  2216.         secondSpecDelay = -1;
  2217.     }
  2218.  
  2219.     /**
  2220.      * Get xp based on your level.
  2221.      * @param skillId The skill level to get the level based off XP for.
  2222.      * @return Returns the level based on the amount of XP the specified skill has.
  2223.      */
  2224.     public int getLevelForXP(int skillId) {
  2225.         int exp = skillXP[skillId];
  2226.         int points = 0;
  2227.         int output = 0;
  2228.         for (int lvl = 1; lvl < 100; lvl++) {
  2229.             points += Math.floor((double)lvl + 300.0 * Math.pow(2.0, (double)lvl / 7.0));
  2230.             output = (int)Math.floor(points / 4);
  2231.             if ((output - 1) >= exp) {
  2232.                 return lvl;
  2233.             }
  2234.         }
  2235.         return 99;
  2236.     }
  2237.  
  2238.     /**
  2239.      * Calculates equipment bonus.
  2240.      */
  2241.     public void calculateEquipmentBonus() {
  2242.         for (int i = 0; i < equipmentBonus.length; i++) {
  2243.             equipmentBonus[i] = 0;
  2244.         }
  2245.         for (int i = 0; i < equipment.length; i++) {
  2246.             if (equipment[i] > -1) {
  2247.                 for (int j = 0; j < Engine.items.maxListedItems; j++) {
  2248.                     if (Engine.items.itemLists[j] != null) {
  2249.                         if (Engine.items.itemLists[j].itemId == equipment[i]) {
  2250.                             for (int k = 0; k < equipmentBonus.length; k++) {
  2251.                                 equipmentBonus[k] += Engine.items.itemLists[j].bonuses[k];
  2252.                             }
  2253.                             break;
  2254.                         }
  2255.                     }
  2256.                 }
  2257.             }
  2258.         }
  2259.     }
  2260.  
  2261.     public void calculateIKOD() {
  2262.         int amountOfKeptItems = isSkulled ? (usingPrayer(10) ? 1 : 0) : (usingPrayer(10) ? 4 : 3);
  2263.         int[] allItems = new int[items.length + equipment.length];
  2264.         int[] allItemsN = new int[itemsN.length + equipmentN.length];
  2265.         int[] keptItems = new int[amountOfKeptItems];
  2266.         int[] toAdd = new int[keptItems.length];
  2267.         System.arraycopy(items, 0, allItems, 0, items.length);
  2268.         System.arraycopy(equipment, 0, allItems, items.length, equipment.length);
  2269.         System.arraycopy(itemsN, 0, allItemsN, 0, itemsN.length);
  2270.         System.arraycopy(equipmentN, 0, allItemsN, itemsN.length, equipmentN.length);
  2271.         for (int i = 0; i < keptItems.length; i++) {
  2272.             int index = 0;
  2273.             int standing = 0;
  2274.             for (int j = 0; j < allItems.length; j++) {
  2275.                 if (allItems[j] < 1) {
  2276.                     continue;
  2277.                 }
  2278.                 int price = (int)Math.round(1.10 * (1 * getItemValue(allItems[j])));
  2279.                 if (price > standing) {
  2280.                     index = j;
  2281.                     standing = price;
  2282.                 }
  2283.             }
  2284.             keptItems[i] = allItems[index];
  2285.             toAdd[i] = allItems[index];
  2286.             allItemsN[index]--;
  2287.             if (allItemsN[index] == 0) {
  2288.                 allItems[index] = 0;
  2289.             }
  2290.         }
  2291.         for (int i = 0; i < keptItems.length; i++) {
  2292.             ikod[i] = keptItems[i];
  2293.             if (ikod[i] == 0) ikod[i] = 6564;
  2294.         }
  2295.     }
  2296.  
  2297.     /**
  2298.      * Writes the equipment bonus.
  2299.      */
  2300.     public void setEquipmentBonus() {
  2301.         String[] bonusNames = Misc.bonusNames;
  2302.         int id = 35;
  2303.         for (int i = 0; i < equipmentBonus.length; i++) {
  2304.             getActionSender().setString(this, bonusNames[i] + ": " + (equipmentBonus[i] >= 0 ? "+" : "") + equipmentBonus[i], 667, id++);
  2305.             if (id == 45) {
  2306.                 id = 47;
  2307.             }
  2308.         }
  2309.         getActionSender().setString(this, "Summoning: +0", 667, 45);
  2310.     }
  2311.  
  2312.     public void openBank() {
  2313.         getActionSender().setConfig2(this, 563, 4194304);
  2314.         getActionSender().setConfig2(this, 1248, -2013265920);
  2315.         getActionSender().showInterface(this, 762);
  2316.         getActionSender().setInventory(this, 763);
  2317.         getActionSender().setBankOptions(this);
  2318.         getActionSender().setString(this, "Bank of Reborn 525" , 762, 24);
  2319.         getActionSender().setItems(this, -1, 64207, 95, bankItems, bankItemsN);
  2320.         getActionSender().setItems(this, -1, 64209, 93, items, itemsN);
  2321.         isBanking = true;
  2322.     }
  2323.  
  2324.     public void updateHP(int difference, boolean heal) {
  2325.         if (skillLvl[3] == 0) {
  2326.             return;
  2327.         }
  2328.         if (heal) {
  2329.             skillLvl[3] += difference;
  2330.             if (skillLvl[3] > getLevelForXP(3)) {
  2331.                 skillLvl[3] = getLevelForXP(3);
  2332.             }
  2333.         } else if (!heal) {
  2334.             skillLvl[3] -= difference;
  2335.             if (skillLvl[3] <= 0) {
  2336.                 skillLvl[3] = 0;
  2337.                 deathEmoteDelay = 3;
  2338.                 isDead = true;
  2339.                 attacking = null;
  2340.                 attackedBy = null;
  2341.                 Engine.playerMovement.resetWalkingQueue(this);
  2342.                 requestFaceTo(65535);
  2343.             }
  2344.         }
  2345.         getActionSender().setSkillLvl(this, 3);
  2346.         if ((skillLvl[3] <= Math.round(getLevelForXP(3) * 0.10) && skillLvl[3] > 0) && usingPrayer(23)) {
  2347.             requestGFX(436, 0);
  2348.             getActionSender().addSoundEffect(this, 2681, 1, 0, 0);
  2349.             skillLvl[3] += Math.round(getLevelForXP(5) * 0.25);
  2350.             skillLvl[5] = 0;
  2351.             getActionSender().setSkillLvl(this, 5);
  2352.         }
  2353.     }
  2354.  
  2355.     /**
  2356.      * Teleports a player.
  2357.      * @param x The x coordinate to teleport to.
  2358.      * @param y The y coordinate to teleport to.
  2359.      * @param height The height level to teleport to.
  2360.      * @param delay The delay before the teleport is done.
  2361.      * @param distance The offset you can teleport to, such as 1 for a max offset of x +/- 1 and y +/- 1.
  2362.      * @param emoteStart The emote to do right away.
  2363.      * @param emoteEnd The emote to do after teleporting.
  2364.      * @param gfxStart The graphic to do right away.
  2365.      * @param gfxStartH The height level to create the start graphic at.
  2366.      * @param gfxEnd The graphic to do after the teleport is done.
  2367.      * @param gfxEndH The finish graphic height.
  2368.      */
  2369.     public void teleportTo(int x, int y, int height, int delay, int distance, int emoteStart, int emoteEnd, int gfxStart,
  2370.             int gfxStartH, int gfxEnd, int gfxEndH) {
  2371.         if (isDead) {
  2372.             return;
  2373.         }
  2374.         if (teleblockTimer >= 0) {
  2375.             getActionSender().sendMessage(this, "You are teleport blocked!");
  2376.             return;
  2377.         }
  2378.         if (jailed > 0) {
  2379.             getActionSender().sendMessage(this, "You are jailed!");
  2380.             return;
  2381.         }
  2382.         if (getWildernessLevel() >= 21) {
  2383.         }
  2384.         itemPickup = false;
  2385.         playerOption1 = false;
  2386.         playerOption2 = false;
  2387.         playerOption3 = false;
  2388.         npcOption1 = false;
  2389.         npcOption2 = false;
  2390.         objectOption1 = false;
  2391.         objectOption2 = false;
  2392.         attackingPlayer = false;
  2393.         clickDelay = delay + 2;
  2394.         teleDelay = delay;
  2395.         if (distance > 0) {
  2396.             int xType = Misc.random(1);
  2397.             int yType = Misc.random(1);
  2398.             int xOffset = Misc.random(distance);
  2399.             int yOffset = Misc.random(distance);
  2400.             if (xType == 1)
  2401.                 x += -xOffset;
  2402.             else
  2403.                 x += xOffset;
  2404.             if(yType == 1)
  2405.                 y += -yOffset;
  2406.             else
  2407.                 y += yOffset;
  2408.         }
  2409.         teleX = x;
  2410.         teleY = y;
  2411.         teleH = height;
  2412.         Engine.playerMovement.resetWalkingQueue(this);
  2413.         requestAnim(emoteStart, 0);
  2414.         requestGFX(gfxStart, gfxStartH);
  2415.         teleFinishGFX = gfxEnd;
  2416.         teleFinishGFXHeight = gfxEndH;
  2417.         teleFinishAnim = emoteEnd;
  2418.     }
  2419.  
  2420.     /**
  2421.      * Set the player's coordinates.
  2422.      * @param x The x coordinate to teleport to.
  2423.      * @param y The y coordinate to teleport to.
  2424.      */
  2425.     public void setCoords(int x, int y, int height) {
  2426.         teleportToX = x;
  2427.         teleportToY = y;
  2428.         heightLevel = height;
  2429.         didTeleport = true;
  2430.         loadStaticObjects();
  2431.     }
  2432.     /**
  2433.      *Pm void
  2434.      */
  2435.     public void friendsLoggedIn() {
  2436.         for(Long friend : friends) {
  2437.             getActionSender().sendFriend(this, friend, getWorld(friend));
  2438.         }
  2439.         long[] array = new long[ignores.size()];
  2440.         int i = 0;
  2441.         for(Long ignore : ignores) {
  2442.             if(ignore != null)
  2443.                 array[i++] = ignore;
  2444.         }
  2445.         getActionSender().sendIgnores(this, array);
  2446.         long me = Misc.stringToLong(username);
  2447.         for(Player client : Engine.players) {
  2448.             if(client == null) continue;
  2449.             if(client.friends.contains(me)) {
  2450.                 client.getActionSender().sendFriend(client, me, 66);
  2451.             }
  2452.         }
  2453.     }
  2454.     public int getWorld(long friend) {
  2455.         for(Player client : Engine.players) {
  2456.             if(client != null && client.online) {
  2457.                 if(Misc.stringToLong(client.username) == friend) {
  2458.                     return 66;
  2459.                 }
  2460.             }
  2461.         }
  2462.         return 0;
  2463.     }
  2464.  
  2465.     /**
  2466.      * Req an animation for this player.
  2467.      * @param animId The amination to perform.
  2468.      * @param animD The delay before doing the animation.
  2469.      */
  2470.     public void requestAnim(int animId, int animD) {
  2471.         animReq = animId;
  2472.         animDelay = animD;
  2473.         animUpdateReq = true;
  2474.         updateReq = true;
  2475.     }
  2476.  
  2477.     /**
  2478.      * Req an graphic for this player.
  2479.      * @param gfxId The graphic to perform.
  2480.      * @param gfxD The delay or height or the gfx depending on the value.
  2481.      */
  2482.     public void requestGFX(int gfxId, int gfxD) {
  2483.         if (gfxD >= 100) {
  2484.             gfxD += 6553500;
  2485.         }
  2486.         gfxReq = gfxId;
  2487.         gfxDelay = gfxD;
  2488.         gfxUpdateReq = true;
  2489.         updateReq = true;
  2490.     }
  2491.  
  2492.     /**
  2493.      * Req this player faces NPC or player.
  2494.      * @param faceId The target to face.
  2495.      */
  2496.     public void requestFaceTo(int faceId) {
  2497.         faceToReq = faceId;
  2498.         faceToUpdateReq = true;
  2499.         updateReq = true;
  2500.     }
  2501.  
  2502.     public void appendNPCHit(int damage, int poison) {
  2503.         if (damage > skillLvl[3]) {
  2504.             damage = skillLvl[3];
  2505.         }
  2506.         updateHP(damage, false);
  2507.         if (!hit1UpdateReq) {
  2508.             hitDiff1 = damage;
  2509.             poisonHit1 = poison;
  2510.             hit1UpdateReq = true;
  2511.         } else {
  2512.             hitDiff2 = damage;
  2513.             poisonHit2 = poison;
  2514.             hit2UpdateReq = true;
  2515.         }
  2516.         updateReq = true;
  2517.     }
  2518.     public int vengDelay;
  2519.     public int damagez;
  2520.     public void appendHit(int damage, int poison) {
  2521.         Player opp = Server.engine.players[hitIndex];
  2522.         if (opp != null) {
  2523.             if (opp.isDead) {
  2524.                 return;
  2525.             }
  2526.             if (damage > skillLvl[3]) {
  2527.                 damage = skillLvl[3];
  2528.                 damagez = skillLvl[3];
  2529.             }
  2530.             damagez = damage;
  2531.             if (opp.equipment[5] == 13742) {//Elysian Effect
  2532.                 if (Misc.random(4) > 0) {
  2533.                     double damages = damage;
  2534.                     double damageDeduction = ((double)damages)/((double)4);
  2535.                     damage = damage-((int)Math.round(damageDeduction));
  2536.                 }
  2537.             }
  2538.             if (opp.equipment[5] == 13740) {//Divine Effect
  2539.                 double damages2 = damage;
  2540.                 double prayer = opp.skillLvl[5];
  2541.                 double possibleDamageDeduction = ((double)damages2)/((double)3.33);//30% of Damage Inflicted
  2542.                 double actualDamageDeduction;
  2543.                 if ((prayer * 2) < possibleDamageDeduction) {
  2544.                     actualDamageDeduction = (prayer * 2);//Partial Effect(Not enough prayer points)
  2545.                 } else {
  2546.                     actualDamageDeduction = possibleDamageDeduction;//Full effect
  2547.                 }
  2548.                 double prayerDeduction = ((double)actualDamageDeduction)/((double)2);//Half of the damage deducted
  2549.                 damage = damage-((int)Math.round(actualDamageDeduction));
  2550.                 opp.skillLvl[5] = opp.skillLvl[5]-((int)Math.round(prayerDeduction));
  2551.                 opp.getActionSender().setSkillLvl(opp, 5);
  2552.             }
  2553.             updateHP(damage, false);
  2554.             if (autoRetaliate) {
  2555.                 enemyIndex = hitIndex;
  2556.                 attackingPlayer = true;
  2557.             }
  2558.             int[] skill = {-1, -1, -1};
  2559.             if (!usingMage) {
  2560.                 switch (opp.attackStyle()) {
  2561.                 case 1:
  2562.                     skill[0] = 0;
  2563.                     skill[1] = 0;
  2564.                     skill[2] = 0;
  2565.                     break;
  2566.                 case 2:
  2567.                     skill[0] = 2;
  2568.                     skill[1] = 2;
  2569.                     skill[2] = 2;
  2570.                     break;
  2571.                 case 3:
  2572.                     skill[0] = 1;
  2573.                     skill[1] = 1;
  2574.                     skill[2] = 1;
  2575.                     break;
  2576.                 case 4:
  2577.                     skill[0] = 0;
  2578.                     skill[1] = 1;
  2579.                     skill[2] = 2;
  2580.                     break;
  2581.                 case 5:
  2582.                 case 6:
  2583.                     skill[0] = 4;
  2584.                     skill[1] = 4;
  2585.                     skill[2] = 4;
  2586.                     break;
  2587.                 case 7:
  2588.                     opp.appendExperience((damage * 200), 4);
  2589.                     opp.appendExperience((damage * 200), 1);
  2590.                     opp.appendExperience((damage * 133), 3);
  2591.                     break;
  2592.                 }
  2593.                 for (int i : skill) {
  2594.                     if (i != -1) {
  2595.                         opp.appendExperience((damage * 133), i);
  2596.                     }
  2597.                 }
  2598.                 opp.appendExperience((damage * 133), 3);
  2599.             }
  2600.             if (opp.equipment[3] == 5698)
  2601.                 Engine.poison.checkForPoison(opp, this);
  2602.             opp.getDealtDamage().appendDamage(username,damage);
  2603.             if (opp.usingPrayer(24) && poison == 0) { //Smite
  2604.                 if (skillLvl[5] - (int)Math.round(damage * 0.25) > 0) {
  2605.                     skillLvl[5] -= (int)Math.round(damage / 4);
  2606.                     getActionSender().setSkillLvl(this, 5);
  2607.                 } else {
  2608.                     skillLvl[5] = 0;
  2609.                     getActionSender().setSkillLvl(this, 5);
  2610.                 }
  2611.             }
  2612.             if (vengeance && poison == 0) { //Vengeance
  2613.                 if (damage > 0) {
  2614.                     //vengUpdate(this);
  2615.                     long vengDelay = System.currentTimeMillis();
  2616.                     if (System.currentTimeMillis() - vengDelay >= 600) {
  2617.                         if (skillLvl[3] > 0) {
  2618.                             opp.append1Hit(((int)Math.floor(damagez * 0.75)), 0);
  2619.                         } else {
  2620.                             opp.append1Hit(0, 0);
  2621.                         }
  2622.                     }
  2623.                     requestForceChat("Taste vengeance!");
  2624.                     vengeance = false;
  2625.                 }
  2626.             }
  2627.             if (equipment[12] == 2550 && poison == 0) { //Ring of recoil
  2628.                 if (damage > 0) {
  2629.                     if (skillLvl[3] > 0) {
  2630.                         int recoil = 1 + ((int)Math.floor(damage * 0.10));
  2631.                         opp.append1Hit(recoil, 0);
  2632.                         totalDamageRecoiled += recoil;
  2633.                         if (totalDamageRecoiled >= 40) {
  2634.                             equipment[12] = -1;
  2635.                             equipmentN[12] = 0;
  2636.                             getActionSender().setItems(this, 387, 28, 93, equipment, equipmentN);
  2637.                             getActionSender().sendMessage(this, "Your ring of recoil has shattered.");
  2638.                             totalDamageRecoiled = 0;
  2639.                         }
  2640.                     } else {
  2641.                         opp.append1Hit(0, 0);
  2642.                     }
  2643.                 }
  2644.             }
  2645.             if (opp.barrowsSet(3) && poison == 0) { //Guthans affect
  2646.                 if (Math.random() <= 0.25) {
  2647.                     opp.updateHP(damage, true);
  2648.                     requestGFX(398, 0);
  2649.                 }  
  2650.             }
  2651.             if (!hit1UpdateReq) {
  2652.                 hitDiff1 = damage;
  2653.                 poisonHit1 = poison;
  2654.                 hit1UpdateReq = true;
  2655.             } else {
  2656.                 hitDiff2 = damage;
  2657.                 poisonHit2 = poison;
  2658.                 hit2UpdateReq = true;
  2659.             }
  2660.             updateReq = true;
  2661.         }
  2662.     }
  2663.     public void vengUpdate(final Player p) {
  2664.         EventManager.getSingleton().addEvent(new Event() {
  2665.             public void execute(EventContainer c) {
  2666.                 Player opp = Server.engine.players[hitIndex];
  2667.                 if (p == null || !p.online || opp == null || !opp.online) {
  2668.                     c.stop();
  2669.                     return;
  2670.                 }
  2671.                 if (skillLvl[3] > 0) {
  2672.                     opp.append1Hit(((int)Math.floor(damagez * 0.75)), 0);
  2673.                 } else {
  2674.                     opp.append1Hit(0, 0);
  2675.                 }
  2676.                 c.stop();
  2677.             }
  2678.         }, 600);
  2679.     };
  2680.     public int EPUpdating;
  2681.     public int EPUpdates;
  2682.     public void EPUpdate(final Player p) {
  2683.         EventManager.getSingleton().addEvent(
  2684.                 new Event() {
  2685.                     public void execute(EventContainer c) {
  2686.                         if (p == null || !p.online) {
  2687.                             c.stop();
  2688.                             return;
  2689.                         }
  2690.                         EPUpdating++;
  2691.                         if (EPAmount > 100)
  2692.                             EPAmount = 100;
  2693.                         if (EPUpdating == 10) {
  2694.                             EPAmount += 25;
  2695.                             if (EPAmount > 100)
  2696.                                 EPAmount = 100;
  2697.                             EPUpdating = 0;
  2698.                         }
  2699.                         if (!wildernessZone(absX, absY)) {
  2700.                             EPUpdates = 0;
  2701.                             c.stop();
  2702.                         }
  2703.                     }
  2704.                 }, 60000);
  2705.     };
  2706.  
  2707.     public void append1Hit(int damage, int poison) {
  2708.         if (damage > skillLvl[3]) {
  2709.             damage = skillLvl[3];
  2710.             damagez = skillLvl[3];
  2711.         }
  2712.         updateHP(damage, false);
  2713.         if (!hit1UpdateReq) {
  2714.             hitDiff1 = damage;
  2715.             damagez = damage;
  2716.             poisonHit1 = poison;
  2717.             hit1UpdateReq = true;
  2718.         } else {
  2719.             hitDiff2 = damage;
  2720.             damagez = damage;
  2721.             poisonHit2 = poison;
  2722.             hit2UpdateReq = true;
  2723.         }
  2724.         updateReq = true;
  2725.     }
  2726.  
  2727.     /**
  2728.      * Block anims.
  2729.      */
  2730.     public int getBlockAnim() {
  2731.         if (equipment[3] == 4031) {
  2732.             return 221;
  2733.         }
  2734.         if (equipment[5] == 8850) {
  2735.             return 4177;
  2736.         }
  2737.         return 1156;
  2738.     }
  2739.  
  2740.     /**
  2741.      * Block anims.
  2742.      */
  2743.     public int getBlockAnim1() {
  2744.         if (equipment[3] == 4031) {
  2745.             return 221;
  2746.         }
  2747.         if (equipment[3] == 4151) {
  2748.             return 1659;
  2749.         }
  2750.         if (equipment[3] == 4718 ||
  2751.                 equipment[3] == -1) {
  2752.             return 424;
  2753.         }
  2754.         if (equipment[3] == 4755) {
  2755.             return 2063;
  2756.         }
  2757.         if (equipment[3] == 10887) {
  2758.             return 5866;
  2759.         }
  2760.         if (equipment[3] == 4153) {
  2761.             return 1666;
  2762.         }
  2763.         if (equipment[3] == 11694 ||
  2764.                 equipment[3] == 11696 ||
  2765.                 equipment[3] == 11698 ||
  2766.                 equipment[3] == 11700 ||
  2767.                 equipment[3] == 1307 ||
  2768.                 equipment[3] == 1309 ||
  2769.                 equipment[3] == 1311 ||
  2770.                 equipment[3] == 1313 ||
  2771.                 equipment[3] == 1315 ||
  2772.                 equipment[3] == 1317 ||
  2773.                 equipment[3] == 1319 ||
  2774.                 equipment[3] == 7158 ||
  2775.                 equipment[3] == 11730) {
  2776.             return 7050;
  2777.         }
  2778.         if (equipment[3] == 3204) {
  2779.             return 420;
  2780.         }
  2781.         return 404;
  2782.     }
  2783.  
  2784.     /**
  2785.      * Force chat text.
  2786.      */
  2787.     public void requestForceChat(String s) {
  2788.         forceChat = s;
  2789.         forceChatUpdateReq = true;
  2790.         updateReq = true;
  2791.     }
  2792.     public boolean quickChat;
  2793.     public void requestForceChat2(String s) {
  2794.         quickChat = true;
  2795.         chatTextUpdateReq = true;
  2796.         chatText = s;
  2797.         updateReq = true;
  2798.     }
  2799.  
  2800.     public int getArmourDef() {
  2801.         switch (equipment[4]) {
  2802.  
  2803.         case 1127: return 80;
  2804.         case 4712: return 120;
  2805.         case 4757: return 140;
  2806.         case 4720: return 140;
  2807.         case 3140: return 100;
  2808.         case 10551: return 70;
  2809.         case 11720: return 215;
  2810.         case 11724: return 220;
  2811.         }
  2812.         return 10;
  2813.     }
  2814.  
  2815.     public int getRangeArmourDef() {
  2816.         switch (equipment[4]) {
  2817.  
  2818.         case 1135: return 115;
  2819.         case 2499: return 140;
  2820.         case 2501: return 165;
  2821.         case 2503: return 190;
  2822.         case 11720: return 200;
  2823.         }
  2824.         return 40;
  2825.     }
  2826.  
  2827.     public int getRangeBonus() {
  2828.         switch (equipment[3]) {
  2829.  
  2830.         case 841: return 65;
  2831.         case 843: return 80;
  2832.         case 845: return 85;
  2833.         case 847: return 90;
  2834.         case 849: return 95;
  2835.         case 851: return 100;
  2836.         case 853: return 120;
  2837.         case 855: return 130;
  2838.         case 857: return 150;
  2839.         case 859: return 165;
  2840.         case 861: return 180;
  2841.         case 9185: return 280;
  2842.         case 11235: return 160;
  2843.         }
  2844.         return 60;
  2845.     }
  2846.  
  2847.     public boolean defile;
  2848.  
  2849.     public void checkVeracs() {
  2850.         if (barrowsSet(6)) {
  2851.             if (Math.random() <= 0.15) {
  2852.                 defile = true;
  2853.             }
  2854.         } else {
  2855.             defile = false;
  2856.         }
  2857.     }
  2858.  
  2859.     public double accuracy = 1;
  2860.  
  2861.     public int calculateMeleeDefence() {
  2862.         int defenceLevel = skillLvl[1];
  2863.         int i = equipmentBonus[bestMeleeDef()];
  2864.         if (usingPrayer(0))
  2865.             defenceLevel += getLevelForXP(1) * 0.05;
  2866.         if (usingPrayer(5))
  2867.             defenceLevel += getLevelForXP(1) * 0.1;
  2868.         if (usingPrayer(13))
  2869.             defenceLevel += getLevelForXP(1) * 0.15;
  2870.         if (usingPrayer(25))
  2871.             defenceLevel += getLevelForXP(1) * 0.2;
  2872.         if (usingPrayer(26)) {
  2873.             defenceLevel += getLevelForXP(1) * 0.25;
  2874.         }
  2875.         return (int)(defenceLevel + (defenceLevel * 0.15) + (i + i * 0.05));
  2876.     }
  2877.  
  2878.     public int bestMeleeDef() {
  2879.         if(equipmentBonus[5] > equipmentBonus[6] && equipmentBonus[5] > equipmentBonus[7])
  2880.             return 5;
  2881.         if(equipmentBonus[6] > equipmentBonus[5] && equipmentBonus[6] > equipmentBonus[7])
  2882.             return 6;
  2883.         return equipmentBonus[7] <= equipmentBonus[5] || equipmentBonus[7] <= equipmentBonus[6] ? 5 : 7;
  2884.     }
  2885.  
  2886.     public double meleeAccuracy(Player opp) {
  2887.         if (opp == null || this.isDead || opp.isDead || this.disconnected[0] || opp.disconnected[0]) {
  2888.             return 1;
  2889.         }
  2890.         double attack = skillLvl[0];
  2891.         double defence = opp.skillLvl[1];
  2892.         int activeAttackBonus = weaponStyle(equipment[3]) - 1;
  2893.         int activeDefenceBonus = activeAttackBonus + 5;
  2894.         double attackBonus = equipmentBonus[activeAttackBonus];
  2895.         double defenceBonus = opp.equipmentBonus[activeDefenceBonus];
  2896.         if (usingPrayer(2)) {
  2897.             attack *= 1.05;
  2898.         }
  2899.         if (usingPrayer(7)) {
  2900.             attack *= 1.10;
  2901.         }
  2902.         if (usingPrayer(15)) {
  2903.             attack *= 1.15;
  2904.         }
  2905.         if (usingPrayer(25)) {
  2906.             attack *= 1.15;
  2907.         }
  2908.         if (usingPrayer(26)) {
  2909.             attack *= 1.20;
  2910.         }
  2911.         if (attackStyle() == 4) {
  2912.             attack += 1;
  2913.         }
  2914.         if (attackStyle() == 1) {
  2915.             attack += 3;
  2916.         }
  2917.         if (opp.usingPrayer(0)) {
  2918.             defence *= 1.05;
  2919.         }
  2920.         if (opp.usingPrayer(5)) {
  2921.             defence *= 1.10;
  2922.         }
  2923.         if (opp.usingPrayer(13)) {
  2924.             defence *= 1.15;
  2925.         }
  2926.         if (opp.usingPrayer(25)) {
  2927.             defence *= 1.20;
  2928.         }
  2929.         if (opp.usingPrayer(26)) {
  2930.             defence *= 1.25;
  2931.         }
  2932.         if (opp.attackStyle() == 4) {
  2933.             defence += 1;
  2934.         }
  2935.         if (opp.attackStyle() == 3) {
  2936.             defence += 3;
  2937.         }
  2938.         if (attackBonus < 0) {
  2939.             attackBonus = 0;
  2940.         }
  2941.         if (defenceBonus < 0) {
  2942.             defenceBonus = 0;
  2943.         }
  2944.         if (defile) {
  2945.             defenceBonus = 0;
  2946.         }
  2947.         double offensiveAttribute = (attack * 1.5) + attackBonus;
  2948.         double defensiveAttribute = (defence * 1.5) + defenceBonus;
  2949.         double difference = Math.abs(offensiveAttribute - defensiveAttribute);
  2950.         boolean positive = offensiveAttribute > defensiveAttribute;
  2951.         double interval = difference * 0.0015;
  2952.         double percentage = 0.55;
  2953.         if (!positive) {
  2954.             percentage -= interval;
  2955.         }
  2956.         if (positive) {
  2957.             percentage += interval;
  2958.         }
  2959.         if (accuracy != 1) {
  2960.             percentage *= accuracy;
  2961.             accuracy = 1;
  2962.         }
  2963.         return percentage;
  2964.     }
  2965.  
  2966.     public boolean hitPlayer(Player opp) {
  2967.         return Math.random() <= meleeAccuracy(opp);
  2968.     }
  2969.  
  2970.     public int mageDefence() {
  2971.         int defence = skillLvl[1]/2 + skillLvl[6]/2;
  2972.         if (usingPrayer(0))
  2973.             defence += skillLvl[1] * 0.05;
  2974.         if (usingPrayer(5))
  2975.             defence += skillLvl[1] * 0.10;
  2976.         if (usingPrayer(13))
  2977.             defence += skillLvl[1] * 0.15;
  2978.         if (usingPrayer(25))
  2979.             defence += skillLvl[1] * 0.20;
  2980.         if (usingPrayer(26))
  2981.             defence += skillLvl[1] * 0.25;
  2982.         return (int) (defence + equipmentBonus[8] + (equipmentBonus[8] / 3));
  2983.     }
  2984.  
  2985.     public double rangeAccuracy(Player opp) {
  2986.         if (opp == null || this.isDead || opp.isDead || this.disconnected[0] || opp.disconnected[0]) {
  2987.             return 1;
  2988.         }
  2989.         double range = skillLvl[4];
  2990.         double defence = opp.skillLvl[1];
  2991.         double rangeBonus = equipmentBonus[4];
  2992.         double defenceBonus = opp.equipmentBonus[9];
  2993.         if (usingPrayer(3)) {
  2994.             range *= 1.05;
  2995.         }
  2996.         if (usingPrayer(11)) {
  2997.             range *= 1.10;
  2998.         }
  2999.         if (usingPrayer(20)) {
  3000.             range *= 1.15;
  3001.         }
  3002.         if (attackStyle() == 5) {
  3003.             range += 1;
  3004.         }
  3005.         if (opp.usingPrayer(0)) {
  3006.             defence *= 1.05;
  3007.         }
  3008.         if (opp.usingPrayer(5)) {
  3009.             defence *= 1.10;
  3010.         }
  3011.         if (opp.usingPrayer(13)) {
  3012.             defence *= 1.15;
  3013.         }
  3014.         if (opp.usingPrayer(25)) {
  3015.             defence *= 1.20;
  3016.         }
  3017.         if (opp.usingPrayer(26)) {
  3018.             defence *= 1.25;
  3019.         }
  3020.         if (opp.attackStyle() == 4) {
  3021.             defence += 1;
  3022.         }
  3023.         if (opp.attackStyle() == 3) {
  3024.             defence += 3;
  3025.         }
  3026.         if (rangeBonus < 0) {
  3027.             rangeBonus = 0;
  3028.         }
  3029.         if (defenceBonus < 0) {
  3030.             defenceBonus = 0;
  3031.         }
  3032.         double offensiveAttribute = range + rangeBonus;
  3033.         double defensiveAttribute = defence + defenceBonus;
  3034.         double difference = Math.abs(offensiveAttribute - defensiveAttribute);
  3035.         boolean positive = offensiveAttribute > defensiveAttribute;
  3036.         double interval = difference * 0.00175;
  3037.         double percentage = 0.50;
  3038.         if (!positive) {
  3039.             percentage -= interval;
  3040.         }
  3041.         if (positive) {
  3042.             percentage += interval;
  3043.         }
  3044.         if (accuracy != 1) {
  3045.             percentage *= accuracy;
  3046.             accuracy = 1;
  3047.         }
  3048.         return percentage;
  3049.     }
  3050.  
  3051.     public boolean hitPlayerRange(Player opp) {
  3052.         return Math.random() <= rangeAccuracy(opp);
  3053.     }
  3054.  
  3055.     public boolean barrowsSet(int setID) {
  3056.         String helmet = Engine.items.getItemName(equipment[0]);
  3057.         String platebody = Engine.items.getItemName(equipment[4]);
  3058.         String weapon = Engine.items.getItemName(equipment[3]);
  3059.         String platelegs = Engine.items.getItemName(equipment[7]);
  3060.         String set = "";
  3061.         switch (setID) {
  3062.         case 1: //Ahrim's
  3063.             set = "Ahrim";
  3064.             break;
  3065.         case 2: //Dharok's
  3066.             set = "Dharok";
  3067.             break;
  3068.         case 3: //Guthan's
  3069.             set = "Guthan";
  3070.             break;
  3071.         case 4: //Karil's
  3072.             set = "Karil";
  3073.             break;
  3074.         case 5: //Torag's
  3075.             set = "Torag";
  3076.             break;
  3077.         case 6: //Verac's
  3078.             set = "Verac";
  3079.             break;
  3080.         }
  3081.         boolean hasHelmet = helmet.contains(set);
  3082.         boolean hasPlatebody = platebody.contains(set);
  3083.         boolean hasWeapon = weapon.contains(set);
  3084.         boolean hasPlatelegs = platelegs.contains(set);
  3085.         if (hasHelmet && hasPlatebody && hasWeapon && hasPlatelegs) {
  3086.             return true;
  3087.         }
  3088.         return false;
  3089.     }
  3090.     public boolean voidSet(int setID) {
  3091.         String helmet = Engine.items.getItemName(equipment[0]);
  3092.         String set = "";
  3093.         switch (setID) {
  3094.         case 1: //Melee
  3095.             set = "Void melee";
  3096.             break;
  3097.         case 2: //Range
  3098.             set = "Void ranger";
  3099.             break;
  3100.         case 3: //Mage
  3101.             set = "Void mage";
  3102.             break;
  3103.         }
  3104.         boolean hasHelmet = helmet.contains(set);
  3105.         boolean hasTop = equipment[4] == 8839;
  3106.         boolean hasGloves = equipment[9] == 8842;
  3107.         boolean hasBottom = equipment[7] == 8840;
  3108.         if (hasHelmet && hasTop && hasGloves && hasBottom) {
  3109.             return true;
  3110.         }
  3111.         return false;
  3112.     }
  3113.  
  3114.     public boolean hasProperArrows(int bow, int arrows) {
  3115.         if (usingSpecial) {
  3116.             if (weapon == 861 || weapon == 11235) {
  3117.                 if (equipmentN[13] <= 1) {
  3118.                     getActionSender().sendMessage(this, "You don't have enough ammo!");
  3119.                     return false;
  3120.                 }
  3121.             }
  3122.         }
  3123.         if (bow >= 839 && bow <= 861) {
  3124.             switch (arrows) {
  3125.             case 882:
  3126.             case 884:
  3127.             case 886:
  3128.             case 888:
  3129.             case 890:
  3130.             case 892: return true;
  3131.             }
  3132.         }
  3133.         if (bow == 6724) {
  3134.             switch (arrows) {
  3135.             case 882:
  3136.             case 884:
  3137.             case 886:
  3138.             case 888:
  3139.             case 890:
  3140.             case 892: return true;
  3141.             }
  3142.         }
  3143.         if (bow == 11235) {
  3144.             switch (arrows) {
  3145.             case 882:
  3146.             case 884:
  3147.             case 886:
  3148.             case 888:
  3149.             case 890:
  3150.             case 892:
  3151.             case 11212:
  3152.                 if (equipmentN[13] > 1) {
  3153.                     return true;
  3154.                 } else {
  3155.                     getActionSender().sendMessage(this, "You don't have enough ammo!");
  3156.                     return false;
  3157.                 }
  3158.             }
  3159.         }
  3160.         if (bow == 4214 || bow == 868 || bow == 11230 || bow == 13879 || bow == 13883) {
  3161.             return true;
  3162.         }
  3163.         if (bow == 9185) {
  3164.             switch (arrows) {
  3165.             case 9243:
  3166.             case 9244: return true;
  3167.             }
  3168.         }
  3169.         if (bow == 4734) {
  3170.             if (arrows == 4740) return true;
  3171.         }
  3172.         return false;
  3173.     }
  3174.  
  3175.     public boolean hitNpcRange() {
  3176.         PlayerCombat playCb = new PlayerCombat(this);
  3177.         if (getRandom(equipmentBonus[8] + getRangeBonus()) > getRandom(playCb.getNpcDefenceRange())) {
  3178.             return true;
  3179.         }
  3180.         return false;
  3181.     }
  3182.     private DamageDealt damageDealt = new DamageDealt();
  3183.  
  3184.     public DamageDealt getDealtDamage(){
  3185.         return damageDealt;
  3186.     }
  3187.     private void resetDealtDamage(){
  3188.         getDealtDamage().dealtDamage.clear();
  3189.     }
  3190.  
  3191.     private int getRandom(int range) {
  3192.         return (int)(Math.random() * (range + 1));
  3193.     }
  3194.  
  3195.     /**
  3196.      * Gives experience to a player.
  3197.      * @param amount The amount which will gives to the player
  3198.      * @param skillId the skill Id of the player which the exp will go to.
  3199.      */
  3200.     public void appendExperience(int amount, int skillId) {
  3201.         if (!getExperience) {
  3202.             return;
  3203.         }
  3204.         int oldLvl = getLevelForXP(skillId);
  3205.         if (skillXP[skillId] > 200000000) {
  3206.             return;
  3207.         }
  3208.         skillXP[skillId] += amount;
  3209.         int newLvl = getLevelForXP(skillId);
  3210.         if (oldLvl < newLvl) {
  3211.             skillLvl[skillId] += (newLvl - oldLvl);
  3212.             switch (skillId) {
  3213.  
  3214.             case 0:
  3215.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Attack level!");
  3216.                 break;
  3217.  
  3218.             case 1:
  3219.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Defence level!");
  3220.                 break;
  3221.  
  3222.             case 2:
  3223.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Strength level!");
  3224.                 break;
  3225.  
  3226.             case 3:
  3227.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new hitpoints level!");
  3228.                 break;
  3229.  
  3230.             case 4:
  3231.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Ranged level!");
  3232.                 break;
  3233.  
  3234.             case 5:
  3235.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Prayer level!");
  3236.                 break;
  3237.  
  3238.             case 6:
  3239.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Magic level!");
  3240.                 break;
  3241.  
  3242.             case 7:
  3243.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Cooking level!");
  3244.                 break;
  3245.  
  3246.             case 8:
  3247.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Woodcutting level!");
  3248.                 break;
  3249.  
  3250.             case 16:
  3251.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Agility level!");
  3252.                 break;
  3253.  
  3254.             case 17:
  3255.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Thieving level!");
  3256.                 break;
  3257.  
  3258.             case 18:
  3259.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Slayer level!");
  3260.                 break;
  3261.  
  3262.             case 19:
  3263.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Farming level!");
  3264.                 break;
  3265.  
  3266.             case 20:
  3267.                 getActionSender().sendMessage(this, "Congratulations, you have just advanced a new Runecrafting level!");
  3268.                 break;
  3269.  
  3270.             default:
  3271.                 getActionSender().sendMessage(this, "This level is unknown, please report this to an administrator.");
  3272.                 break;
  3273.             }
  3274.             requestGFX(1635, 0);
  3275.             appearanceUpdateReq = true;
  3276.             updateReq = true;
  3277.         }
  3278.         getActionSender().setSkillLvl(this, skillId);
  3279.     }
  3280.  
  3281.     /**
  3282.      * Checks special amount and gets config.
  3283.      */
  3284.     public void checkAmount() {
  3285.         int amount = specAmount;
  3286.         getActionSender().setConfig2(this, 300, amount);
  3287.     }
  3288.  
  3289.     /**
  3290.      * Walking request.
  3291.      */
  3292.     public int packetSize;
  3293.     public void playerWalk(int x, int y, int emote, int delay) {
  3294.         Engine.playerMovement.resetWalkingQueue(this);
  3295.         int numPath = (packetSize - 5) / 2;
  3296.         numPath = 100;
  3297.         int[] pathX = new int[numPath];
  3298.         int[] pathY = new int[numPath];
  3299.         int firstX = x - (mapRegionX - 6) * 8;
  3300.         int firstY = y - (mapRegionY - 6) * 8;
  3301.         stream.readSignedByteC();
  3302.         for (int i = 0; i < numPath; i++) {
  3303.             pathX[i] = stream.readSignedByte();//stream.readSignedByte()
  3304.             pathY[i] = stream.readSignedByteS();;//stream.readSignedByteS();
  3305.         }
  3306.         Engine.playerMovement.addToWalkingQueue(this, firstX, firstY);
  3307.         for (int i = 0; i < numPath; i++) {
  3308.             pathX[i] += firstX;
  3309.             pathY[i] += firstY;
  3310.  
  3311.         }
  3312.         appearanceUpdateReq = true;
  3313.         updateReq = true;
  3314.         //Engine.playerMovement.addToWalkingQueue(this, firstX, firstY);
  3315.     }
  3316.     public void WalkingTo(int i, int j) {
  3317.         int k = i - (mapRegionX - 6) * 8;
  3318.         int l = j - (mapRegionY - 6) * 8;
  3319.         Engine.playerMovement.resetWalkingQueue(this);
  3320.         Engine.playerMovement.addToWalkingQueue(this, k, l);
  3321.         appearanceUpdateReq = true;
  3322.         updateReq = true;
  3323.     }
  3324.     public boolean inWilderness() {
  3325.         return absX >= 3136 && absX <= 3350 && absY >= 3523 && absY <= 3597;
  3326.     }
  3327.  
  3328.  
  3329.  
  3330.     /**
  3331.      * Boolean which returns coords ids to get safezone of bounty hunter place.
  3332.      */
  3333.     public boolean pkArenaPart1() {
  3334.         return absX >= 3067 && absX <= 3134 && absY >= 3650 && absY <= 3698;
  3335.     }
  3336.  
  3337.     public boolean pkArenaPart2() {
  3338.         return absX >= 3135 && absX <= 3144 && absY >= 3672 && absY <= 3714;
  3339.     }
  3340.  
  3341.     public boolean inPkArena() {
  3342.         return pkArenaPart1() && pkArenaPart2();
  3343.     }
  3344.  
  3345.     void updateStats() {
  3346.         if (isDead) {
  3347.             return;
  3348.         }
  3349.         int skill = 0;
  3350.         while (skill <= 22) {
  3351.             if (skill == 3 || skill == 5) {
  3352.                 skill++;
  3353.             }
  3354.             if (skillLvl[skill] > getLevelForXP(skill)) {
  3355.                 skillLvl[skill]--;
  3356.             }
  3357.             if (skillLvl[skill] < getLevelForXP(skill)) {
  3358.                 skillLvl[skill]++;
  3359.             }
  3360.             statDelay = 100;
  3361.             getActionSender().setSkillLvl(this, skill);
  3362.             skill++;
  3363.         }
  3364.     }
  3365.     void restoreHP() {
  3366.         if (isDead) {
  3367.             return;
  3368.         }
  3369.         if (skillLvl[3] > getLevelForXP(3)) {
  3370.             skillLvl[3]--;
  3371.         }
  3372.         if (skillLvl[3] < getLevelForXP(3)) {
  3373.             skillLvl[3] += equipment[9] == 11133 ? 2 : 1;
  3374.         }
  3375.         hpDelay = 100;
  3376.         getActionSender().setSkillLvl(this, 3);
  3377.     }
  3378.  
  3379.     /**
  3380.      * Unequip and delete all items player has.
  3381.      */
  3382.     public void dropAllStuff() {
  3383.         if (this == null)
  3384.             return;
  3385.         PlayerItems pi = new PlayerItems();
  3386.         for(int i = 0; i < items.length; i++)
  3387.         {
  3388.             if(items[i] == 6570)
  3389.                 break;
  3390.             if(items[i] >= 0)
  3391.             {
  3392.                 if(Engine.items.isUntradable((items[i])))
  3393.                 {
  3394.                     Engine.playerItems.deleteItem(this, items[i], pi.getItemSlot(this, items[i]), itemsN[i]);
  3395.                 }
  3396.                 else
  3397.                 {
  3398.                     Engine.playerItems.deleteItem(this, items[i], pi.getItemSlot(this, items[i]), itemsN[i]);
  3399.                 }
  3400.             }
  3401.         }
  3402.         for(int i = 0; i < equipment.length; i++)
  3403.         {
  3404.             if(equipment[i] == 6570)
  3405.                 break;
  3406.             if(equipment[i] >= 0)
  3407.             {
  3408.                 getActionSender().removeEquipment(this, equipment[i], i);
  3409.                 if(Engine.items.isUntradable((items[0])))
  3410.                 {
  3411.                     Engine.playerItems.deleteItem(this, items[0], pi.getItemSlot(this, items[0]), itemsN[0]);
  3412.  
  3413.                 }
  3414.                 else
  3415.                 {
  3416.                     Engine.playerItems.deleteItem(this, items[0], pi.getItemSlot(this, items[0]), itemsN[0]);
  3417.                 }
  3418.             }
  3419.         }
  3420.     }
  3421.  
  3422.     public boolean arrayContains(int[] array, int value) {
  3423.         for (int i : array) {
  3424.             if (value == i) {
  3425.                 return true;
  3426.             }
  3427.         }
  3428.         return false;
  3429.     }
  3430.     public int[] removeValueFromArray(int[] array, int value) {
  3431.         int index = -1;
  3432.         for (int i = 0; i < array.length; i++) {
  3433.             if (value == array[i]) {
  3434.                 index = i;
  3435.             }
  3436.         }
  3437.         if (index != -1) {
  3438.             array[index] = 0;
  3439.         }
  3440.         return array;
  3441.     }
  3442.  
  3443.     public int[][] removeValueFromArray(int[][] array, int value) {
  3444.         int indexI = -1;
  3445.         int indexJ = -1;
  3446.         for (int i = 0; i < array.length; i++) {
  3447.             for (int j = 0; j < array[i].length; j++) {
  3448.                 if (value == array[i][j]) {
  3449.                     indexI = i;
  3450.                     indexJ = j;
  3451.                 }
  3452.             }
  3453.         }
  3454.         if (indexI != -1 && indexJ != -1) {
  3455.             array[indexI][indexJ] = -1;
  3456.         }
  3457.         return array;
  3458.     }
  3459.     public void keptItems(Player p) {
  3460.         int amountOfKeptItems = isSkulled ? (usingPrayer(10) ? 1 : 0) : (usingPrayer(10) ? 4 : 3);
  3461.         int[] allItems = new int[items.length + equipment.length];
  3462.         int[] allItemsN = new int[itemsN.length + equipmentN.length];
  3463.         int[] keptItems = new int[amountOfKeptItems];
  3464.         int[] toAdd = new int[keptItems.length];
  3465.         System.arraycopy(items, 0, allItems, 0, items.length);
  3466.         System.arraycopy(equipment, 0, allItems, items.length, equipment.length);
  3467.         System.arraycopy(itemsN, 0, allItemsN, 0, itemsN.length);
  3468.         System.arraycopy(equipmentN, 0, allItemsN, itemsN.length, equipmentN.length);
  3469.         for (int i = 0; i < keptItems.length; i++) {
  3470.             int index = 0;
  3471.             int standing = 0;
  3472.             for (int j = 0; j < allItems.length; j++) {
  3473.                 if (allItems[j] < 1) {
  3474.                     continue;
  3475.                 }
  3476.                 int price = Engine.items.itemLists[allItems[j]].shopValue;
  3477.                 if (price > standing) {
  3478.                     index = j;
  3479.                     standing = price;
  3480.                 }
  3481.             }
  3482.             keptItems[i] = allItems[index];
  3483.             toAdd[i] = allItems[index];
  3484.             allItemsN[index]--;
  3485.             if (allItemsN[index] == 0) {
  3486.                 allItems[index] = 0;
  3487.             }
  3488.         }
  3489.         p.getActionSender().showInterface(p, 255);
  3490.         for (int i : toAdd) {
  3491.             getActionSender().  setString(p, "LOL" +i, 255, 3);
  3492.             getActionSender().  setString(p, "LOL" +i, 255, 4);
  3493.             getActionSender().  setString(p, "LOL" +i, 255, 5);
  3494.             getActionSender().  setString(p, "LOL" +i, 255, 6);
  3495.         }
  3496.     }
  3497.  
  3498.     private int worthStuff;
  3499.  
  3500.     void dropStuff(String opp) {
  3501.         try {
  3502.             int amountOfKeptItems = isSkulled ? (usingPrayer(10) ? 1 : 0) : (usingPrayer(10) ? 4 : 3);
  3503.             int[] allItems = new int[items.length + equipment.length];
  3504.             int[] allItemsN = new int[itemsN.length + equipmentN.length];
  3505.             int[] keptItems = new int[amountOfKeptItems];
  3506.             int[] toAdd = new int[keptItems.length];
  3507.             int[] dropAllowed = {385,391,7060,2440,158,158,159,160,161,162,2436,145,146,147, 148,149,150,6685,6686,
  3508.                     6587,6888,6689,6690,6692,3024,3026,3028,3030,2444,169,170,171,172,173,174,2434,
  3509.                     139,140,141,142,143,144}
  3510.             System.arraycopy(items, 0, allItems, 0, items.length);
  3511.             System.arraycopy(equipment, 0, allItems, items.length, equipment.length);
  3512.             System.arraycopy(itemsN, 0, allItemsN, 0, itemsN.length);
  3513.             System.arraycopy(equipmentN, 0, allItemsN, itemsN.length, equipmentN.length);
  3514.             for (int i = 0; i < keptItems.length; i++) {
  3515.                 int index = 0;
  3516.                 int standing = 0;
  3517.                 for (int j = 0; j < allItems.length; j++) {
  3518.                     if (allItems[j] < 1) {
  3519.                         continue;
  3520.                     }
  3521.                     int price = Engine.items.itemLists[allItems[j]].shopValue;
  3522.                     if (price > standing) {
  3523.                         index = j;
  3524.                         standing = price;
  3525.                     }
  3526.                 }
  3527.                 keptItems[i] = allItems[index];
  3528.                 toAdd[i] = allItems[index];
  3529.                 allItemsN[index]--;
  3530.                 if (allItemsN[index] == 0) {
  3531.                     allItems[index] = 0;
  3532.                 }
  3533.             }
  3534.             worthStuff = priceCheck();
  3535.             for(int i = 0; i < items.length; i++) {
  3536.                 if (items[i] > 0) {
  3537.                     if (!arrayContains(keptItems, items[i])) {
  3538.                         if (Engine.items.isUntradable((items[i]))) {
  3539.                             Engine.items.createGroundItem(items[i], itemsN[i], absX, absY, heightLevel, username);
  3540.                             Engine.playerItems.deleteItem(this, items[i], Engine.playerItems.getItemSlot(this, items[i]), itemsN[i]);
  3541.                         } else {
  3542.                             for (int b = 0; b < dropAllowed.length; b++) {
  3543.                                 if (dropAllowed[b] == items[i]) {
  3544.                                     Engine.items.createGroundItem(items[i], itemsN[i], absX, absY, heightLevel, opp);
  3545.                                 }
  3546.                             }
  3547.                         }
  3548.                     } else {
  3549.                         keptItems = removeValueFromArray(keptItems, items[i]);
  3550.                     }
  3551.                     Engine.playerItems.deleteItem(this, items[i], Engine.playerItems.getItemSlot(this, items[i]), itemsN[i]);
  3552.                 }
  3553.             }
  3554.             for (int i = 0; i < equipment.length; i++) {
  3555.                 if (equipment[i] > 0) {
  3556.                     getActionSender().removeEquipment(this, equipment[i], i);
  3557.                     if (!arrayContains(keptItems, items[0])) {
  3558.                         if(Engine.items.isUntradable((items[0]))) {
  3559.                             if (items[0] != 13290) {
  3560.                                 Engine.items.createGroundItem(items[0], itemsN[0], absX, absY, heightLevel, username);
  3561.                             }
  3562.                             Engine.playerItems.deleteItem(this, items[0], Engine.playerItems.getItemSlot(this, items[0]), itemsN[0]);
  3563.                         } else {
  3564.                             if (!isPVP()) {
  3565.                                 //Engine.items.createGroundItem(items[0], itemsN[0], absX, absY, heightLevel, opp);
  3566.                             }
  3567.                         }
  3568.                     } else {
  3569.                         keptItems = removeValueFromArray(keptItems, items[0]);
  3570.                     }
  3571.                     Engine.playerItems.deleteItem(this, items[0], Engine.playerItems.getItemSlot(this, items[0]), itemsN[0]);
  3572.                 }
  3573.             }
  3574.             for (int i : toAdd) {
  3575.                 if (i > 0) {
  3576.                     Engine.playerItems.addItem(this, i, 1);
  3577.                     worthStuff -= getItemValue(i);
  3578.                 }
  3579.             }
  3580.             int[] lostItems = allItems;
  3581.             if (receivesPVPDrop(this, Server.engine.players[Server.engine.getIdFromName(opp)]))
  3582.                 PVPDrop(opp, lostItems);
  3583.         } catch (Exception e) {
  3584.             e.printStackTrace();
  3585.             System.out.println("Null drop: "+opp);
  3586.             return;
  3587.         }
  3588.     }
  3589.  
  3590.     public double PVPPotential;
  3591.  
  3592.     public boolean hotZone(int x, int y) {
  3593.         if ((x >= 3205 && x <= 3222 && y >= 3420 && y <= 3438) || //Varrock
  3594.                 (x >= 3231 && x <= 3238 && y >= 3212 && y <= 3225) || //Lumbridge
  3595.                 (x >= 2949 && x <= 2978 && y >= 3367 && y <= 3391) || //Falador
  3596.                 (x >= 2741 && x <= 2774 && y >= 3464 && y <= 3481) || //Camelot
  3597.                 (x >= 2652 && x <= 2672 && y >= 3294 && y <= 3318)) { //Ardougne
  3598.             return true;
  3599.         }
  3600.         return false;
  3601.     }
  3602.  
  3603.     void PVPDrop(String player, int[] lostItems) {
  3604.         Player dropFor = Server.engine.players[Server.engine.getIdFromName(player)];
  3605.         try {
  3606.             int[] newest = {4716, 4722, 4718, 4720, 4708, 4710, 4712, 4714, 4745, 4747, 4749, 4751, 4736, 4738};
  3607.             int[] broken = {4884, 4902, 4890, 4896, 4860, 4866, 4872, 4878, 4956, 4962, 4968, 4974, 4944, 4950};
  3608.             for (int x = 0; x < newest.length; x++) {
  3609.                 if (x == newest[x])
  3610.                     x = broken[x];
  3611.             }
  3612.             Engine.items.createGroundItem(526, 1, absX, absY, heightLevel, player);
  3613.             if (Double.isInfinite(dropFor.PVPPotential) || Double.isNaN(dropFor.PVPPotential)) {
  3614.                 dropFor.PVPPotential = 0.0;
  3615.             }
  3616.             double chance = 0.00;
  3617.             int randomDrops = 0;
  3618.  
  3619.             for (int i : lostItems) {
  3620.                 if (i == 0 || Engine.items.isUntradable(i)) {
  3621.                     continue;
  3622.                 }
  3623.                 if (dropFor.priceCheck() > 76000 && worthStuff > 76000) {
  3624.                     if (dropFor.EPAmount >= 20 && dropFor.EPAmount <= 40) {
  3625.                         if (Misc.random(5) == 1) {
  3626.                             for (int x = 0; x < newest.length; x++) {
  3627.                                 if (i == newest[x])
  3628.                                     i = broken[x];
  3629.                             }
  3630.                             Engine.items.createGroundItem(i, 1, absX, absY, heightLevel, player);
  3631.                         }
  3632.                     }
  3633.                     if (dropFor.EPAmount >= 41 && dropFor.EPAmount <= 60) {
  3634.                         if (Misc.random(3) == 1) {
  3635.                             for (int x = 0; x < newest.length; x++) {
  3636.                                 if (i == newest[x])
  3637.                                     i = broken[x];
  3638.                             }
  3639.                             Engine.items.createGroundItem(i, 1, absX, absY, heightLevel, player);
  3640.                         }
  3641.                     }
  3642.                     if (dropFor.EPAmount >= 61 && dropFor.EPAmount <= 80) {
  3643.                         if (Misc.random(2) == 1) {
  3644.                             for (int x = 0; x < newest.length; x++) {
  3645.                                 if (i == newest[x])
  3646.                                     i = broken[x];
  3647.                             }
  3648.                             Engine.items.createGroundItem(i, 1, absX, absY, heightLevel, player);
  3649.                         }
  3650.                     }
  3651.                     if (dropFor.EPAmount >= 81 && dropFor.EPAmount <= 100) {
  3652.                         if (Misc.random(1) == 1) {
  3653.                             for (int x = 0; x < newest.length; x++) {
  3654.                                 if (i == newest[x])
  3655.                                     i = broken[x];
  3656.                             }
  3657.                             Engine.items.createGroundItem(i, 1, absX, absY, heightLevel, player);
  3658.                         }
  3659.                     }
  3660.                 }
  3661.             }
  3662.             if (dropFor.priceCheck() > 76000 && worthStuff > 76000) {
  3663.                 if (dropFor.EPAmount >= 20 && dropFor.EPAmount <= 40) {
  3664.                     dropFor.EPAmount -= Misc.random(28);
  3665.                     if (dropFor.EPAmount < 0)
  3666.                         dropFor.EPAmount = 0;
  3667.                 }
  3668.                 if (dropFor.EPAmount >= 41 && dropFor.EPAmount <= 60) {
  3669.                     dropFor.EPAmount -= Misc.random(35);
  3670.                     if (dropFor.EPAmount < 0)
  3671.                         dropFor.EPAmount = 0;
  3672.                 }
  3673.                 if (dropFor.EPAmount >= 61 && dropFor.EPAmount <= 80) {
  3674.                     dropFor.EPAmount -= Misc.random(55);
  3675.                     if (dropFor.EPAmount < 0)
  3676.                         dropFor.EPAmount = 0;
  3677.                 }
  3678.                 if (dropFor.EPAmount >= 81 && dropFor.EPAmount <= 100) {
  3679.                     dropFor.EPAmount -= Misc.random(73);
  3680.                     if (dropFor.EPAmount < 0)
  3681.                         dropFor.EPAmount = 0;
  3682.                 }
  3683.             }
  3684.  
  3685.             for (int i : lostItems) {
  3686.                 if (Math.random() <= 0.75) {
  3687.                     lostItems = removeValueFromArray(lostItems, i);
  3688.                 } else {
  3689.                     if (getItemValue(i) >= 3000) {
  3690.                         randomDrops++;
  3691.                     } else if (Math.random() <= 0.25) {
  3692.                         randomDrops++;
  3693.                     }
  3694.                 }
  3695.             }
  3696.  
  3697.             int[] potentialDrops = {7060,1127,1079,4587,4151,4153,1712,3105,11732,9036,3486,3749,3751,3753,3755,4884,4908,4956,4753,5574,9038,6128,6131,6137,10350,10589,10606,10828,11200,11335,1073,1079,1091,1093,1123,1127,2599,2601,2607,2609,2615,2617,2623,2625,2653,2655,2661,2669,2671,3474,3476,3480,3481,3483,3485,3670,3476,3674,3676,4087,4585,4720,4722,4920,4968,4974,4759,5575,5576,6129,6617,10346,10348,11720,11722,11724,1199,1201,2603,2611,2621,2629,2659,2667,2675,3488,10352,11726,11728,11730,11720,11718,11694,11696,11698,11700,11283,1187,1215,1231,1249,1263,1305,1377,1434,3101,3140,3204,4087,3587,5680,5698,6739,7158,9244,11212,11217,4618,6785,6888,11227,11228,11229,11230,11231,11233,11234,11732,4091,4093,4095,4097,4099,4101,4103,4105,4107,4109,4111,4113,4115,4117,6916,6918,6920,6922,6924,4860,4866,4878,4872,4755,4757,4914,4926,4962,4732,4734,4735,4950,4740,4890,2491,2497,2503,10370,10386,6764,10368,10372,10374,10444,10450,10456,10460,10468,10474,10786,2663,3479,4151,6762,10384,10386,10388,10390,10440,10446,10452,10458,10464,10470,10784,6760,10376,10378,10380,9034,10382,10442,10448,1454,10462,10466,10472,9672,9674,9676,9678,3122,4153,8082,8083,8084,6809,10564,10330,10332,10334,10336,10338,10340,10342,10344,6731,6733,6735,6737,9185,1704,1706,1708,1710,1712,1725,1727,1729,1731,6585,10354,10356,10358,10360,10362,10364,10366,10719,10736,10738,6889,4129,4131,2579,6914,6912,139,141,143,169,171,173,175,177,179,2430,2442,2444,3040,3042,3044,3046,145,147,149,157,159,161,163,165,167,181,183,185,2436,2440,2448,3024,3026,3028,3030,6568,6524,6526,6523,6525,6522,6527,6528,11126,11124,11122,11120,11118,11133}; //PVP Drops
  3698.             int[] junkK = {325,1145,361,325,325,555,554,556,1725,1891,1891,1891};
  3699.             for (int i = 0; i < randomDrops; i++) {
  3700.                 int item = potentialDrops[(int)Math.floor(Math.random() * potentialDrops.length)];
  3701.                 int junk = junkK[(int)Math.floor(Math.random() * junkK.length)];
  3702.                 chance = getPVPDropPercentage(item, totalValue(lostItems), dropFor.PVPPotential);
  3703.                 if (dropFor.priceCheck() > 76000 && worthStuff > 76000) {
  3704.                     if (Math.random() <= chance) {
  3705.                         Engine.items.createGroundItem(item, 1, absX, absY, heightLevel, player);
  3706.                         dropFor.PVPPotential -= ((1.00 - chance) / 10);
  3707.                         PVPPotential += ((1.00 - chance) / 10);
  3708.                     } else {
  3709.                         dropFor.PVPPotential += ((1.00 - chance) / 10);
  3710.                     }
  3711.                 } else {
  3712.                     Engine.items.createGroundItem(junk, 1, absX, absY, heightLevel, player);
  3713.                 }
  3714.             }
  3715.             worthStuff = 0;
  3716.         } catch (Exception e) {
  3717.         }
  3718.     }
  3719.  
  3720.     double getPVPDropPercentage(int item, int risk, double potential) {
  3721.         double base = 0.10 + potential * (hotZone(absX, absY) ? 3.00 : 1.50);
  3722.         double ratio = getItemValue(item) / 1457000;
  3723.         double value = base / ratio;
  3724.         if (value > 0.95) {
  3725.             value = 0.95;
  3726.         }
  3727.         return value;
  3728.     }
  3729.  
  3730.     private int priceCheck() {
  3731.         int priceCheck = -1;
  3732.         for (int i = 0; i < equipment.length; i++) {
  3733.             priceCheck += getItemValue(equipment[i]) * equipmentN[i];
  3734.         }
  3735.         for (int i = 0; i < items.length; i++) {
  3736.             priceCheck += getItemValue(items[i]) * itemsN[i];
  3737.         }
  3738.         return priceCheck;
  3739.     }
  3740.  
  3741.     public int EPAmount;
  3742.  
  3743.     public int totalValue(int[] items) {
  3744.         int totalValue = 0;
  3745.         try {
  3746.             int[] allItems = new int[items.length + equipment.length];
  3747.             System.arraycopy(items, 0, allItems, 0, items.length);
  3748.             System.arraycopy(equipment, 0, allItems, items.length, equipment.length);
  3749.  
  3750.             for (int i : allItems) {
  3751.                 totalValue += getItemValue(i);
  3752.             }
  3753.         } catch (Exception e) {
  3754.             e.printStackTrace();
  3755.             return 0;
  3756.         }
  3757.         return totalValue;
  3758.     }
  3759.  
  3760.     void drainPrayer() {
  3761.         if (usingPrayer) {
  3762.             if (drainDelay == 0) {
  3763.                 if (skillLvl[5] <= 1) {
  3764.                     resetPrayer();
  3765.                     skillLvl[5]--;
  3766.                     getActionSender().setSkillLvl(this, 5);
  3767.                     appearanceUpdateReq = true;
  3768.                     updateReq = true;
  3769.                     getActionSender().sendMessage(this, "You are out of prayer points. Please restore them at an prayer altar.");
  3770.                     return;
  3771.                 }
  3772.                 skillLvl[5]--;
  3773.                 getActionSender().setSkillLvl(this, 5);
  3774.             }
  3775.             drainDelay = 8;
  3776.             appearanceUpdateReq = true;
  3777.             updateReq = true;
  3778.         }
  3779.     }
  3780.  
  3781.     public void removeWilderness() {
  3782.         getActionSender().setPlayerOption(this, "Null", 1, true);
  3783.         getActionSender().setInterfaceConfig(this, 745, 6, true);
  3784.         getActionSender().setInterfaceConfig(this, 745, 3, false);
  3785.     }
  3786.  
  3787.     public void addWilderness() {
  3788.         getActionSender().setPlayerOption(this, "Attack", 1, true);
  3789.         if (wildernessZone(absX, absY)) {
  3790.         }
  3791.         if (isPVP()) {
  3792.             getActionSender().setInterfaceConfig(this, 745, 3, true);
  3793.             getActionSender().setInterfaceConfig(this, 745, 6, false);
  3794.             int max = combatLevel + wildyLevel;
  3795.             if (max > 126) {
  3796.                 max = 126;
  3797.             }
  3798.             int min = (combatLevel - wildyLevel) + (((combatLevel % 10 >= 5) && ((combatLevel - wildyLevel) % 10 < 5) || (combatLevel >= 114)) ? 2 : 1);
  3799.             if (min < 3) {
  3800.                 min = 3;
  3801.             }
  3802.             String range = +min+" - "+max;
  3803.             getActionSender().setString(this,""+range, 494, 2);
  3804.         }
  3805.     }
  3806.  
  3807.     public int wildernessLevels(int coordY) {
  3808.         wildyLevel = (coordY - 3254 / 7);
  3809.         if (wildyLevel < 1)
  3810.             wildyLevel = 1;
  3811.         return wildyLevel;
  3812.     }
  3813.  
  3814.     public boolean inEdge() {
  3815.         return absX >= 3040 && absX <= 3125 && absY >= 3523 && absY <= 3551;
  3816.     }
  3817.  
  3818.     public boolean fullDharok() {
  3819.         return equipment[3] == 4718 && equipment[4] == 4720 && equipment[7] == 4722 && equipment[0] == 4716;
  3820.     }
  3821.  
  3822.     public boolean fullVerac() {
  3823.         return equipment[3] == 4755 && equipment[4] == 4757 && equipment[7] == 4759 && equipment[0] == 4753;
  3824.     }
  3825.  
  3826.     public boolean hasGuthanEquipment() {
  3827.         return equipment[3] == 4726 && equipment[4] == 4728 && equipment[7] == 4730 && equipment[0] == 4724;
  3828.     }
  3829.  
  3830.     public int distanceToPoint(int pointX, int pointY) {
  3831.         return (int) Math.sqrt(Math.pow(absX - pointX, 2) + Math.pow(absY - pointY, 2));
  3832.     }
  3833.  
  3834.     public boolean fullVoidKnightRange() {
  3835.         return equipment[0] == 11675 && equipment[4] == 8839 && equipment[7] == 8840;
  3836.     }
  3837.  
  3838.     public boolean fullArmadyl() {
  3839.         return equipment[0] == 11718 && equipment[4] == 11720 && equipment[7] == 11722;
  3840.     }
  3841.  
  3842.     public boolean saraChamber() {
  3843.         return absX >= 2889 && absX <= 2907 && absY >= 5258 && absY <= 5276;
  3844.     }
  3845.  
  3846.     public boolean zammyChamber() {
  3847.         return absX >= 2919 && absX <= 2935 && absY >= 5319 && absY <= 5330;
  3848.     }
  3849.  
  3850.     public boolean graardorChamber() {
  3851.         return absX >= 2864 && absX <= 2876 && absY >= 5351 && absY <= 5369;
  3852.     }
  3853.  
  3854.     public boolean armadylChamber() {
  3855.         return absX >= 2823 && absX <= 2843 && absY >= 5295 && absY <= 5310;
  3856.     }
  3857.  
  3858.     public boolean armadylChamber1() {
  3859.         return absX >= 2825 && absX <= 2841 && absY >= 5297 && absY <= 5307;
  3860.     }
  3861.  
  3862.     public boolean inMageArena() {
  3863.         return absX >= 3079 && absX <= 3126 && absY >= 3906 && absY <= 3951;
  3864.     }
  3865.  
  3866.     public boolean inDuelArena() {
  3867.         return absX >= 3349 && absX <= 3388 && absY >= 3262 && absY <= 3280;
  3868.     }
  3869.  
  3870.     public boolean godWarsDung() {
  3871.         return absX >= 2819 && absX <= 2946 && absY >= 5254 && absY <= 5362;
  3872.     }
  3873.  
  3874.     public boolean inJadCave() {
  3875.         return absX >= 2375 && absX <= 2425 && absY >= 5128 && absY <= 5169;
  3876.     }
  3877.  
  3878.     public void setGodWarsStrings() {
  3879.         if (zammyChamber() || addZamorakCheckEventGodWars())
  3880.             for (int i = 7; i <  11; i++)
  3881.                 for (int k = 0; k < 5; k++)
  3882.                     if (this != null)
  3883.                         getActionSender().setString(this, ""+godWarsKills[k]+"", 598, i);
  3884.                     else
  3885.                         for (int s = 7; s <  11; s++)
  3886.                             for (int d = 0; d < 5; d++)
  3887.                                 if (this != null)
  3888.                                     getActionSender().setString(this, ""+godWarsKills[d]+"", 601, s);
  3889.     }
  3890.  
  3891.     public ActionSender getActionSender() {
  3892.         return Engine.actionSender;
  3893.     }
  3894.  
  3895.     public TestWorldLoader getWorldLoader() {
  3896.         return worldLoader;
  3897.     }
  3898.  
  3899.     public ByteVector getByteVector() {
  3900.         return stream;
  3901.     }
  3902.  
  3903.     public boolean duelFight() {
  3904.         return absX >= 3361 && absX <= 3392 && absY >= 3223 && absY <= 3241;
  3905.     }
  3906.  
  3907.     public boolean slayerTower() {
  3908.         return absX >= 3402 && absX <= 3458 && absY >= 3529 && absY <= 3581;
  3909.     }
  3910.  
  3911.  
  3912.     public boolean correctDistance(int j, int k, int l, int i1, int j1) {
  3913.         for(int k1 = 0; k1 <= j1; k1++) {
  3914.             for(int l1 = 0; l1 <= j1; l1++) {
  3915.                 if (j + k1 == l && (k + l1 == i1 || k - l1 == i1 || k == i1))
  3916.                     return true;
  3917.                 if (j - k1 == l && (k + l1 == i1 || k - l1 == i1 || k == i1))
  3918.                     return true;
  3919.                 if (j == l && (k + l1 == i1 || k - l1 == i1 || k == i1))
  3920.                     return true;
  3921.             }
  3922.  
  3923.         }
  3924.         return false;
  3925.     }
  3926.  
  3927.     public int getLoginSpecial() {
  3928.         if (specAmount <= 0) {
  3929.             return 0;
  3930.         } else {
  3931.             return specAmount;
  3932.         }
  3933.     }
  3934.  
  3935.     public int getLoginSpellbook() {
  3936.         if (spellbook <= 0) {
  3937.             return 192;
  3938.         } else {
  3939.             return spellbook;
  3940.         }
  3941.     }
  3942.  
  3943.     public boolean inEdgePk() {
  3944.         return absX >= 3040 && absX <= 3118 && absY >= 3522 && absY <= 3553;
  3945.     }
  3946.  
  3947.     public boolean combatDifference(int cbLvl) {
  3948.         return wildLevel >= combatLevel && combatLevel + cbLvl >= wildLevel || cbLvl < combatLevel && combatLevel - wildLevel <= cbLvl || cbLvl == combatLevel;
  3949.     }
  3950.  
  3951.     void addWildernessUpdating() {
  3952.         getActionSender().setString(this, "Level: " + getWildernessLevel(), 380, 1);
  3953.         getActionSender().setString(this, "Level: " + getWildernessLevel(), 380, 1);
  3954.         getActionSender().setString(this, "Level: " + getWildernessLevel(), 380, 2);
  3955.         getActionSender().setString(this, "Level: " + getWildernessLevel(), 380, 3);
  3956.         if (updatedLevel != wildernessZone(absX, absY)) {
  3957.             updatedLevel = wildernessZone(absX, absY);
  3958.             if (updatedLevel) {
  3959.                 getActionSender().setOverlay(this, 380);
  3960.             } else {
  3961.                 wildyLevel = 0;
  3962.                 getActionSender().removeOverlay(this);
  3963.             }
  3964.         }
  3965.     }
  3966.  
  3967.     public boolean burakZone() {
  3968.         return absX >= 3040 && absX <= 3329 && absY >= 3523 && absY <= 3524;
  3969.     }
  3970.     public boolean specialZone() {
  3971.         return absX == 2995 && absY <= 3533 && absY >= 3530;
  3972.     }
  3973.     public void crossDitch() {
  3974.         int y = 3520;
  3975.         if (!burakZone()) {
  3976.             y = 3523;
  3977.         }
  3978.         if (specialZone()) {
  3979.             playerWalk(2998, absY + 3, 6132, 0);
  3980.             appearanceUpdateReq = true;
  3981.             updateReq = true;
  3982.             return;
  3983.         }
  3984.         playerWalk(absX, y, 6132, 0);
  3985.         appearanceUpdateReq = true;
  3986.         updateReq = true;
  3987.     }
  3988.     public void loadStaticObjects() {
  3989.         //3091 3956
  3990.         //getActionSender().addStaticObject(26972, 0, 3090, 3474, 0, 10);
  3991.         getActionSender().addStaticObject(5959, 0, 3090, 3474, 0, 4);
  3992.     }
  3993.  
  3994.     public boolean addZamorakCheckEventGodWars() {
  3995.         return absX >= 2879 && absX <= 2945 && absY >= 5342 && absY <= 5364;
  3996.     }
  3997.  
  3998.     /**
  3999.      * Update the player.
  4000.      */
  4001.     public void updatePlayer(boolean updateIsNeccesary) {
  4002.         appearanceUpdateReq = updateReq = updateIsNeccesary;
  4003.     }
  4004.  
  4005.     public int getX() {
  4006.         return absX;
  4007.     }
  4008.  
  4009.     public int getY() {
  4010.         return absY;
  4011.     }
  4012.  
  4013.     public int getHeight() {
  4014.         return heightLevel;
  4015.     }
  4016.  
  4017.     public int getPlayerId() {
  4018.         return playerId;
  4019.     }
  4020.  
  4021.     public void convertPlayerToNpc(int npcType) {
  4022.         this.npcType = npcType;
  4023.     }
  4024.  
  4025.     public void updatePlayerAppearance(int walkAnim, int standAnim, int runAnim) {
  4026.         standEmote = standAnim;
  4027.         walkEmote = walkAnim;
  4028.         runEmote = runAnim;
  4029.     }
  4030.  
  4031.     public void appendToIPBanned(Player player) {
  4032.         BufferedWriter bw = null;
  4033.         try {
  4034.             bw = new BufferedWriter(new FileWriter("./data/banned/bannedhosts.dat", true));
  4035.             bw.write(Server.socketListener.getAddress(player.socket.socket));
  4036.             bw.newLine();
  4037.             bw.flush();
  4038.             Server.socketListener.loadBannedHosts();
  4039.             player.disconnected[0] = true;
  4040.             player.disconnected[1] = true;
  4041.         } catch (IOException ioe) {
  4042.         } finally {
  4043.             if (bw != null) {
  4044.                 try {
  4045.                     bw.close();
  4046.                 } catch (IOException ioe2) {
  4047.                 }
  4048.             }
  4049.         }
  4050.     }
  4051.     public void appendToBanned(String player) {
  4052.         BufferedWriter bw = null;
  4053.         try {
  4054.             bw = new BufferedWriter(new FileWriter("./data/banned/bannedusers.dat", true));
  4055.             bw.write(player);
  4056.             bw.newLine();
  4057.             bw.flush();
  4058.             Server.loadBannedUsers();
  4059.         } catch (IOException ioe) {
  4060.         } finally {
  4061.             if (bw != null) {
  4062.                 try {
  4063.                     bw.close();
  4064.                 } catch (IOException ioe2) {
  4065.                 }
  4066.             }
  4067.         }
  4068.     }
  4069.  
  4070.     String Directory = "./data/banned/bannedusers.dat";
  4071.     String MaxBan[] = new String[1000];
  4072.     String UserThatBan = new String();
  4073.     int Ban = 0;
  4074.  
  4075.     public void UnBanPlayer(String Player) {
  4076.         try {
  4077.             BufferedReader dataStream = new BufferedReader(new FileReader("./data/banned/bannedusers.dat"));
  4078.             while ((UserThatBan = dataStream.readLine()) != null) {
  4079.                 if(UserThatBan.equalsIgnoreCase(Player)) {
  4080.                 } else
  4081.                     if(!UserThatBan.equalsIgnoreCase(Player)) {
  4082.                         MaxBan[Ban] = UserThatBan;
  4083.                         Ban++;
  4084.                     }
  4085.             }
  4086.         } catch(Exception e) {
  4087.             e.printStackTrace();
  4088.         }
  4089.         BufferedWriter bw = null;
  4090.         try {
  4091.             bw = new BufferedWriter(new FileWriter(Directory, false));
  4092.             bw.write("");
  4093.             bw.flush();
  4094.             bw.close();
  4095.         } catch(Exception e) {
  4096.             e.printStackTrace();
  4097.         }
  4098.         try {
  4099.             bw = new BufferedWriter(new FileWriter("./data/banned/bannedusers.dat", true));
  4100.             for(int a = 0; a < MaxBan.length; a++) {
  4101.                 if(MaxBan[a] != null) {
  4102.                     bw.write(MaxBan[a]);
  4103.                     bw.newLine();
  4104.                     bw.flush();
  4105.                 }
  4106.             }
  4107.             bw.close();
  4108.         } catch(Exception e) {
  4109.             e.printStackTrace();
  4110.         }
  4111.         Server.loadBannedUsers();
  4112.     }
  4113.     public boolean nonMultiPlace() {
  4114.         return absX >= 3400 && absX <= 3457 && absY >= 3527 && absY <=  3579 && heightLevel == 2;
  4115.     }
  4116.  
  4117.     public int neededSpecialAmount() {
  4118.         switch (equipment[3]) {
  4119.         case 1215:
  4120.         case 1231:
  4121.         case 5680:
  4122.         case 5698:
  4123.         case 1305:
  4124.         case 1434:
  4125.             return 250;
  4126.         case 10887:
  4127.         case 11694:
  4128.         case 11698:
  4129.         case 4151:
  4130.             return 500;
  4131.         case 11235:
  4132.             return 550;
  4133.         case 11700:
  4134.             return 600;
  4135.         case 11696:
  4136.         case 11730:
  4137.             return 1000;
  4138.         default:
  4139.             return 0;
  4140.         }
  4141.     }
  4142.  
  4143.     public int weaponType;
  4144.  
  4145.     public int attackStyle() {
  4146.  
  4147.         /*
  4148.          * Melee weapon styles
  4149.          * 1 : accurate
  4150.          * 2 : agressive
  4151.          * 3 : defensive
  4152.          * 4 : controlled
  4153.          *
  4154.          * Ranged weapon styles
  4155.          * 5 : accurate
  4156.          * 6 : rapid
  4157.          * 7 : longrange
  4158.          */
  4159.  
  4160.         switch (weaponType) {
  4161.         case 0: return fightStyle;
  4162.         case 1: return fightStyle;
  4163.         case 2:
  4164.             if (fightStyle == 1) {
  4165.                 return 1;
  4166.             }
  4167.             if (fightStyle == 3) {
  4168.                 return 2;
  4169.             }
  4170.             if (fightStyle == 2) {
  4171.                 return 3;
  4172.             }
  4173.         case 3:
  4174.             if (fightStyle == 1) {
  4175.                 return 1;
  4176.             }
  4177.             if (fightStyle == 2) {
  4178.                 return 2;
  4179.             }
  4180.             if (fightStyle == 3) {
  4181.                 return 4;
  4182.             }
  4183.             if (fightStyle == 4) {
  4184.                 return 3;
  4185.             }
  4186.         case 4:
  4187.             if (fightStyle == 1) {
  4188.                 return 5;
  4189.             }
  4190.             if (fightStyle == 3) {
  4191.                 return 6;
  4192.             }
  4193.             if (fightStyle == 2) {
  4194.                 return 7;
  4195.             }
  4196.         case 5: break;
  4197.         case 6: return fightStyle;
  4198.         case 7:
  4199.             if (fightStyle == 1) {
  4200.                 return 1;
  4201.             }
  4202.             if (fightStyle == 2 || fightStyle == 3) {
  4203.                 return 2;
  4204.             }
  4205.             if (fightStyle == 4) {
  4206.                 return 3;
  4207.             }
  4208.         case 8:
  4209.             if (fightStyle == 1) {
  4210.                 return 1;
  4211.             }
  4212.             if (fightStyle == 4 || fightStyle == 3) {
  4213.                 return 2;
  4214.             }
  4215.             if (fightStyle == 2) {
  4216.                 return 3;
  4217.             }
  4218.         case 9:
  4219.             if (fightStyle == 1) {
  4220.                 return 4;
  4221.             }
  4222.             if (fightStyle == 2) {
  4223.                 return 2;
  4224.             }
  4225.             if (fightStyle == 3) {
  4226.                 return 3;
  4227.             }
  4228.         case 10:
  4229.             if (fightStyle == 1) {
  4230.                 return 1;
  4231.             }
  4232.             if (fightStyle == 2) {
  4233.                 return 2;
  4234.             }
  4235.             if (fightStyle == 3) {
  4236.                 return 4;
  4237.             }
  4238.             if (fightStyle == 4) {
  4239.                 return 3;
  4240.             }
  4241.         case 11:
  4242.             if (fightStyle == 1) {
  4243.                 return 1;
  4244.             }
  4245.             if (fightStyle == 4) {
  4246.                 return 2;
  4247.             }
  4248.             if (fightStyle == 3) {
  4249.                 return 4;
  4250.             }
  4251.             if (fightStyle == 2) {
  4252.                 return 3;
  4253.             }
  4254.         case 12:
  4255.             if (fightStyle == 1 || fightStyle == 2) {
  4256.                 return fightStyle;
  4257.             }
  4258.             if (fightStyle == 3) {
  4259.                 return 4;
  4260.             }
  4261.             if (fightStyle == 4) {
  4262.                 return 3;
  4263.             }
  4264.         }
  4265.         return 8;
  4266.     }
  4267.  
  4268.     public int weaponStyle(int weaponID) {
  4269.         switch (weaponID) {
  4270.         case 4151: return 2;
  4271.         case 4153: return 3;
  4272.         case 1277:
  4273.         case 1279:
  4274.         case 1281:
  4275.         case 1283:
  4276.         case 1285:
  4277.         case 1287:
  4278.         case 1289:
  4279.         case 1291:
  4280.         case 1293:
  4281.         case 1295:
  4282.         case 1297:
  4283.         case 1299:
  4284.         case 1301:
  4285.         case 1303:
  4286.         case 1305:
  4287.         case 1329:
  4288.         case 1331:
  4289.         case 1337:
  4290.         case 4587:
  4291.             if (fightStyle != 3) {
  4292.                 return 2;
  4293.             } else {
  4294.                 return 1;
  4295.             }
  4296.         case 1434:
  4297.         case 4755:
  4298.         case 10887:
  4299.             if (fightStyle != 3) {
  4300.                 return 3;
  4301.             } else {
  4302.                 return 1;
  4303.             }
  4304.         case 1215:
  4305.         case 1231:
  4306.         case 5680:
  4307.         case 5698:
  4308.             if (fightStyle != 3) {
  4309.                 return 1;
  4310.             } else {
  4311.                 return 2;
  4312.             }
  4313.         case 1307:
  4314.         case 1309:
  4315.         case 1311:
  4316.         case 1313:
  4317.         case 1315:
  4318.         case 1317:
  4319.         case 1319:
  4320.         case 1349:
  4321.         case 1351:
  4322.         case 1353:
  4323.         case 1355:
  4324.         case 1357:
  4325.         case 1359:
  4326.         case 1361:
  4327.         case 1363:
  4328.         case 1365:
  4329.         case 1367:
  4330.         case 1369:
  4331.         case 1371:
  4332.         case 1373:
  4333.         case 1375:
  4334.         case 1377:
  4335.         case 4718:
  4336.         case 6739:
  4337.         case 7158:
  4338.         case 11694:
  4339.         case 11696:
  4340.         case 11698:
  4341.         case 11700:
  4342.         case 11730:
  4343.             if (fightStyle != 3) {
  4344.                 return 2;
  4345.             } else {
  4346.                 return 3;
  4347.             }
  4348.         }
  4349.         return 1;
  4350.     }
  4351.  
  4352.     public int getAttackSound() {
  4353.         String weapon = Engine.items.getItemName(equipment[3]);
  4354.         if (weapon.equals("Abyssal whip")) {
  4355.             return 2720;
  4356.         }
  4357.         if (weapon.contains("godsword") || weapon.equals("Saradomin sword")) {
  4358.             switch (fightStyle) {
  4359.             case 1:
  4360.             case 2:
  4361.             case 4: return 3846;
  4362.             case 3: return 3882;
  4363.             }
  4364.         }
  4365.         if (weapon.equals("Granite maul")) {
  4366.             return 2714;
  4367.         }
  4368.         return -1;
  4369.     }
  4370.  
  4371.     public int getSpecialAttackSound() {
  4372.         return -1;
  4373.     }
  4374.  
  4375.     public boolean clanWarsFightArea() {
  4376.         return absX >= 3263 && absX <= 3327 && absY >= 3713 && absY <= 3840;
  4377.     }
  4378.  
  4379.     public boolean bountySafe1() {
  4380.         return absX >=3173  && absX <=3193  && absY >=3669  && absY <=3701;
  4381.     }
  4382.  
  4383.     public boolean bountySafe2() {
  4384.         return absX >=3154  && absX <=3173  && absY >=3669  && absY <=3690;
  4385.     }
  4386.  
  4387.     public boolean bountySafe3() {
  4388.         return absX >=3145  && absX <=3167  && absY >=3662  && absY <=3668;
  4389.     }
  4390.  
  4391.     public boolean bountySafe4() {
  4392.         return absX >=3143  && absX <=3154  && absY >=3669  && absY <=3675;
  4393.     }
  4394.  
  4395.     public boolean bountySafe5() {
  4396.         return absX >=3136  && absX <=3145  && absY >=3652  && absY <=3662;
  4397.     }
  4398.  
  4399.     public boolean bountySafe(){
  4400.         return bountySafe1() || bountySafe2() || bountySafe3() || bountySafe4() || bountySafe5();
  4401.     }
  4402.  
  4403.     public void destruct() {
  4404.         stream = null;
  4405.         try {
  4406.             socket.input.close();
  4407.             socket.output.close();
  4408.             socket.socket.close();
  4409.         } catch (Exception e) {
  4410.         }
  4411.         socket.input = null;
  4412.         socket.output = null;
  4413.         socket.socket = null;
  4414.         socket = null;
  4415.         absX = absY = mapRegionX = mapRegionY = -1;
  4416.         long me = Misc.stringToLong(username);
  4417.         for(Player p : Engine.players) {
  4418.             if(p == null) continue;
  4419.             if(p.friends.contains(me)) {
  4420.                 p.getActionSender().sendFriend(p, me, 0);
  4421.             }
  4422.         }
  4423.     }
  4424. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement