Thread: Help on playercombat!

Results 1 to 4 of 4
  1. #1 Help on playercombat! 
    Registered Member
    Santaher0's Avatar
    Join Date
    Sep 2008
    Posts
    2,033
    Thanks given
    324
    Thanks received
    49
    Rep Power
    1282
    when i try to attack someone it always give this error in my run.bat
    Starting server on port: 43594
    Connection recieved from: 127.0.0.1
    Connection recieved from: 127.0.0.1
    Connection recieved from: 127.0.0.1
    Connection recieved from: 127.0.0.1
    Exception in thread "Thread-0" java.lang.ArrayIndexOutOfBoundsException: 23271
    at palidino76.rs2.players.combat.PlayerCombat.attackP layer(PlayerCombat.
    java:50)
    at palidino76.rs2.players.Player.process(Player.java: 1718)
    at palidino76.rs2.Engine.run(Engine.java:204)
    at java.lang.Thread.run(Thread.java:619)
    I tried to add other playercombat but doesn't work either could someone help me plz?
    OW yea i'm using gods army V2 or xeloxoft
    - Support my project ArkScape

    - Santaher0's MusicBot

    - Santaher0's MovieBot
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Mar 2008
    Posts
    2,072
    Thanks given
    21
    Thanks received
    74
    Rep Power
    1841
    gebruik deze;
    Code:
    /*
     * Class Player
     *
     * Version 1.0
     *
     * Thursday, August 14, 2008
     *
     * Created by Palidino76
     */
    
    package palidino76.rs2.players;
    
    
    import java.net.Socket;
    import palidino76.rs2.Engine;
    import palidino76.rs2.io.Frames;
    import palidino76.rs2.net.PlayerSocket;
    import palidino76.rs2.util.Stream;
    import palidino76.rs2.util.Misc;
    import palidino76.rs2.npcs.NPC;
    import palidino76.rs2.npcs.loading.LoadNPCLists;
    import palidino76.rs2.players.items.PlayerWeapon;
    import palidino76.rs2.players.combat.PlayerCombat;
    import palidino76.rs2.io.packets.Prayer;
    import palidino76.rs2.Skills.*;
    import palidino76.rs2.content.*;
    
    
    public class Player {
    public int followPlayer = 0;
        public boolean followingPlayer = false;
    	 public void WalkingTo(int x, int y) {
            int firstX = x - (mapRegionX - 6) * 8;
            int firstY = y - (mapRegionY - 6) * 8;
            Engine.playerMovement.resetWalkingQueue(this);
            Engine.playerMovement.addToWalkingQueue(this, firstX, firstY);
                appearanceUpdateReq = true;
                updateReq = true;
        }
    	public int yellTimer = 0;
    	public int suggestionTimer = 0;
    	/**
         * Set leveled up
         */
    	 public int bountyOpp = 0;
    public boolean bountyArea(){
    		return absX >= 3085 && absX <= 3185 && absY >= 3662 && absY <= 3765;
    	}
    	public boolean[] leveledUp = new boolean[24];
    	public int leveledUpSkill = 0;
    	public int skillMenu = 0;
    
        public int trainingSkill = 0;
    	public int SaraFL = 0;
    	public int ZamFL = 0;
    public int cwTimer;
    public int cwzamTimer;
    public int tPartner = 0;
    	public int[] tradeItems = new int[28];
    	public int[] tradeItemsN = new int[28];
    	public boolean[] tAccept = {false,false};
    	public int tradePlayer = 0;
    	public boolean normalHomeTele = false;
    public boolean ancientsHomeTele = false;
    public int homeTele = 0;
    public int homeTeleDelay = 0;
    public double arenaSpellPower = 1;
    
    public void homeTeleport(int telex, int teley) {
    		if (homeTele == 15) {
    			requestAnim(1722, 0);
    		} else if (homeTele == 14) {
    			requestAnim(1723, 0);
    			requestGFX(800, 0);
    		} else if (homeTele == 13) {
    			requestAnim(1724, 0);
    			requestGFX(801, 0);
    		} else if (homeTele == 12) {
    			requestAnim(1725, 0);
    			requestGFX(802, 0);
    		} else if (homeTele == 11) {
    			requestAnim(2798, 0);
    			requestGFX(1703, 0);
    		} else if (homeTele == 10) {
    			requestAnim(2799, 0);
    			requestGFX(1704, 0);
    		} else if (homeTele == 9) {
    			requestAnim(2800, 0);
    			requestGFX(1705, 0);
    		} else if (homeTele == 8) {
    			requestAnim(4847, 0);
    			requestGFX(1706, 0);
    		} else if (homeTele == 7) {
    			requestAnim(4848, 0);
    			requestGFX(1707, 0);
    		} else if (homeTele == 6) {
    			requestAnim(4849, 0);
    			requestGFX(1708, 0);
    		} else if (homeTele == 5) {
    			requestAnim(4849, 0);
    			requestGFX(1709, 0);
    		} else if (homeTele == 4) {
    			requestAnim(4849, 0);
    			requestGFX(1710, 0);
    		} else if (homeTele == 3) {
    			requestAnim(4850, 0);
    			requestGFX(1711, 0);
    		} else if (homeTele == 2) {
    			requestAnim(4851, 0);
    			requestGFX(1712, 0);
    		} else if (homeTele == 1) {
    			requestAnim(4852, 0);
    			requestGFX(1713, 0);
                            setCoords(telex, teley, 0);
                            normalHomeTele = false;
                            ancientsHomeTele = false;
    			homeTeleDelay = 3600;
                            homeTele = 15;
    		}
    	}
    
        /**
         * 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;
    
        /**
         * Player's username.
         */
        public String username = "null";
    
        /**
         * Player's password.
         */
        public String password = "";
    
          /**
         * Player Character Design screen
         */
    	public void resetCharScreenTabs(Player p) {
    		mouseOptions = false;
    		genderOptions = false;
    		headOptions = false;
    		bodyOptions = false;
    	}
    
    	public Woodcutting wc;
    	
    public Mining mi;
    
    	private boolean mouseOptions = false;
    	private boolean genderOptions = false;
    	private boolean headOptions = false;
    	private boolean bodyOptions = false;
    	
    
        public void design(Player p, int button) {
    		switch (button) {
    /*---------Screen Tabs-------*/
    
    	case 14:
    		resetCharScreenTabs(this);
    		mouseOptions = true;
    	break;
    
    	case 16:
    		resetCharScreenTabs(this);
    		genderOptions = true;
    	break;
    
    	case 18:
    		resetCharScreenTabs(this);
    		headOptions = true;
    	break;
    
    	case 20:
    		resetCharScreenTabs(this);
    		bodyOptions = true;
    	break;
    
    /*-------End Screen Tabs-----*/
    
    /*--------Mouse Options------*/
    
    	case 37://two buttons
    	break;
    
    	case 40://one button
    	break;
    
    	case 46://next button
    	break;
    
    /*------End Mouse Options----*/
    
    /*-----------Gender----------*/
    
    	case 49://Male
                        p.look[0] = 7; // Hair
                        p.look[1] = 16; // Beard
                        p.look[2] = 18; // Torso
                        p.look[3] = 28; // Arms
                        p.look[4] = 34; // Bracelets
                        p.look[5] = 38; // Legs
                        p.look[6] = 42; // Shoes
                        p.gender = 0;
                        p.appearanceUpdateReq = true;
                        p.updateReq = true;
    	break;
    
    	case 52://Female
                        p.look[0] = 48; // Hair
                        p.look[1] = 1000; // Beard
                        p.look[2] = 57; // Torso
                        p.look[3] = 64; // Arms
                        p.look[4] = 68; // Bracelets
                        p.look[5] = 77; // Legs
                        p.look[6] = 80; // Shoes
                        p.gender = 1;
                        p.appearanceUpdateReq = true;
                        p.updateReq = true;
    	break;
    
    	case 56://back button
    	break;
    
    	case 58://next button
    	break;
    
    /*---------End Gender--------*/
    
    /*--------Head Options-------*/
    
    	case 61://Skin colour
    	break;
    
    	case 62://Hair colour
    	break;
    
    	case 92://hair -1
    		p.look[0] = p.look[0] - 1;
                    p.appearanceUpdateReq = true;
                    p.updateReq = true;
    	break;
    
    	case 93://hair +1
    		p.look[0] = p.look[0] + 1;
                    p.appearanceUpdateReq = true;
                    p.updateReq = true;
    	break;
    
    	case 97://facial hair -1
    		p.look[1] = p.look[1] - 1;
                    p.appearanceUpdateReq = true;
                    p.updateReq = true;
    	break;
    
    	case 98://facial hair +1
    		p.look[1] = p.look[1] + 1;
                    p.appearanceUpdateReq = true;
                    p.updateReq = true;
    	break;
    
    	case 100://char hair color
    	break;
    
    	case 101://char hair color
    	break;
    
    	case 102://char hair color
    	break;
    
    	case 103://char hair color
    	break;
    
    	case 104://char hair color
    	break;
    
    	case 105://char hair color
    	break;
    
    	case 106://char hair color
    	break;
    
    	case 107://char hair color
    	break;
    
    	case 108://char hair color
    	break;
    
    	case 109://char hair color
    	break;
    
    	case 110://char hair color
    	break;
    
    	case 111://char hair color
    	break;
    
    	case 112://char hair color
    	break;
    
    	case 113://char hair color
    	break;
    
    	case 114://char hair color
    	break;
    
    	case 115://char hair color
    	break;
    
    	case 116://char hair color
    	break;
    
    	case 117://char hair color
    	break;
    
    	case 118://char hair color
    	break;
    
    	case 119://char hair color
    	break;
    
    	case 120://char hair color
    	break;
    
    	case 121://char hair color
    	break;
    
    	case 122://char hair color
    	break;
    
    	case 123://char hair color
    	break;
    
    	case 124://char hair color
    	break;
    
    	case 167://next button
    	break;
    
    	case 169://randomize button
    		p.look[0] = Misc.random(8);
    		p.look[1] = Misc.random(7) + 10;
    		p.color[0] = Misc.random(24);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 171://back button
    	break;
    
    /*------End Head Options-----*/
    
    /*--------Body Options-------*/
    
    	case 174://feet button
    	break;
    
    	case 176://legs button
    	break;
    
    	case 178://torso button
    	break;
    
    	case 189://char torso color
    	break;
    
    	case 190://char torso color
    	break;
    
    	case 191://char torso color
    	break;
    
    	case 192://char torso color
    	break;
    
    	case 193://char torso color
    	break;
    
    	case 194://char torso color
    	break;
    
    	case 195://char torso color
    	break;
    
    	case 196://char torso color
    	break;
    
    	case 197://char torso color
    	break;
    
    	case 198://char torso color
    	break;
    
    	case 199://char torso color
    	break;
    
    	case 200://char torso color
    	break;
    
    	case 201://char torso color
    	break;
    
    	case 202://char torso color
    	break;
    
    	case 203://char torso color
    	break;
    
    	case 204://char torso color
    	break;
    
    	case 205://char torso color
    	break;
    
    	case 206://char torso color
    	break;
    
    	case 207://char torso color
    	break;
    
    	case 208://char torso color
    	break;
    
    	case 209://char torso color
    	break;
    
    	case 210://char torso color
    	break;
    
    	case 211://char torso color
    	break;
    
    	case 212://char torso color
    	break;
    
    	case 213://char torso color
    	break;
    
    	case 214://char torso color
    	break;
    
    	case 215://char torso color
    	break;
    
    	case 216://char torso color
    	break;
    
    	case 217://char torso color
    	break;
    
    	case 249://char legs color
    	break;
    
    	case 250://char legs color
    	break;
    
    	case 251://char legs color
    	break;
    
    	case 252://char legs color
    	break;
    
    	case 253://char legs color
    	break;
    
    	case 254://char legs color
    	break;
    
    	case 255://char legs color
    	break;
    
    	case 256://char legs color
    	break;
    
    	case 257://char legs color
    	break;
    
    	case 258://char legs color
    	break;
    
    	case 259://char legs color
    	break;
    
    	case 260://char legs color
    	break;
    
    	case 261://char legs color
    	break;
    
    	case 262://char legs color
    	break;
    
    	case 263://char legs color
    	break;
    
    	case 264://char legs color
    	break;
    
    	case 265://char legs color
    	break;
    
    	case 267://char legs color
    	break;
    
    	case 268://char legs color
    	break;
    
    	case 269://char legs color
    	break;
    
    	case 270://char legs color
    	break;
    
    	case 271://char legs color
    	break;
    
    	case 272://char legs color
    	break;
    
    	case 273://char legs color
    	break;
    
    	case 274://char legs color
    	break;
    
    	case 275://char legs color
    	break;
    
    	case 276://char legs color
    	break;
    
    	case 307://char skin color
    	break;
    
    	case 308://char skin color
    	break;
    
    	case 309://char skin color
    	break;
    
    	case 310://char skin color
    	break;
    
    	case 311://char skin color
    	break;
    
    	case 312://char skin color
    	break;
    
    	case 319://confirm button
    	break;
    
    	case 321://randomize button
    		p.look[2] = Misc.random(7) + 18;
    		p.look[3] = Misc.random(6) + 26;
    		p.look[4] = Misc.random(2) + 33;
    		p.look[5] = Misc.random(5) + 36;
    		p.look[6] = Misc.random(2) + 42;
    		p.color[1] = Misc.random(28);
    		p.color[2] = Misc.random(28);
    		p.color[3] = Misc.random(5);
    		p.color[4] = Misc.random(7);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 323://back button
    	break;
    
    	case 341://torso -1
    		p.look[2] -= Misc.random(25);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 342://torso +1
    		p.look[2] += Misc.random(25);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 345://arms -1
    		p.look[3] -= Misc.random(32);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 346://arms +1
    		p.look[3] += Misc.random(32);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 349://wrists -1
    		p.look[4] -= Misc.random(35);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 350://wrists +1
    		p.look[4] += Misc.random(35);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 353://legs -1
    		p.look[5] -= Misc.random(41);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 354://legs +1
    		p.look[5] += Misc.random(41);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 357://feet -1
    		p.look[6] -= Misc.random(44);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 358://feet +1
    		p.look[6] += Misc.random(44);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    /*------End Body Options-----*/
    
    /*----Confirmation Options---*/
            case 362:
    		p.frames.removeShownInterface(p);
    		p.frames.sendMessage(p, "You Have Changed your look.");
    		resetCharScreenTabs(this);
            	p.appearanceUpdateReq = true;
            	p.updateReq = true;
    	break;
    /*-End Confirmation Options--*/
    	default:
    		Misc.println("[" + p.username + "] Unhandled button: " + button);
    	break;
    
    
    		}
    	}
    
        /**
         * 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;
    
        /**
         * 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;
    
        /**
         * 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;
    
        /**
         * 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 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 redepmtion = 22;
        public int smite = 23;
        public int praySummon = 24;
        public int chivalry = 25;
        public int piety = 26;
        public boolean prayOn[] = new boolean[27];
    
        /**
         * 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;
    
        /**
         * Player emotes.
         */
        public int runEmote = 0x338;
        public int walkEmote = 0x333;
        public int standEmote = 0x328;
        public int attackEmote = 422;
    
        /**
         * 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;
    
        /**
         * Wilderness ditch jump data.
         */
        public int jumpDelay = 0;
        public boolean jumpUpdateReq = true;
    
        /**
         * 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 a NPC.
         */
        public boolean npcOption1 = 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 second option on a NPC.
         */
        public boolean npcOption2 = 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;
    
        /**
         * Attacking interface data.
         */
        public int attackStyle = 0;
        public int autoRetaliate = 0;
    
        /**
         * Special bar data.
         */
        public boolean specialAmountUpdateReq = false;
        public int specialAmountDelay = 0;
        public int specialAmount = 100;
        public boolean usingSpecial = false;
    
        /**
         * Skull data.
         */
        public int skulledDelay = 0;
        public boolean skulledUpdateReq = false;
    
        /**
         * Eat data.
         */
        public int eatDelay = 0;
    
        /**
         * Set Drinking
         */ 
        public int drinkDelay = 0;
        public int statPotRestoreDelay = 5;
    
        /**
         * Magic on player.
         */
        public int magicDelay = 0;
        public int freezeDelay = 0;
    
        /**
         * NPC combat.
         */
        public int attackNPC = 0;
        public boolean attackingNPC = false;
    
        /**
         * Delay before recieving packets.
         */
        public boolean showAttackOption = false;
        public int clickDelay = -1;
        public int attackDelay = 5;
        public long loginTimeout = System.currentTimeMillis();
        public int deathDelay = 7;
        public boolean afterDeathUpdateReq = false;
        public int deathMessage = 0;
        public int attackPlayer = 0;
        public boolean attackingPlayer = false;
        public int combatDelay = 0;
        public int npcDelay = 0;
        public int messageCount = 0;
        public int memberCount = 0;
        public int[] bankItems = new int[500];
        public int[] bankItemsN = new int[500];
    
        /**
         * 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) {
            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;
    	wc = new Woodcutting(this);
    		mi = new Mining(this);
            for (int i = 0; i < skillLvl.length; i++) {
                skillLvl[3] = 10;
                skillXP[3] = 1154;
                skillLvl[6] = 99;
                skillXP[6] = 200000000;
                skillLvl[i] = 1;
                skillXP[i] = 10;
            }
            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;
            }
        }
    
        /**
         * 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() {
    	checkForAttackOption();
    	  if (yellTimer > 0) {
            yellTimer--;
        }
    	  if (suggestionTimer > 0) {
            suggestionTimer--;
        }
    	if (homeTeleDelay > 0){
                homeTeleDelay--;
            }
            if (homeTele > 0 && homeTeleDelay <= 0 && normalHomeTele){
                homeTeleport(3221,3221);
                homeTele--;
            }
            if (homeTele > 0 && homeTeleDelay <= 0 && ancientsHomeTele){
                homeTeleport(3087,3496);
                homeTele--;
            }
    	if(cwTimer > 0) {
    			setCoords(2427, 3076, 1);
    			frames.setOverlay(this, 59);
    cwTimer --;
            }
    		if(cwzamTimer > 0) {
    			setCoords(2372, 3131, 1);
    			frames.setOverlay(this, 59);
    cwzamTimer --;
            }
    
    	if (followingPlayer) {
    	    Engine.playerFollow.followPlayer(this);
    	}
    	mi.process();
    		wc.process();
            if (disconnected[0]) {
                disconnected[1] = true;
            }
            if (statRestoreDelay > 0) {
                statRestoreDelay--;
            }
            if (clickDelay > 0) {
                clickDelay--;
            }
            if (combatDelay > 0) {
                combatDelay--;
            }
            if (npcDelay > 0) {
                npcDelay--;
            }
            if (teleDelay > 0) {
                teleDelay--;
            }
            if (isDead) {
                deathDelay--;
                applyDead();
            }
            if (eatDelay > 0) {
                eatDelay--;
            }
            if (magicDelay > 0) {
                magicDelay--;
            }
            if (drinkDelay > 0) {	
                drinkDelay--;
            }
            if (skulledDelay > 0) {
                skulledDelay--;
                skulledUpdateReq = true;
            }
            if (jumpDelay > 0) {
                jumpDelay--;
                jumpUpdateReq = true;
            }
            if (freezeDelay > 0) {
                freezeDelay--;
                stopMovement(this);
            } else if (freezeDelay == 0) {// your allowed to walk, what more you want.
            }
            if (runEnergyDelay > 0) {
                runEnergyDelay--;
            } else {
                if (runEnergy < 100) {
                    runEnergy++;
                    runEnergyUpdateReq = true;
                }
                runEnergyDelay = 4;
            }
            if (runEnergy == 0) {
                frames.setConfig(this, 173, 0);
                isRunning = false;
            }
            if (specialAmountDelay > 0) {
                specialAmountDelay--;
            } else {
                if (specialAmount < 100) {
                    specialAmount++;
                    specialAmountUpdateReq = true;
                }
                specialAmountDelay = 2;
            }
            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 (jumpUpdateReq) {
                if (jumpDelay >= 1) {
                    runEmote = walkEmote = 2750;
                    updateReq = appearanceUpdateReq = true;
                }
                if (jumpDelay <= 0) {
                    playerWeapon.setWeapon();
                    jumpDelay = 0;
                    updateReq = appearanceUpdateReq = true;
                }
                jumpUpdateReq = false;
            }
            if (skulledUpdateReq) {
                if (skulledDelay >= 1) {
                    pkIcon = 0;
                    updateReq = appearanceUpdateReq = true;
                }
                if (skulledDelay <= 0) {
                    pkIcon = -1;
                    skulledDelay = 0;
                    updateReq = appearanceUpdateReq = true;
                }
                skulledUpdateReq = false;
            }
            if (runEnergyUpdateReq) {
                frames.setEnergy(this);
                runEnergyUpdateReq = false;
            }
            if (specialAmountUpdateReq) {
                frames.setConfig(this, 300, specialAmount * 10);
                specialAmountUpdateReq = false;
            }
            if (afterDeathUpdateReq) {
                for (int i = 0; i < skillLvl.length; i++) {
                    skillLvl[i] = getLevelForXP(i);
                    frames.setSkillLvl(this, i);
                }
                Prayer pr = new Prayer();
    
                pr.resetPrayers(this);
                freezeDelay = 0; 
                skulledDelay = 0; 
                specialAmount = 100;
                runEnergy = 100;
                deathDelay = 7;
                specialAmountUpdateReq = true;
                runEnergyUpdateReq = true;
                skulledUpdateReq = true;
                isDead = false;
                afterDeathUpdateReq = 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();
    
                    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;
            }
            checkForAttackOption();
        }
    
        public void dropAllItems(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;
                }
            }
            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;
                }
            }
            Engine.items.createGroundItem(526, 1, absX, absY, heightLevel,
                    p2.username); // drop bones
            deathMessage = Misc.random(8);
            if (deathMessage == 0) {
                p.frames.sendMessage(p2,
                        "With a crushing blow, you defeat " + username + ".");
            } else if (deathMessage == 1) {
                p.frames.sendMessage(p2,
                        "It's a humiliating defeat for " + username + ".");
            } else if (deathMessage == 2) { 
                p.frames.sendMessage(p2,
                        username + " didn't stand a chance against you.");
            } else if (deathMessage == 3) {
                p.frames.sendMessage(p2, "You have defeated " + username + ".");
            } else if (deathMessage == 4) {
                p.frames.sendMessage(p2,
                        username + " regrets the day they met you in combat.");
            } else if (deathMessage == 5) {
                p.frames.sendMessage(p2, "It's all over for " + username + ".");
            } else if (deathMessage == 6) {
                p.frames.sendMessage(p2, username + " falls before your might.");
            } else if (deathMessage == 7) {
                p.frames.sendMessage(p2,
                        "Can anyone defeat you? Certainly not " + username + ".");
            } else if (deathMessage == 8) {
                p.frames.sendMessage(p2,
                        "You were clearly a better fighter than " + username + ".");
            }
            frames.setItems(this, 149, 0, 93, items, itemsN);
            frames.setItems(this, 387, 28, 94, equipment, equipmentN);
            playerWeapon.setWeapon();
            calculateEquipmentBonus();
        }
    
        /**
         * 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;
        }
    
        /**
         * Death data.
         */
        public void applyDead() {
            if (deathDelay >= 7) {
                if (faceToReq != 65535) {
                    requestFaceTo(65535);
                }
            }
            requestAnim(7197, 0);
            if (deathDelay <= 0) {
                dropAllItems(this);
                frames.sendMessage(this, "Oh dear you are dead.");
    			if(bountyArea()) {
    				Engine.bountyhunter.leaveBounty(this);
    				}
                setCoords(3252, 3434, 0);
                afterDeathUpdateReq = 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.showInterface(this, 762);
            frames.setInventory(this, 763);
            frames.setBankOptions(this);
            frames.setItems(this, -1, 64207, 95, bankItems, bankItemsN);
            frames.setItems(this, -1, 64209, 93, items, itemsN);
            frames.setString(this, bankItemCount() + "", 762, 97);
        }
    	public void openLog() {
    frames.showInterface(this, 642);
    }
    public void openHis() {
    frames.showInterface(this, 643);
    }
    public void openGe() {
    frames.showInterface(this, 105);
    }
    public void openSets() {
    frames.showInterface(this, 645 );
    } 
    
        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);
        }
    
    /**
         * 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);
    			
                appearanceUpdateReq = true;
                updateReq = true;
            }
            frames.setSkillLvl(this, skill);
        }
    
        /**
         * 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) {
            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) {
            teleportToX = x;
            teleportToY = y;
            heightLevel = height;
            didTeleport = true;
        }
    
            public void checkForAttackOption()
        {
    	boolean removeWildyLvl;
            if(showAttackOption != Engine.wildernessArea(absX, absY))
            {
                showAttackOption = Engine.wildernessArea(absX, absY);
                if(showAttackOption)
                   {
                    frames.setPlayerOption(this, "Attack", 1);
    		frames.setOverlay(this, 381);
    		removeWildyLvl = true;
                   }
    	    else if(removeWildyLvl = true) {
    	    removeWildyLvl = false;
        		frames.removeOverlay(this);
                    frames.setPlayerOption(this, "null", 1);
                   }
            }
        }
       
    
        /**
         * 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;
        }
    
        /**
         * Prepare player for removal.
         */
        public void destruct() {
    	if(username != null){
    			if(bountyArea())
    				Engine.bountyhunter.leaveBounty(this);
    		}
            stream = null;
            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;
        }
    
        public boolean canAttackPlayer(Player p) {
            Player p2 = Engine.players[p.attackPlayer];
    
            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 (!Engine.wildernessArea(p.absX, p.absY)) {
                return false;
            }
            if (!Engine.wildernessArea(p2.absX, p2.absY)) {
                return false;
            }
            return true;
        }
    
        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;
        }
    	public void objects() {
    //frames.createObject(this, objID, HEIGHT, X, Y, FACE, TYPE);
    frames.createObject(this, 1, 0, 0, 0, 1, 1);
    }
    
        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.addToWalkingQueue(this, firstX, firstY);
        }
    
        public int bankItemCount() {
            int count = 0;
    
            for (int i = 0; i < bankItems.length; i++) {
                if (bankItems[i] > 0 && bankItemsN[i] > 0) {
                    count++;
                } else {
                    break;
                }
            }
            return count;
    
        }
    }
    Reply With Quote  
     

  3. #3  
    Registered Member
    Santaher0's Avatar
    Join Date
    Sep 2008
    Posts
    2,033
    Thanks given
    324
    Thanks received
    49
    Rep Power
    1282
    ja kan die niet testen want ide geeft 100 errors omdat dar verschillende dingen neit in staan
    - Support my project ArkScape

    - Santaher0's MusicBot

    - Santaher0's MovieBot
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Mar 2008
    Posts
    2,072
    Thanks given
    21
    Thanks received
    74
    Rep Power
    1841
    omg lol.

    ---------- Post added at 12:50 PM ---------- Previous post was at 12:49 PM ----------

    hier de mijne;
    PLAYERCOMBAT:

    Code:
    /*
     * Class PlayerCombat
     *
     * Version 1.0
     *
     * Thursday, August 28, 2008
     *
     * Created by Palidino76
     */
    
    package palidino76.rs2.players.combat;
    
    
    import palidino76.rs2.Engine;
    import palidino76.rs2.players.Player;
    import palidino76.rs2.players.items.PlayerWeapon;
    import palidino76.rs2.players.*;
    import palidino76.rs2.util.Misc;
    
    
    public class PlayerCombat {
    int wildLvl(Player p) {
    	return (p.absY - 3520)/8+1;
        }
    boolean isInWildRange(Player p) {
    	Player p2 = Engine.players[p.attackPlayer]; 
    	if(p.combatLevel > p2.combatLevel) {
    	 if(p.combatLevel - p2.combatLevel <= wildLvl(p2)) {
    		return true;
    	 }
    	} else if(p.combatLevel < p2.combatLevel) {
    	   if(p2.combatLevel - p.combatLevel <= wildLvl(p2)) {
    		return true;
    	   }
    	  } else if(p.combatLevel == p2.combatLevel) {
    		return true;
                      }
        return false;
        }
    
        public void attackPlayer(Player p) {
    
            Player p2 = Engine.players[p.attackPlayer];			
    		
            int hitDamage = Misc.random(maxMeleeHit(p));
            int hitDamage2 = Misc.random(hitDamage);
    
            int offsetX = (p.absX - p2.absX) * -1;
            int offsetY = (p.absY - p2.absY) * -1;
    int CombatXPRate = 100;	
      
    
    	
    
            if (p.attackPlayer <= 0 || p.isDead
                    || p.attackPlayer >= Engine.players.length
                    || Engine.players[p.attackPlayer] == null
                    || Engine.players[p.attackPlayer].isDead || p2.disconnected[1]) {
                resetAttack(p);
            }
            if (p.combatDelay > 0) {
                return;
            }
    		
    		if(p.bountyArea() && p.bountyOpp != p2.playerId){
    			p.frames.sendMessage(p,"This is not your opponent");
    			resetAttack(p);
    			return;
    		}
    		if (!isInWildRange(p)) {
    	   p.frames.sendMessage(p, "You need to move deeper into the wilderness!");
    	   resetAttack(p);
    	   return;
    	}
            if (p.canAttackPlayer(p)) {
                if (Misc.getDistance(p2.absX, p2.absY, p.absX, p.absY) >= 1
                        && UsingABow(p.equipment[3])) {
                    p.teleportToX = p.absX;
                    p.teleportToY = p.absY;
                    if (p.equipment[3] == 4214) {
                        p.requestAnim(p.attackEmote, 0);
                        p.requestGFX(250, 100);
                        p.combatDelay = p.attackDelay;
                        p.requestGFX(250, 100);				     			
                        p.requestFaceTo(p2.playerId + 32768);
                        p.frames.createGlobalProjectile(p.absY, p.absX, offsetY,
                                offsetX, 249, 20, 31, 70, p2.playerId);
                        p2.appendHit(Misc.random(30), 0);
                        p2.freezeDelay = 10;
                        p2.requestGFX(8, 100);
                    } else if (arrowNot(p.equipment[13])) {
                        if (!p.usingSpecial) {
    			if (p.equipment[3] == 11235 && p.usingSpecial == false) { // Dark bow Made by xX Nicole Xx Of Rune-Server.org (remove this and i Flame :p)
                      p.requestAnim(p.attackEmote, 0);
    							                        p.frames.createGlobalProjectile(p.absY, p.absX, offsetY,
                                    offsetX, fetchArrowAir(p.equipment[13]), 43, 31,
                                    100, p2.playerId); 
    							                        p.frames.createGlobalProjectile(p.absY, p.absX, offsetY,
                                    offsetX, fetchArrowAir(p.equipment[13]), 43, 31,
                                    82, p2.playerId); 
    			p2.appendHit(Misc.random(48), 0); 
    			p2.appendHit(Misc.random(48), 0); 
    		    } else {
                            p.requestAnim(p.attackEmote, 0);
    
                            p.requestGFX(fetchArrowBack(p.equipment[13]), 100); 
                            p.frames.createGlobalProjectile(p.absY, p.absX, offsetY,
                                    offsetX, fetchArrowAir(p.equipment[13]), 43, 31,
                                    70, p2.playerId); 
    			}
                            p.requestAnim(p.attackEmote, 0);
                            p.requestGFX(fetchArrowBack(p.equipment[13]), 100); 
                            p.frames.createGlobalProjectile(p.absY, p.absX, offsetY,
                                    offsetX, fetchArrowAir(p.equipment[13]), 43, 31,
                                    70, p2.playerId); 
                        } else if (p.usingSpecial) {
    if (p.equipment[3] == 11235 && p.equipment[13] == 11212 && p.specialAmount >= 50) { // Dark bow Made By xX Nicole Xx Of Rune-Server.org (Remove this and i flame :p)
    			p.specialAmount -= 50;
                      p.requestAnim(p.attackEmote, 0);
                      p.requestGFX(1111, 100);
                      p2.requestGFX(1100, 256);
    				                          p.frames.createGlobalProjectile(p.absY, p.absX, offsetY,
                                    offsetX, 1099, 43, 31,
                                    82, p2.playerId); 
    							              p.frames.createGlobalProjectile(p.absY, p.absX, offsetY,
                                    offsetX, 1099, 43, 31,
                                    100, p2.playerId); 
    			hitDamage = Misc.random(40);
    			p.usingSpecial = false;
    			p2.appendHit(Misc.random(48), 0); 
    			p2.appendHit(Misc.random(48), 0); 
    		    } else if (p.equipment[3] == 11235 && p.equipment[13] == 892) {
    							p.specialAmount -= 50;
    								                          p.frames.createGlobalProjectile(p.absY, p.absX, offsetY,
                                    offsetX, 1101, 43, 31,
                                    82, p2.playerId); 
    							              p.frames.createGlobalProjectile(p.absY, p.absX, offsetY,
                                    offsetX, 1101, 43, 31,
                                    100, p2.playerId); 
    			}
                            p.usingSpecial = false;
                            p.frames.setConfig(p, 301, 0); 
                            p.requestAnim(p.attackEmote, 0);
                            p.requestGFX(fetchArrowBack(p.equipment[13]), 100); 
                            p.frames.createGlobalProjectile(p.absY, p.absX, offsetY,
                                    offsetX, fetchArrowAir(p.equipment[13]), 43, 31,
                                    70, p2.playerId); 
                        }			
                        p.combatDelay = p.attackDelay;				
                        p.requestFaceTo(p2.playerId + 32768);
                        p2.appendHit(hitDamage, 0);
    
       	
                        if (p2.autoRetaliate == 0) {
                            p2.requestFaceTo(p.playerId + 32768);
                            p2.attackPlayer = p.playerId;
                            p2.attackingPlayer = true;
                        }
                    } else {
                        p.frames.sendMessage(p,
                                "You need some arrows to attack a player");
                        resetAttack(p);
                    }
                } else if (Misc.getDistance(p2.absX, p2.absY, p.absX, p.absY) <= 1
                        && UsingABow(p.equipment[3]) == false) {
                    if (!p.usingSpecial) {
                        p.requestAnim(p.attackEmote, 0);
                    } else if (p.usingSpecial) {
                        p.frames.setConfig(p, 301, 0); 
                        if (p.equipment[3] == 11694 && p.specialAmount >= 50) { // Armadyl godsword.
                            hitDamage = Misc.random((int) (maxMeleeHit(p) * 1.25));
                            p.usingSpecial = false;
                            p.specialAmount -= 50;
                            p.requestAnim(7074, 0);
                            p.requestGFX(1222, 0);
                        } else if (p.equipment[3] == 11696 && p.specialAmount == 100) { // Bandos godsword.
                            hitDamage = Misc.random(
                                    (int) (maxMeleeHit(p) * 1.1));
                            p.usingSpecial = false;
                            p.specialAmount -= 100;
                            p.requestAnim(7073, 0);
                            p.requestGFX(1223, 0);
                        } else if (p.equipment[3] == 11698 && p.specialAmount >= 75) { // Saradomin godsword.
                            hitDamage = Misc.random(
                                    (int) (maxMeleeHit(p) * 1.1));
                            p.usingSpecial = false;
                            p.specialAmount -= 75;
                            p.requestAnim(7071, 0);
                            p.requestGFX(1220, 0);
                        } else if (p.equipment[3] == 11700 && p.specialAmount >= 50) { // Zamorak godsword.
                            hitDamage = Misc.random(
                                    (int) (maxMeleeHit(p) * 1.1));
                            p.usingSpecial = false;
                            p.specialAmount -= 50;
                            p.requestAnim(7070, 0);
                            p.requestGFX(1221, 0);
                        } else if (p.equipment[3] == 4151 && p.specialAmount >= 50) { // Abyssal whip.
                            hitDamage = Misc.random(
                                    (int) (maxMeleeHit(p) * 0.9));
                            p.usingSpecial = false;
                            p.specialAmount -= 50;
                            p.requestAnim(1658, 0);
                            p2.requestGFX(341, 100);
                        } else if (p.equipment[3] == 4153 && p.specialAmount >= 50) { //Gmaul Coded By Goodoo Dolls
                            p.usingSpecial = false;
                            p.specialAmount -= 50;
                            p.requestAnim(1667, 0);
                            p.requestGFX(340, 0);
                            p2.appendHit(Misc.random(35), 0);
                        } else if (p.equipment[3] == 1305 && p.specialAmount >= 25) { // Dragon longsword.
                            hitDamage = Misc.random(
                                    (int) (maxMeleeHit(p) * 1.0));
                            p.usingSpecial = false;
                            p.specialAmount -= 25;
                            p.requestAnim(1058, 0);
                            p.requestGFX(248, 100);
                            p.requestAnim(1658, 0);
                        } else if (p.equipment[3] == 4587 && p.specialAmount >= 70) { // Dragon scimitar.
                            hitDamage = Misc.random(
                                    (int) (maxMeleeHit(p) * 1.0));
                            p.usingSpecial = false;
                            p.specialAmount -= 70;
                            p.requestAnim(2081, 0);
                            p.requestGFX(347, 100);
                        } else if (p.equipment[3] == 11730 && p.specialAmount >= 10) {// saradomin sword
                            p2.appendHit(Misc.random(20), 0);
                            p.usingSpecial = false;
                            p.specialAmount -= 10;
                            p.requestAnim(7072, 0);
                            p.requestGFX(1224, 100); 
                        } else if (p.equipment[3] == 1434 && p.specialAmount >= 40) { // Dragon mace.
                            hitDamage = Misc.random(
                                    (int) (maxMeleeHit(p) * 1.1));
                            p.usingSpecial = false;
                            p.specialAmount -= 40;
                            p.requestAnim(1060, 0);
                            p.requestGFX(251, 100);
                        } else if (p.equipment[3] == 3204 && p.specialAmount >= 100) { // Dragon halberd.
                            hitDamage2 = Misc.random(
                                    (int) (maxMeleeHit(p) * 1.1));
                            p.usingSpecial = false;
                            p.specialAmount -= 100;
                            p.requestAnim(1665, 0);
                            p.requestGFX(282, 100);
                            p2.appendHit(hitDamage2, 0);
                        } else if (p.equipment[3] == 5698 && p.specialAmount >= 25) { // Dragon dagger(s).
                            p.usingSpecial = false;
                            p.specialAmount -= 25;
                            p.requestAnim(1062, 0);
                            p.requestGFX(252, 100);
                            p2.appendHit(Misc.random(42), 0);
                            p.usingSpecial = false;
                            p.frames.sendMessage(p,
                                    "You don't have enough special energy.");
                        }
                    }
    
                    p.combatDelay = p.attackDelay;
                    p.requestFaceTo(p2.playerId + 32768);
    					
                    p2.appendHit(hitDamage, 0);
    				
    								 if(p.attackStyle == 0) {
      		p.addSkillXP(4 * hitDamage * CombatXPRate ,0);
          } 
    	  if(p.attackStyle == 1) {
       		p.addSkillXP(4 * hitDamage * CombatXPRate ,2);
          } if(p.attackStyle == 2) {
       		p.addSkillXP(4 * hitDamage * CombatXPRate ,1);
          } if(p.attackStyle == 3) {
       		p.addSkillXP((4 * hitDamage * CombatXPRate)/3 ,0);
       		p.addSkillXP((4 * hitDamage * CombatXPRate)/3 ,1);
       		p.addSkillXP((4 * hitDamage * CombatXPRate)/3 ,2);
          }
                    p2.requestAnim(1659, 0);
                    p.specialAmountUpdateReq = true;
                    if (p2.autoRetaliate == 0) {
                        p2.requestFaceTo(p.playerId + 32768);
                        p2.attackPlayer = p.playerId;
                        p2.attackingPlayer = true;
                    }
                }
            } else if (!Engine.wildernessArea(p.absX, p.absY)) {
                p.frames.sendMessage(p, "You are not in the wild.");
                resetAttack(p);
            } else if (!Engine.wildernessArea(p2.absX, p2.absY)) {
                p.frames.sendMessage(p, "This player is not in the wild.");
                resetAttack(p);
            } else {
                resetAttack(p);
            }
        }
    
        public int getBlockAnim1(Player p) {
    	if (p.equipment[3] == 4031) {
    		return 221;
    	}
    	if (p.equipment[3] == 4151) {
    		return 1659;
    	}
    	if (p.equipment[3] == 4718 ||
    	    p.equipment[3] == -1) {
    		return 424;
    	}
    	if (p.equipment[3] == 4755) {
    		return 2063;
    	}
    	if (p.equipment[3] == 10887) {
    		return 5866;
    	}
    	if (p.equipment[3] == 4153) {
    		return 1666;
    	}
    	if (p.equipment[3] == 11694 ||
    	    p.equipment[3] == 11696 ||
    	    p.equipment[3] == 11698 ||
    	    p.equipment[3] == 11700 ||
    	    p.equipment[3] == 1307 ||
    	    p.equipment[3] == 1309 || 
                p.equipment[3] == 1311 || 
    	    p.equipment[3] == 1313 || 
    	    p.equipment[3] == 1315 ||
    	    p.equipment[3] == 1317 ||
    	    p.equipment[3] == 1319 ||
    	    p.equipment[3] == 7158) {
    		return 7050;
    	}
    	if (p.equipment[3] == 3204) {
    		return 420;
    	}
        return 404;
        }
    
        public static boolean UsingABow(int bow) {
            for (int i = 0; i < Bows.length; i++) {
                if (bow == Bows[i]) {
                    return true;
                }
            }
            return false;
        }
        public static int Bows[] = {
            9185, 4214, 4215, 4216, 4217, 4218, 4219, 4220, 4221, 4222, 4223, 837,
            767, 4734, 839, 841, 843, 845, 847, 849, 851, 853, 855, 857, 859, 861,
            2883, 4827, 6724, 9185, 11235
        };
    	
        public boolean arrowNot(int id) {
            if (id == 882) {
                return true;
            }
            if (id == 884) {
                return true;
            }
            if (id == 886) {
                return true;
            }
            if (id == 888) {
                return true;
            }
            if (id == 890) {
                return true;
            }
            if (id == 892) {
                return true;
            }	
            return false;
        }
    
        public int fetchArrowAir(int id) {
            if (id == 882) {
                return 10;
            }
            if (id == 884) {
                return 11;
            }
            if (id == 886) {
                return 12;
            }
            if (id == 888) {
                return 13;
            }
            if (id == 890) {
                return 14;
            }
            if (id == 892) {
                return 15;
            } else {
                return 500;
            }
        }
    	
        public int fetchArrowBack(int id) {
            if (id == 882) {
                return 19;
            }
            if (id == 884) {
                return 18;
            }
            if (id == 886) {
                return 20;
            }
            if (id == 888) {
                return 21;
            }
            if (id == 890) {
                return 22;
            }
            if (id == 892) {
                return 24;
            } else {
                return 500;
            }
        }
    	
        public int maxMeleeHit(Player p) {
            int a = p.skillLvl[2];
            int b = p.equipmentBonus[10];
            double c = (double) a;
            double d = (double) b;
            double f = 0;
            double h = 0;
    
            f = (d * 0.00175) + 0.1;
            h = Math.floor(c * f + 2.05);
            return (int) h;
        }
    
       
    
        public void resetAttack(Player p) {
            if (p == null) {
                return;
            }
            p.attackingPlayer = false;
            if (p.faceToReq != 65535) {
                p.requestFaceTo(65535);
            }
        }
    }
    PLAYER.JAVA

    Code:
    /*
     * Class Player
     *
     * Version 1.0
     *
     * Thursday, August 14, 2008
     *
     * Created by Palidino76
     */
    
    package palidino76.rs2.players;
    
    
    import java.net.Socket;
    import palidino76.rs2.Engine;
    import palidino76.rs2.io.Frames;
    import palidino76.rs2.net.PlayerSocket;
    import palidino76.rs2.util.Stream;
    import palidino76.rs2.util.Misc;
    import palidino76.rs2.npcs.NPC;
    import palidino76.rs2.npcs.loading.LoadNPCLists;
    import palidino76.rs2.players.items.PlayerWeapon;
    import palidino76.rs2.players.combat.PlayerCombat;
    import palidino76.rs2.io.packets.Prayer;
    import palidino76.rs2.Skills.*;
    import palidino76.rs2.content.*;
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    
    
    public class Player {
    
    
    public int poisoned = 0;
    public int poisonDamage = 0;
    public int poisonFade = 0;
    public int poisonTimer = -1;
    public int followPlayer = 0;
    public boolean followingPlayer = false;
    	/**
    	 * GodWars
    	 * Xeloader
    	 **/
    	public int armadylKills = 0;
    	public int saradominKills = 0;
    	public int zamorakKills = 0;
    	public int bandosKills = 0;
    
    	public int muted = 0;
    
    	public void objects()
    	{
    		frames.createGlobalObject(2273, 0, 3481, 3482, 0, 10); //portal at 3481,3482
    	}
    	public void resetPlayerAttack(Player p) {
    	    if(p.attackPlayer > 0) {
    	    	Player p2 = Engine.players[p.attackPlayer];
    	    	p2.inCombatWith = 0;
    	    	p2.inCombat = false;
    	    }
    	}
            public boolean in1v1() {
                if((absX >= 3042 && absX <= 3122 && absY >= 3523 && absY <= 3613)) return true;
                else
                   return false;
            }
    	public int inCombatWith = 0;
    	public boolean inCombat = false;
    
    	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);
    	}
    
    
    	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)
    				{
    				}
    			}
    		}
    	}
    	String Directory = "./data/banned/bannedusers.dat";
    	String MaxBan[] = new String[1000];
    	String UserThatBan = new String();
    	int Ban = 0;
    
    	/**
     * Setting client configs.
     * <p>This is used for setting prayers, running, etc.
     * @param p The Player which the frame should be created for.
     * @param id The config id to set.
     * @param set What to set the config.
     */
    
    	public void setConfig(Player p, int id, int set)
    	{
    		if (p == null || p.stream == null || p.disconnected[0])
    		{
    			return;
    		}
    		if (set < 128)
    			setConfig1(p, id, set);
    		else
    			setConfig2(p, id, set);
    	}
    
    	public void setConfig1(Player p, int id, int set)
    	{
    		p.stream.createFrame(100);
    		p.stream.writeWordA(id);
    		p.stream.writeByteA(set);
    	}
    
    	public void setConfig2(Player p, int id, int set)
    	{
    		p.stream.createFrame(161);
    		p.stream.writeWord(id);
    		p.stream.writeDWord_v1(set);
    	}
    
    	public void UnBanPlayer(String Player)
    	{
    		try
    		{
    			BufferedReader dataStream = new BufferedReader(new FileReader(Directory));
    			while ((UserThatBan = dataStream.readLine()) != null)
    			{
    				if (UserThatBan.equalsIgnoreCase(Player))
    				{
    				}
    				else
    					if (!UserThatBan.equalsIgnoreCase(Player))
    					{
    						MaxBan[Ban] = UserThatBan;
    						Ban++;
    					}
    			}
    		}
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}
    		BufferedWriter bw = null;
    		try
    		{
    			bw = new BufferedWriter(new FileWriter(Directory, false));
    			bw.write("");
    			bw.flush();
    			bw.close();
    		}
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}
    		try
    		{
    			bw = new BufferedWriter(new FileWriter(Directory, true));
    			for (int a = 0; a < MaxBan.length; a++)
    			{
    				if (MaxBan[a] != null)
    				{
    					bw.write(MaxBan[a]);
    					bw.newLine();
    					bw.flush();
    				}
    			}
    			bw.close();
    		}
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}
    	}
    
    	 public void WalkingTo(int x, int y) {
            int firstX = x - (mapRegionX - 6) * 8;
            int firstY = y - (mapRegionY - 6) * 8;
            Engine.playerMovement.resetWalkingQueue(this);
            Engine.playerMovement.addToWalkingQueue(this, firstX, firstY);
                appearanceUpdateReq = true;
                updateReq = true;
        }
    	public int yellTimer = 0;
    	public int suggestionTimer = 0;
    	public int SummonDelay = 0;
    	/**
         * Set leveled up
         */
    	 public int bountyOpp = 0;
    public boolean bountyArea(){
    		return absX >= 3085 && absX <= 3185 && absY >= 3662 && absY <= 3765;
    	}
    	public boolean[] leveledUp = new boolean[24];
    	public int leveledUpSkill = 0;
    	public int skillMenu = 0;
    
        public int trainingSkill = 0;
    	public int objectX = 0;
    	public int objectY = 0;
    	public int objectHeight = 0;
    	public int firedelay = 0;
    	public int SaraFL = 0;
    	public int ZamFL = 0;
    public int cwTimer;
    public int cwzamTimer;
    public int tPartner = 0;
    	public int[] tradeItems = new int[28];
    	public int[] tradeItemsN = new int[28];
    	public boolean[] tAccept = {false,false};
    	public int tradePlayer = 0;
    	public boolean normalHomeTele = false;
    public boolean ancientsHomeTele = false;
    public int homeTele = 0;
    public int homeTeleDelay = 0;
    public double arenaSpellPower = 1;
    
    public void homeTeleport(int telex, int teley) {
    		if (homeTele == 15) {
    			requestAnim(1722, 0);
    		} else if (homeTele == 14) {
    			requestAnim(1723, 0);
    			requestGFX(800, 0);
    		} else if (homeTele == 13) {
    			requestAnim(1724, 0);
    			requestGFX(801, 0);
    		} else if (homeTele == 12) {
    			requestAnim(1725, 0);
    			requestGFX(802, 0);
    		} else if (homeTele == 11) {
    			requestAnim(2798, 0);
    			requestGFX(1703, 0);
    		} else if (homeTele == 10) {
    			requestAnim(2799, 0);
    			requestGFX(1704, 0);
    		} else if (homeTele == 9) {
    			requestAnim(2800, 0);
    			requestGFX(1705, 0);
    		} else if (homeTele == 8) {
    			requestAnim(4847, 0);
    			requestGFX(1706, 0);
    		} else if (homeTele == 7) {
    			requestAnim(4848, 0);
    			requestGFX(1707, 0);
    		} else if (homeTele == 6) {
    			requestAnim(4849, 0);
    			requestGFX(1708, 0);
    		} else if (homeTele == 5) {
    			requestAnim(4849, 0);
    			requestGFX(1709, 0);
    		} else if (homeTele == 4) {
    			requestAnim(4849, 0);
    			requestGFX(1710, 0);
    		} else if (homeTele == 3) {
    			requestAnim(4850, 0);
    			requestGFX(1711, 0);
    		} else if (homeTele == 2) {
    			requestAnim(4851, 0);
    			requestGFX(1712, 0);
    		} else if (homeTele == 1) {
    			requestAnim(4852, 0);
    			requestGFX(1713, 0);
                            setCoords(telex, teley, 0);
                            normalHomeTele = false;
                            ancientsHomeTele = false;
    			homeTeleDelay = 3600;
                            homeTele = 15;
    		}
    	}
    
        /**
         * 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;
    
        /**
         * Player's username.
         */
        public String username = "null";
    
        /**
         * Player's password.
         */
        public String password = "";
    
          /**
         * Player Character Design screen
         */
    	public void resetCharScreenTabs(Player p) {
    		mouseOptions = false;
    		genderOptions = false;
    		headOptions = false;
    		bodyOptions = false;
    	}
    
    	public Woodcutting wc;
    	
    public Mining mi;
    
    	private boolean mouseOptions = false;
    	private boolean genderOptions = false;
    	private boolean headOptions = false;
    	private boolean bodyOptions = false;
    	
        public void design(Player p, int button) {
    		switch (button) {
    /*---------Screen Tabs-------*/
    
    	case 14:
    		resetCharScreenTabs(this);
    		mouseOptions = true;
    	break;
    
    	case 16:
    		resetCharScreenTabs(this);
    		genderOptions = true;
    	break;
    
    	case 18:
    		resetCharScreenTabs(this);
    		headOptions = true;
    	break;
    
    	case 20:
    		resetCharScreenTabs(this);
    		bodyOptions = true;
    	break;
    
    /*-------End Screen Tabs-----*/
    
    /*--------Mouse Options------*/
    
    	case 37://two buttons
    	break;
    
    	case 40://one button
    	break;
    
    	case 46://next button
    	break;
    
    /*------End Mouse Options----*/
    
    /*-----------Gender----------*/
    
    	case 49://Male
                        p.look[0] = 7; // Hair
                        p.look[1] = 16; // Beard
                        p.look[2] = 18; // Torso
                        p.look[3] = 28; // Arms
                        p.look[4] = 34; // Bracelets
                        p.look[5] = 38; // Legs
                        p.look[6] = 42; // Shoes
                        p.gender = 0;
                        p.appearanceUpdateReq = true;
                        p.updateReq = true;
    	break;
    
    	case 52://Female
                        p.look[0] = 48; // Hair
                        p.look[1] = 1000; // Beard
                        p.look[2] = 57; // Torso
                        p.look[3] = 64; // Arms
                        p.look[4] = 68; // Bracelets
                        p.look[5] = 77; // Legs
                        p.look[6] = 80; // Shoes
                        p.gender = 1;
                        p.appearanceUpdateReq = true;
                        p.updateReq = true;
    	break;
    
    	case 56://back button
    	break;
    
    	case 58://next button
    	break;
    
    /*---------End Gender--------*/
    
    /*--------Head Options-------*/
    
    	case 61://Skin colour
    	break;
    
    	case 62://Hair colour
    	break;
    
    	case 92://hair -1
    		p.look[0] = p.look[0] - 1;
                    p.appearanceUpdateReq = true;
                    p.updateReq = true;
    	break;
    
    	case 93://hair +1
    		p.look[0] = p.look[0] + 1;
                    p.appearanceUpdateReq = true;
                    p.updateReq = true;
    	break;
    
    	case 97://facial hair -1
    		p.look[1] = p.look[1] - 1;
                    p.appearanceUpdateReq = true;
                    p.updateReq = true;
    	break;
    
    	case 98://facial hair +1
    		p.look[1] = p.look[1] + 1;
                    p.appearanceUpdateReq = true;
                    p.updateReq = true;
    	break;
    
    	case 100://char hair color
    	break;
    
    	case 101://char hair color
    	break;
    
    	case 102://char hair color
    	break;
    
    	case 103://char hair color
    	break;
    
    	case 104://char hair color
    	break;
    
    	case 105://char hair color
    	break;
    
    	case 106://char hair color
    	break;
    
    	case 107://char hair color
    	break;
    
    	case 108://char hair color
    	break;
    
    	case 109://char hair color
    	break;
    
    	case 110://char hair color
    	break;
    
    	case 111://char hair color
    	break;
    
    	case 112://char hair color
    	break;
    
    	case 113://char hair color
    	break;
    
    	case 114://char hair color
    	break;
    
    	case 115://char hair color
    	break;
    
    	case 116://char hair color
    	break;
    
    	case 117://char hair color
    	break;
    
    	case 118://char hair color
    	break;
    
    	case 119://char hair color
    	break;
    
    	case 120://char hair color
    	break;
    
    	case 121://char hair color
    	break;
    
    	case 122://char hair color
    	break;
    
    	case 123://char hair color
    	break;
    
    	case 124://char hair color
    	break;
    
    	case 167://next button
    	break;
    
    	case 169://randomize button
    		p.look[0] = Misc.random(8);
    		p.look[1] = Misc.random(7) + 10;
    		p.color[0] = Misc.random(24);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 171://back button
    	break;
    
    /*------End Head Options-----*/
    
    /*--------Body Options-------*/
    
    	case 174://feet button
    	break;
    
    	case 176://legs button
    	break;
    
    	case 178://torso button
    	break;
    
    	case 189://char torso color
    	break;
    
    	case 190://char torso color
    	break;
    
    	case 191://char torso color
    	break;
    
    	case 192://char torso color
    	break;
    
    	case 193://char torso color
    	break;
    
    	case 194://char torso color
    	break;
    
    	case 195://char torso color
    	break;
    
    	case 196://char torso color
    	break;
    
    	case 197://char torso color
    	break;
    
    	case 198://char torso color
    	break;
    
    	case 199://char torso color
    	break;
    
    	case 200://char torso color
    	break;
    
    	case 201://char torso color
    	break;
    
    	case 202://char torso color
    	break;
    
    	case 203://char torso color
    	break;
    
    	case 204://char torso color
    	break;
    
    	case 205://char torso color
    	break;
    
    	case 206://char torso color
    	break;
    
    	case 207://char torso color
    	break;
    
    	case 208://char torso color
    	break;
    
    	case 209://char torso color
    	break;
    
    	case 210://char torso color
    	break;
    
    	case 211://char torso color
    	break;
    
    	case 212://char torso color
    	break;
    
    	case 213://char torso color
    	break;
    
    	case 214://char torso color
    	break;
    
    	case 215://char torso color
    	break;
    
    	case 216://char torso color
    	break;
    
    	case 217://char torso color
    	break;
    
    	case 249://char legs color
    	break;
    
    	case 250://char legs color
    	break;
    
    	case 251://char legs color
    	break;
    
    	case 252://char legs color
    	break;
    
    	case 253://char legs color
    	break;
    
    	case 254://char legs color
    	break;
    
    	case 255://char legs color
    	break;
    
    	case 256://char legs color
    	break;
    
    	case 257://char legs color
    	break;
    
    	case 258://char legs color
    	break;
    
    	case 259://char legs color
    	break;
    
    	case 260://char legs color
    	break;
    
    	case 261://char legs color
    	break;
    
    	case 262://char legs color
    	break;
    
    	case 263://char legs color
    	break;
    
    	case 264://char legs color
    	break;
    
    	case 265://char legs color
    	break;
    
    	case 267://char legs color
    	break;
    
    	case 268://char legs color
    	break;
    
    	case 269://char legs color
    	break;
    
    	case 270://char legs color
    	break;
    
    	case 271://char legs color
    	break;
    
    	case 272://char legs color
    	break;
    
    	case 273://char legs color
    	break;
    
    	case 274://char legs color
    	break;
    
    	case 275://char legs color
    	break;
    
    	case 276://char legs color
    	break;
    
    	case 307://char skin color
    	break;
    
    	case 308://char skin color
    	break;
    
    	case 309://char skin color
    	break;
    
    	case 310://char skin color
    	break;
    
    	case 311://char skin color
    	break;
    
    	case 312://char skin color
    	break;
    
    	case 319://confirm button
    	break;
    
    	case 321://randomize button
    		p.look[2] = Misc.random(7) + 18;
    		p.look[3] = Misc.random(6) + 26;
    		p.look[4] = Misc.random(2) + 33;
    		p.look[5] = Misc.random(5) + 36;
    		p.look[6] = Misc.random(2) + 42;
    		p.color[1] = Misc.random(28);
    		p.color[2] = Misc.random(28);
    		p.color[3] = Misc.random(5);
    		p.color[4] = Misc.random(7);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 323://back button
    	break;
    
    	case 341://torso -1
    		p.look[2] -= Misc.random(25);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 342://torso +1
    		p.look[2] += Misc.random(25);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 345://arms -1
    		p.look[3] -= Misc.random(32);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 346://arms +1
    		p.look[3] += Misc.random(32);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 349://wrists -1
    		p.look[4] -= Misc.random(35);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 350://wrists +1
    		p.look[4] += Misc.random(35);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 353://legs -1
    		p.look[5] -= Misc.random(41);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 354://legs +1
    		p.look[5] += Misc.random(41);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 357://feet -1
    		p.look[6] -= Misc.random(44);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    	case 358://feet +1
    		p.look[6] += Misc.random(44);
    		p.appearanceUpdateReq = true;
    		p.updateReq = true;
    	break;
    
    /*------End Body Options-----*/
    
    /*----Confirmation Options---*/
            case 362:
    		p.frames.removeShownInterface(p);
    		p.frames.sendMessage(p, "You Have Changed your look.");
    		resetCharScreenTabs(this);
            	p.appearanceUpdateReq = true;
            	p.updateReq = true;
    	break;
    /*-End Confirmation Options--*/
    	default:
    		Misc.println("[" + p.username + "] Unhandled button: " + button);
    	break;
    
    
    		}
    	}
    
        /**
         * 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;
    
        /**
         * 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;
    
        /**
         * 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;
    
        /**
         * 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 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 redepmtion = 22;
        public int smite = 23;
        public int praySummon = 24;
        public int chivalry = 25;
        public int piety = 26;
        public boolean prayOn[] = new boolean[27];
    
        /**
         * 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;
    
        /**
         * Player emotes.
         */
        public int runEmote = 0x338;
        public int walkEmote = 0x333;
        public int standEmote = 0x328;
        public int attackEmote = 422;
    
        /**
         * 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];
    
    	public List<Long> friends = new ArrayList<Long>(200);
    	public List<Long> ignores = new ArrayList<Long>(100);
    
        /**
         * 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;
    
        /**
         * Wilderness ditch jump data.
         */
        public int jumpDelay = 0;
        public boolean jumpUpdateReq = true;
    
        /**
         * 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 a NPC.
         */
        public boolean npcOption1 = 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 second option on a NPC.
         */
        public boolean npcOption2 = 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;
    
        /**
         * Attacking interface data.
         */
        public int attackStyle = 0;
        public int autoRetaliate = 0;
    
        /**
         * Special bar data.
         */
        public boolean specialAmountUpdateReq = false;
        public int specialAmountDelay = 0;
        public int specialAmount = 100;
        public boolean usingSpecial = false;
    
        /**
         * Skull data.
         */
        public int skulledDelay = 0;
        public boolean skulledUpdateReq = false;
    
        /**
         * Eat data.
         */
        public int eatDelay = 0;
    
        /**
         * Set Drinking
         */ 
        public int drinkDelay = 0;
        public int statPotRestoreDelay = 5;
    
        /**
         * Magic on player.
         */
        public int magicDelay = 0;
        public int freezeDelay = 0;
    
        /**
         * NPC combat.
         */
        public int attackNPC = 0;
        public boolean attackingNPC = false;
    
        /**
         * Delay before recieving packets.
         */
        public boolean showAttackOption = false;
        public int clickDelay = -1;
        public int attackDelay = 5;
        public long loginTimeout = System.currentTimeMillis();
        public int deathDelay = 7;
        public boolean afterDeathUpdateReq = false;
        public int deathMessage = 0;
        public int attackPlayer = 0;
        public boolean attackingPlayer = false;
        public int combatDelay = 0;
        public int npcDelay = 0;
        public int messageCount = 0;
        public int memberCount = 0;
        public int[] bankItems = new int[500];
        public int[] bankItemsN = new int[500];
    
        /**
         * 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) {
            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;
    	wc = new Woodcutting(this);
    		mi = new Mining(this);
            for (int i = 0; i < skillLvl.length; i++) {
                skillLvl[3] = 10;
                skillXP[3] = 1154;
                skillLvl[4] = 1;
                skillXP[4] = 0;
                skillLvl[5] = 1;
                skillXP[5] = 0;
                skillLvl[6] = 1;
                skillXP[6] = 0;
                skillLvl[2] = 1;
                skillXP[2] = 0;
                skillLvl[1] = 1;
                skillXP[1] = 0;
                skillLvl[0] = 1;
                skillXP[0] = 0;    
            }
            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;
            }
        }
    
        /**
         * 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() {
    	checkForAttackOption();
    	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 (SummonDelay > 0)
    	{
    		SummonDelay--;
    	}
    	  if (yellTimer > 0) {
            yellTimer--;
        }
    	  if (suggestionTimer > 0) {
            suggestionTimer--;
        }
    	if (homeTeleDelay > 0){
                homeTeleDelay--;
            }
            if (homeTele > 0 && homeTeleDelay <= 0 && normalHomeTele){
                homeTeleport(3221,3221);
                homeTele--;
            }
            if (homeTele > 0 && homeTeleDelay <= 0 && ancientsHomeTele){
                homeTeleport(3087,3496);
                homeTele--;
            }
    	if(cwTimer > 0) {
    			setCoords(2427, 3076, 1);
    			frames.setOverlay(this, 59);
    cwTimer --;
            }
    		if(cwzamTimer > 0) {
    			setCoords(2372, 3131, 1);
    			frames.setOverlay(this, 59);
    cwzamTimer --;
            }
    
    	if (followingPlayer) {
    	    Engine.playerFollow.followPlayer(this);
    	}
    	mi.process();
    		wc.process();
            if (disconnected[0]) {
                disconnected[1] = true;
            }
            if (statRestoreDelay > 0) {
                statRestoreDelay--;
            }
            if (clickDelay > 0) {
                clickDelay--;
            }
            if (combatDelay > 0) {
                combatDelay--;
            }
            if (npcDelay > 0) {
                npcDelay--;
            }
            if (teleDelay > 0) {
                teleDelay--;
            }
            if (isDead) {
                deathDelay--;
                applyDead();
            }
            if (eatDelay > 0) {
                eatDelay--;
            }
            if (magicDelay > 0) {
                magicDelay--;
            }
            if (drinkDelay > 0) {	
                drinkDelay--;
            }
            if (skulledDelay > 0) {
                skulledDelay--;
                skulledUpdateReq = true;
            }
            if (jumpDelay > 0) {
                jumpDelay--;
                jumpUpdateReq = true;
            }
    		if (jumpDelay > 0)
    		{
    			jumpDelay--;
    			jumpUpdateReq = true;
    		}
    if (jumpUpdateReq)
    		{
    			if (jumpDelay >= 1)
    			{
    				runEmote = walkEmote = 2750;
    				updateReq = appearanceUpdateReq = true;
    			}
    			if (jumpDelay <= 0)
    			{
    				playerWeapon.setWeapon();
    				jumpDelay = 0;
    				updateReq = appearanceUpdateReq = true;
    			}
    			jumpUpdateReq = false;
    		}
            if (freezeDelay > 0) {
                freezeDelay--;
                stopMovement(this);
            } else if (freezeDelay == 0) {// your allowed to walk, what more you want.
            }
            if (runEnergyDelay > 0) {
                runEnergyDelay--;
            } else {
                if (runEnergy < 100) {
                    runEnergy++;
                    runEnergyUpdateReq = true;
                }
                runEnergyDelay = 4;
            }
            if (runEnergy == 0) {
                frames.setConfig(this, 173, 0);
                isRunning = false;
            }
            if (specialAmountDelay > 0) {
                specialAmountDelay--;
            } else {
                if (specialAmount < 100) {
                    specialAmount++;
                    specialAmountUpdateReq = true;
                }
                specialAmountDelay = 2;
            }
            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 (jumpUpdateReq) {
                if (jumpDelay >= 1) {
                    runEmote = walkEmote = 2750;
                    updateReq = appearanceUpdateReq = true;
                }
                if (jumpDelay <= 0) {
                    playerWeapon.setWeapon();
                    jumpDelay = 0;
                    updateReq = appearanceUpdateReq = true;
                }
                jumpUpdateReq = false;
            }
            if (skulledUpdateReq) {
                if (skulledDelay >= 1) {
                    pkIcon = 0;
                    updateReq = appearanceUpdateReq = true;
                }
                if (skulledDelay <= 0) {
                    pkIcon = -1;
                    skulledDelay = 0;
                    updateReq = appearanceUpdateReq = true;
                }
                skulledUpdateReq = false;
            }
            if (runEnergyUpdateReq) {
                frames.setEnergy(this);
                runEnergyUpdateReq = false;
            }
            if (specialAmountUpdateReq) {
                frames.setConfig(this, 300, specialAmount * 10);
                specialAmountUpdateReq = false;
            }
            if (afterDeathUpdateReq) {
                for (int i = 0; i < skillLvl.length; i++) {
                    skillLvl[i] = getLevelForXP(i);
                    frames.setSkillLvl(this, i);
                }
                Prayer pr = new Prayer();
    
                pr.resetPrayers(this);
                freezeDelay = 0; 
                skulledDelay = 0; 
                specialAmount = 100;
                runEnergy = 100;
                deathDelay = 7;
                specialAmountUpdateReq = true;
                runEnergyUpdateReq = true;
                skulledUpdateReq = true;
                isDead = false;
                afterDeathUpdateReq = 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();
    
                    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;
            }
            checkForAttackOption();
        }
    
    	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;
    }
    
        public void dropAllItems(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;
                }
            }
            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;
                }
            }
            Engine.items.createGroundItem(526, 1, absX, absY, heightLevel,
                    p2.username); // drop bones
            deathMessage = Misc.random(8);
            if (deathMessage == 0) {
                p.frames.sendMessage(p2,
                        "With a crushing blow, you defeat " + username + ".");
            } else if (deathMessage == 1) {
                p.frames.sendMessage(p2,
                        "It's a humiliating defeat for " + username + ".");
            } else if (deathMessage == 2) { 
                p.frames.sendMessage(p2,
                        username + " didn't stand a chance against you.");
            } else if (deathMessage == 3) {
                p.frames.sendMessage(p2, "You have defeated " + username + ".");
            } else if (deathMessage == 4) {
                p.frames.sendMessage(p2,
                        username + " regrets the day they met you in combat.");
            } else if (deathMessage == 5) {
                p.frames.sendMessage(p2, "It's all over for " + username + ".");
            } else if (deathMessage == 6) {
                p.frames.sendMessage(p2, username + " falls before your might.");
            } else if (deathMessage == 7) {
                p.frames.sendMessage(p2,
                        "Can anyone defeat you? Certainly not " + username + ".");
            } else if (deathMessage == 8) {
                p.frames.sendMessage(p2,
                        "You were clearly a better fighter than " + username + ".");
            }
            frames.setItems(this, 149, 0, 93, items, itemsN);
            frames.setItems(this, 387, 28, 94, equipment, equipmentN);
            playerWeapon.setWeapon();
            calculateEquipmentBonus();
        }
    
        /**
         * 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;
        }
    
        /**
         * Death data.
         */
        public void applyDead() {
            if (deathDelay >= 7) {
                if (faceToReq != 65535) {
                    requestFaceTo(65535);
                }
            }
            requestAnim(7197, 0);
    		poisonDamage = 0;
    		poisonTimer = -1;
            if (deathDelay <= 0) {
                dropAllItems(this);
                frames.sendMessage(this, "Oh dear you are dead.");
    			if(bountyArea()) {
    				Engine.bountyhunter.leaveBounty(this);
    				}
                setCoords(2971, 3341, 0);
                afterDeathUpdateReq = 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.showInterface(this, 762);
            frames.setInventory(this, 763);
            frames.setBankOptions(this);
            frames.setItems(this, -1, 64207, 95, bankItems, bankItemsN);
            frames.setItems(this, -1, 64209, 93, items, itemsN);
            frames.setString(this, bankItemCount() + "", 762, 97);
        }
    	public void openLog() {
    frames.showInterface(this, 642);
    }
    public void openHis() {
    frames.showInterface(this, 643);
    }
    public void openGe() {
    frames.showInterface(this, 105);
    }
    public void openSets() {
    frames.showInterface(this, 645 );
    } 
    
        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);
        }
    
    	/**
    	 * 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);
    			Levelup levelup = new Levelup(this, skill);
    			appearanceUpdateReq = true;
    			updateReq = true;
    			levelup = null;
    		}
    		frames.setSkillLvl(this, skill);
    	}
    
        /**
         * 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) {
            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) {
            teleportToX = x;
            teleportToY = y;
            heightLevel = height;
            didTeleport = true;
        }
    
            public void checkForAttackOption()
        {
    	boolean removeWildyLvl;
            if(showAttackOption != Engine.wildernessArea(absX, absY))
            {
                showAttackOption = Engine.wildernessArea(absX, absY);
                if(showAttackOption)
                   {
                    frames.setPlayerOption(this, "Attack", 1);
    		frames.setOverlay(this, 381);
    		removeWildyLvl = true;
                   }
    	    else if(removeWildyLvl = true) {
    	    removeWildyLvl = false;
        		frames.removeOverlay(this);
                    frames.setPlayerOption(this, "null", 1);
                   }
            }
        }
       
    
        /**
         * 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;
        }
    
        /**
         * Prepare player for removal.
         */
        public void destruct() {
    	if(username != null){
    			if(bountyArea())
    				Engine.bountyhunter.leaveBounty(this);
    		}
            stream = null;
            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;
    		    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);
            }
        }
        }
    
        public boolean canAttackPlayer(Player p) {
            Player p2 = Engine.players[p.attackPlayer];
    
            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 (!Engine.wildernessArea(p.absX, p.absY)) {
                return false;
            }
            if (!Engine.wildernessArea(p2.absX, p2.absY)) {
                return false;
            }
            return true;
        }
    
        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;
        }
    
        /**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.addToWalkingQueue(this, firstX, firstY);
        }**/
    
    /**
    * Wilderness ditch jump data.
    */
    //public int jumpDelay = 0;
    //public boolean jumpUpdateReq = false;
    
    	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);
    	}
    
        public int bankItemCount() {
            int count = 0;
    
            for (int i = 0; i < bankItems.length; i++) {
                if (bankItems[i] > 0 && bankItemsN[i] > 0) {
                    count++;
                } else {
                    break;
                }
            }
    		return count;
        }
    }
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •