Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Class Player
- *
- * Version 1.0
- *
- * Thursday, August 14, 2008
- *
- * Created by Palidino76
- */
- package palidino76.rs2.players;
- import java.io.FileWriter;
- import java.io.BufferedWriter;
- import java.io.IOException;
- import java.net.Socket;
- import java.util.List;
- import java.util.ArrayList;
- import java.util.LinkedList;
- import palidino76.rs2.Engine;
- import palidino76.rs2.Server;
- import palidino76.rs2.io.PacketManager;
- import palidino76.rs2.io.Frames;
- import palidino76.rs2.net.PlayerSocket;
- import palidino76.rs2.net.SocketListener;
- import palidino76.rs2.util.*;
- import palidino76.rs2.npcs.NPC;
- import palidino76.rs2.npcs.combat.NPCPlayerCombat;
- import palidino76.rs2.players.items.PlayerWeapon;
- import palidino76.rs2.players.misc.LevelUp;
- import palidino76.rs2.players.trade.Trade;
- import palidino76.rs2.io.packets.*;
- import palidino76.rs2.players.combat.MagicNPC;
- import palidino76.rs2.Skills.runeCrafting.runecrafting;
- import palidino76.rs2.Skills.*;
- import palidino76.rs2.world.RandomMessages;
- public class Player {
- /**
- *Autoskillcape Trimming
- */
- public int[] untrimmedSkillcapes= {
- 9747, 9750, 9753, 9756, 9759, 9762,
- 9765, 9768, 9771, 9774, 9777, 9780,
- 9783, 9786, 9789, 9792, 9795, 9798,
- 9801, 9804, 9807, 9810, 9948, 12169
- };
- public int[] trimmedSkillcapes= {
- 9748, 9751, 9754, 9757, 9760, 9763,
- 9766, 9769, 9772, 9775, 9778, 9781,
- 9784, 9787, 9790, 9793, 9796, 9799,
- 9802, 9805, 9808, 9811, 9949, 12170
- };
- public boolean needsTrimmedCape() {
- int maxedOutSkills = 0;
- for (int i = 0; i < 25; i++) {
- if (this.getLevelForXP(i) == 99) {
- maxedOutSkills++;
- }
- }
- if (maxedOutSkills >= 2) {
- return true;
- } else {
- return false;
- }
- }
- public void replaceUntrimmedWithTrimmedCapes(Player p) {
- for (int i = 0; i < untrimmedSkillcapes.length; i++) {
- for (int i2 = 0; i2 < p.bankItems.length; i2++) {
- if (p.bankItems[i2] == untrimmedSkillcapes[i]) {
- p.bankItems[i2] = trimmedSkillcapes[i];
- }
- }
- for (int i3 = 0; i3 < p.items.length; i3++) {
- if (p.items[i3] == untrimmedSkillcapes[i]) {
- p.items[i3] = trimmedSkillcapes[i];
- }
- }
- if (p.equipment[1] == untrimmedSkillcapes[i]) {
- p.equipment[1] = trimmedSkillcapes[i];
- }
- }
- }
- }
- /**
- *Donator Shop
- */
- public boolean IsShopping = false;
- public int MyShopID = 0;
- public boolean UpdateShop = false;
- /*
- *Poisonning
- */
- public int poisonDelay;
- public int poisonHitCount;
- public boolean isPoisoned;
- /**
- * Random Message
- */
- public int time = 0;
- /**
- * Skills Cooking/Herb/Farming/Smithing/Mining/Fishing
- */
- public int CookTimer = -1;
- public int CookAmount = 0;
- public int CookXP = 0;
- public int CookGet = 0;
- public int CookID = 0;
- public int HerbloreTimer = -1;
- public int HerbloreType = 0;
- public int HerbType = 0;
- public int FishTimer = -1;
- public int FishAmount = 0;
- public int FishXP = 0;
- public int FishGet = 0;
- public int FishEmote = 0;
- public boolean Farm = false;
- public boolean Cooking = false;
- public boolean Smithing = false;
- public int SmithingTimer = -1;
- public int SmithingAmount = 0;
- public int SmithingXP = 0;
- public int SmithingGet = 0;
- public int SmithingID = 0;
- public int FletchTimer = -1;
- public int FletchAmount = 0;
- public int FletchXP = 0;
- public int FletchGet = 0;
- public int FletchID = 0;
- public int oreType;
- public int oreDelay;
- public boolean isMining;
- public Mining mining = new Mining(this);
- public Mining getMining() {
- return mining;
- }
- public void ResetSkillSuff()
- {
- CookTimer = -1;
- CookAmount = 0;
- CookXP = 0;
- CookGet = 0;
- CookID = 0;
- FletchTimer = -1;
- FletchAmount = 0;
- FletchXP = 0;
- FletchGet = 0;
- FishTimer = -1;
- FishAmount = 0;
- FishXP = 0;
- FishGet = 0;
- FishEmote = 0;
- FletchID = 0;
- SmithingTimer = -1;
- SmithingAmount = 0;
- SmithingXP = 0;
- SmithingGet = 0;
- SmithingID = 0;
- Cooking = false;
- Smithing = false;
- }
- public void SmeltThat(Player p, int XP, int ID, int Get)
- {
- if(Engine.playerItems.HasItemAmount(this, ID, 1) == false)
- {
- ResetSkillSuff();
- p.frames.sendMessage(this, "You ran out of ore to smelt.");
- }
- else
- {
- p.requestAnim(899, 0);
- Engine.playerItems.deleteItem(this, ID, Engine.playerItems.getItemSlot(this, ID), 1);
- Engine.playerItems.addItem(this, Get, 1);
- p.addSkillXP(XP*p.skillLvl[13] ,13);
- p.frames.sendMessage(this, "You make a metal bar.");
- SmithingTimer = 3;
- SmithingAmount -= 1;
- }
- }
- public void CookThat(Player p, int XP, int ID, int Get)
- {
- if(Engine.playerItems.HasItemAmount(this, ID, 1) == false)
- {
- ResetSkillSuff();
- p.frames.sendMessage(this, "You ran out of fish to cook.");
- }
- else
- {
- p.requestAnim(883, 0);
- Engine.playerItems.deleteItem(this, ID, Engine.playerItems.getItemSlot(this, ID), 1);
- Engine.playerItems.addItem(this, Get, 1);
- p.addSkillXP(XP*p.skillLvl[7] ,7);
- p.frames.sendMessage(this, "You cook the fish.");
- CookTimer = 3;
- CookAmount -= 1;
- }
- }
- public void FletchThat(Player p, int XP, int ID, int Get)
- {
- if(Engine.playerItems.HasItemAmount(this, ID, 1) == false)
- {
- ResetSkillSuff();
- p.frames.sendMessage(this, "You ran out of logs to carve.");
- p.requestAnim(standEmote, 0);
- }
- else
- {
- p.requestAnim(1248, 0);
- Engine.playerItems.deleteItem(this, ID, Engine.playerItems.getItemSlot(this, ID), 1);
- Engine.playerItems.addItem(this, Get, 1);
- p.addSkillXP(XP*p.skillLvl[9] ,9);
- p.frames.sendMessage(this, "You make a half bow.");
- FletchTimer = 3;
- FletchAmount -= 1;
- }
- }
- public void FishThat(Player p, int XP, int Get, int Emote)
- {
- int index = Engine.playerItems.findInvSlot(this);
- if(index >= 0)
- {
- p.requestAnim(Emote, 0);
- Engine.playerItems.addItem(this, Get, 1);
- p.addSkillXP(XP*p.skillLvl[10] ,10);
- p.frames.sendMessage(this, "You caught a fish.");
- FishTimer = 3;
- FishAmount -= 1;
- }
- }
- /**
- * Loads objects at Map region loading.
- */
- public void loadStaticObjects() {
- frames.createGlobalObject(1307, 0, 2694, 3426, 0, 10); //Maple Tree
- frames.createGlobalObject(1309, 0, 2700, 3420, 0, 10); //Yew Tree
- frames.createGlobalObject(28214, 0, 2855, 3329, 0, 10); //Donator Portal
- frames.createGlobalObject(11402, 0, 2864, 3335, 0, 10); //Bank outside cooking
- frames.createGlobalObject(16687, 0, 3041, 4834, 0, 10); //rune ess
- frames.createGlobalObject(16687, 0, 3040, 4834, 0, 10); //rune ess
- frames.createGlobalObject(16687, 0, 3039, 4834, 0, 10); //rune ess
- frames.createGlobalObject(16687, 0, 3038, 4834, 0, 10); //rune ess
- frames.createGlobalObject(11402, 0, 2822, 3346, 0, 10); //Bank @ Home
- frames.createGlobalObject(11402, 0, 2821, 3346, 0, 10); //Bank @ Home
- frames.createGlobalObject(611, 0, 2827, 3356, 0, 10); //Picnic Bench @ Home
- frames.createGlobalObject(2873, 0, 2827, 3344, 0, 10); //Saradomin Statue
- frames.createGlobalObject(2029, 0, 2879, 3335, 0, 10); //Fishing
- frames.createGlobalObject(2029, 0, 2879, 3338, 0, 10); //Fishing
- frames.createGlobalObject(2028, 0, 2879, 3339, 0, 10); //Fishing
- frames.createGlobalObject(2028, 0, 2879, 3334, 0, 10); //Fishing
- frames.createGlobalObject(2029, 0, 2877, 3342, 0, 10); //Fishing
- frames.createGlobalObject(2028, 0, 2875, 3342, 0, 10); //Fishing
- frames.createGlobalObject(2515, 0, 2876, 3330, 1, 10); //Row Boat
- frames.createGlobalObject(14859, 0, 2943, 3285, 1, 10); //Rune
- frames.createGlobalObject(14859, 0, 2943, 3286, 1, 10); //Rune
- frames.createGlobalObject(11941, 0, 2943, 3287, 1, 10); //Addy
- frames.createGlobalObject(11941, 0, 2943, 3288, 1, 10); //Addy
- frames.createGlobalObject(11944, 0, 2943, 3289, 1, 10); //Mith
- }
- /**
- * deadItemDelay
- */
- public int deadItemDelay;
- public boolean needItemDelay;
- /**
- *Agility
- */
- public boolean isJumping = false;
- public int NewEmote = 0;
- public int wallTimer1 = -1;
- public int wallTimer2 = -1;
- public int wallTimer3 = -1;
- public int wallTimer4 = -1;
- public int wallTimer5 = -1;
- public int SwingTimer1 = -1;
- public int SwingTimer2 = -1;
- public int SwingTimer3 = -1;
- public int LogTimer = -1;
- public int AgilityXP = 0;
- public int AgilityTimer = -1;
- public int NetTimer = -1;
- /**
- *Donator Shop Items
- */
- public int[] shop12 = {11724,11726,11728,11694,11696,11698,11700,11718,11720,11722,1050,1053,1055,1057,1037,1419};
- public int[] shop12n = {10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10};
- public int[] shop12p = {5,5,2,15,6,10,8,2,5,5,20,18,18,18,20,25};
- public int shopid = 0;
- public int ShopID = 0;
- public int viewings = 0;
- public int[] ShopItems = new int[32];
- public int[] ShopItemCost = new int[32];
- public int[] ShopItemsA = new int[32];
- /**
- *Followplayer
- */
- public int FamiliarID = 0;
- public int FamiliarType = 0;
- public int followPlayer = 0;
- public boolean followingPlayer = false;
- /**
- *Firemaking
- */
- public int[] firemaking = new int[4];
- public int objectX = 0;
- public int objectY = 0;
- public int objectHeight = 0;
- public int firedelay = 0;
- public void fmwalk(int x, int y) {
- int firstX = x - (mapRegionX - 6) * 8; int firstY = y - (mapRegionY - 6) * 8;
- Engine.playerMovement.resetWalkingQueue(this);
- Engine.playerMovement.addStepToWalkingQueue(firstX-1, firstY, this);
- }
- /**
- *Runecrafting
- */
- public runecrafting runecrafting = new runecrafting();
- /**
- *Magic on NPC
- */
- public MagicNPC magicNPC;
- /**
- *Woodcutting
- */
- public Woodcutting wc;
- /**
- * Lagg
- */
- public long LogOut = System.currentTimeMillis();
- public long Login = System.currentTimeMillis();
- /**
- * Starter
- */
- public int firstLog = 0;
- public int started = 0;
- /**
- * Bury Bones
- */
- public int buryDelay = 0;
- /**
- * Fishing Delay
- */
- public int FishingDelay = 0;
- /**
- * Yell Command
- */
- public int yellTimer = 0;
- /**
- * Summoning Delay
- */
- public int SummonDelay = 0;
- /**
- * Muted
- */
- public int muted = 0;
- /**
- * Dragon Claws
- */
- public int secHit2;
- public int thirdHit2;
- public int fourHit2;
- public void dClaw3(Player p) {
- NPC n = Engine.npcs[p.attackNPC];
- requestAnim(2068, 0);
- requestGFX(274, 100);
- n.appendHit((thirdHit2), 0);
- n.appendHit((fourHit2), 0);
- }
- public int clawTimer2;
- public boolean UseClaws2;
- /**
- * Vengeance
- */
- public long lastVeng;
- public boolean vengOn = false;
- /**
- * Magic.
- */
- public int mageDamage;
- public int projectileTimer = -1;
- public boolean normalHomeTele = false;
- public boolean ancientsHomeTele = false;
- public int homeTele = 0;
- public int homeTeleDelay = 0;
- public int magicDelay = 0;
- public int freezeDelay = 0;
- /**
- * Option variable
- */
- public int optionId;
- public int maxArrays = 10;
- public boolean[] optionArray = new boolean[maxArrays];
- /**
- *Eat delay
- */
- public int eatDelay = 0;
- /**
- * trade.
- */
- public Trade trade;
- /**
- * Destroy item arrays
- */
- public int[] destroyItem = new int[28];
- public int[] destroyItemAmt = new int[28];
- /**
- * Npc Dialogues Stage.
- */
- public boolean[] stage = new boolean[maxArrays];
- public int iStage;
- public int iiStage;
- /**
- * Destroy item variable
- */
- public int destroyItemInt;
- /**
- * Attacking interface data.
- */
- public int attackStyle = 0;
- public int autoRetaliate = 0;
- /**
- * Private messages.
- * Friends
- * Ignores
- */
- public boolean splitChat = false;
- public List<Long> friends = new ArrayList<Long>(200);
- public List<Long> ignores = new ArrayList<Long>(100);
- /**
- * Set Drinking
- */
- public int drinkDelay = 0;
- public int statPotRestoreDelay = 5;
- /**
- * Player's Note's.
- */
- public boolean swapAsNote = false;
- /**
- * Prayer settings.
- */
- public int prayerDrain = 100;
- public int drainRate = 0;
- public int defLow = 0;
- public int strLow = 1;
- public int atkLow = 2;
- public int rangeLow = 3;
- public int mageLow = 4;
- public int defMid = 5;
- public int strMid = 6;
- public int atkMid = 7;
- public int rapidRestore = 8;
- public int rapidHeal = 9;
- public int protItems = 10;
- public int rangeMid = 11;
- public int Hitter = 5;
- public int mageMid = 12;
- public int defHigh = 13;
- public int strHigh = 14;
- public int atkHigh = 15;
- public int prayMage = 16;
- public int prayRange = 17;
- public int prayMelee = 18;
- public int rangeHigh = 19;
- public int mageHigh = 20;
- public int retribution = 21;
- public int redemption = 22;
- public int smite = 23;
- public int praySummon = 24;
- public int chivalry = 25;
- public int piety = 26;
- public boolean prayOn[] = new boolean[27];
- /**
- * NPC combat.
- */
- public int attackNPC = 0;
- public boolean attackingNPC = false;
- /**
- * Player's Skilltab's.
- */
- public int skillMenu = 0;
- /**
- * Player's index.
- */
- public int playerId = 0;
- /**
- * Class for storing and converting bytes.
- */
- public Stream stream = new Stream(500, 5000);
- /**
- * Player's socket for handling most io operations.
- */
- public PlayerSocket socket;
- /**
- * Set to true if the player has finished the login stage.
- */
- public boolean online = false;
- /**
- * This is for Welcome Interface.
- */
- public int RandomMessage = Misc.random(9);
- public int messageCount = 1;
- public int memberCount = 0;
- /**
- * Player's username.
- */
- public String username = "null";
- /**
- * Player's password.
- */
- public String password = "";
- /**
- * Player's rights.
- */
- public int rights = 0;
- /**
- * 1 set to true means socket disconnected but logged in, both for removing the player.
- */
- public boolean[] disconnected = new boolean[2];
- /**
- * Gives quick access to the frame class.
- */
- public Frames frames = Engine.frames;
- /**
- * The region this player is in.
- */
- public int mapRegionX = 0;
- public int mapRegionY = 0;
- /**
- * The position this player is at in the map region.
- */
- public int currentX = 0;
- public int currentY = 0;
- /**
- * The slot at which each bank tab starts at
- */
- public int[] tabStartSlot = new int[11];
- /**
- * The amount of items that you have last withrawn/deposited with the X function
- */
- public int bankX = 50;
- /**
- * The tab you are viewing, used to store items in it when depositing
- */
- public int viewingBankTab = 10;
- /**
- * Skull
- */
- public boolean isSkulled;
- /**
- * Items Kept on Death
- */
- public int[] ikod = new int[3];
- /**
- * If you are withrawing items as a note
- */
- public boolean withdrawNote;
- /**
- * If you are using insert mode
- */
- public boolean insertMode;
- /**
- * Absolute coordinates this player is at.
- */
- public int absX = 0;
- public int absY = 0;
- /**
- * The height level this player is at.
- */
- public int heightLevel = 0;
- /**
- * If either are above -1 then the player is in motion.
- */
- public int walkDir = -1;
- public int runDir = -1;
- /**
- * True if the player is running, false if it isn't.
- */
- public boolean isRunning = false;
- /**
- * Set to true if the player has entered a new map region.
- */
- public boolean mapRegionDidChange = false;
- /**
- *Player config.
- */
- public boolean Mouse = false;
- public boolean Chat = false;
- public boolean Aid = false;
- /**
- * Set to true if teleported.
- */
- public boolean didTeleport = false;
- /**
- * Set Absolute coordinates to these.
- */
- public int teleportToX = -1;
- public int teleportToY = -1;
- /**
- * True if the player is Reqing an update.
- */
- public boolean updateReq = false;
- /**
- * Max number of steps this player can have pending.
- */
- public int walkingQueueSize = 50;
- public int wQueueReadPtr = 0;
- public int wQueueWritePtr = 0;
- /**
- * Positions the player is Reqing to walk to.
- */
- public int[] walkingQueueX = new int[walkingQueueSize];
- public int[] walkingQueueY = new int[walkingQueueSize];
- public int[] walkingQueue = new int[walkingQueueSize];
- /**
- * All the players within distance.
- */
- public Player[] playerList = new Player[Engine.players.length];
- /**
- * All the players stored in distance.
- */
- public byte[] playersInList = new byte[Engine.players.length];
- public int playerListSize = 0;
- /**
- * True if chatting is Reqing to be sent.
- */
- public boolean chatTextUpdateReq = false;
- public String chatText = "";
- public int chatTextEffects = 0;
- /**
- * True if an appearance update is needed.
- */
- public boolean appearanceUpdateReq = false;
- /**
- * Animation data.
- */
- public boolean animUpdateReq = false;
- public int animReq = -1;
- public int animDelay = 0;
- /**
- * GFX data.
- */
- public boolean gfxUpdateReq = false;
- public int gfxReq = -1;
- public int gfxDelay = 0;
- /**
- * Player and NPC facing data.
- */
- public boolean faceToUpdateReq = false;
- public int faceToReq = -1;
- /**
- * Damage data.
- */
- public boolean hit1UpdateReq = false;
- public boolean hit2UpdateReq = false;
- public int hitDiff1 = 0;
- public int hitDiff2 = 0;
- public int posionHit1 = 0;
- public int posionHit2 = 0;
- /**
- * Skill level data.
- */
- public int[] skillLvl = new int[25];
- public int[] skillXP = new int[25];
- public int combatLevel = 0;
- /**
- * Player headicons.
- */
- public int pkIcon = -1;
- public int prayerIcon = -1;
- public int headIcon = -1;
- /**
- * Wilderness variables.
- */
- public int wildyLevel;
- /**
- * If player updated the Wilderness level.
- */
- public boolean updatedLevel;
- /**
- * Wild ditch jumping.
- */
- public int jumpDelay = 0;
- public boolean jumpUpdateReq = false;
- public int enemyIndex;
- /**
- * Equipment data.
- */
- public int[] equipment = new int[14];
- public int[] equipmentN = new int[14];
- public int[] equipmentBonus = new int[12];
- /**
- * Player appearance.
- */
- public int[] color = new int[5];
- public int[] look = new int[7];
- public int npcType = -1;
- public int gender = 0;
- public int[] colour = new int[5];
- /**
- * Player emotes.
- */
- public int runEmote = 0x338;
- public int walkEmote = 0x333;
- public int standEmote = 0x328;
- public int attackEmote = 422;
- public int BlockEmote = 425;
- /**
- * Turn anim
- */
- public int turnAnimation = 7040;
- public int turnAnimation180 = 7045;
- public int turnAnimationC90 = 7044;
- public int turnAnimationCC90 = 7043;
- /**
- * All the NPCs within distance.
- */
- public NPC[] npcList = new NPC[Engine.npcs.length];
- /**
- * All the npcs stored in distance.
- */
- public byte[] npcsInList = new byte[Engine.npcs.length];
- public int npcListSize = 0;
- /**
- * Rebuild the entire NPC list.
- */
- public boolean rebuildNPCList = false;
- /**
- * An array storing all the players items.
- */
- public int[] items = new int[28];
- public int[] itemsN = new int[28];
- /**
- * Open interfaces, use these to confirm an interface is open when trying to use one.
- */
- public int interfaceId = -1;
- public int chatboxInterfaceId = -1;
- /**
- * The current position in the login stage.
- */
- public int loginStage = 0;
- /**
- * Click x position.
- */
- public int clickX = 0;
- /**
- * Click y position.
- */
- public int clickY = 0;
- /**
- * Click id.
- */
- public int clickId = 0;
- /**
- * True if the player is trying to pickup an item.
- */
- public boolean itemPickup = false;
- /**
- * True if the player is dead.
- */
- public boolean isDead = false;
- /**
- * Set run energy.
- */
- public boolean runEnergyUpdateReq = false;
- /**
- * Amount of current run energy.
- */
- public int runEnergy = 100;
- /**
- * Delay before run energy can increase.
- */
- public int runEnergyDelay = 0;
- /**
- * Clicked the first option on a player.
- */
- public boolean playerOption1 = false;
- /**
- * Clicked the second option on a player.
- */
- public boolean playerOption2 = false;
- /**
- * Clicked the third option on a player.
- */
- public boolean playerOption3 = false;
- /**
- * Clicked the first option on an object.
- */
- public boolean objectOption1 = false;
- /**
- * Setting the players weapon.
- */
- public PlayerWeapon playerWeapon = new PlayerWeapon(this);
- /**
- * Clicked the second option on an object.
- */
- public boolean objectOption2 = false;
- /**
- * Clicked the options on a NPC.
- */
- public boolean npcOption2 = false;
- public boolean npcOption1 = false;
- public boolean npcOption3 = false;
- /**
- * Forced chat.
- */
- public String forceChat = "";
- public boolean forceChatUpdateReq = false;
- /**
- * Stat restore delay.
- */
- public int statRestoreDelay = 75;
- /**
- * Teleporting variables.
- */
- public int teleX = -1;
- public int teleY = -1;
- public int teleDelay = -1;
- public int teleFinishGFX = 0;
- public int teleFinishGFXHeight = 0;
- public int teleFinishAnim = 0;
- /**
- * Wilderness level
- */
- public int wildLevel;
- /**
- * Face coords
- */
- public boolean updateFaceCoords = false;
- public int faceX = -1;
- public int faceY = -1;
- /**
- * Special bar data.
- */
- public boolean specialAmountUpdateReq = false;
- public int specialAmountDelay = 0;
- public int specialAmount = 100;
- public boolean SpecialBar = false;
- public boolean usingSpecial = false;
- /**
- * Delay before recieving packets.
- */
- public int clickDelay = -1;
- public int attackDelay = 5;
- public long loginTimeout = System.currentTimeMillis();
- public int attackPlayer = 0;
- public boolean attackingPlayer = false;
- public int combatDelay = 0;
- public int npcDelay = 0;
- public int deathDelay = 7;
- /**
- * Set leveled up
- */
- public boolean[] leveledUp = new boolean[24];
- public int leveledUpSkill = 0;
- /**
- * UserInput.
- */
- public UserInput input = new UserInput(this);
- /**
- * Arrays holding the items + their amounts of your bank
- */
- public int[] bankItems = new int[Engine.playerBank.SIZE];
- public int[] bankItemsN = new int[Engine.playerBank.SIZE];
- /**
- * Constructs a new Player.
- * @param socket The socket this Player belongs to.
- * @param id The index this player is at.
- */
- public Player(Socket socket, int id) {
- wc = new Woodcutting(this);
- magicNPC = new MagicNPC(this);
- this.socket = new PlayerSocket(this, socket);
- playerId = id;
- look[1] = 10;
- look[2] = 18;
- look[3] = 26;
- look[4] = 33;
- look[5] = 36;
- look[6] = 42;
- for (int i = 0; i < skillLvl.length; i++) {
- skillLvl[i] = 1;
- skillXP[i] = 0;
- skillLvl[3] = 10;
- skillXP[3] = 1154;
- }
- for (int i = 0; i < items.length; i++) {
- items[i] = -1;
- }
- for (int i = 0; i < equipment.length; i++) {
- equipment[i] = -1;
- }
- for (int i = 0; i < bankItems.length; i++) {
- bankItems[i] = -1;
- }
- trade = new Trade(this);
- }
- /**
- * This method is called every 600 milliseconds.
- * <p>While this is good for for changing integers, this
- * should not be abused. Things that can be handled else where should
- * be done in that way, such as clicking the accept button in trade
- * should update in the ActionsButton class rather than Reqing
- * an update for the process to handle.
- */
- public void process() {
- if (poisonDelay > 0) {
- poisonDelay--;
- }
- if (isPoisoned && poisonDelay == 0) {
- appendHit(Misc.random(6), 1);
- if (posionHit1 == 0) {
- posionHit1 = 4;
- }
- poisonHitCount++;
- poisonDelay = 45;
- }
- if (isPoisoned && poisonHitCount >= 7) {
- isPoisoned = false;
- poisonHitCount = 0;
- frames.sendMessage(this, "Poison has faded away..");
- }
- wc.process();
- RandomMessages RM = new RandomMessages(this);
- RM.process(this);
- if (oreDelay > 0) {
- oreDelay--;
- }
- if (oreDelay == 0 && isMining) {
- getMining().receiveOre();
- }
- if (HerbloreTimer > 0) {
- HerbloreTimer--;
- }
- if(HerbloreTimer == 0)
- {
- if(HerbloreType == 7871 || HerbloreType == 7941 || HerbloreType == 8111 || HerbloreType == 7855)
- {
- HerbloreTimer = -1;
- HerbloreType = 0;
- HerbType = 0;
- }
- else
- {
- HerbloreTimer = 30;
- if(HerbType == 1)
- {
- frames.createGlobalObject(HerbloreType+1, heightLevel, 2809, 3463, 0, 10);
- }
- else
- {
- frames.createGlobalObject(HerbloreType+1, heightLevel, 2813, 3463, 0, 10);
- }
- HerbloreType += 1;
- }
- }
- if(FishTimer > 0) FishTimer -= 1;
- if(FishTimer == 0)
- {
- FishThat(this, FishXP, FishGet, FishEmote);
- }
- if(CookTimer > 0) CookTimer -= 1;
- if(CookTimer == 0)
- {
- if(CookAmount == 0)
- {
- CookTimer = -1;
- }
- else
- {
- CookThat(this, CookXP, CookID, CookGet);
- }
- }
- if(SmithingTimer > 0) SmithingTimer -= 1;
- if(SmithingTimer == 0)
- {
- if(SmithingAmount == 0)
- {
- SmithingTimer = -1;
- }
- else
- {
- SmeltThat(this, SmithingXP, SmithingID, SmithingGet);
- }
- }
- if(FletchTimer > 0) FletchTimer -= 1;
- if(FletchTimer == 0)
- {
- if(FletchAmount == 0)
- {
- FletchTimer = -1;
- }
- else
- {
- FletchThat(this, FletchXP, FletchID, FletchGet);
- }
- }
- if (deadItemDelay <= 0 && needItemDelay) {
- needItemDelay = false;
- }
- if((absX >= 2949 && absX <= 3400 && absY >= 3525 && absY <=4462))
- {
- frames.setPlayerOption(this, "Attack", 1);
- }
- else
- {
- frames.setPlayerOption(this, "null", 1);
- }
- if (buryDelay > 0) {
- buryDelay--;
- }
- if(SwingTimer1 > 0) SwingTimer1 -= 1;
- if(SwingTimer1 == 0)
- {
- SwingTimer2 = 2;
- SwingTimer1 = -1;
- reqWalkQueue(2553,3554);
- }
- if(SwingTimer2 > 0) SwingTimer2 -= 1;
- if(SwingTimer2 == 0)
- {
- chatText = "I'm going around!";
- chatTextUpdateReq = true;
- updateReq = true;
- SwingTimer2 = -1;
- reqWalkQueue(2553,3549);
- SwingTimer3 = 4;
- }
- if(LogTimer > 0) LogTimer -= 1;
- if(LogTimer == 0)
- {
- chatText = "Easy peasy lemon squeezy...";
- chatTextUpdateReq = true;
- updateReq = true;
- LogTimer = -1;
- }
- if(SwingTimer3 > 0) SwingTimer3 -= 1;
- if(SwingTimer3 == 0)
- {
- SwingTimer3 = -1;
- reqWalkQueue(2551,3546);
- addSkillXP(75*skillLvl[16] ,16);
- frames.sendMessage(this, "You earn some Agility XP for running...");
- }
- if (firedelay > 0) { firedelay--; } if (firedelay == 0) {
- frames.createGlobalObject(-1, objectHeight, objectX, objectY, 0, 10);
- Engine.items.createGroundItem(592, 1, objectX, objectY, heightLevel, username);
- firedelay = -1; }
- if (FishingDelay > 0) {
- FishingDelay--;
- }
- if (SummonDelay > 0) {
- SummonDelay--;
- }
- if(clawTimer2 > 0) clawTimer2--;
- if(clawTimer2 == 0 && UseClaws2)
- {
- dClaw3(this);
- UseClaws2 = false;
- }
- addWildernessUpdating();
- if (disconnected[0]) {
- if (trade.getPartner() != null) {
- trade.declineTrade();
- }
- disconnected[1] = true;
- }
- if (statRestoreDelay > 0) {
- statRestoreDelay--;
- }
- if (drinkDelay > 0) {
- drinkDelay--;
- }
- if (magicDelay > 0) {
- magicDelay--;
- } else if(!magicNPC.canCast) {
- magicNPC.canCast=true;
- }
- if (homeTeleDelay > 0){
- homeTeleDelay--;
- }
- if (homeTele > 0 && homeTeleDelay <= 0 && normalHomeTele){
- homeTeleport(3221,3221);
- homeTele--;
- }
- if (freezeDelay > 0) {
- freezeDelay--;
- stopMovement(this);
- } else if (freezeDelay == 0) {// your allowed to walk, what more you want.
- }
- if (eatDelay > 0) {
- eatDelay--;
- }
- if (jumpDelay > 0) {
- jumpDelay--;
- jumpUpdateReq();
- }
- if (clickDelay > 0) {
- clickDelay--;
- }
- if (specialAmountDelay > 0) {
- specialAmountDelay--;
- } else {
- if (specialAmount < 100) {
- specialAmount++;
- specialAmountUpdateReq = true;
- }
- specialAmountDelay = 2;
- }
- if (isDead) {
- attackingPlayer = false;
- deathDelay--;
- applyDead();
- }
- if (combatDelay > 0) {
- combatDelay--;
- }
- if (teleDelay > 0) {
- teleDelay--;
- }
- if (npcDelay > 0) {
- npcDelay--;
- }
- if (runEnergyDelay > 0) {
- runEnergyDelay--;
- } else {
- if (runEnergy < 100) {
- runEnergy++;
- runEnergyUpdateReq = true;
- }
- if (runEnergy < 0) {
- frames.setConfig(this, 173, 0);
- isRunning = false;
- }
- runEnergyDelay = 4;
- }
- if (itemPickup) {
- Engine.packets.pickupItem.handlePacket(this, 0, 0);
- }
- if (playerOption1) {
- Engine.packets.playerOption1.handlePacket(this, 0, 0);
- }
- if (playerOption2) {
- Engine.packets.playerOption2.handlePacket(this, 0, 0);
- }
- if (playerOption3) {
- Engine.packets.playerOption3.handlePacket(this, 0, 0);
- }
- if (npcOption1) {
- Engine.packets.npcOption1.handlePacket(this, 0, 0);
- }
- if (npcOption2) {
- Engine.packets.npcOption2.handlePacket(this, 0, 0);
- }
- if (objectOption1) {
- Engine.packets.objectOption1.handlePacket(this, 0, 0);
- }
- if (objectOption2) {
- Engine.packets.objectOption2.handlePacket(this, 0, 0);
- }
- if (attackingPlayer) {
- Engine.playerCombat.attackPlayer(this);
- }
- if (attackingNPC) {
- Engine.playerNPCCombat.attackNPC(this);
- }
- if (runEnergyUpdateReq) {
- frames.setEnergy(this);
- runEnergyUpdateReq = false;
- }
- if (specialAmountUpdateReq) {
- checkAmount(this);
- specialAmountUpdateReq = false;
- }
- if (statRestoreDelay <= 0) {
- for (int i1 = 0; i1 < skillLvl.length; i1++) {
- int xpLvl = getLevelForXP(i1);
- if (skillLvl[i1] < xpLvl) {
- skillLvl[i1]++;
- frames.setSkillLvl(this, i1);
- } else if (skillLvl[i1] > xpLvl) {
- skillLvl[i1]--;
- frames.setSkillLvl(this, i1);
- }
- }
- statRestoreDelay = 75;
- }
- prayerDrain -= drainRate;
- if (prayerDrain <= 0 && skillLvl[5] > 0) {
- skillLvl[5]--;
- frames.setSkillLvl(this, 5);
- if (skillLvl[5] <= 0) {
- Prayer pr = new Prayer(null, BlockEmote);
- pr.resetPrayers(this);
- frames.sendMessage(this, "You have run out of prayer points.");
- }
- prayerDrain = 100;
- }
- if (teleDelay == 0) {
- teleDelay = -1;
- setCoords(teleX, teleY, heightLevel);
- requestAnim(teleFinishAnim, 0);
- requestGFX(teleFinishGFX, teleFinishGFXHeight);
- teleX = teleY = -1;
- }
- if (clickDelay == 0) {
- clickDelay = -1;
- }
- }
- public void openShop() {
- frames.setConfig2(this, 563, 4194304);
- frames.setConfig2(this, 1248, -2013265920);
- frames.showInterface(this, 278);
- // frames.setInventory(this, 763); //Inventory Set
- frames.setBankOptions(this);
- frames.setString(this, " General Store", 278, 88);//Title
- frames.setString(this, "", 200, 14);//Confirm
- frames.setItems(this, 278, 89, 94, ShopItems, ShopItemsA);
- }
- public void stopMovement(Player p) {
- if (p == null) {
- return;
- }
- if (p.teleportToX == -1 && p.teleportToY == -1) {
- p.teleportToX = p.absX;
- p.teleportToY = p.absY;
- }
- p.walkingQueueX[0] = 0;
- p.walkingQueueY[0] = 0;
- p.walkingQueue[0] = 0;
- }
- /**
- * home Teleporting method.
- */
- public void homeTeleport(int telex, int teley) {
- if (homeTele == 16) {
- requestAnim(1722, 0);
- } else if (homeTele == 15) {
- requestAnim(1723, 0);
- requestGFX(800, 0);
- } else if (homeTele == 14) {
- requestAnim(1724, 0);
- requestGFX(801, 0);
- } else if (homeTele == 13) {
- requestAnim(1725, 0);
- requestGFX(802, 0);
- } else if (homeTele == 12) {
- requestAnim(2798, 0);
- requestGFX(1703, 0);
- } else if (homeTele == 11) {
- requestAnim(2799, 0);
- requestGFX(1704, 0);
- } else if (homeTele == 10) {
- requestAnim(2800, 0);
- requestGFX(1705, 0);
- } else if (homeTele == 9) {
- requestAnim(4847, 0);
- requestGFX(1706, 0);
- } else if (homeTele == 8) {
- requestAnim(4848, 0);
- requestGFX(1707, 0);
- } else if (homeTele == 7) {
- requestAnim(4849, 0);
- requestGFX(1708, 0);
- } else if (homeTele == 6) {
- requestAnim(4849, 0);
- requestGFX(1709, 0);
- } else if (homeTele == 5) {
- requestAnim(4849, 0);
- requestGFX(1710, 0);
- } else if (homeTele == 4) {
- requestAnim(4850, 0);
- requestGFX(1711, 0);
- } else if (homeTele == 3) {
- requestAnim(4851, 0);
- requestGFX(1712, 0);
- } else if (homeTele == 2) {
- requestAnim(4852, 0);
- requestGFX(1713, 0);
- } else if (homeTele == 1) {
- homeTeleDelay = 3600;
- homeTele = 16;
- setCoords(telex, teley, 0);
- normalHomeTele = false;
- ancientsHomeTele = false;
- }
- }
- /**
- * Private messages.
- * Friends
- * Ignores
- */
- public void friendsLoggedIn() {
- for(Long friend : friends) {
- frames.sendFriend(this, friend, getWorld(friend));
- }
- long[] array = new long[ignores.size()];
- int i = 0;
- for(Long ignore : ignores) {
- if(ignore != null)
- array[i++] = ignore;
- }
- frames.sendIgnores(this, array);
- long me = Misc.stringToLong(username);
- for(Player p : Engine.players) {
- if(p == null) continue;
- if(p.friends.contains(me)) {
- p.frames.sendFriend(p, me, 66);
- }
- }
- }
- public int getWorld(long friend) {
- for(Player p : Engine.players) {
- if(p != null && p.online) {
- if(Misc.stringToLong(p.username) == friend) {
- return 66;
- }
- }
- }
- return 0;
- }
- /**
- * reqWalkQueue & reqWalkQueueBack method.
- */
- public void reqWalkQueue(int x, int y) {
- int firstX = x - (mapRegionX - 6) * 8;
- int firstY = y - (mapRegionY - 6) * 8;
- Engine.playerMovement.resetWalkingQueue(this);
- Engine.playerMovement.addStepToWalkingQueue(firstX, firstY, this);
- Engine.playerMovement.addStepToWalkingQueue(firstX, firstY+1, this);
- Engine.playerMovement.addStepToWalkingQueue(firstX, firstY+2, this);
- }
- public void reqWalkQueueBack(int x, int y) {
- int firstX = x - (mapRegionX - 6) * 8;
- int firstY = y - (mapRegionY - 6) * 8;
- Engine.playerMovement.resetWalkingQueue(this);
- Engine.playerMovement.addStepToWalkingQueue(firstX, firstY, this);
- Engine.playerMovement.addStepToWalkingQueue(firstX, firstY-1, this);
- Engine.playerMovement.addStepToWalkingQueue(firstX, firstY-2, this);
- }
- /**
- * cantattackplayer method.
- */
- public boolean canAttackPlayer(Player p) {
- if (p == null || p.isDead) {
- return false;
- } else if (p.attackPlayer < 1 || p.attackPlayer >= Engine.players.length
- || Engine.players[p.attackPlayer] == null) {
- return false;
- }
- if(absX >= 3093 && absY >= 3920 && absX <= 3120 && absY <= 3950)
- {
- return false;
- }
- return true;
- }
- /**
- * restore tabs, hide tabs, used for trading fix bug and equipements bonus...
- */
- public void restoreTabs(Player p) {
- for (int b = 16; b <= 21; b++) {
- p.frames.setInterfaceConfig(p, 548, b, false);
- }
- for (int a = 32; a <= 38; a++) {
- p.frames.setInterfaceConfig(p, 548, a, false);
- }
- p.calculateEquipmentBonus();
- p.frames.setInterfaceConfig(p, 548, 14, false);
- p.frames.setInterfaceConfig(p, 548, 31, false);
- p.frames.setInterfaceConfig(p, 548, 63, false);
- p.frames.setInterfaceConfig(p, 548, 72, false);
- }
- public void hideTabs(Player p) {
- for (int b = 16; b <= 21; b++) {
- p.frames.setInterfaceConfig(p, 548, b, true);
- }
- for (int a = 32; a <= 38; a++) {
- p.frames.setInterfaceConfig(p, 548, a, true);
- }
- p.calculateEquipmentBonus();
- p.frames.setInterfaceConfig(p, 548, 14, true);
- p.frames.setInterfaceConfig(p, 548, 31, true);
- p.frames.setInterfaceConfig(p, 548, 63, true);
- p.frames.setInterfaceConfig(p, 548, 72, true);
- }
- public void calculateIKOD() {
- int amountOfKeptItems = isSkulled ? (prayOn[protItems] ? 1 : 0) : (prayOn[protItems] ? 4 : 3);
- int[] allItems = new int[items.length + equipment.length];
- int[] allItemsN = new int[itemsN.length + equipmentN.length];
- int[] keptItems = new int[amountOfKeptItems];
- int[] toAdd = new int[keptItems.length];
- if (items == null){
- System.arraycopy(equipment, 0, allItems, items.length, equipment.length);
- System.arraycopy(equipmentN, 0, allItemsN, itemsN.length, equipmentN.length);
- } else {
- System.arraycopy(items, 0, allItems, 0, items.length);
- System.arraycopy(itemsN, 0, allItemsN, 0, itemsN.length);
- System.arraycopy(equipment, 0, allItems, items.length, equipment.length);
- System.arraycopy(equipmentN, 0, allItemsN, itemsN.length, equipmentN.length);
- }
- for (int i = 0; i < keptItems.length; i++) {
- int index = 0;
- int standing = 0;
- for (int j = 0; j < allItems.length; j++) {
- if (allItems[j] < 1) {
- continue;
- }
- int price = (int)Math.round(1.10 * (1 * Engine.items.getItemValue(allItems[j])));
- if (price > standing) {
- index = j;
- standing = price;
- }
- }
- keptItems[i] = allItems[index];
- toAdd[i] = allItems[index];
- allItemsN[index]--;
- if (allItemsN[index] == 0) {
- allItems[index] = 0;
- }
- }
- for (int i = 0; i < keptItems.length; i++) {
- ikod[i] = keptItems[i];
- if (ikod[i] == 0) ikod[i] = 6564;
- }
- }
- public void noMapdata() {
- setCoords(2827,3343,0);
- Engine.playerMovement.getNextPlayerMovement(this);
- this.frames.setMapRegion(this);
- this.frames.sendMessage(this, "Missing mapdata.Please contact Your Administrator");
- }
- public LinkedList<Integer> getRegion() {
- LinkedList<Integer> regions = new LinkedList<Integer>();
- boolean forceSend = true;
- if ((((mapRegionX / 8) == 48) || ((mapRegionX / 8) == 49)) && ((mapRegionY / 8) == 48)) {
- forceSend = false;
- }
- if (((mapRegionX / 8) == 48) && ((mapRegionY / 8) == 148)) {
- forceSend = false;
- }
- for (int xCalc = (mapRegionX - 6) / 8; xCalc <= ((mapRegionX + 6) / 8); xCalc++) {
- for (int yCalc = (mapRegionY - 6) / 8; yCalc <= ((mapRegionY + 6) / 8); yCalc++) {
- if (forceSend || ((yCalc != 49) && (yCalc != 149) && (yCalc != 147) && (xCalc != 50) && ((xCalc != 49) || (yCalc != 47)))) {
- regions.add(yCalc + (xCalc << 1786653352));
- }
- }
- }
- return regions;
- }
- /**
- * Ip Banning.
- */
- public void appendIPBan() {
- BufferedWriter bw = null;
- try {
- bw = new BufferedWriter(new FileWriter("./data/banned/bannedhosts.dat", true));
- bw.write(SocketListener.getAddress(this.socket.socket));
- bw.newLine();
- bw.flush();
- } catch (IOException ioe) {
- } finally {
- if (bw != null) {
- try {
- bw.close();
- } catch (IOException ioe2) {
- }
- }
- }
- }
- /**
- * Ip Mute.
- */
- public void appendIPMute() {
- BufferedWriter bw = null;
- try {
- bw = new BufferedWriter(new FileWriter("./data/banned/mutedhosts.dat", true));
- bw.write(SocketListener.getAddress(this.socket.socket));
- bw.newLine();
- bw.flush();
- } catch (IOException ioe) {
- } finally {
- if (bw != null) {
- try {
- bw.close();
- } catch (IOException ioe2) {
- }
- }
- }
- }
- /**
- * Bann.
- */
- public void appendToBanned(String player) {
- BufferedWriter bw = null;
- try {
- bw = new BufferedWriter(new FileWriter("./data/banned/bannedusers.dat", true));
- bw.write(player);
- bw.newLine();
- bw.flush();
- } catch (IOException ioe) {
- } finally {
- if (bw != null) {
- try {
- bw.close();
- } catch (IOException ioe2) {
- }
- }
- }
- }
- /**
- * Mute The Player
- */
- public void appendToMuted(String player) {
- BufferedWriter bw = null;
- try {
- bw = new BufferedWriter(new FileWriter("./data/banned/mutedusers.dat", true));
- bw.write(player);
- bw.newLine();
- bw.flush();
- } catch (IOException ioe) {
- } finally {
- if (bw != null) {
- try {
- bw.close();
- } catch (IOException ioe2) {
- }
- }
- }
- }
- /**
- * Checks if a user is Muted
- * @param username The name to check.
- * @return Returns if the name was found.
- */
- public boolean checkMutedUsers(String username) {
- if (username == null) {
- return true;
- }
- for (int i = 0; i < Server.mutedUsers.length; i++) {
- if (Server.mutedUsers[i] != null && username.equalsIgnoreCase(Server.mutedUsers[i])) {
- return true;
- }
- }
- return false;
- }
- /**
- * Checks to make sure the host isnt IP muted.
- */
- public boolean checkMutedHosts(String hostName) {
- if (hostName == null) {
- return true;
- }
- for (int i = 0; i < SocketListener.mutedHosts.length; i++) {
- if (SocketListener.mutedHosts[i] != null && (hostName.startsWith(SocketListener.mutedHosts[i]) || hostName.equals(SocketListener.mutedHosts[i]))) {
- return true;
- }
- }
- return false;
- }
- /*================================Start of Wild Methods================================*\
- /**
- * Calculates wilderness Levels.
- */
- public int getWildernessLevel() {
- wildLevel = (absY - 3520) / 8 + 1;
- if (wildLevel < 1)
- wildLevel = 1;
- return wildLevel;
- }
- /**
- * the wilderness Area.
- */
- public boolean wildy() {
- if((absX >= 2949 && absX <= 3400 && absY >= 3525 && absY <=4462))
- return true;
- else
- return false;
- }
- public void faceCoords(int x, int y) {
- faceX = 2 * x + 1;
- faceY = 2 * y + 1;
- updateFaceCoords = true;
- updateReq = true;
- }
- /**
- * Update the wilderness levels.
- */
- public void addWildernessUpdating() {
- frames.setString(this, "Level: "+getWildernessLevel(), 381, 1);
- if (updatedLevel != Engine.wildernessArea(absX, absY)) {
- updatedLevel = Engine.wildernessArea(absX, absY);
- if (updatedLevel) {
- frames.setOverlay(this, 381);
- } else {
- wildyLevel = 0;
- frames.removeOverlay(this);
- }
- }
- }
- /*================================END of Wild Methods================================*\
- /**
- * Get xp based on your level.
- * @param skillId The skill level to get the level based off XP for.
- * @return Returns the level based on the amount of XP the specified skill has.
- */
- public int getLevelForXP(int skillId) {
- int exp = skillXP[skillId];
- int points = 0;
- int output = 0;
- for (int lvl = 1; lvl < 100; lvl++) {
- points += Math.floor((double)lvl + 300.0 * Math.pow(2.0, (double)lvl / 7.0));
- output = (int)Math.floor(points / 4);
- if ((output - 1) >= exp) {
- return lvl;
- }
- }
- return 99;
- }
- public void jumpUpdateReq() {
- if (jumpDelay >= 1) {
- runEmote = walkEmote = 2750;
- updateReq = appearanceUpdateReq = true;
- }
- if (jumpDelay <= 0) {
- playerWeapon.setWeapon();
- jumpDelay = 0;
- updateReq = appearanceUpdateReq = true;
- }
- jumpUpdateReq = false;
- }
- public void afterDeathUpdateReq() {
- for (int i = 0; i < skillLvl.length; i++) {
- skillLvl[i] = getLevelForXP(i);
- frames.setSkillLvl(this, i);
- }
- Prayer pr = new Prayer(null, BlockEmote);
- pr.resetPrayers(this);
- runEnergy = 100;
- specialAmount = 100;
- deathDelay = 8;
- runEnergyUpdateReq = true;
- specialAmountUpdateReq = true;
- isDead = false;
- }
- /**
- * Death data.
- */
- public void appendItemPK(Player p) {
- Player p2 = Engine.players[p.attackPlayer];
- if (p2 == null) {
- return;
- }
- for (int i = 0; i < items.length; i++) {
- if (items[i] > 0) {
- if (Engine.items.isUntradable(items[i])) {
- Engine.items.createGroundItem(items[i], itemsN[i], absX,
- absY, heightLevel, username);
- } else {
- Engine.items.createGroundItem(items[i], itemsN[i], absX,
- absY, heightLevel, p2.username);
- }
- items[i] = -1;
- itemsN[i] = 0;
- }
- }
- Engine.items.createGroundItem(526, 1, absX, absY, heightLevel, p2.username);
- for (int i = 0; i < equipment.length; i++) {
- if (equipment[i] > 0) {
- if (Engine.items.isUntradable(equipment[i])) {
- Engine.items.createGroundItem(equipment[i], equipmentN[i],
- absX, absY, heightLevel, username);
- } else {
- Engine.items.createGroundItem(equipment[i], equipmentN[i],
- absX, absY, heightLevel, p2.username);
- }
- equipment[i] = -1;
- equipmentN[i] = 0;
- }
- }
- frames.setItems(this, 149, 0, 93, items, itemsN);
- frames.setItems(this, 387, 28, 94, equipment, equipmentN);
- playerWeapon.setWeapon();
- calculateEquipmentBonus();
- }
- public void applyDead() {
- requestAnim(7197, 0);
- if(deathDelay <= 0)
- {
- frames.removeOverlay(this);
- frames.sendMessage(this, "Oh dear you are dead!");
- appendItemPK(this);
- isDead = false;
- afterDeathUpdateReq();
- attackingPlayer = false;
- requestFaceTo(65535);
- pkIcon = -1;
- setCoords(2827,3343,0);
- for(int i = 0; i < skillLvl.length; i++)
- {
- skillLvl[i] = getLevelForXP(i);
- frames.setSkillLvl(this, i);
- }
- requestAnim(-1, 0);
- updateReq = true;
- appearanceUpdateReq = true;
- faceToUpdateReq = true;
- }
- }
- /**
- * Add experiance to a specific skill.
- * @param amount The amoubt of XP you want to add.
- * @param skill The skill id you want to add it to.
- */
- public void addSkillXP(double amount, int skill) {
- if(skill > skillXP.length || skill < 0) {
- return;
- }
- int oldLevel = getLevelForXP(skill);
- skillXP[skill] += amount;
- int newLevel = getLevelForXP(skill);
- if(oldLevel < newLevel) {
- if(skill == 3) {
- updateHP(newLevel - oldLevel, true);
- } else {
- skillLvl[skill] += (newLevel - oldLevel);
- }
- frames.setSkillLvl(this, skill);
- new LevelUp(this, skill);
- appearanceUpdateReq = true;
- updateReq = true;
- }
- frames.setSkillLvl(this, skill);
- if (needsTrimmedCape()) {
- replaceUntrimmedWithTrimmedCapes();
- frames.setItems(this, 149, 0, 93, this.items, this.itemsN);
- frames.setItems(this, -1, 64207, 95, this.bankItems, this.bankItemsN);
- frames.setItems(this, 387, 28, 93, this.equipment, this.equipmentN);
- this.appearanceUpdateReq = true;
- this.updateReq = true;
- }
- }
- /**
- * Calculates equipment bonus.
- */
- public void calculateEquipmentBonus() {
- for (int i = 0; i < equipmentBonus.length; i++) {
- equipmentBonus[i] = 0;
- }
- for (int i = 0; i < equipment.length; i++) {
- if (equipment[i] > -1) {
- for (int j = 0; j < Engine.items.maxListedItems; j++) {
- if (Engine.items.itemLists[j] != null) {
- if (Engine.items.itemLists[j].itemId == equipment[i]) {
- for (int k = 0; k < equipmentBonus.length; k++) {
- equipmentBonus[k] += Engine.items.itemLists[j].bonuses[k];
- }
- break;
- }
- }
- }
- }
- }
- }
- /**
- * Writes the equipment bonus.
- */
- public void setEquipmentBonus() {
- String[] bonusNames = Misc.bonusNames;
- int id = 35;
- for (int i = 0; i < equipmentBonus.length; i++) {
- frames.setString(this, bonusNames[i] + ": " + (equipmentBonus[i] >= 0 ? "+" : "") + equipmentBonus[i], 667, id++);
- if (id == 45) {
- id = 47;
- }
- }
- frames.setString(this, "Summoning: +0", 667, 45);
- }
- public void openBank() {
- frames.setConfig2(this, 563, 4194304);
- frames.setConfig2(this, 1248, -2013265920);
- frames.setConfig(this, 115, withdrawNote ? 1 : 0);
- frames.setConfig(this, 305, insertMode ? 1 : 0);
- Engine.playerBank.sendTabConfig(this);
- frames.showInterface(this, 762);
- frames.setInventory(this, 763);
- frames.setBankOptions(this);
- frames.setString(this, "The Carrscape bank", 762, 24);
- frames.setItems(this, -1, 64207, 95, bankItems, bankItemsN);
- frames.setItems(this, -1, 64209, 93, items, itemsN);
- //hideTabs(this);
- viewingBankTab = 10;
- frames.setString(this, ""+Engine.playerBank.getFreeBankSlot(this), 762, 97);
- frames.setString(this, ""+Engine.playerBank.SIZE, 762, 98);
- }
- public void updateHP(int chHp, boolean heal) {
- if (heal) {
- skillLvl[3] += chHp;
- if (skillLvl[3] > getLevelForXP(3)) {
- skillLvl[3] = getLevelForXP(3);
- }
- } else if (!heal) {
- skillLvl[3] -= chHp;
- if (skillLvl[3] <= 0) {
- skillLvl[3] = 0;
- isDead = true;
- Engine.playerMovement.resetWalkingQueue(this);
- }
- }
- frames.setSkillLvl(this, 3);
- }
- public void updatePRAY(int chPR, boolean pray) {
- if (pray) {
- skillLvl[5] += chPR;
- if (skillLvl[5] > getLevelForXP(5)) {
- skillLvl[5] = getLevelForXP(5);
- }
- }
- frames.setSkillLvl(this, 5);
- }
- /**
- * Teleports a player.
- * @param x The x coordinate to teleport to.
- * @param y The y coordinate to teleport to.
- * @param height The height level to teleport to.
- * @param delay The delay before the teleport is done.
- * @param distance The offset you can teleport to, such as 1 for a max offset of x +/- 1 and y +/- 1.
- * @param emoteStart The emote to do right away.
- * @param emoteEnd The emote to do after teleporting.
- * @param gfxStart The graphic to do right away.
- * @param gfxStartH The height level to create the start graphic at.
- * @param gfxEnd The graphic to do after the teleport is done.
- * @param gfxEndH The finish graphic height.
- */
- public void teleportTo(int x, int y, int height, int delay, int distance, int emoteStart, int emoteEnd, int gfxStart,
- int gfxStartH, int gfxEnd, int gfxEndH) {
- wc.resetWoodcutting();
- ResetSkillSuff();
- itemPickup = false;
- playerOption1 = false;
- playerOption2 = false;
- playerOption3 = false;
- npcOption1 = false;
- npcOption2 = false;
- objectOption1 = false;
- objectOption2 = false;
- attackingPlayer = false;
- clickDelay = delay + 2;
- teleDelay = delay;
- if (distance > 0) {
- int xType = Misc.random(1);
- int yType = Misc.random(1);
- int xOffset = Misc.random(distance);
- int yOffset = Misc.random(distance);
- if (xType == 1)
- x += -xOffset;
- else
- x += xOffset;
- if(yType == 1)
- y += -yOffset;
- else
- y += yOffset;
- }
- teleX = x;
- teleY = y;
- heightLevel = height;
- Engine.playerMovement.resetWalkingQueue(this);
- requestAnim(emoteStart, 0);
- requestGFX(gfxStart, gfxStartH);
- teleFinishGFX = gfxEnd;
- teleFinishGFXHeight = gfxEndH;
- teleFinishAnim = emoteEnd;
- }
- /**
- * Set the player's coordinates.
- * @param x The x coordinate to teleport to.
- * @param y The y coordinate to teleport to.
- */
- public void setCoords(int x, int y, int height) {
- ResetSkillSuff();
- wc.resetWoodcutting();
- teleportToX = x;
- teleportToY = y;
- heightLevel = height;
- didTeleport = true;
- }
- /**
- * Req an animation for this player.
- * @param animId The amination to perform.
- * @param animD The delay before doing the animation.
- */
- public void requestAnim(int animId, int animD) {
- animReq = animId;
- animDelay = animD;
- animUpdateReq = true;
- updateReq = true;
- }
- /**
- * Req an graphic for this player.
- * @param gfxId The graphic to perform.
- * @param gfxD The delay or height or the gfx depending on the value.
- */
- public void requestGFX(int gfxId, int gfxD) {
- if (gfxD >= 100) {
- gfxD += 6553500;
- }
- gfxReq = gfxId;
- gfxDelay = gfxD;
- gfxUpdateReq = true;
- updateReq = true;
- }
- /**
- * Req this player faces NPC or player.
- * @param faceId The target to face.
- */
- public void requestFaceTo(int faceId) {
- faceToReq = faceId;
- faceToUpdateReq = true;
- updateReq = true;
- }
- /**
- * Append damage.
- */
- public void appendHit(int damage, int posion) {
- if (damage > skillLvl[3]) {
- damage = skillLvl[3];
- }
- updateHP(damage, false);
- if (!hit1UpdateReq) {
- hitDiff1 = damage;
- posionHit1 = posion;
- hit1UpdateReq = true;
- } else {
- hitDiff2 = damage;
- posionHit2 = posion;
- hit2UpdateReq = true;
- }
- updateReq = true;
- }
- /**
- * Force chat text.
- */
- public void requestForceChat(String s) {
- forceChat = s;
- forceChatUpdateReq = true;
- updateReq = true;
- }
- public void objects() {
- frames.createGlobalObject(1307, 0, 2694, 3426, 0, 10); //Maple Tree
- frames.createGlobalObject(1309, 0, 2700, 3420, 0, 10); //Yew Tree
- frames.createGlobalObject(28214, 0, 2855, 3329, 0, 10); //Donator Portal
- frames.createGlobalObject(11402, 0, 2864, 3335, 0, 10); //Bank outside cooking
- frames.createGlobalObject(11402, 0, 2822, 3346, 0, 10); //Bank @ Home
- frames.createGlobalObject(11402, 0, 2821, 3346, 0, 10); //Bank @ Home
- frames.createGlobalObject(611, 0, 2827, 3356, 0, 10); //Picnic Bench @ Home
- frames.createGlobalObject(16687, 0, 3041, 4834, 0, 10); //rune ess
- frames.createGlobalObject(16687, 0, 3040, 4834, 0, 10); //rune ess
- frames.createGlobalObject(16687, 0, 3039, 4834, 0, 10); //rune ess
- frames.createGlobalObject(16687, 0, 3038, 4834, 0, 10); //rune ess
- frames.createGlobalObject(2873, 0, 2827, 3344, 0, 10); //Saradomin Statue
- frames.createGlobalObject(2029, 0, 2879, 3335, 0, 10); //Fishing
- frames.createGlobalObject(2029, 0, 2879, 3338, 0, 10); //Fishing
- frames.createGlobalObject(2028, 0, 2879, 3339, 0, 10); //Fishing
- frames.createGlobalObject(2028, 0, 2879, 3334, 0, 10); //Fishing
- frames.createGlobalObject(2029, 0, 2877, 3342, 0, 10); //Fishing
- frames.createGlobalObject(2028, 0, 2875, 3342, 0, 10); //Fishing
- frames.createGlobalObject(2515, 0, 2876, 3330, 0, 10); //Row Boat
- frames.createGlobalObject(14859, 0, 2943, 3285, 1, 10); //Rune
- frames.createGlobalObject(14859, 0, 2943, 3286, 1, 10); //Rune
- frames.createGlobalObject(11941, 0, 2943, 3287, 1, 10); //Addy
- frames.createGlobalObject(11941, 0, 2943, 3288, 1, 10); //Addy
- frames.createGlobalObject(11944, 0, 2943, 3289, 1, 10); //Mith
- }
- /**
- * Checks special amount and gets config.
- */
- public void checkAmount(Player p) {
- int amount = p.specialAmount;
- if (amount == 100) {
- p.frames.setConfig(p, 300, 1000);
- } else if (amount >= 80){
- p.frames.setConfig(p, 300, 800);
- } else if (amount >= 60){
- p.frames.setConfig(p, 300, 600);
- } else if (amount >= 50){
- p.frames.setConfig(p, 300, 500);
- } else if (amount >= 40){
- p.frames.setConfig(p, 300, 400);
- } else if (amount >= 20){
- p.frames.setConfig(p, 300, 200);
- } else if (amount >= 0){
- p.frames.setConfig(p, 300, 0);
- } else {
- // nothing
- }
- }
- /**
- * Prepare player for removal.
- */
- public void destruct() {
- stream = null;
- long me = Misc.stringToLong(username);
- for(Player p : Engine.players) {
- if(p == null) continue;
- if(p.friends.contains(me)) {
- p.frames.sendFriend(p, me, 0);
- }
- }
- try {
- socket.input.close();
- socket.output.close();
- socket.socket.close();
- } catch (Exception e) {
- }
- socket.input = null;
- socket.output = null;
- socket.socket = null;
- socket = null;
- absX = absY = mapRegionX = mapRegionY = -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement