Guest User

Untitled

a guest
Jan 21st, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 56.67 KB | None | 0 0
  1. package server.model.players;
  2. import java.util.ArrayList;
  3. import java.util.LinkedList;
  4. import java.util.List;
  5.  
  6. import server.Config;
  7. import server.World;
  8. import server.model.items.Item;
  9. import server.model.minigames.BarrowsData;
  10. import server.model.npcs.NPC;
  11. import server.model.players.combat.CombatConstants;
  12. import server.region.Region;
  13. import server.World;
  14. import server.tickable.Tickable;
  15. import server.tickable.impl.PoisonDrainTick;
  16. import server.util.ISAACRandomGen;
  17. import server.util.Misc;
  18. import server.util.Stream;
  19. import server.world.Location;
  20.  
  21. public abstract class Player {
  22. public int x1 = -1, y1 = -1, x2 = -1, y2 = -1, speed1 = -1, speed2 = -1, direction = -1;
  23. public boolean stopPlayerPacket;
  24. public boolean inSetMode = false;
  25. public int chosenSkill = -1;
  26. public int kills = 0, deaths = 0, killStreak = 0, maxKillStreak = 0;
  27. public int poisonDamage = 0;
  28. public int drainPoint;
  29. public int currentInterface = -1;
  30. public int travel;
  31. public int dfsDelay;
  32. public boolean playerStun = false, newPlayer = false;
  33. public boolean recentlyUsedSpec = false;
  34. public long lastDagChange = -1, lastRunRecovery;
  35. public int rfdRound;
  36. public boolean rfdSpawned = false;
  37. public boolean rfdOption = false;
  38. public boolean horrorOption = false;
  39. public boolean casketOption = false;
  40. public boolean solEffect;
  41. public double solDelay = 0;
  42. public int hitType;
  43. public int soak = 0;
  44. public String loginMessage = "";
  45. public int npcWave = 1;
  46. public boolean crit = false;
  47. public boolean hasBankPIN = false;
  48. public int hasDoneCaves = 0;
  49. public int duelTarget;
  50. public boolean fcFlag = false, dfsActive;
  51. public boolean hasBoosted = false;
  52. public boolean protectItem = false;
  53. public boolean demoteUser = false, promoteUser = false, kickUser = false;
  54. public String bankPin = "";
  55. public int attempts = 3;
  56. public int newDamage;
  57. public double absorbMagic, absorbMelee, absorbRanged;
  58. public double percentage;
  59. public boolean canUseKorasi = false;
  60. public boolean startingOut = false;
  61. public boolean setPin = false;
  62. public boolean inCyclops;
  63. public boolean spawned;
  64. public boolean hasOverloadBoost;
  65. public int hitOwner = 1;
  66. public boolean forceMovementUpdate;
  67. public long lastFire;
  68. public boolean teleporting = false;
  69. public int telePorting = 0;
  70. public int teleportDelay = -1;
  71. public int lsp = 0;
  72. public int teleToX = 0;
  73. public int teleToY = 0;
  74. public int newHeight = 0;
  75. public long nloadDelay;
  76. public int[][] playerSkillProp = new int[20][15];
  77. public boolean[] playerSkilling = new boolean[20];
  78. public boolean beserkerEffect = false;
  79. public double crossbowDamage;
  80. public int cannonTimer = 0;
  81. public boolean specGfx = false;
  82. public boolean multiAttacking, rangeEndGFXHeight, playerFletch, playerIsFletching, playerIsMining, playerIsFiremaking, playerIsFishing, playerIsCooking, playerIsWoodcutting;
  83. public boolean ignoreDefence, usingBow, usingArrows, usingOtherRangeWeapons, usingCross, magicDef, spellSwap, hasBankPin, recoverysSet;
  84. public int rangeEndGFX, boltDamage, teleotherType, playerTradeWealth, doAmount, woodcuttingTree, stageT, dfsCharge, recoilHits, playerDialogue;
  85. public ArrayList<String> lastKilledPlayers = new ArrayList<String>();
  86. public boolean TunnelEntrance = false;
  87. public int Arma, Zammy, Sara;
  88. public int Band;
  89. public boolean xpLock;
  90. public boolean kamfreenaDone;
  91. public int xamount;
  92. public int usedOnObjectID, usedOnobjectX, usedOnobjectY;
  93. public boolean
  94. stopPlayerSkill,
  95. herbloreI = false,
  96. secondHerb = false;
  97. public int
  98. herbAmount,
  99. doingHerb,
  100. newHerb,
  101. newXp,
  102. newItem;
  103.  
  104. /** Curse variables */
  105.  
  106. public int soulSplitDelay = 0,
  107. leechAttackDelay = 0,
  108. leechRangeDelay = 0,
  109. leechMagicDelay = 0,
  110. leechDefenceDelay = 0,
  111. leechStrengthDelay = 0,
  112. leechSpecialDelay = 0,
  113. leechAttackTimer = 0,
  114. leechRangeTimer = 0;
  115. public int atkCount = 0;
  116. public boolean turmoilBoolean, berserkerBoolean, soulsplitBoolean, protectSummon, protectMissiles, protectMelee, wrathBoolean, protectMage;
  117. public boolean specleech = false;
  118. public boolean attackleech = false;
  119. public boolean rangedleech = false;
  120. public boolean magicleech = false;
  121. public boolean defenceleech = false;
  122. public boolean strengthleech = false;
  123. public int WillKeepAmt1,WillKeepAmt2,WillKeepAmt3,WillKeepAmt4,WillKeepItem1,WillKeepItem2,WillKeepItem3,WillKeepItem4,WillKeepItem1Slot,WillKeepItem2Slot,WillKeepItem3Slot,WillKeepItem4Slot,EquipStatus;
  124.  
  125. public boolean isDoingSkillcapeAnim = false;
  126. public long lastCast = 0;
  127.  
  128. public ArrayList <String>killedPlayers = new ArrayList<String> ();
  129. public ArrayList <Integer>attackedPlayers = new ArrayList<Integer> ();
  130.  
  131. public int[] clawHit = new int[4];
  132. public boolean
  133. usingClaws,
  134. disableWalking = false,
  135. teleportFlag = false,
  136. pNpc = false,
  137. autoRetaliate = false,
  138. initialized = false,
  139. disconnected = false,
  140. ruleAgreeButton = false,
  141. RebuildNPCList = false,
  142. isActive = false,
  143. isKicked = false,
  144. isSkulled = false,
  145. friendUpdate = false,
  146. hasMultiSign = false,
  147. inAclan = false,
  148. saveCharacter = false,
  149. mouseButton = false,
  150. splitChat = false,
  151. chatEffects = true,
  152. acceptAid = false,
  153. nextDialogue = false,
  154. autocasting = false,
  155. usedSpecial = false,
  156. mageFollow = false,
  157. dbowSpec = false,
  158. craftingLeather = false,
  159. properLogout = false,
  160. secDbow = false,
  161. ssSpec = false,
  162. vengOn = false,
  163. addStarter = false,
  164. accountFlagged = false,
  165. msbSpec = false,
  166. newCmb = false,
  167. runOption,
  168. isBanking = false
  169. ;
  170. public boolean isDoingComp = false;
  171. public int playerTitle;
  172. public boolean isRunning() {
  173. if (stopPlayerPacket) {
  174. return false;
  175. }
  176. return isNewWalkCmdIsRunning() || (runOption && isMoving);
  177. }
  178. public boolean handcannon = false;
  179. public int
  180.  
  181. runEnergy = 100,
  182. barrageCount = 0,
  183. CSLS = 0,
  184. pNpcId = -1,
  185. recoil = 0,
  186. headIconHints,
  187. pure,
  188. saveDelay,
  189. altarPrayed = 0,
  190. playerKilled,
  191. pkPoints,
  192. wcLevelReq,
  193. totalPlayerDamageDealt,
  194. killedBy,
  195. lastChatId = 1,
  196. privateChat,
  197. friendSlot = 0,
  198. dialogueId,
  199. fishingLevelReq,
  200. processPackets = 0,
  201. newLocation,
  202. lastNpcAttacked = 0,
  203. specEffect,
  204. specBarId,
  205. processTimer,
  206. attackLevelReq,
  207. fletchingLevelReq,
  208. Donatorreq,
  209. defenceLevelReq,
  210. strengthLevelReq,
  211. rangeLevelReq,
  212. magicLevelReq,
  213. followId,
  214. skullTimer,
  215. nextChat = 0,
  216. talkingNpc = -1,
  217. dialogueAction = 0,
  218. autocastId,
  219. followDistance,
  220. followId2,
  221. pcPoints,
  222. isDonator = 0,
  223. desertTreasure = 0,
  224. lastArrowUsed = -1,
  225. clanId = -1,
  226. pcDamage = 0,
  227. xInterfaceId = 0,
  228. xRemoveId = 0,
  229. xRemoveSlot = 0,
  230. waveId,
  231. frozenBy = 0,
  232. teleAction = 0,
  233. bonusAttack = 0,
  234. newCombat = 0;
  235. public String currentTime, date;
  236. public String clanName, properName;
  237. public int[] itemKeptId = new int [4];
  238. public int[] pouches = new int[4];
  239. public boolean[] invSlot = new boolean[28], equipSlot = new boolean[14];
  240. public long friends[] = new long[200];
  241. public long lastButton;
  242. public double specDamage, specAccuracy, specAmount;
  243. public double prayerPoint = 1.0;
  244. public int teleGrabItem, teleGrabX, teleGrabY, duelCount, underAttackBy, underAttackBy2, wildLevel, respawnTimer, saveTimer = 0, teleBlockLength, poisonDelay;
  245. public long lastPlayerMove,lastPoison,lastPoisonSip,poisonImmune,lastSpear,lastProtItem, lastVeng,lastYell,teleGrabDelay, protMageDelay, protMeleeDelay, protRangeDelay, lastAction, lastThieve,lastLockPick,lastRunDrain, alchDelay, specDelay = System.currentTimeMillis(), duelDelay, teleBlockDelay, godSpellDelay, singleCombatDelay, singleCombatDelay2, reduceStat, restoreStatsDelay, logoutDelay, buryDelay, foodDelay, potDelay;
  246. public boolean canChangeAppearance = false;
  247. public boolean mageAllowed;
  248. public long SpecialDelay = 0;
  249. public byte poisonMask = 0;
  250.  
  251.  
  252. public boolean withinInteractionDistance(int x, int y, int z) {
  253. if (heightLevel != z)
  254. return false;
  255. Client c = (Client)this;
  256. int deltaX = x - c.getX(), deltaY = y - c.getY();
  257. return deltaX <= 4 && deltaX >= -4 && deltaY <= 4 && deltaY >= -4;
  258. }
  259.  
  260. public boolean isAutoButton(int button) {
  261. for (int j = 0; j < CombatConstants.autocastIds.length; j += 2) {
  262. if (CombatConstants.autocastIds[j] == button)
  263. return true;
  264. }
  265. return false;
  266. }
  267.  
  268. public boolean doingEmote() {
  269. return (this.animationRequest != -1);
  270. }
  271.  
  272. public boolean fullVerac() {
  273. return playerEquipment[playerHat] == 4753 && playerEquipment[playerLegs] == 4759 && playerEquipment[playerChest] == 4757 && playerEquipment[playerWeapon] == 4755;
  274. }
  275. //public String spellName = "Select Spell";
  276. public void assignAutocast(int button) {
  277. for (int j = 0; j < CombatConstants.autocastIds.length; j++) {
  278. if (CombatConstants.autocastIds[j] == button) {
  279. Client c = (Client) PlayerHandler.players[this.playerId];
  280. autocasting = true;
  281. autocastId = CombatConstants.autocastIds[j+1];
  282. c.getPA().sendFrame36(108, 1);
  283. c.setSidebarInterface(0, 328);
  284. c = null;
  285. break;
  286. }
  287. }
  288. }
  289.  
  290. public boolean[] killedBrother = new boolean[7];
  291. public boolean[] spawnedBrother = new boolean[7];
  292. public int barrowsKill;
  293. public int hiddenBrother;
  294. public boolean inBarrows() {
  295. return (absX >= BarrowsData.BARROW_CAVE[0] && absX <= BarrowsData.BARROW_CAVE[2] & absY >= BarrowsData.BARROW_CAVE[1] && absY <= BarrowsData.BARROW_CAVE[3]);
  296. }
  297.  
  298. public boolean fullVoidRange() {
  299. return playerEquipment[playerHat] == 11664 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
  300. }
  301.  
  302. public boolean fullVoidMage() {
  303. return playerEquipment[playerHat] == 11663 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
  304. }
  305.  
  306. public boolean fullVoidMelee() {
  307. return playerEquipment[playerHat] == 11665 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
  308. }
  309.  
  310. public int reduceSpellId;
  311. public long[] reduceSpellDelay = new long[6];
  312. public boolean[] canUseReducingSpell = {true, true, true, true, true, true};
  313.  
  314. public int slayerTask,taskAmount;
  315.  
  316. public int prayerId = -1;
  317. public int headIcon = -1;
  318. public int bountyIcon = 0;
  319. public long stopPrayerDelay, prayerDelay;
  320. public boolean usingPrayer;
  321.  
  322.  
  323.  
  324. 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};
  325.  
  326. /* Curse Prayers */
  327.  
  328. public boolean[] curseActive = {
  329. false,false,false,false,false,
  330. false,false,false,false,false,
  331. false,false,false,false,false,
  332. false,false,false,false,false
  333. };
  334. /*End of curse prayers*/
  335.  
  336. public int duelTimer, duelTeleX, duelTeleY, duelSlot, duelSpaceReq, duelOption, duelingWith, duelStatus;
  337. public int headIconPk = -1, headIconhint;
  338. public int headIconPray = 0;
  339. public boolean duelRequested;
  340. public boolean[] duelRule = new boolean[22];
  341.  
  342. public boolean doubleHit, usingSpecial, npcDroppingItems, usingRangeWeapon, usingMagic, castingMagic;
  343. public int specMaxHitIncrease, freezeDelay, freezeTimer = -6, killerId, playerIndex, oldPlayerIndex, lastWeaponUsed, projectileStage, crystalBowArrowCount, playerMagicBook, teleGfx, teleEndAnimation, teleHeight, teleX, teleY, rangeItemUsed, killingNpcIndex, totalDamageDealt, oldNpcIndex, fightMode, attackTimer, npcIndex,npcClickIndex, npcType, castingSpellId, oldSpellId, spellId, hitDelay;
  344. public boolean magicFailed, oldMagicFailed;
  345. public int bowSpecShot, clickNpcType, clickObjectType, objectId, objectX, objectY, objectXOffset, objectYOffset, objectDistance;
  346. public int pItemX, pItemY, pItemId;
  347. public boolean isMoving, walkingToItem;
  348. public boolean isShopping, updateShop;
  349. public int myShopId;
  350. public int tradeStatus, tradeWith;
  351. public boolean forcedChatUpdateRequired, inDuel, tradeAccepted, goodTrade, inTrade, tradeRequested, tradeResetNeeded, tradeConfirmed, tradeConfirmed2, canOffer, acceptTrade, acceptedTrade;
  352. public int attackAnim, animationRequest = -1,animationWaitCycles;
  353. public int[] playerBonus = new int[12];
  354. public boolean takeAsNote;
  355. public int combatLevel;
  356. public boolean saveFile = false;
  357. public int playerAppearance[] = new int[13];
  358. public int apset;
  359. public int actionID;
  360. public int wearItemTimer, wearId, wearSlot, interfaceId;
  361. public int XremoveSlot, XinterfaceID, XremoveID, Xamount;
  362.  
  363. public boolean usingGlory = false;
  364. public int smeltType; //1 = bronze, 2 = iron, 3 = steel, 4 = gold, 5 = mith, 6 = addy, 7 = rune
  365. public int smeltAmount;
  366. public int smeltTimer = 0;
  367. public boolean smeltInterface;
  368.  
  369.  
  370. public boolean antiFirePot = false;
  371.  
  372. /**
  373. * SouthWest, NorthEast, SouthWest, NorthEast
  374. */
  375.  
  376. public boolean inGWD() {
  377. if (absX > 2820 && absX < 2955 && absY > 5250 && absY < 5370) {
  378. return true;
  379. }
  380. return false;
  381. }
  382.  
  383. public boolean inArea(int x, int y, int x1, int y1) {
  384. if (absX > x && absX < x1 && absY < y && absY > y1) {
  385. return true;
  386. }
  387. return false;
  388. }
  389.  
  390. public boolean inDungeoneering() {
  391. return false;
  392. }
  393.  
  394. public boolean inPits() {
  395. return inArea(2370, 2430, 5122, 5168);
  396. }
  397.  
  398.  
  399. public boolean inWild() {
  400. if (absX > 2941 && absX < 3392 && absY > 3524 && absY < 3966 ||
  401. absX > 2941 && absX < 3392 && absY > 9918 && absY < 10366){
  402. return true;
  403. }
  404. return false;
  405. }
  406. public boolean isInEdge() {
  407. if(absX > 3084 && absX < 3111 && absY > 3483 && absY < 3509) {
  408. return true;
  409. }
  410. return false;
  411. }
  412.  
  413. public boolean inPitsWait() {
  414. return getX() >= 2393 && getX() <= 2405 && getY() >= 5169 && getY() <= 5175;
  415. }
  416.  
  417. public boolean safeZone() {
  418. if(absX > 2608 && absX < 2617 && absY > 3087 && absY < 3098 || absX > 2612 && absX < 2622 && absY > 3330 && absY < 3335 || absX > 2648 && absX < 2658 && absY > 3279 && absY < 3287) {
  419. return true;
  420. }
  421. return false;
  422. }
  423.  
  424.  
  425. public boolean arenas() {
  426. if(absX > 3331 && absX < 3391 && absY > 3242 && absY < 3260) {
  427. return true;
  428. }
  429. return false;
  430. }
  431.  
  432. public boolean inDuelArena() {
  433. if((absX > 3322 && absX < 3394 && absY > 3195 && absY < 3291) ||
  434. (absX > 3311 && absX < 3323 && absY > 3223 && absY < 3248)) {
  435. return true;
  436. }
  437. return false;
  438. }
  439.  
  440. public boolean inMulti() {
  441. if((absX >= 3136 && absX <= 3327 && absY >= 3519 && absY <= 3607) ||
  442. (absX >= 3210 && absX <= 3339 && absY >= 9333 && absY <= 9424) ||
  443. (absX >= 2607 && absX <= 2644 && absY >= 3296 && absY <= 3332) ||
  444. (absX >= 2949 && absX <= 3001 && absY >= 3370 && absY <= 3392) ||
  445. (absX >= 3250 && absX <= 3342 && absY >= 9800 && absY <= 9870) ||
  446. (absX >= 3190 && absX <= 3327 && absY >= 3648 && absY <= 3839) ||
  447. (absX >= 3200 && absX <= 3390 && absY >= 3840 && absY <= 3967) ||
  448. (absX >= 2992 && absX <= 3007 && absY >= 3912 && absY <= 3967) ||
  449. (absX >= 2946 && absX <= 2959 && absY >= 3816 && absY <= 3831) ||
  450. (absX >= 3008 && absX <= 3199 && absY >= 3856 && absY <= 3903) ||
  451. (absX >= 3008 && absX <= 3071 && absY >= 3600 && absY <= 3711) ||
  452. (absX >= 3072 && absX <= 3327 && absY >= 3608 && absY <= 3647) ||
  453. (absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <= 2619) ||
  454. (absX >= 2371 && absX <= 2422 && absY >= 5062 && absY <= 5117) ||
  455. (absX >= 2896 && absX <= 2927 && absY >= 3595 && absY <= 3630) ||
  456. (absX >= 2820 && absX <= 2955 && absY >= 5250 && absY <= 5370) ||
  457. (absX >= 2892 && absX <= 2932 && absY >= 4435 && absY <= 4464) ||
  458. (absX >= 3465 && absX <= 3508 && absY >= 9480 && absY <= 9518) ||
  459. (absX >= 3080 && absX <= 3140 && absY >= 9800 && absY <= 9860) ||
  460. (absX >= 2256 && absX <= 2287 && absY >= 4680 && absY <= 4711)) {
  461. return true;
  462. }
  463. return false;
  464. }
  465.  
  466.  
  467.  
  468. public boolean inFightCaves()
  469. {
  470. return (absX >= 2360 && absX <= 2445 && absY >= 5045 && absY <= 5125);
  471. }
  472.  
  473.  
  474. public String connectedFrom="";
  475. public String globalMessage="";
  476. public abstract void initialize();
  477. public abstract void update();
  478. public int playerId = -1;
  479. public String playerName = null;
  480. public String playerName2 = null;
  481. public String playerPass = null;
  482. public int playerRights;
  483. public int playerItems[] = new int[28];
  484. public int playerItemsN[] = new int[28];
  485. public int bankItems[] = new int[Config.BANK_SIZE];
  486. public int bankItemsN[] = new int[Config.BANK_SIZE];
  487. public boolean bankNotes = false;
  488.  
  489. public int playerStandIndex = 0x328;
  490. public int playerTurnIndex = 0x337;
  491. public int playerWalkIndex = 0x333;
  492. public int playerTurn180Index = 0x334;
  493. public int playerTurn90CWIndex = 0x335;
  494. public int playerTurn90CCWIndex = 0x336;
  495. public int playerRunIndex = 824;
  496.  
  497. public int playerHat=0;
  498. public int playerCape=1;
  499. public int playerAmulet=2;
  500. public int playerWeapon=3;
  501. public int playerChest=4;
  502. public int playerShield=5;
  503. public int playerLegs=7;
  504. public int playerHands=9;
  505. public int playerFeet=10;
  506. public int playerRing=12;
  507. public int playerArrows=13;
  508.  
  509. public int playerAttack = 0;
  510. public int playerDefence = 1;
  511. public int playerStrength = 2;
  512. public int playerHitpoints = 3;
  513. public int playerRanged = 4;
  514. public int playerPrayer = 5;
  515. public int playerMagic = 6;
  516. public int playerCooking = 7;
  517. public int playerWoodcutting = 8;
  518. public int playerFletching = 9;
  519. public int playerFishing = 10;
  520. public int playerFiremaking = 11;
  521. public int playerCrafting = 12;
  522. public int playerSmithing = 13;
  523. public int playerMining = 14;
  524. public int playerHerblore = 15;
  525. public int playerAgility = 16;
  526. public int playerThieving = 17;
  527. public int playerSlayer = 18;
  528. public int playerFarming = 19;
  529. public int playerRunecrafting = 20;
  530. public int playerHunter = 21;
  531.  
  532. public int[] playerEquipment = new int[14];
  533. public int[] playerEquipmentN = new int[14];
  534. public int[] playerLevel = new int[25];
  535. public int[] playerXP = new int[25];
  536.  
  537. public void updateshop(int i){
  538. Client p = (Client) PlayerHandler.players[playerId];
  539. p.getShops().resetShop(i);
  540. }
  541.  
  542. public void println_debug(String str) {
  543. System.out.println("[player-"+playerId+"]: "+str);
  544. }
  545. public void println(String str) {
  546. System.out.println("[player-"+playerId+"]: "+str);
  547. }
  548. public Player(int _playerId) {
  549. playerId = _playerId;
  550. playerRights = 0;
  551.  
  552. for (int i=0; i<playerItems.length; i++) {
  553. playerItems[i] = 0;
  554. }
  555. for (int i=0; i<playerItemsN.length; i++) {
  556. playerItemsN[i] = 0;
  557. }
  558.  
  559. for (int i=0; i<playerLevel.length; i++) {
  560. if (i == 3) {
  561. playerLevel[i] = 10;
  562. } else {
  563. playerLevel[i] = 1;
  564. }
  565. }
  566.  
  567. for (int i=0; i<playerXP.length; i++) {
  568. if (i == 3) {
  569. playerXP[i] = 1300;
  570. } else {
  571. playerXP[i] = 0;
  572. }
  573. }
  574. for (int i=0; i < Config.BANK_SIZE; i++) {
  575. bankItems[i] = 0;
  576. }
  577.  
  578. for (int i=0; i < Config.BANK_SIZE; i++) {
  579. bankItemsN[i] = 0;
  580. }
  581.  
  582. playerAppearance[0] = 0; // gender
  583. playerAppearance[1] = 7; // head
  584. playerAppearance[2] = 25;// Torso
  585. playerAppearance[3] = 29; // arms
  586. playerAppearance[4] = 35; // hands
  587. playerAppearance[5] = 39; // legs
  588. playerAppearance[6] = 44; // feet
  589. playerAppearance[7] = 14; // beard
  590. playerAppearance[8] = 7; // hair colour
  591. playerAppearance[9] = 8; // torso colour
  592. playerAppearance[10] = 9; // legs colour
  593. playerAppearance[11] = 5; // feet colour
  594. playerAppearance[12] = 0; // skin colour
  595.  
  596. apset = 0;
  597. actionID = 0;
  598.  
  599. playerEquipment[playerHat]=-1;
  600. playerEquipment[playerCape]=-1;
  601. playerEquipment[playerAmulet]=-1;
  602. playerEquipment[playerChest]=-1;
  603. playerEquipment[playerShield]=-1;
  604. playerEquipment[playerLegs]=-1;
  605. playerEquipment[playerHands]=-1;
  606. playerEquipment[playerFeet]=-1;
  607. playerEquipment[playerRing]=-1;
  608. playerEquipment[playerArrows]=-1;
  609. playerEquipment[playerWeapon]=-1;
  610.  
  611. heightLevel = 0;
  612.  
  613. teleportToX = Config.START_LOCATION_X;
  614. teleportToY = Config.START_LOCATION_Y;
  615.  
  616.  
  617. absX = absY = -1;
  618. mapRegionX = mapRegionY = -1;
  619. currentX = currentY = 0;
  620. resetWalkingQueue();
  621. }
  622.  
  623. public void destruct() {
  624. getLocalPlayers().clear();
  625. getLocalNPCs().clear();
  626. absX = absY = -1;
  627. mapRegionX = mapRegionY = -1;
  628. currentX = currentY = 0;
  629. resetWalkingQueue();
  630. }
  631.  
  632.  
  633.  
  634. public static final int maxPlayerListSize = 500;
  635. public Player playerList[] = new Player[maxPlayerListSize];
  636. public int playerListSize = 0;
  637.  
  638. public byte playerInListBitmap[] = new byte[(maxPlayerListSize+7) >> 3];
  639.  
  640. public static final int maxNPCListSize = 600;
  641. public NPC npcList[] = new NPC[maxNPCListSize];
  642. public int npcListSize = 0;
  643.  
  644. public byte npcInListBitmap[] = new byte[(maxNPCListSize+7) >> 3];
  645.  
  646. public boolean withinDistance(Player otherPlr) {
  647. if(heightLevel != otherPlr.heightLevel) return false;
  648. int deltaX = otherPlr.absX-absX, deltaY = otherPlr.absY-absY;
  649. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  650. }
  651.  
  652. public boolean withinDistance(NPC npc) {
  653. if (heightLevel != npc.heightLevel) return false;
  654. if (npc.needRespawn == true) return false;
  655. int deltaX = npc.absX-absX, deltaY = npc.absY-absY;
  656. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  657. }
  658.  
  659. public int distanceToPoint(int pointX,int pointY) {
  660. return (int) Math.sqrt(Math.pow(absX - pointX, 2) + Math.pow(absY - pointY, 2));
  661. }
  662.  
  663. public double toPoint(int pointX, int pointY) {
  664. int i1 = this.absX - pointX;
  665. int i2 = this.absY - pointY;
  666. return Math.sqrt(i1 * i1 + i2 * i2);
  667. }
  668.  
  669. public int calculateSpeed(int i1, int i2) {
  670. int i3 = (int) (Math.round(this.toPoint(i1, i2)));
  671. @SuppressWarnings("unused")
  672. Client c = (Client)this;
  673. //c.sendMessage("distance is" + i3);
  674. //c.sendMessage("my coords" + absX + "- " +absY);
  675. //c.sendMessage("his coords" + i1 + "- " + i2);
  676. for(int i = 1; i < 8; i++) {
  677. if(i3 <= i) {
  678. int i4 = (i + 5) * 10;
  679. //c.sendMessage("speed is" + i4);
  680. return i4;
  681. }
  682. }
  683. return 110;
  684. }
  685.  
  686. public int mapRegionX, mapRegionY;
  687. public int absX, absY;
  688. public int currentX, currentY;
  689.  
  690. public int heightLevel;
  691. public int playerSE = 0x328;
  692. public int playerSEW = 0x333;
  693. public int playerSER = 0x334;
  694.  
  695. public boolean updateRequired = true;
  696.  
  697.  
  698. public final int walkingQueueSize = 50;
  699. public int walkingQueueX[] = new int[walkingQueueSize], walkingQueueY[] = new int[walkingQueueSize];
  700. public int wQueueReadPtr = 0;
  701. public int wQueueWritePtr = 0;
  702. public int teleportToX = -1, teleportToY = -1;
  703.  
  704. public void resetWalkingQueue() {
  705. wQueueReadPtr = wQueueWritePtr = 0;
  706.  
  707. for(int i = 0; i < walkingQueueSize; i++) {
  708. walkingQueueX[i] = currentX;
  709. walkingQueueY[i] = currentY;
  710. }
  711. }
  712.  
  713. public void addToWalkingQueue(int x, int y) {
  714. //if (VirtualWorld.I(heightLevel, absX, absY, x, y, 0)) {
  715. int next = (wQueueWritePtr+1) % walkingQueueSize;
  716. if(next == wQueueWritePtr) return;
  717. walkingQueueX[wQueueWritePtr] = x;
  718. walkingQueueY[wQueueWritePtr] = y;
  719. wQueueWritePtr = next;
  720. //}
  721. }
  722.  
  723. public boolean goodDistance(int objectX, int objectY, int playerX, int playerY, int distance) {
  724. for (int i = 0; i <= distance; i++) {
  725. for (int j = 0; j <= distance; j++) {
  726. if ((objectX + i) == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  727. return true;
  728. } else if ((objectX - i) == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  729. return true;
  730. } else if (objectX == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  731. return true;
  732. }
  733. }
  734. }
  735. return false;
  736. }
  737.  
  738. public int getNextWalkingDirection() {
  739. if(wQueueReadPtr == wQueueWritePtr) return -1;
  740. int dir;
  741. do {
  742. dir = Misc.direction(currentX, currentY, walkingQueueX[wQueueReadPtr], walkingQueueY[wQueueReadPtr]);
  743. if(dir == -1) wQueueReadPtr = (wQueueReadPtr+1) % walkingQueueSize;
  744. else if((dir&1) != 0) {
  745. resetWalkingQueue();
  746. return -1;
  747. }
  748. } while((dir == -1) && (wQueueReadPtr != wQueueWritePtr));
  749. if(dir == -1) return -1;
  750. dir >>= 1;
  751. currentX += Misc.directionDeltaX[dir];
  752. currentY += Misc.directionDeltaY[dir];
  753. absX += Misc.directionDeltaX[dir];
  754. absY += Misc.directionDeltaY[dir];
  755. if (isRunning()) {
  756. Client c = (Client) this;
  757. if (runEnergy > 0) {
  758. if (System.currentTimeMillis() > c.getPA().getAgilityRunDrain() + lastRunDrain) {
  759. runEnergy--;
  760. lastRunDrain = System.currentTimeMillis();
  761. c.getPA().sendFrame126(runEnergy + "%", 149);
  762. }
  763. } else {
  764. runOption = false;
  765. c.getPA().sendFrame87(173, 0);
  766. }
  767. }
  768. return dir;
  769. }
  770.  
  771.  
  772. public boolean didTeleport = false;
  773. public boolean mapRegionDidChange = false;
  774. public int dir1 = -1, dir2 = -1;
  775. public boolean createItems = false;
  776. public int poimiX = 0, poimiY = 0;
  777.  
  778. public void getNextPlayerMovement() {
  779. mapRegionDidChange = false;
  780. didTeleport = false;
  781. dir1 = dir2 = -1;
  782.  
  783. if(teleportToX != -1 && teleportToY != -1) {
  784. mapRegionDidChange = true;
  785. if(mapRegionX != -1 && mapRegionY != -1) {
  786. int relX = teleportToX-mapRegionX*8, relY = teleportToY-mapRegionY*8;
  787. if(relX >= 2*8 && relX < 11*8 && relY >= 2*8 && relY < 11*8)
  788. mapRegionDidChange = false;
  789. }
  790. if(mapRegionDidChange) {
  791. mapRegionX = (teleportToX>>3)-6;
  792. mapRegionY = (teleportToY>>3)-6;
  793. }
  794. currentX = teleportToX - 8*mapRegionX;
  795. currentY = teleportToY - 8*mapRegionY;
  796. absX = teleportToX;
  797. absY = teleportToY;
  798. resetWalkingQueue();
  799.  
  800. teleportToX = teleportToY = -1;
  801. didTeleport = true;
  802. } else {
  803. dir1 = getNextWalkingDirection();
  804. if(dir1 == -1) {
  805. return;
  806. }
  807. if ((runOption || isNewWalkCmdIsRunning()) && runEnergy > 0) {
  808. dir2 = getNextWalkingDirection();
  809. }
  810. byte deltaX = 0;
  811. byte deltaY = 0;
  812. if(this.currentX < 16) {
  813. deltaX = 32;
  814. this.mapRegionX -= 4;
  815. this.mapRegionDidChange = true;
  816. } else if(this.currentX >= 88) {
  817. deltaX = -32;
  818. this.mapRegionX += 4;
  819. this.mapRegionDidChange = true;
  820. }
  821. if(this.currentY < 16) {
  822. deltaY = 32;
  823. this.mapRegionY -= 4;
  824. this.mapRegionDidChange = true;
  825. } else if(this.currentY >= 88) {
  826. deltaY = -32;
  827. this.mapRegionY += 4;
  828. this.mapRegionDidChange = true;
  829. }
  830.  
  831. if(this.mapRegionDidChange) {
  832. this.currentX += deltaX;
  833. this.currentY += deltaY;
  834. for(int i = 0; i < 50; ++i) {
  835. this.walkingQueueX[i] += deltaX;
  836. this.walkingQueueY[i] += deltaY;
  837. }
  838. setLocation(getLocation());
  839. }
  840.  
  841. }
  842. }
  843. public boolean isDonator() {
  844. return (isDonator > 0);
  845. }
  846.  
  847. private boolean isSuperDonator() {
  848. return (isDonator == 2);
  849. }
  850.  
  851.  
  852.  
  853. public void updateThisPlayerMovement(Stream str) {
  854. if(mapRegionDidChange) {
  855. str.createFrame(73);
  856. str.writeWordA(mapRegionX+6);
  857. str.writeWord(mapRegionY+6);
  858. }
  859.  
  860. if(didTeleport) {
  861. str.createFrameVarSizeWord(81);
  862. str.initBitAccess();
  863. str.writeBits(1, 1);
  864. str.writeBits(2, 3);
  865. str.writeBits(2, heightLevel);
  866. str.writeBits(1, 1);
  867. str.writeBits(1, (updateRequired) ? 1 : 0);
  868. str.writeBits(7, currentY);
  869. str.writeBits(7, currentX);
  870. return ;
  871. }
  872.  
  873.  
  874. if(dir1 == -1) {
  875. // don't have to update the character position, because we're just standing
  876. str.createFrameVarSizeWord(81);
  877. str.initBitAccess();
  878. isMoving = false;
  879. if(updateRequired) {
  880. // tell client there's an update block appended at the end
  881. str.writeBits(1, 1);
  882. str.writeBits(2, 0);
  883. } else {
  884. str.writeBits(1, 0);
  885. }
  886. if (DirectionCount < 50) {
  887. DirectionCount++;
  888. }
  889. } else {
  890. DirectionCount = 0;
  891. str.createFrameVarSizeWord(81);
  892. str.initBitAccess();
  893. str.writeBits(1, 1);
  894.  
  895. if(dir2 == -1) {
  896. isMoving = true;
  897. str.writeBits(2, 1);
  898. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  899. if(updateRequired) str.writeBits(1, 1);
  900. else str.writeBits(1, 0);
  901. }
  902. else {
  903. isMoving = true;
  904. str.writeBits(2, 2);
  905. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  906. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  907. if(updateRequired) str.writeBits(1, 1);
  908. else str.writeBits(1, 0);
  909. }
  910. }
  911. }
  912.  
  913.  
  914. public void updatePlayerMovement(Stream str) {
  915. if(dir1 == -1) {
  916. if(updateRequired || isChatTextUpdateRequired()) {
  917.  
  918. str.writeBits(1, 1);
  919. str.writeBits(2, 0);
  920. }
  921. else str.writeBits(1, 0);
  922. }
  923. else if(dir2 == -1) {
  924.  
  925. str.writeBits(1, 1);
  926. str.writeBits(2, 1);
  927. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  928. str.writeBits(1, (updateRequired || isChatTextUpdateRequired()) ? 1: 0);
  929. }
  930. else {
  931.  
  932. str.writeBits(1, 1);
  933. str.writeBits(2, 2);
  934. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  935. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  936. str.writeBits(1, (updateRequired || isChatTextUpdateRequired()) ? 1: 0);
  937. }
  938. }
  939.  
  940. public byte cachedPropertiesBitmap[] = new byte[(Config.MAX_PLAYERS+7) >> 3];
  941.  
  942. public void addNewNPC(NPC npc, Stream str, Stream updateBlock) { //synchronized(this) {
  943. if(npcListSize == 255) {
  944. return;
  945. }
  946. int id = npc.npcId;
  947. npcInListBitmap[id >> 3] |= 1 << (id&7);
  948. npcList[npcListSize++] = npc;
  949.  
  950. str.writeBits(14, id);
  951.  
  952. int z = npc.absY-absY;
  953. if(z < 0) z += 32;
  954. str.writeBits(5, z);
  955. z = npc.absX-absX;
  956. if(z < 0) z += 32;
  957. str.writeBits(5, z);
  958.  
  959. str.writeBits(1, 0);
  960. str.writeBits(16, npc.npcType); // Nicknames eller vanliga 14 - 12
  961.  
  962. boolean savedUpdateRequired = npc.updateRequired;
  963. npc.updateRequired = true;
  964. npc.appendNPCUpdateBlock(updateBlock);
  965. npc.updateRequired = savedUpdateRequired;
  966. str.writeBits(1, 1);
  967. }
  968.  
  969.  
  970. public void addNewPlayer(Player plr, Stream str, Stream updateBlock) {
  971. //synchronized(this) {
  972. if(playerListSize == 255) {
  973. return;
  974. }
  975. int id = plr.playerId;
  976. playerInListBitmap[id >> 3] |= 1 << (id&7);
  977. playerList[playerListSize++] = plr;
  978. str.writeBits(11, id);
  979. str.writeBits(1, 1);
  980. boolean savedFlag = plr.isAppearanceUpdateRequired();
  981. boolean savedUpdateRequired = plr.updateRequired;
  982. plr.setAppearanceUpdateRequired(true);
  983. plr.updateRequired = true;
  984. plr.appendPlayerUpdateBlock(updateBlock);
  985. plr.setAppearanceUpdateRequired(savedFlag);
  986. plr.updateRequired = savedUpdateRequired;
  987. str.writeBits(1, 1);
  988. int z = plr.absY-absY;
  989. if(z < 0) z += 32;
  990. str.writeBits(5, z);
  991. z = plr.absX-absX;
  992. if(z < 0) z += 32;
  993. str.writeBits(5, z);
  994. //}
  995. }
  996.  
  997. public int DirectionCount = 0;
  998. public boolean appearanceUpdateRequired = true;
  999. public int hitDiff2;
  1000. public int hitDiff = 0;
  1001. public boolean hitUpdateRequired2;
  1002. public boolean hitUpdateRequired = false;
  1003. public boolean isDead = false;
  1004. public boolean isDying = false;
  1005.  
  1006. protected static Stream playerProps;
  1007. static {
  1008. playerProps = new Stream(new byte[100]);
  1009. }
  1010. protected void appendPlayerAppearance(Stream str) {
  1011. playerProps.currentOffset = 0;
  1012.  
  1013. playerProps.writeByte(playerAppearance[0]);
  1014.  
  1015. playerProps.writeByte(headIcon);
  1016. playerProps.writeByte(headIconPk);
  1017.  
  1018. if(!pNpc) {
  1019. if (playerEquipment[playerHat] > 1) {
  1020. playerProps.writeWord(0x200 + playerEquipment[playerHat]);
  1021. } else {
  1022. playerProps.writeByte(0);
  1023. }
  1024.  
  1025. if (playerEquipment[playerCape] > 1) {
  1026. playerProps.writeWord(0x200 + playerEquipment[playerCape]);
  1027. } else {
  1028. playerProps.writeByte(0);
  1029. }
  1030.  
  1031. if (playerEquipment[playerAmulet] > 1) {
  1032. playerProps.writeWord(0x200 + playerEquipment[playerAmulet]);
  1033. } else {
  1034. playerProps.writeByte(0);
  1035. }
  1036.  
  1037. if (playerEquipment[playerWeapon] > 1) {
  1038. playerProps.writeWord(0x200 + playerEquipment[playerWeapon]);
  1039. } else {
  1040. playerProps.writeByte(0);
  1041. }
  1042.  
  1043. if (playerEquipment[playerChest] > 1) {
  1044. playerProps.writeWord(0x200 + playerEquipment[playerChest]);
  1045. } else {
  1046. playerProps.writeWord(0x100+playerAppearance[2]);
  1047. }
  1048.  
  1049. if (playerEquipment[playerShield] > 1) {
  1050. playerProps.writeWord(0x200 + playerEquipment[playerShield]);
  1051. } else {
  1052. playerProps.writeByte(0);
  1053. }
  1054.  
  1055. if (!Item.isFullBody(playerEquipment[playerChest])) {
  1056. playerProps.writeWord(0x100+playerAppearance[3]);
  1057. } else {
  1058. playerProps.writeByte(0);
  1059. }
  1060.  
  1061. if (playerEquipment[playerLegs] > 1) {
  1062. playerProps.writeWord(0x200 + playerEquipment[playerLegs]);
  1063. } else {
  1064. playerProps.writeWord(0x100+playerAppearance[5]);
  1065. }
  1066.  
  1067. if (!Item.isFullHelm(playerEquipment[playerHat]) && !Item.isFullMask(playerEquipment[playerHat]) && playerEquipment[playerHat] != 13362 && playerEquipment[playerHat] != 13350) {
  1068. playerProps.writeWord(0x100 + playerAppearance[1]);
  1069. } else {
  1070. playerProps.writeByte(0);
  1071. }
  1072.  
  1073. if (playerEquipment[playerHands] > 1) {
  1074. playerProps.writeWord(0x200 + playerEquipment[playerHands]);
  1075. } else {
  1076. playerProps.writeWord(0x100+playerAppearance[4]);
  1077. }
  1078.  
  1079. if (playerEquipment[playerFeet] > 1) {
  1080. playerProps.writeWord(0x200 + playerEquipment[playerFeet]);
  1081. } else {
  1082. playerProps.writeWord(0x100+playerAppearance[6]);
  1083. }
  1084.  
  1085. if (playerAppearance[0] != 1 && !Item.isFullMask(playerEquipment[playerHat]) && playerEquipment[playerHat] != 13362 && playerEquipment[playerHat] != 13350) {
  1086. playerProps.writeWord(0x100 + playerAppearance[7]);
  1087. } else {
  1088. playerProps.writeByte(0);
  1089. }
  1090. } else {
  1091. playerProps.writeWord(-1);
  1092. playerProps.writeWord(pNpc ? pNpcId : 2626);
  1093. }
  1094. playerProps.writeByte(playerAppearance[8]);
  1095. playerProps.writeByte(playerAppearance[9]);
  1096. playerProps.writeByte(playerAppearance[10]);
  1097. playerProps.writeByte(playerAppearance[11]);
  1098. playerProps.writeByte(playerAppearance[12]);
  1099. playerProps.writeWord(playerStandIndex); // standAnimIndex
  1100. playerProps.writeWord(playerTurnIndex); // standTurnAnimIndex
  1101. playerProps.writeWord(playerWalkIndex); // walkAnimIndex
  1102. playerProps.writeWord(playerTurn180Index); // turn180AnimIndex
  1103. playerProps.writeWord(playerTurn90CWIndex); // turn90CWAnimIndex
  1104. playerProps.writeWord(playerTurn90CCWIndex); // turn90CCWAnimIndex
  1105. playerProps.writeWord(playerRunIndex); // runAnimIndex
  1106.  
  1107. playerProps.writeQWord(Misc.playerNameToInt64(playerName));
  1108. combatLevel = calculateCombatLevel();
  1109. playerProps.writeByte(combatLevel);
  1110. playerProps.writeByte(playerTitle);
  1111. playerProps.writeByte(isDonator);
  1112. playerProps.writeWord(0);
  1113.  
  1114. str.writeByteC(playerProps.currentOffset);
  1115. str.writeBytes(playerProps.buffer, playerProps.currentOffset, 0);
  1116. }
  1117.  
  1118. public int calculateCombatLevel() {
  1119. int magic = (int) ((getLevelForXP(playerXP[6])) * 1.5);
  1120. int ranged = (int) ((getLevelForXP(playerXP[4])) * 1.5);
  1121. int melee = (int) ((double) (getLevelForXP(playerXP[0])) +
  1122. (double) (getLevelForXP(playerXP[2])));
  1123. int summoning = (int)(getLevelForXP(playerXP[22]) * 0.125);
  1124. int combatLevel = (int) (summoning + (getLevelForXP(playerXP[1]) * 0.25) +
  1125. (getLevelForXP(playerXP[5]) * 0.125));
  1126.  
  1127. if (ranged > melee) {
  1128. combatLevel += (int) ((getLevelForXP(playerXP[3]) * 0.25) +
  1129. (getLevelForXP(playerXP[4]) * 0.4875));
  1130. } else if (magic > melee) {
  1131. combatLevel += (int) ((getLevelForXP(playerXP[3]) * 0.25) +
  1132. (getLevelForXP(playerXP[6]) * 0.4875));
  1133. } else {
  1134. combatLevel += (int) ((getLevelForXP(playerXP[3]) * 0.25) +
  1135. (getLevelForXP(playerXP[0]) * 0.325) +
  1136. (getLevelForXP(playerXP[2]) * 0.325));
  1137. }
  1138. return combatLevel;
  1139. }
  1140. public int calculateMaxLifePoints() {
  1141. int lifePoints = getLevelForXP(playerXP[3]);//The normal hp
  1142. int torvaLegs = 13360;//Torva Legs id
  1143. int torvaBody = 13358;//Torva Body id
  1144. int torvaHelm = 13362;//Torva Helm id
  1145. int pernixLegs = 13352;//Pernix Chaps id
  1146. int pernixBody = 13354;//Pernix Body id
  1147. int pernixHelm = 13355;//Pernix Cowl id
  1148. int virtusLegs = 13346;//Virtus Robe bottom id
  1149. int virtusBody = 13348;//Virtus Robe top id
  1150. int virtusHelm = 13346;//Virtus Mask id
  1151. if (playerEquipment[playerLegs] == torvaLegs || playerEquipment[playerLegs] == pernixLegs || playerEquipment[playerLegs] == virtusLegs) {
  1152. lifePoints += 13;
  1153. }
  1154. if (playerEquipment[playerChest] == torvaBody || playerEquipment[playerChest] == pernixBody || playerEquipment[playerChest] == virtusBody) {
  1155. lifePoints += 20;
  1156. }
  1157. if (playerEquipment[playerHat] == torvaHelm || playerEquipment[playerHat] == pernixHelm || playerEquipment[playerHat] == virtusHelm) {
  1158. lifePoints += 7;
  1159. }
  1160. return lifePoints;
  1161. }
  1162. public int getLevelForXP(int exp) {
  1163. int points = 0;
  1164. int output = 0;
  1165.  
  1166. for (int lvl = 1; lvl <= 99; lvl++) {
  1167. points += Math.floor((double)lvl + 300.0 * Math.pow(2.0, (double)lvl / 7.0));
  1168. output = (int)Math.floor(points / 4);
  1169. if (output >= exp)
  1170. return lvl;
  1171. }
  1172. return 99;
  1173. }
  1174.  
  1175. private boolean chatTextUpdateRequired = false;
  1176. private byte chatText[] = new byte[4096];
  1177. private byte chatTextSize = 0;
  1178. private int chatTextColor = 0;
  1179. private int chatTextEffects = 0;
  1180.  
  1181. protected void appendPlayerChatText(Stream str) {
  1182. str.writeWordBigEndian(((getChatTextColor()&0xFF) << 8) + (getChatTextEffects()&0xFF));
  1183. str.writeByte(playerRights);
  1184. str.writeByteC(getChatTextSize());
  1185. str.writeBytes_reverse(getChatText(), getChatTextSize(), 0);
  1186. }
  1187.  
  1188. public void forcedChat(String text) {
  1189. forcedText = text;
  1190. forcedChatUpdateRequired = true;
  1191. updateRequired = true;
  1192. setAppearanceUpdateRequired(true);
  1193. }
  1194.  
  1195. public String forcedText = "null";
  1196. public void appendForcedChat(Stream str) {
  1197. str.writeString(forcedText);
  1198. }
  1199.  
  1200. /**
  1201. *Graphics
  1202. **/
  1203.  
  1204. public int mask100var1 = 0;
  1205. public int mask100var2 = 0;
  1206. protected boolean mask100update = false;
  1207.  
  1208. public void appendMask100Update(Stream str) {
  1209. str.writeWordBigEndian(mask100var1);
  1210. str.writeDWord(mask100var2);
  1211. }
  1212.  
  1213. public void gfx100(int gfx) {
  1214. mask100var1 = gfx;
  1215. mask100var2 = 6553600;
  1216. mask100update = true;
  1217. updateRequired = true;
  1218. }
  1219. public void gfx50(int gfx) {
  1220. mask100var1 = gfx;
  1221. mask100var2 = 65536 * 50;
  1222. mask100update = true;
  1223. updateRequired = true;
  1224. }
  1225. public void customGfx(int gfx, int height, int delay) {
  1226. mask100var1 = gfx;
  1227. mask100var2 = (65536*height)+delay;
  1228. mask100update = true;
  1229. updateRequired = true;
  1230. }
  1231. public void gfx0(int gfx) {
  1232. if(isDoingSkillcapeAnim)
  1233. return;
  1234. mask100var1 = gfx;
  1235. mask100var2 = 65536;
  1236. mask100update = true;
  1237. updateRequired = true;
  1238. }
  1239.  
  1240. public boolean wearing2h() {
  1241. Client c = (Client)this;
  1242. String s = c.getItems().getItemName(c.playerEquipment[c.playerWeapon]);
  1243. if (s.contains("2h"))
  1244. return true;
  1245. else if (s.contains("godsword"))
  1246. return true;
  1247. return false;
  1248. }
  1249.  
  1250. /**
  1251. *Animations
  1252. **/
  1253.  
  1254. public void startAnimation(int animId) {
  1255. animationRequest = animId;
  1256. animationWaitCycles = 0;
  1257. updateRequired = true;
  1258. }
  1259.  
  1260. public void startAnimation(int animId, int time) {
  1261. animationRequest = animId;
  1262. animationWaitCycles = time;
  1263. updateRequired = true;
  1264. }
  1265.  
  1266. public void appendAnimationRequest(Stream str) {
  1267. str.writeWordBigEndian((animationRequest== -1) ? 65535 : animationRequest);
  1268. str.writeByteC(animationWaitCycles);
  1269. }
  1270.  
  1271. /**
  1272. *Face Update
  1273. **/
  1274.  
  1275. protected boolean faceUpdateRequired = false;
  1276. public int face = -1;
  1277. public int FocusPointX = -1, FocusPointY = -1;
  1278.  
  1279. public void faceUpdate(int index) {
  1280. face = index;
  1281. faceUpdateRequired = true;
  1282. updateRequired = true;
  1283. }
  1284.  
  1285. public void appendFaceUpdate(Stream str) {
  1286. str.writeWordBigEndian(face);
  1287. }
  1288.  
  1289. public void turnPlayerTo(int pointX, int pointY){
  1290. FocusPointX = 2*pointX+1;
  1291. FocusPointY = 2*pointY+1;
  1292. updateRequired = true;
  1293. }
  1294.  
  1295. private void appendSetFocusDestination(Stream str) {
  1296. str.writeWordBigEndianA(FocusPointX);
  1297. str.writeWordBigEndian(FocusPointY);
  1298. }
  1299.  
  1300. /**
  1301. *Hit Update
  1302. **/
  1303.  
  1304. protected void appendHitUpdate(Stream str, int hitType, boolean isMax) {
  1305. str.writeByte(getHitDiff()); // What the perseon got 'hit' for
  1306. str.writeByteA((poisonMask == 1) ? 2 : (getHitDiff() > 0) ? 1 : 0);
  1307. if (playerLevel[3] <= 0) {
  1308. playerLevel[3] = 0;
  1309. isDead = true;
  1310. }
  1311. str.writeByte(hitType);
  1312. int hitMax = isMax ? 1 : 0;
  1313. str.writeByte(hitMax);
  1314. str.writeByte(soak);
  1315. str.writeByte(hitOwner);
  1316. str.writeByteC(playerLevel[3]); // Their current hp, for HP bar
  1317. str.writeByte(calculateMaxLifePoints()); // Their max hp, for HP bar
  1318. }
  1319.  
  1320.  
  1321. protected void appendHitUpdate2(Stream str, int hitType, boolean isMax) {
  1322. boolean isPoison = (poisonMask == 1);
  1323. str.writeByte(hitDiff2); // What the perseon got 'hit' for
  1324. str.writeByteA((isPoison) ? 2 : (getHitDiff() > 0) ? 1 : 0);
  1325. if (poisonMask == 2)
  1326. poisonMask = -1;
  1327. if (playerLevel[3] <= 0) {
  1328. playerLevel[3] = 0;
  1329. isDead = true;
  1330. }
  1331. str.writeByte(hitType);
  1332. int hitMax = isMax ? ((isPoison) ? 0 : 1 ) : 0;
  1333. str.writeByte(hitMax);
  1334. int hitSoak = 0;
  1335. str.writeByte((isPoison) ? 0 : hitSoak);
  1336. str.writeByte(hitOwner);
  1337. str.writeByte(playerLevel[3]); // Their current hp, for HP bar
  1338. str.writeByte(calculateMaxLifePoints()); // Their max hp, for HP bar
  1339. }
  1340.  
  1341.  
  1342. public void appendPlayerUpdateBlock(Stream str){
  1343. if(!updateRequired && !isChatTextUpdateRequired()) return; // nothing required
  1344. int updateMask = 0;
  1345. if (forceMovementUpdate) {
  1346. updateMask |= 0x400;
  1347. }
  1348. if(mask100update) {
  1349. updateMask |= 0x100;
  1350. }
  1351. if(animationRequest != -1) {
  1352. updateMask |= 8;
  1353. }
  1354. if(forcedChatUpdateRequired) {
  1355. updateMask |= 4;
  1356. }
  1357. if(isChatTextUpdateRequired()) {
  1358. updateMask |= 0x80;
  1359. }
  1360. if(isAppearanceUpdateRequired()) {
  1361. updateMask |= 0x10;
  1362. }
  1363. if(faceUpdateRequired) {
  1364. updateMask |= 1;
  1365. }
  1366. if(FocusPointX != -1) {
  1367. updateMask |= 2;
  1368. }
  1369. if (isHitUpdateRequired()) {
  1370. updateMask |= 0x20;
  1371. }
  1372.  
  1373. if(hitUpdateRequired2) {
  1374. updateMask |= 0x200;
  1375. }
  1376.  
  1377. if(updateMask >= 0x100) {
  1378. updateMask |= 0x40;
  1379. str.writeByte(updateMask & 0xFF);
  1380. str.writeByte(updateMask >> 8);
  1381. } else {
  1382. str.writeByte(updateMask);
  1383. }
  1384.  
  1385. // now writing the various update blocks itself - note that their order crucial
  1386. if (forceMovementUpdate) {
  1387. appendMask400Update(str);
  1388. }
  1389. if(mask100update) {
  1390. appendMask100Update(str);
  1391. }
  1392. if(animationRequest != -1) {
  1393. appendAnimationRequest(str);
  1394. }
  1395. if(forcedChatUpdateRequired) {
  1396. appendForcedChat(str);
  1397. }
  1398. if(isChatTextUpdateRequired()) {
  1399. appendPlayerChatText(str);
  1400. }
  1401. if(faceUpdateRequired) {
  1402. appendFaceUpdate(str);
  1403. }
  1404. if(isAppearanceUpdateRequired()) {
  1405. appendPlayerAppearance(str);
  1406. }
  1407. if(FocusPointX != -1) {
  1408. appendSetFocusDestination(str);
  1409. }
  1410. if(isHitUpdateRequired()) {
  1411. appendHitUpdate(str, this.hitType, this.crit);
  1412. }
  1413. if(hitUpdateRequired2) {
  1414. appendHitUpdate2(str, this.hitType, this.crit);
  1415. }
  1416. }
  1417.  
  1418. public void clearUpdateFlags() {
  1419. forceMovementUpdate = false;
  1420. updateRequired = false;
  1421. setChatTextUpdateRequired(false);
  1422. setAppearanceUpdateRequired(false);
  1423. setHitUpdateRequired(false);
  1424. hitUpdateRequired2 = false;
  1425. forcedChatUpdateRequired = false;
  1426. mask100update = false;
  1427. animationRequest = -1;
  1428. FocusPointX = -1;
  1429. FocusPointY = -1;
  1430. faceUpdateRequired = false;
  1431. face = 65535;
  1432. poisonMask = -1;
  1433. }
  1434.  
  1435. public void stopMovement() {
  1436. if(respawnTimer > 0 || isDead) {
  1437. return;
  1438. }
  1439. if(teleportToX <= 0 && teleportToY <= 0) {
  1440. teleportToX = absX;
  1441. teleportToY = absY;
  1442. }
  1443. newWalkCmdSteps = 0;
  1444. getNewWalkCmdX()[0] = getNewWalkCmdY()[0] = travelBackX[0] = travelBackY[0] = 0;
  1445. resetWalkingQueue();
  1446. getNextPlayerMovement();
  1447.  
  1448. }
  1449.  
  1450.  
  1451. private int newWalkCmdX[] = new int[walkingQueueSize];
  1452. private int newWalkCmdY[] = new int[walkingQueueSize];
  1453. public int newWalkCmdSteps = 0;
  1454. private boolean newWalkCmdIsRunning = false;
  1455. protected int travelBackX[] = new int[walkingQueueSize];
  1456. protected int travelBackY[] = new int[walkingQueueSize];
  1457. protected int numTravelBackSteps = 0;
  1458.  
  1459. public void preProcessing() {
  1460. newWalkCmdSteps = 0;
  1461. }
  1462.  
  1463. public abstract void process();
  1464. public abstract boolean processQueuedPackets();
  1465.  
  1466. public void postProcessing() {
  1467. if (newWalkCmdSteps > 0) {
  1468. int firstX = getNewWalkCmdX()[0], firstY = getNewWalkCmdY()[0];
  1469.  
  1470. int lastDir = 0;
  1471. boolean found = false;
  1472. numTravelBackSteps = 0;
  1473. int ptr = wQueueReadPtr;
  1474. int dir = Misc.direction(currentX, currentY, firstX, firstY);
  1475. if (dir != -1 && (dir & 1) != 0) {
  1476. do {
  1477. lastDir = dir;
  1478. if (--ptr < 0) {
  1479. ptr = walkingQueueSize - 1;
  1480. }
  1481. travelBackX[numTravelBackSteps] = walkingQueueX[ptr];
  1482. travelBackY[numTravelBackSteps++] = walkingQueueY[ptr];
  1483. dir = Misc.direction(walkingQueueX[ptr], walkingQueueY[ptr], firstX, firstY);
  1484. if (lastDir != dir) {
  1485. found = true;
  1486. break;
  1487. }
  1488.  
  1489. } while (ptr != wQueueWritePtr);
  1490. } else {
  1491. found = true;
  1492. }
  1493. if (!found) {
  1494. println_debug("Fatal: couldn't find connection vertex! Dropping packet.");
  1495. resetWalkingQueue();
  1496. stopMovement();
  1497. // disconnected = true;
  1498. } else {
  1499. wQueueWritePtr = wQueueReadPtr;
  1500.  
  1501. addToWalkingQueue(currentX, currentY);
  1502.  
  1503. if (dir != -1 && (dir & 1) != 0) {
  1504.  
  1505. for (int i = 0; i < numTravelBackSteps - 1; i++) {
  1506. addToWalkingQueue(travelBackX[i], travelBackY[i]);
  1507. }
  1508. int wayPointX2 = travelBackX[numTravelBackSteps - 1], wayPointY2 = travelBackY[numTravelBackSteps - 1];
  1509. int wayPointX1, wayPointY1;
  1510. if (numTravelBackSteps == 1) {
  1511. wayPointX1 = currentX;
  1512. wayPointY1 = currentY;
  1513. } else {
  1514. wayPointX1 = travelBackX[numTravelBackSteps - 2];
  1515. wayPointY1 = travelBackY[numTravelBackSteps - 2];
  1516. }
  1517.  
  1518. dir = Misc.direction(wayPointX1, wayPointY1, wayPointX2, wayPointY2);
  1519. if (dir == -1 || (dir & 1) != 0) {
  1520. println_debug("Fatal: The walking queue is corrupt! wp1=(" + wayPointX1 + ", " + wayPointY1 + "), " + "wp2=(" + wayPointX2 + ", " + wayPointY2 + ")");
  1521. } else {
  1522. dir >>= 1;
  1523. found = false;
  1524. int x = wayPointX1, y = wayPointY1;
  1525. while (x != wayPointX2 || y != wayPointY2) {
  1526. x += Misc.directionDeltaX[dir];
  1527. y += Misc.directionDeltaY[dir];
  1528. if ((Misc.direction(x, y, firstX, firstY) & 1) == 0) {
  1529. found = true;
  1530. break;
  1531. }
  1532. }
  1533. if (!found) {
  1534. println_debug("Fatal: Internal error: unable to determine connection vertex!" + " wp1=(" + wayPointX1 + ", " + wayPointY1 + "), wp2=(" + wayPointX2 + ", " + wayPointY2 + "), " + "first=(" + firstX + ", " + firstY + ")");
  1535. } else {
  1536. addToWalkingQueue(wayPointX1, wayPointY1);
  1537. }
  1538. }
  1539. } else {
  1540. for (int i = 0; i < numTravelBackSteps; i++) {
  1541. addToWalkingQueue(travelBackX[i], travelBackY[i]);
  1542. }
  1543. }
  1544.  
  1545. for (int i = 0; i < newWalkCmdSteps; i++) {
  1546. addToWalkingQueue(getNewWalkCmdX()[i], getNewWalkCmdY()[i]);
  1547. }
  1548.  
  1549. }
  1550. }
  1551. }
  1552.  
  1553. public int getMapRegionX() {
  1554. return mapRegionX;
  1555. }
  1556. public int getMapRegionY() {
  1557. return mapRegionY;
  1558. }
  1559.  
  1560. public int getX() {
  1561. return absX;
  1562. }
  1563.  
  1564. public int getY() {
  1565. return absY;
  1566. }
  1567.  
  1568. public int getId() {
  1569. return playerId;
  1570. }
  1571.  
  1572. public boolean inPcBoat() {
  1573. return absX >= 2660 && absX <= 2663 && absY >= 2638 && absY <= 2643;
  1574. }
  1575.  
  1576. public boolean inPcGame() {
  1577. return absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <= 2619;
  1578. }
  1579.  
  1580. public boolean inWG() {
  1581. return absX >= 2837 && absX <= 2847 && absY >= 3535 && absY <= 3543;
  1582. }
  1583.  
  1584. public void setHitDiff(int hitDiff) {
  1585. this.hitDiff = hitDiff;
  1586. }
  1587.  
  1588. public void setHitDiff2(int amount) {
  1589. this.hitDiff2 = amount;
  1590. }
  1591.  
  1592.  
  1593. public int getHitDiff() {
  1594. return hitDiff;
  1595. }
  1596.  
  1597. public int getHitDiff2() {
  1598. return hitDiff2;
  1599. }
  1600.  
  1601.  
  1602. public void setHitUpdateRequired(boolean hitUpdateRequired) {
  1603. this.hitUpdateRequired = hitUpdateRequired;
  1604. }
  1605.  
  1606. public void setHitUpdateRequired2(boolean hitUpdateRequired2) {
  1607. this.hitUpdateRequired2 = hitUpdateRequired2;
  1608. }
  1609.  
  1610.  
  1611. public boolean isHitUpdateRequired() {
  1612. return hitUpdateRequired;
  1613. }
  1614.  
  1615. public boolean getHitUpdateRequired() {
  1616. return hitUpdateRequired;
  1617. }
  1618.  
  1619. public boolean getHitUpdateRequired2() {
  1620. return hitUpdateRequired2;
  1621. }
  1622.  
  1623.  
  1624. public void setAppearanceUpdateRequired(boolean appearanceUpdateRequired) {
  1625. this.appearanceUpdateRequired = appearanceUpdateRequired;
  1626. }
  1627.  
  1628.  
  1629. public boolean isAppearanceUpdateRequired() {
  1630. return appearanceUpdateRequired;
  1631. }
  1632.  
  1633.  
  1634. public void setChatTextEffects(int chatTextEffects) {
  1635. this.chatTextEffects = chatTextEffects;
  1636. }
  1637.  
  1638.  
  1639. public int getChatTextEffects() {
  1640. return chatTextEffects;
  1641. }
  1642.  
  1643.  
  1644. public void setChatTextSize(byte chatTextSize) {
  1645. this.chatTextSize = chatTextSize;
  1646. }
  1647.  
  1648.  
  1649. public byte getChatTextSize() {
  1650. return chatTextSize;
  1651. }
  1652.  
  1653.  
  1654. public void setChatTextUpdateRequired(boolean chatTextUpdateRequired) {
  1655. this.chatTextUpdateRequired = chatTextUpdateRequired;
  1656. }
  1657.  
  1658.  
  1659. public boolean isChatTextUpdateRequired() {
  1660. return chatTextUpdateRequired;
  1661. }
  1662.  
  1663.  
  1664. public void setChatText(byte chatText[]) {
  1665. this.chatText = chatText;
  1666. }
  1667.  
  1668.  
  1669. public byte[] getChatText() {
  1670. return chatText;
  1671. }
  1672.  
  1673.  
  1674. public void setChatTextColor(int chatTextColor) {
  1675. this.chatTextColor = chatTextColor;
  1676. }
  1677.  
  1678.  
  1679. public int getChatTextColor() {
  1680. return chatTextColor;
  1681. }
  1682.  
  1683.  
  1684. public void setNewWalkCmdX(int newWalkCmdX[]) {
  1685. this.newWalkCmdX = newWalkCmdX;
  1686. }
  1687.  
  1688.  
  1689. public int[] getNewWalkCmdX() {
  1690. return newWalkCmdX;
  1691. }
  1692.  
  1693.  
  1694. public void setNewWalkCmdY(int newWalkCmdY[]) {
  1695. this.newWalkCmdY = newWalkCmdY;
  1696. }
  1697.  
  1698.  
  1699. public int[] getNewWalkCmdY() {
  1700. return newWalkCmdY;
  1701. }
  1702.  
  1703.  
  1704. public void setNewWalkCmdIsRunning(boolean newWalkCmdIsRunning) {
  1705. this.newWalkCmdIsRunning = newWalkCmdIsRunning;
  1706. }
  1707.  
  1708.  
  1709. public boolean isNewWalkCmdIsRunning() {
  1710. return newWalkCmdIsRunning;
  1711. }
  1712.  
  1713. @SuppressWarnings("unused")
  1714. private ISAACRandomGen inStreamDecryption = null, outStreamDecryption = null;
  1715.  
  1716. public void setInStreamDecryption(ISAACRandomGen inStreamDecryption) {
  1717. this.inStreamDecryption = inStreamDecryption;
  1718. }
  1719.  
  1720. public void setOutStreamDecryption(ISAACRandomGen outStreamDecryption) {
  1721. this.outStreamDecryption = outStreamDecryption;
  1722. }
  1723.  
  1724. public boolean samePlayer() {
  1725. for (int j = 0; j < PlayerHandler.players.length; j++) {
  1726. if (j == playerId)
  1727. continue;
  1728. if (PlayerHandler.players[j] != null) {
  1729. if (PlayerHandler.players[j].playerName.equalsIgnoreCase(playerName)) {
  1730. disconnected = true;
  1731. return true;
  1732. }
  1733. }
  1734. }
  1735. return false;
  1736. }
  1737.  
  1738. public void putInCombat(int attacker) {
  1739. underAttackBy = attacker;
  1740. logoutDelay = System.currentTimeMillis();
  1741. SpecialDelay = System.currentTimeMillis();
  1742. singleCombatDelay = System.currentTimeMillis();
  1743. }
  1744.  
  1745. public void dealDamage(int damage) {
  1746. if (!teleporting || teleportDelay == -1) {
  1747. playerLevel[3] -= damage;
  1748. Client c = (Client)this;
  1749. c.getPA().refreshSkill(3);
  1750. if (c.playerEquipment[c.playerAmulet] == 11090) {
  1751. if(c.duelRule[6]) { return; }
  1752. double hitpoints = c.getLevelForXP(c.playerXP[c.playerHitpoints]);
  1753. double amtToHeal = hitpoints / 10 * 3;
  1754. double correctHitpoints = hitpoints / 10 * 2;
  1755. if (c.playerLevel[3] <= correctHitpoints
  1756. && c.playerEquipment[c.playerAmulet] == 11090) {
  1757. c.getItems().removeItem(c.playerEquipment[c.playerAmulet],
  1758. c.playerAmulet);
  1759. c.getItems().deleteItem2(11090, 1);
  1760. c.playerLevel[3] += (int)amtToHeal;
  1761. c.updateRequired = true;
  1762. c.sendMessage("Your phoenix necklace heals you, but is destroyed in the process.");
  1763. }
  1764. }
  1765. } else {
  1766. if (hitUpdateRequired)
  1767. hitUpdateRequired = false;
  1768. if (hitUpdateRequired2)
  1769. hitUpdateRequired2 = false;
  1770. }
  1771.  
  1772. }
  1773. public void dealDamage(int damage, int hitType) {
  1774. if (!teleporting || teleportDelay == -1) {
  1775. playerLevel[3] -= damage;
  1776. Client c = (Client)this;
  1777. c.getPA().refreshSkill(3);
  1778. handleHitMask(damage, hitType, 1);
  1779. if (c.playerEquipment[c.playerAmulet] == 11090) {
  1780. if(c.duelRule[6]) { return; }
  1781. double hitpoints = c.getLevelForXP(c.playerXP[c.playerHitpoints]);
  1782. double amtToHeal = hitpoints / 10 * 3;
  1783. double correctHitpoints = hitpoints / 10 * 2;
  1784. if (c.playerLevel[3] <= correctHitpoints
  1785. && c.playerEquipment[c.playerAmulet] == 11090) {
  1786. c.getItems().removeItem(c.playerEquipment[c.playerAmulet],
  1787. c.playerAmulet);
  1788. c.getItems().deleteItem2(11090, 1);
  1789. c.playerLevel[3] += (int)amtToHeal;
  1790. c.updateRequired = true;
  1791. c.sendMessage("Your phoenix necklace heals you, but is destroyed in the process.");
  1792. }
  1793. }
  1794. } else {
  1795. if (hitUpdateRequired)
  1796. hitUpdateRequired = false;
  1797. if (hitUpdateRequired2)
  1798. hitUpdateRequired2 = false;
  1799. }
  1800.  
  1801. }
  1802.  
  1803. public int[] damageTaken = new int[Config.MAX_PLAYERS];
  1804.  
  1805. public void handleHitMask(int damage, int hitType, int hitOwner) {
  1806. if (!hitUpdateRequired) {
  1807. hitUpdateRequired = true;
  1808. hitDiff = damage;
  1809. } else if (!hitUpdateRequired2) {
  1810. hitUpdateRequired2 = true;
  1811. hitDiff2 = damage;
  1812. }
  1813. this.hitType = hitType;
  1814. this.hitOwner = hitOwner;
  1815. updateRequired = true;
  1816. }
  1817.  
  1818. public Location location = getLocation();
  1819.  
  1820. public Location getLocation() {
  1821. return Location.create(absX, absY, heightLevel);
  1822. }
  1823.  
  1824. private Location lastKnownRegion = this.getLocation();
  1825. private Region currentRegion = null;
  1826.  
  1827. /**
  1828. * Sets the last known map region.
  1829. * @param lastKnownRegion The last known map region.
  1830. */
  1831. public void setLastKnownRegion(Location lastKnownRegion) {
  1832. this.lastKnownRegion = lastKnownRegion;
  1833. }
  1834.  
  1835. /**
  1836. * Gets the last known map region.
  1837. * @return The last known map region.
  1838. */
  1839. public Location getLastKnownRegion() {
  1840. return lastKnownRegion;
  1841. }
  1842.  
  1843. public Region getRegion() {
  1844. return currentRegion;
  1845. }
  1846.  
  1847. /**
  1848. * Removes this entity from the specified region.
  1849. * @param region The region.
  1850. */
  1851. public abstract void removeFromRegion(Region region);
  1852.  
  1853. /**
  1854. * Adds this entity to the specified region.
  1855. * @param region The region.
  1856. */
  1857. public abstract void addToRegion(Region region);
  1858.  
  1859. /**
  1860. * Sets the current location.
  1861. * @param location The current location.
  1862. */
  1863. public void setLocation(Location location) {
  1864. this.location = location;
  1865. Region newRegion = World.getWorld().getRegionManager().getRegionByLocation(location);
  1866. if(newRegion != currentRegion) {
  1867. if(currentRegion != null) {
  1868. removeFromRegion(currentRegion);
  1869. }
  1870. currentRegion = newRegion;
  1871. addToRegion(currentRegion);
  1872. }
  1873. }
  1874.  
  1875. /**
  1876. * Gets the list of local npcs.
  1877. * @return The list of local npcs.
  1878. */
  1879. public List<NPC> getLocalNPCs() {
  1880. return localNpcs;
  1881. }
  1882.  
  1883. public List<Player> getLocalPlayers() {
  1884. return localPlayers;
  1885. }
  1886.  
  1887. /**
  1888. * The list of local npcs.
  1889. */
  1890. public List<NPC> localNpcs = new LinkedList<NPC>();
  1891.  
  1892. public List<Player> localPlayers = new LinkedList<Player>();
  1893.  
  1894. private Tickable walkToAction = null;
  1895.  
  1896. public void setWalkToAction(Tickable walkToAction) {
  1897. if(this.walkToAction != null) {
  1898. this.walkToAction.stop();
  1899. this.walkToAction = null;
  1900. }
  1901. if(walkToAction != null) {
  1902. this.walkToAction = walkToAction;
  1903. World.getWorld().submit(walkToAction);
  1904. }
  1905. }
  1906.  
  1907. public Tickable getWalkToAction() {
  1908. return walkToAction;
  1909. }
  1910.  
  1911. public PoisonDrainTick poisonDrainTick;
  1912.  
  1913. public PoisonDrainTick getPoisonDrainTick() {
  1914. return poisonDrainTick;
  1915. }
  1916.  
  1917. public void setPoisonDrainTick(PoisonDrainTick poisonDrainTick) {
  1918. this.poisonDrainTick = poisonDrainTick;
  1919. }
  1920.  
  1921. public int getPlayerLevel(int level) {
  1922. return getLevelForXP(playerXP[level]);
  1923. }
  1924.  
  1925. 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) {
  1926. final int endX = getX() + x;
  1927. final int endY = getY() + y;
  1928. this.x1 = currentX;
  1929. this.y1 = currentY;
  1930. this.x2 = currentX + x;
  1931. this.y2 = currentY + y;
  1932. this.speed1 = speed1;
  1933. this.speed2 = speed2;
  1934. this.direction = direction;
  1935. updateRequired = true;
  1936. forceMovementUpdate = true;
  1937. if (stopPacket) {
  1938. stopPlayerPacket = true;
  1939. }
  1940. final Client c = (Client) this;
  1941. World.getWorld().submit(new Tickable(time - 1) {
  1942. @Override
  1943. public void execute() {
  1944. if (endAnim > 0) {
  1945. c.startAnimation(endAnim);
  1946. }
  1947. this.stop();
  1948. }
  1949. });
  1950. World.getWorld().submit(new Tickable(time) {
  1951. @Override
  1952. public void execute() {
  1953. updateRequired = true;
  1954. forceMovementUpdate = false;
  1955. if (stopPacket) {
  1956. stopPlayerPacket = false;
  1957. }
  1958. c.getPA().movePlayer(endX, endY, height);
  1959. c.getCombat().getPlayerAnimIndex(c.getItems().getItemName(c.playerEquipment[c.playerWeapon]).toLowerCase());
  1960. this.stop();
  1961. }
  1962. });
  1963. }
  1964.  
  1965. public void appendMask400Update(Stream str) {
  1966. str.writeByteS(x1);
  1967. str.writeByteS(y1);
  1968. str.writeByteS(x2);
  1969. str.writeByteS(y2);
  1970. str.writeWordBigEndianA(speed1);
  1971. str.writeWordA(speed2);
  1972. str.writeByteS(direction);
  1973. }
  1974.  
  1975.  
  1976. }
Add Comment
Please, Sign In to add comment