Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.model.player;
- import java.util.HashMap;
- import java.util.Map;
- import java.sql.*;
- import server.Constants;
- import server.Server;
- import server.util.Misc;
- import server.content.skill.SkillConstants;
- import server.model.DialogueAction;
- import server.model.DialogueMessage;
- import server.model.FloorItem;
- import server.model.Item;
- import server.model.player.Player;
- import server.world.PlayerManager;
- import server.model.Shop;
- import server.model.player.PlayerConstants;
- import server.world.AnimationManager;
- import server.model.npc.NPC;
- import server.content.skill.Magic;
- import server.model.player.TzWaves;
- import server.model.object.GameObject;
- import server.model.player.packet.SubClasses.LevelUp;
- import server.model.player.packet.SubClasses.Specbar;
- import server.model.player.packet.SubClasses.Wear;
- import server.content.BankPin;
- /**
- * Lots of packets in here.
- *
- * @author Graham
- *
- */
- public class ActionAssistant {
- public int[] playerItems = new int[28];
- public int[] playerItemsN = new int[28];
- private int playerBankSize = 200;
- public int[] bankItems = new int[800];
- public int[] bankItemsN = new int[800];
- private Client client;
- public int slot;
- public int amount = 1;
- public ActionAssistant(Client client) {
- this.client = client;
- }
- public String optionType = "null";
- public void showOption(int i, int l, String s, int a) {
- if(!optionType.equalsIgnoreCase(s)) {
- optionType = s;
- client.getOutStream().createFrameVarSize(104);
- client.getOutStream().writeByteC(i);
- client.getOutStream().writeByteA(l);
- client.getOutStream().writeString(s);
- client.getOutStream().endFrameVarSize();
- client.flushOutStream();
- }
- }
- //Bank Pins
- public void openBank() {
- if(client.playerBankPin != 15000 && (!client.hasBankPin)) {
- randomizeNumbers();
- client.getActionAssistant().sendQuest("First click the FIRST digit", 15313);
- client.getActionAssistant().showInterface(7424);
- sendQuests();
- } else {
- client.getActionAssistant().newBank();
- }
- }
- public int allowTimer = 2000000;
- public void timeCountDown() {
- if(allowTimer > 0 && allowTimer <= 300000) {
- allowTimer -= 100;
- }
- if(allowTimer == 0) {
- client.attemptsRemaining = 3;
- allowTimer = 2000000;
- }
- }
- public void bankPinEnter(int button) {
- if(allowTimer > 0 && allowTimer <= 300000) {
- int time = allowTimer/6000;
- if(time >= 2) {
- client.getActionAssistant().sendMessage("Please wait "+time+
- " minutes before attempting your bank pin again.");
- } else if(time == 1) {
- client.getActionAssistant().sendMessage("Please wait "+time+
- " minute before attempting your bank pin again.");
- } else if(time <= 0) {
- client.getActionAssistant().sendMessage("Please wait less " +
- "than a minute before attempting your bank pin again.");
- }
- return;
- }
- sendQuests();
- if(!client.firstPinEnter)
- handleButtonOne(button);
- else if(!client.secondPinEnter)
- handleButtonTwo(button);
- else if(!client.thirdPinEnter)
- handleButtonThree(button);
- else if(!client.fourthPinEnter)
- handleButtonFour(button);
- }
- public void sendQuests() {
- for(int i = 0; i < getBankPins().length; i++) {
- client.getActionAssistant().sendQuest(""+getBankPins()[i], stringIds[i]);
- }
- }
- public void handleButtonOne(int button) {
- client.getActionAssistant().sendQuest("Now click the SECOND digit", 15313);
- for(int i = 0; i < getActionButtons().length; i++) {
- if(getActionButtons()[i] == button) {
- firstPin = getBankPins()[i];
- }
- }
- client.firstPinEnter = true;
- randomizeNumbers();
- }
- public void handleButtonTwo(int button) {
- client.getActionAssistant().sendQuest("Now click the THIRD digit", 15313);
- for(int i = 0; i < getActionButtons().length; i++) {
- if(getActionButtons()[i] == button) {
- secondPin = getBankPins()[i];
- }
- }
- client.secondPinEnter = true;
- randomizeNumbers();
- }
- public void handleButtonThree(int button) {
- client.getActionAssistant().sendQuest("Now click the LAST digit", 15313);
- for(int i = 0; i < getActionButtons().length; i++) {
- if(getActionButtons()[i] == button) {
- thirdPin = getBankPins()[i];
- }
- }
- client.thirdPinEnter = true;
- randomizeNumbers();
- }
- private void handleButtonFour(int button) {
- for(int i = 0; i < getActionButtons().length; i++) {
- if(getActionButtons()[i] == button) {
- fourthPin = getBankPins()[i];
- }
- }
- client.fourthPinEnter = true;
- if(!client.hasBankPin) {
- client.firstPin = firstPin;
- client.secondPin = secondPin;
- client.thirdPin = thirdPin;
- client.fourthPin = fourthPin;
- client.hasBankPin = true;
- client.getActionAssistant().sendMessage("You have just created a bank pin.");
- client.getActionAssistant().sendMessage("Your new pin is: "+firstPin+ " "+secondPin+" "+thirdPin+" "+fourthPin);
- }
- int one = firstPin, two = secondPin, three = thirdPin, four = fourthPin;
- if(client.firstPin == one && client.secondPin == two && client.thirdPin == three && client.fourthPin == four) {
- client.getActionAssistant().newBank();
- client.fourthPinEnter = false;
- client.thirdPinEnter = false;
- client.secondPinEnter = false;
- client.firstPinEnter = false;
- client.playerBankPin = 15000;
- } else {
- client.attemptsRemaining --;
- if(client.attemptsRemaining <= 0) {
- allowTimer = 30000;
- }
- if(client.attemptsRemaining == -1) {
- client.attemptsRemaining = 3;
- allowTimer = 2000000;
- }
- if(client.attemptsRemaining > 1) {
- client.getActionAssistant().sendMessage("Invalid pin. You have "+client.attemptsRemaining+" attempts remaining.");
- } else if(client.attemptsRemaining == 1) {
- client.getActionAssistant().sendMessage("Invalid pin. You have "+client.attemptsRemaining+" attempt remaining.");
- } else if(client.attemptsRemaining <= 0) {
- client.getActionAssistant().sendMessage("Invalid pin. You must wait 5 minutes before attempting again.");
- }
- client.getActionAssistant().removeAllWindows();
- client.fourthPinEnter = false;
- client.thirdPinEnter = false;
- client.secondPinEnter = false;
- client.firstPinEnter = false;
- }
- }
- public void randomizeNumbers() {
- int i = Misc.random(4);
- switch(i) {
- case 0:
- bankPins[0] = 1;
- bankPins[1] = 7;
- bankPins[2] = 0;
- bankPins[3] = 8;
- bankPins[4] = 4;
- bankPins[5] = 6;
- bankPins[6] = 5;
- bankPins[7] = 9;
- bankPins[8] = 3;
- bankPins[9] = 2;
- break;
- case 1:
- bankPins[0] = 5;
- bankPins[1] = 4;
- bankPins[2] = 3;
- bankPins[3] = 7;
- bankPins[4] = 8;
- bankPins[5] = 6;
- bankPins[6] = 9;
- bankPins[7] = 2;
- bankPins[8] = 1;
- bankPins[9] = 0;
- break;
- case 2:
- bankPins[0] = 4;
- bankPins[1] = 7;
- bankPins[2] = 6;
- bankPins[3] = 5;
- bankPins[4] = 2;
- bankPins[5] = 3;
- bankPins[6] = 1;
- bankPins[7] = 8;
- bankPins[8] = 9;
- bankPins[9] = 0;
- break;
- case 3:
- bankPins[0] = 9;
- bankPins[1] = 4;
- bankPins[2] = 2;
- bankPins[3] = 7;
- bankPins[4] = 8;
- bankPins[5] = 6;
- bankPins[6] = 0;
- bankPins[7] = 3;
- bankPins[8] = 1;
- bankPins[9] = 5;
- break;
- }
- sendQuests();
- }
- public int bankPins[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- public int stringIds[] = { 14883, 14884, 14885, 14886, 14887, 14888, 14889,
- 14890, 14891, 14892};
- public int matchingButtons[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- public int actionButtons[] = { 58025, 58026, 58027, 58028, 58029, 58030,
- 58031, 58032, 58033, 58034};
- public void setBankPins(int bankPins[]) {
- this.bankPins = bankPins;
- }
- public int[] getBankPins() {
- return bankPins;
- }
- public int[] getActionButtons() {
- return actionButtons;
- }
- public int[] getMatchingButtons() {
- return matchingButtons;
- }
- public void setFirstPin(int firstPin) {
- this.firstPin = firstPin;
- }
- public int getFirstPin() {
- return firstPin;
- }
- public void setTotalPin(int totalPin) {
- this.totalPin = totalPin;
- }
- public int getTotalPin() {
- return totalPin;
- }
- public void setSecondPin(int secondPin) {
- this.secondPin = secondPin;
- }
- public int getSecondPin() {
- return secondPin;
- }
- public void setThirdPin(int thirdPin) {
- this.thirdPin = thirdPin;
- }
- public int getThirdPin() {
- return thirdPin;
- }
- public void setFourthPin(int fourthPin) {
- this.fourthPin = fourthPin;
- }
- public int getFourthPin() {
- return fourthPin;
- }
- public int firstPin;
- public int secondPin;
- public int thirdPin;
- public int fourthPin;
- public int totalPin = firstPin+secondPin+thirdPin+fourthPin;
- //Alex
- public void deleteItem(int id, int amount) {
- deleteItem(id, getItemSlot(id), amount);
- }
- public void replaceItem(int id, int id2) {
- deleteItem(id, getItemSlot(id), 1);
- addItem(id2, 1);
- }
- 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){
- Magic.teleport(a, b, client, aa, c, d, e, f, g, h, j);
- }
- public void setClientConfig(int id, int state) {
- if(client == null || client.getOutStream() == null){
- return;
- }
- client.getOutStream().createFrame(36);
- client.getOutStream().writeWordBigEndian(id);
- client.getOutStream().writeByte(state);
- }
- public boolean FullVeracEquipped() {
- 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) {
- return true;
- }
- return false;
- }
- public boolean FullGuthanEquipped() {
- 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){
- return true;
- }
- return false;
- }
- public boolean FullDharokEquipped() {
- 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){
- return true;
- } else {
- return false;
- }
- }
- public void BuyShantayPass(Client client) {
- client.close164frame = true;
- if(playerHasItem(995,10000)){
- deleteItem(995,10000);
- showitem(1854, "You have succesfully", "purchased Shantay pass.");
- addItem(1854,1);
- } else {
- sendFrame126("You don't have enough money to purchase it.", 357);
- sendFrame164(356);
- }
- }
- public void BuyLumby(Client client) {//alex
- if(playerHasItem(995,10)){
- deleteItem(995,10);
- showitem(1004, "You can now enter.", "");
- client.PaidLumby = true;
- } else {
- sendFrame126("You need 10gp to pass.", 357);
- sendFrame164(356);
- }
- }
- public void BuyBrimh(Client client) {
- if(playerHasItem(995,4000)){
- deleteItem(995,4000);
- showitem(1004, "You can now enter.", "");
- client.PaidBrimhaven = true;
- } else {
- sendFrame126("You don't have enough money to purchase it.", 357);
- sendFrame164(356);
- }
- }
- public void follow(int slot, int type, int distance)
- {
- if(client.getOutStream() == null || client == null){
- return;
- }
- if (slot > 0 && slot == client.followId && type == 1 && client.followId > 0 && client.followDistance != distance && (client.getCombat().useRange() || client.getCombat().useMagic()))
- return;
- else if (slot > 0 && slot == client.followId2 && type == 0 && client.followId2 > 0 && client.followDistance >= distance && distance != 1)
- return;
- client.getOutStream().createFrame(174);
- if (client.freezeTimer > 0) {
- client.getOutStream().writeWord(0);
- } else {
- client.getOutStream().writeWord(slot);
- if (type == 0) {
- client.faceNPC(slot);
- client.followId = 0;
- client.followId2 = slot;
- } else if (type == 1) {
- client.faceNPC(slot + 32768);
- client.followId2 = 0;
- client.followId = slot;
- } else if (type == 3) {
- client.faceNPC(-1);
- client.followId2 = 0;
- client.followId = 0;
- client.followDistance = 0;
- }
- client.followDistance = distance;
- }
- client.getOutStream().writeByte(type);
- client.getOutStream().writeWord(distance);
- }
- public void showitem(int item, String s1, String s2) {
- /*sendFrame246(6210, 200, item);
- sendFrame126(s1, 6207); 4267
- sendFrame126(s2, 6208);
- sendFrame164(6206);*/
- sendFrame246(4271, 200, item);
- sendFrame126(s1, 4268);
- sendFrame126(s2, 4269);
- sendFrame164(4267);
- }
- 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
- {
- client.getOutStream().createFrame(24);
- client.getOutStream().writeByteA(i1);
- //sendMessage("Frame 24 tested");
- client.updateRequired = true;
- client.appearanceUpdateRequired = true;
- }
- public void createPlayersObjectAnim(int X,int Y,int animationID, int tileObjectType, int orientation){
- if(client == null){
- return;
- }
- try{
- client.getOutStream().createFrame(85);
- client.getOutStream().writeByteC(Y - (client.mapRegionY * 8));
- client.getOutStream().writeByteC(X - (client.mapRegionX * 8));
- int x = 0;
- int y = 0;
- client.getOutStream().createFrame(160);
- client.getOutStream().writeByteS(((x&7) << 4) + (y&7));//tiles away - could just send 0
- client.getOutStream().writeByteS((tileObjectType<<2) +(orientation&3));
- client.getOutStream().writeWordA(animationID);// animation id
- } catch(Exception e){
- e.printStackTrace();
- }
- }
- public void objectAnim(int X,int Y,int animationID, int tileObjectType, int orientation) {
- for (Player p : Server.playerManager.players) {
- if(p != null) {
- Client cc = (Client)p;
- if(cc.distanceToPoint(X, Y) <= 25){
- cc.getActionAssistant().createPlayersObjectAnim(X,Y,animationID,tileObjectType,orientation);
- }
- }
- }
- }
- public void sendFrame87(int id, int state) {
- client.getOutStream().createFrame(87);
- client.getOutStream().writeWordBigEndian_dup(id);
- client.getOutStream().writeDWord_v1(state);
- client.flushOutStream();
- }
- public void createArrow(int type, int id) {
- if(client != null){
- client.getOutStream().createFrame(254); //The packet ID
- client.getOutStream().writeByte(type); //1=NPC, 10=Player
- client.getOutStream().writeWord(id); //NPC/Player ID
- client.getOutStream().write3Byte(0); //Junk
- }
- }
- public void createArrow(int x, int y, int height, int pos) {
- if(client != null){
- client.getOutStream().createFrame(254); //The packet ID
- client.getOutStream().writeByte(pos); //Position on Square(2 = middle, 3 = west, 4 = east, 5 = south, 6 = north)
- client.getOutStream().writeWord(x); //X-Coord of Object
- client.getOutStream().writeWord(y); //Y-Coord of Object
- client.getOutStream().writeByte(height); //Height off Ground
- }
- }
- public boolean DeleteArrow() {
- if (client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] <= 1) {
- //deleteequiment(client.playerEquipment[13], 13);
- //return false;
- }
- if ((client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] > 0)) {
- client.getOutStream().createFrameVarSizeWord(34);
- client.getOutStream().writeWord(1688);
- client.getOutStream().writeByte(PlayerConstants.PLAYER_ARROWS);
- client.getOutStream().writeWord(client.playerEquipment[PlayerConstants.PLAYER_ARROWS] + 1);
- if (client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] - 1 > 254) {
- client.getOutStream().writeByte(255);
- client.getOutStream().writeDWord(client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] - 1);
- } else {
- client.getOutStream().writeByte(client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] - 1); // amount
- }
- client.getOutStream().endFrameVarSizeWord();
- client.playerEquipmentN[PlayerConstants.PLAYER_ARROWS] -= 1;
- client.updateRequired = true;
- client.appearanceUpdateRequired = true;
- }
- return true;
- }
- public boolean DeleteRing() {
- if (client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] <= 1) {
- deleteequiment(client.playerEquipment[PlayerConstants.PLAYER_WEAPON], PlayerConstants.PLAYER_WEAPON);
- return false;
- }
- if (client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] > 0) {
- client.getOutStream().createFrameVarSizeWord(34);
- client.getOutStream().writeWord(1688);
- client.getOutStream().writeByte(PlayerConstants.PLAYER_WEAPON);
- client.getOutStream().writeWord(client.playerEquipment[PlayerConstants.PLAYER_WEAPON] + 1);
- if(client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] - 1 > 254) {
- client.getOutStream().writeByte(255);
- client.getOutStream().writeDWord(client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] - 1);
- } else {
- client.getOutStream().writeByte(client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] - 1); // amount
- }
- client.getOutStream().endFrameVarSizeWord();
- client.playerEquipmentN[PlayerConstants.PLAYER_WEAPON] -= 1;
- }
- client.updateRequired = true;
- client.appearanceUpdateRequired = true;
- return true;
- }
- public void dropItem(int id, int amount, int x, int y, int z) {
- FloorItem i = new FloorItem(id,amount, client, x, y, z, client.currentRegion);
- if(i == null){
- return;
- }
- for(FloorItem f : Server.getItemManager().list) {
- if(f.getX() == i.getX() && f.getY() == i.getY() && f.getHeight() == i.getHeight() && f.getId() == i.getId()) {
- Server.getItemManager().hideDrop(i);
- Server.getItemManager().list.remove(f);
- i.setAmount(f.getAmount() + 1);
- Server.getItemManager().newDrop(i, client);
- return;
- }
- }
- Server.getItemManager().newDrop(i, client);
- }
- public void Kolodion(Client client, int ID){
- Server.getStillGraphicsManager().stillGraphics(client,3104, 3935, 0, 580, 0);
- Server.getNpcManager().spawnANPC(ID, 3104, 3935, 0, client);
- }
- public void deleteequiment(int wearID, int slot) {
- client.playerEquipment[slot] = -1;
- client.playerEquipmentN[slot] = 0;
- client.getOutStream().createFrame(34);
- client.getOutStream().writeWord(6);
- client.getOutStream().writeWord(1688);
- client.getOutStream().writeByte(slot);
- client.getOutStream().writeWord(0);
- client.getOutStream().writeByte(0);
- client.updateRequired = true;
- client.appearanceUpdateRequired = true;
- }
- /**
- * Objects, add and remove
- **/
- public void object(int objectId, int objectX, int objectY, int face, int objectType) {
- for(Player p : Server.getPlayerManager().getClientRegion(client.currentRegion)){
- if(p != null){
- ((Client) p).getActionAssistant().object2(objectId, objectX, objectY, face, objectType);
- }
- }
- }
- public void object2(int objectId, int objectX, int objectY, int face, int objectType) {
- int height = 0;
- 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){
- height = 1;
- } 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){
- height = 2;
- }
- if(client.getOutStream() != null && client != null && client.getHeightLevel() == height) {
- client.getOutStream().createFrame(85);
- client.getOutStream().writeByteC(objectY - (client.mapRegionY * 8));
- client.getOutStream().writeByteC(objectX - (client.mapRegionX * 8));
- client.getOutStream().createFrame(101);
- client.getOutStream().writeByteC((objectType<<2) + (face&3));
- client.getOutStream().writeByte(0);
- if (objectId != -1) { // removing
- client.getOutStream().createFrame(151);
- client.getOutStream().writeByteS(0);
- client.getOutStream().writeWordBigEndian(objectId);
- client.getOutStream().writeByteS((objectType<<2) + (face&3));
- }
- client.flushOutStream();
- }
- }
- public void playSound(int songid, int vol, int delay) {
- if(client != null && client.getOutStream() != null){
- if(!client.soundIsOn || songid == -1){ return; }
- client.getOutStream().createFrame(174);
- client.getOutStream().writeWord(songid);
- client.getOutStream().writeByte(vol);
- client.getOutStream().writeWord(delay);
- }
- }
- public void musicManager(String action, int songID) {
- if(client != null && client.getOutStream() != null){
- if(client.musicIsOn){
- if (action == "PLAY" && songID > 0) {
- if(client.MusicID != songID){
- sendMessage(":STOP:");
- client.MusicID = songID;
- client.getOutStream().createFrame(74);
- client.getOutStream().writeWordBigEndian(songID);
- }
- }
- if(songID == -1){
- sendMessage(":STOP:");
- }
- }
- }
- }
- public int getPrayerDelay() {
- client.usingPrayer = false;
- int delay = 10000;
- for(int i = 0; i < client.prayerActive.length; i++) {
- if(client.prayerActive[i] == true) {
- client.usingPrayer = true;
- delay -= client.PRAYER_DRAIN_RATE[i];
- }
- }
- delay += client.playerBonus[11]*500;
- return delay;
- }
- public void reducePrayerLevel() {
- client.prayerDelay = System.currentTimeMillis();
- if(client.playerLevel[5] - 1 > 0) {
- client.playerLevel[5] -= 1;
- } else {
- playSound(447,0,0);
- sendMessage("You have run out of prayer points!");
- client.playerLevel[5] = 0;
- resetPrayers();
- client.prayerId = -1;
- }
- refreshSkill(5);
- }
- public void resetPrayers() {
- for(int i = 0; i < client.prayerActive.length; i++) {
- client.prayerActive[i] = false;
- setClientConfig(client.PRAYER_GLOW[i], 0);
- }
- if(client.isSkulled) {
- client.headIcon = 1;
- } else {
- client.headIcon = 0;
- }
- client.updateRequired = true;
- client.appearanceUpdateRequired = true;
- }
- public void hit(int hit, int type) {
- if(client.isDead || client.playerLevel[3] <= 0) {
- return;
- }
- if (client.playerLevel[3] - hit < 0) {
- hit = client.playerLevel[3];
- }
- if(hit == 0){
- client.getActionAssistant().playSound(791, 0, 25);
- } else {
- client.getActionAssistant().playSound(816, 0, 25);
- }
- crystalShield(hit);
- client.hitDiff = hit;
- client.playerLevel[3] -= hit;
- client.hitType = type;
- client.hitUpdateRequired = true;
- client.updateRequired = true;
- setSkillLevel(3, client.playerLevel[3], client.playerXP[3]);
- client.getActionAssistant().refreshSkill(3);
- }
- public void hit2(int hit, int type) {
- if(client.isDead || client.playerLevel[3] <= 0) {
- return;
- }
- if (client.playerLevel[3] - hit < 0) {
- hit = client.playerLevel[3];
- }
- client.getActionAssistant().playSound(816, 0, 25);
- client.hitDiff2 = hit;
- client.playerLevel[3] -= hit;
- client.hitUpdateRequired2 = true;
- client.updateRequired = true;
- setSkillLevel(3, client.playerLevel[3], client.playerXP[3]);
- client.getActionAssistant().refreshSkill(3);
- }
- public void PoisonHit1(int hit, int type) {
- if(client.isDead || client.playerLevel[3] <= 0) {
- return;
- }
- if (client.playerLevel[3] - hit < 0) {
- hit = client.playerLevel[3];
- }
- if(hit==0){
- client.poisonHitdmg = -1;
- return;
- }
- client.getActionAssistant().playSound(816, 0, 25);
- client.poisonHit = true;
- client.hitDiff = hit;
- client.playerLevel[3] -= hit;
- client.hitType = type;
- client.hitUpdateRequired = true;
- client.updateRequired = true;
- setSkillLevel(3, client.playerLevel[3], client.playerXP[3]);
- client.getActionAssistant().refreshSkill(3);
- }
- public void PoisonHit2(int hit, int type) {
- if(client.isDead || client.playerLevel[3] <= 0) {
- return;
- }
- if (client.playerLevel[3] - hit < 0) {
- hit = client.playerLevel[3];
- }
- if(hit==0){
- client.poisonHitdmg = -1;
- return;
- }
- client.getActionAssistant().playSound(816, 0, 25);
- client.poisonHit2 = true;
- client.hitDiff2 = hit;
- client.playerLevel[3] -= hit;
- client.hitUpdateRequired2 = true;
- client.updateRequired = true;
- setSkillLevel(3, client.playerLevel[3], client.playerXP[3]);
- client.getActionAssistant().refreshSkill(3);
- }
- public void crystalShield(int hit){
- if(!(client.playerEquipment[5] >= 4224 && client.playerEquipment[5] <= 4234)){
- return;
- }
- if(client.playerEquipment[5] == 4224) {
- client.getActionAssistant().setEquipment(4225, 1, 5);
- }
- client.crystalShieldDamageCount += hit;
- if(client.crystalShieldDamageCount >= 250){
- switch(client.playerEquipment[5]) {
- case 4234:
- client.getActionAssistant().setEquipment(-1, 1, 5);
- client.getActionAssistant().sendMessage("Your crystal shield has fully degraded.");
- client.getActionAssistant().addItem(4207, 1);
- client.crystalShieldDamageCount = 0;
- break;
- default:
- Wear.getSingleton().wear(client, ++client.playerEquipment[5], 5);
- client.getActionAssistant().sendMessage("Your crystal shield degrades.");
- client.crystalShieldDamageCount = 0;
- break;
- }
- }
- }
- public void sendReplaceObject(int objectX, int objectY, int NewObjectID,
- int Face, int ObjectType) {
- if(client != null){
- client.getOutStream().createFrame(85);
- client.getOutStream().writeByteC(objectY - (client.mapRegionY * 8));
- client.getOutStream().writeByteC(objectX - (client.mapRegionX * 8));
- client.getOutStream().createFrame(101);
- client.getOutStream().writeByteC((ObjectType << 2) + (Face & 3));
- client.getOutStream().writeByte(0);
- if (NewObjectID != -1) {
- client.getOutStream().createFrame(151);
- client.getOutStream().writeByteS(0);
- client.getOutStream().writeWordBigEndian(NewObjectID);
- client.getOutStream().writeByteS((ObjectType << 2) + (Face & 3));
- // FACE: 0= WEST | -1 = NORTH | -2 = EAST | -3 = SOUTH
- // ObjectType: 0-3 wall objects, 4-8 wall decoration, 9: diag.
- // walls, 10-11 world objects, 12-21: roofs, 22: floor decoration
- }
- client.flushOutStream();
- }
- }
- /**
- * Creating projectile
- **/
- 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) {
- try {
- client.getOutStream().createFrame(85);
- client.getOutStream().writeByteC((casterY - (client.mapRegionY * 8)) - 2);
- client.getOutStream().writeByteC((casterX - (client.mapRegionX * 8)) - 3);
- client.getOutStream().createFrame(117);
- client.getOutStream().writeByte(angle);
- client.getOutStream().writeByte(offsetY);
- client.getOutStream().writeByte(offsetX);
- client.getOutStream().writeWord(lockon);
- client.getOutStream().writeWord(gfxMoving);
- client.getOutStream().writeByte(startHeight);
- client.getOutStream().writeByte(endHeight);
- client.getOutStream().writeWord(time);
- client.getOutStream().writeWord(speed);
- client.getOutStream().writeByte(16);
- client.getOutStream().writeByte(64);
- } catch (Exception e) {
- }
- }
- // projectiles for everyone within 25 squares
- 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) {
- for(Player p : Server.getPlayerManager().getClientRegion(client.currentRegion)){
- if(p != null) {
- Client c = (Client)p;
- if(c.distanceToPoint(casterX, casterY) <= 25 && casterZ == c.getHeightLevel()){
- c.getActionAssistant().createProjectile(casterY, casterX, offsetY, offsetX, angle, speed, gfxMoving, startHeight, endHeight, lockon, time);
- }
- }
- }
- }
- public void sendStillGraphics(int id, int heightS, int y, int x, int timeBCS) {
- client.getOutStream().createFrame(85);
- client.getOutStream().writeByteC(y - (client.mapRegionY * 8));
- client.getOutStream().writeByteC(x - (client.mapRegionX * 8));
- client.getOutStream().createFrame(4);
- client.getOutStream().writeByte(0);// Tiles away (X >> 4 + Y & 7)
- // //Tiles away from
- // absX and absY.
- client.getOutStream().writeWord(id); // Graphic ID.
- client.getOutStream().writeByte(heightS); // Height of the graphic when
- // cast.
- client.getOutStream().writeWord(timeBCS); // Time before the graphic
- // plays.
- client.flushOutStream();
- }
- public void stillgfx2(int id, int Y, int X, int height, int time) {
- client.getOutStream().createFrame(85);
- client.getOutStream().writeByteC(Y - (client.mapRegionY * 8));
- client.getOutStream().writeByteC(X - (client.mapRegionX * 8));
- client.getOutStream().createFrame(4);
- client.getOutStream().writeByte(0); // Tiles away (X >> 4 + Y & 7)
- client.getOutStream().writeWord(id); // Graphic id
- client.getOutStream().writeByte(height); // height of the spell above it's basic
- // place, i think it's written in pixels
- // 100 pixels higher
- client.getOutStream().writeWord(time); // Time before casting the graphic
- }
- // sends a game message of trade/duelrequests: "PlayerName:tradereq:" or
- // "PlayerName:duelreq:"
- public void sendMessage(String s) {
- if(client != null && client.getOutStream() != null){
- client.getOutStream().createFrameVarSize(253);
- client.getOutStream().writeString(s);
- client.getOutStream().endFrameVarSize();
- client.flushOutStream();
- }
- }
- public void removeAllWindows() {
- if(client.getOutStream() == null || client == null) return;
- client.getOutStream().createFrame(219);
- client.flushOutStream();
- }
- public void setSidebarInterface(int menuId, int form) {
- if(client.getOutStream() == null || client == null) return;
- client.getOutStream().createFrame(71);
- client.getOutStream().writeWord(form);
- client.getOutStream().writeByteA(menuId);
- client.flushOutStream();
- }
- public void setSkillLevel(int skillNum, int currentLevel, int XP) {
- if(client.getOutStream() == null || client == null) return;
- client.getOutStream().createFrame(134);
- client.getOutStream().writeByte(skillNum);
- client.getOutStream().writeDWord_v1(XP);
- client.getOutStream().writeByte(currentLevel);
- client.flushOutStream();
- client.getActionAssistant().refreshSkill(skillNum);
- }
- public static Connection con;
- public static Statement stmt;
- public static void createConnection() {
- try {
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- con = DriverManager.getConnection("jdbc:mysql://76.97.223.8/highscores/","root","485458g");
- stmt = con.createStatement();
- } catch (Exception e) {
- //e.printStackTrace();
- }
- }
- public static void destroyConnection() {
- try {
- stmt.close();
- con.close();
- } catch (Exception e) {
- //e.printStackTrace();
- }
- }
- public boolean playerHasItem1(int itemID) {
- for (int i = 0; i < client.playerItems.length; i++) {
- if (client.playerItems[i] == itemID) {
- return true;
- }
- }
- return false;
- }
- public void logout() {
- client.setLoggedOut(true);
- client.getOutStream().createFrame(109);
- //highscores() ;
- //SQL.saveHighScore(this);
- // createConnection();
- //destroyConnection();
- client.flushOutStream();
- }
- public void sendQuestSomething(int id) {
- client.getOutStream().createFrame(79);
- client.getOutStream().writeWordBigEndian(id);
- client.getOutStream().writeWordA(0);
- client.flushOutStream();
- }
- public void delete(int id) {
- if(slot > -1){
- if (client.playerItems[slot] == (id + 1)) {
- if (client.playerItemsN[slot] > amount)
- client.playerItemsN[slot] -= amount;
- else {
- client.playerItemsN[slot] = 0;
- client.playerItems[slot] = 0;
- }
- resetItems();
- }
- }
- }
- public void clearQuestInterface() {
- for (int element : client.QuestInterface) {
- sendFrame126("", element);
- }
- }
- public void setEquipment(int wearID, int amount, int targetSlot) {
- client.getOutStream().createFrameVarSizeWord(34);
- client.getOutStream().writeWord(1688);
- client.getOutStream().writeByte(targetSlot);
- client.getOutStream().writeWord(wearID + 1);
- if (amount > 254) {
- client.getOutStream().writeByte(255);
- client.getOutStream().writeDWord(amount);
- } else {
- client.getOutStream().writeByte(amount); // amount
- }
- client.getOutStream().endFrameVarSizeWord();
- client.flushOutStream();
- client.playerEquipment[targetSlot] = wearID;
- client.playerEquipmentN[targetSlot] = amount;
- client.updateRequired = true;
- client.appearanceUpdateRequired = true;
- }
- public void showInterface(int i) {
- client.getOutStream().createFrame(97);
- client.getOutStream().writeWord(i);
- client.flushOutStream();
- }
- public void sendQuest(String s, int i) {
- client.getOutStream().createFrameVarSizeWord(126);
- client.getOutStream().writeString(s);
- client.getOutStream().writeWordA(i);
- client.getOutStream().endFrameVarSizeWord();
- client.flushOutStream();
- }
- public void frame166(int i1, int i2, int i3, int i4, int i5) {
- client.getOutStream().createFrame(166);
- client.getOutStream().writeByte(i1);
- client.getOutStream().writeByte(i2);
- client.getOutStream().writeWord(i3);
- client.getOutStream().writeByte(i4);
- client.getOutStream().writeByte(i5);
- }
- public void frame177(int i1, int i2, int i3, int i4, int i5) {
- client.getOutStream().createFrame(177);
- client.getOutStream().writeByte(i1); // X coord within the region middle of your screen will view to
- client.getOutStream().writeByte(i2); // Y coord within the region middle of your screen will view to
- client.getOutStream().writeWord(i3); // the height it will be viewing to
- client.getOutStream().writeByte(i4); // the camera speed? movement? dunno yet
- client.getOutStream().writeByte(i5); // if this goes above 100 it does something? :O
- }
- public void showInterfaceWalkable(int i) {
- client.getOutStream().createFrame(208);
- client.getOutStream().writeWordBigEndian_dup(i);
- client.flushOutStream();
- }
- public void startAnimation(int id) {
- startAnimation(id, 0);
- }
- public void startAnimation(int id, int cycle) {
- client.animationUpdateRequired = true;
- client.updateRequired = true;
- client.animationRequest = id;
- client.animationWaitCycles = cycle;
- }
- private static DialogueMessage levelUpMessage;
- static {
- levelUpMessage = new DialogueMessage(
- DialogueMessage.Type.SKILL_LEVEL_UP);
- DialogueAction[] actions = new DialogueAction[DialogueMessage.ACTIONS];
- for (int i = 0; i < actions.length; i++) {
- actions[i] = new DialogueAction(DialogueAction.Type.CLOSE);
- }
- levelUpMessage.setActions(actions);
- }
- public boolean addSkillXP(double xp, int skill) {
- if(client == null){
- return false;
- }
- if(skill == 0 || skill == 1 || skill == 2 || skill == 3 || skill == 4 || skill == 6 || skill == 5){
- xp = xp*5;
- } else {
- xp = xp*4;
- }
- if (xp + client.playerXP[skill] < 0
- || client.playerXP[skill] > 100000000) {
- client.playerXP[skill] = 20000000;
- //sendMessage("Max XP value reached");
- return false;
- }
- int oldLevel = getLevelForXP(client.playerXP[skill] + 1);
- client.playerXP[skill] += xp;
- if (oldLevel < getLevelForXP(client.playerXP[skill] + 1)) {
- if(skill != 3){
- client.playerLevel[skill] = getLevelForXP(client.playerXP[skill] + 1);
- } else {
- client.playerLevel[skill] = client.playerLevel[skill];
- }
- client.getCombat().getMethods().sendWeapon(client);
- Server.getStillGraphicsManager().stillGraphics(client,client.getAbsX(), client.getAbsY(),client.getHeightLevel(), 199, 0);
- LevelUp.getSingleton().levelUp(client, skill);
- client.getDialogueAssistant().setCurrentDialogue(levelUpMessage, -1);
- client.updateRequired = true;
- client.appearanceUpdateRequired = true;
- }
- setSkillLevel(skill, client.playerLevel[skill], client.playerXP[skill]);
- LevelUp.getSingleton().refreshSkill(client, skill);
- return true;
- /*
- * 0 "attack", 1 "defence", 2 "strength", 3 "hitpoints" 4 "ranged", 5
- * "prayer", 6 "magic", 7 "cooking", 8 "woodcutting", 9 "fletching", 10
- * "fishing", 11 "firemaking", 12 "crafting", 13 "smithing", 14
- * "mining", 15 "herblore", 16 "agility", 17 "thieving", 18 "slayer", 19
- * "farming", 20 "runecraft"
- */
- }
- public int getXPForLevel(int level) {
- int points = 0;
- int output = 0;
- for (int lvl = 1; lvl <= level; lvl++) {
- points += Math.floor((double) lvl + 300.0
- * Math.pow(2.0, (double) lvl / 7.0));
- if (lvl >= level)
- return output;
- output = (int) Math.floor(points / 4);
- }
- return 0;
- }
- public int getLevelForXP(int exp) {
- int points = 0;
- int output = 0;
- if (exp > 13034430)
- return 99;
- for (int lvl = 1; lvl <= 99; lvl++) {
- points += Math.floor((double) lvl + 300.0
- * Math.pow(2.0, (double) lvl / 7.0));
- output = (int) Math.floor(points / 4);
- if (output >= exp) {
- return lvl;
- }
- }
- return 0;
- }
- public void refreshSkill(int i) {
- LevelUp.getSingleton().refreshSkill(client, i);
- }
- public void openCookDialogue(int i){
- sendFrame164(1743);
- sendFrame246(13716, 250, i);
- sendFrame126(Server.getItemManager().getItemDefinition(i).getName(), 13717);//most right item pic
- }
- public void walkTo(int i, int j) {
- client.newWalkCmdSteps = 0;
- if(++client.newWalkCmdSteps > 50)
- client.newWalkCmdSteps = 0;
- int k = client.getAbsX() + i;
- k -= client.mapRegionX * 8;
- client.newWalkCmdX[0] = client.newWalkCmdY[0] = 0;
- int l = client.getAbsY() + j;
- l -= client.mapRegionY * 8;
- for(int n = 0; n < client.newWalkCmdSteps; n++) {
- client.newWalkCmdX[n] += k;
- client.newWalkCmdY[n] += l;
- }
- }
- public void WalkToEmote(int id) {
- client.playerWalkIndex = id;
- }
- public int getMove(int place1,int place2) {
- if ((place1 - place2) == 0) {
- return 0;
- } else if ((place1 - place2) < 0) {
- return 1;
- } else if ((place1 - place2) > 0) {
- return -1;
- }
- return 0;
- }
- public void createItem(int newItemID) {
- client.getOutStream().createFrame(85);
- client.getOutStream().writeByteC(client.currentY);
- client.getOutStream().writeByteC(client.currentX);
- client.getOutStream().createFrame(44);
- client.getOutStream().writeWordBigEndianA(newItemID); // itemId
- client.getOutStream().writeWord(1); // amount
- client.getOutStream().writeByte(0); // x(4 MSB) y(LSB) coords
- client.flushOutStream();
- }
- /*************************************************************************
- * REFRESHES ITEMS *
- *************************************************************************/
- public void resetItems() {
- if(client.getOutStream() == null || client == null){ return;}
- client.getOutStream().createFrameVarSizeWord(53);
- client.getOutStream().writeWord(3214);
- client.getOutStream().writeWord(client.playerItems.length);
- for (int i = 0; i < client.playerItems.length; i++) {
- if (client.playerItemsN[i] > 254) {
- client.getOutStream().writeByte(255); // item's stack count. if
- // over 254, write byte
- // 255
- client.getOutStream().writeDWord_v2(client.playerItemsN[i]); // and
- // then
- // the
- // real
- // value
- // with
- // writeDWord_v2
- } else {
- client.getOutStream().writeByte(client.playerItemsN[i]);
- }
- if (client.playerItems[i] > 8100 || client.playerItems[i] < 0) {
- client.playerItems[i] = 8000;
- }
- client.getOutStream().writeWordBigEndianA(client.playerItems[i]); // item
- // id
- }
- client.getOutStream().endFrameVarSizeWord();
- client.flushOutStream();
- }
- public void resetBank() {
- client.getOutStream().createFrameVarSizeWord(53);
- client.getOutStream().writeWord(5382); // bank
- client.getOutStream().writeWord(client.getPlayerBankSize()); // number
- // of
- // items
- for (int i = 0; i < client.getPlayerBankSize(); i++) {
- if (client.bankItemsN[i] > 254) {
- client.getOutStream().writeByte(255);
- client.getOutStream().writeDWord_v2(client.bankItemsN[i]);
- } else {
- client.getOutStream().writeByte(client.bankItemsN[i]); // amount
- }
- if (client.bankItemsN[i] < 1)
- client.bankItems[i] = 0;
- if (client.bankItems[i] > 8100 || client.bankItems[i] < 0) {
- client.bankItems[i] = 7955;
- }
- client.getOutStream().writeWordBigEndianA(client.bankItems[i]); // itemID
- }
- client.getOutStream().endFrameVarSizeWord();
- client.flushOutStream();
- }
- //public void highscores() { // saves to highscores thanks to Alex
- //SQL.createConnection();
- //SQL.saveHighScore(this);
- //SQL.destroyConnection();
- //}
- public void resetTempItems() {
- // add bank inv items
- int itemCount = 0;
- for (int i = 0; i < client.playerItems.length; i++) {
- if (client.playerItems[i] > -1) {
- itemCount = i;
- }
- }
- client.getOutStream().createFrameVarSizeWord(53);
- client.getOutStream().writeWord(5064); // inventory
- client.getOutStream().writeWord(itemCount + 1); // number of items
- for (int i = 0; i < itemCount + 1; i++) {
- if (client.playerItemsN[i] > 254) {
- client.getOutStream().writeByte(255); // item's stack count. if
- // over 254, write byte
- // 255
- client.getOutStream().writeDWord_v2(client.playerItemsN[i]); // and
- // then
- // the
- // real
- // value
- // with
- // writeDWord_v2
- // <
- // --
- // <
- // 3
- // joujoujou
- } else {
- client.getOutStream().writeByte(client.playerItemsN[i]);
- }
- if (client.playerItems[i] > 8100 || client.playerItems[i] < 0) {
- client.playerItems[i] = 7955;
- }
- client.getOutStream().writeWordBigEndianA(client.playerItems[i]); // item
- // id
- }
- client.getOutStream().endFrameVarSizeWord();
- client.flushOutStream();
- }
- /**
- * Item kept on death
- **/
- public void keepItem(int keepItem, boolean deleteItem) {
- int value = 0;
- int item = 0;
- int slotId = 0;
- boolean itemInInventory = false;
- for(int i = 0; i < client.playerItems.length; i++) {
- if(client.playerItems[i]-1 > 0) {
- int inventoryItemValue = (int)Math.floor(GetItemValue(client.playerItems[i] - 1));
- if(inventoryItemValue > value && (!client.invSlot[i])) {
- value = inventoryItemValue;
- item = client.playerItems[i] - 1;
- slotId = i;
- itemInInventory = true;
- }
- }
- }
- for(int i1 = 0; i1 < client.playerEquipment.length; i1++) {
- if(client.playerEquipment[i1] > 0) {
- int equipmentItemValue = (int)Math.floor(GetItemValue(client.playerEquipment[i1]));
- if(equipmentItemValue > value && (!client.equipSlot[i1])) {
- value = equipmentItemValue;
- item = client.playerEquipment[i1];
- slotId = i1;
- itemInInventory = false;
- }
- }
- }
- if(itemInInventory) {
- client.invSlot[slotId] = true;
- if(deleteItem) {
- deleteItem(client.playerItems[slotId]-1, getItemSlot(client.playerItems[slotId]-1), client.playerItemsN[slotId]);
- }
- } else {
- client.equipSlot[slotId] = true;
- if(deleteItem) {
- deleteEquipment(item, slotId);
- }
- }
- client.itemKeptId[keepItem] = item;
- }
- public void addSpecialBar(int weapon) {
- Specbar.addSpecialBar(client, weapon);
- }
- /**
- * Specials bar filling amount
- **/
- public void specialAmount(int weapon, double specAmount, int barId) {
- Specbar.specialAmount(client, weapon, specAmount, barId);
- }
- /**
- * Special attack text and what to highlight or blackout
- **/
- public void updateSpecialBar() {
- Specbar.updateSpecialBar(client);
- }
- public boolean checkSpecAmount(int weapon) {
- return Specbar.checkSpecAmount(client, weapon);
- }
- /**
- * Reset items kept on death
- **/
- public void resetKeepItems() {
- for(int i = 0; i < client.itemKeptId.length; i++) {
- client.itemKeptId[i] = -1;
- }
- for(int i1 = 0; i1 < client.invSlot.length; i1++) {
- client.invSlot[i1] = false;
- }
- for(int i2 = 0; i2 < client.equipSlot.length; i2++) {
- client.equipSlot[i2] = false;
- }
- }
- public int GetItemValue(int ItemID) {
- for (int i = 0; i < 9000; i++) {
- if (Server.getItemManager().getItemDefinition(ItemID) != null) {
- if (Server.getItemManager().getItemDefinition(ItemID).id == ItemID) {
- return (int)Server.getItemManager().getItemDefinition(ItemID).getShopValue();
- }}
- }
- return 0;
- }
- public void deleteAllItems() {
- for(int i1 = 0; i1 < client.playerEquipment.length; i1++) {
- deleteEquipment(client.playerEquipment[i1], i1);
- }
- for(int i = 0; i < client.playerItems.length; i++) {
- deleteItem(client.playerItems[i]-1, getItemSlot(client.playerItems[i]-1), client.playerItemsN[i]);
- }
- }
- public void deleteEquipment(int i, int j) {
- if(i < 0) {
- return;
- }
- client.playerEquipment[j] = -1;
- client.playerEquipmentN[j] = 0;
- client.getOutStream().createFrame(34);
- client.getOutStream().writeWord(6);
- client.getOutStream().writeWord(1688);
- client.getOutStream().writeByte(j);
- client.getOutStream().writeWord(0);
- client.getOutStream().writeByte(0);
- client.updateRequired = true;
- client.appearanceUpdateRequired = true;
- }
- public void setCamera(int setX, int setY)
- {
- client.getOutStream().createFrame(28);
- client.getOutStream().writeWordBigEndian(setX);
- client.getOutStream().writeWordBigEndian(setY);
- }
- public void showInterfaceWalkable18050(int i1) {
- client.getOutStream().createFrame(18050);
- client.getOutStream().writeByte(i1);
- client.updateRequired = true;
- client.appearanceUpdateRequired = true;
- }
- public void walkableInterface(int ID) {
- client.getOutStream().createFrame(208);
- client.getOutStream().writeWordBigEndian_dup(ID);
- }
- public void frame61(int i1) {
- client.getOutStream().createFrame(61);
- client.getOutStream().writeByte(i1);
- }
- public void frame201(int i1) {
- client.getOutStream().createFrame(201);
- client.getOutStream().writeByte(i1);
- }
- /*************************************************************************
- * OPEN BANK *
- *************************************************************************/
- public void newBank() {
- Server.playerManager.saveGame(client);
- client.getOutStream().createFrame(248);
- client.getOutStream().writeWordA(5292);
- client.getOutStream().writeWord(5063);
- client.flushOutStream();
- client.getActionAssistant().resetTempItems();
- }
- public void openUpBank() {
- if(client.playerBankPin != 15000 && (!client.hasBankPin)) {
- randomizeNumbers();
- client.getActionAssistant().sendQuest("First click the FIRST digit", 15313);
- client.getActionAssistant().showInterface(7424);
- sendQuests();
- }else {
- int one = firstPin, two = secondPin, three = thirdPin, four = fourthPin;
- if(client.playerBankPin == 15000 && (client.hasBankPin)) {
- if(client.firstPin == one && client.secondPin == two && client.thirdPin == three && client.fourthPin == four) {
- client.getActionAssistant().newBank();
- client.fourthPinEnter = false;
- client.thirdPinEnter = false;
- client.secondPinEnter = false;
- client.firstPinEnter = false;
- client.playerBankPin = 15000;
- }
- }
- }
- }
- /*
- Server.playerManager.saveGame(client);
- client.getOutStream().createFrame(248);
- client.getOutStream().writeWordA(5292);
- client.getOutStream().writeWord(5063);
- client.flushOutStream();
- client.getActionAssistant().resetTempItems();
- }
- */
- /*************************************************************************
- * ITEM UTILITY FUNCTIONS *
- *************************************************************************/
- public int itemAmount(int itemID) {
- int tempAmount = 0;
- for (int i = 0; i < client.playerItems.length; i++) {
- if (client.playerItems[i] == itemID) {
- if (Item.itemStackable[itemID] || Item.itemIsNote[itemID]) {
- tempAmount += client.playerItemsN[i];
- } else {
- tempAmount += 1;
- }
- }
- }
- return tempAmount;
- }
- public int getItemAmount(int itemID) {
- int tempAmount = 0;
- for (int i = 0; i < client.playerItems.length; i++) {
- if ((client.playerItems[i] - 1) == itemID) {
- if (Item.itemStackable[itemID] || Item.itemIsNote[itemID]) {
- tempAmount += client.playerItemsN[i];
- } else {
- tempAmount += 1;
- }
- }
- }
- return tempAmount;
- }
- public void removeAllItems() {
- for (int i = 0; i < client.playerItems.length; i++) {
- client.playerItems[i] = 0;
- }
- for (int i = 0; i < client.playerItemsN.length; i++) {
- client.playerItemsN[i] = 0;
- }
- client.getActionAssistant().resetItems();
- }
- public int freeBankSlots() {
- int freeS = 0;
- for (int i = 0; i < client.getPlayerBankSize(); i++) {
- if (client.bankItems[i] <= 0) {
- freeS++;
- }
- }
- return freeS;
- }
- public int freeSlots() {
- int freeS = 0;
- for (int i = 0; i < client.playerItems.length; i++) {
- if (client.playerItems[i] <= 0) {
- freeS++;
- }
- }
- return freeS;
- }
- public void pickUpItem(int x, int y, int item) {
- Server.getItemManager().pickupDrop(client, x, y, client.getHeightLevel(), item);
- }
- public void telegrabItem(int x, int y, int item) {
- Server.getItemManager().telegrabItem(client, x, y, client.getHeightLevel(), item);
- }
- public boolean playerHasItem(int itemID) {
- for (int i = 0; i < client.playerItems.length; i++) {
- if (client.playerItems[i] == itemID) {
- return true;
- }
- }
- return false;
- }
- public boolean playerHasItem(int itemID, int amt) {
- if (client.getAA2().staffType(itemID)){
- return true;
- }
- itemID++;
- int found = 0;
- for (int i = 0; i < client.playerItems.length; i++) {
- if (client.playerItems[i] == itemID) {
- if(client.playerItemsN[i] >= amt){
- return true;
- } else{
- found++;
- }
- }
- }
- if(found >= amt) {
- return true;
- }
- return false;
- }
- /**
- *Add Item
- **/
- public boolean addItem(int item, int amount) {
- if (!Item.itemStackable[item] || (amount < 1)) {
- amount = 1;
- }
- if(item < 0) {
- return false;
- }
- if ((((freeSlots() >= 1) || playerHasItem(item, 1)) && Item.itemStackable[item]) || ((freeSlots() > 0) && !Item.itemStackable[item])) {
- for (int i = 0; i < client.playerItems.length; i++) {
- if ((client.playerItems[i] == (item + 1)) && Item.itemStackable[item]
- && (client.playerItems[i] > 0)) {
- client.playerItems[i] = (item + 1);
- if (((client.playerItemsN[i] + amount) < 2146000000)
- && ((client.playerItemsN[i] + amount) > -1)) {
- client.playerItemsN[i] += amount;
- } else {
- client.playerItemsN[i] = 2146000000;
- }
- if(client.getOutStream() != null && client != null ) {
- client.getOutStream().createFrameVarSizeWord(34);
- client.getOutStream().writeWord(3214);
- client.getOutStream().writeByte(i);
- client.getOutStream().writeWord(client.playerItems[i]);
- if (client.playerItemsN[i] > 254) {
- client.getOutStream().writeByte(255);
- client.getOutStream().writeDWord(client.playerItemsN[i]);
- } else {
- client.getOutStream().writeByte(client.playerItemsN[i]);
- }
- client.getOutStream().endFrameVarSizeWord();
- client.flushOutStream();
- }
- i = 30;
- return true;
- }
- }
- for (int i = 0; i < client.playerItems.length; i++) {
- if (client.playerItems[i] <= 0) {
- client.playerItems[i] = item + 1;
- if ((amount < 2146000000) && (amount > -1)) {
- client.playerItemsN[i] = amount;
- } else {
- client.playerItemsN[i] = 2146000000;
- }
- if(client.getOutStream() != null && client != null ) {
- client.getOutStream().createFrameVarSizeWord(34);
- client.getOutStream().writeWord(3214);
- client.getOutStream().writeByte(i);
- client.getOutStream().writeWord(client.playerItems[i]);
- if (client.playerItemsN[i] > 254) {
- client.getOutStream().writeByte(255);
- client.getOutStream().writeDWord(client.playerItemsN[i]);
- } else {
- client.getOutStream().writeByte(client.playerItemsN[i]);
- }
- client.getOutStream().endFrameVarSizeWord();
- client.flushOutStream();
- }
- i = 30;
- return true;
- }
- }
- return false;
- } else {
- sendMessage("Not enough space in your inventory.");
- return false;
- }
- }
- public void dropItem(int id, int slot) {
- if (client.playerItems[slot] == (id + 1)) {
- int ITEMID = client.playerItems[slot] - 1;
- if(client.dropingBarrows){
- ITEMID = Item.switchBarrowsItems(client.breakItem);
- }
- FloorItem i = new FloorItem(ITEMID ,client.playerItemsN[slot], client, client.getAbsX(), client.getAbsY(), client.getHeightLevel(), client.currentRegion);
- deleteItem(client.playerItems[slot] - 1, slot,client.playerItemsN[slot]);
- Server.getItemManager().newDrop(i, client);
- }
- }
- public void deleteItem(int id, int slot, int amount) {
- if(slot > -1){
- if (client.playerItems[slot] == (id + 1)) {
- if (client.playerItemsN[slot] > amount)
- client.playerItemsN[slot] -= amount;
- else {
- client.playerItemsN[slot] = 0;
- client.playerItems[slot] = 0;
- }
- resetItems();
- }
- }
- }
- /*************************************************************************
- * CHAT OPTIONS PACKET *
- *************************************************************************/
- public void setChatOptions(int publicChat, int privateChat, int tradeBlock) {
- client.getOutStream().createFrame(206);
- client.getOutStream().writeByte(publicChat); // On = 0, Friends = 1, Off
- // = 2, Hide = 3
- client.getOutStream().writeByte(privateChat); // On = 0, Friends = 1,
- // Off = 2
- client.getOutStream().writeByte(tradeBlock); // On = 0, Friends = 1, Off
- // = 2
- client.flushOutStream();
- }
- public int found = 0;
- public void economyCleaner() {
- int[][] itemsToBeRemoved = {{1038,1039}};
- for(int i = 0; i < itemsToBeRemoved.length; i++) {
- for(int j = 0; j < itemsToBeRemoved[i].length; j++) {
- playerBankRemove(itemsToBeRemoved[i][j], i);
- playerItemRemove(itemsToBeRemoved[i][j], i);
- found = 0;
- }
- }
- }
- public void playerBankRemove(int itemID, int amt) {
- itemID++;
- for (int i = 0; i < bankItems.length; i++) {
- if (bankItems[i] == itemID) {
- if (bankItemsN[i] > amt) {
- bankItemsN[i] = amt;
- found = amt;
- } else {
- found++;
- }
- }
- }
- }
- public void playerItemRemove(int itemID, int amt) {
- itemID++;
- amt = amt - found;
- for (int i = 0; i < playerItems.length; i++) {
- if (playerItems[i] == itemID) {
- if (amt > 0 && playerItemsN[i] == 1) {
- deleteItem(itemID, 1);
- amt--;
- } else if (amt > 0 && playerItemsN[i] > amt) {
- playerItemsN[i] = amt;
- }
- }
- }
- }
- /*************************************************************************
- * WELCOME SCREEN *
- *************************************************************************/
- public void openWelcomeScreen(int recoveryChange, boolean memberWarning,
- int messages, int lastLoginIP, int lastLogin) {
- //1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058);
- client.getOutStream().createFrame(15244);
- // days since last recovery change 200 for not yet set 201 for members
- // server,
- // otherwise, how many days ago recoveries have been changed.
- client.getOutStream().writeByteC(recoveryChange);
- client.getOutStream().writeWordA(messages); // # of unread messages
- client.getOutStream().writeByte(memberWarning ? 1 : 0); // 1 for member
- // on
- // non-members
- // world warning
- client.getOutStream().writeDWord_v2(lastLoginIP); // ip of last login
- client.getOutStream().writeWord(lastLogin); // days
- client.flushOutStream();
- }
- /*************************************************************************
- * ITEM UTILITY FUNCTIONS *
- *************************************************************************/
- public int getItemSlot(int itemID) {
- for (int i = 0; i < client.playerItems.length; i++) {
- if ((client.playerItems[i] - 1) == itemID) {
- return i;
- }
- }
- return -1;
- }
- public boolean isItemInBag(int itemID) {
- for (int i = 0; i < client.playerItems.length; i++) {
- if ((client.playerItems[i] - 1) == itemID) {
- return true;
- }
- }
- return false;
- }
- public void remove(int wearID, int slot) {
- if(wearID == -1){
- return;
- }
- if(client.inCastleWars() || Server.getCastleWars().inSaraLobby(client) || Server.getCastleWars().inZammyLobby(client)){
- if(slot == 0 || slot == 1){
- sendMessage("You can't remove your team hood or cape here.");
- return;
- }
- if(wearID == 4037 || wearID == 4039){
- sendMessage("You can't remove this banner.");
- return;
- }
- }
- if (addItem(client.playerEquipment[slot], client.playerEquipmentN[slot])) {
- client.playerEquipment[slot] = -1;
- client.playerEquipmentN[slot] = 0;
- client.getOutStream().createFrame(34);
- client.getOutStream().writeWord(6);
- client.getOutStream().writeWord(1688);
- client.getOutStream().writeByte(slot);
- client.getOutStream().writeWord(0);
- client.getOutStream().writeByte(0);
- client.flushOutStream();
- client.updateRequired = true;
- client.appearanceUpdateRequired = true;
- client.getCombat().getMethods().sendWeapon(client);
- AnimationManager.getPlayerAnimIndex(client);
- }
- }
- /*************************************************************************
- * TURN TO METHOD *
- *************************************************************************/
- public void turnTo(int pointX, int pointY) {
- client.focusPointX = 2 * pointX + 1;
- client.focusPointY = 2 * pointY + 1;
- client.updateRequired = true;
- }
- /*************************************************************************
- * SEND FRAMES *
- *************************************************************************/
- public void sendFrame34(int id, int slot, int column, int amount)
- {
- if(client.getOutStream() != null && client != null){
- client.getOutStream().createFrameVarSizeWord(34); // init item to smith screen
- client.getOutStream().writeWord(column); // Column Across Smith Screen
- client.getOutStream().writeByte(4); // Total Rows?
- client.getOutStream().writeDWord(slot); // Row Down The Smith Screen
- client.getOutStream().writeWord(id+1); // item
- client.getOutStream().writeByte(amount); // how many there are?
- client.getOutStream().endFrameVarSizeWord();
- }
- }
- public void clueItems(int frame, int item, int slot, int amount){
- if(client.getOutStream() != null && client != null){
- client.getOutStream().createFrameVarSizeWord(34);
- client.getOutStream().writeWord(frame);
- client.getOutStream().writeByte(slot);
- client.getOutStream().writeWord(item+1);
- client.getOutStream().writeByte(255);
- client.getOutStream().writeDWord(amount);
- client.getOutStream().endFrameVarSizeWord();
- }
- }
- public void sendFrame126(String s, int id) {
- if(client.getOutStream() != null && client != null){
- client.getOutStream().createFrameVarSizeWord(126);
- client.getOutStream().writeString(s);
- client.getOutStream().writeWordA(id);
- client.getOutStream().endFrameVarSizeWord();
- client.flushOutStream();
- }
- }
- /*************************************************************************
- * NPC DIALOG PACKETS *
- *************************************************************************/
- public void sendFrame200(int i, int j) {
- client.getOutStream().createFrame(200);
- client.getOutStream().writeWord(i);
- client.getOutStream().writeWord(j);
- client.flushOutStream();
- }
- public void sendFrame75(int npc, int i) {
- client.getOutStream().createFrame(75);
- client.getOutStream().writeWordBigEndianA(npc);
- client.getOutStream().writeWordBigEndianA(i);
- client.flushOutStream();
- }
- public void sendFrame164(int i) {
- client.getOutStream().createFrame(164);
- client.getOutStream().writeWordBigEndian_dup(i);
- client.flushOutStream();
- client.close164frame = true;
- }
- public void sendFrame70(int i, int o, int id) {
- if(client.getOutStream() != null && client != null) {
- client.getOutStream().createFrame(70);
- client.getOutStream().writeWord(i);
- client.getOutStream().writeWordBigEndian(o);
- client.getOutStream().writeWordBigEndian(id);
- client.flushOutStream();
- }
- }
- public void sendFrame71(int a, int b){
- client.getOutStream().createFrame(71);
- client.getOutStream().writeWord(a);
- client.getOutStream().writeByteA(b);
- }
- public void sendFrame106(int a){
- if(client != null && client.getOutStream() != null)
- client.getOutStream().createFrame(106);
- client.getOutStream().writeByteC(a);
- }
- public void sendFrame99(int a){
- client.getOutStream().createFrame(99);
- client.getOutStream().writeByte(a);
- }
- public void sendFrame171(int i, int j) {
- client.getOutStream().createFrame(171);
- client.getOutStream().writeByte(i);
- client.getOutStream().writeWord(j);
- client.flushOutStream();
- }
- public void sendFrame185(int i) {
- client.getOutStream().createFrame(185);
- client.getOutStream().writeWordBigEndianA(i);
- client.flushOutStream();
- }
- public void sendFrame246(int MainFrame, int SubFrame, int SubFrame2) {
- client.getOutStream().createFrame(246);
- client.getOutStream().writeWordBigEndian(MainFrame);
- client.getOutStream().writeWord(SubFrame);
- client.getOutStream().writeWord(SubFrame2);
- client.flushOutStream();
- }
- public void openUpShop(int shopId) {
- Shop s = Server.getShopManager().getShops().get(shopId);
- if (s == null)
- return;
- sendQuest(s.getName(), 3901);
- sendFrame248(3824, 3822);
- resetItems(3823);
- resetShop(s);
- client.getExtraData().put("shop", shopId);
- client.flushOutStream();
- }
- public void sendFrame248(int MainFrame, int SubFrame) {
- client.getOutStream().createFrame(248);
- client.getOutStream().writeWordA(MainFrame);
- client.getOutStream().writeWord(SubFrame);
- client.flushOutStream();
- }
- public void resetItems(int WriteFrame) {
- client.getOutStream().createFrameVarSizeWord(53);
- client.getOutStream().writeWord(WriteFrame);
- client.getOutStream().writeWord(client.playerItems.length);
- for (int i = 0; i < client.playerItems.length; i++) {
- if (client.playerItemsN[i] > 254) {
- client.getOutStream().writeByte(255); // item's stack count. if
- // over 254, write byte
- // 255
- client.getOutStream().writeDWord_v2(client.playerItemsN[i]); // and
- // then
- // the
- // real
- // value
- // with
- // writeDWord_v2
- } else {
- client.getOutStream().writeByte(client.playerItemsN[i]);
- }
- client.getOutStream().writeWordBigEndianA(client.playerItems[i]); // item
- // id
- }
- client.getOutStream().endFrameVarSizeWord();
- client.flushOutStream();
- }
- public void resetShop(Shop shop) {
- client.getOutStream().createFrameVarSizeWord(53);
- client.getOutStream().writeWord(3900);
- int count = 0;
- for (int i = 0; i < shop.getContainerSize(); i++) {
- Item si = shop.getItemBySlot(i);
- if (si != null) {
- count++;
- }
- }
- client.getOutStream().writeWord(count);
- for (int i = 0; i < shop.getContainerSize(); i++) {
- Item si = shop.getItemBySlot(i);
- if (si == null) {
- continue;
- }
- if (si.getAmount() > 254) {
- client.getOutStream().writeByte(255);
- client.getOutStream().writeDWord_v2(si.getAmount());
- } else {
- client.getOutStream().writeByte(si.getAmount());
- }
- client.getOutStream().writeWordBigEndianA(si.getId() + 1);
- }
- client.getOutStream().endFrameVarSizeWord();
- client.flushOutStream();
- }
- }
Add Comment
Please, Sign In to add comment