Advertisement
Guest User

player.java

a guest
Apr 6th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.21 KB | None | 0 0
  1. package server.rs2.entity.player;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import server.Config;
  6. import server.engine.util.ISAACRandomGen;
  7. import server.engine.util.Misc;
  8. import server.engine.util.Stream;
  9. import server.rs2.content.minigames.BountyHunter;
  10. import server.rs2.entity.npc.NPC;
  11. import server.rs2.entity.npc.NPCHandler;
  12. import server.engine.packet.Highscores;
  13. import server.engine.packet.HighscoresConfig;
  14. import server.rs2.items.Item;
  15. import server.rs2.items.ItemAssistant;
  16.  
  17. public abstract class Player {
  18.  
  19. public ArrayList<String> lastKilledPlayers = new ArrayList<String>();
  20. public ArrayList <String>killedPlayers = new ArrayList<String> ();
  21. public ArrayList <Integer>attackedPlayers = new ArrayList<Integer> ();
  22. public String clanPass = null;
  23. public int specRestoreTimer = 0;
  24. public String savedClan = "";
  25. public int playerTitle;
  26. public int cStreak;
  27. public int hStreak;
  28. public int entitled;
  29. public boolean buyingX;
  30. public int totalLevel, xpTotal;
  31. /* Dicing */
  32. public boolean clanDice = false;
  33. public long diceDelay;
  34. public int diceID = 15084;
  35. public int cDice = 0;
  36. /*Dominion Tower*/
  37. public int dominionToKill = 0;
  38. public int dominionKilled = 0;
  39. public int overloadcounter = 0;
  40. public int DTPoints = 0;
  41. /*Bounty Hunter*/
  42. public String targetName;
  43. public int playerTarget,pickupPenalty,cantLeavePenalty,enterTime;
  44.  
  45. public boolean
  46. isHaxing = false,
  47. initialized = false,
  48. entitledMoney = false,
  49. disconnected = false,
  50. ruleAgreeButton = false,
  51. RebuildNPCList = false,
  52. isActive = false,
  53. isKicked = false,
  54. isSkulled = false,
  55. friendUpdate = false,
  56. newPlayer = false,
  57. hasMultiSign = false,
  58. saveCharacter = false,
  59. mouseButton = false,
  60. splitChat = false,
  61. chatEffects = true,
  62. acceptAid = false,
  63. nextDialogue = false,
  64. autocasting = false,
  65. usedSpecial = false,
  66. mageFollow = false,
  67. dbowSpec = false,
  68. craftingLeather = false,
  69. properLogout = false,
  70. secDbow = false,
  71. maxNextHit = false,
  72. ssSpec = false,
  73. vengOn = false,
  74. addStarter = false,
  75. accountFlagged = false,
  76. msbSpec = false;
  77. public int prayerBook = 0;
  78. public int coinPouch = 0;
  79. public long lastButton;
  80.  
  81. public NPC summoned, ssTargetNPC, leechTargetNPC;
  82. public Client ssTarget, leechTarget;
  83. public int ssDelay = -1, ssHeal = 0, soulSplitDamage = 0, leechEndGFX = 0;
  84. public int clawDelay, clawTarg, clawTargNPC, hit1, hit2, hit3, hit4 = -1;
  85.  
  86. public final int[] CURSE_GLOW = {
  87. 610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629
  88. };
  89.  
  90. public double attackLeechBonus, rangedLeechBonus, magicLeechBonus, defenceLeechBonus, strengthLeechBonus = 1.0;
  91. public double attackLeechDefence, rangedLeechDefence, magicLeechDefence, defenceLeechDefence, strengthLeechDefence = 1.0;
  92. public int leechDelay = 0;
  93. public int leechType;
  94. public String[] leechTypes = {"Attack", "Ranged", "Magic", "Defence", "Strength", "energy", "special attack"};
  95.  
  96. public final int ACCURATE = 0, RAPID = 1 , AGGRESSIVE = 1, LONGRANGE = 2, BLOCK = 2, DEFENSIVE = 2, CONTROLLED = 3;
  97.  
  98. public boolean combatType(int type) {
  99. return fightMode == type;
  100. }
  101.  
  102. public int[] bobItems = new int[30];
  103. public boolean usingBoB;
  104.  
  105. /* Pk points and
  106. other related variables */
  107. public int pkp, kill, death;
  108. public String lastKilled;
  109.  
  110. /*Skills*/
  111. public int[][] playerSkillProp = new int[20][15];
  112. public boolean stopPlayerSkill;
  113. public long lastFire;
  114. public int woodcuttingTree, doAmount;
  115. public boolean playerIsFiremaking, playerIsWoodcutting;
  116.  
  117. /*Donator Stuff*/
  118. public boolean rigour = false, augury = false, isDonator = false;
  119. public int donatorPoints;
  120.  
  121. public int
  122. saveDelay,
  123. playerKilled,
  124. pkPoints,
  125. totalPlayerDamageDealt,
  126. killedBy,
  127. lastChatId = 1,
  128. privateChat,
  129. friendSlot = 0,
  130. dialogueId,
  131. randomCoffin,
  132. newLocation,
  133. specEffect,
  134. specBarId,
  135. attackLevelReq,
  136. defenceLevelReq,
  137. strengthLevelReq,
  138. rangeLevelReq,
  139. magicLevelReq,
  140. prayerLevelReq,
  141. followId,
  142. skullTimer,
  143. votingPoints,
  144. nextChat = 0,
  145. talkingNpc = -1,
  146. dialogueAction = 0,
  147. autocastId,
  148. followDistance,
  149. followId2,
  150. barrageCount = 0,
  151. delayedDamage = 0,
  152. delayedDamage2 = 0,
  153. pcPoints = 0,
  154. magePoints = 0,
  155. desertTreasure = 0,
  156. lastArrowUsed = -1,
  157. clanId = -1,
  158. autoRet = 0,
  159. pcDamage = 0,
  160. xInterfaceId = 0,
  161. xRemoveId = 0,
  162. xRemoveSlot = 0,
  163. tzhaarToKill = 0,
  164. tzhaarKilled = 0,
  165. waveId,
  166. frozenBy = 0,
  167. poisonDamage = 0,
  168. teleAction = 0,
  169. magicAltar = 0,
  170. bonusAttack = 0,
  171. lastNpcAttacked = 0,
  172. killCount = 0,
  173. destroyItem = 0,
  174. barbsToKill = 0,
  175. barbsKilled = 0,
  176. barbWave = 0,
  177. npcId2 = 0,
  178. foodCombo = 0,
  179. barbDamage = 0,
  180. barbLeader = 0,
  181. barbPoints = 0,
  182. KC,
  183. DC,
  184. pTime,
  185. safeTimer = 0;
  186. public boolean inBarbDef = false;
  187. public String clanName, properName = "", donorTag = "Default tag";
  188. public boolean orb;
  189. public int[] voidStatus = new int[5];
  190. public int[] itemKeptId = new int [4];
  191. public int[] pouches = new int[4];
  192. public final int[] POUCH_SIZE = {3,6,9,12};
  193. public boolean[] invSlot = new boolean[28], equipSlot = new boolean[14];
  194. public long friends[] = new long[200];
  195. public double specAmount = 0;
  196. public double specAccuracy = 1;
  197. public double specDamage = 1;
  198. public double prayerPoint = 1.0;
  199. public int teleGrabItem, teleGrabX, teleGrabY, duelCount, underAttackBy, underAttackBy2, wildLevel, teleTimer, respawnTimer = 0, teleBlockLength, poisonDelay;
  200. public long lastPlayerMove,lastPoison,lastPoisonSip,poisonImmune,lastSpear,lastProtItem, dfsDelay, lastVeng,lastYell,teleGrabDelay, protMageDelay, protMeleeDelay, protRangeDelay, lastAction, lastThieve,lastLockPick, alchDelay, specDelay = System.currentTimeMillis(), duelDelay, teleBlockDelay, godSpellDelay, singleCombatDelay, singleCombatDelay2, reduceStat, restoreStatsDelay, logoutDelay, buryDelay, foodDelay, potDelay, restoreDelay;
  201. public long restoreStatsDelay2 = 6000;
  202. public boolean canChangeAppearance = false;
  203. public boolean mageAllowed;
  204. public byte poisonMask = 0;
  205.  
  206. public static final int[] BOWS = {9185,18357,15241839,845,847,851,855,859,841,843,849,853,857,861,4212,4214,4215,11235,4216,4217,4218,4219,4220,4221,4222,4223,6724,4734,4934,4935,4936,4937};
  207. public static final int[] ARROWS = {882,884,886,888,890,892,4740,11212,9140,9141,4142,9143,9144,9240,9241,9242,9243,9244,9245,15243};
  208. public static final int[] NO_ARROW_DROP = {4212,4214,4215,4216,4217,4218,4219,4220,4221,4222,4223,4734,4934,4935,4936,4937};
  209. public static final int[] OTHER_RANGE_WEAPONS = {863,864,865,866,867,868,869,806,807,808,809,810,811,825,826,827,828,829,830,800,801,802,803,804,805,6522};
  210.  
  211. public static final int[][] MAGIC_SPELLS = {
  212. // example {magicId, level req, animation, startGFX, projectile Id, endGFX, maxhit, exp gained, rune 1, rune 1 amount, rune 2, rune 2 amount, rune 3, rune 3 amount, rune 4, rune 4 amount}
  213.  
  214. // Modern Spells
  215. {1152,1,711,90,91,92,2,5,556,1,558,1,0,0,0,0}, //wind strike
  216. {1154,5,711,93,94,95,4,7,555,1,556,1,558,1,0,0}, // water strike
  217. {1156,9,711,96,97,98,6,9,557,2,556,1,558,1,0,0},// earth strike
  218. {1158,13,711,99,100,101,8,11,554,3,556,2,558,1,0,0}, // fire strike
  219. {1160,17,711,117,118,119,9,13,556,2,562,1,0,0,0,0}, // wind bolt
  220. {1163,23,711,120,121,122,10,16,556,2,555,2,562,1,0,0}, // water bolt
  221. {1166,29,711,123,124,125,11,20,556,2,557,3,562,1,0,0}, // earth bolt
  222. {1169,35,711,126,127,128,12,22,556,3,554,4,562,1,0,0}, // fire bolt
  223. {1172,41,711,132,133,134,13,25,556,3,560,1,0,0,0,0}, // wind blast
  224. {1175,47,711,135,136,137,14,28,556,3,555,3,560,1,0,0}, // water blast
  225. {1177,53,711,138,139,140,15,31,556,3,557,4,560,1,0,0}, // earth blast
  226. {1181,59,711,129,130,131,16,35,556,4,554,5,560,1,0,0}, // fire blast
  227. {1183,62,711,158,159,160,17,36,556,5,565,1,0,0,0,0}, // wind wave
  228. {1185,65,711,161,162,163,18,37,556,5,555,7,565,1,0,0}, // water wave
  229. {1188,70,711,164,165,166,19,40,556,5,557,7,565,1,0,0}, // earth wave
  230. {1189,75,711,155,156,157,20,42,556,5,554,7,565,1,0,0}, // fire wave
  231. {1153,3,716,102,103,104,0,13,555,3,557,2,559,1,0,0}, // confuse
  232. {1157,11,716,105,106,107,0,20,555,3,557,2,559,1,0,0}, // weaken
  233. {1161,19,716,108,109,110,0,29,555,2,557,3,559,1,0,0}, // curse
  234. {1542,66,729,167,168,169,0,76,557,5,555,5,566,1,0,0}, // vulnerability
  235. {1543,73,729,170,171,172,0,83,557,8,555,8,566,1,0,0}, // enfeeble
  236. {1562,80,729,173,174,107,0,90,557,12,555,12,556,1,0,0}, // stun
  237. {1572,20,711,177,178,181,0,30,557,3,555,3,561,2,0,0}, // bind
  238. {1582,50,711,177,178,180,2,60,557,4,555,4,561,3,0,0}, // snare
  239. {1592,79,711,177,178,179,4,90,557,5,555,5,561,4,0,0}, // entangle
  240. {1171,39,724,145,146,147,15,25,556,2,557,2,562,1,0,0}, // crumble undead
  241. {1539,50,708,87,88,89,25,42,554,5,560,1,0,0,0,0}, // iban blast
  242. {12037,50,1576,327,328,329,19,30,560,1,558,4,0,0,0,0}, // magic dart
  243. {1190,60,811,0,0,76,20,60,554,2,565,2,556,4,0,0}, // sara strike
  244. {1191,60,811,0,0,77,20,60,554,1,565,2,556,4,0,0}, // cause of guthix
  245. {1192,60,811,0,0,78,20,60,554,4,565,2,556,1,0,0}, // flames of zammy
  246. {12445,85,1819,1841,1842,1843,0,65,563,1,562,1,560,1,0,0}, // teleblock
  247.  
  248. // Ancient Spells
  249. {12939,50,1978,0,384,385,13,30,560,2,562,2,554,1,556,1}, // smoke rush
  250. {12987,52,1978,0,378,379,14,31,560,2,562,2,566,1,556,1}, // shadow rush
  251. {12901,56,1978,0,0,373,15,33,560,2,562,2,565,1,0,0}, // blood rush
  252. {12861,58,1978,0,360,361,16,34,560,2,562,2,555,2,0,0}, // ice rush
  253. {12963,62,1979,0,0,389,19,36,560,2,562,4,556,2,554,2}, // smoke burst
  254. {13011,64,1979,0,0,382,20,37,560,2,562,4,556,2,566,2}, // shadow burst
  255. {12919,68,1979,0,0,376,21,39,560,2,562,4,565,2,0,0}, // blood burst
  256. {12881,70,1979,0,0,363,22,40,560,2,562,4,555,4,0,0}, // ice burst
  257. {12951,74,1978,0,386,387,23,42,560,2,554,2,565,2,556,2}, // smoke blitz
  258. {12999,76,1978,0,380,381,24,43,560,2,565,2,556,2,566,2}, // shadow blitz
  259. {12911,80,1978,0,374,375,25,45,560,2,565,4,0,0,0,0}, // blood blitz
  260. {12871,82,1978,366,0,367,26,46,560,2,565,2,555,3,0,0}, // ice blitz
  261. {12975,86,1979,0,0,391,27,48,560,4,565,2,556,4,554,4}, // smoke barrage
  262. {13023,88,1979,0,0,383,28,49,560,4,565,2,556,4,566,3}, // shadow barrage
  263. {12929,92,1979,0,0,377,29,51,560,4,565,4,566,1,0,0}, // blood barrage
  264. {12891,94,1979,0,0,369,30,52,560,4,565,2,555,6,0,0}, // ice barrage
  265.  
  266. {-1,80,811,301,0,0,0,0,554,3,565,3,556,3,0,0}, // charge
  267. {-1,21,712,112,0,0,0,10,554,3,561,1,0,0,0,0}, // low alch
  268. {-1,55,713,113,0,0,0,20,554,5,561,1,0,0,0,0}, // high alch
  269. {-1,33,728,142,143,144,0,35,556,1,563,1,0,0,0,0} // telegrab
  270.  
  271. };
  272.  
  273. public boolean isAutoButton(int button) {
  274. for (int j = 0; j < autocastIds.length; j += 2) {
  275. if (autocastIds[j] == button)
  276. return true;
  277. }
  278. return false;
  279. }
  280.  
  281. public long joinTime = -1;
  282. public boolean newPlayer()
  283. {
  284. if (joinTime == -1)
  285. return false;
  286. else
  287. return (System.currentTimeMillis() - joinTime <= 900000);//15 minutes
  288. }
  289. public String getTimeLeftForNP()
  290. {
  291. long millis = System.currentTimeMillis() - joinTime;
  292. int minutes = (int) ((millis/ 1000) / 60);
  293. return ""+(15-minutes)+" minutes left before you can offer items in trade, drop, and lose items on death.";
  294. }
  295.  
  296. public int getLocalX() {
  297. return getX() - 8 * getMapRegionX();
  298. }
  299.  
  300. public int getLocalY() {
  301. return getY() - 8 * getMapRegionY();
  302. }
  303.  
  304. public int[] autocastIds = {51133,32,51185,33,51091,34,24018,35,51159,36,51211,37,51111,38,51069,39,51146,40,51198,41,51102,42,51058,43,51172,44,51224,45,51122,46,51080,47,
  305. 7038,0,7039,1,7040,2,7041,3,7042,4,7043,5,7044,6,7045,7,7046,8,7047,9,7048,10,7049,11,7050,12,7051,13,7052,14,7053,15,
  306. 47019,27,47020,25,47021,12,47022,13,47023,14,47024,15};
  307.  
  308. public void assignAutocast(int button) {
  309. for (int j = 0; j < autocastIds.length; j++) {
  310. if (autocastIds[j] == button) {
  311. Client c = (Client) PlayerHandler.players[this.playerId];
  312. autocasting = true;
  313. autocastId = autocastIds[j+1];
  314. c.getPA().sendFrame36(108, 1);
  315. c.setSidebarInterface(0, 328);
  316. c = null;
  317. break;
  318. }
  319. }
  320. }
  321.  
  322. public String getSpellName(int id) {
  323. switch (id) {
  324. case 0: return "Air Strike";
  325. case 1: return "Water Strike";
  326. case 2: return "Earth Strike";
  327. case 3: return "Fire Strike";
  328. case 4: return "Air Bolt";
  329. case 5: return "Water Bolt";
  330. case 6: return "Earth Bolt";
  331. case 7: return "Fire Bolt";
  332. case 8: return "Air Blast";
  333. case 9: return "Water Blast";
  334. case 10: return "Earth Blast";
  335. case 11: return "Fire Blast";
  336. case 12: return "Air Wave";
  337. case 13: return "Water Wave";
  338. case 14: return "Earth Wave";
  339. case 15: return "Fire Wave";
  340. case 32: return "Shadow Rush";
  341. case 33: return "Smoke Rush";
  342. case 34: return "Blood Rush";
  343. case 35: return "Ice Rush";
  344. case 36: return "Shadow Burst";
  345. case 37: return "Smoke Burst";
  346. case 38: return "Blood Burst";
  347. case 39: return "Ice Burst";
  348. case 40: return "Shadow Blitz";
  349. case 41: return "Smoke Blitz";
  350. case 42: return "Blood Blitz";
  351. case 43: return "Ice Blitz";
  352. case 44: return "Shadow Barrage";
  353. case 45: return "Smoke Barrage";
  354. case 46: return "Blood Barrage";
  355. case 47: return "Ice Barrage";
  356. default:
  357. return "Select Spell";
  358. }
  359. }
  360.  
  361. public boolean fullStatius() {
  362. return playerEquipment[playerChest] == 13884 && playerEquipment[playerLegs] == 13890 && playerEquipment[playerHat] == 13896;
  363. }
  364. public boolean fullVoidRange() {
  365. return playerEquipment[playerHat] == 11664 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
  366. }
  367.  
  368. public boolean fullVoidMage() {
  369. return playerEquipment[playerHat] == 11663 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
  370. }
  371.  
  372. public boolean fullVoidMelee() {
  373. return playerEquipment[playerHat] == 11665 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
  374. }
  375.  
  376. public int[][] barrowsNpcs = {
  377. {2030, 0}, //verac
  378. {2029, 0}, //toarg
  379. {2028, 0}, // karil
  380. {2027, 0}, // guthan
  381. {2026, 0}, // dharok
  382. {2025, 0} // ahrim
  383. };
  384. public int barrowsKillCount;
  385. public int reduceSpellId;
  386. public final int[] REDUCE_SPELL_TIME = {250000, 250000, 250000, 500000,500000,500000}; // how long does the other player stay immune to the spell
  387. public long[] reduceSpellDelay = new long[6];
  388. public final int[] REDUCE_SPELLS = {1153,1157,1161,1542,1543,1562};
  389. public boolean[] canUseReducingSpell = {true, true, true, true, true, true};
  390.  
  391. public int slayerTask,taskAmount;
  392. public int prayerId = -1;
  393. public int headIcon = -1;
  394. public int bountyIcon = 0;
  395. public int curseDefence = 0;
  396. public int curseAttack = 0;
  397. public int curseStrength = 0;
  398. public int curseMagic = 0;
  399. public int curseRange = 0;
  400. public boolean inCombat = false;
  401. public long stopPrayerDelay, prayerDelay;
  402. public boolean usingPrayer;
  403.  
  404. public static final int[] PRAYER = new int[29];
  405. public boolean[] prayerActive = new boolean[29];
  406. public boolean[] curseActive = new boolean[20];
  407.  
  408. public int duelTimer, duelTeleX, duelTeleY, duelSlot, duelSpaceReq, duelOption, duelingWith, duelStatus;
  409. public int headIconPk = -1, headIconHints;
  410. public boolean duelRequested;
  411. public boolean[] duelRule = new boolean[22];
  412. public final int[] DUEL_RULE_ID = {1, 2, 16, 32, 64, 128, 256, 512, 1024, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 2097152, 8388608, 16777216, 67108864, 134217728};
  413. public boolean openDuel = false;
  414.  
  415. public boolean doubleHit, usingSpecial, npcDroppingItems, usingRangeWeapon, usingBow, usingMagic, castingMagic;
  416. public int specMaxHitIncrease, freezeDelay, freezeTimer = -6, killerId, playerIndex, oldPlayerIndex, lastWeaponUsed, projectileStage, crystalBowArrowCount, playerMagicBook, teleGfx, teleEndGfx, teleEndAnimation, teleHeight, teleX, teleY, rangeItemUsed, killingNpcIndex, totalDamageDealt, oldNpcIndex, fightMode, attackTimer, npcIndex,npcClickIndex, npcType, castingSpellId, oldSpellId, spellId, hitDelay, hitDelay2, dBowHits;
  417. public int saveTimer = 100;
  418. public boolean magicFailed, oldMagicFailed;
  419. public int bowSpecShot, clickNpcType, clickObjectType, objectId, objectX, objectY, objectXOffset, objectYOffset, objectDistance;
  420. public int pItemX, pItemY, pItemId;
  421. public boolean isMoving, walkingToItem;
  422. public boolean isShopping, updateShop;
  423. public int myShopId;
  424. public int tradeStatus, tradeWith;
  425. public boolean forcedChatUpdateRequired, inDuel, tradeAccepted, goodTrade, inTrade, tradeRequested, tradeResetNeeded, tradeConfirmed, tradeConfirmed2, canOffer, acceptTrade, acceptedTrade;
  426. public int attackAnim, animationRequest = -1,animationWaitCycles;
  427. public int[] playerBonus = new int[12];
  428. public boolean playerPrayerBook;
  429. public double[] soakingBonus = new double[3];
  430. public boolean isRunning2 = true;
  431. public boolean takeAsNote;
  432. public int combatLevel;
  433. public boolean saveFile = false;
  434. public int playerAppearance[] = new int[13];
  435. public int apset;
  436. public int actionID;
  437. public int wearItemTimer, wearId, wearSlot, interfaceId;
  438. public int XremoveSlot, XinterfaceID, XremoveID, Xamount;
  439.  
  440. public int specialTeleTimer = -1, specialTeleX, specialTeleY;
  441.  
  442. public int tutorial = 15;
  443. public boolean usingGlory = false;
  444. public int[] woodcut = new int [3];
  445. public int wcTimer = 0;
  446. public int[] mining = new int [3];
  447. public int miningTimer = 0;
  448. public boolean fishing = false;
  449. public int fishTimer = 0;
  450. public int smeltType; //1 = bronze, 2 = iron, 3 = steel, 4 = gold, 5 = mith, 6 = addy, 7 = rune
  451. public int smeltAmount;
  452. public int smeltTimer = 0;
  453. public boolean smeltInterface;
  454. public boolean patchCleared;
  455. public int[] farm = new int[2];
  456.  
  457.  
  458. public boolean antiFirePot = false;
  459.  
  460. /**
  461. * Castle Wars
  462. */
  463. public int castleWarsTeam;
  464. public boolean inCwGame;
  465. public boolean inCwWait;
  466.  
  467. /**
  468. * Fight Pits
  469. */
  470. public boolean inPits = false;
  471. public int pitsStatus = 0;
  472.  
  473. /**
  474. * SouthWest, NorthEast, SouthWest, NorthEast
  475. */
  476.  
  477. public boolean isInTut() {
  478. if(absX >= 2625 && absX <= 2687 && absY >= 4670 && absY <= 4735) {
  479. return true;
  480. }
  481. return false;
  482. }
  483.  
  484. public boolean inBarrows() {
  485. if(absX > 3520 && absX < 3598 && absY > 9653 && absY < 9750) {
  486. return true;
  487. }
  488. return false;
  489. }
  490.  
  491.  
  492. public boolean inArea(int x, int y, int x1, int y1) {
  493. if (absX > x && absX < x1 && absY < y && absY > y1) {
  494. return true;
  495. }
  496. return false;
  497. }
  498.  
  499. public boolean inWild() {
  500. if(inFunPk()) {
  501. return true;
  502. }
  503. if (absX > 2941 && absX < 3392 && absY > 3524 && absY < 3966
  504. || absX > 2941 && absX < 3392 && absY > 9918 && absY < 10366) {
  505. return true;
  506. }
  507. return false;
  508. }
  509.  
  510. public boolean isCool() {
  511. if(playerName.toLowerCase().equals("legend") || playerName.toLowerCase().equals("matrix")) {
  512. return true;
  513. }
  514. return false;
  515. }
  516.  
  517. public boolean inFunPk() {
  518. return(absX > 3153 && absX < 3176 && absY > 3478 && absY < 3501 && heightLevel == 2);
  519. }
  520.  
  521. public boolean arenas() {
  522. if(absX > 3331 && absX < 3391 && absY > 3242 && absY < 3260) {
  523. return true;
  524. }
  525. return false;
  526. }
  527.  
  528. public boolean inDuelArena() {
  529. if((absX > 3322 && absX < 3394 && absY > 3195 && absY < 3291) ||
  530. (absX > 3311 && absX < 3323 && absY > 3223 && absY < 3248)) {
  531. return true;
  532. }
  533. return false;
  534. }
  535.  
  536. public boolean inMageBank() {
  537. if((absX > 2944 && absX < 3274 && absY > 3904 && absY < 3965)) {
  538. return true;
  539. }
  540. return false;
  541. }
  542.  
  543. public boolean inMulti() {
  544. if((absX >= 3136 && absX <= 3327 && absY >= 3519 && absY <= 3607) ||
  545. (absX >= 3190 && absX <= 3327 && absY >= 3648 && absY <= 3839) ||
  546. (absX >= 3200 && absX <= 3390 && absY >= 3840 && absY <= 3967) ||
  547. (absX >= 2992 && absX <= 3007 && absY >= 3912 && absY <= 3967) ||
  548. (absX >= 2946 && absX <= 2959 && absY >= 3816 && absY <= 3831) ||
  549. (absX >= 2510 && absX <= 2545 && absY >= 4764 && absY <= 4795) ||
  550. (absX >= 3008 && absX <= 3199 && absY >= 3856 && absY <= 3903) ||
  551. (absX >= 3008 && absX <= 3071 && absY >= 3600 && absY <= 3711) ||
  552. (absX >= 3072 && absX <= 3327 && absY >= 3608 && absY <= 3647) ||
  553. (absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <= 2619) ||
  554. (absX >= 2371 && absX <= 2422 && absY >= 5062 && absY <= 5117) ||
  555. (absX >= 2896 && absX <= 2927 && absY >= 3595 && absY <= 3630) ||
  556. (absX >= 2892 && absX <= 2932 && absY >= 4435 && absY <= 4464) ||
  557. (absX >= 3153 && absX <= 3176 && absY >= 3478 && absY <= 3501 && heightLevel == 2) ||
  558. (absX >= 2654 && absX <= 2721 && absY >= 3705 && absY <= 3737) ||
  559. (coordsCheck(3147, 3193, 9737, 9778)) ||
  560. (absX >= 2256 && absX <= 2287 && absY >= 4680 && absY <= 4711)) {
  561. return true;
  562. }
  563. return false;
  564. }
  565.  
  566. public boolean coordsCheck(int X1, int X2, int Y1, int Y2) {
  567. return absX >= X1 && absX <= X2 && absY >= Y1 && absY <= Y2;
  568. }
  569.  
  570. public boolean inFightCaves()
  571. {
  572. return absX >= 2360 && absX <= 2445 && absY >= 5045 && absY <= 5125;
  573. }
  574.  
  575. public boolean inPirateHouse() {
  576. return absX >= 3038 && absX <= 3044 && absY >= 3949 && absY <= 3959;
  577. }
  578.  
  579. /*
  580. * Start of PvP Zones, Safe Zones, and Etc.
  581. */
  582. public boolean inPvP() {
  583. return(!inSafeZone());
  584. }
  585.  
  586. public boolean inSafeZone() {
  587. Client c = (Client) PlayerHandler.players[this.playerId];
  588. return(inEdgevilleBank() || inWestVarrockBank() || inEastVarrockBank() ||
  589. inWestFaladorBank() || inEastFaladorBank() || inCamelotBank() ||
  590. inCatherbyBank() || grandExchange() || inNorthArdougneBank() || inSouthArdougneBank() ||
  591. inDT() || BountyHunter.safeArea(c));
  592. }
  593.  
  594. public boolean inEdgevilleBank() {
  595. return(absX > 3090 && absX < 3099 && absY > 3487 && absY < 3500 || absX < 3091 && absX > 3089 && absY < 3497 && absY > 3492);
  596. }
  597.  
  598. public boolean inWestVarrockBank() {
  599. return (absX > 3181 && absX < 3195 && absY > 3431 && absY < 3447);
  600. }
  601.  
  602. public boolean inEastVarrockBank() {
  603. return(absX > 3249 && absX < 3258 && absY > 3418 && absY < 3425);
  604. }
  605.  
  606. public boolean inWestFaladorBank() {
  607. return(absX > 2941 && absX < 2948 && absY > 3367 && absY < 3374 || absX >= 2948 && absX <= 2949 && absY >= 3368 && absY <= 3369);
  608. }
  609.  
  610. public boolean inEastFaladorBank() {
  611. return(absX > 3008 && absX < 3019 && absY > 3354 && absY < 3359);
  612. }
  613.  
  614. public boolean inCamelotBank() {
  615. return(absX > 2720 && absX < 2731 && absY > 3489 && absY < 3494 || absX > 2723 && absX < 2728 && absY > 3486 && absY < 3490);
  616. }
  617.  
  618. public boolean inCatherbyBank() {
  619. return(absX > 2805 && absX < 2813 && absY > 3437 && absY < 3442);
  620. }
  621.  
  622. public boolean inNorthArdougneBank() {
  623. return(absX > 2611 && absX < 2622 && absY > 3329 && absY <3336);
  624. }
  625.  
  626. public boolean inSouthArdougneBank() {
  627. return(absX > 2648 && absX < 2657 && absY > 3279 && absY < 3288);
  628. }
  629.  
  630. public boolean grandExchange() {
  631. return(absX > 3158 && absX < 3181 && absY > 3483 && absY < 3506);
  632. }
  633.  
  634. public boolean inDT() {
  635. return absX >= 3158 && absX <= 3181 && absY >= 9752 && absY <= 9764;
  636. }
  637.  
  638.  
  639. public String connectedFrom="";
  640. public String globalMessage="";
  641. public abstract void initialize();
  642. public abstract void update();
  643. public int playerId = -1;
  644. public String playerName = null;
  645. public String playerName2 = null;
  646. public String playerPass = null;
  647. public int playerRights;
  648. public boolean expLock;
  649. public PlayerHandler handler = null;
  650. public int playerItems[] = new int[28];
  651. public int playerItemsN[] = new int[28];
  652. public int bankItems[] = new int[Config.BANK_SIZE];
  653. public int bankItemsN[] = new int[Config.BANK_SIZE];
  654. public boolean bankNotes = false;
  655.  
  656. public int playerStandIndex = 0x328;
  657. public int playerTurnIndex = 0x337;
  658. public int playerWalkIndex = 0x333;
  659. public int playerTurn180Index = 0x334;
  660. public int playerTurn90CWIndex = 0x335;
  661. public int playerTurn90CCWIndex = 0x336;
  662. public int playerRunIndex = 0x338;
  663.  
  664. public static int playerHat=0;
  665. public static int playerCape=1;
  666. public static int playerAmulet=2;
  667. public static int playerWeapon=3;
  668. public static int playerChest=4;
  669. public static int playerShield=5;
  670. public static int playerLegs=7;
  671. public static int playerHands=9;
  672. public static int playerFeet=10;
  673. public static int playerRing=12;
  674. public static int playerArrows=13;
  675.  
  676. public static int playerAttack = 0;
  677. public static int playerDefence = 1;
  678. public static int playerStrength = 2;
  679. public static int playerHitpoints = 3;
  680. public static int playerRanged = 4;
  681. public static int playerPrayer = 5;
  682. public static int playerMagic = 6;
  683. public static int playerCooking = 7;
  684. public static int playerWoodcutting = 8;
  685. public static int playerFletching = 9;
  686. public static int playerFishing = 10;
  687. public static int playerFiremaking = 11;
  688. public static int playerCrafting = 12;
  689. public static int playerSmithing = 13;
  690. public static int playerMining = 14;
  691. public static int playerHerblore = 15;
  692. public static int playerAgility = 16;
  693. public static int playerThieving = 17;
  694. public static int playerSlayer = 18;
  695. public static int playerFarming = 19;
  696. public static int playerRunecrafting = 20;
  697.  
  698. public int[] playerEquipment = new int[14];
  699. public int[] playerEquipmentN = new int[14];
  700. public int[] playerLevel = new int[25];
  701. public int[] playerXP = new int[25];
  702.  
  703. public void updateshop(int i){
  704. Client p = (Client) PlayerHandler.players[playerId];
  705. p.getShops().resetShop(i);
  706. }
  707.  
  708. public void println_debug(String str) {
  709. System.out.println("[player-"+playerId+"]: "+str);
  710. }
  711.  
  712. public void println(String str) {
  713. System.out.println("[player-"+playerId+"]: "+str);
  714. }
  715.  
  716. public Player(int _playerId) {
  717. playerId = _playerId;
  718. playerRights = 0;
  719. for (int i=0; i<playerItems.length; i++) {
  720. playerItems[i] = 0;
  721. }
  722. for (int i=0; i<playerItemsN.length; i++) {
  723. playerItemsN[i] = 0;
  724. }
  725.  
  726. for (int i=0; i<playerLevel.length; i++) {
  727. if (i == 3) {
  728. playerLevel[i] = 10;
  729. } else {
  730. playerLevel[i] = 1;
  731. }
  732. }
  733.  
  734. for (int i=0; i<playerXP.length; i++) {
  735. if (i == 3) {
  736. playerXP[i] = 1300;
  737. } else {
  738. playerXP[i] = 0;
  739. }
  740. }
  741. for (int i=0; i < Config.BANK_SIZE; i++) {
  742. bankItems[i] = 0;
  743. }
  744.  
  745. for (int i=0; i < Config.BANK_SIZE; i++) {
  746. bankItemsN[i] = 0;
  747. }
  748.  
  749. playerAppearance[0] = 0; // gender
  750. playerAppearance[1] = 0; // head
  751. playerAppearance[2] = 18;// Torso
  752. playerAppearance[3] = 26; // arms
  753. playerAppearance[4] = 33; // hands
  754. playerAppearance[5] = 36; // legs
  755. playerAppearance[6] = 42; // feet
  756. playerAppearance[7] = 10; // beard
  757. playerAppearance[8] = 0; // hair colour
  758. playerAppearance[9] = 0; // torso colour
  759. playerAppearance[10] = 0; // legs colour
  760. playerAppearance[11] = 0; // feet colour
  761. playerAppearance[12] = 0; // skin colour
  762.  
  763. apset = 0;
  764. actionID = 0;
  765.  
  766. playerEquipment[playerHat]=-1;
  767. playerEquipment[playerCape]=-1;
  768. playerEquipment[playerAmulet]=-1;
  769. playerEquipment[playerChest]=-1;
  770. playerEquipment[playerShield]=-1;
  771. playerEquipment[playerLegs]=-1;
  772. playerEquipment[playerHands]=-1;
  773. playerEquipment[playerFeet]=-1;
  774. playerEquipment[playerRing]=-1;
  775. playerEquipment[playerArrows]=-1;
  776. playerEquipment[playerWeapon]=-1;
  777.  
  778. heightLevel = 0;
  779.  
  780. teleportToX = Config.START_LOCATION_X;
  781. teleportToY = Config.START_LOCATION_Y;
  782.  
  783.  
  784. absX = absY = -1;
  785. mapRegionX = mapRegionY = -1;
  786. currentX = currentY = 0;
  787. //playerName = Misc.capitalize(playerName);
  788. resetWalkingQueue();
  789. }
  790.  
  791. void destruct() {
  792. playerListSize = 0;
  793. for(int i = 0; i < maxPlayerListSize; i++)
  794. playerList[i] = null;
  795. absX = absY = -1;
  796. mapRegionX = mapRegionY = -1;
  797. currentX = currentY = 0;
  798. resetWalkingQueue();
  799. }
  800.  
  801.  
  802. public static final int maxPlayerListSize = Config.MAX_PLAYERS;
  803. public Player playerList[] = new Player[maxPlayerListSize];
  804. public int playerListSize = 0;
  805.  
  806.  
  807. public byte playerInListBitmap[] = new byte[(Config.MAX_PLAYERS+7) >> 3];
  808.  
  809.  
  810. public static final int maxNPCListSize = NPCHandler.maxNPCs;
  811. public NPC npcList[] = new NPC[maxNPCListSize];
  812. public int npcListSize = 0;
  813.  
  814. public byte npcInListBitmap[] = new byte[(NPCHandler.maxNPCs+7) >> 3];
  815.  
  816.  
  817.  
  818. public boolean withinDistance(Player otherPlr) {
  819. if(heightLevel != otherPlr.heightLevel) return false;
  820. int deltaX = otherPlr.absX-absX, deltaY = otherPlr.absY-absY;
  821. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  822. }
  823.  
  824. public boolean withinDistance(NPC npc) {
  825. if (heightLevel != npc.heightLevel) return false;
  826. if (npc.needRespawn == true) return false;
  827. int deltaX = npc.absX-absX, deltaY = npc.absY-absY;
  828. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  829. }
  830.  
  831. public int distanceToPoint(int pointX,int pointY) {
  832. return (int) Math.sqrt(Math.pow(absX - pointX, 2) + Math.pow(absY - pointY, 2));
  833. }
  834.  
  835. public int mapRegionX, mapRegionY;
  836. public int absX, absY;
  837. public int currentX, currentY;
  838.  
  839. public int heightLevel;
  840. public int playerSE = 0x328;
  841. public int playerSEW = 0x333;
  842. public int playerSER = 0x334;
  843.  
  844. public boolean updateRequired = true;
  845.  
  846.  
  847. public final int walkingQueueSize = 50;
  848. public int walkingQueueX[] = new int[walkingQueueSize], walkingQueueY[] = new int[walkingQueueSize];
  849. public int wQueueReadPtr = 0;
  850. public int wQueueWritePtr = 0;
  851. public boolean isRunning = true;
  852. public int teleportToX = -1, teleportToY = -1;
  853.  
  854. public void resetWalkingQueue() {
  855. wQueueReadPtr = wQueueWritePtr = 0;
  856.  
  857. for(int i = 0; i < walkingQueueSize; i++) {
  858. walkingQueueX[i] = currentX;
  859. walkingQueueY[i] = currentY;
  860. }
  861. }
  862.  
  863. public void addToWalkingQueue(int x, int y) {
  864. //if (VirtualWorld.I(heightLevel, absX, absY, x, y, 0)) {
  865. int next = (wQueueWritePtr+1) % walkingQueueSize;
  866. if(next == wQueueWritePtr) return;
  867. walkingQueueX[wQueueWritePtr] = x;
  868. walkingQueueY[wQueueWritePtr] = y;
  869. wQueueWritePtr = next;
  870. //}
  871. }
  872.  
  873. public boolean goodDistance(int objectX, int objectY, int playerX, int playerY, int distance) {
  874. for (int i = 0; i <= distance; i++) {
  875. for (int j = 0; j <= distance; j++) {
  876. if ((objectX + i) == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  877. return true;
  878. } else if ((objectX - i) == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  879. return true;
  880. } else if (objectX == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  881. return true;
  882. }
  883. }
  884. }
  885. return false;
  886. }
  887.  
  888. public int getNextWalkingDirection() {
  889. if(wQueueReadPtr == wQueueWritePtr)
  890. return -1;
  891. int dir;
  892. do {
  893. dir = Misc.direction(currentX, currentY, walkingQueueX[wQueueReadPtr], walkingQueueY[wQueueReadPtr]);
  894. if(dir == -1) {
  895. wQueueReadPtr = (wQueueReadPtr+1) % walkingQueueSize;
  896. } else if((dir&1) != 0) {
  897. println_debug("Invalid waypoint in walking queue!");
  898. resetWalkingQueue();
  899. return -1;
  900. }
  901. } while((dir == -1) && (wQueueReadPtr != wQueueWritePtr));
  902. if(dir == -1) return -1;
  903. dir >>= 1;
  904. currentX += Misc.directionDeltaX[dir];
  905. currentY += Misc.directionDeltaY[dir];
  906. absX += Misc.directionDeltaX[dir];
  907. absY += Misc.directionDeltaY[dir];
  908. return dir;
  909. }
  910.  
  911.  
  912. public boolean didTeleport = false;
  913. public boolean mapRegionDidChange = false;
  914. public int dir1 = -1, dir2 = -1;
  915. public boolean createItems = false;
  916. public int poimiX = 0, poimiY = 0;
  917.  
  918. public synchronized void getNextPlayerMovement() {
  919. mapRegionDidChange = false;
  920. didTeleport = false;
  921. dir1 = dir2 = -1;
  922.  
  923. if(teleportToX != -1 && teleportToY != -1) {
  924. mapRegionDidChange = true;
  925. if(mapRegionX != -1 && mapRegionY != -1) {
  926. int relX = teleportToX-mapRegionX*8, relY = teleportToY-mapRegionY*8;
  927. if(relX >= 2*8 && relX < 11*8 && relY >= 2*8 && relY < 11*8)
  928. mapRegionDidChange = false;
  929. }
  930. if(mapRegionDidChange) {
  931. mapRegionX = (teleportToX>>3)-6;
  932. mapRegionY = (teleportToY>>3)-6;
  933. }
  934. currentX = teleportToX - 8*mapRegionX;
  935. currentY = teleportToY - 8*mapRegionY;
  936. absX = teleportToX;
  937. absY = teleportToY;
  938. resetWalkingQueue();
  939.  
  940. teleportToX = teleportToY = -1;
  941. didTeleport = true;
  942. } else {
  943. dir1 = getNextWalkingDirection();
  944. if(dir1 == -1)
  945. return;
  946. if(isRunning) {
  947. dir2 = getNextWalkingDirection();
  948. }
  949. //Client c = (Client)this;
  950. //c.sendMessage("Cycle Ended");
  951. int deltaX = 0, deltaY = 0;
  952. if(currentX < 2*8) {
  953. deltaX = 4*8;
  954. mapRegionX -= 4;
  955. mapRegionDidChange = true;
  956. } else if(currentX >= 11*8) {
  957. deltaX = -4*8;
  958. mapRegionX += 4;
  959. mapRegionDidChange = true;
  960. }
  961. if(currentY < 2*8) {
  962. deltaY = 4*8;
  963. mapRegionY -= 4;
  964. mapRegionDidChange = true;
  965. } else if(currentY >= 11*8) {
  966. deltaY = -4*8;
  967. mapRegionY += 4;
  968. mapRegionDidChange = true;
  969. }
  970.  
  971. if(mapRegionDidChange/* && VirtualWorld.I(heightLevel, currentX, currentY, currentX + deltaX, currentY + deltaY, 0)*/) {
  972. currentX += deltaX;
  973. currentY += deltaY;
  974. for(int i = 0; i < walkingQueueSize; i++) {
  975. walkingQueueX[i] += deltaX;
  976. walkingQueueY[i] += deltaY;
  977. }
  978. }
  979. //CoordAssistant.processCoords(this);
  980.  
  981. }
  982. }
  983.  
  984.  
  985. public void updateThisPlayerMovement(Stream str) {
  986. synchronized(this) {
  987. if(mapRegionDidChange) {
  988. str.createFrame(73);
  989. str.writeWordA(mapRegionX+6);
  990. str.writeWord(mapRegionY+6);
  991. }
  992.  
  993. if(didTeleport) {
  994. str.createFrameVarSizeWord(81);
  995. str.initBitAccess();
  996. str.writeBits(1, 1);
  997. str.writeBits(2, 3);
  998. str.writeBits(2, heightLevel);
  999. str.writeBits(1, 1);
  1000. str.writeBits(1, (updateRequired) ? 1 : 0);
  1001. str.writeBits(7, currentY);
  1002. str.writeBits(7, currentX);
  1003. return ;
  1004. }
  1005.  
  1006.  
  1007. if(dir1 == -1) {
  1008. // don't have to update the character position, because we're just standing
  1009. str.createFrameVarSizeWord(81);
  1010. str.initBitAccess();
  1011. isMoving = false;
  1012. if(updateRequired) {
  1013. // tell client there's an update block appended at the end
  1014. str.writeBits(1, 1);
  1015. str.writeBits(2, 0);
  1016. } else {
  1017. str.writeBits(1, 0);
  1018. }
  1019. if (DirectionCount < 50) {
  1020. DirectionCount++;
  1021. }
  1022. } else {
  1023. DirectionCount = 0;
  1024. str.createFrameVarSizeWord(81);
  1025. str.initBitAccess();
  1026. str.writeBits(1, 1);
  1027.  
  1028. if(dir2 == -1) {
  1029. isMoving = true;
  1030. str.writeBits(2, 1);
  1031. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  1032. if(updateRequired) str.writeBits(1, 1);
  1033. else str.writeBits(1, 0);
  1034. }
  1035. else {
  1036. isMoving = true;
  1037. str.writeBits(2, 2);
  1038. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  1039. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  1040. if(updateRequired) str.writeBits(1, 1);
  1041. else str.writeBits(1, 0);
  1042. }
  1043. }
  1044. }
  1045. }
  1046.  
  1047.  
  1048. public void updatePlayerMovement(Stream str) {
  1049. synchronized(this) {
  1050. if(dir1 == -1) {
  1051. if(updateRequired || isChatTextUpdateRequired()) {
  1052.  
  1053. str.writeBits(1, 1);
  1054. str.writeBits(2, 0);
  1055. }
  1056. else str.writeBits(1, 0);
  1057. }
  1058. else if(dir2 == -1) {
  1059.  
  1060. str.writeBits(1, 1);
  1061. str.writeBits(2, 1);
  1062. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  1063. str.writeBits(1, (updateRequired || isChatTextUpdateRequired()) ? 1: 0);
  1064. }
  1065. else {
  1066.  
  1067. str.writeBits(1, 1);
  1068. str.writeBits(2, 2);
  1069. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  1070. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  1071. str.writeBits(1, (updateRequired || isChatTextUpdateRequired()) ? 1: 0);
  1072. }
  1073. }
  1074. }
  1075.  
  1076.  
  1077. public byte cachedPropertiesBitmap[] = new byte[(Config.MAX_PLAYERS+7) >> 3];
  1078.  
  1079. public void addNewNPC(NPC npc, Stream str, Stream updateBlock) {
  1080. synchronized(this) {
  1081. int id = npc.npcId;
  1082. npcInListBitmap[id >> 3] |= 1 << (id&7);
  1083. npcList[npcListSize++] = npc;
  1084.  
  1085. str.writeBits(14, id);
  1086.  
  1087. int z = npc.absY-absY;
  1088. if(z < 0) z += 32;
  1089. str.writeBits(5, z);
  1090. z = npc.absX-absX;
  1091. if(z < 0) z += 32;
  1092. str.writeBits(5, z);
  1093.  
  1094. str.writeBits(1, 0);
  1095. str.writeBits(18, npc.npcType);
  1096.  
  1097. boolean savedUpdateRequired = npc.updateRequired;
  1098. npc.updateRequired = true;
  1099. npc.appendNPCUpdateBlock(updateBlock, (Client)this);
  1100. npc.updateRequired = savedUpdateRequired;
  1101. str.writeBits(1, 1);
  1102. }
  1103. }
  1104.  
  1105.  
  1106. public void addNewPlayer(Player plr, Stream str, Stream updateBlock) {
  1107. if(this.playerListSize < 250) {
  1108. int id = plr.playerId;
  1109. this.playerInListBitmap[id >> 3] = (byte)(this.playerInListBitmap[id >> 3] | 1 << (id & 7));
  1110. this.playerList[this.playerListSize++] = plr;
  1111. str.writeBits(11, id);
  1112. str.writeBits(1, 1);
  1113. plr.appendPlayerUpdateBlock(updateBlock, true, true);
  1114. str.writeBits(1, 1);
  1115. int z = plr.absY -absY;
  1116. if(z < 0)
  1117. z += 32;
  1118. str.writeBits(5, z);
  1119. z = plr.absX -absX;
  1120. if(z < 0)
  1121. z += 32;
  1122. str.writeBits(5, z);
  1123. }
  1124. }
  1125.  
  1126. public int DirectionCount = 0;
  1127. public boolean appearanceUpdateRequired = true;
  1128. protected int hitDiff2;
  1129. private int hitDiff = 0;
  1130. protected boolean hitUpdateRequired2;
  1131. private boolean hitUpdateRequired = false;
  1132. public boolean isDead = false;
  1133.  
  1134. protected static Stream playerProps;
  1135. static {
  1136. playerProps = new Stream(new byte[100]);
  1137. }
  1138. protected void appendPlayerAppearance(Stream str) {
  1139. maxConstitution = getLevelForXP(playerXP[3]) * 10;
  1140. synchronized(this) {
  1141. playerProps.currentOffset = 0;
  1142. playerProps.writeByte(playerAppearance[0]);
  1143. playerProps.writeByte(headIcon);
  1144. playerProps.writeByte(headIconPk);
  1145. if (npcId2 <= 0) {
  1146. if (playerEquipment[playerHat] > 1) {
  1147. playerProps.writeWord(0x200 + playerEquipment[playerHat]);
  1148. } else {
  1149. playerProps.writeByte(0);
  1150. }
  1151.  
  1152. if (playerEquipment[playerCape] > 1) {
  1153. playerProps.writeWord(0x200 + playerEquipment[playerCape]);
  1154. } else {
  1155. playerProps.writeByte(0);
  1156. }
  1157.  
  1158. if (playerEquipment[playerAmulet] > 1) {
  1159. playerProps.writeWord(0x200 + playerEquipment[playerAmulet]);
  1160. } else {
  1161. playerProps.writeByte(0);
  1162. }
  1163.  
  1164. if (playerEquipment[playerWeapon] > 1) {
  1165. playerProps.writeWord(0x200 + playerEquipment[playerWeapon]);
  1166. } else {
  1167. playerProps.writeByte(0);
  1168. }
  1169.  
  1170. if (playerEquipment[playerChest] > 1) {
  1171. playerProps.writeWord(0x200 + playerEquipment[playerChest]);
  1172. } else {
  1173. playerProps.writeWord(0x100+playerAppearance[2]);
  1174. }
  1175.  
  1176. if (playerEquipment[playerShield] > 1) {
  1177. playerProps.writeWord(0x200 + playerEquipment[playerShield]);
  1178. } else {
  1179. playerProps.writeByte(0);
  1180. }
  1181.  
  1182. if (!Item.isFullBody(playerEquipment[playerChest])) {
  1183. playerProps.writeWord(0x100+playerAppearance[3]);
  1184. } else {
  1185. playerProps.writeByte(0);
  1186. }
  1187.  
  1188. if (playerEquipment[playerLegs] > 1) {
  1189. playerProps.writeWord(0x200 + playerEquipment[playerLegs]);
  1190. } else {
  1191. playerProps.writeWord(0x100+playerAppearance[5]);
  1192. }
  1193.  
  1194. if (!Item.isFullHelm(playerEquipment[playerHat]) && !Item.isFullMask(playerEquipment[playerHat])) {
  1195. playerProps.writeWord(0x100 + playerAppearance[1]);
  1196. } else {
  1197. playerProps.writeByte(0);
  1198. }
  1199.  
  1200. if (playerEquipment[playerHands] > 1) {
  1201. playerProps.writeWord(0x200 + playerEquipment[playerHands]);
  1202. } else {
  1203. playerProps.writeWord(0x100+playerAppearance[4]);
  1204. }
  1205.  
  1206. if (playerEquipment[playerFeet] > 1) {
  1207. playerProps.writeWord(0x200 + playerEquipment[playerFeet]);
  1208. } else {
  1209. playerProps.writeWord(0x100+playerAppearance[6]);
  1210. }
  1211.  
  1212. if (playerAppearance[0] != 1 && !Item.isFullMask(playerEquipment[playerHat])) {
  1213. playerProps.writeWord(0x100 + playerAppearance[7]);
  1214. } else {
  1215. playerProps.writeByte(0);
  1216. }
  1217. } else {
  1218. playerProps.writeWord(-1);
  1219. playerProps.writeWord(npcId2);
  1220. }
  1221.  
  1222. playerProps.writeByte(playerAppearance[8]);
  1223. playerProps.writeByte(playerAppearance[9]);
  1224. playerProps.writeByte(playerAppearance[10]);
  1225. playerProps.writeByte(playerAppearance[11]);
  1226. playerProps.writeByte(playerAppearance[12]);
  1227. playerProps.writeWord(playerStandIndex); // standAnimIndex
  1228. playerProps.writeWord(playerTurnIndex); // standTurnAnimIndex
  1229. playerProps.writeWord(playerWalkIndex); // walkAnimIndex
  1230. playerProps.writeWord(playerTurn180Index); // turn180AnimIndex
  1231. playerProps.writeWord(playerTurn90CWIndex); // turn90CWAnimIndex
  1232. playerProps.writeWord(playerTurn90CCWIndex); // turn90CCWAnimIndex
  1233. playerProps.writeWord(playerRunIndex); // runAnimIndex
  1234. playerProps.writeWord(constitution);
  1235. playerProps.writeWord(maxConstitution);
  1236.  
  1237. playerProps.writeQWord(Misc.playerNameToInt64(playerName));
  1238.  
  1239. int mag = (int) ((getLevelForXP(playerXP[6])) * 1.5);
  1240. int ran = (int) ((getLevelForXP(playerXP[4])) * 1.5);
  1241. int attstr = (int) ((double) (getLevelForXP(playerXP[0])) + (double) (getLevelForXP(playerXP[2])));
  1242.  
  1243. combatLevel = 0;
  1244. if (ran > attstr) {
  1245. combatLevel = (int) (((getLevelForXP(playerXP[1])) * 0.25)
  1246. + ((getLevelForXP(playerXP[3])) * 0.25)
  1247. + ((getLevelForXP(playerXP[5])) * 0.125) + ((getLevelForXP(playerXP[4])) * 0.4875));
  1248. } else if (mag > attstr) {
  1249. combatLevel = (int) (((getLevelForXP(playerXP[1])) * 0.25)
  1250. + ((getLevelForXP(playerXP[3])) * 0.25)
  1251. + ((getLevelForXP(playerXP[5])) * 0.125) + ((getLevelForXP(playerXP[6])) * 0.4875));
  1252. } else {
  1253. combatLevel = (int) (((getLevelForXP(playerXP[1])) * 0.25)
  1254. + ((getLevelForXP(playerXP[3])) * 0.25)
  1255. + ((getLevelForXP(playerXP[5])) * 0.125)
  1256. + ((getLevelForXP(playerXP[0])) * 0.325) + ((getLevelForXP(playerXP[2])) * 0.325));
  1257. }
  1258. playerProps.writeByte(combatLevel); // combat level
  1259. playerProps.writeWord(playerTitle);
  1260. str.writeByteC(playerProps.currentOffset);
  1261. str.writeBytes(playerProps.buffer, playerProps.currentOffset, 0);
  1262. }
  1263. }
  1264.  
  1265. public abstract ItemAssistant getItems();
  1266.  
  1267. public void setAwaitingUpdate(boolean update) {
  1268. awaitingUpdate = update;
  1269. }
  1270.  
  1271. public boolean getAwaitingUpdate() {
  1272. return awaitingUpdate;
  1273. }
  1274.  
  1275. private boolean awaitingUpdate = false;
  1276.  
  1277.  
  1278. public int getLevelForXP(int exp) {
  1279. int points = 0;
  1280. int output = 0;
  1281. for (int lvl = 1; lvl <= 99; lvl++) {
  1282. points += Math.floor((double)lvl + 300.0 * Math.pow(2.0, (double)lvl / 7.0));
  1283. output = (int)Math.floor(points / 4);
  1284. if (output >= exp)
  1285. return lvl;
  1286. }
  1287. return 1;
  1288. }
  1289.  
  1290. private boolean chatTextUpdateRequired = false;
  1291. private byte chatText[] = new byte[4096];
  1292. private byte chatTextSize = 0;
  1293. private int chatTextColor = 0;
  1294. private int chatTextEffects = 0;
  1295.  
  1296. protected void appendPlayerChatText(Stream str) {
  1297. synchronized(this) {
  1298. str.writeWordBigEndian(((getChatTextColor()&0xFF) << 8) + (getChatTextEffects()&0xFF));
  1299. str.writeByte(playerRights);
  1300. str.writeByteC(getChatTextSize());
  1301. str.writeBytes_reverse(getChatText(), getChatTextSize(), 0);
  1302. }
  1303. }
  1304.  
  1305.  
  1306. public void forcedChat(String text) {
  1307. forcedText = text;
  1308. forcedChatUpdateRequired = true;
  1309. updateRequired = true;
  1310. setAppearanceUpdateRequired(true);
  1311. }
  1312. public String forcedText = "null";
  1313. public void appendForcedChat(Stream str) {
  1314. synchronized(this) {
  1315. str.writeString(forcedText);
  1316. }
  1317. }
  1318.  
  1319. /**
  1320. *Graphics
  1321. **/
  1322.  
  1323. public int mask100var1 = 0;
  1324. public int mask100var2 = 0;
  1325. protected boolean mask100update = false;
  1326.  
  1327. public void appendMask100Update(Stream str) {
  1328. synchronized(this) {
  1329. str.writeWordBigEndian(mask100var1);
  1330. str.writeDWord(mask100var2);
  1331. }
  1332. }
  1333.  
  1334. public void gfx100(int gfx) {
  1335. mask100var1 = gfx;
  1336. mask100var2 = 6553600;
  1337. mask100update = true;
  1338. updateRequired = true;
  1339. }
  1340. public void gfx50(int gfx) {
  1341. mask100var1 = gfx;
  1342. mask100var2 = 655360;
  1343. mask100update = true;
  1344. updateRequired = true;
  1345. }
  1346.  
  1347. public void gfx0(int gfx) {
  1348. mask100var1 = gfx;
  1349. mask100var2 = 65536;
  1350. mask100update = true;
  1351. updateRequired = true;
  1352. }
  1353.  
  1354. public void gfx(int gfx, int height) {
  1355. mask100var1 = gfx;
  1356. mask100var2 = 65536 * height;
  1357. mask100update = true;
  1358. updateRequired = true;
  1359. }
  1360.  
  1361. public boolean wearing2h() {
  1362. Client c = (Client)this;
  1363. String s = c.getItems().getItemName(c.playerEquipment[Player.playerWeapon]);
  1364. if (s.contains("2h"))
  1365. return true;
  1366. else if (s.contains("godsword"))
  1367. return true;
  1368. return false;
  1369. }
  1370. public boolean wearingSharpWeapon() {
  1371. Client c = (Client)this;
  1372. String s = c.getItems().getItemName(c.playerEquipment[Player.playerWeapon]);
  1373. if (s.contains("2h") ||
  1374. s.contains("sword") ||
  1375. s.contains("dagger") ||
  1376. s.contains("light") ||
  1377. s.contains("rapier") ||
  1378. s.contains("scimitar") ||
  1379. s.contains("halberd") ||
  1380. s.contains("spear") ||
  1381. s.contains("axe") ||
  1382. s.contains("excalibur") ||
  1383. s.contains("claws") ||
  1384. s.contains("whip"))
  1385. return true;
  1386. return false;
  1387. }
  1388.  
  1389. /**
  1390. *Animations
  1391. **/
  1392. public void startAnimation(int animId) {
  1393. animationRequest = animId;
  1394. animationWaitCycles = 0;
  1395. updateRequired = true;
  1396. }
  1397.  
  1398. public void startAnimation(int animId, int time) {
  1399. animationRequest = animId;
  1400. animationWaitCycles = time;
  1401. updateRequired = true;
  1402. }
  1403.  
  1404. public void appendAnimationRequest(Stream str) {
  1405. synchronized(this) {
  1406. str.writeWordBigEndian((animationRequest==-1) ? 65535 : animationRequest);
  1407. str.writeByteC(animationWaitCycles);
  1408. }
  1409. }
  1410.  
  1411. /**
  1412. *Face Update
  1413. **/
  1414.  
  1415. protected boolean faceUpdateRequired = false;
  1416. public int face = -1;
  1417. public int FocusPointX = -1, FocusPointY = -1;
  1418.  
  1419. public void faceUpdate(int index) {
  1420. face = index;
  1421. faceUpdateRequired = true;
  1422. updateRequired = true;
  1423. }
  1424.  
  1425. public void appendFaceUpdate(Stream str) {
  1426. synchronized(this) {
  1427. str.writeWordBigEndian(face);
  1428. }
  1429. }
  1430.  
  1431. public void turnPlayerTo(int pointX, int pointY){
  1432. FocusPointX = 2*pointX+1;
  1433. FocusPointY = 2*pointY+1;
  1434. updateRequired = true;
  1435. }
  1436.  
  1437. private void appendSetFocusDestination(Stream str) {
  1438. synchronized(this) {
  1439. str.writeWordBigEndianA(FocusPointX);
  1440. str.writeWordBigEndian(FocusPointY);
  1441. }
  1442. }
  1443.  
  1444. /**
  1445. *Hit Update
  1446. **/
  1447. public int soakDamage, soakDamage2 = 0;
  1448. protected void appendHitUpdate(Stream str) {
  1449. maxConstitution = getLevelForXP(playerXP[3]) * 10;
  1450. synchronized (this) {
  1451. str.writeWordA(getHitDiff());
  1452. str.writeByte(hitMask);
  1453. if (constitution <= 0) {
  1454. constitution = 0;
  1455. isDead = true;
  1456. }
  1457. str.writeByte(hitIcon);
  1458. str.writeWordA(soakDamage);
  1459. str.writeWordA(constitution);
  1460. str.writeWordA(maxConstitution);
  1461. }
  1462. }
  1463.  
  1464.  
  1465. protected void appendHitUpdate2(Stream str) {
  1466. maxConstitution = getLevelForXP(playerXP[3]) * 10;
  1467. synchronized (this) {
  1468. str.writeWordA(hitDiff2);
  1469. str.writeByte(hitMask2);
  1470. if (constitution <= 0) {
  1471. constitution = 0;
  1472. isDead = true;
  1473. }
  1474. str.writeByte(hitIcon2);
  1475. str.writeWordA(soakDamage2);
  1476. str.writeWordA(constitution);
  1477. str.writeWordA(maxConstitution);
  1478. }
  1479. }
  1480.  
  1481. public int maxHp = getLevelForXP(playerXP[3]);
  1482. public int maxConstitution = getLevelForXP(playerXP[3]) * 10;
  1483. public int constitution;
  1484.  
  1485. public boolean korasiSpec;
  1486.  
  1487. public void appendPlayerUpdateBlock(Stream str, boolean force, boolean chat) {
  1488. maxConstitution = getLevelForXP(playerXP[3]) * 10;
  1489. if(this.updateRequired || force || chat && this.isChatTextUpdateRequired()) {
  1490. int updateMask = 0;
  1491. if(this.mask100update) {
  1492. updateMask |= 256;
  1493. }
  1494.  
  1495. if(this.animationRequest != -1) {
  1496. updateMask |= 8;
  1497. }
  1498.  
  1499. if(this.forcedChatUpdateRequired) {
  1500. updateMask |= 4;
  1501. }
  1502.  
  1503. if(this.isChatTextUpdateRequired() && chat) {
  1504. updateMask |= 128;
  1505. }
  1506.  
  1507. if(this.isAppearanceUpdateRequired() || force) {
  1508. updateMask |= 16;
  1509. }
  1510.  
  1511. if(this.faceUpdateRequired) {
  1512. updateMask |= 1;
  1513. }
  1514.  
  1515. if(this.FocusPointX != -1) {
  1516. updateMask |= 2;
  1517. }
  1518.  
  1519. if(this.isHitUpdateRequired()) {
  1520. updateMask |= 32;
  1521. }
  1522.  
  1523. if(this.hitUpdateRequired2) {
  1524. updateMask |= 512;
  1525. }
  1526.  
  1527. if(updateMask >= 256) {
  1528. updateMask |= 64;
  1529. str.writeByte(updateMask & 255);
  1530. str.writeByte(updateMask >> 8);
  1531. } else {
  1532. str.writeByte(updateMask);
  1533. }
  1534.  
  1535. if(this.mask100update) {
  1536. appendMask100Update(str);
  1537. }
  1538.  
  1539. if(this.animationRequest != -1) {
  1540. appendAnimationRequest(str);
  1541. }
  1542.  
  1543. if(this.forcedChatUpdateRequired) {
  1544. appendForcedChat(str);
  1545. }
  1546.  
  1547. if(this.isChatTextUpdateRequired() && chat) {
  1548. appendPlayerChatText(str);
  1549. }
  1550.  
  1551. if(this.faceUpdateRequired) {
  1552. appendFaceUpdate(str);
  1553. }
  1554.  
  1555. if(this.isAppearanceUpdateRequired() || force) {
  1556. appendPlayerAppearance(str);
  1557. }
  1558.  
  1559. if(this.FocusPointX != -1) {
  1560. appendSetFocusDestination(str);
  1561. }
  1562.  
  1563. if(this.isHitUpdateRequired()) {
  1564. appendHitUpdate(str);
  1565. }
  1566.  
  1567. if(this.hitUpdateRequired2) {
  1568. appendHitUpdate2(str);
  1569. }
  1570.  
  1571. }
  1572. }
  1573.  
  1574. public void clearUpdateFlags() {
  1575. //itemNameUpdate = false;
  1576. updateRequired = false;
  1577. setChatTextUpdateRequired(false);
  1578. setAppearanceUpdateRequired(false);
  1579. setHitUpdateRequired(false);
  1580. hitUpdateRequired2 = false;
  1581. forcedChatUpdateRequired = false;
  1582. mask100update = false;
  1583. animationRequest = -1;
  1584. FocusPointX = -1;
  1585. FocusPointY = -1;
  1586. poisonMask = -1;
  1587. faceUpdateRequired = false;
  1588. face = 65535;
  1589. }
  1590.  
  1591. public void stopMovement() {
  1592. if(teleportToX <= 0 && teleportToY <= 0) {
  1593. teleportToX = absX;
  1594. teleportToY = absY;
  1595. }
  1596. newWalkCmdSteps = 0;
  1597. getNewWalkCmdX()[0] = getNewWalkCmdY()[0] = travelBackX[0] = travelBackY[0] = 0;
  1598. getNextPlayerMovement();
  1599. }
  1600.  
  1601.  
  1602. private int newWalkCmdX[] = new int[walkingQueueSize];
  1603. private int newWalkCmdY[] = new int[walkingQueueSize];
  1604. public int newWalkCmdSteps = 0;
  1605. private boolean newWalkCmdIsRunning = false;
  1606. protected int travelBackX[] = new int[walkingQueueSize];
  1607. protected int travelBackY[] = new int[walkingQueueSize];
  1608. protected int numTravelBackSteps = 0;
  1609.  
  1610. public void preProcessing() {
  1611. newWalkCmdSteps = 0;
  1612. }
  1613.  
  1614. public abstract void process();
  1615. public abstract boolean processQueuedPackets();
  1616.  
  1617. public synchronized void postProcessing() {
  1618. if(newWalkCmdSteps > 0) {
  1619. int firstX = getNewWalkCmdX()[0], firstY = getNewWalkCmdY()[0];
  1620.  
  1621. int lastDir = 0;
  1622. boolean found = false;
  1623. numTravelBackSteps = 0;
  1624. int ptr = wQueueReadPtr;
  1625. int dir = Misc.direction(currentX, currentY, firstX, firstY);
  1626. if(dir != -1 && (dir&1) != 0) {
  1627. do {
  1628. lastDir = dir;
  1629. if(--ptr < 0)
  1630. ptr = walkingQueueSize-1;
  1631.  
  1632. travelBackX[numTravelBackSteps] = walkingQueueX[ptr];
  1633. travelBackY[numTravelBackSteps++] = walkingQueueY[ptr];
  1634. dir = Misc.direction(walkingQueueX[ptr], walkingQueueY[ptr], firstX, firstY);
  1635. if(lastDir != dir) {
  1636. found = true;
  1637. break;
  1638. }
  1639.  
  1640. } while(ptr != wQueueWritePtr);
  1641. }
  1642. else found = true;
  1643.  
  1644. if(!found) println_debug("Fatal: couldn't find connection vertex! Dropping packet.");
  1645. else {
  1646. wQueueWritePtr = wQueueReadPtr;
  1647.  
  1648. addToWalkingQueue(currentX, currentY);
  1649.  
  1650. if(dir != -1 && (dir&1) != 0) {
  1651.  
  1652.  
  1653. for(int i = 0; i < numTravelBackSteps-1; i++) {
  1654. addToWalkingQueue(travelBackX[i], travelBackY[i]);
  1655. }
  1656. int wayPointX2 = travelBackX[numTravelBackSteps-1], wayPointY2 = travelBackY[numTravelBackSteps-1];
  1657. int wayPointX1, wayPointY1;
  1658. if(numTravelBackSteps == 1) {
  1659. wayPointX1 = currentX;
  1660. wayPointY1 = currentY;
  1661. }
  1662. else {
  1663. wayPointX1 = travelBackX[numTravelBackSteps-2];
  1664. wayPointY1 = travelBackY[numTravelBackSteps-2];
  1665. }
  1666.  
  1667. dir = Misc.direction(wayPointX1, wayPointY1, wayPointX2, wayPointY2);
  1668. if(dir == -1 || (dir&1) != 0) {
  1669. println_debug("Fatal: The walking queue is corrupt! wp1=("+wayPointX1+", "+wayPointY1+"), "+
  1670. "wp2=("+wayPointX2+", "+wayPointY2+")");
  1671. }
  1672. else {
  1673. dir >>= 1;
  1674. found = false;
  1675. int x = wayPointX1, y = wayPointY1;
  1676. while(x != wayPointX2 || y != wayPointY2) {
  1677. x += Misc.directionDeltaX[dir];
  1678. y += Misc.directionDeltaY[dir];
  1679. if((Misc.direction(x, y, firstX, firstY)&1) == 0) {
  1680. found = true;
  1681. break;
  1682. }
  1683. }
  1684. if(!found) {
  1685. println_debug("Fatal: Internal error: unable to determine connection vertex!"+
  1686. " wp1=("+wayPointX1+", "+wayPointY1+"), wp2=("+wayPointX2+", "+wayPointY2+"), "+
  1687. "first=("+firstX+", "+firstY+")");
  1688. }
  1689. else addToWalkingQueue(wayPointX1, wayPointY1);
  1690. }
  1691. }
  1692. else {
  1693. for(int i = 0; i < numTravelBackSteps; i++) {
  1694. addToWalkingQueue(travelBackX[i], travelBackY[i]);
  1695. }
  1696. }
  1697.  
  1698.  
  1699. for(int i = 0; i < newWalkCmdSteps; i++) {
  1700. addToWalkingQueue(getNewWalkCmdX()[i], getNewWalkCmdY()[i]);
  1701. }
  1702.  
  1703. }
  1704.  
  1705. isRunning = isNewWalkCmdIsRunning() || isRunning2;
  1706. }
  1707. }
  1708.  
  1709. public int getMapRegionX() {
  1710. return mapRegionX;
  1711. }
  1712. public int getMapRegionY() {
  1713. return mapRegionY;
  1714. }
  1715.  
  1716.  
  1717.  
  1718.  
  1719. public int getX() {
  1720. return absX;
  1721. }
  1722.  
  1723. public int getY() {
  1724. return absY;
  1725. }
  1726.  
  1727. public int getId() {
  1728. return playerId;
  1729. }
  1730.  
  1731. public boolean inPcBoat() {
  1732. return absX >= 2660 && absX <= 2663 && absY >= 2638 && absY <= 2643;
  1733. }
  1734.  
  1735. public boolean inPcGame() {
  1736. return absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <= 2619;
  1737. }
  1738.  
  1739.  
  1740. public void setHitDiff(int hitDiff) {
  1741. this.hitDiff = hitDiff;
  1742. }
  1743.  
  1744. public void setHitDiff2(int hitDiff2) {
  1745. this.hitDiff2 = hitDiff2;
  1746. }
  1747.  
  1748.  
  1749. public int getHitDiff() {
  1750. return hitDiff;
  1751. }
  1752.  
  1753.  
  1754. public void setHitUpdateRequired(boolean hitUpdateRequired) {
  1755. this.hitUpdateRequired = hitUpdateRequired;
  1756. }
  1757.  
  1758. public void setHitUpdateRequired2(boolean hitUpdateRequired2) {
  1759. this.hitUpdateRequired2 = hitUpdateRequired2;
  1760. }
  1761.  
  1762.  
  1763. public boolean isHitUpdateRequired() {
  1764. return hitUpdateRequired;
  1765. }
  1766.  
  1767. public boolean getHitUpdateRequired() {
  1768. return hitUpdateRequired;
  1769. }
  1770.  
  1771. public boolean getHitUpdateRequired2() {
  1772. return hitUpdateRequired2;
  1773. }
  1774.  
  1775.  
  1776. public void setAppearanceUpdateRequired(boolean appearanceUpdateRequired) {
  1777. this.appearanceUpdateRequired = appearanceUpdateRequired;
  1778. }
  1779.  
  1780.  
  1781. public boolean isAppearanceUpdateRequired() {
  1782. return appearanceUpdateRequired;
  1783. }
  1784.  
  1785.  
  1786. public void setChatTextEffects(int chatTextEffects) {
  1787. this.chatTextEffects = chatTextEffects;
  1788. }
  1789.  
  1790.  
  1791. public int getChatTextEffects() {
  1792. return chatTextEffects;
  1793. }
  1794.  
  1795.  
  1796. public void setChatTextSize(byte chatTextSize) {
  1797. this.chatTextSize = chatTextSize;
  1798. }
  1799.  
  1800.  
  1801. public byte getChatTextSize() {
  1802. return chatTextSize;
  1803. }
  1804.  
  1805.  
  1806. public void setChatTextUpdateRequired(boolean chatTextUpdateRequired) {
  1807. this.chatTextUpdateRequired = chatTextUpdateRequired;
  1808. }
  1809.  
  1810.  
  1811. public boolean isChatTextUpdateRequired() {
  1812. return chatTextUpdateRequired;
  1813. }
  1814.  
  1815.  
  1816. public void setChatText(byte chatText[]) {
  1817. this.chatText = chatText;
  1818. }
  1819.  
  1820.  
  1821. public byte[] getChatText() {
  1822. return chatText;
  1823. }
  1824.  
  1825.  
  1826. public void setChatTextColor(int chatTextColor) {
  1827. this.chatTextColor = chatTextColor;
  1828. }
  1829.  
  1830.  
  1831. public int getChatTextColor() {
  1832. return chatTextColor;
  1833. }
  1834.  
  1835.  
  1836. public void setNewWalkCmdX(int newWalkCmdX[]) {
  1837. this.newWalkCmdX = newWalkCmdX;
  1838. }
  1839.  
  1840.  
  1841. public int[] getNewWalkCmdX() {
  1842. return newWalkCmdX;
  1843. }
  1844.  
  1845.  
  1846. public void setNewWalkCmdY(int newWalkCmdY[]) {
  1847. this.newWalkCmdY = newWalkCmdY;
  1848. }
  1849.  
  1850.  
  1851. public int[] getNewWalkCmdY() {
  1852. return newWalkCmdY;
  1853. }
  1854.  
  1855.  
  1856. public void setNewWalkCmdIsRunning(boolean newWalkCmdIsRunning) {
  1857. this.newWalkCmdIsRunning = newWalkCmdIsRunning;
  1858. }
  1859.  
  1860.  
  1861. public boolean isNewWalkCmdIsRunning() {
  1862. return newWalkCmdIsRunning;
  1863. }
  1864.  
  1865. @SuppressWarnings("unused")
  1866. private ISAACRandomGen inStreamDecryption = null, outStreamDecryption = null;
  1867.  
  1868. public void setInStreamDecryption(ISAACRandomGen inStreamDecryption) {
  1869. this.inStreamDecryption = inStreamDecryption;
  1870. }
  1871.  
  1872. public void setOutStreamDecryption(ISAACRandomGen outStreamDecryption) {
  1873. this.outStreamDecryption = outStreamDecryption;
  1874. }
  1875.  
  1876. public boolean samePlayer() {
  1877. for (int j = 0; j < PlayerHandler.players.length; j++) {
  1878. if (j == playerId)
  1879. continue;
  1880. if (PlayerHandler.players[j] != null) {
  1881. if (PlayerHandler.players[j].playerName.equalsIgnoreCase(playerName)) {
  1882. disconnected = true;
  1883. return true;
  1884. }
  1885. }
  1886. }
  1887. return false;
  1888. }
  1889.  
  1890. public void putInCombat(int attacker) {
  1891. underAttackBy = attacker;
  1892. logoutDelay = System.currentTimeMillis();
  1893. singleCombatDelay = System.currentTimeMillis();
  1894. }
  1895.  
  1896. public void dealDamage(int damage) {
  1897. if (constitution - damage < 0)
  1898. damage = constitution;
  1899. constitution -= damage;
  1900. int difference = constitution - damage;
  1901. if (difference <= maxConstitution/10 && difference > 0)
  1902. appendRedemption();
  1903. //Test
  1904. if (playerEquipment[playerShield] == 13742) { //Elysian
  1905. if (Misc.random(9) > 2) {
  1906. damage = (int)(damage * .70);
  1907. }
  1908. }
  1909. if (playerEquipment[playerShield] == 13740 && damage > 0) { //Divine
  1910. int prayerDamage = (int)(damage * .015);
  1911. if (playerLevel[5] >= prayerDamage) {
  1912. playerLevel[5] -= prayerDamage;
  1913. damage = (int)(damage * .070);
  1914. } else {
  1915. double mod = (playerLevel[5]/prayerDamage);
  1916. mod = mod * .30;
  1917. damage = (int)(damage * mod);
  1918. playerLevel[5] = 0;
  1919. }
  1920. ((Client)this).getPA().refreshSkill(5);
  1921. }
  1922. }
  1923.  
  1924. public void OmarWrath() {
  1925. Client c = (Client) PlayerHandler.players[this.playerId];
  1926. if (c.curseActive[17]) {
  1927. constitution += (int)(maxConstitution * .25);
  1928. playerLevel[5] = 0;
  1929. c.getPA().refreshSkill(3);
  1930. c.getPA().refreshSkill(5);
  1931. c.gfx100(2259);
  1932. c.startAnimation(12583);
  1933. //c2.gfx0(2260);
  1934. c.getCombat().resetPrayers();
  1935. }
  1936. }
  1937.  
  1938. public void appendRedemption() {
  1939. Client c = (Client) PlayerHandler.players[this.playerId];
  1940. if (prayerActive[22]) {
  1941. constitution += (int)(maxConstitution * .25);
  1942. playerLevel[5] = 0;
  1943. c.getPA().refreshSkill(3);
  1944. c.getPA().refreshSkill(5);
  1945. gfx0(436);
  1946. c.getCombat().resetPrayers();
  1947. }
  1948. }
  1949.  
  1950. public int[] damageTaken = new int[Config.MAX_PLAYERS];
  1951.  
  1952. public int hitMask, hitIcon, hitMask2, hitIcon2;
  1953. public void handleHitMask(int damage, int mask, int icon, int soak, boolean maxHit) {
  1954. if (!hitUpdateRequired) {
  1955. hitDiff = damage;
  1956. hitMask = maxHit ? 1 : mask;
  1957. hitIcon = icon;
  1958. soakDamage = soak;
  1959. hitUpdateRequired = true;
  1960. } else if (!hitUpdateRequired2) {
  1961. hitDiff2 = damage;
  1962. hitMask2 = maxHit ? 1 : mask;
  1963. hitIcon2 = icon;
  1964. soakDamage2 = soak;
  1965. hitUpdateRequired2 = true;
  1966. }
  1967. updateRequired = true;
  1968. }
  1969.  
  1970. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement