Guest User

Untitled

a guest
Mar 17th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package server.model.player;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5.  
  6.  
  7. import java.sql.*;
  8. import server.Constants;
  9. import server.Server;
  10. import server.util.Misc;
  11. import server.content.skill.SkillConstants;
  12. import server.model.DialogueAction;
  13. import server.model.DialogueMessage;
  14. import server.model.FloorItem;
  15. import server.model.Item;
  16. import server.model.player.Player;
  17. import server.world.PlayerManager;
  18. import server.model.Shop;
  19. import server.model.player.PlayerConstants;
  20. import server.world.AnimationManager;
  21. import server.model.npc.NPC;
  22. import server.content.skill.Magic;
  23. import server.model.player.TzWaves;
  24. import server.model.object.GameObject;
  25. import server.model.player.packet.SubClasses.LevelUp;
  26. import server.model.player.packet.SubClasses.Specbar;
  27. import server.model.player.packet.SubClasses.Wear;
  28. import server.content.BankPin;
  29.  
  30. /**
  31.  * Lots of packets in here.
  32.  *
  33.  * @author Graham
  34.  *
  35.  */
  36. public class ActionAssistant {
  37.  
  38.  
  39.  
  40.     public int[] playerItems = new int[28];
  41.     public int[] playerItemsN = new int[28];
  42.  
  43.     private int playerBankSize = 200;
  44.     public int[] bankItems = new int[800];
  45.     public int[] bankItemsN = new int[800];
  46.  
  47.  
  48.     private Client client;
  49.  
  50. public int slot;
  51. public int amount = 1;
  52.     public ActionAssistant(Client client) {
  53.         this.client = client;
  54.     }
  55. public String optionType = "null";
  56.     public void showOption(int i, int l, String s, int a) {
  57.         if(!optionType.equalsIgnoreCase(s)) {
  58.             optionType = s;
  59.             client.getOutStream().createFrameVarSize(104);
  60.             client.getOutStream().writeByteC(i);
  61.             client.getOutStream().writeByteA(l);
  62.             client.getOutStream().writeString(s);
  63.             client.getOutStream().endFrameVarSize();
  64.             client.flushOutStream();
  65.         }
  66.     }
  67.  
  68.  
  69.  
  70. //Bank Pins
  71.  
  72.  
  73.  
  74.     public void openBank() {
  75.    
  76.         if(client.playerBankPin != 15000 && (!client.hasBankPin)) {
  77.             randomizeNumbers();
  78.             client.getActionAssistant().sendQuest("First click the FIRST digit", 15313);
  79.             client.getActionAssistant().showInterface(7424);
  80.             sendQuests();
  81.            
  82.         } else {
  83. client.getActionAssistant().newBank();
  84. }
  85. }  
  86.     public int allowTimer = 2000000;
  87.    
  88.     public void timeCountDown() {
  89.         if(allowTimer > 0 && allowTimer <= 300000) {
  90.             allowTimer -= 100;
  91.         }
  92.         if(allowTimer == 0) {
  93.             client.attemptsRemaining = 3;
  94.             allowTimer = 2000000;
  95.         }
  96.     }
  97.    
  98.     public void bankPinEnter(int button) {
  99.         if(allowTimer > 0 && allowTimer <= 300000) {
  100.             int time = allowTimer/6000;
  101.             if(time >= 2) {
  102.                 client.getActionAssistant().sendMessage("Please wait "+time+
  103.                         " minutes before attempting your bank pin again.");
  104.             } else if(time == 1) {
  105.                 client.getActionAssistant().sendMessage("Please wait "+time+
  106.                 " minute before attempting your bank pin again.");
  107.             } else if(time <= 0) {
  108.                 client.getActionAssistant().sendMessage("Please wait less " +
  109.                         "than a minute before attempting your bank pin again.");
  110.             }
  111.             return;
  112.         }
  113.         sendQuests();
  114.         if(!client.firstPinEnter)
  115.             handleButtonOne(button);
  116.         else if(!client.secondPinEnter)
  117.             handleButtonTwo(button);
  118.         else if(!client.thirdPinEnter)
  119.             handleButtonThree(button);
  120.         else if(!client.fourthPinEnter)
  121.             handleButtonFour(button);
  122.     }
  123.    
  124.    
  125.    
  126.     public void sendQuests() {
  127.         for(int i = 0; i < getBankPins().length; i++) {
  128.             client.getActionAssistant().sendQuest(""+getBankPins()[i], stringIds[i]);
  129.         }
  130.     }
  131.    
  132.     public void handleButtonOne(int button) {
  133.         client.getActionAssistant().sendQuest("Now click the SECOND digit", 15313);
  134.         for(int i = 0; i < getActionButtons().length; i++) {
  135.             if(getActionButtons()[i] == button) {
  136.                 firstPin = getBankPins()[i];
  137.             }
  138.         }
  139.         client.firstPinEnter = true;
  140.         randomizeNumbers();
  141.     }
  142.    
  143.     public void handleButtonTwo(int button) {
  144.         client.getActionAssistant().sendQuest("Now click the THIRD digit", 15313);
  145.         for(int i = 0; i < getActionButtons().length; i++) {
  146.             if(getActionButtons()[i] == button) {
  147.                 secondPin = getBankPins()[i];
  148.             }
  149.         }
  150.         client.secondPinEnter = true;
  151.         randomizeNumbers();
  152.     }
  153.    
  154.     public void handleButtonThree(int button) {
  155.         client.getActionAssistant().sendQuest("Now click the LAST digit", 15313);
  156.         for(int i = 0; i < getActionButtons().length; i++) {
  157.             if(getActionButtons()[i] == button) {
  158.                 thirdPin = getBankPins()[i];
  159.             }
  160.         }
  161.         client.thirdPinEnter = true;
  162.         randomizeNumbers();
  163.     }
  164.    
  165.         private void handleButtonFour(int button) {
  166.         for(int i = 0; i < getActionButtons().length; i++) {
  167.             if(getActionButtons()[i] == button) {
  168.                 fourthPin = getBankPins()[i];
  169.             }
  170.         }
  171.         client.fourthPinEnter = true;
  172.         if(!client.hasBankPin) {
  173.             client.firstPin = firstPin;
  174.             client.secondPin = secondPin;
  175.             client.thirdPin = thirdPin;
  176.             client.fourthPin = fourthPin;
  177.             client.hasBankPin = true;
  178.             client.getActionAssistant().sendMessage("You have just created a bank pin.");
  179.             client.getActionAssistant().sendMessage("Your new pin is: "+firstPin+ " "+secondPin+" "+thirdPin+" "+fourthPin);
  180.         }
  181.         int one = firstPin, two = secondPin, three = thirdPin, four = fourthPin;
  182.         if(client.firstPin == one && client.secondPin == two && client.thirdPin == three && client.fourthPin == four) {
  183.             client.getActionAssistant().newBank();
  184.             client.fourthPinEnter = false;
  185.             client.thirdPinEnter = false;
  186.             client.secondPinEnter = false;
  187.             client.firstPinEnter = false;
  188.             client.playerBankPin = 15000;
  189.         } else {
  190.             client.attemptsRemaining --;
  191.             if(client.attemptsRemaining <= 0) {
  192.                 allowTimer = 30000;
  193.             }
  194.             if(client.attemptsRemaining == -1) {
  195.                 client.attemptsRemaining = 3;
  196.                 allowTimer = 2000000;
  197.             }
  198.             if(client.attemptsRemaining > 1) {
  199.                 client.getActionAssistant().sendMessage("Invalid pin. You have "+client.attemptsRemaining+" attempts remaining.");
  200.             } else if(client.attemptsRemaining == 1) {
  201.                 client.getActionAssistant().sendMessage("Invalid pin. You have "+client.attemptsRemaining+" attempt remaining.");
  202.             } else if(client.attemptsRemaining <= 0) {
  203.                 client.getActionAssistant().sendMessage("Invalid pin. You must wait 5 minutes before attempting again.");
  204.             }
  205.             client.getActionAssistant().removeAllWindows();
  206.             client.fourthPinEnter = false;
  207.             client.thirdPinEnter = false;
  208.             client.secondPinEnter = false;
  209.             client.firstPinEnter = false;
  210.         }
  211.     }
  212.    
  213.     public void randomizeNumbers() {
  214.         int i = Misc.random(4);
  215.         switch(i) {
  216.         case 0:
  217.             bankPins[0] = 1;
  218.             bankPins[1] = 7;
  219.             bankPins[2] = 0;
  220.             bankPins[3] = 8;
  221.             bankPins[4] = 4;
  222.             bankPins[5] = 6;
  223.             bankPins[6] = 5;
  224.             bankPins[7] = 9;
  225.             bankPins[8] = 3;
  226.             bankPins[9] = 2;
  227.             break;
  228.        
  229.         case 1:
  230.             bankPins[0] = 5;
  231.             bankPins[1] = 4;
  232.             bankPins[2] = 3;
  233.             bankPins[3] = 7;
  234.             bankPins[4] = 8;
  235.             bankPins[5] = 6;
  236.             bankPins[6] = 9;
  237.             bankPins[7] = 2;
  238.             bankPins[8] = 1;
  239.             bankPins[9] = 0;
  240.             break;
  241.            
  242.         case 2:
  243.             bankPins[0] = 4;
  244.             bankPins[1] = 7;
  245.             bankPins[2] = 6;
  246.             bankPins[3] = 5;
  247.             bankPins[4] = 2;
  248.             bankPins[5] = 3;
  249.             bankPins[6] = 1;
  250.             bankPins[7] = 8;
  251.             bankPins[8] = 9;
  252.             bankPins[9] = 0;
  253.             break;
  254.            
  255.         case 3:
  256.             bankPins[0] = 9;
  257.             bankPins[1] = 4;
  258.             bankPins[2] = 2;
  259.             bankPins[3] = 7;
  260.             bankPins[4] = 8;
  261.             bankPins[5] = 6;
  262.             bankPins[6] = 0;
  263.             bankPins[7] = 3;
  264.             bankPins[8] = 1;
  265.             bankPins[9] = 5;
  266.             break;
  267.         }
  268.         sendQuests();
  269.     }
  270.  
  271.     public int bankPins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  272.     public int stringIds[] = { 14883, 14884, 14885, 14886, 14887, 14888, 14889,
  273.             14890, 14891, 14892};
  274.     public int matchingButtons[] =  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  275.     public int actionButtons[] = { 58025, 58026, 58027, 58028, 58029, 58030,
  276.             58031, 58032, 58033, 58034};
  277.  
  278.    
  279.     public void setBankPins(int bankPins[]) {
  280.         this.bankPins = bankPins;
  281.     }
  282.  
  283.     public int[] getBankPins() {
  284.         return bankPins;
  285.     }
  286.  
  287.     public int[] getActionButtons() {
  288.         return actionButtons;
  289.     }
  290.  
  291.     public int[] getMatchingButtons() {
  292.         return matchingButtons;
  293.     }
  294.    
  295.     public void setFirstPin(int firstPin) {
  296.         this.firstPin = firstPin;
  297.     }
  298.  
  299.     public int getFirstPin() {
  300.         return firstPin;
  301.     }
  302.  
  303.     public void setTotalPin(int totalPin) {
  304.         this.totalPin = totalPin;
  305.     }
  306.  
  307.     public int getTotalPin() {
  308.         return totalPin;
  309.     }
  310.  
  311.     public void setSecondPin(int secondPin) {
  312.         this.secondPin = secondPin;
  313.     }
  314.  
  315.     public int getSecondPin() {
  316.         return secondPin;
  317.     }
  318.  
  319.     public void setThirdPin(int thirdPin) {
  320.         this.thirdPin = thirdPin;
  321.     }
  322.  
  323.     public int getThirdPin() {
  324.         return thirdPin;
  325.     }
  326.  
  327.     public void setFourthPin(int fourthPin) {
  328.         this.fourthPin = fourthPin;
  329.     }
  330.  
  331.     public int getFourthPin() {
  332.         return fourthPin;
  333.     }
  334.  
  335.     public int firstPin;
  336.     public int secondPin;
  337.     public int thirdPin;
  338.     public int fourthPin;
  339.     public int totalPin = firstPin+secondPin+thirdPin+fourthPin;
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376. //Alex
  377.  
  378.  
  379.     public void deleteItem(int id, int amount) {
  380.         deleteItem(id, getItemSlot(id), amount);
  381.     }
  382.  
  383.     public void replaceItem(int id, int id2) {
  384.         deleteItem(id, getItemSlot(id), 1);
  385.         addItem(id2, 1);
  386.     }
  387.     public void MagicTeleport(int a, int b, Client client, String aa, int c, int d, int e, int f, int g, int h, int j){
  388.         Magic.teleport(a, b, client, aa, c, d, e, f, g, h, j);
  389.     }
  390.  
  391.     public void setClientConfig(int id, int state) {
  392.         if(client == null || client.getOutStream() == null){
  393.         return;
  394.         }
  395.         client.getOutStream().createFrame(36);
  396.         client.getOutStream().writeWordBigEndian(id);
  397.         client.getOutStream().writeByte(state);
  398.     }
  399.  
  400.     public boolean FullVeracEquipped() {
  401.         if(client.playerEquipment[PlayerConstants.PLAYER_HAT] == 4753 && client.playerEquipment[PlayerConstants.PLAYER_CHEST] == 4757 && client.playerEquipment[PlayerConstants.PLAYER_LEGS] == 4759 && client.playerEquipment[PlayerConstants.PLAYER_WEAPON] == 4755)  {
  402.              return true;
  403.         }
  404.             return false;          
  405.         }
  406.     public boolean FullGuthanEquipped() {
  407.         if(client.playerEquipment[PlayerConstants.PLAYER_HAT] == 4724 && client.playerEquipment[PlayerConstants.PLAYER_CHEST] == 4728 && client.playerEquipment[PlayerConstants.PLAYER_LEGS] == 4730 && client.playerEquipment[PlayerConstants.PLAYER_WEAPON] == 4726){
  408.             return true;
  409.         }
  410.             return false;          
  411.         }
  412.     public boolean FullDharokEquipped() {
  413.         if(client.playerEquipment[PlayerConstants.PLAYER_HAT] == 4716 && client.playerEquipment[PlayerConstants.PLAYER_CHEST] == 4720 && client.playerEquipment[PlayerConstants.PLAYER_LEGS] == 4722 && client.playerEquipment[PlayerConstants.PLAYER_WEAPON] == 4718){
  414.             return true;
  415.                 } else {
  416.             return false;  
  417.         }      
  418.         }
  419.  
  420.     public void BuyShantayPass(Client client) {
  421.         client.close164frame = true;
  422.         if(playerHasItem(995,10000)){
  423.             deleteItem(995,10000);
  424.             showitem(1854, "You have succesfully", "purchased Shantay pass.");
  425.             addItem(1854,1);
  426.         } else {
  427.             sendFrame126("You don't have enough money to purchase it.", 357);
  428.             sendFrame164(356);         
  429.         }
  430.     }
  431. public void BuyLumby(Client client) {//alex
  432.         if(playerHasItem(995,10)){
  433.             deleteItem(995,10);
  434.             showitem(1004, "You can now enter.", "");
  435.             client.PaidLumby = true;
  436.         } else {
  437.             sendFrame126("You need 10gp to pass.", 357);
  438.             sendFrame164(356);         
  439.         }
  440.     }
  441.     public void BuyBrimh(Client client) {
  442.         if(playerHasItem(995,4000)){
  443.             deleteItem(995,4000);
  444.             showitem(1004, "You can now enter.", "");
  445.             client.PaidBrimhaven = true;
  446.         } else {
  447.             sendFrame126("You don't have enough money to purchase it.", 357);
  448.             sendFrame164(356);         
  449.         }
  450.     }
  451.  
  452.     public void follow(int slot, int type, int distance)
  453.     {
  454.         if(client.getOutStream() == null || client == null){
  455.             return;
  456.         }
  457.         if (slot > 0 && slot == client.followId && type == 1 && client.followId > 0 && client.followDistance != distance && (client.getCombat().useRange() || client.getCombat().useMagic()))
  458.                     return;
  459.         else if (slot > 0 && slot == client.followId2 && type == 0 && client.followId2 > 0 && client.followDistance >= distance && distance != 1)
  460.                     return;
  461.         client.getOutStream().createFrame(174);
  462.         if (client.freezeTimer > 0) {
  463.             client.getOutStream().writeWord(0);
  464.         } else {
  465.             client.getOutStream().writeWord(slot);
  466.             if (type == 0) {
  467.                 client.faceNPC(slot);
  468.                 client.followId = 0;
  469.                 client.followId2 = slot;
  470.             } else if (type == 1) {
  471.                 client.faceNPC(slot + 32768);
  472.                 client.followId2 = 0;
  473.                 client.followId = slot;
  474.             } else if (type == 3) {
  475.                 client.faceNPC(-1);
  476.                 client.followId2 = 0;
  477.                 client.followId = 0;
  478.                 client.followDistance = 0;
  479.             }
  480.             client.followDistance = distance;
  481.         }
  482.         client.getOutStream().writeByte(type);
  483.         client.getOutStream().writeWord(distance);
  484.     }
  485.  
  486.     public void showitem(int item, String s1, String s2) {
  487.         /*sendFrame246(6210, 200, item);
  488.         sendFrame126(s1, 6207); 4267
  489.         sendFrame126(s2, 6208);
  490.         sendFrame164(6206);*/
  491.  
  492.         sendFrame246(4271, 200, item);
  493.         sendFrame126(s1, 4268);
  494.         sendFrame126(s2, 4269);
  495.         sendFrame164(4267);
  496.     }
  497.  
  498. public void sendFrame24(int i1) // Xero: flashes sidebar tab icons!, i1 must be 0 to -12 to work ;) make a command to test em out
  499. {
  500. client.getOutStream().createFrame(24);
  501. client.getOutStream().writeByteA(i1);
  502. //sendMessage("Frame 24 tested");
  503. client.updateRequired = true;
  504. client.appearanceUpdateRequired = true;
  505. }
  506.  
  507.     public void createPlayersObjectAnim(int X,int Y,int animationID, int tileObjectType, int orientation){
  508.         if(client == null){
  509.             return;
  510.         }
  511.         try{
  512.             client.getOutStream().createFrame(85);
  513.             client.getOutStream().writeByteC(Y - (client.mapRegionY * 8));
  514.             client.getOutStream().writeByteC(X - (client.mapRegionX * 8));
  515.             int x = 0;
  516.             int y = 0;
  517.             client.getOutStream().createFrame(160);
  518.             client.getOutStream().writeByteS(((x&7) << 4) + (y&7));//tiles away - could just send 0      
  519.             client.getOutStream().writeByteS((tileObjectType<<2) +(orientation&3));
  520.             client.getOutStream().writeWordA(animationID);// animation id
  521.         } catch(Exception e){
  522.             e.printStackTrace();
  523.         }
  524.     }
  525.     public void objectAnim(int X,int Y,int animationID, int tileObjectType, int orientation) {
  526.         for (Player p : Server.playerManager.players) {
  527.             if(p != null) {
  528.                 Client cc = (Client)p;
  529.                 if(cc.distanceToPoint(X, Y) <= 25){
  530.                     cc.getActionAssistant().createPlayersObjectAnim(X,Y,animationID,tileObjectType,orientation);   
  531.                 }
  532.             }
  533.         }
  534.     }
  535.  
  536.  
  537.     public void sendFrame87(int id, int state) {
  538.         client.getOutStream().createFrame(87);
  539.         client.getOutStream().writeWordBigEndian_dup(id);  
  540.         client.getOutStream().writeDWord_v1(state);
  541.         client.flushOutStream();
  542.     }
  543.  
  544.     public void createArrow(int type, int id) {
  545.     if(client != null){
  546.         client.getOutStream().createFrame(254); //The packet ID
  547.         client.getOutStream().writeByte(type); //1=NPC, 10=Player
  548.         client.getOutStream().writeWord(id); //NPC/Player ID
  549.         client.getOutStream().write3Byte(0); //Junk
  550.     }
  551.     }
  552.     public void createArrow(int x, int y, int height, int pos) {
  553.     if(client != null){
  554.         client.getOutStream().createFrame(254); //The packet ID
  555.         client.getOutStream().writeByte(pos); //Position on Square(2 = middle, 3 = west, 4 = east, 5 = south, 6 = north)
  556.         client.getOutStream().writeWord(x); //X-Coord of Object
  557.         client.getOutStream().writeWord(y); //Y-Coord of Object
  558.         client.getOutStream().writeByte(height); //Height off Ground
  559.     }
  560.     }
  561.  
  562.     public boolean DeleteArrow() {
  563.         if (client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] <= 1) {
  564.             //deleteequiment(client.playerEquipment[13], 13);
  565.             //return false;
  566.         }
  567.         if ((client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] > 0)) {
  568.             client.getOutStream().createFrameVarSizeWord(34);
  569.             client.getOutStream().writeWord(1688);
  570.             client.getOutStream().writeByte(PlayerConstants.PLAYER_ARROWS);
  571.             client.getOutStream().writeWord(client.playerEquipment[PlayerConstants.PLAYER_ARROWS] + 1);
  572.             if (client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] - 1 > 254) {
  573.                 client.getOutStream().writeByte(255);
  574.                 client.getOutStream().writeDWord(client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] - 1);
  575.             } else {
  576.                 client.getOutStream().writeByte(client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] - 1); // amount
  577.             }
  578.             client.getOutStream().endFrameVarSizeWord();
  579.             client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] -= 1;
  580.             client.updateRequired = true;
  581.             client.appearanceUpdateRequired = true;
  582.         }
  583.         return true;
  584.     }
  585.  
  586.     public boolean DeleteRing() {
  587.         if (client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] <= 1) {
  588.             deleteequiment(client.playerEquipment[PlayerConstants.PLAYER_WEAPON], PlayerConstants.PLAYER_WEAPON);
  589.             return false;
  590.         }
  591.         if (client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] > 0) {
  592.             client.getOutStream().createFrameVarSizeWord(34);
  593.             client.getOutStream().writeWord(1688);
  594.             client.getOutStream().writeByte(PlayerConstants.PLAYER_WEAPON);
  595.             client.getOutStream().writeWord(client.playerEquipment[PlayerConstants.PLAYER_WEAPON] + 1);
  596.             if(client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] - 1 > 254) {
  597.                 client.getOutStream().writeByte(255);
  598.                 client.getOutStream().writeDWord(client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] - 1);
  599.             } else {
  600.                 client.getOutStream().writeByte(client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] - 1); // amount
  601.             }
  602.             client.getOutStream().endFrameVarSizeWord();
  603.             client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] -= 1;
  604.         }
  605.         client.updateRequired = true;
  606.         client.appearanceUpdateRequired = true;
  607.         return true;
  608.     }
  609.  
  610.     public void dropItem(int id, int amount, int x, int y, int z) {
  611.        
  612.         FloorItem i = new FloorItem(id,amount, client, x, y, z, client.currentRegion);
  613.     if(i == null){
  614.         return;
  615.     }
  616.         for(FloorItem f : Server.getItemManager().list) {
  617.             if(f.getX() == i.getX() && f.getY() == i.getY() && f.getHeight() == i.getHeight() && f.getId() == i.getId()) {
  618.                 Server.getItemManager().hideDrop(i);
  619.                 Server.getItemManager().list.remove(f);
  620.                 i.setAmount(f.getAmount() + 1);
  621.                 Server.getItemManager().newDrop(i, client);
  622.                 return;
  623.             }
  624.         }
  625.         Server.getItemManager().newDrop(i, client);
  626.     }
  627.     public void Kolodion(Client client, int ID){
  628.         Server.getStillGraphicsManager().stillGraphics(client,3104, 3935, 0, 580, 0);
  629.         Server.getNpcManager().spawnANPC(ID, 3104, 3935, 0, client);
  630.     }
  631.  
  632.     public void deleteequiment(int wearID, int slot) {
  633.         client.playerEquipment[slot] = -1;
  634.         client.playerEquipmentN[slot] = 0;
  635.         client.getOutStream().createFrame(34);
  636.         client.getOutStream().writeWord(6);
  637.         client.getOutStream().writeWord(1688);
  638.         client.getOutStream().writeByte(slot);
  639.         client.getOutStream().writeWord(0);
  640.         client.getOutStream().writeByte(0);
  641.         client.updateRequired = true;
  642.         client.appearanceUpdateRequired = true;
  643.     }
  644.  
  645.     /**
  646.     * Objects, add and remove
  647.     **/
  648.     public void object(int objectId, int objectX, int objectY, int face, int objectType) {
  649.          for(Player p : Server.getPlayerManager().getClientRegion(client.currentRegion)){
  650.         if(p != null){
  651.             ((Client) p).getActionAssistant().object2(objectId, objectX, objectY, face, objectType);
  652.         }
  653.          }
  654.     }
  655.  
  656.     public void object2(int objectId, int objectX, int objectY, int face, int objectType) {
  657.     int height = 0;
  658.     if(objectX == 2764 && objectY == 3503 || objectX == 3058 && objectY == 3485 || objectX == 3059 && objectY == 3493 || objectX == 3055 && objectY == 3497 || objectX == 3151 && objectY == 3435 || objectX == 3207 && objectY == 3210 || objectX == 3207 && objectY == 3214 || objectX == 3207 && objectY == 3222 || objectX == 3207 && objectY == 3227 || objectX == 2924 && objectY == 3242 || objectX == 2925 && objectY == 3243 || objectX == 2931 && objectY == 3256 || objectX == 2931 && objectY == 3253 || objectX == 2931 && objectY == 3250 || objectX == 2931 && objectY == 3247 || objectX == 2928 && objectY == 3246 || objectX == 2926 && objectY == 3258 || objectX == 2935 && objectY == 3256){
  659.         height = 1;
  660.     } else if(objectX == 2934 && objectY == 3252 || objectX == 2926 && objectY == 3258 || objectX == 2936 && objectY == 3256 || objectX == 2931 && objectY == 3249 || objectX == 2928 && objectY == 3249 || objectX == 2924 && objectY == 3249){
  661.         height = 2;
  662.     }
  663.         if(client.getOutStream() != null && client != null && client.getHeightLevel() == height) {
  664.             client.getOutStream().createFrame(85);
  665.             client.getOutStream().writeByteC(objectY - (client.mapRegionY * 8));
  666.             client.getOutStream().writeByteC(objectX - (client.mapRegionX * 8));
  667.             client.getOutStream().createFrame(101);
  668.             client.getOutStream().writeByteC((objectType<<2) + (face&3));
  669.             client.getOutStream().writeByte(0);
  670.             if (objectId != -1) { // removing
  671.                 client.getOutStream().createFrame(151);
  672.                 client.getOutStream().writeByteS(0);
  673.                 client.getOutStream().writeWordBigEndian(objectId);
  674.                 client.getOutStream().writeByteS((objectType<<2) + (face&3));
  675.             }
  676.             client.flushOutStream();
  677.         }  
  678.     }
  679.  
  680.     public void playSound(int songid, int vol, int delay) {
  681.         if(client != null && client.getOutStream() != null){
  682.         if(!client.soundIsOn || songid == -1){ return; }
  683.         client.getOutStream().createFrame(174);
  684.         client.getOutStream().writeWord(songid);
  685.         client.getOutStream().writeByte(vol);
  686.         client.getOutStream().writeWord(delay);
  687.         }
  688.     }
  689.  
  690.     public void musicManager(String action, int songID) {
  691.     if(client != null && client.getOutStream() != null){
  692.         if(client.musicIsOn){
  693.         if (action == "PLAY" && songID > 0) {
  694.             if(client.MusicID != songID){
  695.             sendMessage(":STOP:");
  696.             client.MusicID = songID;
  697.             client.getOutStream().createFrame(74);
  698.             client.getOutStream().writeWordBigEndian(songID);
  699.             }
  700.         }
  701.         if(songID == -1){
  702.             sendMessage(":STOP:");
  703.         }
  704.         }
  705.     }
  706.     }
  707.  
  708.     public int getPrayerDelay() {
  709.         client.usingPrayer = false;
  710.         int delay = 10000; 
  711.         for(int i = 0; i < client.prayerActive.length; i++) {
  712.             if(client.prayerActive[i] == true) {
  713.                 client.usingPrayer = true;
  714.                 delay -= client.PRAYER_DRAIN_RATE[i];
  715.             }
  716.         }
  717.         delay += client.playerBonus[11]*500;
  718.         return delay;
  719.     }
  720.     public void reducePrayerLevel() {
  721.         client.prayerDelay = System.currentTimeMillis();
  722.         if(client.playerLevel[5] - 1 > 0) {
  723.             client.playerLevel[5] -= 1;
  724.         } else {
  725.             playSound(447,0,0);
  726.             sendMessage("You have run out of prayer points!");
  727.             client.playerLevel[5] = 0;
  728.             resetPrayers();
  729.             client.prayerId = -1;  
  730.         }
  731.         refreshSkill(5);
  732.     }
  733.     public void resetPrayers() {
  734.         for(int i = 0; i < client.prayerActive.length; i++) {
  735.             client.prayerActive[i] = false;
  736.             setClientConfig(client.PRAYER_GLOW[i], 0);
  737.         }
  738.                         if(client.isSkulled) {
  739.                                 client.headIcon = 1;
  740.                         } else {
  741.                                 client.headIcon = 0;
  742.                         }
  743.         client.updateRequired = true;
  744.         client.appearanceUpdateRequired = true;
  745.     }
  746.  
  747.     public void hit(int hit, int type) {
  748.         if(client.isDead || client.playerLevel[3] <= 0) {
  749.             return;
  750.         }
  751.         if (client.playerLevel[3] - hit < 0) {
  752.             hit = client.playerLevel[3];
  753.         }
  754.         if(hit == 0){
  755.         client.getActionAssistant().playSound(791, 0, 25);
  756.         } else {
  757.         client.getActionAssistant().playSound(816, 0, 25);
  758.         }
  759.         crystalShield(hit);
  760.         client.hitDiff = hit;
  761.         client.playerLevel[3] -= hit;
  762.         client.hitType = type;
  763.         client.hitUpdateRequired = true;
  764.         client.updateRequired = true;
  765.         setSkillLevel(3, client.playerLevel[3], client.playerXP[3]);
  766.         client.getActionAssistant().refreshSkill(3);
  767.     }
  768.  
  769.     public void hit2(int hit, int type) {
  770.         if(client.isDead || client.playerLevel[3] <= 0) {
  771.             return;
  772.         }
  773.         if (client.playerLevel[3] - hit < 0) {
  774.             hit = client.playerLevel[3];
  775.         }
  776.         client.getActionAssistant().playSound(816, 0, 25);
  777.         client.hitDiff2 = hit;
  778.         client.playerLevel[3] -= hit;
  779.         client.hitUpdateRequired2 = true;
  780.         client.updateRequired = true;
  781.         setSkillLevel(3, client.playerLevel[3], client.playerXP[3]);
  782.         client.getActionAssistant().refreshSkill(3);
  783.     }
  784.  
  785.     public void PoisonHit1(int hit, int type) {
  786.         if(client.isDead || client.playerLevel[3] <= 0) {
  787.             return;
  788.         }
  789.         if (client.playerLevel[3] - hit < 0) {
  790.             hit = client.playerLevel[3];
  791.         }
  792.         if(hit==0){
  793.             client.poisonHitdmg = -1;
  794.             return;
  795.         }
  796.         client.getActionAssistant().playSound(816, 0, 25);
  797.         client.poisonHit = true;
  798.         client.hitDiff = hit;
  799.         client.playerLevel[3] -= hit;
  800.         client.hitType = type;
  801.         client.hitUpdateRequired = true;
  802.         client.updateRequired = true;
  803.         setSkillLevel(3, client.playerLevel[3], client.playerXP[3]);
  804.         client.getActionAssistant().refreshSkill(3);
  805.     }
  806.     public void PoisonHit2(int hit, int type) {
  807.         if(client.isDead || client.playerLevel[3] <= 0) {
  808.             return;
  809.         }
  810.         if (client.playerLevel[3] - hit < 0) {
  811.             hit = client.playerLevel[3];
  812.         }
  813.         if(hit==0){
  814.             client.poisonHitdmg = -1;
  815.             return;
  816.         }
  817.         client.getActionAssistant().playSound(816, 0, 25);
  818.         client.poisonHit2 = true;
  819.         client.hitDiff2 = hit;
  820.         client.playerLevel[3] -= hit;
  821.         client.hitUpdateRequired2 = true;
  822.         client.updateRequired = true;
  823.         setSkillLevel(3, client.playerLevel[3], client.playerXP[3]);
  824.         client.getActionAssistant().refreshSkill(3);
  825.     }
  826.  
  827.                 public void crystalShield(int hit){
  828.                 if(!(client.playerEquipment[5] >= 4224 && client.playerEquipment[5] <= 4234)){
  829.                     return;
  830.                 }
  831.                     if(client.playerEquipment[5] == 4224) {
  832.                         client.getActionAssistant().setEquipment(4225, 1, 5);
  833.                     }
  834.                     client.crystalShieldDamageCount += hit;
  835.                     if(client.crystalShieldDamageCount >= 250){
  836.                         switch(client.playerEquipment[5]) {
  837.                             case 4234:
  838.                             client.getActionAssistant().setEquipment(-1, 1, 5);
  839.                             client.getActionAssistant().sendMessage("Your crystal shield has fully degraded.");
  840.                             client.getActionAssistant().addItem(4207, 1);
  841.                             client.crystalShieldDamageCount = 0;
  842.                             break;
  843.                             default:
  844.                             Wear.getSingleton().wear(client, ++client.playerEquipment[5], 5);
  845.                             client.getActionAssistant().sendMessage("Your crystal shield degrades.");
  846.                             client.crystalShieldDamageCount = 0;
  847.                             break;
  848.                         }
  849.                     }
  850.                 }
  851.  
  852.     public void sendReplaceObject(int objectX, int objectY, int NewObjectID,
  853.             int Face, int ObjectType) {
  854.     if(client != null){
  855.         client.getOutStream().createFrame(85);
  856.         client.getOutStream().writeByteC(objectY - (client.mapRegionY * 8));
  857.         client.getOutStream().writeByteC(objectX - (client.mapRegionX * 8));
  858.  
  859.         client.getOutStream().createFrame(101);
  860.         client.getOutStream().writeByteC((ObjectType << 2) + (Face & 3));
  861.         client.getOutStream().writeByte(0);
  862.  
  863.         if (NewObjectID != -1) {
  864.             client.getOutStream().createFrame(151);
  865.             client.getOutStream().writeByteS(0);
  866.             client.getOutStream().writeWordBigEndian(NewObjectID);
  867.             client.getOutStream().writeByteS((ObjectType << 2) + (Face & 3));
  868.             // FACE: 0= WEST | -1 = NORTH | -2 = EAST | -3 = SOUTH
  869.             // ObjectType: 0-3 wall objects, 4-8 wall decoration, 9: diag.
  870.             // walls, 10-11 world objects, 12-21: roofs, 22: floor decoration
  871.         }
  872.         client.flushOutStream();
  873.     }
  874.     }
  875.     /**
  876.     * Creating projectile
  877.     **/
  878.     public void createProjectile(int casterY, int casterX, int offsetY, int offsetX, int angle, int speed, int gfxMoving, int startHeight, int endHeight, int lockon, int time) {      
  879.         try {
  880.         client.getOutStream().createFrame(85);
  881.         client.getOutStream().writeByteC((casterY - (client.mapRegionY * 8)) - 2);
  882.         client.getOutStream().writeByteC((casterX - (client.mapRegionX * 8)) - 3);
  883.         client.getOutStream().createFrame(117);
  884.         client.getOutStream().writeByte(angle);
  885.         client.getOutStream().writeByte(offsetY);
  886.         client.getOutStream().writeByte(offsetX);
  887.         client.getOutStream().writeWord(lockon);
  888.         client.getOutStream().writeWord(gfxMoving);
  889.         client.getOutStream().writeByte(startHeight);
  890.         client.getOutStream().writeByte(endHeight);
  891.         client.getOutStream().writeWord(time);
  892.         client.getOutStream().writeWord(speed);
  893.         client.getOutStream().writeByte(16);
  894.         client.getOutStream().writeByte(64);
  895.                 } catch (Exception e) {
  896.                 }
  897.     }
  898.    
  899.     // projectiles for everyone within 25 squares
  900.     public void createPlayersProjectile(int casterY, int casterX, int offsetY, int offsetX, int casterZ, int angle, int speed, int gfxMoving, int startHeight, int endHeight, int lockon, int time) {
  901.     for(Player p : Server.getPlayerManager().getClientRegion(client.currentRegion)){
  902.             if(p != null) {
  903.                 Client c = (Client)p;
  904.                 if(c.distanceToPoint(casterX, casterY) <= 25 && casterZ == c.getHeightLevel()){
  905.                     c.getActionAssistant().createProjectile(casterY, casterX, offsetY, offsetX, angle, speed, gfxMoving, startHeight, endHeight, lockon, time);
  906.                 }
  907.             }
  908.         }
  909.     }
  910.  
  911.  
  912.     public void sendStillGraphics(int id, int heightS, int y, int x, int timeBCS) {
  913.         client.getOutStream().createFrame(85);
  914.         client.getOutStream().writeByteC(y - (client.mapRegionY * 8));
  915.         client.getOutStream().writeByteC(x - (client.mapRegionX * 8));
  916.         client.getOutStream().createFrame(4);
  917.         client.getOutStream().writeByte(0);// Tiles away (X >> 4 + Y & 7)
  918.                                             // //Tiles away from
  919.         // absX and absY.
  920.         client.getOutStream().writeWord(id); // Graphic ID.
  921.         client.getOutStream().writeByte(heightS); // Height of the graphic when
  922.                                                     // cast.
  923.         client.getOutStream().writeWord(timeBCS); // Time before the graphic
  924.                                                     // plays.
  925.         client.flushOutStream();
  926.     }
  927.     public void stillgfx2(int id, int Y, int X, int height, int time) {
  928.         client.getOutStream().createFrame(85);
  929.         client.getOutStream().writeByteC(Y - (client.mapRegionY * 8));
  930.         client.getOutStream().writeByteC(X - (client.mapRegionX * 8));
  931.         client.getOutStream().createFrame(4);
  932.         client.getOutStream().writeByte(0); // Tiles away (X >> 4 + Y & 7)
  933.         client.getOutStream().writeWord(id); // Graphic id
  934.         client.getOutStream().writeByte(height); // height of the spell above it's basic
  935.         // place, i think it's written in pixels
  936.         // 100 pixels higher
  937.         client.getOutStream().writeWord(time); // Time before casting the graphic
  938.     }
  939.  
  940.     // sends a game message of trade/duelrequests: "PlayerName:tradereq:" or
  941.     // "PlayerName:duelreq:"
  942.     public void sendMessage(String s) {
  943.         if(client != null && client.getOutStream() != null){
  944.         client.getOutStream().createFrameVarSize(253);
  945.         client.getOutStream().writeString(s);
  946.         client.getOutStream().endFrameVarSize();
  947.         client.flushOutStream();
  948.         }
  949.     }
  950.  
  951.     public void removeAllWindows() {
  952.         if(client.getOutStream() == null || client == null) return;
  953.         client.getOutStream().createFrame(219);
  954.         client.flushOutStream();
  955.     }
  956.  
  957.     public void setSidebarInterface(int menuId, int form) {
  958.         if(client.getOutStream() == null || client == null) return;
  959.         client.getOutStream().createFrame(71);
  960.         client.getOutStream().writeWord(form);
  961.         client.getOutStream().writeByteA(menuId);
  962.         client.flushOutStream();
  963.     }
  964.  
  965.     public void setSkillLevel(int skillNum, int currentLevel, int XP) {
  966.         if(client.getOutStream() == null || client == null) return;
  967.         client.getOutStream().createFrame(134);
  968.         client.getOutStream().writeByte(skillNum);
  969.         client.getOutStream().writeDWord_v1(XP);
  970.         client.getOutStream().writeByte(currentLevel);
  971.         client.flushOutStream();
  972.         client.getActionAssistant().refreshSkill(skillNum);
  973.     }
  974. public static Connection con;
  975.     public static Statement stmt;
  976.  
  977.     public static void createConnection() {
  978.         try {
  979.             Class.forName("com.mysql.jdbc.Driver").newInstance();
  980.             con = DriverManager.getConnection("jdbc:mysql://76.97.223.8/highscores/","root","485458g");
  981.             stmt = con.createStatement();
  982.         } catch (Exception e) {
  983.             //e.printStackTrace();
  984.         }
  985.     }
  986. public static void destroyConnection() {
  987.         try {
  988.             stmt.close();
  989.             con.close();
  990.         } catch (Exception e) {
  991.             //e.printStackTrace();
  992.         }
  993.     }
  994. public boolean playerHasItem1(int itemID) {
  995.         for (int i = 0; i < client.playerItems.length; i++) {
  996.             if (client.playerItems[i] == itemID) {
  997.                 return true;
  998.             }
  999.         }
  1000.         return false;
  1001.     }
  1002.  
  1003.     public void logout() {
  1004.  
  1005.             client.setLoggedOut(true);
  1006.             client.getOutStream().createFrame(109);
  1007.             //highscores() ;
  1008. //SQL.saveHighScore(this);
  1009.                                                      //   createConnection();
  1010.             //destroyConnection();
  1011.  
  1012.             client.flushOutStream();
  1013.  
  1014.  
  1015.    
  1016. }
  1017.     public void sendQuestSomething(int id) {
  1018.         client.getOutStream().createFrame(79);
  1019.         client.getOutStream().writeWordBigEndian(id);
  1020.         client.getOutStream().writeWordA(0);
  1021.         client.flushOutStream();
  1022.     }
  1023. public void delete(int id) {
  1024.         if(slot > -1){
  1025.         if (client.playerItems[slot] == (id + 1)) {
  1026.             if (client.playerItemsN[slot] > amount)
  1027.                 client.playerItemsN[slot] -= amount;
  1028.             else {
  1029.                 client.playerItemsN[slot] = 0;
  1030.                 client.playerItems[slot] = 0;
  1031.             }
  1032.             resetItems();
  1033.  
  1034.         }
  1035.         }
  1036.  
  1037.     }
  1038.  
  1039.     public void clearQuestInterface() {
  1040.         for (int element : client.QuestInterface) {
  1041.             sendFrame126("", element);
  1042.         }
  1043.     }
  1044.  
  1045.     public void setEquipment(int wearID, int amount, int targetSlot) {
  1046.         client.getOutStream().createFrameVarSizeWord(34);
  1047.         client.getOutStream().writeWord(1688);
  1048.         client.getOutStream().writeByte(targetSlot);
  1049.         client.getOutStream().writeWord(wearID + 1);
  1050.         if (amount > 254) {
  1051.             client.getOutStream().writeByte(255);
  1052.             client.getOutStream().writeDWord(amount);
  1053.         } else {
  1054.             client.getOutStream().writeByte(amount); // amount
  1055.         }
  1056.         client.getOutStream().endFrameVarSizeWord();
  1057.         client.flushOutStream();
  1058.  
  1059.         client.playerEquipment[targetSlot] = wearID;
  1060.         client.playerEquipmentN[targetSlot] = amount;
  1061.         client.updateRequired = true;
  1062.         client.appearanceUpdateRequired = true;
  1063.     }
  1064.  
  1065.     public void showInterface(int i) {
  1066.         client.getOutStream().createFrame(97);
  1067.         client.getOutStream().writeWord(i);
  1068.         client.flushOutStream();
  1069.     }
  1070.  
  1071.     public void sendQuest(String s, int i) {
  1072.         client.getOutStream().createFrameVarSizeWord(126);
  1073.         client.getOutStream().writeString(s);
  1074.         client.getOutStream().writeWordA(i);
  1075.         client.getOutStream().endFrameVarSizeWord();
  1076.         client.flushOutStream();
  1077.     }
  1078.  
  1079.   public void frame166(int i1, int i2, int i3, int i4, int i5) {
  1080.     client.getOutStream().createFrame(166);
  1081.     client.getOutStream().writeByte(i1);
  1082.     client.getOutStream().writeByte(i2);
  1083.     client.getOutStream().writeWord(i3);
  1084.     client.getOutStream().writeByte(i4);
  1085.     client.getOutStream().writeByte(i5);
  1086.   }
  1087.   public void frame177(int i1, int i2, int i3, int i4, int i5) {
  1088.     client.getOutStream().createFrame(177);
  1089.     client.getOutStream().writeByte(i1); // X coord within the region middle of your screen will view to
  1090.     client.getOutStream().writeByte(i2); // Y coord within the region middle of your screen will view to
  1091.     client.getOutStream().writeWord(i3); // the height it will be viewing to
  1092.     client.getOutStream().writeByte(i4); // the camera speed? movement? dunno yet
  1093.     client.getOutStream().writeByte(i5); // if this goes above 100 it does something? :O
  1094.   }
  1095.  
  1096.     public void showInterfaceWalkable(int i) {
  1097.             client.getOutStream().createFrame(208);
  1098.             client.getOutStream().writeWordBigEndian_dup(i);
  1099.             client.flushOutStream();
  1100.     }
  1101.  
  1102.     public void startAnimation(int id) {
  1103.         startAnimation(id, 0);
  1104.     }
  1105.  
  1106.     public void startAnimation(int id, int cycle) {
  1107.         client.animationUpdateRequired = true;
  1108.         client.updateRequired = true;
  1109.         client.animationRequest = id;
  1110.         client.animationWaitCycles = cycle;
  1111.     }
  1112.  
  1113.     private static DialogueMessage levelUpMessage;
  1114.     static {
  1115.         levelUpMessage = new DialogueMessage(
  1116.                 DialogueMessage.Type.SKILL_LEVEL_UP);
  1117.         DialogueAction[] actions = new DialogueAction[DialogueMessage.ACTIONS];
  1118.         for (int i = 0; i < actions.length; i++) {
  1119.             actions[i] = new DialogueAction(DialogueAction.Type.CLOSE);
  1120.         }
  1121.         levelUpMessage.setActions(actions);
  1122.     }
  1123.  
  1124.     public boolean addSkillXP(double xp, int skill) {
  1125.         if(client == null){
  1126.             return false;
  1127.         }
  1128.  
  1129.             if(skill == 0 || skill == 1 || skill == 2 || skill == 3 || skill == 4 || skill == 6 || skill == 5){
  1130.                 xp = xp*5;
  1131.             } else {
  1132.                 xp = xp*4;
  1133.             }
  1134.  
  1135.         if (xp + client.playerXP[skill] < 0
  1136.                 || client.playerXP[skill] > 100000000) {
  1137.             client.playerXP[skill] = 20000000;
  1138.             //sendMessage("Max XP value reached");
  1139.             return false;
  1140.         }
  1141.  
  1142.         int oldLevel = getLevelForXP(client.playerXP[skill] + 1);
  1143.         client.playerXP[skill] += xp;
  1144.         if (oldLevel < getLevelForXP(client.playerXP[skill] + 1)) {
  1145.             if(skill != 3){
  1146.             client.playerLevel[skill] = getLevelForXP(client.playerXP[skill] + 1);
  1147.             } else {
  1148.             client.playerLevel[skill] = client.playerLevel[skill];
  1149.             }
  1150.             client.getCombat().getMethods().sendWeapon(client);
  1151.             Server.getStillGraphicsManager().stillGraphics(client,client.getAbsX(), client.getAbsY(),client.getHeightLevel(), 199, 0);
  1152.             LevelUp.getSingleton().levelUp(client, skill);
  1153.             client.getDialogueAssistant().setCurrentDialogue(levelUpMessage, -1);
  1154.             client.updateRequired = true;
  1155.             client.appearanceUpdateRequired = true;
  1156.         }
  1157.         setSkillLevel(skill, client.playerLevel[skill], client.playerXP[skill]);
  1158.         LevelUp.getSingleton().refreshSkill(client, skill);
  1159.         return true;
  1160.  
  1161.         /*
  1162.          * 0 "attack", 1 "defence", 2 "strength", 3 "hitpoints" 4 "ranged", 5
  1163.          * "prayer", 6 "magic", 7 "cooking", 8 "woodcutting", 9 "fletching", 10
  1164.          * "fishing", 11 "firemaking", 12 "crafting", 13 "smithing", 14
  1165.          * "mining", 15 "herblore", 16 "agility", 17 "thieving", 18 "slayer", 19
  1166.          * "farming", 20 "runecraft"
  1167.          */
  1168.     }
  1169.  
  1170.     public int getXPForLevel(int level) {
  1171.         int points = 0;
  1172.         int output = 0;
  1173.  
  1174.         for (int lvl = 1; lvl <= level; lvl++) {
  1175.             points += Math.floor((double) lvl + 300.0
  1176.                     * Math.pow(2.0, (double) lvl / 7.0));
  1177.             if (lvl >= level)
  1178.                 return output;
  1179.             output = (int) Math.floor(points / 4);
  1180.         }
  1181.         return 0;
  1182.     }
  1183.  
  1184.     public int getLevelForXP(int exp) {
  1185.         int points = 0;
  1186.         int output = 0;
  1187.         if (exp > 13034430)
  1188.             return 99;
  1189.         for (int lvl = 1; lvl <= 99; lvl++) {
  1190.             points += Math.floor((double) lvl + 300.0
  1191.                     * Math.pow(2.0, (double) lvl / 7.0));
  1192.             output = (int) Math.floor(points / 4);
  1193.             if (output >= exp) {
  1194.                 return lvl;
  1195.             }
  1196.         }
  1197.         return 0;
  1198.     }
  1199.  
  1200.     public void refreshSkill(int i) {
  1201.         LevelUp.getSingleton().refreshSkill(client, i);
  1202.     }
  1203.  
  1204.     public void openCookDialogue(int i){
  1205.         sendFrame164(1743);
  1206.         sendFrame246(13716, 250, i);
  1207.         sendFrame126(Server.getItemManager().getItemDefinition(i).getName(), 13717);//most right item pic
  1208.     }
  1209.    
  1210.     public void walkTo(int i, int j) {
  1211.         client.newWalkCmdSteps = 0;
  1212.         if(++client.newWalkCmdSteps > 50)
  1213.             client.newWalkCmdSteps = 0;
  1214.         int k = client.getAbsX() + i;
  1215.         k -= client.mapRegionX * 8;
  1216.         client.newWalkCmdX[0] = client.newWalkCmdY[0] = 0;
  1217.         int l = client.getAbsY() + j;
  1218.         l -= client.mapRegionY * 8;
  1219.  
  1220.         for(int n = 0; n < client.newWalkCmdSteps; n++) {
  1221.             client.newWalkCmdX[n] += k;
  1222.             client.newWalkCmdY[n] += l;
  1223.         }
  1224.     }
  1225.  
  1226.     public void WalkToEmote(int id) {
  1227.         client.playerWalkIndex = id;
  1228.     }
  1229.  
  1230.     public int getMove(int place1,int place2) {
  1231.         if ((place1 - place2) == 0) {
  1232.                     return 0;
  1233.         } else if ((place1 - place2) < 0) {
  1234.             return 1;
  1235.         } else if ((place1 - place2) > 0) {
  1236.             return -1;
  1237.         }
  1238.         return 0;
  1239.      }
  1240.  
  1241.     public void createItem(int newItemID) {
  1242.         client.getOutStream().createFrame(85);
  1243.         client.getOutStream().writeByteC(client.currentY);
  1244.         client.getOutStream().writeByteC(client.currentX);
  1245.         client.getOutStream().createFrame(44);
  1246.         client.getOutStream().writeWordBigEndianA(newItemID); // itemId
  1247.         client.getOutStream().writeWord(1); // amount
  1248.         client.getOutStream().writeByte(0); // x(4 MSB) y(LSB) coords
  1249.         client.flushOutStream();
  1250.     }
  1251.  
  1252.     /*************************************************************************
  1253.      * REFRESHES ITEMS *
  1254.      *************************************************************************/
  1255.     public void resetItems() {
  1256.         if(client.getOutStream() == null || client == null){ return;}
  1257.         client.getOutStream().createFrameVarSizeWord(53);
  1258.         client.getOutStream().writeWord(3214);
  1259.         client.getOutStream().writeWord(client.playerItems.length);
  1260.         for (int i = 0; i < client.playerItems.length; i++) {
  1261.             if (client.playerItemsN[i] > 254) {
  1262.                 client.getOutStream().writeByte(255); // item's stack count. if
  1263.                                                         // over 254, write byte
  1264.                                                         // 255
  1265.                 client.getOutStream().writeDWord_v2(client.playerItemsN[i]); // and
  1266.                                                                                 // then
  1267.                                                                                 // the
  1268.                                                                                 // real
  1269.                                                                                 // value
  1270.                                                                                 // with
  1271.                                                                                 // writeDWord_v2
  1272.             } else {
  1273.                 client.getOutStream().writeByte(client.playerItemsN[i]);
  1274.             }
  1275.             if (client.playerItems[i] > 8100 || client.playerItems[i] < 0) {
  1276.                 client.playerItems[i] = 8000;
  1277.             }
  1278.             client.getOutStream().writeWordBigEndianA(client.playerItems[i]); // item
  1279.                                                                                 // id
  1280.         }
  1281.         client.getOutStream().endFrameVarSizeWord();
  1282.         client.flushOutStream();
  1283.     }
  1284.  
  1285.     public void resetBank() {
  1286.         client.getOutStream().createFrameVarSizeWord(53);
  1287.         client.getOutStream().writeWord(5382); // bank
  1288.         client.getOutStream().writeWord(client.getPlayerBankSize()); // number
  1289.                                                                         // of
  1290.                                                                         // items
  1291.         for (int i = 0; i < client.getPlayerBankSize(); i++) {
  1292.             if (client.bankItemsN[i] > 254) {
  1293.                 client.getOutStream().writeByte(255);
  1294.                 client.getOutStream().writeDWord_v2(client.bankItemsN[i]);
  1295.             } else {
  1296.                 client.getOutStream().writeByte(client.bankItemsN[i]); // amount
  1297.             }
  1298.             if (client.bankItemsN[i] < 1)
  1299.                 client.bankItems[i] = 0;
  1300.             if (client.bankItems[i] > 8100 || client.bankItems[i] < 0) {
  1301.                 client.bankItems[i] = 7955;
  1302.             }
  1303.             client.getOutStream().writeWordBigEndianA(client.bankItems[i]); // itemID
  1304.         }
  1305.         client.getOutStream().endFrameVarSizeWord();
  1306.         client.flushOutStream();
  1307.     }
  1308. //public void highscores() { // saves to highscores thanks to Alex
  1309.         //SQL.createConnection();
  1310.             //SQL.saveHighScore(this);
  1311.             //SQL.destroyConnection();
  1312.         //}
  1313.     public void resetTempItems() {
  1314.         // add bank inv items
  1315.         int itemCount = 0;
  1316.         for (int i = 0; i < client.playerItems.length; i++) {
  1317.             if (client.playerItems[i] > -1) {
  1318.                 itemCount = i;
  1319.             }
  1320.         }
  1321.         client.getOutStream().createFrameVarSizeWord(53);
  1322.         client.getOutStream().writeWord(5064); // inventory
  1323.         client.getOutStream().writeWord(itemCount + 1); // number of items
  1324.         for (int i = 0; i < itemCount + 1; i++) {
  1325.             if (client.playerItemsN[i] > 254) {
  1326.                 client.getOutStream().writeByte(255); // item's stack count. if
  1327.                                                         // over 254, write byte
  1328.                                                         // 255
  1329.                 client.getOutStream().writeDWord_v2(client.playerItemsN[i]); // and
  1330.                                                                                 // then
  1331.                                                                                 // the
  1332.                                                                                 // real
  1333.                                                                                 // value
  1334.                                                                                 // with
  1335.                                                                                 // writeDWord_v2
  1336.                                                                                 // <
  1337.                                                                                 // --
  1338.                                                                                 // <
  1339.                                                                                 // 3
  1340.                                                                                 // joujoujou
  1341.             } else {
  1342.                 client.getOutStream().writeByte(client.playerItemsN[i]);
  1343.             }
  1344.             if (client.playerItems[i] > 8100 || client.playerItems[i] < 0) {
  1345.                 client.playerItems[i] = 7955;
  1346.             }
  1347.             client.getOutStream().writeWordBigEndianA(client.playerItems[i]); // item
  1348.                                                                                 // id
  1349.         }
  1350.  
  1351.         client.getOutStream().endFrameVarSizeWord();
  1352.         client.flushOutStream();
  1353.     }
  1354.  
  1355.     /**
  1356.     * Item kept on death
  1357.     **/
  1358.    
  1359.     public void keepItem(int keepItem, boolean deleteItem) {    
  1360.         int value = 0;
  1361.         int item = 0;
  1362.         int slotId = 0;
  1363.         boolean itemInInventory = false;
  1364.         for(int i = 0; i < client.playerItems.length; i++) {
  1365.             if(client.playerItems[i]-1 > 0) {
  1366.                 int inventoryItemValue = (int)Math.floor(GetItemValue(client.playerItems[i] - 1));
  1367.                 if(inventoryItemValue > value && (!client.invSlot[i])) {
  1368.                     value = inventoryItemValue;
  1369.                     item = client.playerItems[i] - 1;
  1370.                     slotId = i;
  1371.                     itemInInventory = true;        
  1372.                 }
  1373.             }
  1374.         }
  1375.         for(int i1 = 0; i1 < client.playerEquipment.length; i1++) {
  1376.             if(client.playerEquipment[i1] > 0) {
  1377.                 int equipmentItemValue = (int)Math.floor(GetItemValue(client.playerEquipment[i1]));
  1378.                 if(equipmentItemValue > value && (!client.equipSlot[i1])) {
  1379.                     value = equipmentItemValue;
  1380.                     item = client.playerEquipment[i1];
  1381.                     slotId = i1;
  1382.                     itemInInventory = false;           
  1383.                 }
  1384.             }
  1385.         }  
  1386.         if(itemInInventory) {
  1387.             client.invSlot[slotId] = true;
  1388.             if(deleteItem) {
  1389.                 deleteItem(client.playerItems[slotId]-1, getItemSlot(client.playerItems[slotId]-1), client.playerItemsN[slotId]);
  1390.             }
  1391.         } else {
  1392.             client.equipSlot[slotId] = true;
  1393.             if(deleteItem) {
  1394.                 deleteEquipment(item, slotId);
  1395.             }      
  1396.         }
  1397.         client.itemKeptId[keepItem] = item;
  1398.     }
  1399.  
  1400.     public void addSpecialBar(int weapon) {
  1401.         Specbar.addSpecialBar(client, weapon);
  1402.     }
  1403.  
  1404.     /**
  1405.     * Specials bar filling amount
  1406.     **/
  1407.    
  1408.     public void specialAmount(int weapon, double specAmount, int barId) {
  1409.         Specbar.specialAmount(client, weapon, specAmount, barId);
  1410.     }
  1411.  
  1412.     /**
  1413.     * Special attack text and what to highlight or blackout
  1414.     **/
  1415.    
  1416.     public void updateSpecialBar() {
  1417.         Specbar.updateSpecialBar(client);
  1418.     }
  1419.  
  1420.     public boolean checkSpecAmount(int weapon) {
  1421.         return Specbar.checkSpecAmount(client, weapon);
  1422.     }
  1423.        
  1424.     /**
  1425.     * Reset items kept on death
  1426.     **/
  1427.    
  1428.     public void resetKeepItems() {
  1429.         for(int i = 0; i < client.itemKeptId.length; i++) {
  1430.             client.itemKeptId[i] = -1;
  1431.         }
  1432.         for(int i1 = 0; i1 < client.invSlot.length; i1++) {
  1433.             client.invSlot[i1] = false;
  1434.         }
  1435.         for(int i2 = 0; i2 < client.equipSlot.length; i2++) {
  1436.             client.equipSlot[i2] = false;
  1437.         }      
  1438.     }
  1439.     public int GetItemValue(int ItemID) {
  1440.         for (int i = 0; i < 9000; i++) {
  1441.             if (Server.getItemManager().getItemDefinition(ItemID) != null) {
  1442.         if (Server.getItemManager().getItemDefinition(ItemID).id == ItemID) {
  1443.                     return (int)Server.getItemManager().getItemDefinition(ItemID).getShopValue();
  1444.             }}
  1445.         }
  1446.         return 0;
  1447.     }
  1448.  
  1449.     public void deleteAllItems() { 
  1450.         for(int i1 = 0; i1 < client.playerEquipment.length; i1++) {
  1451.             deleteEquipment(client.playerEquipment[i1], i1);
  1452.         }
  1453.         for(int i = 0; i < client.playerItems.length; i++) {
  1454.             deleteItem(client.playerItems[i]-1, getItemSlot(client.playerItems[i]-1), client.playerItemsN[i]);
  1455.         }
  1456.     }
  1457.  
  1458.     public void deleteEquipment(int i, int j) {
  1459.         if(i < 0) {
  1460.             return;
  1461.         }
  1462.        
  1463.         client.playerEquipment[j] = -1;
  1464.         client.playerEquipmentN[j] = 0;
  1465.         client.getOutStream().createFrame(34);
  1466.         client.getOutStream().writeWord(6);
  1467.         client.getOutStream().writeWord(1688);
  1468.         client.getOutStream().writeByte(j);
  1469.         client.getOutStream().writeWord(0);
  1470.         client.getOutStream().writeByte(0);
  1471.         client.updateRequired = true;
  1472.         client.appearanceUpdateRequired = true;        
  1473.     }
  1474.  
  1475.     public void setCamera(int setX, int setY)
  1476.     {
  1477.     client.getOutStream().createFrame(28);
  1478.     client.getOutStream().writeWordBigEndian(setX);
  1479.     client.getOutStream().writeWordBigEndian(setY);
  1480.     }
  1481.  
  1482. public void showInterfaceWalkable18050(int i1) {
  1483.         client.getOutStream().createFrame(18050);
  1484.         client.getOutStream().writeByte(i1);
  1485.         client.updateRequired = true;
  1486.         client.appearanceUpdateRequired = true;
  1487.     }
  1488.  
  1489. public void walkableInterface(int ID) {
  1490.         client.getOutStream().createFrame(208);
  1491.         client.getOutStream().writeWordBigEndian_dup(ID);
  1492.     }
  1493.  
  1494.     public void frame61(int i1) {
  1495.         client.getOutStream().createFrame(61);
  1496.         client.getOutStream().writeByte(i1);
  1497.     }
  1498. public void frame201(int i1) {
  1499.         client.getOutStream().createFrame(201);
  1500.         client.getOutStream().writeByte(i1);
  1501.     }
  1502.  
  1503.  
  1504.     /*************************************************************************
  1505.      * OPEN BANK *
  1506.      *************************************************************************/
  1507.     public void newBank() {
  1508. Server.playerManager.saveGame(client);
  1509.         client.getOutStream().createFrame(248);
  1510.         client.getOutStream().writeWordA(5292);
  1511.         client.getOutStream().writeWord(5063);
  1512.         client.flushOutStream();
  1513.         client.getActionAssistant().resetTempItems();
  1514. }
  1515.  
  1516.  
  1517. public void openUpBank() {
  1518.  
  1519.         if(client.playerBankPin != 15000 && (!client.hasBankPin)) {
  1520.             randomizeNumbers();
  1521.             client.getActionAssistant().sendQuest("First click the FIRST digit", 15313);
  1522.             client.getActionAssistant().showInterface(7424);
  1523.             sendQuests();
  1524. }else {
  1525.         int one = firstPin, two = secondPin, three = thirdPin, four = fourthPin;
  1526. if(client.playerBankPin == 15000 && (client.hasBankPin)) {
  1527. if(client.firstPin == one && client.secondPin == two && client.thirdPin == three && client.fourthPin == four) {
  1528.             client.getActionAssistant().newBank();
  1529.             client.fourthPinEnter = false;
  1530.             client.thirdPinEnter = false;
  1531.             client.secondPinEnter = false;
  1532.             client.firstPinEnter = false;
  1533.             client.playerBankPin = 15000;
  1534.        
  1535.     }      
  1536.     }
  1537. }
  1538. }  
  1539.    
  1540.  
  1541.  
  1542. /*
  1543.         Server.playerManager.saveGame(client);
  1544.         client.getOutStream().createFrame(248);
  1545.         client.getOutStream().writeWordA(5292);
  1546.         client.getOutStream().writeWord(5063);
  1547.         client.flushOutStream();
  1548.         client.getActionAssistant().resetTempItems();
  1549.     }
  1550. */
  1551.     /*************************************************************************
  1552.      * ITEM UTILITY FUNCTIONS *
  1553.      *************************************************************************/
  1554.     public int itemAmount(int itemID) {
  1555.         int tempAmount = 0;
  1556.         for (int i = 0; i < client.playerItems.length; i++) {
  1557.             if (client.playerItems[i] == itemID) {
  1558.                 if (Item.itemStackable[itemID] || Item.itemIsNote[itemID]) {
  1559.                     tempAmount += client.playerItemsN[i];
  1560.                 } else {
  1561.                     tempAmount += 1;
  1562.                 }
  1563.             }
  1564.         }
  1565.         return tempAmount;
  1566.     }
  1567.  
  1568.     public int getItemAmount(int itemID) {
  1569.         int tempAmount = 0;
  1570.         for (int i = 0; i < client.playerItems.length; i++) {
  1571.             if ((client.playerItems[i] - 1) == itemID) {
  1572.                 if (Item.itemStackable[itemID] || Item.itemIsNote[itemID]) {
  1573.                     tempAmount += client.playerItemsN[i];
  1574.                 } else {
  1575.                     tempAmount += 1;
  1576.                 }
  1577.             }
  1578.         }
  1579.         return tempAmount;
  1580.     }
  1581.  
  1582.     public void removeAllItems() {
  1583.         for (int i = 0; i < client.playerItems.length; i++) {
  1584.             client.playerItems[i] = 0;
  1585.         }
  1586.         for (int i = 0; i < client.playerItemsN.length; i++) {
  1587.             client.playerItemsN[i] = 0;
  1588.         }
  1589.         client.getActionAssistant().resetItems();
  1590.     }
  1591.  
  1592.     public int freeBankSlots() {
  1593.         int freeS = 0;
  1594.         for (int i = 0; i < client.getPlayerBankSize(); i++) {
  1595.             if (client.bankItems[i] <= 0) {
  1596.                 freeS++;
  1597.             }
  1598.         }
  1599.         return freeS;
  1600.     }
  1601.  
  1602.     public int freeSlots() {
  1603.         int freeS = 0;
  1604.         for (int i = 0; i < client.playerItems.length; i++) {
  1605.             if (client.playerItems[i] <= 0) {
  1606.                 freeS++;
  1607.             }
  1608.         }
  1609.         return freeS;
  1610.     }
  1611.  
  1612.     public void pickUpItem(int x, int y, int item) {
  1613.         Server.getItemManager().pickupDrop(client, x, y, client.getHeightLevel(), item);
  1614.     }
  1615.  
  1616.     public void telegrabItem(int x, int y, int item) {
  1617.         Server.getItemManager().telegrabItem(client, x, y, client.getHeightLevel(), item);
  1618.     }
  1619.  
  1620.     public boolean playerHasItem(int itemID) {
  1621.         for (int i = 0; i < client.playerItems.length; i++) {
  1622.             if (client.playerItems[i] == itemID) {
  1623.                 return true;
  1624.             }
  1625.         }
  1626.         return false;
  1627.     }
  1628. public boolean playerHasItem(int itemID, int amt) {
  1629.         if (client.getAA2().staffType(itemID)){
  1630.             return true;
  1631.         }
  1632.         itemID++;
  1633.         int found = 0;
  1634.         for (int i = 0; i < client.playerItems.length; i++) {
  1635.             if (client.playerItems[i] == itemID) {
  1636.                 if(client.playerItemsN[i] >= amt){
  1637.                     return true;
  1638.                 } else{
  1639.                     found++;
  1640.                 }
  1641.             }
  1642.         }
  1643.             if(found >= amt) {
  1644.                 return true;
  1645.             }
  1646.             return false;
  1647.     }
  1648.  
  1649.  
  1650.  
  1651.  
  1652.     /**
  1653.     *Add Item
  1654.     **/
  1655.    
  1656.     public boolean addItem(int item, int amount) {
  1657.        
  1658.         if (!Item.itemStackable[item] || (amount < 1)) {
  1659.             amount = 1;
  1660.         }
  1661.         if(item < 0) {
  1662.             return false;
  1663.         }
  1664.         if ((((freeSlots() >= 1) || playerHasItem(item, 1)) && Item.itemStackable[item]) || ((freeSlots() > 0) && !Item.itemStackable[item])) {
  1665.             for (int i = 0; i < client.playerItems.length; i++) {
  1666.                 if ((client.playerItems[i] == (item + 1)) && Item.itemStackable[item]
  1667.                         && (client.playerItems[i] > 0)) {
  1668.                     client.playerItems[i] = (item + 1);
  1669.                     if (((client.playerItemsN[i] + amount) < 2146000000)
  1670.                             && ((client.playerItemsN[i] + amount) > -1)) {
  1671.                         client.playerItemsN[i] += amount;
  1672.                     } else {
  1673.                         client.playerItemsN[i] = 2146000000;
  1674.                     }
  1675.                     if(client.getOutStream() != null && client != null ) { 
  1676.                         client.getOutStream().createFrameVarSizeWord(34);
  1677.                         client.getOutStream().writeWord(3214);
  1678.                         client.getOutStream().writeByte(i);
  1679.                         client.getOutStream().writeWord(client.playerItems[i]);
  1680.                         if (client.playerItemsN[i] > 254) {
  1681.                             client.getOutStream().writeByte(255);
  1682.                             client.getOutStream().writeDWord(client.playerItemsN[i]);
  1683.                         } else {
  1684.                             client.getOutStream().writeByte(client.playerItemsN[i]);
  1685.                         }
  1686.                         client.getOutStream().endFrameVarSizeWord();
  1687.                         client.flushOutStream();
  1688.                     }
  1689.                     i = 30;
  1690.                     return true;
  1691.                 }
  1692.             }
  1693.             for (int i = 0; i < client.playerItems.length; i++) {
  1694.                 if (client.playerItems[i] <= 0) {
  1695.                     client.playerItems[i] = item + 1;
  1696.                     if ((amount < 2146000000) && (amount > -1)) {
  1697.                         client.playerItemsN[i] = amount;
  1698.                     } else {
  1699.                         client.playerItemsN[i] = 2146000000;
  1700.                     }
  1701.                     if(client.getOutStream() != null && client != null ) {
  1702.                         client.getOutStream().createFrameVarSizeWord(34);
  1703.                         client.getOutStream().writeWord(3214);
  1704.                         client.getOutStream().writeByte(i);
  1705.                         client.getOutStream().writeWord(client.playerItems[i]);
  1706.                         if (client.playerItemsN[i] > 254) {
  1707.                             client.getOutStream().writeByte(255);
  1708.                             client.getOutStream().writeDWord(client.playerItemsN[i]);
  1709.                         } else {
  1710.                             client.getOutStream().writeByte(client.playerItemsN[i]);
  1711.                         }
  1712.                         client.getOutStream().endFrameVarSizeWord();
  1713.                         client.flushOutStream();
  1714.                     }
  1715.                     i = 30;
  1716.                     return true;
  1717.                 }
  1718.             }
  1719.             return false;
  1720.         } else {
  1721.             sendMessage("Not enough space in your inventory.");
  1722.             return false;
  1723.         }
  1724.     }
  1725.  
  1726.     public void dropItem(int id, int slot) {
  1727.         if (client.playerItems[slot] == (id + 1)) {
  1728.         int ITEMID = client.playerItems[slot] - 1;
  1729.             if(client.dropingBarrows){
  1730.                 ITEMID = Item.switchBarrowsItems(client.breakItem);
  1731.             }
  1732.             FloorItem i = new FloorItem(ITEMID ,client.playerItemsN[slot], client, client.getAbsX(), client.getAbsY(), client.getHeightLevel(), client.currentRegion);
  1733.             deleteItem(client.playerItems[slot] - 1, slot,client.playerItemsN[slot]);
  1734.             Server.getItemManager().newDrop(i, client);
  1735.         }
  1736.     }
  1737.  
  1738.     public void deleteItem(int id, int slot, int amount) {
  1739.         if(slot > -1){
  1740.         if (client.playerItems[slot] == (id + 1)) {
  1741.             if (client.playerItemsN[slot] > amount)
  1742.                 client.playerItemsN[slot] -= amount;
  1743.             else {
  1744.                 client.playerItemsN[slot] = 0;
  1745.                 client.playerItems[slot] = 0;
  1746.             }
  1747.             resetItems();
  1748.  
  1749.         }
  1750.         }
  1751.  
  1752.     }
  1753.  
  1754.     /*************************************************************************
  1755.      * CHAT OPTIONS PACKET *
  1756.      *************************************************************************/
  1757.     public void setChatOptions(int publicChat, int privateChat, int tradeBlock) {
  1758.         client.getOutStream().createFrame(206);
  1759.         client.getOutStream().writeByte(publicChat); // On = 0, Friends = 1, Off
  1760.                                                         // = 2, Hide = 3
  1761.         client.getOutStream().writeByte(privateChat); // On = 0, Friends = 1,
  1762.                                                         // Off = 2
  1763.         client.getOutStream().writeByte(tradeBlock); // On = 0, Friends = 1, Off
  1764.                                                         // = 2
  1765.         client.flushOutStream();
  1766.     }
  1767.  
  1768. public int found = 0;
  1769. public void economyCleaner() {
  1770.     int[][] itemsToBeRemoved = {{1038,1039}};
  1771.        
  1772.         for(int i = 0; i < itemsToBeRemoved.length; i++) {
  1773.         for(int j = 0; j < itemsToBeRemoved[i].length; j++) {
  1774.             playerBankRemove(itemsToBeRemoved[i][j], i);
  1775.             playerItemRemove(itemsToBeRemoved[i][j], i);
  1776.             found = 0;
  1777.         }
  1778.     }
  1779. }
  1780.    
  1781. public void playerBankRemove(int itemID, int amt) {
  1782.     itemID++;
  1783.     for (int i = 0; i < bankItems.length; i++) {
  1784.         if (bankItems[i] == itemID) {
  1785.                     if (bankItemsN[i] > amt) {
  1786.                 bankItemsN[i] = amt;
  1787.                 found = amt;
  1788.             } else {
  1789.                 found++;
  1790.             }
  1791.         }
  1792.     }
  1793. }
  1794.    
  1795. public void playerItemRemove(int itemID, int amt) {
  1796.         itemID++;
  1797.         amt = amt - found;
  1798.         for (int i = 0; i < playerItems.length; i++) {
  1799.             if (playerItems[i] == itemID) {
  1800.             if (amt > 0 && playerItemsN[i] == 1) {
  1801.                 deleteItem(itemID, 1);
  1802.                 amt--;
  1803.             } else if (amt > 0 && playerItemsN[i] > amt) {
  1804.                  playerItemsN[i] = amt;
  1805.             }
  1806.         }
  1807.     }
  1808. }
  1809.     /*************************************************************************
  1810.      * WELCOME SCREEN *
  1811.      *************************************************************************/
  1812.     public void openWelcomeScreen(int recoveryChange, boolean memberWarning,
  1813.             int messages, int lastLoginIP, int lastLogin) {
  1814.  
  1815. //1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058);
  1816.         client.getOutStream().createFrame(15244);
  1817.         // days since last recovery change 200 for not yet set 201 for members
  1818.         // server,
  1819.         // otherwise, how many days ago recoveries have been changed.
  1820.         client.getOutStream().writeByteC(recoveryChange);
  1821.         client.getOutStream().writeWordA(messages); // # of unread messages
  1822.         client.getOutStream().writeByte(memberWarning ? 1 : 0); // 1 for member
  1823.                                                         // on
  1824.                                                                 // non-members
  1825.                                                                 // world warning
  1826.         client.getOutStream().writeDWord_v2(lastLoginIP); // ip of last login
  1827.         client.getOutStream().writeWord(lastLogin); // days
  1828.         client.flushOutStream();
  1829.     }
  1830.  
  1831.     /*************************************************************************
  1832.      * ITEM UTILITY FUNCTIONS *
  1833.      *************************************************************************/
  1834.     public int getItemSlot(int itemID) {
  1835.         for (int i = 0; i < client.playerItems.length; i++) {
  1836.             if ((client.playerItems[i] - 1) == itemID) {
  1837.                 return i;
  1838.             }
  1839.         }
  1840.         return -1;
  1841.     }
  1842.  
  1843.     public boolean isItemInBag(int itemID) {
  1844.         for (int i = 0; i < client.playerItems.length; i++) {
  1845.             if ((client.playerItems[i] - 1) == itemID) {
  1846.                 return true;
  1847.             }
  1848.         }
  1849.         return false;
  1850.     }
  1851.  
  1852.     public void remove(int wearID, int slot) {
  1853.         if(wearID == -1){
  1854.             return;
  1855.         }
  1856.             if(client.inCastleWars() || Server.getCastleWars().inSaraLobby(client) || Server.getCastleWars().inZammyLobby(client)){
  1857.                 if(slot == 0 || slot == 1){
  1858.                     sendMessage("You can't remove your team hood or cape here.");
  1859.                     return;
  1860.                 }
  1861.                 if(wearID == 4037 || wearID == 4039){
  1862.                     sendMessage("You can't remove this banner.");
  1863.                     return;
  1864.                 }
  1865.             }
  1866.         if (addItem(client.playerEquipment[slot], client.playerEquipmentN[slot])) {
  1867.             client.playerEquipment[slot] = -1;
  1868.             client.playerEquipmentN[slot] = 0;
  1869.             client.getOutStream().createFrame(34);
  1870.             client.getOutStream().writeWord(6);
  1871.             client.getOutStream().writeWord(1688);
  1872.             client.getOutStream().writeByte(slot);
  1873.             client.getOutStream().writeWord(0);
  1874.             client.getOutStream().writeByte(0);
  1875.             client.flushOutStream();
  1876.             client.updateRequired = true;
  1877.             client.appearanceUpdateRequired = true;
  1878.             client.getCombat().getMethods().sendWeapon(client);
  1879.             AnimationManager.getPlayerAnimIndex(client);
  1880.         }
  1881.     }
  1882.  
  1883.     /*************************************************************************
  1884.      * TURN TO METHOD *
  1885.      *************************************************************************/
  1886.     public void turnTo(int pointX, int pointY) {
  1887.         client.focusPointX = 2 * pointX + 1;
  1888.         client.focusPointY = 2 * pointY + 1;
  1889.         client.updateRequired = true;
  1890.     }
  1891.  
  1892.     /*************************************************************************
  1893.      * SEND FRAMES *
  1894.      *************************************************************************/
  1895.  
  1896.     public void sendFrame34(int id, int slot, int column, int amount)
  1897.     {
  1898.         if(client.getOutStream() != null && client != null){
  1899.            client.getOutStream().createFrameVarSizeWord(34); // init item to smith screen
  1900.            client.getOutStream().writeWord(column); // Column Across Smith Screen
  1901.            client.getOutStream().writeByte(4); // Total Rows?
  1902.            client.getOutStream().writeDWord(slot); // Row Down The Smith Screen
  1903.            client.getOutStream().writeWord(id+1); // item
  1904.            client.getOutStream().writeByte(amount); // how many there are?
  1905.            client.getOutStream().endFrameVarSizeWord();
  1906.         }
  1907.     }
  1908.  
  1909.     public void clueItems(int frame, int item, int slot, int amount){
  1910.         if(client.getOutStream() != null && client != null){
  1911.         client.getOutStream().createFrameVarSizeWord(34);
  1912.         client.getOutStream().writeWord(frame);
  1913.         client.getOutStream().writeByte(slot);
  1914.         client.getOutStream().writeWord(item+1);
  1915.         client.getOutStream().writeByte(255);
  1916.         client.getOutStream().writeDWord(amount);
  1917.         client.getOutStream().endFrameVarSizeWord();
  1918.         }
  1919.     }
  1920.  
  1921.     public void sendFrame126(String s, int id) {
  1922.         if(client.getOutStream() != null && client != null){
  1923.         client.getOutStream().createFrameVarSizeWord(126);
  1924.         client.getOutStream().writeString(s);
  1925.         client.getOutStream().writeWordA(id);
  1926.         client.getOutStream().endFrameVarSizeWord();
  1927.         client.flushOutStream();
  1928.         }
  1929.     }
  1930.  
  1931.     /*************************************************************************
  1932.      * NPC DIALOG PACKETS *
  1933.      *************************************************************************/
  1934.     public void sendFrame200(int i, int j) {
  1935.         client.getOutStream().createFrame(200);
  1936.         client.getOutStream().writeWord(i);
  1937.         client.getOutStream().writeWord(j);
  1938.         client.flushOutStream();
  1939.     }
  1940.  
  1941.     public void sendFrame75(int npc, int i) {
  1942.         client.getOutStream().createFrame(75);
  1943.         client.getOutStream().writeWordBigEndianA(npc);
  1944.         client.getOutStream().writeWordBigEndianA(i);
  1945.         client.flushOutStream();
  1946.     }
  1947.  
  1948.     public void sendFrame164(int i) {
  1949.         client.getOutStream().createFrame(164);
  1950.         client.getOutStream().writeWordBigEndian_dup(i);
  1951.         client.flushOutStream();
  1952.         client.close164frame = true;
  1953.     }
  1954.  
  1955.     public void sendFrame70(int i, int o, int id) {
  1956.         if(client.getOutStream() != null && client != null) {
  1957.             client.getOutStream().createFrame(70);
  1958.             client.getOutStream().writeWord(i);
  1959.             client.getOutStream().writeWordBigEndian(o);
  1960.             client.getOutStream().writeWordBigEndian(id);
  1961.             client.flushOutStream();
  1962.         }
  1963.     }
  1964.  
  1965.     public void sendFrame71(int a, int b){
  1966.        client.getOutStream().createFrame(71);
  1967.        client.getOutStream().writeWord(a);
  1968.        client.getOutStream().writeByteA(b);
  1969.     }
  1970.     public void sendFrame106(int a){
  1971.         if(client != null && client.getOutStream() != null)
  1972.         client.getOutStream().createFrame(106);
  1973.         client.getOutStream().writeByteC(a);
  1974.     }
  1975.     public void sendFrame99(int a){
  1976.         client.getOutStream().createFrame(99);
  1977.         client.getOutStream().writeByte(a);
  1978.     }
  1979.  
  1980.     public void sendFrame171(int i, int j) {
  1981.         client.getOutStream().createFrame(171);
  1982.         client.getOutStream().writeByte(i);
  1983.         client.getOutStream().writeWord(j);
  1984.         client.flushOutStream();
  1985.     }
  1986.  
  1987.     public void sendFrame185(int i) {
  1988.         client.getOutStream().createFrame(185);
  1989.         client.getOutStream().writeWordBigEndianA(i);
  1990.         client.flushOutStream();
  1991.     }
  1992.  
  1993.     public void sendFrame246(int MainFrame, int SubFrame, int SubFrame2) {
  1994.         client.getOutStream().createFrame(246);
  1995.         client.getOutStream().writeWordBigEndian(MainFrame);
  1996.         client.getOutStream().writeWord(SubFrame);
  1997.         client.getOutStream().writeWord(SubFrame2);
  1998.         client.flushOutStream();
  1999.     }
  2000.  
  2001.     public void openUpShop(int shopId) {
  2002.         Shop s = Server.getShopManager().getShops().get(shopId);
  2003.         if (s == null)
  2004.             return;
  2005.         sendQuest(s.getName(), 3901);
  2006.         sendFrame248(3824, 3822);
  2007.         resetItems(3823);
  2008.         resetShop(s);
  2009.         client.getExtraData().put("shop", shopId);
  2010.         client.flushOutStream();
  2011.     }
  2012.  
  2013.     public void sendFrame248(int MainFrame, int SubFrame) {
  2014.         client.getOutStream().createFrame(248);
  2015.         client.getOutStream().writeWordA(MainFrame);
  2016.         client.getOutStream().writeWord(SubFrame);
  2017.         client.flushOutStream();
  2018.     }
  2019.  
  2020.     public void resetItems(int WriteFrame) {
  2021.         client.getOutStream().createFrameVarSizeWord(53);
  2022.         client.getOutStream().writeWord(WriteFrame);
  2023.         client.getOutStream().writeWord(client.playerItems.length);
  2024.         for (int i = 0; i < client.playerItems.length; i++) {
  2025.             if (client.playerItemsN[i] > 254) {
  2026.                 client.getOutStream().writeByte(255); // item's stack count. if
  2027.                                                         // over 254, write byte
  2028.                                                         // 255
  2029.                 client.getOutStream().writeDWord_v2(client.playerItemsN[i]); // and
  2030.                                                                                 // then
  2031.                                                                                 // the
  2032.                                                                                 // real
  2033.                                                                                 // value
  2034.                                                                                 // with
  2035.                                                                                 // writeDWord_v2
  2036.             } else {
  2037.                 client.getOutStream().writeByte(client.playerItemsN[i]);
  2038.             }
  2039.             client.getOutStream().writeWordBigEndianA(client.playerItems[i]); // item
  2040.                                                                                 // id
  2041.         }
  2042.         client.getOutStream().endFrameVarSizeWord();
  2043.         client.flushOutStream();
  2044.     }
  2045.  
  2046.     public void resetShop(Shop shop) {
  2047.         client.getOutStream().createFrameVarSizeWord(53);
  2048.         client.getOutStream().writeWord(3900);
  2049.         int count = 0;
  2050.         for (int i = 0; i < shop.getContainerSize(); i++) {
  2051.             Item si = shop.getItemBySlot(i);
  2052.             if (si != null) {
  2053.                 count++;
  2054.             }
  2055.         }
  2056.         client.getOutStream().writeWord(count);
  2057.         for (int i = 0; i < shop.getContainerSize(); i++) {
  2058.             Item si = shop.getItemBySlot(i);
  2059.             if (si == null) {
  2060.                 continue;
  2061.             }
  2062.             if (si.getAmount() > 254) {
  2063.                 client.getOutStream().writeByte(255);
  2064.                 client.getOutStream().writeDWord_v2(si.getAmount());
  2065.             } else {
  2066.                 client.getOutStream().writeByte(si.getAmount());
  2067.             }
  2068.             client.getOutStream().writeWordBigEndianA(si.getId() + 1);
  2069.         }
  2070.         client.getOutStream().endFrameVarSizeWord();
  2071.         client.flushOutStream();
  2072.     }
  2073.  
  2074. }
Add Comment
Please, Sign In to add comment