Guest User

Untitled

a guest
Jan 23rd, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 59.86 KB | None | 0 0
  1. package server.model.players;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6.  
  7. import server.Config;
  8. import server.event.CycleEvent;
  9. import server.event.CycleEventContainer;
  10. import server.event.CycleEventHandler;
  11. import server.model.items.Item;
  12. import server.model.items.ItemAssistant;
  13. import server.model.npcs.NPC;
  14. import server.model.npcs.NPCHandler;
  15. import server.model.players.combat.magic.MagicData;
  16. import server.model.players.skills.Agility;
  17. import server.model.shops.GrandExchangeItem;
  18. import server.util.ISAACRandomGen;
  19. import server.util.Misc;
  20. import server.util.Stream;
  21.  
  22. public abstract class Player {
  23.  
  24. public String connectedFrom = "", clanOwner = "", properName, spellName = "Spell";
  25.  
  26. private byte chatText[] = new byte[4096], chatTextSize;
  27.  
  28. public byte poisonMask, fireMask;
  29.  
  30. 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,
  31. 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,
  32. 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],
  33. 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];
  34.  
  35. protected int NewHp = 10, travelBackX[] = new int[Config.walkingQueueSize], travelBackY[] = new int[Config.walkingQueueSize], numTravelBackSteps;
  36.  
  37. private int chatTextColor, chatTextEffects, newWalkCmdX[] = new int[Config.walkingQueueSize], newWalkCmdY[] = new int[Config.walkingQueueSize];
  38.  
  39. 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,
  40. 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];
  41.  
  42. protected boolean didTeleport, mapRegionDidChange, createItems, faceUpdateRequired, mask100update, hitUpdateRequired2;
  43.  
  44. private boolean newWalkCmdIsRunning, chatTextUpdateRequired;
  45.  
  46. 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];
  47.  
  48. public double specAmount, specAccuracy = 1, specDamage = 1, prayerPoint = 1, crossbowDamage;
  49.  
  50. public CycleEvent skilling, spellSwap;
  51.  
  52. public ArrayList<GrandExchangeItem> GE;
  53.  
  54. public boolean poisonweapon(String p) {
  55. if (playerEquipment[Config.WEAPON] < 1) {
  56. return false;
  57. }
  58. return ItemAssistant.getItemName(playerEquipment[Config.WEAPON]).endsWith(p);
  59. }
  60.  
  61. public boolean poisonrange(String p) {
  62. if (playerEquipment[Config.ARROWS] < 1) {
  63. return false;
  64. }
  65. return ItemAssistant.getItemName(playerEquipment[Config.ARROWS]).endsWith(p);
  66. }
  67.  
  68. public Map<String, Integer> killedPlayers = new HashMap<String, Integer>();
  69. public ArrayList<Integer> attackedPlayers = new ArrayList<Integer>();
  70.  
  71. 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) {
  72. final int endX = getX() + x;
  73. final int endY = getY() + y;
  74. this.x1 = currentX;
  75. this.y1 = currentY;
  76. this.x2 = currentX + x;
  77. this.y2 = currentY + y;
  78. this.speed1 = speed1;
  79. this.speed2 = speed2;
  80. this.direction = direction;
  81. updateRequired = true;
  82. forceMovementUpdateRequired = true;
  83. if (stopPacket) {
  84. stopPlayerPacket = true;
  85. }
  86. final Client c = (Client) this;
  87. CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
  88. @Override
  89. public void execute(CycleEventContainer container) {
  90. if (endAnim > 0) {
  91. c.startAnimation(endAnim);
  92. }
  93. container.stop();
  94. }
  95. @Override
  96. public void stop() {
  97. }
  98. }, time - 1);
  99. CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
  100. @Override
  101. public void execute(CycleEventContainer container) {
  102. updateRequired = true;
  103. forceMovementUpdateRequired = false;
  104. if (stopPacket) {
  105. stopPlayerPacket = false;
  106. }
  107. c.getPA().movePlayer(endX, endY, height);
  108. c.getCombat().getPlayerAnimIndex();
  109. container.stop();
  110. }
  111. @Override
  112. public void stop() {
  113. }
  114. }, time);
  115. }
  116.  
  117. public void appendMask400Update(Stream str) {
  118. str.writeByteS(x1);
  119. str.writeByteS(y1);
  120. str.writeByteS(x2);
  121. str.writeByteS(y2);
  122. str.writeWordBigEndianA(speed1);
  123. str.writeWordA(speed2);
  124. str.writeByteS(direction);
  125. }
  126.  
  127. public boolean Area(int x, int x1, int y, int y1) {
  128. return absX >= x && absX <= x1 && absY >= y && absY <= y1;
  129. }
  130.  
  131. public boolean Area(int x, int x1, int y, int y1, int x2, int y2) {
  132. return x2 >= x && x2 <= x1 && y2 >= y && y2 <= y1;
  133. }
  134.  
  135. public boolean inCwSafe() {
  136. return (Area(2423, 2431, 3072, 3080) || Area(2368, 2376, 3127, 3135)) && heightLevel == 1;
  137. }
  138.  
  139. public boolean inZammyWait() {
  140. return Area(2409, 2431, 9511, 9535);
  141. }
  142.  
  143. public boolean inSaraWait() {
  144. return Area(2368, 2392, 9479, 9498);
  145. }
  146.  
  147. public boolean inCwGame() {
  148. return Area(2368, 2431, 9479, 9535) || Area(2368, 2431, 3072, 3135) && !inSaraWait() && !inZammyWait();
  149. }
  150.  
  151. public boolean inCwUnderground() {
  152. return Area(2368, 2431, 9479, 9535) && !inSaraWait() && !inZammyWait();
  153. }
  154.  
  155. public boolean inZammyBase() {
  156. return Area(2368, 2384, 3118, 3135);
  157. }
  158.  
  159. public boolean inSaraBase() {
  160. return Area(2414, 2431, 3072, 3088);
  161. }
  162.  
  163. public boolean inPits() {
  164. return Area(2370, 2430, 5122, 5168);
  165. }
  166.  
  167. public boolean inPitsWait() {
  168. return Area(2394, 2404, 5169, 5175);
  169. }
  170.  
  171. public boolean inCaves() {
  172. return Area(2371, 2422, 5062, 5117);
  173. }
  174.  
  175. public boolean inDuelArena() {
  176. return Area(3331, 3390, 3205, 3259);
  177. }
  178.  
  179. public boolean inDuelArea() {
  180. return Area(3325, 3410, 3200, 3266) || Area(3341, 3410, 3267, 3288) || Area(3312, 3322, 3224, 3247) && !inDuelArena();
  181. }
  182.  
  183. public boolean inRestrictedArea() {
  184. return Area(3276, 3289, 3330, 3332) || Area(2240, 2241, 3233, 3237);
  185. }
  186.  
  187. public boolean inMageArena() {
  188. return Area(3078, 3133, 3908, 3959) && heightLevel > 3;
  189. }
  190.  
  191. public boolean inWild() {
  192. return Area(2942, 3391, 3519, 3965) || Area(2942, 3391, 9919, 10365) && !inMageArena();
  193. }
  194.  
  195. public boolean inSafePvp() {
  196. return Area(2582, 2606, 3152, 3171);
  197. }
  198.  
  199. public boolean inSafePvpArea() {
  200. return Area(2577, 2623, 3134, 3178);
  201. }
  202.  
  203. public boolean inPcBoat() {
  204. return Area(2660, 2663, 2638, 2643);
  205. }
  206.  
  207. public boolean inPcGame() {
  208. return Area(2624, 2690, 2550, 2619);
  209. }
  210.  
  211. // Bandos, Arma, Sara, Zammy
  212. public boolean inGwdChamber() {
  213. return Area(2864, 2876, 5351, 5369) || Area(2824, 2842, 5296, 5308) || Area(2889, 2907, 5258, 5276) || Area(2918, 2936, 5318, 5331);
  214. }
  215.  
  216. public boolean inGwd() {
  217. return Area(2792, 2952, 5235, 5394);
  218. }
  219.  
  220. public boolean inMulti() {
  221. 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();
  222. }
  223.  
  224. public boolean rangableArea(int x, int y) {
  225. 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);
  226. }
  227.  
  228. public boolean nonRangableArea(int x, int y) {
  229. 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);
  230. }
  231.  
  232. public boolean inRandomEvent() {
  233. return Area(2587, 2619, 4760, 4785);
  234. }
  235.  
  236. public boolean inBank() {
  237. 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;
  238. }
  239.  
  240. public boolean cantTeleport() {
  241. return tutorial < 11 || inRandomEvent() || inPits() || inPitsWait() || inCaves() || inDuelArena() || saraTeam() || zammyTeam();
  242. }
  243.  
  244. public boolean inSpawnPvp() {
  245. return false;
  246. }
  247.  
  248. public void updateHp(int chHp, boolean heal) {
  249. if (heal) {
  250. NewHp += chHp;
  251. if (NewHp > getPlayerLevel(Config.HITPOINTS)) {
  252. chHp = NewHp - getPlayerLevel(Config.HITPOINTS);
  253. NewHp = getPlayerLevel(Config.HITPOINTS);
  254. }
  255. subtractDamage(chHp);
  256. } else if (!heal) {
  257. if (!isTeleporting) {
  258. NewHp -= chHp;
  259. if (NewHp < 0) {
  260. NewHp = 0;
  261. }
  262. }
  263. }
  264. playerLevel[Config.HITPOINTS] = NewHp;
  265. NewHp = playerLevel[Config.HITPOINTS];
  266. }
  267.  
  268. public void subtractDamage(int dmg) {
  269. for (int i = 1; i < KilledBy.length; i++) {
  270. KilledBy[i] -= dmg;
  271. if (KilledBy[i] < 0) {
  272. KilledBy[i] = 0;
  273. }
  274. }
  275. }
  276.  
  277. public void lowGFX(int id, int delay) {
  278. mask100var1 = id;
  279. mask100var2 = delay;
  280. mask100update = true;
  281. updateRequired = true;
  282. }
  283.  
  284. public boolean isAutoButton(int button) {
  285. for (int j = 0; j < Config.autocastIds.length; j += 2) {
  286. if (Config.autocastIds[j] == button) {
  287. return true;
  288. }
  289. }
  290. return false;
  291. }
  292.  
  293. public void assignAutocast(int button) {
  294. for (int j = 0; j < Config.autocastIds.length; j++) {
  295. if (Config.autocastIds[j] == button) {
  296. Client c = (Client) PlayerHandler.players[playerId];
  297. c.autocasting = true;
  298. c.autocastId = Config.autocastIds[j + 1];
  299. c.getPA().setConfig(108, 1);
  300. c.setSidebarInterface(0, 328);
  301. c.spellName = MagicData.getSpellName(c.autocastId);
  302. c.getPA().sendFrame126(c.spellName, 354);
  303. c = null;
  304. break;
  305. }
  306. }
  307. }
  308.  
  309. public boolean fullVoid(String s) {
  310. return playerEquipment[Config.HAT] == (s == "Melee" ? 11665 : s == "Range" ? 11664 : 11663) && playerEquipment[Config.LEGS] == 8840 && playerEquipment[Config.CHEST] == 8839 && playerEquipment[Config.HANDS] == 8842;
  311. }
  312.  
  313. 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};
  314.  
  315. public abstract void initialize();
  316.  
  317. public abstract void update();
  318.  
  319. public int playerId = -1;
  320. public PlayerHandler handler = null;
  321. public String playerName = null;
  322. public String playerName2 = null;
  323. public String playerPass = null;
  324. public int playerRights;
  325. public int playerItems[] = new int[28];
  326. public int playerItemsN[] = new int[28];
  327. public int bankItems[] = new int[Config.BANK_SIZE];
  328. public int bankItemsN[] = new int[Config.BANK_SIZE];
  329. public boolean bankNotes;
  330.  
  331. public int playerStandIndex = 0x328;
  332. public int playerTurnIndex = 0x337;
  333. public int playerWalkIndex = 0x333;
  334. public int playerTurn180Index = 0x334;
  335. public int playerTurn90CWIndex = 0x335;
  336. public int playerTurn90CCWIndex = 0x336;
  337. public int playerRunIndex = 0x338;
  338.  
  339. public int[] playerEquipment = new int[14];
  340. public int[] playerEquipmentN = new int[14];
  341. public int[] playerLevel = new int[22];
  342. public int[] playerXP = new int[22];
  343.  
  344. public void updateshop(int i) {
  345. Client p = (Client) PlayerHandler.players[playerId];
  346. p.getShops().resetShop(i);
  347. }
  348.  
  349. public void println_debug(String str) {
  350. System.out.println("[player-" + playerId + "]: " + str);
  351. }
  352.  
  353. public void println(String str) {
  354. System.out.println("[player-" + playerId + "]: " + str);
  355. }
  356.  
  357. public Player(int _playerId) {
  358. playerId = _playerId;
  359. playerRights = 0;
  360.  
  361. for (int i = 0; i < playerItems.length; i++) {
  362. playerItems[i] = 0;
  363. }
  364. for (int i = 0; i < playerItemsN.length; i++) {
  365. playerItemsN[i] = 0;
  366. }
  367.  
  368. for (int i = 0; i < playerLevel.length; i++) {
  369. if (i == 3) {
  370. playerLevel[i] = 10;
  371. } else {
  372. playerLevel[i] = 1;
  373. }
  374. }
  375.  
  376. for (int i = 0; i < playerXP.length; i++) {
  377. if (i == 3) {
  378. playerXP[i] = 1300;
  379. } else {
  380. playerXP[i] = 0;
  381. }
  382. }
  383. for (int i = 0; i < Config.BANK_SIZE; i++) {
  384. bankItems[i] = 0;
  385. }
  386.  
  387. for (int i = 0; i < Config.BANK_SIZE; i++) {
  388. bankItemsN[i] = 0;
  389. }
  390.  
  391. playerAppearance[0] = 0; // gender
  392. playerAppearance[1] = 7; // head
  393. playerAppearance[2] = 25;// Torso
  394. playerAppearance[3] = 29; // arms
  395. playerAppearance[4] = 35; // hands
  396. playerAppearance[5] = 39; // legs
  397. playerAppearance[6] = 44; // feet
  398. playerAppearance[7] = 14; // beard
  399. playerAppearance[8] = 7; // hair colour
  400. playerAppearance[9] = 8; // torso colour
  401. playerAppearance[10] = 9; // legs colour
  402. playerAppearance[11] = 5; // feet colour
  403. playerAppearance[12] = 0; // skin colour
  404.  
  405. apset = 0;
  406. actionID = 0;
  407.  
  408. playerEquipment[Config.HAT] = -1;
  409. playerEquipment[Config.CAPE] = -1;
  410. playerEquipment[Config.AMULET] = -1;
  411. playerEquipment[Config.CHEST] = -1;
  412. playerEquipment[Config.SHIELD] = -1;
  413. playerEquipment[Config.LEGS] = -1;
  414. playerEquipment[Config.HANDS] = -1;
  415. playerEquipment[Config.FEET] = -1;
  416. playerEquipment[Config.RING] = -1;
  417. playerEquipment[Config.ARROWS] = -1;
  418. playerEquipment[Config.WEAPON] = -1;
  419.  
  420. heightLevel = 0;
  421. if (Config.countY > 10) {
  422. Config.countY = 0;
  423. Config.countX++;
  424. }
  425. teleportToX = Config.START_LOCATION_X + Config.countX;
  426. teleportToY = Config.START_LOCATION_Y + (Config.countY++);
  427. absX = absY = -1;
  428. mapRegionX = mapRegionY = -1;
  429. currentX = currentY = 0;
  430. resetWalkingQueue();
  431. }
  432.  
  433. void destruct() {
  434. playerListSize = 0;
  435. for (int i = 0; i < maxPlayerListSize; i++) {
  436. playerList[i] = null;
  437. }
  438. absX = absY = -1;
  439. mapRegionX = mapRegionY = -1;
  440. currentX = currentY = 0;
  441. resetWalkingQueue();
  442. }
  443.  
  444. public static final int maxPlayerListSize = Config.MAX_PLAYERS;
  445. public Player playerList[] = new Player[maxPlayerListSize];
  446. public int playerListSize = 0;
  447.  
  448. public byte playerInListBitmap[] = new byte[Config.MAX_PLAYERS + 7 >> 3];
  449.  
  450. public static final int maxNPCListSize = NPCHandler.maxNPCs;
  451. public NPC npcList[] = new NPC[maxNPCListSize];
  452. public int npcListSize = 0;
  453.  
  454. public byte npcInListBitmap[] = new byte[NPCHandler.maxNPCs + 7 >> 3];
  455.  
  456. public boolean withinDistance(Player otherPlr) {
  457. if (heightLevel != otherPlr.heightLevel) {
  458. return false;
  459. }
  460. int deltaX = otherPlr.absX - absX, deltaY = otherPlr.absY - absY;
  461. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  462. }
  463.  
  464. public boolean withinDistance(NPC npc) {
  465. if (heightLevel != npc.heightLevel) {
  466. return false;
  467. }
  468. if (npc.needRespawn == true) {
  469. return false;
  470. }
  471. int deltaX = npc.absX - absX, deltaY = npc.absY - absY;
  472. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  473. }
  474.  
  475. public int distanceToPoint(int pointX, int pointY) {
  476. return (int) Math.sqrt(Math.pow(absX - pointX, 2) + Math.pow(absY - pointY, 2));
  477. }
  478.  
  479. public void resetWalkingQueue() {
  480. wQueueReadPtr = wQueueWritePtr;
  481. for (int i = 0; i < Config.walkingQueueSize; i++) {
  482. walkingQueueX[i] = currentX;
  483. walkingQueueY[i] = currentY;
  484. }
  485. }
  486.  
  487. public void addToWalkingQueue(int x, int y) {
  488. int next = (wQueueWritePtr + 1) % Config.walkingQueueSize;
  489. if (next == wQueueWritePtr) {
  490. return;
  491. }
  492. walkingQueueX[wQueueWritePtr] = x;
  493. walkingQueueY[wQueueWritePtr] = y;
  494. wQueueWritePtr = next;
  495. }
  496.  
  497. public boolean checkBarricade(int X, int Y) {
  498. for (int i = 0; i < NPCHandler.maxNPCs; i++) {
  499. if (NPCHandler.npcs[i] != null) {
  500. if (NPCHandler.npcs[i].npcType == 1532 || NPCHandler.npcs[i].npcType == 1533 || NPCHandler.npcs[i].npcType == 1534 || NPCHandler.npcs[i].npcType == 1535) {
  501. if (NPCHandler.npcs[i].heightLevel == heightLevel) {
  502. if (NPCHandler.npcs[i].absX == X && NPCHandler.npcs[i].absY == Y) {
  503. return false;
  504. }
  505. if (NPCHandler.npcs[i].absX == absX && NPCHandler.npcs[i].absY - absY == 1 && Y - absY == 1) {
  506. return false;
  507. }
  508. if (NPCHandler.npcs[i].absX == absX && NPCHandler.npcs[i].absY - absY == -1 && Y - absY == -1) {
  509. return false;
  510. }
  511. if (NPCHandler.npcs[i].absY == absY && NPCHandler.npcs[i].absX - absX == 1 && X - absX == 1) {
  512. return false;
  513. }
  514. if (NPCHandler.npcs[i].absY == absY && NPCHandler.npcs[i].absX - absX == -1 && X - absX == -1) {
  515. return false;
  516. }
  517. }
  518. }
  519. }
  520. }
  521. return true;
  522. }
  523.  
  524. public int getNextWalkingDirection() {
  525. if (wQueueReadPtr == wQueueWritePtr) {
  526. return -1;
  527. }
  528. int dir;
  529. do {
  530. dir = Misc.direction(currentX, currentY, walkingQueueX[wQueueReadPtr], walkingQueueY[wQueueReadPtr]);
  531. if (dir == -1) {
  532. wQueueReadPtr = (wQueueReadPtr + 1) % Config.walkingQueueSize;
  533. } else if ((dir & 1) != 0) {
  534. println_debug("Invalid waypoint in walking queue!");
  535. resetWalkingQueue();
  536. return -1;
  537. }
  538. } while (dir == -1 && wQueueReadPtr != wQueueWritePtr);
  539. if (dir == -1) {
  540. return -1;
  541. }
  542. dir >>= 1;
  543. int tempabsX = absX + Misc.directionDeltaX[dir];
  544. int tempabsY = absY + Misc.directionDeltaY[dir];
  545. if (checkBarricade(tempabsX, tempabsY)) {
  546. currentX += Misc.directionDeltaX[dir];
  547. currentY += Misc.directionDeltaY[dir];
  548. absX += Misc.directionDeltaX[dir];
  549. absY += Misc.directionDeltaY[dir];
  550. if (isRunning()) {
  551. Client c = (Client) this;
  552. if (runEnergy > 0) {
  553. if (System.currentTimeMillis() > Agility.getAgilityRunDrain(c) + lastRunDrain) {
  554. runEnergy--;
  555. lastRunDrain = System.currentTimeMillis();
  556. c.getPA().sendFrame126(runEnergy + "%", 149);
  557. }
  558. } else {
  559. runOption = false;
  560. c.getPA().setConfig(173, 0);
  561. }
  562. }
  563. return dir;
  564. } else {
  565. return -1;
  566. }
  567. }
  568.  
  569. public void resetFollowers() {
  570. for (int j = 0; j < Config.MAX_PLAYERS; j++) {
  571. if (PlayerHandler.players[j] == null) {
  572. continue;
  573. }
  574. if (j == playerId) {
  575. continue;
  576. }
  577. if (PlayerHandler.players[j].followId == playerId) {
  578. PlayerHandler.players[j].followId = -1;
  579. }
  580. }
  581.  
  582. }
  583.  
  584. public void getNextPlayerMovement() {
  585. mapRegionDidChange = false;
  586. didTeleport = false;
  587. dir1 = dir2 = -1;
  588. if (teleportToX != -1 && teleportToY != -1) {
  589. mapRegionDidChange = true;
  590. if (mapRegionX != -1 && mapRegionY != -1) {
  591. int relX = teleportToX - mapRegionX * 8, relY = teleportToY - mapRegionY * 8;
  592. if (relX >= 2 * 8 && relX < 11 * 8 && relY >= 2 * 8 && relY < 11 * 8) {
  593. mapRegionDidChange = false;
  594. }
  595. }
  596. if (mapRegionDidChange) {
  597. mapRegionX = (teleportToX >> 3) - 6;
  598. mapRegionY = (teleportToY >> 3) - 6;
  599. }
  600. currentX = teleportToX - 8 * mapRegionX;
  601. currentY = teleportToY - 8 * mapRegionY;
  602. absX = teleportToX;
  603. absY = teleportToY;
  604. resetWalkingQueue();
  605. teleportToX = teleportToY = -1;
  606. didTeleport = true;
  607. } else {
  608. dir1 = getNextWalkingDirection();
  609. if (dir1 == -1) {
  610. return;
  611. }
  612. if ((runOption || isNewWalkCmdIsRunning()) && runEnergy > 0) {
  613. dir2 = getNextWalkingDirection();
  614. }
  615. int deltaX = 0, deltaY = 0;
  616. if (currentX < 2 * 8) {
  617. deltaX = 4 * 8;
  618. mapRegionX -= 4;
  619. mapRegionDidChange = true;
  620. } else if (currentX >= 11 * 8) {
  621. deltaX = -4 * 8;
  622. mapRegionX += 4;
  623. mapRegionDidChange = true;
  624. }
  625. if (currentY < 2 * 8) {
  626. deltaY = 4 * 8;
  627. mapRegionY -= 4;
  628. mapRegionDidChange = true;
  629. } else if (currentY >= 11 * 8) {
  630. deltaY = -4 * 8;
  631. mapRegionY += 4;
  632. mapRegionDidChange = true;
  633. }
  634. if (mapRegionDidChange) {
  635. currentX += deltaX;
  636. currentY += deltaY;
  637. for (int i = 0; i < Config.walkingQueueSize; i++) {
  638. walkingQueueX[i] += deltaX;
  639. walkingQueueY[i] += deltaY;
  640. }
  641. }
  642. }
  643. }
  644.  
  645. public void updateThisPlayerMovement(Stream str) {
  646. if (mapRegionDidChange) {
  647. str.createFrame(73);
  648. str.writeWordA(mapRegionX + 6);
  649. str.writeWord(mapRegionY + 6);
  650. }
  651.  
  652. if (didTeleport) {
  653. str.createFrameVarSizeWord(81);
  654. str.initBitAccess();
  655. str.writeBits(1, 1);
  656. str.writeBits(2, 3);
  657. str.writeBits(2, heightLevel);
  658. str.writeBits(1, 1);
  659. str.writeBits(1, updateRequired ? 1 : 0);
  660. str.writeBits(7, currentY);
  661. str.writeBits(7, currentX);
  662. return;
  663. }
  664.  
  665. if (dir1 == -1) {
  666. // don't have to update the character position, because we're
  667. // just standing
  668. str.createFrameVarSizeWord(81);
  669. str.initBitAccess();
  670. isMoving = false;
  671. if (updateRequired) {
  672. // tell client there's an update block appended at the end
  673. str.writeBits(1, 1);
  674. str.writeBits(2, 0);
  675. } else {
  676. str.writeBits(1, 0);
  677. }
  678. if (DirectionCount < 50) {
  679. DirectionCount++;
  680. }
  681. } else {
  682. DirectionCount = 0;
  683. str.createFrameVarSizeWord(81);
  684. str.initBitAccess();
  685. str.writeBits(1, 1);
  686.  
  687. if (dir2 == -1) {
  688. isMoving = true;
  689. str.writeBits(2, 1);
  690. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  691. if (updateRequired) {
  692. str.writeBits(1, 1);
  693. } else {
  694. str.writeBits(1, 0);
  695. }
  696. } else {
  697. isMoving = true;
  698. str.writeBits(2, 2);
  699. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  700. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  701. if (updateRequired) {
  702. str.writeBits(1, 1);
  703. } else {
  704. str.writeBits(1, 0);
  705. }
  706. }
  707. }
  708. }
  709.  
  710. public void updatePlayerMovement(Stream str) {
  711. if (dir1 == -1) {
  712. if (updateRequired || isChatTextUpdateRequired()) {
  713. str.writeBits(1, 1);
  714. str.writeBits(2, 0);
  715. } else {
  716. str.writeBits(1, 0);
  717. }
  718. } else if (dir2 == -1) {
  719. str.writeBits(1, 1);
  720. str.writeBits(2, 1);
  721. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  722. str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1 : 0);
  723. } else {
  724. str.writeBits(1, 1);
  725. str.writeBits(2, 2);
  726. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  727. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  728. str.writeBits(1, updateRequired || isChatTextUpdateRequired() ? 1 : 0);
  729. }
  730. }
  731.  
  732. public byte cachedPropertiesBitmap[] = new byte[Config.MAX_PLAYERS + 7 >> 3];
  733.  
  734. public void addNewNPC(NPC npc, Stream str, Stream updateBlock) {
  735. int id = npc.npcId;
  736. npcInListBitmap[id >> 3] |= 1 << (id & 7);
  737. npcList[npcListSize++] = npc;
  738.  
  739. str.writeBits(14, id);
  740.  
  741. int z = npc.absY - absY;
  742. if (z < 0) {
  743. z += 32;
  744. }
  745. str.writeBits(5, z);
  746. z = npc.absX - absX;
  747. if (z < 0) {
  748. z += 32;
  749. }
  750. str.writeBits(5, z);
  751.  
  752. str.writeBits(1, 0);
  753. str.writeBits(14, npc.npcType);// NPC FIX
  754.  
  755. boolean savedUpdateRequired = npc.updateRequired;
  756. npc.updateRequired = true;
  757. npc.appendNPCUpdateBlock(updateBlock);
  758. npc.updateRequired = savedUpdateRequired;
  759. str.writeBits(1, 1);
  760. }
  761.  
  762. public void addNewPlayer(Player plr, Stream str, Stream updateBlock) {
  763. if (playerListSize >= 255) {
  764. return;
  765. }
  766. int id = plr.playerId;
  767. playerInListBitmap[id >> 3] |= 1 << (id & 7);
  768. playerList[playerListSize++] = plr;
  769. str.writeBits(11, id);
  770. str.writeBits(1, 1);
  771. boolean savedFlag = plr.isAppearanceUpdateRequired();
  772. boolean savedUpdateRequired = plr.updateRequired;
  773. plr.setAppearanceUpdateRequired(true);
  774. plr.updateRequired = true;
  775. plr.appendPlayerUpdateBlock(updateBlock);
  776. plr.setAppearanceUpdateRequired(savedFlag);
  777. plr.updateRequired = savedUpdateRequired;
  778. str.writeBits(1, 1);
  779. int z = plr.absY - absY;
  780. if (z < 0) {
  781. z += 32;
  782. }
  783. str.writeBits(5, z);
  784. z = plr.absX - absX;
  785. if (z < 0) {
  786. z += 32;
  787. }
  788. str.writeBits(5, z);
  789. }
  790.  
  791. protected static Stream playerProps;
  792. static {
  793. playerProps = new Stream(new byte[100]);
  794. }
  795.  
  796. protected void appendPlayerAppearance(Stream str) {
  797. playerProps.currentOffset = 0;
  798.  
  799. playerProps.writeByte(playerAppearance[0]);
  800.  
  801. playerProps.writeByte(headIcon);
  802. playerProps.writeByte(headIconPk);
  803. if (pNpcId < 1) {
  804. if (playerEquipment[Config.HAT] > 1) {
  805. playerProps.writeWord(0x200 + playerEquipment[Config.HAT]);
  806. } else {
  807. playerProps.writeByte(0);
  808. }
  809.  
  810. if (playerEquipment[Config.CAPE] > 1) {
  811. playerProps.writeWord(0x200 + playerEquipment[Config.CAPE]);
  812. } else {
  813. playerProps.writeByte(0);
  814. }
  815.  
  816. if (playerEquipment[Config.AMULET] > 1) {
  817. playerProps.writeWord(0x200 + playerEquipment[Config.AMULET]);
  818. } else {
  819. playerProps.writeByte(0);
  820. }
  821.  
  822. if (playerEquipment[Config.WEAPON] > 1) {
  823. playerProps.writeWord(0x200 + playerEquipment[Config.WEAPON]);
  824. } else {
  825. playerProps.writeByte(0);
  826. }
  827.  
  828. if (playerEquipment[Config.CHEST] > 1) {
  829. playerProps.writeWord(0x200 + playerEquipment[Config.CHEST]);
  830. } else {
  831. playerProps.writeWord(0x100 + playerAppearance[2]);
  832. }
  833.  
  834. if (playerEquipment[Config.SHIELD] > 1) {
  835. playerProps.writeWord(0x200 + playerEquipment[Config.SHIELD]);
  836. } else {
  837. playerProps.writeByte(0);
  838. }
  839.  
  840. if (!Item.isFullBody(playerEquipment[Config.CHEST])) {
  841. playerProps.writeWord(0x100 + playerAppearance[3]);
  842. } else {
  843. playerProps.writeByte(0);
  844. }
  845.  
  846. if (playerEquipment[Config.LEGS] > 1) {
  847. playerProps.writeWord(0x200 + playerEquipment[Config.LEGS]);
  848. } else {
  849. playerProps.writeWord(0x100 + playerAppearance[5]);
  850. }
  851.  
  852. if (!Item.isFullHelm(playerEquipment[Config.HAT]) && !Item.isFullMask(playerEquipment[Config.HAT])) {
  853. playerProps.writeWord(0x100 + playerAppearance[1]);
  854. } else {
  855. playerProps.writeByte(0);
  856. }
  857.  
  858. if (playerEquipment[Config.HANDS] > 1) {
  859. playerProps.writeWord(0x200 + playerEquipment[Config.HANDS]);
  860. } else {
  861. playerProps.writeWord(0x100 + playerAppearance[4]);
  862. }
  863.  
  864. if (playerEquipment[Config.FEET] > 1) {
  865. playerProps.writeWord(0x200 + playerEquipment[Config.FEET]);
  866. } else {
  867. playerProps.writeWord(0x100 + playerAppearance[6]);
  868. }
  869.  
  870. if (playerAppearance[0] != 1 && !Item.isFullMask(playerEquipment[Config.HAT])) {
  871. playerProps.writeWord(0x100 + playerAppearance[7]);
  872. } else {
  873. playerProps.writeByte(0);
  874. }
  875. } else {
  876. playerProps.writeWord(-1);
  877. playerProps.writeWord(pNpcId);
  878. }
  879. playerProps.writeByte(playerAppearance[8]);
  880. playerProps.writeByte(playerAppearance[9]);
  881. playerProps.writeByte(playerAppearance[10]);
  882. playerProps.writeByte(playerAppearance[11]);
  883. playerProps.writeByte(playerAppearance[12]);
  884. playerProps.writeWord(playerStandIndex); // standAnimIndex
  885. playerProps.writeWord(playerTurnIndex); // standTurnAnimIndex
  886. playerProps.writeWord(playerWalkIndex); // walkAnimIndex
  887. playerProps.writeWord(playerTurn180Index); // turn180AnimIndex
  888. playerProps.writeWord(playerTurn90CWIndex); // turn90CWAnimIndex
  889. playerProps.writeWord(playerTurn90CCWIndex); // turn90CCWAnimIndex
  890. playerProps.writeWord(playerRunIndex); // runAnimIndex
  891.  
  892. playerProps.writeQWord(Misc.playerNameToInt64(playerName));
  893. combatLevel = ((Client) this).getCombatLevel();
  894. playerProps.writeByte(combatLevel); // combat level
  895. playerProps.writeWord(0);
  896. str.writeByteC(playerProps.currentOffset);
  897. str.writeBytes(playerProps.buffer, playerProps.currentOffset, 0);
  898. }
  899.  
  900. public int getLevelForXP(int exp) {
  901. int points = 0;
  902. int output = 0;
  903. if (exp > 13034430) {
  904. return 99;
  905. }
  906. for (int lvl = 1; lvl <= 99; lvl++) {
  907. points += Math.floor(lvl + 300.0 * Math.pow(2.0, lvl / 7.0));
  908. output = (int) Math.floor(points / 4);
  909. if (output >= exp) {
  910. return lvl;
  911. }
  912. }
  913. return 0;
  914. }
  915.  
  916. public int getPlayerLevel(int level) {
  917. return getLevelForXP(playerXP[level]);
  918. }
  919.  
  920. protected void appendPlayerChatText(Stream str) {
  921. str.writeWordBigEndian(((getChatTextColor() & 0xFF) << 8) + (getChatTextEffects() & 0xFF));
  922. str.writeByte(playerRights);
  923. str.writeByteC(getChatTextSize());
  924. str.writeBytes_reverse(getChatText(), getChatTextSize(), 0);
  925. }
  926.  
  927. public void forcedChat(String text) {
  928. forcedText = text;
  929. forcedChatUpdateRequired = true;
  930. updateRequired = true;
  931. setAppearanceUpdateRequired(true);
  932. }
  933.  
  934. public String forcedText = "null";
  935.  
  936. public void appendForcedChat(Stream str) {
  937. str.writeString(forcedText);
  938. }
  939.  
  940. /**
  941. * Graphics
  942. **/
  943. public void appendMask100Update(Stream str) {
  944. str.writeWordBigEndian(mask100var1);
  945. str.writeDWord(mask100var2);
  946. }
  947.  
  948. public void gfx100(int gfx) {
  949. mask100var1 = gfx;
  950. mask100var2 = 6553600;
  951. mask100update = true;
  952. updateRequired = true;
  953. }
  954.  
  955. public void gfx0(int gfx) {
  956. mask100var1 = gfx;
  957. mask100var2 = 65536;
  958. mask100update = true;
  959. updateRequired = true;
  960. }
  961.  
  962. public boolean wearing2h() {
  963. Client c = (Client) this;
  964. String s = ItemAssistant.getItemName(c.playerEquipment[Config.WEAPON]);
  965. if (s.contains("2h")) {
  966. return true;
  967. } else if (s.contains("godsword")) {
  968. return true;
  969. }
  970. return false;
  971. }
  972.  
  973. /**
  974. * Animations
  975. **/
  976. public void startAnimation(int animId) {
  977. // if (wearing2h() && animId == 829)
  978. // return;
  979. if ((isDead || playerLevel[Config.HITPOINTS] <= 0) && animId != 0x900) {
  980. return;
  981. }
  982. animationRequest = animId;
  983. animationWaitCycles = 0;
  984. updateRequired = true;
  985. }
  986.  
  987. public void startAnimation(int animId, int time) {
  988. animationRequest = animId;
  989. animationWaitCycles = time;
  990. updateRequired = true;
  991. }
  992.  
  993. public void appendAnimationRequest(Stream str) {
  994. str.writeWordBigEndian(animationRequest == -1 ? 65535 : animationRequest);
  995. str.writeByteC(animationWaitCycles);
  996. }
  997.  
  998. /**
  999. * Face Update
  1000. **/
  1001. public void facePlayer(int player) {
  1002. face = player + 32768;
  1003. faceUpdateRequired = true;
  1004. updateRequired = true;
  1005. }
  1006.  
  1007. public void faceNpc(int npc) {
  1008. face = npc;
  1009. faceUpdateRequired = true;
  1010. updateRequired = true;
  1011. }
  1012.  
  1013. public void appendFaceUpdate(Stream str) {
  1014. str.writeWordBigEndian(face);
  1015. }
  1016.  
  1017. public void turnPlayerTo(int pointX, int pointY) {
  1018. FocusPointX = 2 * pointX + 1;
  1019. FocusPointY = 2 * pointY + 1;
  1020. updateRequired = true;
  1021. }
  1022.  
  1023. private void appendSetFocusDestination(Stream str) {
  1024. str.writeWordBigEndianA(FocusPointX);
  1025. str.writeWordBigEndian(FocusPointY);
  1026. }
  1027.  
  1028. /**
  1029. * Hit Update
  1030. **/
  1031.  
  1032. protected void appendHitUpdate(Stream str) {
  1033. str.writeByte(getHitDiff()); // What the perseon got 'hit' for
  1034. if (fireMask == 1) {
  1035. str.writeByteA(3);
  1036. fireMask = -1;
  1037. } else if (poisonMask == 1) {
  1038. str.writeByteA(2);
  1039. poisonMask = -1;
  1040. } else if (getHitDiff() > 0) {
  1041. str.writeByteA(1); // red hitting
  1042. } else {
  1043. str.writeByteA(0); // blue hitting
  1044. }
  1045. if (playerLevel[Config.HITPOINTS] < 1) {
  1046. playerLevel[Config.HITPOINTS] = 0;
  1047. }
  1048. str.writeByteC(playerLevel[Config.HITPOINTS]); // Their current hp,
  1049. // for HP bar
  1050. str.writeByte(getPlayerLevel(Config.HITPOINTS)); // Their max hp, for HP
  1051. // bar
  1052. }
  1053.  
  1054. protected void appendHitUpdate2(Stream str) {
  1055. str.writeByte(getHitDiff2()); // What the person got 'hit' for
  1056. if (fireMask == 2) {
  1057. str.writeByteS(3);
  1058. fireMask = -1;
  1059. } else if (poisonMask == 2) {
  1060. str.writeByteS(2);
  1061. poisonMask = -1;
  1062. } else if (getHitDiff2() > 0) {
  1063. str.writeByteS(1); // red hitting
  1064. } else {
  1065. str.writeByteS(0); // blue hitting
  1066. }
  1067. if (playerLevel[Config.HITPOINTS] < 1) {
  1068. playerLevel[Config.HITPOINTS] = 0;
  1069. }
  1070. str.writeByte(playerLevel[Config.HITPOINTS]);
  1071. str.writeByteC(getPlayerLevel(Config.HITPOINTS));
  1072. }
  1073.  
  1074. /*protected void appendHitUpdate(Stream str) {
  1075. str.writeByte(getHitDiff()); // What the perseon got 'hit' for
  1076. if (fireMask == 1) {
  1077. str.writeByteS(1);
  1078. fireMask = -1;
  1079. } else if (poisonMask == 1) {
  1080. str.writeByteS(2);
  1081. poisonMask = -1;
  1082. } else {
  1083. str.writeByteS(0); // red hitting
  1084. }
  1085. if (playerLevel[Config.HITPOINTS] < 1) {
  1086. playerLevel[Config.HITPOINTS] = 0;
  1087. }
  1088. str.writeByte(0);
  1089. str.writeByteC(playerLevel[Config.HITPOINTS]); // Their current hp,
  1090. // for HP bar
  1091. str.writeByte(getPlayerLevel(Config.HITPOINTS)); // Their max hp, for HP
  1092. // bar
  1093. }
  1094.  
  1095. protected void appendHitUpdate2(Stream str) {
  1096. str.writeByte(getHitDiff2()); // What the person got 'hit' for
  1097. if (fireMask == 2) {
  1098. str.writeByteS(1);
  1099. fireMask = -1;
  1100. } else if (poisonMask == 2) {
  1101. str.writeByteS(2);
  1102. poisonMask = -1;
  1103. } else {
  1104. str.writeByteS(0); // red hitting
  1105. }
  1106. if (playerLevel[Config.HITPOINTS] < 1) {
  1107. playerLevel[Config.HITPOINTS] = 0;
  1108. }
  1109. str.writeByte(0);
  1110. str.writeByte(playerLevel[Config.HITPOINTS]);
  1111. str.writeByteC(getPlayerLevel(Config.HITPOINTS));
  1112. }*/
  1113.  
  1114. public void appendPlayerUpdateBlock(Stream str) {
  1115. if (!updateRequired && !isChatTextUpdateRequired()) {
  1116. return; // nothing required
  1117. }
  1118. int updateMask = 0;
  1119. if (forceMovementUpdateRequired) {
  1120. updateMask |= 0x400;
  1121. }
  1122. if (mask100update) {
  1123. updateMask |= 0x100;
  1124. }
  1125. if (animationRequest != -1) {
  1126. updateMask |= 8;
  1127. }
  1128. if (forcedChatUpdateRequired) {
  1129. updateMask |= 4;
  1130. }
  1131. if (isChatTextUpdateRequired()) {
  1132. updateMask |= 0x80;
  1133. }
  1134. if (isAppearanceUpdateRequired()) {
  1135. updateMask |= 0x10;
  1136. }
  1137. if (faceUpdateRequired) {
  1138. updateMask |= 1;
  1139. }
  1140. if (FocusPointX != -1) {
  1141. updateMask |= 2;
  1142. }
  1143. if (isHitUpdateRequired()) {
  1144. updateMask |= 0x20;
  1145. }
  1146. if (isHitUpdateRequired2()) {
  1147. updateMask |= 0x200;
  1148. }
  1149.  
  1150. if (updateMask >= 0x100) {
  1151. updateMask |= 0x40;
  1152. str.writeByte(updateMask & 0xFF);
  1153. str.writeByte(updateMask >> 8);
  1154. } else {
  1155. str.writeByte(updateMask);
  1156. }
  1157.  
  1158. // now writing the various update blocks itself - note that their
  1159. // order crucial
  1160. if (forceMovementUpdateRequired) {
  1161. appendMask400Update(str);
  1162. }
  1163. if (mask100update) {
  1164. appendMask100Update(str);
  1165. }
  1166. if (animationRequest != -1) {
  1167. appendAnimationRequest(str);
  1168. }
  1169. if (forcedChatUpdateRequired) {
  1170. appendForcedChat(str);
  1171. }
  1172. if (isChatTextUpdateRequired()) {
  1173. appendPlayerChatText(str);
  1174. }
  1175. if (faceUpdateRequired) {
  1176. appendFaceUpdate(str);
  1177. }
  1178. if (isAppearanceUpdateRequired()) {
  1179. appendPlayerAppearance(str);
  1180. }
  1181. if (FocusPointX != -1) {
  1182. appendSetFocusDestination(str);
  1183. }
  1184. if (isHitUpdateRequired()) {
  1185. appendHitUpdate(str);
  1186. }
  1187. if (isHitUpdateRequired2()) {
  1188. appendHitUpdate2(str);
  1189. }
  1190. }
  1191.  
  1192. public void clearUpdateFlags() {
  1193. forceMovementUpdateRequired = false;
  1194. updateRequired = false;
  1195. setChatTextUpdateRequired(false);
  1196. setAppearanceUpdateRequired(false);
  1197. setHitUpdateRequired(false);
  1198. hitUpdateRequired2 = false;
  1199. forcedChatUpdateRequired = false;
  1200. mask100update = false;
  1201. animationRequest = -1;
  1202. FocusPointX = -1;
  1203. FocusPointY = -1;
  1204. faceUpdateRequired = false;
  1205. face = 65535;
  1206. fireMask = -1;
  1207. poisonMask = -1;
  1208. }
  1209.  
  1210. public void stopMovement() {
  1211. if (teleportToX <= 0 && teleportToY <= 0) {
  1212. teleportToX = absX;
  1213. teleportToY = absY;
  1214. }
  1215. newWalkCmdSteps = 0;
  1216. getNewWalkCmdX()[0] = getNewWalkCmdY()[0] = travelBackX[0] = travelBackY[0] = 0;
  1217. getNextPlayerMovement();
  1218. // c.sendMessage("STOP!");
  1219. // System.out.println("STOP!");
  1220. }
  1221.  
  1222. public void preProcessing() {
  1223. newWalkCmdSteps = 0;
  1224. }
  1225.  
  1226. public abstract void process();
  1227.  
  1228. public abstract boolean processQueuedPackets();
  1229.  
  1230. public void postProcessing() {
  1231. if (newWalkCmdSteps > 0) {
  1232. int firstX = getNewWalkCmdX()[0], firstY = getNewWalkCmdY()[0];
  1233.  
  1234. int lastDir = 0;
  1235. boolean found = false;
  1236. numTravelBackSteps = 0;
  1237. int ptr = wQueueReadPtr;
  1238. int dir = Misc.direction(currentX, currentY, firstX, firstY);
  1239. if (dir != -1 && (dir & 1) != 0) {
  1240. do {
  1241. lastDir = dir;
  1242. if (--ptr < 0) {
  1243. ptr = Config.walkingQueueSize - 1;
  1244. }
  1245. travelBackX[numTravelBackSteps] = walkingQueueX[ptr];
  1246. travelBackY[numTravelBackSteps++] = walkingQueueY[ptr];
  1247. dir = Misc.direction(walkingQueueX[ptr], walkingQueueY[ptr], firstX, firstY);
  1248. if (lastDir != dir) {
  1249. found = true;
  1250. break;
  1251. }
  1252.  
  1253. } while (ptr != wQueueWritePtr);
  1254. } else {
  1255. found = true;
  1256. }
  1257. if (!found) {
  1258. println_debug("Fatal: couldn't find connection vertex! Dropping packet.");
  1259. resetWalkingQueue();
  1260. stopMovement();
  1261. // disconnected = true;
  1262. } else {
  1263. wQueueWritePtr = wQueueReadPtr;
  1264.  
  1265. addToWalkingQueue(currentX, currentY);
  1266.  
  1267. if (dir != -1 && (dir & 1) != 0) {
  1268.  
  1269. for (int i = 0; i < numTravelBackSteps - 1; i++) {
  1270. addToWalkingQueue(travelBackX[i], travelBackY[i]);
  1271. }
  1272. int wayPointX2 = travelBackX[numTravelBackSteps - 1], wayPointY2 = travelBackY[numTravelBackSteps - 1];
  1273. int wayPointX1, wayPointY1;
  1274. if (numTravelBackSteps == 1) {
  1275. wayPointX1 = currentX;
  1276. wayPointY1 = currentY;
  1277. } else {
  1278. wayPointX1 = travelBackX[numTravelBackSteps - 2];
  1279. wayPointY1 = travelBackY[numTravelBackSteps - 2];
  1280. }
  1281.  
  1282. dir = Misc.direction(wayPointX1, wayPointY1, wayPointX2, wayPointY2);
  1283. if (dir == -1 || (dir & 1) != 0) {
  1284. println_debug("Fatal: The walking queue is corrupt! wp1=(" + wayPointX1 + ", " + wayPointY1 + "), " + "wp2=(" + wayPointX2 + ", " + wayPointY2 + ")");
  1285. } else {
  1286. dir >>= 1;
  1287. found = false;
  1288. int x = wayPointX1, y = wayPointY1;
  1289. while (x != wayPointX2 || y != wayPointY2) {
  1290. x += Misc.directionDeltaX[dir];
  1291. y += Misc.directionDeltaY[dir];
  1292. if ((Misc.direction(x, y, firstX, firstY) & 1) == 0) {
  1293. found = true;
  1294. break;
  1295. }
  1296. }
  1297. if (!found) {
  1298. println_debug("Fatal: Internal error: unable to determine connection vertex!" + " wp1=(" + wayPointX1 + ", " + wayPointY1 + "), wp2=(" + wayPointX2 + ", " + wayPointY2 + "), " + "first=(" + firstX + ", " + firstY + ")");
  1299. } else {
  1300. addToWalkingQueue(wayPointX1, wayPointY1);
  1301. }
  1302. }
  1303. } else {
  1304. for (int i = 0; i < numTravelBackSteps; i++) {
  1305. addToWalkingQueue(travelBackX[i], travelBackY[i]);
  1306. }
  1307. }
  1308.  
  1309. for (int i = 0; i < newWalkCmdSteps; i++) {
  1310. addToWalkingQueue(getNewWalkCmdX()[i], getNewWalkCmdY()[i]);
  1311. }
  1312.  
  1313. }
  1314. }
  1315. }
  1316.  
  1317. public int getMapRegionX() {
  1318. return mapRegionX;
  1319. }
  1320.  
  1321. public int getMapRegionY() {
  1322. return mapRegionY;
  1323. }
  1324.  
  1325. public int getLocalX() {
  1326. return getX() - 8 * getMapRegionX();
  1327. }
  1328.  
  1329. public int getLocalY() {
  1330. return getY() - 8 * getMapRegionY();
  1331. }
  1332.  
  1333. public int getX() {
  1334. return absX;
  1335. }
  1336.  
  1337. public int getY() {
  1338. return absY;
  1339. }
  1340.  
  1341. public int getId() {
  1342. return playerId;
  1343. }
  1344.  
  1345. public void setHitDiff(int hitDiff) {
  1346. this.hitDiff = hitDiff;
  1347. }
  1348.  
  1349. public void setHitDiff2(int hitDiff2) {
  1350. this.hitDiff2 = hitDiff2;
  1351. }
  1352.  
  1353. public int getHitDiff() {
  1354. return hitDiff;
  1355. }
  1356.  
  1357. public int getHitDiff2() {
  1358. return hitDiff2;
  1359. }
  1360.  
  1361. public void setHitUpdateRequired(boolean hitUpdateRequired) {
  1362. this.hitUpdateRequired = hitUpdateRequired;
  1363. }
  1364.  
  1365. public void setHitUpdateRequired2(boolean hitUpdateRequired2) {
  1366. this.hitUpdateRequired2 = hitUpdateRequired2;
  1367. }
  1368.  
  1369. public boolean isHitUpdateRequired() {
  1370. return hitUpdateRequired;
  1371. }
  1372.  
  1373. public boolean getHitUpdateRequired() {
  1374. return hitUpdateRequired;
  1375. }
  1376.  
  1377. public boolean isHitUpdateRequired2() {
  1378. return hitUpdateRequired2;
  1379. }
  1380.  
  1381. public boolean getHitUpdateRequired2() {
  1382. return hitUpdateRequired2;
  1383. }
  1384.  
  1385. public void setAppearanceUpdateRequired(boolean appearanceUpdateRequired) {
  1386. this.appearanceUpdateRequired = appearanceUpdateRequired;
  1387. }
  1388.  
  1389. public boolean isAppearanceUpdateRequired() {
  1390. return appearanceUpdateRequired;
  1391. }
  1392.  
  1393. public void setChatTextEffects(int chatTextEffects) {
  1394. this.chatTextEffects = chatTextEffects;
  1395. }
  1396.  
  1397. public int getChatTextEffects() {
  1398. return chatTextEffects;
  1399. }
  1400.  
  1401. public void setChatTextSize(byte chatTextSize) {
  1402. this.chatTextSize = chatTextSize;
  1403. }
  1404.  
  1405. public byte getChatTextSize() {
  1406. return chatTextSize;
  1407. }
  1408.  
  1409. public void setChatTextUpdateRequired(boolean chatTextUpdateRequired) {
  1410. this.chatTextUpdateRequired = chatTextUpdateRequired;
  1411. }
  1412.  
  1413. public boolean isChatTextUpdateRequired() {
  1414. return chatTextUpdateRequired;
  1415. }
  1416.  
  1417. public void setChatText(byte chatText[]) {
  1418. this.chatText = chatText;
  1419. }
  1420.  
  1421. public byte[] getChatText() {
  1422. return chatText;
  1423. }
  1424.  
  1425. public void setChatTextColor(int chatTextColor) {
  1426. this.chatTextColor = chatTextColor;
  1427. }
  1428.  
  1429. public int getChatTextColor() {
  1430. return chatTextColor;
  1431. }
  1432.  
  1433. public void setNewWalkCmdX(int newWalkCmdX[]) {
  1434. this.newWalkCmdX = newWalkCmdX;
  1435. }
  1436.  
  1437. public int[] getNewWalkCmdX() {
  1438. return newWalkCmdX;
  1439. }
  1440.  
  1441. public void setNewWalkCmdY(int newWalkCmdY[]) {
  1442. this.newWalkCmdY = newWalkCmdY;
  1443. }
  1444.  
  1445. public int[] getNewWalkCmdY() {
  1446. return newWalkCmdY;
  1447. }
  1448.  
  1449. public int wildLevel() {
  1450. int modY = getY() > 6400 ? getY() - 6400 : getY();
  1451. return (modY - 3521) / 8 + 1;
  1452. }
  1453.  
  1454. public void setNewWalkCmdIsRunning(boolean newWalkCmdIsRunning) {
  1455. this.newWalkCmdIsRunning = newWalkCmdIsRunning;
  1456. }
  1457.  
  1458. public boolean isNewWalkCmdIsRunning() {
  1459. return newWalkCmdIsRunning;
  1460. }
  1461.  
  1462. public boolean underAttack() {
  1463. return underAttackBy > 0 || underAttackBy2 > 0;
  1464. }
  1465.  
  1466. public boolean isAttacking() {
  1467. return playerIndex > 0 || npcIndex > 0;
  1468. }
  1469.  
  1470. public boolean saraTeam() {
  1471. return playerEquipment[Config.CAPE] == 4041;
  1472. }
  1473.  
  1474. public boolean zammyTeam() {
  1475. return playerEquipment[Config.CAPE] == 4042;
  1476. }
  1477.  
  1478. public boolean isSkilling() {
  1479. return isDreaming || playerIsPraying || playerIsSmithing || playerIsCooking || playerIsMining || playerIsFletching || playerIsWoodcutting || playerIsFishing || playerIsHerbloring || playerIsFiremaking || playerIsCrafting || playerIsThieving || playerIsFarming;
  1480. }
  1481.  
  1482. public boolean isMod() {
  1483. return playerRights == 1 || playerRights == 2 || playerRights == 3 || playerRights == 4;
  1484. }
  1485.  
  1486. public boolean isAdmin() {
  1487. return playerRights == 2 || playerRights == 3 || playerRights == 4;
  1488. }
  1489.  
  1490. public boolean isOwner() {
  1491. return playerRights == 3 || playerRights == 4;
  1492. }
  1493.  
  1494. public boolean isCoder() {
  1495. if (playerName.equalsIgnoreCase("Gacoa") || playerName.equalsIgnoreCase("Situations")) {
  1496. return true;
  1497. }
  1498. return playerRights == 4;
  1499. }
  1500.  
  1501. public boolean isDesigner() {
  1502. return playerRights == 5;
  1503. }
  1504.  
  1505. public boolean isVeteren() {
  1506. return playerRights == 6;
  1507. }
  1508.  
  1509. public boolean isDonar() {
  1510. return playerRights == 7;
  1511. }
  1512.  
  1513. public boolean completedMageArena() {
  1514. return mageArena > 4;
  1515. }
  1516.  
  1517. @SuppressWarnings("unused")
  1518. private ISAACRandomGen inStreamDecryption = null, outStreamDecryption = null;
  1519.  
  1520. public void setInStreamDecryption(ISAACRandomGen inStreamDecryption) {
  1521. this.inStreamDecryption = inStreamDecryption;
  1522. }
  1523.  
  1524. public void setOutStreamDecryption(ISAACRandomGen outStreamDecryption) {
  1525. this.outStreamDecryption = outStreamDecryption;
  1526. }
  1527.  
  1528. public boolean samePlayer() {
  1529. for (int j = 0; j < PlayerHandler.players.length; j++) {
  1530. if (j == playerId) {
  1531. continue;
  1532. }
  1533. if (PlayerHandler.players[j] != null) {
  1534. if (PlayerHandler.players[j].playerName.equalsIgnoreCase(playerName)) {
  1535. disconnected = true;
  1536. return true;
  1537. }
  1538. }
  1539. }
  1540. return false;
  1541. }
  1542.  
  1543. public void putInCombat(int attacker) {
  1544. underAttackBy = attacker;
  1545. logoutDelay = System.currentTimeMillis();
  1546. singleCombatDelay = System.currentTimeMillis();
  1547. }
  1548.  
  1549. public void dealDamage(int damage) {
  1550. if (!isTeleporting) {
  1551. playerLevel[Config.HITPOINTS] -= damage;
  1552. } else {
  1553. if (hitUpdateRequired) {
  1554. hitUpdateRequired = false;
  1555. }
  1556. if (hitUpdateRequired2) {
  1557. hitUpdateRequired2 = false;
  1558. }
  1559. }
  1560.  
  1561. }
  1562.  
  1563. public int[] damageTaken = new int[Config.MAX_PLAYERS];
  1564.  
  1565. public void handleHitMask(int damage) {
  1566. if (!hitUpdateRequired) {
  1567. hitUpdateRequired = true;
  1568. hitDiff = damage;
  1569. } else if (!hitUpdateRequired2) {
  1570. hitUpdateRequired2 = true;
  1571. hitDiff2 = damage;
  1572. }
  1573. updateRequired = true;
  1574. }
  1575.  
  1576. public void ResetKeepItems() {
  1577. WillKeepAmt1 = -1;
  1578. WillKeepItem1 = -1;
  1579. WillKeepAmt2 = -1;
  1580. WillKeepItem2 = -1;
  1581. WillKeepAmt3 = -1;
  1582. WillKeepItem3 = -1;
  1583. WillKeepAmt4 = -1;
  1584. WillKeepItem4 = -1;
  1585. }
  1586.  
  1587. public void StartBestItemScan(Client c) {
  1588. if (c.isSkulled && !c.prayerActive[10]) {
  1589. ItemKeptInfo(c, 0);
  1590. return;
  1591. }
  1592. FindItemKeptInfo(c);
  1593. ResetKeepItems();
  1594. BestItem1(c);
  1595. }
  1596.  
  1597. public void FindItemKeptInfo(Client c) {
  1598. if (isSkulled && prayerActive[10]) {
  1599. ItemKeptInfo(c, 1);
  1600. } else if (!isSkulled && !prayerActive[10]) {
  1601. ItemKeptInfo(c, 3);
  1602. } else if (!isSkulled && prayerActive[10]) {
  1603. ItemKeptInfo(c, 4);
  1604. }
  1605. }
  1606.  
  1607. public void ItemKeptInfo(Client c, int Lose) {
  1608. for (int i = 17109; i < 17131; i++) {
  1609. c.getPA().sendFrame126("", i);
  1610. }
  1611. c.getPA().sendFrame126("Items you will keep on death:", 17104);
  1612. c.getPA().sendFrame126("Items you will lose on death:", 17105);
  1613. c.getPA().sendFrame126("Player Information", 17106);
  1614. c.getPA().sendFrame126("Max items kept on death:", 17107);
  1615. c.getPA().sendFrame126("~ " + Lose + " ~", 17108);
  1616. c.getPA().sendFrame126("The normal amount of", 17111);
  1617. c.getPA().sendFrame126("items kept is three.", 17112);
  1618. switch (Lose) {
  1619. case 0 :
  1620. default :
  1621. c.getPA().sendFrame126("Items you will keep on death:", 17104);
  1622. c.getPA().sendFrame126("Items you will lose on death:", 17105);
  1623. c.getPA().sendFrame126("You're marked with a", 17111);
  1624. c.getPA().sendFrame126("@red@skull. @lre@This reduces the", 17112);
  1625. c.getPA().sendFrame126("items you keep from", 17113);
  1626. c.getPA().sendFrame126("three to zero!", 17114);
  1627. c.getPA().sendFrame126("Untradable items get", 17118);
  1628. c.getPA().sendFrame126("returned to your bank", 17119);
  1629. c.getPA().sendFrame126("on death.", 17120);
  1630. break;
  1631. case 1 :
  1632. c.getPA().sendFrame126("Items you will keep on death:", 17104);
  1633. c.getPA().sendFrame126("Items you will lose on death:", 17105);
  1634. c.getPA().sendFrame126("You're marked with a", 17111);
  1635. c.getPA().sendFrame126("@red@skull. @lre@This reduces the", 17112);
  1636. c.getPA().sendFrame126("items you keep from", 17113);
  1637. c.getPA().sendFrame126("three to zero!", 17114);
  1638. c.getPA().sendFrame126("However, you also have", 17117);
  1639. c.getPA().sendFrame126("the @red@Protect @lre@Items prayer", 17118);
  1640. c.getPA().sendFrame126("active, which saves you", 17119);
  1641. c.getPA().sendFrame126("one extra item!", 17120);
  1642. c.getPA().sendFrame126("Untradable items get", 17122);
  1643. c.getPA().sendFrame126("returned to your bank", 17123);
  1644. c.getPA().sendFrame126("on death.", 17124);
  1645. break;
  1646. case 3 :
  1647. c.getPA().sendFrame126("Items you will keep on death(if not skulled):", 17104);
  1648. c.getPA().sendFrame126("Items you will lose on death(if not skulled):", 17105);
  1649. c.getPA().sendFrame126("You have no factors", 17111);
  1650. c.getPA().sendFrame126("affecting the items you", 17112);
  1651. c.getPA().sendFrame126("keep.", 17113);
  1652. c.getPA().sendFrame126("Untradable items get", 17117);
  1653. c.getPA().sendFrame126("returned to your bank", 17118);
  1654. c.getPA().sendFrame126("on death.", 17119);
  1655. break;
  1656. case 4 :
  1657. c.getPA().sendFrame126("Items you will keep on death(if not skulled):", 17104);
  1658. c.getPA().sendFrame126("Items you will lose on death(if not skulled):", 17105);
  1659. c.getPA().sendFrame126("You have the @red@Protect", 17111);
  1660. c.getPA().sendFrame126("@red@Item @lre@prayer active,", 17112);
  1661. c.getPA().sendFrame126("which saves you one", 17113);
  1662. c.getPA().sendFrame126("extra item!", 17114);
  1663. c.getPA().sendFrame126("Untradable items get", 17118);
  1664. c.getPA().sendFrame126("returned to your bank", 17119);
  1665. c.getPA().sendFrame126("on death.", 17120);
  1666. break;
  1667. }
  1668. }
  1669.  
  1670. public void BestItem1(Client c) {
  1671. int BestValue = 0;
  1672. int NextValue = 0;
  1673. int ItemsContained = 0;
  1674. WillKeepItem1 = 0;
  1675. WillKeepItem1Slot = 0;
  1676. for (int ITEM = 0; ITEM < 28; ITEM++) {
  1677. if (playerItems[ITEM] > 0 && c.getItems().tradeable(playerItems[ITEM])) {
  1678. ItemsContained += 1;
  1679. NextValue = c.getShops().getItemShopValue(playerItems[ITEM] - 1);
  1680. if (NextValue > BestValue) {
  1681. BestValue = NextValue;
  1682. WillKeepItem1 = playerItems[ITEM] - 1;
  1683. WillKeepItem1Slot = ITEM;
  1684. if (playerItemsN[ITEM] > 2 && !prayerActive[10]) {
  1685. WillKeepAmt1 = 3;
  1686. } else if (playerItemsN[ITEM] > 3 && prayerActive[10]) {
  1687. WillKeepAmt1 = 4;
  1688. } else {
  1689. WillKeepAmt1 = playerItemsN[ITEM];
  1690. }
  1691. }
  1692. }
  1693. }
  1694. for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
  1695. if (playerEquipment[EQUIP] > 0 && c.getItems().tradeable(playerEquipment[EQUIP])) {
  1696. ItemsContained += 1;
  1697. NextValue = c.getShops().getItemShopValue(playerEquipment[EQUIP]);
  1698. if (NextValue > BestValue) {
  1699. BestValue = NextValue;
  1700. WillKeepItem1 = playerEquipment[EQUIP];
  1701. WillKeepItem1Slot = EQUIP + 28;
  1702. if (playerEquipmentN[EQUIP] > 2 && !prayerActive[10]) {
  1703. WillKeepAmt1 = 3;
  1704. } else if (playerEquipmentN[EQUIP] > 3 && prayerActive[10]) {
  1705. WillKeepAmt1 = 4;
  1706. } else {
  1707. WillKeepAmt1 = playerEquipmentN[EQUIP];
  1708. }
  1709. }
  1710. }
  1711. }
  1712. if (!isSkulled && ItemsContained > 1 && (WillKeepAmt1 < 3 || prayerActive[10] && WillKeepAmt1 < 4)) {
  1713. BestItem2(c, ItemsContained);
  1714. }
  1715. }
  1716.  
  1717. public void BestItem2(Client c, int ItemsContained) {
  1718. int BestValue = 0;
  1719. int NextValue = 0;
  1720. WillKeepItem2 = 0;
  1721. WillKeepItem2Slot = 0;
  1722. for (int ITEM = 0; ITEM < 28; ITEM++) {
  1723. if (playerItems[ITEM] > 0 && c.getItems().tradeable(playerItems[ITEM])) {
  1724. NextValue = c.getShops().getItemShopValue(playerItems[ITEM] - 1);
  1725. if (NextValue > BestValue && !(ITEM == WillKeepItem1Slot && playerItems[ITEM] - 1 == WillKeepItem1)) {
  1726. BestValue = NextValue;
  1727. WillKeepItem2 = playerItems[ITEM] - 1;
  1728. WillKeepItem2Slot = ITEM;
  1729. if (playerItemsN[ITEM] > 2 - WillKeepAmt1 && !prayerActive[10]) {
  1730. WillKeepAmt2 = 3 - WillKeepAmt1;
  1731. } else if (playerItemsN[ITEM] > 3 - WillKeepAmt1 && prayerActive[10]) {
  1732. WillKeepAmt2 = 4 - WillKeepAmt1;
  1733. } else {
  1734. WillKeepAmt2 = playerItemsN[ITEM];
  1735. }
  1736. }
  1737. }
  1738. }
  1739. for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
  1740. if (playerEquipment[EQUIP] > 0 && c.getItems().tradeable(playerEquipment[EQUIP])) {
  1741. NextValue = c.getShops().getItemShopValue(playerEquipment[EQUIP]);
  1742. if (NextValue > BestValue && !(EQUIP + 28 == WillKeepItem1Slot && playerEquipment[EQUIP] == WillKeepItem1)) {
  1743. BestValue = NextValue;
  1744. WillKeepItem2 = playerEquipment[EQUIP];
  1745. WillKeepItem2Slot = EQUIP + 28;
  1746. if (playerEquipmentN[EQUIP] > 2 - WillKeepAmt1 && !prayerActive[10]) {
  1747. WillKeepAmt2 = 3 - WillKeepAmt1;
  1748. } else if (playerEquipmentN[EQUIP] > 3 - WillKeepAmt1 && prayerActive[10]) {
  1749. WillKeepAmt2 = 4 - WillKeepAmt1;
  1750. } else {
  1751. WillKeepAmt2 = playerEquipmentN[EQUIP];
  1752. }
  1753. }
  1754. }
  1755. }
  1756. if (!isSkulled && ItemsContained > 2 && (WillKeepAmt1 + WillKeepAmt2 < 3 || prayerActive[10] && WillKeepAmt1 + WillKeepAmt2 < 4)) {
  1757. BestItem3(c, ItemsContained);
  1758. }
  1759. }
  1760.  
  1761. public void BestItem3(Client c, int ItemsContained) {
  1762. int BestValue = 0;
  1763. int NextValue = 0;
  1764. WillKeepItem3 = 0;
  1765. WillKeepItem3Slot = 0;
  1766. for (int ITEM = 0; ITEM < 28; ITEM++) {
  1767. if (playerItems[ITEM] > 0 && c.getItems().tradeable(playerItems[ITEM])) {
  1768. NextValue = c.getShops().getItemShopValue(playerItems[ITEM] - 1);
  1769. if (NextValue > BestValue && !(ITEM == WillKeepItem1Slot && playerItems[ITEM] - 1 == WillKeepItem1) && !(ITEM == WillKeepItem2Slot && playerItems[ITEM] - 1 == WillKeepItem2)) {
  1770. BestValue = NextValue;
  1771. WillKeepItem3 = playerItems[ITEM] - 1;
  1772. WillKeepItem3Slot = ITEM;
  1773. if (playerItemsN[ITEM] > 2 - (WillKeepAmt1 + WillKeepAmt2) && !prayerActive[10]) {
  1774. WillKeepAmt3 = 3 - (WillKeepAmt1 + WillKeepAmt2);
  1775. } else if (playerItemsN[ITEM] > 3 - (WillKeepAmt1 + WillKeepAmt2) && prayerActive[10]) {
  1776. WillKeepAmt3 = 4 - (WillKeepAmt1 + WillKeepAmt2);
  1777. } else {
  1778. WillKeepAmt3 = playerItemsN[ITEM];
  1779. }
  1780. }
  1781. }
  1782. }
  1783. for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
  1784. if (playerEquipment[EQUIP] > 0 && c.getItems().tradeable(playerEquipment[EQUIP])) {
  1785. NextValue = c.getShops().getItemShopValue(playerEquipment[EQUIP]);
  1786. if (NextValue > BestValue && !(EQUIP + 28 == WillKeepItem1Slot && playerEquipment[EQUIP] == WillKeepItem1) && !(EQUIP + 28 == WillKeepItem2Slot && playerEquipment[EQUIP] == WillKeepItem2)) {
  1787. BestValue = NextValue;
  1788. WillKeepItem3 = playerEquipment[EQUIP];
  1789. WillKeepItem3Slot = EQUIP + 28;
  1790. if (playerEquipmentN[EQUIP] > 2 - (WillKeepAmt1 + WillKeepAmt2) && !prayerActive[10]) {
  1791. WillKeepAmt3 = 3 - (WillKeepAmt1 + WillKeepAmt2);
  1792. } else if (playerEquipmentN[EQUIP] > 3 - WillKeepAmt1 && prayerActive[10]) {
  1793. WillKeepAmt3 = 4 - (WillKeepAmt1 + WillKeepAmt2);
  1794. } else {
  1795. WillKeepAmt3 = playerEquipmentN[EQUIP];
  1796. }
  1797. }
  1798. }
  1799. }
  1800. if (!isSkulled && ItemsContained > 3 && prayerActive[10] && WillKeepAmt1 + WillKeepAmt2 + WillKeepAmt3 < 4) {
  1801. BestItem4(c);
  1802. }
  1803. }
  1804.  
  1805. public void BestItem4(Client c) {
  1806. int BestValue = 0;
  1807. int NextValue = 0;
  1808. WillKeepItem4 = 0;
  1809. WillKeepItem4Slot = 0;
  1810. for (int ITEM = 0; ITEM < 28; ITEM++) {
  1811. if (playerItems[ITEM] > 0 && c.getItems().tradeable(playerItems[ITEM])) {
  1812. NextValue = c.getShops().getItemShopValue(playerItems[ITEM] - 1);
  1813. if (NextValue > BestValue && !(ITEM == WillKeepItem1Slot && playerItems[ITEM] - 1 == WillKeepItem1) && !(ITEM == WillKeepItem2Slot && playerItems[ITEM] - 1 == WillKeepItem2) && !(ITEM == WillKeepItem3Slot && playerItems[ITEM] - 1 == WillKeepItem3)) {
  1814. BestValue = NextValue;
  1815. WillKeepItem4 = playerItems[ITEM] - 1;
  1816. WillKeepItem4Slot = ITEM;
  1817. }
  1818. }
  1819. }
  1820. for (int EQUIP = 0; EQUIP < 14; EQUIP++) {
  1821. if (playerEquipment[EQUIP] > 0 && c.getItems().tradeable(playerEquipment[EQUIP])) {
  1822. NextValue = c.getShops().getItemShopValue(playerEquipment[EQUIP]);
  1823. if (NextValue > BestValue && !(EQUIP + 28 == WillKeepItem1Slot && playerEquipment[EQUIP] == WillKeepItem1) && !(EQUIP + 28 == WillKeepItem2Slot && playerEquipment[EQUIP] == WillKeepItem2) && !(EQUIP + 28 == WillKeepItem3Slot && playerEquipment[EQUIP] == WillKeepItem3)) {
  1824. BestValue = NextValue;
  1825. WillKeepItem4 = playerEquipment[EQUIP];
  1826. WillKeepItem4Slot = EQUIP + 28;
  1827. }
  1828. }
  1829. }
  1830. }
  1831.  
  1832. public boolean isRunning() {
  1833. if (stopPlayerPacket) {
  1834. return false;
  1835. }
  1836. return isNewWalkCmdIsRunning() || (runOption && isMoving);
  1837. }
  1838.  
  1839. public boolean frozen() {
  1840. return frozen > System.currentTimeMillis();
  1841. }
  1842.  
  1843. public boolean immuneToFreeze() {
  1844. return immuneToFreeze > System.currentTimeMillis();
  1845. }
  1846.  
  1847. public boolean antiFirePot() {
  1848. return antiFirePot > System.currentTimeMillis();
  1849. }
  1850.  
  1851. public void gameInterface(int id) {
  1852. if (gameInterface != id) {
  1853. gameInterface = id;
  1854. }
  1855. }
  1856.  
  1857. public void stopEvent(CycleEvent event) {
  1858. if (event != null) {
  1859. event.stop();
  1860. event = null;
  1861. }
  1862. }
  1863.  
  1864. public int getTask() {
  1865. if (skillTask + 1 > Integer.MAX_VALUE) {
  1866. skillTask = 0;
  1867. } else {
  1868. skillTask++;
  1869. }
  1870. return skillTask;
  1871. }
  1872.  
  1873. public boolean checkTask(int task) {
  1874. return task == skillTask;
  1875. }
  1876.  
  1877. public void stopSkilling() {
  1878. if (skilling != null) {
  1879. skilling.stop();
  1880. skilling = null;
  1881. }
  1882. }
  1883.  
  1884. public void setSkilling(CycleEvent event) {
  1885. this.skilling = event;
  1886. }
  1887.  
  1888. public CycleEvent getSkilling() {
  1889. return skilling;
  1890. }
  1891.  
  1892. }
Add Comment
Please, Sign In to add comment