Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package server.model.players;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- import server.Config;
- import server.event.CycleEvent;
- import server.event.CycleEventContainer;
- import server.event.CycleEventHandler;
- import server.model.items.Item;
- import server.model.items.ItemAssistant;
- import server.model.npcs.NPC;
- import server.model.npcs.NPCHandler;
- import server.model.players.combat.magic.MagicData;
- import server.model.players.skills.Agility;
- import server.model.shops.GrandExchangeItem;
- import server.util.ISAACRandomGen;
- import server.util.Misc;
- import server.util.Stream;
- public abstract class Player {
- public String connectedFrom = "", clanOwner = "", properName, spellName = "Spell";
- private byte chatText[] = new byte[4096], chatTextSize;
- public byte poisonMask, fireMask;
- public int vote, castSpell, castingSpellOnId, skillTask, skillSpeed = 1, pet, timeOutCounter, runEnergy = 100, course1, course2, hitDiff, hitDiff2, rangeStartGfx, rangeProj, gwdPoints[] = new int[4], skillCape, mageArena, currentGameInterface, gameInterface, pheasantAssigned, pheasantKilled, tradeId, challengeId, x1 = -1, y1 = -1, x2 = -1, y2 = -1, speed1 = -1, speed2 = -1, direction = -1, inviteClan, lastGame, kills, deaths, waveId = -1, caveWave = -1, tzhaarNpcs, randomEvent, smithInterface, mapState, poisonDamage, dir1 = -1, dir2 = -1, poimiX, poimiY, oldItem, oldItem2, gainXp, gainXp2, levelReq, levelReq2, newItem, newItem2, doAnim, objectType, chance, EntangleDelay, lastH, lastX, lastY, pNpcId = -1, leatherType, teleotherType, playerTradeWealth, doAmount, tutorial, team, dfsCharge, recoilHits, playerDialogue, playerKilled, totalPlayerDamageDealt, killedBy, lastChatId = 1, privateChat, friendSlot, dialogueId, specEffect, specBarId, followId, skullTimer, nextChat,
- talkingNpc = -1, autocastId = -1, barrageCount, clanId = -1, yInterfaceId, xInterfaceId, xRemoveId, xRemoveSlot, lastNpcAttacked, teleGrabItem, teleGrabX, teleGrabY, underAttackBy, underAttackBy2, teleBlockLength, reduceSpellId, slayerTask, taskAmount, prayerId = -1, headIcon = -1, headIconPk = -1, headIconHints, bowSpecShot, clickNpcType, clickObjectType, objectId, objectWalkX, objectWalkY, objectX, objectY, objectXOffset, objectYOffset, objectDistance, pItemX, pItemY, pItemId, killerId, prayerPrayerBook, playerIndex, oldPlayerIndex, projectileStage, crystalBowArrowCount, playerMagicBook, rangeItemUsed, totalDamageDealt, oldNpcIndex, oldClickNpcIndex, fightMode, fightType, fightStyle, fightXp, attackTimer, npcIndex, npcClickIndex, npcType, castingSpellId = -1, oldSpellId = -1, spellId = -1, myGeId, myShopId, tradeStatus, tradeWith, attackAnim, animationRequest = -1, animationWaitCycles, combatLevel, apset, actionID, wearId, wearSlot, interfaceId,
- XremoveSlot, XinterfaceID, XremoveID, Xamount, smeltType, smeltAmount, smeltTimer, heightLevel, playerSE = 0x328, playerSEW = 0x333, playerSER = 0x334, mapRegionX, mapRegionY, absX, absY, currentX, currentY, wQueueReadPtr, wQueueWritePtr, teleportToX = -1, teleportToY = -1, WillKeepAmt1, WillKeepAmt2, WillKeepAmt3, WillKeepAmt4, WillKeepItem1, WillKeepItem2, WillKeepItem3, WillKeepItem4, WillKeepItem1Slot, WillKeepItem2Slot, WillKeepItem3Slot, WillKeepItem4Slot, EquipStatus, fletchLevelReq, cookingLevelReq, fishingLevelReq, slayerLevelReq, prayerLevelReq, hitpointsLevelReq, attackLevelReq, defenceLevelReq, strengthLevelReq, runeLevelReq, agilityLevelReq, rangeLevelReq, magicLevelReq, thievingLevelReq, fireLevelReq, woodLevelReq, craftLevelReq, duelTeleX, duelTeleY, duelSpaceReq, duelOption, duelingWith, duelStatus, newWalkCmdSteps, face = -1, FocusPointX = -1, FocusPointY = -1, mask100var1, mask100var2, DirectionCount, walkingQueueX[] = new int[Config.walkingQueueSize],
- walkingQueueY[] = new int[Config.walkingQueueSize], itemKeptId[] = new int[4], pouches[] = new int[4], clawHit[] = new int[4], KilledBy[] = new int[Config.MAX_PLAYERS], playerBonus[] = new int[12], keepItems[] = new int[4], keepItemsN[] = new int[4], playerAppearance[] = new int[13];
- protected int NewHp = 10, travelBackX[] = new int[Config.walkingQueueSize], travelBackY[] = new int[Config.walkingQueueSize], numTravelBackSteps;
- private int chatTextColor, chatTextEffects, newWalkCmdX[] = new int[Config.walkingQueueSize], newWalkCmdY[] = new int[Config.walkingQueueSize];
- public boolean entangled, locked, debugCombat, pheasantComplete, wildyWarning, usingMagic, isDreaming, forceMovementUpdateRequired, magicCharge, barrowsNpcDead[] = new boolean[6], duelCanAttack, hasDuelOption, isTeleporting, dfsActive, usingBow, usingArrows, usingOtherRangeWeapons, usingCross, usingBolts, throwAxeSpec, attackOption, updateRequired = true, playerIsPraying, playerIsSmithing, playerIsFishing, playerIsFletching, playerIsMining, playerIsFarming, playerIsFiremaking, playerIsCooking, playerIsWoodcutting, playerIsCrafting, playerIsThieving, playerIsHerbloring, updateInventory, stopPlayerPacket, finishedBarbarianTraining, ignoreDefence, spellBookSwap, hasBankPin, recoverysSet, deleteNPC, castingDamage, attackingPlayer, autoRet, initialized, disconnected, ruleAgreeButton, RebuildNPCList, isActive, isKicked, isSkulled, friendUpdate, hasMultiSign, saveCharacter, mouseButton = true, splitChat, chatEffects = true, acceptAid = true, nextDialogue, autocasting, usedSpecial,
- dbowSpec, craftingLeather, properLogout, secDbow, maxNextHit, ssSpec, vengOn, canChangeAppearance, mageAllowed, usingPrayer, usingSpecial, npcDroppingItems, castingMagic, oldMagicFailed, isMoving, walkingToItem, isShopping, updateShop, forcedChatUpdateRequired, inDuel, tradeAccepted, goodTrade, inTrade, tradeRequested, tradeResetNeeded, tradeConfirmed, tradeConfirmed2, canOffer, acceptTrade, acceptedTrade, runOption, takeAsNote, saveFile, usingGlory, smeltInterface, secondHerb, duelRequested, hitUpdateRequired, isDead, appearanceUpdateRequired = true, invSlot[] = new boolean[28], equipSlot[] = new boolean[14], canUseReducingSpell[] = {true, true, true, true, true, true}, duelRule[] = new boolean[22];
- protected boolean didTeleport, mapRegionDidChange, createItems, faceUpdateRequired, mask100update, hitUpdateRequired2;
- private boolean newWalkCmdIsRunning, chatTextUpdateRequired;
- public long lastRunDrain, lastRunRecovery, antiFirePot, frozen, immuneToFreeze, immuneToPoison, lastPlayerMove, playerStun, lastProtItem, dfsDelay, lastVeng, lastYell, teleGrabDelay, protMageDelay, protMeleeDelay, protRangeDelay, lastAction, alchDelay, duelDelay, teleBlockDelay, singleCombatDelay, singleCombatDelay2, reduceStat, buryDelay, foodDelay, potDelay, lastFire, agilityDelay, logoutDelay, stopPrayerDelay, prayerDelay, friends[] = new long[200], ignores[] = new long[200], reduceSpellDelay[] = new long[6];
- public double specAmount, specAccuracy = 1, specDamage = 1, prayerPoint = 1, crossbowDamage;
- public CycleEvent skilling, spellSwap;
- public ArrayList<GrandExchangeItem> GE;
- public boolean poisonweapon(String p) {
- if (playerEquipment[Config.WEAPON] < 1) {
- return false;
- }
- return ItemAssistant.getItemName(playerEquipment[Config.WEAPON]).endsWith(p);
- }
- public boolean poisonrange(String p) {
- if (playerEquipment[Config.ARROWS] < 1) {
- return false;
- }
- return ItemAssistant.getItemName(playerEquipment[Config.ARROWS]).endsWith(p);
- }
- public Map<String, Integer> killedPlayers = new HashMap<String, Integer>();
- public ArrayList<Integer> attackedPlayers = new ArrayList<Integer>();
- public void setForceMovement(final int x, final int y, final int speed1, final int speed2, final int direction, final int endAnim, final int time, final int height, final boolean stopPacket) {
- final int endX = getX() + x;
- final int endY = getY() + y;
- this.x1 = currentX;
- this.y1 = currentY;
- this.x2 = currentX + x;
- this.y2 = currentY + y;
- this.speed1 = speed1;
- this.speed2 = speed2;
- this.direction = direction;
- updateRequired = true;
- forceMovementUpdateRequired = true;
- if (stopPacket) {
- stopPlayerPacket = true;
- }
- final Client c = (Client) this;
- CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
- @Override
- public void execute(CycleEventContainer container) {
- if (endAnim > 0) {
- c.startAnimation(endAnim);
- }
- container.stop();
- }
- @Override
- public void stop() {
- }
- }, time - 1);
- CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
- @Override
- public void execute(CycleEventContainer container) {
- updateRequired = true;
- forceMovementUpdateRequired = false;
- if (stopPacket) {
- stopPlayerPacket = false;
- }
- c.getPA().movePlayer(endX, endY, height);
- c.getCombat().getPlayerAnimIndex();
- container.stop();
- }
- @Override
- public void stop() {
- }
- }, time);
- }
- public void appendMask400Update(Stream str) {
- str.writeByteS(x1);
- str.writeByteS(y1);
- str.writeByteS(x2);
- str.writeByteS(y2);
- str.writeWordBigEndianA(speed1);
- str.writeWordA(speed2);
- str.writeByteS(direction);
- }
- public boolean Area(int x, int x1, int y, int y1) {
- return absX >= x && absX <= x1 && absY >= y && absY <= y1;
- }
- public boolean Area(int x, int x1, int y, int y1, int x2, int y2) {
- return x2 >= x && x2 <= x1 && y2 >= y && y2 <= y1;
- }
- public boolean inCwSafe() {
- return (Area(2423, 2431, 3072, 3080) || Area(2368, 2376, 3127, 3135)) && heightLevel == 1;
- }
- public boolean inZammyWait() {
- return Area(2409, 2431, 9511, 9535);
- }
- public boolean inSaraWait() {
- return Area(2368, 2392, 9479, 9498);
- }
- public boolean inCwGame() {
- return Area(2368, 2431, 9479, 9535) || Area(2368, 2431, 3072, 3135) && !inSaraWait() && !inZammyWait();
- }
- public boolean inCwUnderground() {
- return Area(2368, 2431, 9479, 9535) && !inSaraWait() && !inZammyWait();
- }
- public boolean inZammyBase() {
- return Area(2368, 2384, 3118, 3135);
- }
- public boolean inSaraBase() {
- return Area(2414, 2431, 3072, 3088);
- }
- public boolean inPits() {
- return Area(2370, 2430, 5122, 5168);
- }
- public boolean inPitsWait() {
- return Area(2394, 2404, 5169, 5175);
- }
- public boolean inCaves() {
- return Area(2371, 2422, 5062, 5117);
- }
- public boolean inDuelArena() {
- return Area(3331, 3390, 3205, 3259);
- }
- public boolean inDuelArea() {
- return Area(3325, 3410, 3200, 3266) || Area(3341, 3410, 3267, 3288) || Area(3312, 3322, 3224, 3247) && !inDuelArena();
- }
- public boolean inRestrictedArea() {
- return Area(3276, 3289, 3330, 3332) || Area(2240, 2241, 3233, 3237);
- }
- public boolean inMageArena() {
- return Area(3078, 3133, 3908, 3959) && heightLevel > 3;
- }
- public boolean inWild() {
- return Area(2942, 3391, 3519, 3965) || Area(2942, 3391, 9919, 10365) && !inMageArena();
- }
- public boolean inSafePvp() {
- return Area(2582, 2606, 3152, 3171);
- }
- public boolean inSafePvpArea() {
- return Area(2577, 2623, 3134, 3178);
- }
- public boolean inPcBoat() {
- return Area(2660, 2663, 2638, 2643);
- }
- public boolean inPcGame() {
- return Area(2624, 2690, 2550, 2619);
- }
- // Bandos, Arma, Sara, Zammy
- public boolean inGwdChamber() {
- return Area(2864, 2876, 5351, 5369) || Area(2824, 2842, 5296, 5308) || Area(2889, 2907, 5258, 5276) || Area(2918, 2936, 5318, 5331);
- }
- public boolean inGwd() {
- return Area(2792, 2952, 5235, 5394);
- }
- public boolean inMulti() {
- return Area(3136, 3327, 3519, 3607) || Area(3190, 3327, 3648, 3839) || Area(3200, 3390, 3840, 3967) || Area(2992, 3007, 3912, 3967) || Area(2946, 2959, 3816, 3831) || Area(3008, 3199, 3856, 3903) || Area(3008, 3071, 3600, 3711) || Area(3072, 3327, 3608, 3647) || Area(2624, 2690, 2550, 2619) || Area(2896, 2927, 3595, 3630) || Area(2892, 2932, 4435, 4464) || Area(2256, 2287, 4680, 4711) || Area(2863, 2878, 5350, 5372) || Area(2396, 2435, 4691, 4739) || Area(2365, 2395, 4702, 4739) || Area(3461, 3514, 9473, 9525) || Area(2448, 2481, 4764, 4795) || Area(2703, 2734, 9797, 9832) || inCwGame() || inPits() || inCaves() || inSafePvp() || inGwd();
- }
- public boolean rangableArea(int x, int y) {
- return Area(2414, 2416, 3074, 3085, x, y) || Area(2418, 2424, 3087, 3089, x, y) || Area(2412, 2417, 3086, 3091, x, y) || Area(2383, 2385, 3122, 3133, x, y) || Area(2375, 2381, 3118, 3120, x, y) || Area(2382, 2387, 3116, 3121, x, y);
- }
- public boolean nonRangableArea(int x, int y) {
- return Area(2382, 2385, 3134, 3135, x, y) || Area(2368, 2379, 3124, 3135, x, y) || Area(2414, 2417, 3072, 3074, x, y) || Area(2420, 2431, 3072, 3083, x, y);
- }
- public boolean inRandomEvent() {
- return Area(2587, 2619, 4760, 4785);
- }
- public boolean inBank() {
- return absX > 3090 && absX < 3099 && absY > 3487 && absY < 3500 || absX > 3089 && absX < 3090 && absY > 3492 && absY < 3498 || absX > 3248 && absX < 3258 && absY > 3413 && absY < 3428 || absX > 3179 && absX < 3191 && absY > 3432 && absY < 3448 || absX > 2944 && absX < 2948 && absY > 3365 && absY < 3374 || absX > 2942 && absX < 2948 && absY > 3367 && absY < 3374 || absX > 2944 && absX < 2950 && absY > 3365 && absY < 3370 || absX > 3008 && absX < 3019 && absY > 3352 && absY < 3359 || absX > 3017 && absX < 3022 && absY > 3352 && absY < 3357 || absX > 3203 && absX < 3213 && absY > 3200 && absY < 3237 || absX > 3212 && absX < 3215 && absY > 3200 && absY < 3235 || absX > 3215 && absX < 3220 && absY > 3202 && absY < 3235 || absX > 3220 && absX < 3227 && absY > 3202 && absY < 3229 || absX > 3227 && absX < 3230 && absY > 3208 && absY < 3226 || absX > 3226 && absX < 3228 && absY > 3230 && absY < 3211 || absX > 3227 && absX < 3229 && absY > 3208 && absY < 3226 && heightLevel == 4;
- }
- public boolean cantTeleport() {
- return tutorial < 11 || inRandomEvent() || inPits() || inPitsWait() || inCaves() || inDuelArena() || saraTeam() || zammyTeam();
- }
- public boolean inSpawnPvp() {
- return false;
- }
- public void updateHp(int chHp, boolean heal) {
- if (heal) {
- NewHp += chHp;
- if (NewHp > getPlayerLevel(Config.HITPOINTS)) {
- chHp = NewHp - getPlayerLevel(Config.HITPOINTS);
- NewHp = getPlayerLevel(Config.HITPOINTS);
- }
- subtractDamage(chHp);
- } else if (!heal) {
- if (!isTeleporting) {
- NewHp -= chHp;
- if (NewHp < 0) {
- NewHp = 0;
- }
- }
- }
- playerLevel[Config.HITPOINTS] = NewHp;
- NewHp = playerLevel[Config.HITPOINTS];
- }
- public void subtractDamage(int dmg) {
- for (int i = 1; i < KilledBy.length; i++) {
- KilledBy[i] -= dmg;
- if (KilledBy[i] < 0) {
- KilledBy[i] = 0;
- }
- }
- }
- public void lowGFX(int id, int delay) {
- mask100var1 = id;
- mask100var2 = delay;
- mask100update = true;
- updateRequired = true;
- }
- public boolean isAutoButton(int button) {
- for (int j = 0; j < Config.autocastIds.length; j += 2) {
- if (Config.autocastIds[j] == button) {
- return true;
- }
- }
- return false;
- }
- public void assignAutocast(int button) {
- for (int j = 0; j < Config.autocastIds.length; j++) {
- if (Config.autocastIds[j] == button) {
- Client c = (Client) PlayerHandler.players[playerId];
- c.autocasting = true;
- c.autocastId = Config.autocastIds[j + 1];
- c.getPA().setConfig(108, 1);
- c.setSidebarInterface(0, 328);
- c.spellName = MagicData.getSpellName(c.autocastId);
- c.getPA().sendFrame126(c.spellName, 354);
- c = null;
- break;
- }
- }
- }
- public boolean fullVoid(String s) {
- return playerEquipment[Config.HAT] == (s == "Melee" ? 11665 : s == "Range" ? 11664 : 11663) && playerEquipment[Config.LEGS] == 8840 && playerEquipment[Config.CHEST] == 8839 && playerEquipment[Config.HANDS] == 8842;
- }
- public boolean[] prayerActive = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
- public abstract void initialize();
- public abstract void update();
- public int playerId = -1;
- public PlayerHandler handler = null;
- public String playerName = null;
- public String playerName2 = null;
- public String playerPass = null;
- public int playerRights;
- public int playerItems[] = new int[28];
- public int playerItemsN[] = new int[28];
- public int bankItems[] = new int[Config.BANK_SIZE];
- public int bankItemsN[] = new int[Config.BANK_SIZE];
- public boolean bankNotes;
- public int playerStandIndex = 0x328;
- public int playerTurnIndex = 0x337;
- public int playerWalkIndex = 0x333;
- public int playerTurn180Index = 0x334;
- public int playerTurn90CWIndex = 0x335;
- public int playerTurn90CCWIndex = 0x336;
- public int playerRunIndex = 0x338;
- public int[] playerEquipment = new int[14];
- public int[] playerEquipmentN = new int[14];
- public int[] playerLevel = new int[22];
- public int[] playerXP = new int[22];
- public void updateshop(int i) {
- Client p = (Client) PlayerHandler.players[playerId];
- p.getShops().resetShop(i);
- }
- public void println_debug(String str) {
- System.out.println("[player-" + playerId + "]: " + str);
- }
- public void println(String str) {
- System.out.println("[player-" + playerId + "]: " + str);
- }
- public Player(int _playerId) {
- playerId = _playerId;
- playerRights = 0;
- for (int i = 0; i < playerItems.length; i++) {
- playerItems[i] = 0;
- }
- for (int i = 0; i < playerItemsN.length; i++) {
- playerItemsN[i] = 0;
- }
- for (int i = 0; i < playerLevel.length; i++) {
- if (i == 3) {
- playerLevel[i] = 10;
- } else {
- playerLevel[i] = 1;
- }
- }
- for (int i = 0; i < playerXP.length; i++) {
- if (i == 3) {
- playerXP[i] = 1300;
- } else {
- playerXP[i] = 0;
- }
- }
- for (int i = 0; i < Config.BANK_SIZE; i++) {
- bankItems[i] = 0;
- }
- for (int i = 0; i < Config.BANK_SIZE; i++) {
- bankItemsN[i] = 0;
- }
- playerAppearance[0] = 0; // gender
- playerAppearance[1] = 7; // head
- playerAppearance[2] = 25;// Torso
- playerAppearance[3] = 29; // arms
- playerAppearance[4] = 35; // hands
- playerAppearance[5] = 39; // legs
- playerAppearance[6] = 44; // feet
- playerAppearance[7] = 14; // beard
- playerAppearance[8] = 7; // hair colour
- playerAppearance[9] = 8; // torso colour
- playerAppearance[10] = 9; // legs colour
- playerAppearance[11] = 5; // feet colour
- playerAppearance[12] = 0; // skin colour
- apset = 0;
- actionID = 0;
- playerEquipment[Config.HAT] = -1;
- playerEquipment[Config.CAPE] = -1;
- playerEquipment[Config.AMULET] = -1;
- playerEquipment[Config.CHEST] = -1;
- playerEquipment[Config.SHIELD] = -1;
- playerEquipment[Config.LEGS] = -1;
- playerEquipment[Config.HANDS] = -1;
- playerEquipment[Config.FEET] = -1;
- playerEquipment[Config.RING] = -1;
- playerEquipment[Config.ARROWS] = -1;
- playerEquipment[Config.WEAPON] = -1;
- heightLevel = 0;
- if (Config.countY > 10) {
- Config.countY = 0;
- Config.countX++;
- }
- teleportToX = Config.START_LOCATION_X + Config.countX;
- teleportToY = Config.START_LOCATION_Y + (Config.countY++);
- absX = absY = -1;
- mapRegionX = mapRegionY = -1;
- currentX = currentY = 0;
- resetWalkingQueue();
- }
- void destruct() {
- playerListSize = 0;
- for (int i = 0; i < maxPlayerListSize; i++) {
- playerList[i] = null;
- }
- absX = absY = -1;
- mapRegionX = mapRegionY = -1;
- currentX = currentY = 0;
- resetWalkingQueue();
- }
- public static final int maxPlayerListSize = Config.MAX_PLAYERS;
- public Player playerList[] = new Player[maxPlayerListSize];
- public int playerListSize = 0;
- public byte playerInListBitmap[] = new byte[Config.MAX_PLAYERS + 7 >> 3];
- public static final int maxNPCListSize = NPCHandler.maxNPCs;
- public NPC npcList[] = new NPC[maxNPCListSize];
- public int npcListSize = 0;
- public byte npcInListBitmap[] = new byte[NPCHandler.maxNPCs + 7 >> 3];
- public boolean withinDistance(Player otherPlr) {
- if (heightLevel != otherPlr.heightLevel) {
- return false;
- }
- int deltaX = otherPlr.absX - absX, deltaY = otherPlr.absY - absY;
- return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
- }
- public boolean withinDistance(NPC npc) {
- if (heightLevel != npc.heightLevel) {
- return false;
- }
- if (npc.needRespawn == true) {
- return false;
- }
- int deltaX = npc.absX - absX, deltaY = npc.absY - absY;
- return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
- }
- public int distanceToPoint(int pointX, int pointY) {
- return (int) Math.sqrt(Math.pow(absX - pointX, 2) + Math.pow(absY - pointY, 2));
- }
- public void resetWalkingQueue() {
- wQueueReadPtr = wQueueWritePtr;
- for (int i = 0; i < Config.walkingQueueSize; i++) {
- walkingQueueX[i] = currentX;
- walkingQueueY[i] = currentY;
- }
- }
- public void addToWalkingQueue(int x, int y) {
- int next = (wQueueWritePtr + 1) % Config.walkingQueueSize;
- if (next == wQueueWritePtr) {
- return;
- }
- walkingQueueX[wQueueWritePtr] = x;
- walkingQueueY[wQueueWritePtr] = y;
- wQueueWritePtr = next;
- }
- public boolean checkBarricade(int X, int Y) {
- for (int i = 0; i < NPCHandler.maxNPCs; i++) {
- if (NPCHandler.npcs[i] != null) {
- if (NPCHandler.npcs[i].npcType == 1532 || NPCHandler.npcs[i].npcType == 1533 || NPCHandler.npcs[i].npcType == 1534 || NPCHandler.npcs[i].npcType == 1535) {
- if (NPCHandler.npcs[i].heightLevel == heightLevel) {
- if (NPCHandler.npcs[i].absX == X && NPCHandler.npcs[i].absY == Y) {
- return false;
- }
- if (NPCHandler.npcs[i].absX == absX && NPCHandler.npcs[i].absY - absY == 1 && Y - absY == 1) {
- return false;
- }
- if (NPCHandler.npcs[i].absX == absX && NPCHandler.npcs[i].absY - absY == -1 && Y - absY == -1) {
- return false;
- }
- if (NPCHandler.npcs[i].absY == absY && NPCHandler.npcs[i].absX - absX == 1 && X - absX == 1) {
- return false;
- }
- if (NPCHandler.npcs[i].absY == absY && NPCHandler.npcs[i].absX - absX == -1 && X - absX == -1) {
- return false;
- }
- }
- }
- }
- }
- return true;
- }
- public int getNextWalkingDirection() {
- if (wQueueReadPtr == wQueueWritePtr) {
- return -1;
- }
- int dir;
- do {
- dir = Misc.direction(currentX, currentY, walkingQueueX[wQueueReadPtr], walkingQueueY[wQueueReadPtr]);
- if (dir == -1) {
- wQueueReadPtr = (wQueueReadPtr + 1) % Config.walkingQueueSize;
- } else if ((dir & 1) != 0) {
- println_debug("Invalid waypoint in walking queue!");
- resetWalkingQueue();
- return -1;
- }
- } while (dir == -1 && wQueueReadPtr != wQueueWritePtr);
- if (dir == -1) {
- return -1;
- }
- dir >>= 1;
- int tempabsX = absX + Misc.directionDeltaX[dir];
- int tempabsY = absY + Misc.directionDeltaY[dir];
- if (checkBarricade(tempabsX, tempabsY)) {
- currentX += Misc.directionDeltaX[dir];
- currentY += Misc.directionDeltaY[dir];
- absX += Misc.directionDeltaX[dir];
- absY += Misc.directionDeltaY[dir];
- if (isRunning()) {
- Client c = (Client) this;
- if (runEnergy > 0) {
- if (System.currentTimeMillis() > Agility.getAgilityRunDrain(c) + lastRunDrain) {
- runEnergy--;
- lastRunDrain = System.currentTimeMillis();
- c.getPA().sendFrame126(runEnergy + "%", 149);
- }
- } else {
- runOption = false;
- c.getPA().setConfig(173, 0);
- }
- }
- return dir;
- } else {
- return -1;
- }
- }
- public void resetFollowers() {
- for (int j = 0; j < Config.MAX_PLAYERS; j++) {
- if (PlayerHandler.players[j] == null) {
- continue;
- }
- if (j == playerId) {
- continue;
- }
- if (PlayerHandler.players[j].followId == playerId) {
- PlayerHandler.players[j].followId = -1;
- }
- }
- }
- public void getNextPlayerMovement() {
- mapRegionDidChange = false;
- didTeleport = false;
- dir1 = dir2 = -1;
- if (teleportToX != -1 && teleportToY != -1) {
- mapRegionDidChange = true;
- if (mapRegionX != -1 && mapRegionY != -1) {
- int relX = teleportToX - mapRegionX * 8, relY = teleportToY - mapRegionY * 8;
- if (relX >= 2 * 8 && relX < 11 * 8 && relY >= 2 * 8 && relY < 11 * 8) {
- mapRegionDidChange = false;
- }
- }
- if (mapRegionDidChange) {
- mapRegionX = (teleportToX >> 3) - 6;
- mapRegionY = (teleportToY >> 3) - 6;
- }
- currentX = teleportToX - 8 * mapRegionX;
- currentY = teleportToY - 8 * mapRegionY;
- absX = teleportToX;
- absY = teleportToY;
- resetWalkingQueue();
- teleportToX = teleportToY = -1;
- didTeleport = true;
- } else {
- dir1 = getNextWalkingDirection();
- if (dir1 == -1) {
- return;
- }
- if ((runOption || isNewWalkCmdIsRunning()) && runEnergy > 0) {
- dir2 = getNextWalkingDirection();
- }
- int deltaX = 0, deltaY = 0;
- if (currentX < 2 * 8) {
- deltaX = 4 * 8;
- mapRegionX -= 4;
- mapRegionDidChange = true;
- } else if (currentX >= 11 * 8) {
- deltaX = -4 * 8;
- mapRegionX += 4;
- mapRegionDidChange = true;
- }
- if (currentY < 2 * 8) {
- deltaY = 4 * 8;
- mapRegionY -= 4;
- mapRegionDidChange = true;
- } else if (currentY >= 11 * 8) {
- deltaY = -4 * 8;
- mapRegionY += 4;
- mapRegionDidChange = true;
- }
- if (mapRegionDidChange) {
- currentX += deltaX;
- currentY += deltaY;
- for (int i = 0; i < Config.walkingQueueSize; i++) {
- walkingQueueX[i] += deltaX;
- walkingQueueY[i] += deltaY;
- }
- }
- }
- }
- public void updateThisPlayerMovement(Stream str) {
- if (mapRegionDidChange) {
- str.createFrame(73);
- str.writeWordA(mapRegionX + 6);
- str.writeWord(mapRegionY + 6);
- }
- if (didTeleport) {
- str.createFrameVarSizeWord(81);
- str.initBitAccess();
- str.writeBits(1, 1);
- str.writeBits(2, 3);
- str.writeBits(2, heightLevel);
- str.writeBits(1, 1);
- str.writeBits(1, updateRequired ? 1 : 0);
- str.writeBits(7, currentY);
- str.writeBits(7, currentX);
- return;
- }
- if (dir1 == -1) {
- // don't have to update the character position, because we're
- // just standing
- str.createFrameVarSizeWord(81);
- str.initBitAccess();
- isMoving = false;
- if (updateRequired) {
- // tell client there's an update block appended at the end
- str.writeBits(1, 1);
- str.writeBits(2, 0);
- } else {
- str.writeBits(1, 0);
- }
- if (DirectionCount < 50) {
- DirectionCount++;
- }
- } else {
- DirectionCount = 0;
- str.createFrameVarSizeWord(81);
- str.initBitAccess();
- str.writeBits(1, 1);
- if (dir2 == -1) {
- isMoving = true;
- str.writeBits(2, 1);
- str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
- if (updateRequired) {
- str.writeBits(1, 1);
- } else {
- str.writeBits(1, 0);
- }
- } else {
- isMoving = true;
- str.writeBits(2, 2);
- str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
- str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
- if (updateRequired) {
- str.writeBits(1, 1);
- } else {
- str.writeBits(1, 0);
- }
- }
- }
- }
- public void updatePlayerMovement(Stream str) {
- if (dir1 == -1) {
- if (updateRequired || isChatTextUpdateRequired()) {
- str.writeBits(1, 1);
- str.writeBits(2, 0);
- } else {
- str.writeBits(1, 0);
- }
- } else if (dir2 == -1) {
- str.writeBits(1, 1);
- str.writeBits(2, 1);
- str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
- str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1 : 0);
- } else {
- str.writeBits(1, 1);
- str.writeBits(2, 2);
- str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
- str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
- str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1 : 0);
- }
- }
- public byte cachedPropertiesBitmap[] = new byte[Config.MAX_PLAYERS + 7 >> 3];
- public void addNewNPC(NPC npc, Stream str, Stream updateBlock) {
- int id = npc.npcId;
- npcInListBitmap[id >> 3] |= 1 << (id & 7);
- npcList[npcListSize++] = npc;
- str.writeBits(14, id);
- int z = npc.absY - absY;
- if (z < 0) {
- z += 32;
- }
- str.writeBits(5, z);
- z = npc.absX - absX;
- if (z < 0) {
- z += 32;
- }
- str.writeBits(5, z);
- str.writeBits(1, 0);
- str.writeBits(14, npc.npcType);// NPC FIX
- boolean savedUpdateRequired = npc.updateRequired;
- npc.updateRequired = true;
- npc.appendNPCUpdateBlock(updateBlock);
- npc.updateRequired = savedUpdateRequired;
- str.writeBits(1, 1);
- }
- public void addNewPlayer(Player plr, Stream str, Stream updateBlock) {
- if (playerListSize >= 255) {
- return;
- }
- int id = plr.playerId;
- playerInListBitmap[id >> 3] |= 1 << (id & 7);
- playerList[playerListSize++] = plr;
- str.writeBits(11, id);
- str.writeBits(1, 1);
- boolean savedFlag = plr.isAppearanceUpdateRequired();
- boolean savedUpdateRequired = plr.updateRequired;
- plr.setAppearanceUpdateRequired(true);
- plr.updateRequired = true;
- plr.appendPlayerUpdateBlock(updateBlock);
- plr.setAppearanceUpdateRequired(savedFlag);
- plr.updateRequired = savedUpdateRequired;
- str.writeBits(1, 1);
- int z = plr.absY - absY;
- if (z < 0) {
- z += 32;
- }
- str.writeBits(5, z);
- z = plr.absX - absX;
- if (z < 0) {
- z += 32;
- }
- str.writeBits(5, z);
- }
- protected static Stream playerProps;
- static {
- playerProps = new Stream(new byte[100]);
- }
- protected void appendPlayerAppearance(Stream str) {
- playerProps.currentOffset = 0;
- playerProps.writeByte(playerAppearance[0]);
- playerProps.writeByte(headIcon);
- playerProps.writeByte(headIconPk);
- if (pNpcId < 1) {
- if (playerEquipment[Config.HAT] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[Config.HAT]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[Config.CAPE] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[Config.CAPE]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[Config.AMULET] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[Config.AMULET]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[Config.WEAPON] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[Config.WEAPON]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[Config.CHEST] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[Config.CHEST]);
- } else {
- playerProps.writeWord(0x100 + playerAppearance[2]);
- }
- if (playerEquipment[Config.SHIELD] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[Config.SHIELD]);
- } else {
- playerProps.writeByte(0);
- }
- if (!Item.isFullBody(playerEquipment[Config.CHEST])) {
- playerProps.writeWord(0x100 + playerAppearance[3]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[Config.LEGS] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[Config.LEGS]);
- } else {
- playerProps.writeWord(0x100 + playerAppearance[5]);
- }
- if (!Item.isFullHelm(playerEquipment[Config.HAT]) && !Item.isFullMask(playerEquipment[Config.HAT])) {
- playerProps.writeWord(0x100 + playerAppearance[1]);
- } else {
- playerProps.writeByte(0);
- }
- if (playerEquipment[Config.HANDS] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[Config.HANDS]);
- } else {
- playerProps.writeWord(0x100 + playerAppearance[4]);
- }
- if (playerEquipment[Config.FEET] > 1) {
- playerProps.writeWord(0x200 + playerEquipment[Config.FEET]);
- } else {
- playerProps.writeWord(0x100 + playerAppearance[6]);
- }
- if (playerAppearance[0] != 1 && !Item.isFullMask(playerEquipment[Config.HAT])) {
- playerProps.writeWord(0x100 + playerAppearance[7]);
- } else {
- playerProps.writeByte(0);
- }
- } else {
- playerProps.writeWord(-1);
- playerProps.writeWord(pNpcId);
- }
- playerProps.writeByte(playerAppearance[8]);
- playerProps.writeByte(playerAppearance[9]);
- playerProps.writeByte(playerAppearance[10]);
- playerProps.writeByte(playerAppearance[11]);
- playerProps.writeByte(playerAppearance[12]);
- playerProps.writeWord(playerStandIndex); // standAnimIndex
- playerProps.writeWord(playerTurnIndex); // standTurnAnimIndex
- playerProps.writeWord(playerWalkIndex); // walkAnimIndex
- playerProps.writeWord(playerTurn180Index); // turn180AnimIndex
- playerProps.writeWord(playerTurn90CWIndex); // turn90CWAnimIndex
- playerProps.writeWord(playerTurn90CCWIndex); // turn90CCWAnimIndex
- playerProps.writeWord(playerRunIndex); // runAnimIndex
- playerProps.writeQWord(Misc.playerNameToInt64(playerName));
- combatLevel = ((Client) this).getCombatLevel();
- playerProps.writeByte(combatLevel); // combat level
- playerProps.writeWord(0);
- str.writeByteC(playerProps.currentOffset);
- str.writeBytes(playerProps.buffer, playerProps.currentOffset, 0);
- }
- public int getLevelForXP(int exp) {
- int points = 0;
- int output = 0;
- if (exp > 13034430) {
- return 99;
- }
- for (int lvl = 1; lvl <= 99; lvl++) {
- points += Math.floor(lvl + 300.0 * Math.pow(2.0, lvl / 7.0));
- output = (int) Math.floor(points / 4);
- if (output >= exp) {
- return lvl;
- }
- }
- return 0;
- }
- public int getPlayerLevel(int level) {
- return getLevelForXP(playerXP[level]);
- }
- protected void appendPlayerChatText(Stream str) {
- str.writeWordBigEndian(((getChatTextColor() & 0xFF) << 8) + (getChatTextEffects() & 0xFF));
- str.writeByte(playerRights);
- str.writeByteC(getChatTextSize());
- str.writeBytes_reverse(getChatText(), getChatTextSize(), 0);
- }
- public void forcedChat(String text) {
- forcedText = text;
- forcedChatUpdateRequired = true;
- updateRequired = true;
- setAppearanceUpdateRequired(true);
- }
- public String forcedText = "null";
- public void appendForcedChat(Stream str) {
- str.writeString(forcedText);
- }
- /**
- * Graphics
- **/
- public void appendMask100Update(Stream str) {
- str.writeWordBigEndian(mask100var1);
- str.writeDWord(mask100var2);
- }
- public void gfx100(int gfx) {
- mask100var1 = gfx;
- mask100var2 = 6553600;
- mask100update = true;
- updateRequired = true;
- }
- public void gfx0(int gfx) {
- mask100var1 = gfx;
- mask100var2 = 65536;
- mask100update = true;
- updateRequired = true;
- }
- public boolean wearing2h() {
- Client c = (Client) this;
- String s = ItemAssistant.getItemName(c.playerEquipment[Config.WEAPON]);
- if (s.contains("2h")) {
- return true;
- } else if (s.contains("godsword")) {
- return true;
- }
- return false;
- }
- /**
- * Animations
- **/
- public void startAnimation(int animId) {
- // if (wearing2h() && animId == 829)
- // return;
- if ((isDead || playerLevel[Config.HITPOINTS] <= 0) && animId != 0x900) {
- return;
- }
- animationRequest = animId;
- animationWaitCycles = 0;
- updateRequired = true;
- }
- public void startAnimation(int animId, int time) {
- animationRequest = animId;
- animationWaitCycles = time;
- updateRequired = true;
- }
- public void appendAnimationRequest(Stream str) {
- str.writeWordBigEndian(animationRequest == -1 ? 65535 : animationRequest);
- str.writeByteC(animationWaitCycles);
- }
- /**
- * Face Update
- **/
- public void facePlayer(int player) {
- face = player + 32768;
- faceUpdateRequired = true;
- updateRequired = true;
- }
- public void faceNpc(int npc) {
- face = npc;
- faceUpdateRequired = true;
- updateRequired = true;
- }
- public void appendFaceUpdate(Stream str) {
- str.writeWordBigEndian(face);
- }
- public void turnPlayerTo(int pointX, int pointY) {
- FocusPointX = 2 * pointX + 1;
- FocusPointY = 2 * pointY + 1;
- updateRequired = true;
- }
- private void appendSetFocusDestination(Stream str) {
- str.writeWordBigEndianA(FocusPointX);
- str.writeWordBigEndian(FocusPointY);
- }
- /**
- * Hit Update
- **/
- protected void appendHitUpdate(Stream str) {
- str.writeByte(getHitDiff()); // What the perseon got 'hit' for
- if (fireMask == 1) {
- str.writeByteA(3);
- fireMask = -1;
- } else if (poisonMask == 1) {
- str.writeByteA(2);
- poisonMask = -1;
- } else if (getHitDiff() > 0) {
- str.writeByteA(1); // red hitting
- } else {
- str.writeByteA(0); // blue hitting
- }
- if (playerLevel[Config.HITPOINTS] < 1) {
- playerLevel[Config.HITPOINTS] = 0;
- }
- str.writeByteC(playerLevel[Config.HITPOINTS]); // Their current hp,
- // for HP bar
- str.writeByte(getPlayerLevel(Config.HITPOINTS)); // Their max hp, for HP
- // bar
- }
- protected void appendHitUpdate2(Stream str) {
- str.writeByte(getHitDiff2()); // What the person got 'hit' for
- if (fireMask == 2) {
- str.writeByteS(3);
- fireMask = -1;
- } else if (poisonMask == 2) {
- str.writeByteS(2);
- poisonMask = -1;
- } else if (getHitDiff2() > 0) {
- str.writeByteS(1); // red hitting
- } else {
- str.writeByteS(0); // blue hitting
- }
- if (playerLevel[Config.HITPOINTS] < 1) {
- playerLevel[Config.HITPOINTS] = 0;
- }
- str.writeByte(playerLevel[Config.HITPOINTS]);
- str.writeByteC(getPlayerLevel(Config.HITPOINTS));
- }
- /*protected void appendHitUpdate(Stream str) {
- str.writeByte(getHitDiff()); // What the perseon got 'hit' for
- if (fireMask == 1) {
- str.writeByteS(1);
- fireMask = -1;
- } else if (poisonMask == 1) {
- str.writeByteS(2);
- poisonMask = -1;
- } else {
- str.writeByteS(0); // red hitting
- }
- if (playerLevel[Config.HITPOINTS] < 1) {
- playerLevel[Config.HITPOINTS] = 0;
- }
- str.writeByte(0);
- str.writeByteC(playerLevel[Config.HITPOINTS]); // Their current hp,
- // for HP bar
- str.writeByte(getPlayerLevel(Config.HITPOINTS)); // Their max hp, for HP
- // bar
- }
- protected void appendHitUpdate2(Stream str) {
- str.writeByte(getHitDiff2()); // What the person got 'hit' for
- if (fireMask == 2) {
- str.writeByteS(1);
- fireMask = -1;
- } else if (poisonMask == 2) {
- str.writeByteS(2);
- poisonMask = -1;
- } else {
- str.writeByteS(0); // red hitting
- }
- if (playerLevel[Config.HITPOINTS] < 1) {
- playerLevel[Config.HITPOINTS] = 0;
- }
- str.writeByte(0);
- str.writeByte(playerLevel[Config.HITPOINTS]);
- str.writeByteC(getPlayerLevel(Config.HITPOINTS));
- }*/
- public void appendPlayerUpdateBlock(Stream str) {
- if (!updateRequired && !isChatTextUpdateRequired()) {
- return; // nothing required
- }
- int updateMask = 0;
- if (forceMovementUpdateRequired) {
- updateMask |= 0x400;
- }
- if (mask100update) {
- updateMask |= 0x100;
- }
- if (animationRequest != -1) {
- updateMask |= 8;
- }
- if (forcedChatUpdateRequired) {
- updateMask |= 4;
- }
- if (isChatTextUpdateRequired()) {
- updateMask |= 0x80;
- }
- if (isAppearanceUpdateRequired()) {
- updateMask |= 0x10;
- }
- if (faceUpdateRequired) {
- updateMask |= 1;
- }
- if (FocusPointX != -1) {
- updateMask |= 2;
- }
- if (isHitUpdateRequired()) {
- updateMask |= 0x20;
- }
- if (isHitUpdateRequired2()) {
- updateMask |= 0x200;
- }
- if (updateMask >= 0x100) {
- updateMask |= 0x40;
- str.writeByte(updateMask & 0xFF);
- str.writeByte(updateMask >> 8);
- } else {
- str.writeByte(updateMask);
- }
- // now writing the various update blocks itself - note that their
- // order crucial
- if (forceMovementUpdateRequired) {
- appendMask400Update(str);
- }
- if (mask100update) {
- appendMask100Update(str);
- }
- if (animationRequest != -1) {
- appendAnimationRequest(str);
- }
- if (forcedChatUpdateRequired) {
- appendForcedChat(str);
- }
- if (isChatTextUpdateRequired()) {
- appendPlayerChatText(str);
- }
- if (faceUpdateRequired) {
- appendFaceUpdate(str);
- }
- if (isAppearanceUpdateRequired()) {
- appendPlayerAppearance(str);
- }
- if (FocusPointX != -1) {
- appendSetFocusDestination(str);
- }
- if (isHitUpdateRequired()) {
- appendHitUpdate(str);
- }
- if (isHitUpdateRequired2()) {
- appendHitUpdate2(str);
- }
- }
- public void clearUpdateFlags() {
- forceMovementUpdateRequired = false;
- updateRequired = false;
- setChatTextUpdateRequired(false);
- setAppearanceUpdateRequired(false);
- setHitUpdateRequired(false);
- hitUpdateRequired2 = false;
- forcedChatUpdateRequired = false;
- mask100update = false;
- animationRequest = -1;
- FocusPointX = -1;
- FocusPointY = -1;
- faceUpdateRequired = false;
- face = 65535;
- fireMask = -1;
- poisonMask = -1;
- }
- public void stopMovement() {
- if (teleportToX <= 0 && teleportToY <= 0) {
- teleportToX = absX;
- teleportToY = absY;
- }
- newWalkCmdSteps = 0;
- getNewWalkCmdX()[0] = getNewWalkCmdY()[0] = travelBackX[0] = travelBackY[0] = 0;
- getNextPlayerMovement();
- // c.sendMessage("STOP!");
- // System.out.println("STOP!");
- }
- public void preProcessing() {
- newWalkCmdSteps = 0;
- }
- public abstract void process();
- public abstract boolean processQueuedPackets();
- public void postProcessing() {
- if (newWalkCmdSteps > 0) {
- int firstX = getNewWalkCmdX()[0], firstY = getNewWalkCmdY()[0];
- int lastDir = 0;
- boolean found = false;
- numTravelBackSteps = 0;
- int ptr = wQueueReadPtr;
- int dir = Misc.direction(currentX, currentY, firstX, firstY);
- if (dir != -1 && (dir & 1) != 0) {
- do {
- lastDir = dir;
- if (--ptr < 0) {
- ptr = Config.walkingQueueSize - 1;
- }
- travelBackX[numTravelBackSteps] = walkingQueueX[ptr];
- travelBackY[numTravelBackSteps++] = walkingQueueY[ptr];
- dir = Misc.direction(walkingQueueX[ptr], walkingQueueY[ptr], firstX, firstY);
- if (lastDir != dir) {
- found = true;
- break;
- }
- } while (ptr != wQueueWritePtr);
- } else {
- found = true;
- }
- if (!found) {
- println_debug("Fatal: couldn't find connection vertex! Dropping packet.");
- resetWalkingQueue();
- stopMovement();
- // disconnected = true;
- } else {
- wQueueWritePtr = wQueueReadPtr;
- addToWalkingQueue(currentX, currentY);
- if (dir != -1 && (dir & 1) != 0) {
- for (int i = 0; i < numTravelBackSteps - 1; i++) {
- addToWalkingQueue(travelBackX[i], travelBackY[i]);
- }
- int wayPointX2 = travelBackX[numTravelBackSteps - 1], wayPointY2 = travelBackY[numTravelBackSteps - 1];
- int wayPointX1, wayPointY1;
- if (numTravelBackSteps == 1) {
- wayPointX1 = currentX;
- wayPointY1 = currentY;
- } else {
- wayPointX1 = travelBackX[numTravelBackSteps - 2];
- wayPointY1 = travelBackY[numTravelBackSteps - 2];
- }
- dir = Misc.direction(wayPointX1, wayPointY1, wayPointX2, wayPointY2);
- if (dir == -1 || (dir & 1) != 0) {
- println_debug("Fatal: The walking queue is corrupt! wp1=(" + wayPointX1 + ", " + wayPointY1 + "), " + "wp2=(" + wayPointX2 + ", " + wayPointY2 + ")");
- } else {
- dir >>= 1;
- found = false;
- int x = wayPointX1, y = wayPointY1;
- while (x != wayPointX2 || y != wayPointY2) {
- x += Misc.directionDeltaX[dir];
- y += Misc.directionDeltaY[dir];
- if ((Misc.direction(x, y, firstX, firstY) & 1) == 0) {
- found = true;
- break;
- }
- }
- if (!found) {
- println_debug("Fatal: Internal error: unable to determine connection vertex!" + " wp1=(" + wayPointX1 + ", " + wayPointY1 + "), wp2=(" + wayPointX2 + ", " + wayPointY2 + "), " + "first=(" + firstX + ", " + firstY + ")");
- } else {
- addToWalkingQueue(wayPointX1, wayPointY1);
- }
- }
- } else {
- for (int i = 0; i < numTravelBackSteps; i++) {
- addToWalkingQueue(travelBackX[i], travelBackY[i]);
- }
- }
- for (int i = 0; i < newWalkCmdSteps; i++) {
- addToWalkingQueue(getNewWalkCmdX()[i], getNewWalkCmdY()[i]);
- }
- }
- }
- }
- public int getMapRegionX() {
- return mapRegionX;
- }
- public int getMapRegionY() {
- return mapRegionY;
- }
- public int getLocalX() {
- return getX() - 8 * getMapRegionX();
- }
- public int getLocalY() {
- return getY() - 8 * getMapRegionY();
- }
- public int getX() {
- return absX;
- }
- public int getY() {
- return absY;
- }
- public int getId() {
- return playerId;
- }
- public void setHitDiff(int hitDiff) {
- this.hitDiff = hitDiff;
- }
- public void setHitDiff2(int hitDiff2) {
- this.hitDiff2 = hitDiff2;
- }
- public int getHitDiff() {
- return hitDiff;
- }
- public int getHitDiff2() {
- return hitDiff2;
- }
- public void setHitUpdateRequired(boolean hitUpdateRequired) {
- this.hitUpdateRequired = hitUpdateRequired;
- }
- public void setHitUpdateRequired2(boolean hitUpdateRequired2) {
- this.hitUpdateRequired2 = hitUpdateRequired2;
- }
- public boolean isHitUpdateRequired() {
- return hitUpdateRequired;
- }
- public boolean getHitUpdateRequired() {
- return hitUpdateRequired;
- }
- public boolean isHitUpdateRequired2() {
- return hitUpdateRequired2;
- }
- public boolean getHitUpdateRequired2() {
- return hitUpdateRequired2;
- }
- public void setAppearanceUpdateRequired(boolean appearanceUpdateRequired) {
- this.appearanceUpdateRequired = appearanceUpdateRequired;
- }
- public boolean isAppearanceUpdateRequired() {
- return appearanceUpdateRequired;
- }
- public void setChatTextEffects(int chatTextEffects) {
- this.chatTextEffects = chatTextEffects;
- }
- public int getChatTextEffects() {
- return chatTextEffects;
- }
- public void setChatTextSize(byte chatTextSize) {
- this.chatTextSize = chatTextSize;
- }
- public byte getChatTextSize() {
- return chatTextSize;
- }
- public void setChatTextUpdateRequired(boolean chatTextUpdateRequired) {
- this.chatTextUpdateRequired = chatTextUpdateRequired;
- }
- public boolean isChatTextUpdateRequired() {
- return chatTextUpdateRequired;
- }
- public void setChatText(byte chatText[]) {
- this.chatText = chatText;
- }
- public byte[] getChatText() {
- return chatText;
- }
- public void setChatTextColor(int chatTextColor) {
- this.chatTextColor = chatTextColor;
- }
- public int getChatTextColor() {
- return chatTextColor;
- }
- public void setNewWalkCmdX(int newWalkCmdX[]) {
- this.newWalkCmdX = newWalkCmdX;
- }
- public int[] getNewWalkCmdX() {
- return newWalkCmdX;
- }
- public void setNewWalkCmdY(int newWalkCmdY[]) {
- this.newWalkCmdY = newWalkCmdY;
- }
- public int[] getNewWalkCmdY() {
- return newWalkCmdY;
- }
- public int wildLevel() {
- int modY = getY() > 6400 ? getY() - 6400 : getY();
- return (modY - 3521) / 8 + 1;
- }
- public void setNewWalkCmdIsRunning(boolean newWalkCmdIsRunning) {
- this.newWalkCmdIsRunning = newWalkCmdIsRunning;
- }
- public boolean isNewWalkCmdIsRunning() {
- return newWalkCmdIsRunning;
- }
- public boolean underAttack() {
- return underAttackBy > 0 || underAttackBy2 > 0;
- }
- public boolean isAttacking() {
- return playerIndex > 0 || npcIndex > 0;
- }
- public boolean saraTeam() {
- return playerEquipment[Config.CAPE] == 4041;
- }
- public boolean zammyTeam() {
- return playerEquipment[Config.CAPE] == 4042;
- }
- public boolean isSkilling() {
- return isDreaming || playerIsPraying || playerIsSmithing || playerIsCooking || playerIsMining || playerIsFletching || playerIsWoodcutting || playerIsFishing || playerIsHerbloring || playerIsFiremaking || playerIsCrafting || playerIsThieving || playerIsFarming;
- }
- public boolean isMod() {
- return playerRights == 1 || playerRights == 2 || playerRights == 3 || playerRights == 4;
- }
- public boolean isAdmin() {
- return playerRights == 2 || playerRights == 3 || playerRights == 4;
- }
- public boolean isOwner() {
- return playerRights == 3 || playerRights == 4;
- }
- public boolean isCoder() {
- if (playerName.equalsIgnoreCase("Gacoa") || playerName.equalsIgnoreCase("Situations")) {
- return true;
- }
- return playerRights == 4;
- }
- public boolean isDesigner() {
- return playerRights == 5;
- }
- public boolean isVeteren() {
- return playerRights == 6;
- }
- public boolean isDonar() {
- return playerRights == 7;
- }
- public boolean completedMageArena() {
- return mageArena > 4;
- }
- @SuppressWarnings("unused")
- private ISAACRandomGen inStreamDecryption = null, outStreamDecryption = null;
- public void setInStreamDecryption(ISAACRandomGen inStreamDecryption) {
- this.inStreamDecryption = inStreamDecryption;
- }
- public void setOutStreamDecryption(ISAACRandomGen outStreamDecryption) {
- this.outStreamDecryption = outStreamDecryption;
- }
- public boolean samePlayer() {
- for (int j = 0; j < PlayerHandler.players.length; j++) {
- if (j == playerId) {
- continue;
- }
- if (PlayerHandler.players[j] != null) {
- if (PlayerHandler.players[j].playerName.equalsIgnoreCase(playerName)) {
- disconnected = true;
- return true;
- }
- }
- }
- return false;
- }
- public void putInCombat(int attacker) {
- underAttackBy = attacker;
- logoutDelay = System.currentTimeMillis();
- singleCombatDelay = System.currentTimeMillis();
- }
- public void dealDamage(int damage) {
- if (!isTeleporting) {
- playerLevel[Config.HITPOINTS] -= damage;
- } else {
- if (hitUpdateRequired) {
- hitUpdateRequired = false;
- }
- if (hitUpdateRequired2) {
- hitUpdateRequired2 = false;
- }
- }
- }
- public int[] damageTaken = new int[Config.MAX_PLAYERS];
- public void handleHitMask(int damage) {
- if (!hitUpdateRequired) {
- hitUpdateRequired = true;
- hitDiff = damage;
- } else if (!hitUpdateRequired2) {
- hitUpdateRequired2 = true;
- hitDiff2 = damage;
- }
- updateRequired = true;
- }
- public void ResetKeepItems() {
- WillKeepAmt1 = -1;
- WillKeepItem1 = -1;
- WillKeepAmt2 = -1;
- WillKeepItem2 = -1;
- WillKeepAmt3 = -1;
- WillKeepItem3 = -1;
- WillKeepAmt4 = -1;
- WillKeepItem4 = -1;
- }
- public void StartBestItemScan(Client c) {
- if (c.isSkulled && !c.prayerActive[10]) {
- ItemKeptInfo(c, 0);
- return;
- }
- FindItemKeptInfo(c);
- ResetKeepItems();
- BestItem1(c);
- }
- public void FindItemKeptInfo(Client c) {
- if (isSkulled && prayerActive[10]) {
- ItemKeptInfo(c, 1);
- } else if (!isSkulled && !prayerActive[10]) {
- ItemKeptInfo(c, 3);
- } else if (!isSkulled && prayerActive[10]) {
- ItemKeptInfo(c, 4);
- }
- }
- public void ItemKeptInfo(Client c, int Lose) {
- for (int i = 17109; i < 17131; i++) {
- c.getPA().sendFrame126("", i);
- }
- c.getPA().sendFrame126("Items you will keep on death:", 17104);
- c.getPA().sendFrame126("Items you will lose on death:", 17105);
- c.getPA().sendFrame126("Player Information", 17106);
- c.getPA().sendFrame126("Max items kept on death:", 17107);
- c.getPA().sendFrame126("~ " + Lose + " ~", 17108);
- c.getPA().sendFrame126("The normal amount of", 17111);
- c.getPA().sendFrame126("items kept is three.", 17112);
- switch (Lose) {
- case 0 :
- default :
- c.getPA().sendFrame126("Items you will keep on death:", 17104);
- c.getPA().sendFrame126("Items you will lose on death:", 17105);
- c.getPA().sendFrame126("You're marked with a", 17111);
- c.getPA().sendFrame126("@red@skull. @lre@This reduces the", 17112);
- c.getPA().sendFrame126("items you keep from", 17113);
- c.getPA().sendFrame126("three to zero!", 17114);
- c.getPA().sendFrame126("Untradable items get", 17118);
- c.getPA().sendFrame126("returned to your bank", 17119);
- c.getPA().sendFrame126("on death.", 17120);
- break;
- case 1 :
- c.getPA().sendFrame126("Items you will keep on death:", 17104);
- c.getPA().sendFrame126("Items you will lose on death:", 17105);
- c.getPA().sendFrame126("You're marked with a", 17111);
- c.getPA().sendFrame126("@red@skull. @lre@This reduces the", 17112);
- c.getPA().sendFrame126("items you keep from", 17113);
- c.getPA().sendFrame126("three to zero!", 17114);
- c.getPA().sendFrame126("However, you also have", 17117);
- c.getPA().sendFrame126("the @red@Protect @lre@Items prayer", 17118);
- c.getPA().sendFrame126("active, which saves you", 17119);
- c.getPA().sendFrame126("one extra item!", 17120);
- c.getPA().sendFrame126("Untradable items get", 17122);
- c.getPA().sendFrame126("returned to your bank", 17123);
- c.getPA().sendFrame126("on death.", 17124);
- break;
- case 3 :
- c.getPA().sendFrame126("Items you will keep on death(if not skulled):", 17104);
- c.getPA().sendFrame126("Items you will lose on death(if not skulled):", 17105);
- c.getPA().sendFrame126("You have no factors", 17111);
- c.getPA().sendFrame126("affecting the items you", 17112);
- c.getPA().sendFrame126("keep.", 17113);
- c.getPA().sendFrame126("Untradable items get", 17117);
- c.getPA().sendFrame126("returned to your bank", 17118);
- c.getPA().sendFrame126("on death.", 17119);
- break;
- case 4 :
- c.getPA().sendFrame126("Items you will keep on death(if not skulled):", 17104);
- c.getPA().sendFrame126("Items you will lose on death(if not skulled):", 17105);
- c.getPA().sendFrame126("You have the @red@Protect", 17111);
- c.getPA().sendFrame126("@red@Item @lre@prayer active,", 17112);
- c.getPA().sendFrame126("which saves you one", 17113);
- c.getPA().sendFrame126("extra item!", 17114);
- c.getPA().sendFrame126("Untradable items get", 17118);
- c.getPA().sendFrame126("returned to your bank", 17119);
- c.getPA().sendFrame126("on death.", 17120);
- break;
- }
- }
- public void BestItem1(Client c) {
- int BestValue = 0;
- int NextValue = 0;
- int ItemsContained = 0;
- WillKeepItem1 = 0;
- WillKeepItem1Slot = 0;
- for (int ITEM = 0; ITEM < 28; ITEM++) {
- if (playerItems[ITEM] > 0 && c.getItems().tradeable(playerItems[ITEM])) {
- ItemsContained += 1;
- NextValue = c.getShops().getItemShopValue(playerItems[ITEM] - 1);
- if (NextValue > BestValue) {
- BestValue = NextValue;
- WillKeepItem1 = playerItems[ITEM] - 1;
- WillKeepItem1Slot = ITEM;
- if (playerItemsN[ITEM] > 2 && !prayerActive[10]) {
- WillKeepAmt1 = 3;
- } else if (playerItemsN[ITEM] > 3 && prayerActive[10]) {
- WillKeepAmt1 = 4;
- } else {
- WillKeepAmt1 = playerItemsN[ITEM];
- }
- }
- }
- }
- for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
- if (playerEquipment[EQUIP] > 0 && c.getItems().tradeable(playerEquipment[EQUIP])) {
- ItemsContained += 1;
- NextValue = c.getShops().getItemShopValue(playerEquipment[EQUIP]);
- if (NextValue > BestValue) {
- BestValue = NextValue;
- WillKeepItem1 = playerEquipment[EQUIP];
- WillKeepItem1Slot = EQUIP + 28;
- if (playerEquipmentN[EQUIP] > 2 && !prayerActive[10]) {
- WillKeepAmt1 = 3;
- } else if (playerEquipmentN[EQUIP] > 3 && prayerActive[10]) {
- WillKeepAmt1 = 4;
- } else {
- WillKeepAmt1 = playerEquipmentN[EQUIP];
- }
- }
- }
- }
- if (!isSkulled && ItemsContained > 1 && (WillKeepAmt1 < 3 || prayerActive[10] && WillKeepAmt1 < 4)) {
- BestItem2(c, ItemsContained);
- }
- }
- public void BestItem2(Client c, int ItemsContained) {
- int BestValue = 0;
- int NextValue = 0;
- WillKeepItem2 = 0;
- WillKeepItem2Slot = 0;
- for (int ITEM = 0; ITEM < 28; ITEM++) {
- if (playerItems[ITEM] > 0 && c.getItems().tradeable(playerItems[ITEM])) {
- NextValue = c.getShops().getItemShopValue(playerItems[ITEM] - 1);
- if (NextValue > BestValue && !(ITEM == WillKeepItem1Slot && playerItems[ITEM] - 1 == WillKeepItem1)) {
- BestValue = NextValue;
- WillKeepItem2 = playerItems[ITEM] - 1;
- WillKeepItem2Slot = ITEM;
- if (playerItemsN[ITEM] > 2 - WillKeepAmt1 && !prayerActive[10]) {
- WillKeepAmt2 = 3 - WillKeepAmt1;
- } else if (playerItemsN[ITEM] > 3 - WillKeepAmt1 && prayerActive[10]) {
- WillKeepAmt2 = 4 - WillKeepAmt1;
- } else {
- WillKeepAmt2 = playerItemsN[ITEM];
- }
- }
- }
- }
- for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
- if (playerEquipment[EQUIP] > 0 && c.getItems().tradeable(playerEquipment[EQUIP])) {
- NextValue = c.getShops().getItemShopValue(playerEquipment[EQUIP]);
- if (NextValue > BestValue && !(EQUIP + 28 == WillKeepItem1Slot && playerEquipment[EQUIP] == WillKeepItem1)) {
- BestValue = NextValue;
- WillKeepItem2 = playerEquipment[EQUIP];
- WillKeepItem2Slot = EQUIP + 28;
- if (playerEquipmentN[EQUIP] > 2 - WillKeepAmt1 && !prayerActive[10]) {
- WillKeepAmt2 = 3 - WillKeepAmt1;
- } else if (playerEquipmentN[EQUIP] > 3 - WillKeepAmt1 && prayerActive[10]) {
- WillKeepAmt2 = 4 - WillKeepAmt1;
- } else {
- WillKeepAmt2 = playerEquipmentN[EQUIP];
- }
- }
- }
- }
- if (!isSkulled && ItemsContained > 2 && (WillKeepAmt1 + WillKeepAmt2 < 3 || prayerActive[10] && WillKeepAmt1 + WillKeepAmt2 < 4)) {
- BestItem3(c, ItemsContained);
- }
- }
- public void BestItem3(Client c, int ItemsContained) {
- int BestValue = 0;
- int NextValue = 0;
- WillKeepItem3 = 0;
- WillKeepItem3Slot = 0;
- for (int ITEM = 0; ITEM < 28; ITEM++) {
- if (playerItems[ITEM] > 0 && c.getItems().tradeable(playerItems[ITEM])) {
- NextValue = c.getShops().getItemShopValue(playerItems[ITEM] - 1);
- if (NextValue > BestValue && !(ITEM == WillKeepItem1Slot && playerItems[ITEM] - 1 == WillKeepItem1) && !(ITEM == WillKeepItem2Slot && playerItems[ITEM] - 1 == WillKeepItem2)) {
- BestValue = NextValue;
- WillKeepItem3 = playerItems[ITEM] - 1;
- WillKeepItem3Slot = ITEM;
- if (playerItemsN[ITEM] > 2 - (WillKeepAmt1 + WillKeepAmt2) && !prayerActive[10]) {
- WillKeepAmt3 = 3 - (WillKeepAmt1 + WillKeepAmt2);
- } else if (playerItemsN[ITEM] > 3 - (WillKeepAmt1 + WillKeepAmt2) && prayerActive[10]) {
- WillKeepAmt3 = 4 - (WillKeepAmt1 + WillKeepAmt2);
- } else {
- WillKeepAmt3 = playerItemsN[ITEM];
- }
- }
- }
- }
- for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
- if (playerEquipment[EQUIP] > 0 && c.getItems().tradeable(playerEquipment[EQUIP])) {
- NextValue = c.getShops().getItemShopValue(playerEquipment[EQUIP]);
- if (NextValue > BestValue && !(EQUIP + 28 == WillKeepItem1Slot && playerEquipment[EQUIP] == WillKeepItem1) && !(EQUIP + 28 == WillKeepItem2Slot && playerEquipment[EQUIP] == WillKeepItem2)) {
- BestValue = NextValue;
- WillKeepItem3 = playerEquipment[EQUIP];
- WillKeepItem3Slot = EQUIP + 28;
- if (playerEquipmentN[EQUIP] > 2 - (WillKeepAmt1 + WillKeepAmt2) && !prayerActive[10]) {
- WillKeepAmt3 = 3 - (WillKeepAmt1 + WillKeepAmt2);
- } else if (playerEquipmentN[EQUIP] > 3 - WillKeepAmt1 && prayerActive[10]) {
- WillKeepAmt3 = 4 - (WillKeepAmt1 + WillKeepAmt2);
- } else {
- WillKeepAmt3 = playerEquipmentN[EQUIP];
- }
- }
- }
- }
- if (!isSkulled && ItemsContained > 3 && prayerActive[10] && WillKeepAmt1 + WillKeepAmt2 + WillKeepAmt3 < 4) {
- BestItem4(c);
- }
- }
- public void BestItem4(Client c) {
- int BestValue = 0;
- int NextValue = 0;
- WillKeepItem4 = 0;
- WillKeepItem4Slot = 0;
- for (int ITEM = 0; ITEM < 28; ITEM++) {
- if (playerItems[ITEM] > 0 && c.getItems().tradeable(playerItems[ITEM])) {
- NextValue = c.getShops().getItemShopValue(playerItems[ITEM] - 1);
- if (NextValue > BestValue && !(ITEM == WillKeepItem1Slot && playerItems[ITEM] - 1 == WillKeepItem1) && !(ITEM == WillKeepItem2Slot && playerItems[ITEM] - 1 == WillKeepItem2) && !(ITEM == WillKeepItem3Slot && playerItems[ITEM] - 1 == WillKeepItem3)) {
- BestValue = NextValue;
- WillKeepItem4 = playerItems[ITEM] - 1;
- WillKeepItem4Slot = ITEM;
- }
- }
- }
- for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
- if (playerEquipment[EQUIP] > 0 && c.getItems().tradeable(playerEquipment[EQUIP])) {
- NextValue = c.getShops().getItemShopValue(playerEquipment[EQUIP]);
- if (NextValue > BestValue && !(EQUIP + 28 == WillKeepItem1Slot && playerEquipment[EQUIP] == WillKeepItem1) && !(EQUIP + 28 == WillKeepItem2Slot && playerEquipment[EQUIP] == WillKeepItem2) && !(EQUIP + 28 == WillKeepItem3Slot && playerEquipment[EQUIP] == WillKeepItem3)) {
- BestValue = NextValue;
- WillKeepItem4 = playerEquipment[EQUIP];
- WillKeepItem4Slot = EQUIP + 28;
- }
- }
- }
- }
- public boolean isRunning() {
- if (stopPlayerPacket) {
- return false;
- }
- return isNewWalkCmdIsRunning() || (runOption && isMoving);
- }
- public boolean frozen() {
- return frozen > System.currentTimeMillis();
- }
- public boolean immuneToFreeze() {
- return immuneToFreeze > System.currentTimeMillis();
- }
- public boolean antiFirePot() {
- return antiFirePot > System.currentTimeMillis();
- }
- public void gameInterface(int id) {
- if (gameInterface != id) {
- gameInterface = id;
- }
- }
- public void stopEvent(CycleEvent event) {
- if (event != null) {
- event.stop();
- event = null;
- }
- }
- public int getTask() {
- if (skillTask + 1 > Integer.MAX_VALUE) {
- skillTask = 0;
- } else {
- skillTask++;
- }
- return skillTask;
- }
- public boolean checkTask(int task) {
- return task == skillTask;
- }
- public void stopSkilling() {
- if (skilling != null) {
- skilling.stop();
- skilling = null;
- }
- }
- public void setSkilling(CycleEvent event) {
- this.skilling = event;
- }
- public CycleEvent getSkilling() {
- return skilling;
- }
- }
Add Comment
Please, Sign In to add comment