Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 62.53 KB | None | 0 0
  1. package server.model.players;
  2. import java.util.ArrayList;
  3. import java.util.Collection;
  4. import java.util.Collections;
  5. import java.util.LinkedList;
  6. import java.util.List;
  7. import server.Config;
  8. import server.Server;
  9. import server.model.items.Item;
  10. import server.model.npcs.NPC;
  11. import server.model.npcs.NPCHandler;
  12. import server.util.ISAACRandomGen;
  13. import server.util.Misc;
  14. import server.util.Stream;
  15. import server.util.SQL;
  16. import server.world.map.*;
  17. import java.io.*;
  18. import java.net.*;
  19.  
  20. public abstract class Player {
  21. public ArrayList<String> lastKilledPlayers = new ArrayList<String>();
  22.  
  23. public long ignores[] = new long[200];
  24. public boolean DCDamg = false;
  25. public int DCdown = 0;
  26. public int FishID;
  27. public int cookedFishID;
  28. public ArrayList<Integer> addPlayerList = new ArrayList<Integer>();
  29. public int addPlayerSize = 0;
  30. public int rangeEndGFX, boltDamage, teleotherType, playerTradeWealth, doAmount, woodcuttingTree, stageT, dfsCount, recoilHits, playerDialogue, clawDelay, previousDamage;
  31.  
  32. public boolean multiAttacking, rangeEndGFXHeight;
  33. public boolean oldSpec, stopPlayerSkill, stopPlayerPacket, usingClaws;
  34. public boolean ignoreDefence, secondFormAutocast, usingBow, usingArrows, usingOtherRangeWeapons, usingCross, magicDef, spellSwap, recoverysSet;
  35. public double crossbowDamage;
  36. public static int[] questSends = {7332,7333, 7334, 7336, 7383, 7339, 7338, 7340, 7346, 7341, 7342, 7337, 7343, 7335, 7344, 7345, 7347, 7348};
  37. public int destroyItem = 0;
  38. public int lockedEXP = 0;
  39. public int sellingId;
  40. public int sellingN;
  41. public int sellingS, playerCollect;
  42. public int playerShop[] = new int[10];
  43. public int playerShopN[] = new int[10];
  44. public int playerShopP[] = new int[10];
  45. public boolean protectItem = false;
  46. public Client myShopClient;
  47. public int pointsSpent = 0;
  48. public long lastPlant = 0;
  49. public int npcId2 = 0;
  50. public boolean isNpc;
  51. public int flowerIndex = -1;
  52. public Boolean flowerOption = false;
  53. public int CookingEmote;
  54. public boolean pkable=true;
  55. public int clawDamage = 0;
  56. public String CookFishName;
  57. public int burnFishID;
  58. public int succeslvl;
  59. public int playerKills, playerDeaths, KBDKills, CEKills, ZammyKills, BandosKills, SaradominKills, ArmyKills, VoteCount;
  60. public int xamount;
  61. public int playerMac;
  62. public int questPoints;
  63. public ArrayList<String> lastConnectedFrom = new ArrayList<String>();
  64. public long lastLogin = -1;
  65. public boolean isCooking = false;
  66. public int completedSetsMar, usedOnObjectID, usedOnobjectX, usedOnobjectY, CWPlayerIndex, TrownSpellTimer;
  67. public long joinTime = -1;
  68. public long lastVoted = -1;
  69. public boolean yellSettable = false;
  70. public long lastyell = -1;
  71. public int getOverallDP()
  72. {
  73. return SQL.totalPoints(playerName);
  74.  
  75. }
  76. public int getDL()
  77. {
  78. String[] dz1 ={""};
  79. String[] dz2 = {""};
  80. String[] dz3 = {"super nova", "pixel pirate", "acacia"};
  81. for (String s : dz1)
  82. if (playerName.equalsIgnoreCase(s))
  83. return 1;
  84. for (String s : dz2)
  85. if (playerName.equalsIgnoreCase(s))
  86. return 2;
  87. for (String s : dz3)
  88. if (playerName.equalsIgnoreCase(s))
  89. return 3;
  90.  
  91. int dp = getOverallDP();
  92. if (dp >= 50)
  93. return 3;
  94. if (dp >= 20)
  95. return 2;
  96. if (dp > 0)
  97. return 1;
  98. return 0;
  99. }
  100. public static String[] badWords = {"fuck", "bitch", "admin", "mod", "cunt", "dick", "linksbro", "linksy"};
  101. public boolean checkTitle(String s)
  102. {
  103. s = s.toLowerCase();
  104. for (String b : badWords)
  105. {
  106. if (s.contains(b))
  107. {
  108. Client c = (Client)this;
  109. c.sendMessage("Title can't contain word: "+b);
  110. return false;
  111. }
  112. }
  113. return true;
  114. }
  115. public boolean canVote()
  116. {
  117. if (lastVoted == -1)
  118. return true;
  119. else
  120. return (System.currentTimeMillis() - lastVoted <= 86400000);
  121. }
  122. public int getCurrentDP()
  123. {
  124. if (pointsSpent < 0)
  125. pointsSpent = 0;
  126. return getOverallDP() - pointsSpent;
  127.  
  128. }
  129. public boolean newPlayer()
  130. {
  131. if (joinTime == -1)
  132. return false;
  133. else
  134. return (System.currentTimeMillis() - joinTime <= 3600000);
  135. }
  136. public String getTimeLeftForNP()
  137. {
  138. long millis = System.currentTimeMillis() - joinTime;
  139. int minutes = (int) ((millis/ 1000) / 60);
  140. return "About "+(60-minutes)+" minutes left in new player protection.";
  141. }
  142. public int getTimeLeftForDXP()
  143. {
  144. Client c = (Client)this;
  145. long millis = c.xpTime - System.currentTimeMillis();
  146. if (millis < 0)
  147. return 0;
  148. int minutes = (int) ((millis/ 1000) / 60);
  149. return minutes;
  150. }
  151. /**
  152. * A list of players in this region.
  153. */
  154. public List<Player> players = new LinkedList<Player>();
  155.  
  156. public boolean isDoingSkillcapeAnim = false;
  157. public boolean hasNpc = false;
  158. public String playerClan = "None";
  159. public boolean changeTag = false;
  160. public int summonId;
  161. public boolean varrockTeleSelected = false;
  162. public boolean edgevileTeleSelected = false;
  163. public boolean faladorTeleSelected = false;
  164. public boolean catherbyTeleSelected = false;
  165. public boolean camelotTeleSelected = false;
  166. public boolean barbarianTeleSelected = false;
  167. public long lastCast = 0;
  168.  
  169. public boolean yanilleTeleSelected = false;
  170. public ArrayList <String>killedPlayers = new ArrayList<String> ();
  171. public ArrayList <Integer>attackedPlayers = new ArrayList<Integer> ();
  172.  
  173. public boolean
  174. initialized = false,
  175. disconnected = false,
  176. ruleAgreeButton = false,
  177. RebuildNPCList = false,
  178. isActive = false,
  179. isKicked = false,
  180. isSkulled = false,
  181. friendUpdate = false,
  182. newPlayer = false,
  183. hasMultiSign = false,
  184. saveCharacter = false,
  185. mouseButton = false,
  186. splitChat = false,
  187. chatEffects = true,
  188. acceptAid = false,
  189. nextDialogue = false,
  190. autocasting = false,
  191. usedSpecial = false,
  192. mageFollow = false,
  193. dbowSpec = false,
  194. craftingLeather = false,
  195. properLogout = false,
  196. secDbow = false,
  197. maxNextHit = false,
  198. ssSpec = false,
  199. vengOn = false,
  200. addStarter = false,
  201. accountFlagged = false,
  202. msbSpec = false,
  203. newCmb = false,
  204. isBanking = false
  205. ;
  206.  
  207.  
  208. public int
  209. headIconHints,
  210. pure,
  211. cwKills,
  212. cwDeaths,
  213. cwGames,
  214. saveDelay,
  215. ag1,
  216. ag2,
  217. ag3,
  218. ag4,
  219. ag5,
  220. ag6,
  221. playerKilled,
  222. pkPoints,
  223. totalPlayerDamageDealt,
  224. killedBy,
  225. lastChatId = 1,
  226. privateChat,
  227. friendSlot = 0,
  228. dialogueId,
  229. randomCoffin,
  230. newLocation,
  231. specEffect,
  232. specBarId,
  233. attackLevelReq,
  234. Donatorreq,
  235. defenceLevelReq,
  236. strengthLevelReq,
  237. rangeLevelReq,
  238. magicLevelReq,
  239. followId,
  240. skullTimer,
  241. votingPoints,
  242. nextChat = 0,
  243. talkingNpc = -1,
  244. dialogueAction = 0,
  245. autocastId,
  246. followDistance,
  247. followId2,
  248. barrageCount = 0,
  249. delayedDamage = 0,
  250. delayedDamage2 = 0,
  251. pcPoints,
  252. isDonator,
  253. WildTimer = 0,
  254. magePoints = 0,
  255. desertTreasure = 0,
  256. lastArrowUsed = -1,
  257. clanId = -1,
  258. autoRet = 0,
  259. pcDamage = 0,
  260. xInterfaceId = 0,
  261. xRemoveId = 0,
  262. xRemoveSlot = 0,
  263. tzhaarToKill = 0,
  264. tzhaarKilled = 0,
  265. waveId,
  266. frozenBy = 0,
  267. poisonDamage = 0,
  268. teleAction = 0,
  269. bonusAttack = 0,
  270. lastNpcAttacked = 0,
  271. killCount = 0,
  272. newCombat = 0;
  273. public String currentTime, date;
  274. public String clanName, properName;
  275. public int[] voidStatus = new int[5];
  276. public int[] itemKeptId = new int [4];
  277. public int[] pouches = new int[4];
  278. public final int[] POUCH_SIZE = {3,6,9,12};
  279. public boolean[] invSlot = new boolean[28], equipSlot = new boolean[14];
  280. public long friends[] = new long[200];
  281. public long lastButton;
  282. public int[] clawHit = new int[4];
  283. public double specAmount = 0;
  284. public double specAccuracy = 1;
  285. public double specDamage = 1;
  286. public double prayerPoint = 1.0;
  287. public int teleGrabItem, teleGrabX, teleGrabY, duelCount, underAttackBy, underAttackBy2, wildLevel, teleTimer, respawnTimer, saveTimer = 0, teleBlockLength, poisonDelay;
  288. 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;
  289. public boolean canChangeAppearance = false;
  290. public boolean mageAllowed;
  291. public byte poisonMask = 0;
  292.  
  293. public final int[] BOWS = {9185,839,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};
  294. public final int[] ARROWS = {882,884,886,888,890,892,4740,11212,9140,9141,4142,9143,9144,9240,9241,9242,9243,9244,9245};
  295. public final int[] NO_ARROW_DROP = {4212,4214,4215,4216,4217,4218,4219,4220,4221,4222,4223,4734,4934,4935,4936,4937};
  296. public 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};
  297.  
  298. public final int[][] MAGIC_SPELLS = {
  299. // 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}
  300.  
  301. // Modern Spells
  302. {1152,1,711,90,91,92,2,5,556,1,558,1,0,0,0,0}, //wind strike
  303. {1154,5,711,93,94,95,4,7,555,1,556,1,558,1,0,0}, // water strike
  304. {1156,9,711,96,97,98,6,9,557,2,556,1,558,1,0,0},// earth strike
  305. {1158,13,711,99,100,101,8,11,554,3,556,2,558,1,0,0}, // fire strike
  306. {1160,17,711,117,118,119,9,13,556,2,562,1,0,0,0,0}, // wind bolt
  307. {1163,23,711,120,121,122,10,16,556,2,555,2,562,1,0,0}, // water bolt
  308. {1166,29,711,123,124,125,11,20,556,2,557,3,562,1,0,0}, // earth bolt
  309. {1169,35,711,126,127,128,12,22,556,3,554,4,562,1,0,0}, // fire bolt
  310. {1172,41,711,132,133,134,13,25,556,3,560,1,0,0,0,0}, // wind blast
  311. {1175,47,711,135,136,137,14,28,556,3,555,3,560,1,0,0}, // water blast
  312. {1177,53,711,138,139,140,15,31,556,3,557,4,560,1,0,0}, // earth blast
  313. {1181,59,711,129,130,131,16,35,556,4,554,5,560,1,0,0}, // fire blast
  314. {1183,62,711,158,159,160,17,36,556,5,565,1,0,0,0,0}, // wind wave
  315. {1185,65,711,161,162,163,18,37,556,5,555,7,565,1,0,0}, // water wave
  316. {1188,70,711,164,165,166,19,40,556,5,557,7,565,1,0,0}, // earth wave
  317. {1189,75,711,155,156,157,20,42,556,5,554,7,565,1,0,0}, // fire wave
  318. {1153,3,716,102,103,104,0,13,555,3,557,2,559,1,0,0}, // confuse
  319. {1157,11,716,105,106,107,0,20,555,3,557,2,559,1,0,0}, // weaken
  320. {1161,19,716,108,109,110,0,29,555,2,557,3,559,1,0,0}, // curse
  321. {1542,66,729,167,168,169,0,76,557,5,555,5,566,1,0,0}, // vulnerability
  322. {1543,73,729,170,171,172,0,83,557,8,555,8,566,1,0,0}, // enfeeble
  323. {1562,80,729,173,174,107,0,90,557,12,555,12,556,1,0,0}, // stun
  324. {1572,20,711,177,178,181,0,30,557,3,555,3,561,2,0,0}, // bind
  325. {1582,50,711,177,178,180,2,60,557,4,555,4,561,3,0,0}, // snare
  326. {1592,79,711,177,178,179,4,90,557,5,555,5,561,4,0,0}, // entangle
  327. {1171,39,724,145,146,147,15,25,556,2,557,2,562,1,0,0}, // crumble undead
  328. {1539,50,708,87,88,89,25,42,554,5,560,1,0,0,0,0}, // iban blast
  329. {12037,50,1576,327,328,329,19,30,560,1,558,4,0,0,0,0}, // magic dart
  330. {1190,60,811,0,0,76,20,60,554,2,565,2,556,4,0,0}, // sara strike
  331. {1191,60,811,0,0,77,20,60,554,1,565,2,556,4,0,0}, // cause of guthix
  332. {1192,60,811,0,0,78,20,60,554,4,565,2,556,1,0,0}, // flames of zammy
  333. {12445,85,1819,0,344,345,0,65,563,1,562,1,560,1,0,0}, // teleblock
  334.  
  335. // Ancient Spells
  336. {12939,50,1978,0,384,385,13,30,560,2,562,2,554,1,556,1}, // smoke rush
  337. {12987,52,1978,0,378,379,14,31,560,2,562,2,566,1,556,1}, // shadow rush
  338. {12901,56,1978,0,0,373,15,33,560,2,562,2,565,1,0,0}, // blood rush
  339. {12861,58,1978,0,360,361,16,34,560,2,562,2,555,2,0,0}, // ice rush
  340. {12963,62,1979,0,0,389,19,36,560,2,562,4,556,2,554,2}, // smoke burst
  341. {13011,64,1979,0,0,382,20,37,560,2,562,4,556,2,566,2}, // shadow burst
  342. {12919,68,1979,0,0,376,21,39,560,2,562,4,565,2,0,0}, // blood burst
  343. {12881,70,1979,0,0,363,22,40,560,2,562,4,555,4,0,0}, // ice burst
  344. {12951,74,1978,0,386,387,23,42,560,2,554,2,565,2,556,2}, // smoke blitz
  345. {12999,76,1978,0,380,381,24,43,560,2,565,2,556,2,566,2}, // shadow blitz
  346. {12911,80,1978,0,374,375,25,45,560,2,565,4,0,0,0,0}, // blood blitz
  347. {12871,82,1978,366,0,367,26,46,560,2,565,2,555,3,0,0}, // ice blitz
  348. {12975,86,1979,0,0,391,27,48,560,4,565,2,556,4,554,4}, // smoke barrage
  349. {13023,88,1979,0,0,383,28,49,560,4,565,2,556,4,566,3}, // shadow barrage
  350. {12929,92,1979,0,0,377,29,51,560,4,565,4,566,1,0,0}, // blood barrage
  351. {12891,94,1979,0,0,369,30,52,560,4,565,2,555,6,0,0}, // ice barrage
  352.  
  353. {-1,80,811,301,0,0,0,0,554,3,565,3,556,3,0,0}, // charge
  354. {-1,21,712,112,0,0,0,10,554,3,561,1,0,0,0,0}, // low alch
  355. {-1,55,713,113,0,0,0,20,554,5,561,1,0,0,0,0}, // high alch
  356. {-1,33,728,142,143,144,0,35,556,1,563,1,0,0,0,0} // telegrab
  357.  
  358. };
  359.  
  360. public boolean withinInteractionDistance(int x, int y, int z) {
  361. if (heightLevel != z)
  362. return false;
  363. Client c = (Client)this;
  364. int deltaX = x - c.getX(), deltaY = y - c.getY();
  365. return deltaX <= 4 && deltaX >= -4 && deltaY <= 4 && deltaY >= -4;
  366. }
  367.  
  368. public boolean isAutoButton(int button) {
  369. for (int j = 0; j < autocastIds.length; j += 2) {
  370. if (autocastIds[j] == button)
  371. return true;
  372. }
  373. return false;
  374. }
  375.  
  376. 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,
  377. 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,
  378. 47019,27,47020,25,47021,12,47022,13,47023,14,47024,15};
  379.  
  380. //public String spellName = "Select Spell";
  381. public void assignAutocast(int button) {
  382. for (int j = 0; j < autocastIds.length; j++) {
  383. if (autocastIds[j] == button) {
  384. Client c = (Client) Server.playerHandler.players[this.playerId];
  385. autocasting = true;
  386. autocastId = autocastIds[j+1];
  387. c.getPA().sendFrame36(108, 1);
  388. c.setSidebarInterface(0, 328);
  389. //spellName = getSpellName(autocastId);
  390. //spellName = spellName;
  391. //c.getPA().sendFrame126(spellName, 354);
  392. c = null;
  393. break;
  394. }
  395. }
  396. }
  397.  
  398. public String getSpellName(int id) {
  399. switch (id) {
  400. case 0: return "Air Strike";
  401. case 1: return "Water Strike";
  402. case 2: return "Earth Strike";
  403. case 3: return "Fire Strike";
  404. case 4: return "Air Bolt";
  405. case 5: return "Water Bolt";
  406. case 6: return "Earth Bolt";
  407. case 7: return "Fire Bolt";
  408. case 8: return "Air Blast";
  409. case 9: return "Water Blast";
  410. case 10: return "Earth Blast";
  411. case 11: return "Fire Blast";
  412. case 12: return "Air Wave";
  413. case 13: return "Water Wave";
  414. case 14: return "Earth Wave";
  415. case 15: return "Fire Wave";
  416. case 32: return "Shadow Rush";
  417. case 33: return "Smoke Rush";
  418. case 34: return "Blood Rush";
  419. case 35: return "Ice Rush";
  420. case 36: return "Shadow Burst";
  421. case 37: return "Smoke Burst";
  422. case 38: return "Blood Burst";
  423. case 39: return "Ice Burst";
  424. case 40: return "Shadow Blitz";
  425. case 41: return "Smoke Blitz";
  426. case 42: return "Blood Blitz";
  427. case 43: return "Ice Blitz";
  428. case 44: return "Shadow Barrage";
  429. case 45: return "Smoke Barrage";
  430. case 46: return "Blood Barrage";
  431. case 47: return "Ice Barrage";
  432. default:
  433. return "Select Spell";
  434. }
  435. }
  436.  
  437. public boolean fullVoidRange() {
  438. return playerEquipment[playerHat] == 11664 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
  439. }
  440.  
  441. public boolean fullVoidMage() {
  442. return playerEquipment[playerHat] == 11663 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
  443. }
  444.  
  445. public boolean fullVoidMelee() {
  446. return playerEquipment[playerHat] == 11665 && playerEquipment[playerLegs] == 8840 && playerEquipment[playerChest] == 8839 && playerEquipment[playerHands] == 8842;
  447. }
  448.  
  449. public int[][] barrowsNpcs = {
  450. {2030, 0}, //verac
  451. {2029, 0}, //toarg
  452. {2028, 0}, // karil
  453. {2027, 0}, // guthan
  454. {2026, 0}, // dharok
  455. {2025, 0} // ahrim
  456. };
  457. public int barrowsKillCount;
  458.  
  459. public int reduceSpellId;
  460. public final int[] REDUCE_SPELL_TIME = {250000, 250000, 250000, 500000,500000,500000}; // how long does the other player stay immune to the spell
  461. public long[] reduceSpellDelay = new long[6];
  462. public final int[] REDUCE_SPELLS = {1153,1157,1161,1542,1543,1562};
  463. public boolean[] canUseReducingSpell = {true, true, true, true, true, true};
  464.  
  465. public int slayerTask,taskAmount;
  466.  
  467. public int prayerId = -1;
  468. public int headIcon = -1;
  469. public int bountyIcon = 0;
  470. public long stopPrayerDelay, prayerDelay;
  471. public boolean usingPrayer;
  472. public final int[] PRAYER_DRAIN_RATE = {500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500};
  473. public final int[] PRAYER_LEVEL_REQUIRED = {1,4,7,8,9,10,13,16,19,22,25,26,27,28,31,34,37,40,43,44,45,46,49,52,70,95};
  474. public final int[] PRAYER = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25};
  475. public final String[] PRAYER_NAME = {"Thick Skin", "Burst of Strength", "Clarity of Thought", "Sharp Eye", "Mystic Will", "Rock Skin", "Superhuman Strength", "Improved Reflexes","Rapid Restore",
  476. "Rapid Heal", "Protect Item", "Hawk Eye", "Mystic Lore", "Steel Skin", "Ultimate Strength", "Incredible Reflexes","Protect from Magic", "Protect from Missiles",
  477. "Protect from Melee","Eagle Eye", "Mystic Might", "Retribution", "Redemption", "Smite", "Piety", "Turmoil"};
  478. public final int[] PRAYER_GLOW = {83,84,85,601,602,86,87,88,89,90,91,603,604,92,93,94,95,96,97,605,606,98,99,100,607,608};
  479. public final int[] PRAYER_HEAD_ICONS = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,1,0,-1,-1,3,5,4,-1,-1};
  480. //{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,1,4,6,5};
  481.  
  482. 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};
  483.  
  484. public int duelTimer, duelTeleX, duelTeleY, duelSlot, duelSpaceReq, duelOption, duelingWith, duelStatus;
  485. public int headIconPk = -1, headIconhint;
  486. public int headIconPray = 0;
  487. public boolean duelRequested;
  488. public boolean[] duelRule = new boolean[22];
  489. 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};
  490.  
  491. public boolean doubleHit, usingSpecial, npcDroppingItems, usingRangeWeapon, usingMagic, castingMagic;
  492. 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;
  493. public boolean magicFailed, oldMagicFailed;
  494. public int bowSpecShot, clickNpcType, clickObjectType, objectId, objectX, objectY, objectXOffset, objectYOffset, objectDistance;
  495. public int pItemX, pItemY, pItemId;
  496. public boolean isMoving, walkingToItem;
  497. public boolean isShopping, updateShop;
  498. public int myShopId;
  499. public int tradeStatus, tradeWith;
  500. public boolean forcedChatUpdateRequired, inDuel, tradeAccepted, goodTrade, inTrade, tradeRequested, tradeResetNeeded, tradeConfirmed, tradeConfirmed2, canOffer, acceptTrade, acceptedTrade;
  501. public int attackAnim, animationRequest = -1,animationWaitCycles;
  502. public int[] playerBonus = new int[12];
  503. public boolean isRunning2 = true;
  504. public boolean takeAsNote;
  505. public int combatLevel;
  506. public boolean saveFile = false;
  507. public int playerAppearance[] = new int[13];
  508. public int apset;
  509. public int actionID;
  510. public int wearItemTimer, wearId, wearSlot, interfaceId;
  511. public int XremoveSlot, XinterfaceID, XremoveID, Xamount;
  512.  
  513. public int tutorial = 15;
  514. public boolean usingGlory = false;
  515. public int[] woodcut = new int [3];
  516. public int wcTimer = 0;
  517. public int[] mining = new int [3];
  518. public int miningTimer = 0;
  519. public boolean fishing = false;
  520. public int fishTimer = 0;
  521. public int smeltType; //1 = bronze, 2 = iron, 3 = steel, 4 = gold, 5 = mith, 6 = addy, 7 = rune
  522. public int smeltAmount;
  523. public int smeltTimer = 0;
  524. public boolean smeltInterface;
  525. public boolean patchCleared;
  526. public int[] farm = new int[2];
  527.  
  528.  
  529. public boolean antiFirePot = false;
  530.  
  531. /**
  532. * Castle Wars
  533. */
  534. public int castleWarsTeam;
  535. public boolean inCwGame;
  536. public boolean inCwWait;
  537.  
  538. /**
  539. * Fight Pits
  540. */
  541. public boolean inPits = false;
  542. public int pitsStatus = 0;
  543.  
  544. /**
  545. * SouthWest, NorthEast, SouthWest, NorthEast
  546. */
  547.  
  548. public boolean isInTut() {
  549. if(absX >= 2625 && absX <= 2687 && absY >= 4670 && absY <= 4735) {
  550. return true;
  551. }
  552. return false;
  553. }
  554.  
  555. public boolean inBarrows() {
  556. if(absX > 3520 && absX < 3598 && absY > 9653 && absY < 9750) {
  557. return true;
  558. }
  559. return false;
  560. }
  561.  
  562.  
  563. public boolean inArea(int x, int y, int x1, int y1) {
  564. if (absX > x && absX < x1 && absY < y && absY > y1) {
  565. return true;
  566. }
  567. return false;
  568. }
  569.  
  570. public boolean inWild() {
  571. if(absX > 2941 && absX < 3392 && absY > 3518 && absY < 3966 ||
  572. absX > 2941 && absX < 3392 && absY > 9918 && absY < 10366){
  573. return true;
  574. }
  575. return false;
  576. }
  577. public boolean isInArd() {
  578. if(absX > 2583 && absX < 2729 && absY > 3255 && absY < 3343) {
  579. //return true;
  580. }
  581. return false;
  582. }
  583. public boolean isInFala() {
  584. if(absX > 2941 && absX < 3060 && absY > 3314 && absY < 3399) {
  585. //return true;
  586. }
  587. return false;
  588. }
  589. public boolean isInEdge() {
  590. if(absX > 3084 && absX < 3111 && absY > 3483 && absY < 3509) {
  591. return true;
  592. }
  593. return false;
  594. }
  595.  
  596. public boolean safeZone() {
  597. if(absX > 2943 && absX < 2949 && absY > 3358 && absY < 3374 || absX > 3009 && absX < 3018 && absY > 3355 && absY < 3359 || absX > 2612 && absX < 2622 && absY > 3330 && absY < 3335 || absX > 2648 && absX < 2658 && absY > 3279 && absY < 3287) {
  598. return true;
  599. }
  600. return false;
  601. }
  602.  
  603.  
  604. public boolean arenas() {
  605. if(absX > 3331 && absX < 3391 && absY > 3242 && absY < 3260) {
  606. return true;
  607. }
  608. return false;
  609. }
  610.  
  611. public boolean inDuelArena() {
  612. if((absX > 3322 && absX < 3394 && absY > 3195 && absY < 3291) ||
  613. (absX > 3311 && absX < 3323 && absY > 3223 && absY < 3248)) {
  614. return true;
  615. }
  616. return false;
  617. }
  618.  
  619. public boolean inMulti() {
  620. if((absX >= 3136 && absX <= 3327 && absY >= 3519 && absY <= 3607) ||
  621. (absX >= 2607 && absX <= 2644 && absY >= 3296 && absY <= 3332) ||
  622. (absX >= 2949 && absX <= 3001 && absY >= 3370 && absY <= 3392) ||
  623. (absX >= 3250 && absX <= 3342 && absY >= 9800 && absY <= 9870) ||
  624. (absX >= 3190 && absX <= 3327 && absY >= 3648 && absY <= 3839) ||
  625. (absX >= 3200 && absX <= 3390 && absY >= 3840 && absY <= 3967) ||
  626. (absX >= 2992 && absX <= 3007 && absY >= 3912 && absY <= 3967) ||
  627. (absX >= 2946 && absX <= 2959 && absY >= 3816 && absY <= 3831) ||
  628. (absX >= 3008 && absX <= 3199 && absY >= 3856 && absY <= 3903) ||
  629. (absX >= 3008 && absX <= 3071 && absY >= 3600 && absY <= 3711) ||
  630. (absX >= 3072 && absX <= 3327 && absY >= 3608 && absY <= 3647) ||
  631. (absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <= 2619) ||
  632. (absX >= 2371 && absX <= 2422 && absY >= 5062 && absY <= 5117) ||
  633. (absX >= 2896 && absX <= 2927 && absY >= 3595 && absY <= 3630) ||
  634. (absX >= 2892 && absX <= 2932 && absY >= 4435 && absY <= 4464) ||
  635. (absX >= 2256 && absX <= 2287 && absY >= 4680 && absY <= 4711)) {
  636. return true;
  637. }
  638. return false;
  639. }
  640.  
  641.  
  642.  
  643. public boolean inFightCaves()
  644. {
  645. return absX >= 2360 && absX <= 2445 && absY >= 5045 && absY <= 5125;
  646. }
  647.  
  648. public boolean inPirateHouse() {
  649. return absX >= 3038 && absX <= 3044 && absY >= 3949 && absY <= 3959;
  650. }
  651.  
  652.  
  653. public String connectedFrom="";
  654. public String globalMessage="";
  655. public abstract void initialize();
  656. public abstract void update();
  657. public int playerId = -1;
  658. public String playerName = null;
  659. public String playerName2 = null;
  660. public String playerPass = null;
  661. public int playerRights;
  662. public PlayerHandler handler = null;
  663. public int playerItems[] = new int[28];
  664. public int playerItemsN[] = new int[28];
  665. public int bankItems[] = new int[Config.BANK_SIZE];
  666. public int bankItemsN[] = new int[Config.BANK_SIZE];
  667. public boolean bankNotes = false;
  668.  
  669. public int playerStandIndex = 0x328;
  670. public int playerTurnIndex = 0x337;
  671. public int playerWalkIndex = 0x333;
  672. public int playerTurn180Index = 0x334;
  673. public int playerTurn90CWIndex = 0x335;
  674. public int playerTurn90CCWIndex = 0x336;
  675. public int playerRunIndex = 0x338;
  676.  
  677. public static int playerHat = 0;
  678. public static int playerCape = 1;
  679. public static int playerAmulet = 2;
  680. public static int playerWeapon = 3;
  681. public static int playerChest = 4;
  682. public static int playerShield = 5;
  683. public static int playerLegs = 7;
  684. public static int playerHands = 9;
  685. public static int playerFeet = 10;
  686. public static int playerRing = 12;
  687. public static int playerArrows = 13;
  688.  
  689. public int playerAttack = 0;
  690. public int playerDefence = 1;
  691. public int playerStrength = 2;
  692. public int playerHitpoints = 3;
  693. public int playerRanged = 4;
  694. public int playerPrayer = 5;
  695. public int playerMagic = 6;
  696. public int playerCooking = 7;
  697. public int playerWoodcutting = 8;
  698. public int playerFletching = 9;
  699. public int playerFishing = 10;
  700. public int playerFiremaking = 11;
  701. public int playerCrafting = 12;
  702. public int playerSmithing = 13;
  703. public int playerMining = 14;
  704. public int playerHerblore = 15;
  705. public int playerAgility = 16;
  706. public int playerThieving = 17;
  707. public int playerSlayer = 18;
  708. public int playerFarming = 19;
  709. public int playerRunecrafting = 20;
  710.  
  711. public int[] playerEquipment = new int[14];
  712. public int[] playerEquipmentN = new int[14];
  713. public int[] playerLevel = new int[25];
  714. public int[] playerXP = new int[25];
  715.  
  716. public void updateshop(int i){
  717. Client p = (Client) Server.playerHandler.players[playerId];
  718. p.getShops().resetShop(i);
  719. }
  720.  
  721. public void println_debug(String str) {
  722. System.out.println("[player-"+playerId+"]: "+str);
  723. }
  724. public void println(String str) {
  725. System.out.println("[player-"+playerId+"]: "+str);
  726. }
  727. public Player(int _playerId) {
  728. playerId = _playerId;
  729. playerRights = 0;
  730.  
  731. for (int i=0; i<playerItems.length; i++) {
  732. playerItems[i] = 0;
  733. }
  734. for (int i=0; i<playerItemsN.length; i++) {
  735. playerItemsN[i] = 0;
  736. }
  737.  
  738. for (int i=0; i<playerLevel.length; i++) {
  739. if (i == 3) {
  740. playerLevel[i] = 10;
  741. } else {
  742. playerLevel[i] = 1;
  743. }
  744. }
  745.  
  746. for (int i=0; i<playerXP.length; i++) {
  747. if (i == 3) {
  748. playerXP[i] = 1300;
  749. } else {
  750. playerXP[i] = 0;
  751. }
  752. }
  753. for (int i=0; i < Config.BANK_SIZE; i++) {
  754. bankItems[i] = 0;
  755. }
  756.  
  757. for (int i=0; i < Config.BANK_SIZE; i++) {
  758. bankItemsN[i] = 0;
  759. }
  760.  
  761. playerAppearance[0] = 0; // gender
  762. playerAppearance[1] = 7; // head
  763. playerAppearance[2] = 25;// Torso
  764. playerAppearance[3] = 29; // arms
  765. playerAppearance[4] = 35; // hands
  766. playerAppearance[5] = 39; // legs
  767. playerAppearance[6] = 44; // feet
  768. playerAppearance[7] = 14; // beard
  769. playerAppearance[8] = 7; // hair colour
  770. playerAppearance[9] = 8; // torso colour
  771. playerAppearance[10] = 9; // legs colour
  772. playerAppearance[11] = 5; // feet colour
  773. playerAppearance[12] = 0; // skin colour
  774.  
  775. apset = 0;
  776. actionID = 0;
  777.  
  778. playerEquipment[playerHat]=-1;
  779. playerEquipment[playerCape]=-1;
  780. playerEquipment[playerAmulet]=-1;
  781. playerEquipment[playerChest]=-1;
  782. playerEquipment[playerShield]=-1;
  783. playerEquipment[playerLegs]=-1;
  784. playerEquipment[playerHands]=-1;
  785. playerEquipment[playerFeet]=-1;
  786. playerEquipment[playerRing]=-1;
  787. playerEquipment[playerArrows]=-1;
  788. playerEquipment[playerWeapon]=-1;
  789.  
  790. heightLevel = 0;
  791.  
  792. teleportToX = Config.START_LOCATION_X;
  793. teleportToY = Config.START_LOCATION_Y;
  794.  
  795.  
  796. absX = absY = -1;
  797. mapRegionX = mapRegionY = -1;
  798. currentX = currentY = 0;
  799. resetWalkingQueue();
  800. }
  801.  
  802. void destruct() {
  803. playerListSize = 0;
  804. for(int i = 0; i < maxPlayerListSize; i++)
  805. playerList[i] = null;
  806. absX = absY = -1;
  807. mapRegionX = mapRegionY = -1;
  808. currentX = currentY = 0;
  809. resetWalkingQueue();
  810. }
  811.  
  812.  
  813. public static final int maxPlayerListSize = Config.MAX_PLAYERS;
  814. public Player playerList[] = new Player[maxPlayerListSize];
  815. public int playerListSize = 0;
  816.  
  817.  
  818. public byte playerInListBitmap[] = new byte[(Config.MAX_PLAYERS+7) >> 3];
  819.  
  820.  
  821. public static final int maxNPCListSize = NPCHandler.maxNPCs;
  822. public NPC npcList[] = new NPC[maxNPCListSize];
  823. public int npcListSize = 0;
  824.  
  825. public byte npcInListBitmap[] = new byte[(NPCHandler.maxNPCs+7) >> 3];
  826.  
  827.  
  828.  
  829. public boolean withinDistance(Player otherPlr) {
  830. if(heightLevel != otherPlr.heightLevel) return false;
  831. int deltaX = otherPlr.absX-absX, deltaY = otherPlr.absY-absY;
  832. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  833. }
  834.  
  835. public boolean withinDistance(NPC npc) {
  836. if (heightLevel != npc.heightLevel) return false;
  837. if (npc.needRespawn == true) return false;
  838. int deltaX = npc.absX-absX, deltaY = npc.absY-absY;
  839. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  840. }
  841.  
  842. public int distanceToPoint(int pointX,int pointY) {
  843. return (int) Math.sqrt(Math.pow(absX - pointX, 2) + Math.pow(absY - pointY, 2));
  844. }
  845.  
  846. public int mapRegionX, mapRegionY;
  847. public int absX, absY;
  848. public int currentX, currentY;
  849.  
  850. public int heightLevel;
  851. public int playerSE = 0x328;
  852. public int playerSEW = 0x333;
  853. public int playerSER = 0x334;
  854.  
  855. public boolean updateRequired = true;
  856.  
  857.  
  858. public final int walkingQueueSize = 50;
  859. public int walkingQueueX[] = new int[walkingQueueSize], walkingQueueY[] = new int[walkingQueueSize];
  860. public int wQueueReadPtr = 0;
  861. public int wQueueWritePtr = 0;
  862. public boolean isRunning = true;
  863. public int teleportToX = -1, teleportToY = -1;
  864.  
  865. public void resetWalkingQueue() {
  866. wQueueReadPtr = wQueueWritePtr = 0;
  867.  
  868. for(int i = 0; i < walkingQueueSize; i++) {
  869. walkingQueueX[i] = currentX;
  870. walkingQueueY[i] = currentY;
  871. }
  872. }
  873.  
  874. public void addToWalkingQueue(int x, int y) {
  875. //if (VirtualWorld.I(heightLevel, absX, absY, x, y, 0)) {
  876. int next = (wQueueWritePtr+1) % walkingQueueSize;
  877. if(next == wQueueWritePtr) return;
  878. walkingQueueX[wQueueWritePtr] = x;
  879. walkingQueueY[wQueueWritePtr] = y;
  880. wQueueWritePtr = next;
  881. //}
  882. }
  883.  
  884. public boolean goodDistance(int objectX, int objectY, int playerX, int playerY, int distance) {
  885. for (int i = 0; i <= distance; i++) {
  886. for (int j = 0; j <= distance; j++) {
  887. if ((objectX + i) == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  888. return true;
  889. } else if ((objectX - i) == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  890. return true;
  891. } else if (objectX == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  892. return true;
  893. }
  894. }
  895. }
  896. return false;
  897. }
  898.  
  899. public int getNextWalkingDirection() {
  900. if(wQueueReadPtr == wQueueWritePtr)
  901. return -1;
  902. int dir;
  903. do {
  904. dir = Misc.direction(currentX, currentY, walkingQueueX[wQueueReadPtr], walkingQueueY[wQueueReadPtr]);
  905. if(dir == -1) {
  906. wQueueReadPtr = (wQueueReadPtr+1) % walkingQueueSize;
  907. } else if((dir&1) != 0) {
  908. println_debug("Invalid waypoint in walking queue!");
  909. resetWalkingQueue();
  910. return -1;
  911. }
  912. } while((dir == -1) && (wQueueReadPtr != wQueueWritePtr));
  913. if(dir == -1) return -1;
  914. dir >>= 1;
  915. currentX += Misc.directionDeltaX[dir];
  916. currentY += Misc.directionDeltaY[dir];
  917. absX += Misc.directionDeltaX[dir];
  918. absY += Misc.directionDeltaY[dir];
  919. return dir;
  920. }
  921.  
  922.  
  923. public boolean didTeleport = false;
  924. public boolean mapRegionDidChange = false;
  925. public int dir1 = -1, dir2 = -1;
  926. public boolean createItems = false;
  927. public int poimiX = 0, poimiY = 0;
  928.  
  929. public void getNextPlayerMovement() {
  930. mapRegionDidChange = false;
  931. didTeleport = false;
  932. dir1 = dir2 = -1;
  933.  
  934. if(teleportToX != -1 && teleportToY != -1) {
  935. mapRegionDidChange = true;
  936. if(mapRegionX != -1 && mapRegionY != -1) {
  937. int relX = teleportToX-mapRegionX*8, relY = teleportToY-mapRegionY*8;
  938. if(relX >= 2*8 && relX < 11*8 && relY >= 2*8 && relY < 11*8)
  939. mapRegionDidChange = false;
  940. }
  941. if(mapRegionDidChange) {
  942. mapRegionX = (teleportToX>>3)-6;
  943. mapRegionY = (teleportToY>>3)-6;
  944. }
  945. currentX = teleportToX - 8*mapRegionX;
  946. currentY = teleportToY - 8*mapRegionY;
  947. absX = teleportToX;
  948. absY = teleportToY;
  949. resetWalkingQueue();
  950.  
  951. teleportToX = teleportToY = -1;
  952. didTeleport = true;
  953. updateVisiblePlayers();
  954. } else {
  955. dir1 = getNextWalkingDirection();
  956. if(dir1 == -1)
  957. return;
  958. if(isRunning) {
  959. dir2 = getNextWalkingDirection();
  960. }
  961. Client c = (Client)this;
  962. //c.sendMessage("Cycle Ended");
  963. int deltaX = 0, deltaY = 0;
  964. if(currentX < 2*8) {
  965. deltaX = 4*8;
  966. mapRegionX -= 4;
  967. mapRegionDidChange = true;
  968. } else if(currentX >= 11*8) {
  969. deltaX = -4*8;
  970. mapRegionX += 4;
  971. mapRegionDidChange = true;
  972. }
  973. if(currentY < 2*8) {
  974. deltaY = 4*8;
  975. mapRegionY -= 4;
  976. mapRegionDidChange = true;
  977. } else if(currentY >= 11*8) {
  978. deltaY = -4*8;
  979. mapRegionY += 4;
  980. mapRegionDidChange = true;
  981. }
  982. if (dir1 != -1 || dir2 != -1)
  983. {
  984. updateVisiblePlayers();
  985. }
  986.  
  987. if(mapRegionDidChange/* && VirtualWorld.I(heightLevel, currentX, currentY, currentX + deltaX, currentY + deltaY, 0)*/) {
  988. currentX += deltaX;
  989. currentY += deltaY;
  990. for(int i = 0; i < walkingQueueSize; i++) {
  991. walkingQueueX[i] += deltaX;
  992. walkingQueueY[i] += deltaY;
  993. }
  994. }
  995. //CoordAssistant.processCoords(this);
  996.  
  997. }
  998. }
  999.  
  1000. public void updateVisiblePlayers()
  1001. {
  1002. for(int i = 0; i < Config.MAX_PLAYERS; i++)
  1003. {
  1004. if(Server.playerHandler.players[i] == null || !Server.playerHandler.players[i].isActive || Server.playerHandler.players[i] == this)
  1005. continue;
  1006.  
  1007. int id = Server.playerHandler.players[i].playerId;
  1008.  
  1009. if ((playerInListBitmap[id >> 3] & (1 << (id & 7))) != 0)
  1010. {
  1011. continue;
  1012. }
  1013.  
  1014. if(!withinDistance(Server.playerHandler.players[i])
  1015. || addPlayerList.contains(id))
  1016. {
  1017. continue;
  1018. }
  1019.  
  1020. addPlayerList.add(id);
  1021. addPlayerSize++;
  1022.  
  1023. Server.playerHandler.players[id].addPlayerList.add(playerId);
  1024. Server.playerHandler.players[id].addPlayerSize++;
  1025. }
  1026. }
  1027.  
  1028.  
  1029. public void updateThisPlayerMovement(Stream str) {
  1030. //synchronized(this) {
  1031. if(mapRegionDidChange) {
  1032. str.createFrame(73);
  1033. str.writeWordA(mapRegionX+6);
  1034. str.writeWord(mapRegionY+6);
  1035. }
  1036.  
  1037. if(didTeleport) {
  1038. str.createFrameVarSizeWord(81);
  1039. str.initBitAccess();
  1040. str.writeBits(1, 1);
  1041. str.writeBits(2, 3);
  1042. str.writeBits(2, heightLevel);
  1043. str.writeBits(1, 1);
  1044. str.writeBits(1, (updateRequired) ? 1 : 0);
  1045. str.writeBits(7, currentY);
  1046. str.writeBits(7, currentX);
  1047. return ;
  1048. }
  1049.  
  1050.  
  1051. if(dir1 == -1) {
  1052. // don't have to update the character position, because we're just standing
  1053. str.createFrameVarSizeWord(81);
  1054. str.initBitAccess();
  1055. isMoving = false;
  1056. if(updateRequired) {
  1057. // tell client there's an update block appended at the end
  1058. str.writeBits(1, 1);
  1059. str.writeBits(2, 0);
  1060. } else {
  1061. str.writeBits(1, 0);
  1062. }
  1063. if (DirectionCount < 50) {
  1064. DirectionCount++;
  1065. }
  1066. } else {
  1067. DirectionCount = 0;
  1068. str.createFrameVarSizeWord(81);
  1069. str.initBitAccess();
  1070. str.writeBits(1, 1);
  1071.  
  1072. if(dir2 == -1) {
  1073. isMoving = true;
  1074. str.writeBits(2, 1);
  1075. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  1076. if(updateRequired) str.writeBits(1, 1);
  1077. else str.writeBits(1, 0);
  1078. }
  1079. else {
  1080. isMoving = true;
  1081. str.writeBits(2, 2);
  1082. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  1083. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  1084. if(updateRequired) str.writeBits(1, 1);
  1085. else str.writeBits(1, 0);
  1086. }
  1087. }
  1088. //}
  1089. }
  1090.  
  1091.  
  1092. public void updatePlayerMovement(Stream str) {
  1093. //synchronized(this) {
  1094. if(dir1 == -1) {
  1095. if(updateRequired || isChatTextUpdateRequired()) {
  1096.  
  1097. str.writeBits(1, 1);
  1098. str.writeBits(2, 0);
  1099. }
  1100. else str.writeBits(1, 0);
  1101. }
  1102. else if(dir2 == -1) {
  1103.  
  1104. str.writeBits(1, 1);
  1105. str.writeBits(2, 1);
  1106. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  1107. str.writeBits(1, (updateRequired || isChatTextUpdateRequired()) ? 1: 0);
  1108. }
  1109. else {
  1110.  
  1111. str.writeBits(1, 1);
  1112. str.writeBits(2, 2);
  1113. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  1114. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  1115. str.writeBits(1, (updateRequired || isChatTextUpdateRequired()) ? 1: 0);
  1116. }
  1117. // }
  1118. }
  1119.  
  1120.  
  1121. public byte cachedPropertiesBitmap[] = new byte[(Config.MAX_PLAYERS+7) >> 3];
  1122.  
  1123. public void addNewNPC(NPC npc, Stream str, Stream updateBlock) {
  1124. //synchronized(this) {
  1125. int id = npc.npcId;
  1126. npcInListBitmap[id >> 3] |= 1 << (id&7);
  1127. npcList[npcListSize++] = npc;
  1128.  
  1129. str.writeBits(14, id);
  1130.  
  1131. int z = npc.absY-absY;
  1132. if(z < 0) z += 32;
  1133. str.writeBits(5, z);
  1134. z = npc.absX-absX;
  1135. if(z < 0) z += 32;
  1136. str.writeBits(5, z);
  1137.  
  1138. str.writeBits(1, 0);
  1139. str.writeBits(12, npc.npcType);
  1140.  
  1141. boolean savedUpdateRequired = npc.updateRequired;
  1142. npc.updateRequired = true;
  1143. npc.appendNPCUpdateBlock(updateBlock);
  1144. npc.updateRequired = savedUpdateRequired;
  1145. str.writeBits(1, 1);
  1146. //}
  1147. }
  1148.  
  1149. public void addNewPlayer(Player plr, Stream str, Stream updateBlock) {
  1150. //synchronized(this) {
  1151. if(playerListSize >= 79) {
  1152. return;
  1153. }
  1154. int id = plr.playerId;
  1155. playerInListBitmap[id >> 3] |= 1 << (id&7);
  1156. playerList[playerListSize++] = plr;
  1157. str.writeBits(11, id);
  1158. str.writeBits(1, 1);
  1159. boolean savedFlag = plr.isAppearanceUpdateRequired();
  1160. boolean savedUpdateRequired = plr.updateRequired;
  1161. plr.setAppearanceUpdateRequired(true);
  1162. plr.updateRequired = true;
  1163. plr.appendPlayerUpdateBlock(updateBlock);
  1164. plr.setAppearanceUpdateRequired(savedFlag);
  1165. plr.updateRequired = savedUpdateRequired;
  1166. str.writeBits(1, 1);
  1167. int z = plr.absY-absY;
  1168. if(z < 0) z += 32;
  1169. str.writeBits(5, z);
  1170. z = plr.absX-absX;
  1171. if(z < 0) z += 32;
  1172. str.writeBits(5, z);
  1173. //}
  1174. }
  1175. public void SkillcapeGfx(int gfx) {
  1176. mask100var1 = gfx;
  1177. mask100var2 = 6553600;
  1178. mask100update = true;
  1179. updateRequired = true;
  1180. }
  1181.  
  1182. public void SkillcapeAnimation(int animId) {
  1183. animationRequest = animId;
  1184. animationWaitCycles = 0;
  1185. updateRequired = true;
  1186. }
  1187. public void skillCapeEmotes(int itemId) {
  1188.  
  1189. int capes[] =
  1190. {9747, //1 atk
  1191. 9750, //2 str
  1192. 9753, //3 def
  1193. 9756, //4 rng
  1194. 9759, //5 pry
  1195. 9762, //6 mag
  1196. 9765,//7 rc
  1197. 9771,//8 agil
  1198. 9774,//9 herb
  1199. 9777,//10 theive
  1200. 9780,//11 crafting
  1201. 9783,//12 fletching
  1202. 9786,//13 slay
  1203. 9792,//14 mine
  1204. 9795,//15 smith
  1205. 9798,//16 fish
  1206. 9801,//17 cook
  1207. 9804,//18 fm
  1208. 9807,//19 wc
  1209. 9810};//20 farm
  1210. boolean cont=false;
  1211. for (int i : capes)
  1212. {
  1213. if (itemId == i || (itemId == i+1) || (itemId==9768 || itemId == 9769 || itemId == 9813))
  1214. cont=true;
  1215. }
  1216. if (!cont)
  1217. return;
  1218. int emotes[] =
  1219. {4959,//1 atk
  1220. 4981,//2 str
  1221. 4961,//3 def
  1222. 4973,//4 rng
  1223. 4979,//5 pry
  1224. 4939,//6 mag
  1225. 4947,//7 rc
  1226. 4977,//8 agil
  1227. 4969,//9 herb
  1228. 4965,//10 theive
  1229. 4949,//11 crafting
  1230. 4937,//12 fletching
  1231. 4967,//13 slay
  1232. 4941,//14 mine
  1233. 4943,//15 smith
  1234. 4951,//16 fish
  1235. 4955,//17 cook
  1236. 4975,//18 fm
  1237. 4957,//19 wc
  1238. 4963};//20 farm
  1239. int gfx[] =
  1240. {611,//1 atk
  1241. 614,//2 str
  1242. 621,//3 def
  1243. 617,//4 rng
  1244. 606,//5 pry
  1245. 599,//6 mag
  1246. 607,//7 rc
  1247. 625,//8 agil
  1248. 626,//9 herb
  1249. 623,//10 theive
  1250. 620,//11 crafting
  1251. 619,//12 fletching
  1252. 624,//13 slay
  1253. 610,//14 mine
  1254. 609,//15 smith
  1255. 616,//16 fish
  1256. 618,//17 cook
  1257. 615,//18 fm
  1258. 613,//19 nothing (wc)
  1259. 622};//20 farm
  1260. for (int i = 0; i < capes.length; i++) {
  1261. if (playerEquipment[playerCape] == capes[i] || playerEquipment[playerCape] == capes[i] + 1) {
  1262. SkillcapeAnimation(emotes[i]);
  1263. gfx0(gfx[i]);
  1264. updateRequired = true;
  1265. appearanceUpdateRequired = true;
  1266. }
  1267. }
  1268. if (playerEquipment[playerCape] == 9768
  1269. || playerEquipment[playerCape] == 9769) { //Hitpoints cape
  1270. if (playerAppearance[0] == 0) {
  1271. gfx0(612);
  1272. SkillcapeAnimation(4971);
  1273. updateRequired = true;
  1274. appearanceUpdateRequired = true;
  1275. } else
  1276. if (playerAppearance[0] == 1) {
  1277. gfx0(628);
  1278. SkillcapeAnimation(4971);
  1279. updateRequired = true;
  1280. appearanceUpdateRequired = true;
  1281. }
  1282. }
  1283. if (playerEquipment[playerCape] == 9813) { //Quest cape
  1284. gfx0(608);
  1285. SkillcapeAnimation(4945);
  1286. updateRequired = true;
  1287. appearanceUpdateRequired = true;
  1288. }
  1289. }
  1290. public int DirectionCount = 0;
  1291. public boolean appearanceUpdateRequired = true;
  1292.  
  1293. protected int hitDiff2;
  1294. private int hitDiff = 0;
  1295. protected boolean hitUpdateRequired2;
  1296. private boolean hitUpdateRequired = false;
  1297. public boolean isDead = false;
  1298.  
  1299. protected static Stream playerProps;
  1300. static {
  1301. playerProps = new Stream(new byte[100]);
  1302. }
  1303. protected void appendPlayerAppearance(Stream str) {
  1304. // synchronized(this) {
  1305. playerProps.currentOffset = 0;
  1306.  
  1307. playerProps.writeByte(playerAppearance[0]);
  1308.  
  1309. playerProps.writeByte(headIcon);
  1310. playerProps.writeByte(headIconPk);
  1311. //playerProps.writeByte(headIconHints);
  1312. //playerProps.writeByte(bountyIcon);
  1313. if (isNpc == false) {
  1314. if (playerEquipment[playerHat] > 1) {
  1315. playerProps.writeWord(0x200 + playerEquipment[playerHat]);
  1316. } else {
  1317. playerProps.writeByte(0);
  1318. }
  1319.  
  1320. if (playerEquipment[playerCape] > 1) {
  1321. playerProps.writeWord(0x200 + playerEquipment[playerCape]);
  1322. } else {
  1323. playerProps.writeByte(0);
  1324. }
  1325.  
  1326. if (playerEquipment[playerAmulet] > 1) {
  1327. playerProps.writeWord(0x200 + playerEquipment[playerAmulet]);
  1328. } else {
  1329. playerProps.writeByte(0);
  1330. }
  1331.  
  1332. if (playerEquipment[playerWeapon] > 1) {
  1333. playerProps.writeWord(0x200 + playerEquipment[playerWeapon]);
  1334. } else {
  1335. playerProps.writeByte(0);
  1336. }
  1337.  
  1338. if (playerEquipment[playerChest] > 1) {
  1339. playerProps.writeWord(0x200 + playerEquipment[playerChest]);
  1340. } else {
  1341. playerProps.writeWord(0x100+playerAppearance[2]);
  1342. }
  1343.  
  1344. if (playerEquipment[playerShield] > 1) {
  1345. playerProps.writeWord(0x200 + playerEquipment[playerShield]);
  1346. } else {
  1347. playerProps.writeByte(0);
  1348. }
  1349.  
  1350. if (!Item.isFullBody(playerEquipment[playerChest])) {
  1351. playerProps.writeWord(0x100+playerAppearance[3]);
  1352. } else {
  1353. playerProps.writeByte(0);
  1354. }
  1355.  
  1356. if (playerEquipment[playerLegs] > 1) {
  1357. playerProps.writeWord(0x200 + playerEquipment[playerLegs]);
  1358. } else {
  1359. playerProps.writeWord(0x100+playerAppearance[5]);
  1360. }
  1361.  
  1362. if (!Item.isFullHelm(playerEquipment[playerHat]) && !Item.isFullMask(playerEquipment[playerHat])) {
  1363. playerProps.writeWord(0x100 + playerAppearance[1]);
  1364. } else {
  1365. playerProps.writeByte(0);
  1366. }
  1367.  
  1368. if (playerEquipment[playerHands] > 1) {
  1369. playerProps.writeWord(0x200 + playerEquipment[playerHands]);
  1370. } else {
  1371. playerProps.writeWord(0x100+playerAppearance[4]);
  1372. }
  1373.  
  1374. if (playerEquipment[playerFeet] > 1) {
  1375. playerProps.writeWord(0x200 + playerEquipment[playerFeet]);
  1376. } else {
  1377. playerProps.writeWord(0x100+playerAppearance[6]);
  1378. }
  1379.  
  1380. if (playerAppearance[0] != 1 && !Item.isFullMask(playerEquipment[playerHat])) {
  1381. playerProps.writeWord(0x100 + playerAppearance[7]);
  1382. } else {
  1383. playerProps.writeByte(0);
  1384. }
  1385. } else {
  1386. playerProps.writeWord(-1);
  1387. playerProps.writeWord(npcId2);
  1388. }
  1389. playerProps.writeByte(playerAppearance[8]);
  1390. playerProps.writeByte(playerAppearance[9]);
  1391. playerProps.writeByte(playerAppearance[10]);
  1392. playerProps.writeByte(playerAppearance[11]);
  1393. playerProps.writeByte(playerAppearance[12]);
  1394. playerProps.writeWord(playerStandIndex); // standAnimIndex
  1395. playerProps.writeWord(playerTurnIndex); // standTurnAnimIndex
  1396. playerProps.writeWord(playerWalkIndex); // walkAnimIndex
  1397. playerProps.writeWord(playerTurn180Index); // turn180AnimIndex
  1398. playerProps.writeWord(playerTurn90CWIndex); // turn90CWAnimIndex
  1399. playerProps.writeWord(playerTurn90CCWIndex); // turn90CCWAnimIndex
  1400. playerProps.writeWord(playerRunIndex); // runAnimIndex
  1401.  
  1402. playerProps.writeQWord(Misc.playerNameToInt64(playerName));
  1403. playerProps.writeString(playerClan+"@whi@");
  1404.  
  1405. combatLevel = calculateCombatLevel();
  1406.  
  1407. playerProps.writeByte(combatLevel); // combat level
  1408. playerProps.writeWord(0);
  1409. str.writeByteC(playerProps.currentOffset);
  1410. str.writeBytes(playerProps.buffer, playerProps.currentOffset, 0);
  1411. // }
  1412. }
  1413.  
  1414.  
  1415. public int getLevelForXP(int exp) {
  1416. int points = 0;
  1417. int output = 0;
  1418.  
  1419. for (int lvl = 1; lvl <= 99; lvl++) {
  1420. points += Math.floor((double)lvl + 300.0 * Math.pow(2.0, (double)lvl / 7.0));
  1421. output = (int)Math.floor(points / 4);
  1422. if (output >= exp)
  1423. return lvl;
  1424. }
  1425. return 99;
  1426. }
  1427.  
  1428. public int calculateCombatLevel() {
  1429. int j = getLevelForXP(playerXP[playerAttack]);
  1430. int k = getLevelForXP(playerXP[playerDefence]);
  1431. int l = getLevelForXP(playerXP[playerStrength]);
  1432. int i1 = getLevelForXP(playerXP[playerHitpoints]);
  1433. int j1 = getLevelForXP(playerXP[playerPrayer]);
  1434. int k1 = getLevelForXP(playerXP[playerRanged]);
  1435. int l1 = getLevelForXP(playerXP[playerMagic]);
  1436. int combatLevel = (int) (((k + i1) + Math.floor(j1 / 2)) * 0.25D) + 1;
  1437. double d = (j + l) * 0.32500000000000001D;
  1438. double d1 = Math.floor(k1 * 1.5D) * 0.32500000000000001D;
  1439. double d2 = Math.floor(l1 * 1.5D) * 0.32500000000000001D;
  1440. if (d >= d1 && d >= d2) {
  1441. combatLevel += d;
  1442. } else if (d1 >= d && d1 >= d2) {
  1443. combatLevel += d1;
  1444. } else if (d2 >= d && d2 >= d1) {
  1445. combatLevel += d2;
  1446. }
  1447. return combatLevel;
  1448. }
  1449.  
  1450. private boolean chatTextUpdateRequired = false;
  1451. private byte chatText[] = new byte[4096];
  1452. private byte chatTextSize = 0;
  1453. private int chatTextColor = 0;
  1454. private int chatTextEffects = 0;
  1455.  
  1456. protected void appendPlayerChatText(Stream str) {
  1457. //synchronized(this) {
  1458. str.writeWordBigEndian(((getChatTextColor()&0xFF) << 8) + (getChatTextEffects()&0xFF));
  1459. str.writeByte(playerRights);
  1460. str.writeByteC(getChatTextSize());
  1461. str.writeBytes_reverse(getChatText(), getChatTextSize(), 0);
  1462. //}
  1463. }
  1464.  
  1465. public void forcedChat(String text) {
  1466. forcedText = text;
  1467. forcedChatUpdateRequired = true;
  1468. updateRequired = true;
  1469. setAppearanceUpdateRequired(true);
  1470. }
  1471. public String forcedText = "null";
  1472. public void appendForcedChat(Stream str) {
  1473. //synchronized(this) {
  1474. str.writeString(forcedText);
  1475. //}
  1476. }
  1477.  
  1478. /**
  1479. *Graphics
  1480. **/
  1481.  
  1482. public int mask100var1 = 0;
  1483. public int mask100var2 = 0;
  1484. protected boolean mask100update = false;
  1485.  
  1486. public void appendMask100Update(Stream str) {
  1487. //synchronized(this) {
  1488. str.writeWordBigEndian(mask100var1);
  1489. str.writeDWord(mask100var2);
  1490. //}
  1491. }
  1492.  
  1493. public void gfx100(int gfx) {
  1494. mask100var1 = gfx;
  1495. mask100var2 = 6553600;
  1496. mask100update = true;
  1497. updateRequired = true;
  1498. }
  1499. public void gfx0(int gfx) {
  1500. if(isDoingSkillcapeAnim) {
  1501. return;
  1502. }
  1503. mask100var1 = gfx;
  1504. mask100var2 = 65536;
  1505. mask100update = true;
  1506. updateRequired = true;
  1507. }
  1508.  
  1509. public boolean wearing2h() {
  1510. Client c = (Client)this;
  1511. String s = c.getItems().getItemName(c.playerEquipment[c.playerWeapon]);
  1512. if (s.contains("2h"))
  1513. return true;
  1514. else if (s.contains("godsword"))
  1515. return true;
  1516. return false;
  1517. }
  1518.  
  1519. /**
  1520. *Animations
  1521. **/
  1522. public void startAnimation(int animId) {
  1523. if (wearing2h() && animId == 829)
  1524. return;
  1525. animationRequest = animId;
  1526. animationWaitCycles = 0;
  1527. updateRequired = true;
  1528. }
  1529.  
  1530. public void startAnimation(int animId, int time) {
  1531. animationRequest = animId;
  1532. animationWaitCycles = time;
  1533. updateRequired = true;
  1534. }
  1535.  
  1536. public void appendAnimationRequest(Stream str) {
  1537. //synchronized(this) {
  1538. str.writeWordBigEndian((animationRequest==-1) ? 65535 : animationRequest);
  1539. str.writeByteC(animationWaitCycles);
  1540. //}
  1541. }
  1542.  
  1543. /**
  1544. *Face Update
  1545. **/
  1546.  
  1547. protected boolean faceUpdateRequired = false;
  1548. public int face = -1;
  1549. public int FocusPointX = -1, FocusPointY = -1;
  1550.  
  1551. public void faceUpdate(int index) {
  1552. face = index;
  1553. faceUpdateRequired = true;
  1554. updateRequired = true;
  1555. }
  1556.  
  1557. public void appendFaceUpdate(Stream str) {
  1558. //synchronized(this) {
  1559. str.writeWordBigEndian(face);
  1560. //}
  1561. }
  1562.  
  1563. public void turnPlayerTo(int pointX, int pointY){
  1564. FocusPointX = 2*pointX+1;
  1565. FocusPointY = 2*pointY+1;
  1566. updateRequired = true;
  1567. }
  1568.  
  1569. private void appendSetFocusDestination(Stream str) {
  1570. //synchronized(this) {
  1571. str.writeWordBigEndianA(FocusPointX);
  1572. str.writeWordBigEndian(FocusPointY);
  1573. // }
  1574. }
  1575.  
  1576. /**
  1577. *Hit Update
  1578. **/
  1579.  
  1580. protected void appendHitUpdate(Stream str) {
  1581. //synchronized(this) {
  1582. str.writeByte(getHitDiff()); // What the perseon got 'hit' for
  1583. if (poisonMask == 1) {
  1584. str.writeByteA(2);
  1585. } else if (getHitDiff() > 0) {
  1586. str.writeByteA(1); // 0: red hitting - 1: blue hitting
  1587. } else {
  1588. str.writeByteA(0); // 0: red hitting - 1: blue hitting
  1589. }
  1590. if (playerLevel[3] <= 0) {
  1591. playerLevel[3] = 0;
  1592. isDead = true;
  1593. }
  1594. str.writeByteC(playerLevel[3]); // Their current hp, for HP bar
  1595. str.writeByte(getLevelForXP(playerXP[3])); // Their max hp, for HP bar
  1596. //}
  1597. }
  1598.  
  1599.  
  1600. protected void appendHitUpdate2(Stream str) {
  1601. //synchronized(this) {
  1602. str.writeByte(hitDiff2); // What the perseon got 'hit' for
  1603. if (poisonMask == 2) {
  1604. str.writeByteS(2);
  1605. poisonMask = -1;
  1606. } else if (hitDiff2 > 0) {
  1607. str.writeByteS(1); // 0: red hitting - 1: blue hitting
  1608. } else {
  1609. str.writeByteS(0); // 0: red hitting - 1: blue hitting
  1610. }
  1611. if (playerLevel[3] <= 0) {
  1612. playerLevel[3] = 0;
  1613. isDead = true;
  1614. }
  1615. str.writeByte(playerLevel[3]); // Their current hp, for HP bar
  1616. str.writeByteC(getLevelForXP(playerXP[3])); // Their max hp, for HP bar
  1617. //}
  1618. }
  1619.  
  1620.  
  1621. public void appendPlayerUpdateBlock(Stream str){
  1622. //synchronized(this) {
  1623. if(!updateRequired && !isChatTextUpdateRequired()) return; // nothing required
  1624. Client c = (Client)this;
  1625. int updateMask = 0;
  1626. if(mask100update) {
  1627. updateMask |= 0x100;
  1628. }
  1629. if(animationRequest != -1) {
  1630. updateMask |= 8;
  1631. }
  1632. if(forcedChatUpdateRequired) {
  1633. updateMask |= 4;
  1634. }
  1635. if(isChatTextUpdateRequired()) {
  1636. updateMask |= 0x80;
  1637. }
  1638. if(isAppearanceUpdateRequired()) {
  1639. updateMask |= 0x10;
  1640. }
  1641. if(faceUpdateRequired) {
  1642. updateMask |= 1;
  1643. }
  1644. if(FocusPointX != -1) {
  1645. updateMask |= 2;
  1646. }
  1647. if (isHitUpdateRequired()) {
  1648. updateMask |= 0x20;
  1649. }
  1650.  
  1651. if(hitUpdateRequired2) {
  1652. updateMask |= 0x200;
  1653. }
  1654.  
  1655. if(updateMask >= 0x100) {
  1656. updateMask |= 0x40;
  1657. str.writeByte(updateMask & 0xFF);
  1658. str.writeByte(updateMask >> 8);
  1659. } else {
  1660. str.writeByte(updateMask);
  1661. }
  1662.  
  1663. // now writing the various update blocks itself - note that their order crucial
  1664. if(mask100update) {
  1665. appendMask100Update(str);
  1666. }
  1667. if(animationRequest != -1) {
  1668. appendAnimationRequest(str);
  1669. }
  1670. if(forcedChatUpdateRequired) {
  1671. appendForcedChat(str);
  1672. }
  1673. if(isChatTextUpdateRequired()) {
  1674. appendPlayerChatText(str);
  1675. }
  1676. if(faceUpdateRequired) {
  1677. appendFaceUpdate(str);
  1678. }
  1679. if(isAppearanceUpdateRequired()) {
  1680. appendPlayerAppearance(str);
  1681. }
  1682. if(FocusPointX != -1) {
  1683. appendSetFocusDestination(str);
  1684. }
  1685. if(isHitUpdateRequired()) {
  1686. appendHitUpdate(str);
  1687. }
  1688. if(hitUpdateRequired2) {
  1689. appendHitUpdate2(str);
  1690. }
  1691. //}
  1692. }
  1693.  
  1694. public void clearUpdateFlags(){
  1695. updateRequired = false;
  1696. setChatTextUpdateRequired(false);
  1697. setAppearanceUpdateRequired(false);
  1698. setHitUpdateRequired(false);
  1699. hitUpdateRequired2 = false;
  1700. forcedChatUpdateRequired = false;
  1701. mask100update = false;
  1702. animationRequest = -1;
  1703. FocusPointX = -1;
  1704. FocusPointY = -1;
  1705. poisonMask = -1;
  1706. faceUpdateRequired = false;
  1707. face = 65535;
  1708. }
  1709.  
  1710. public void stopMovement() {
  1711. if(teleportToX <= 0 && teleportToY <= 0) {
  1712. teleportToX = absX;
  1713. teleportToY = absY;
  1714. }
  1715. newWalkCmdSteps = 0;
  1716. getNewWalkCmdX()[0] = getNewWalkCmdY()[0] = travelBackX[0] = travelBackY[0] = 0;
  1717. getNextPlayerMovement();
  1718. }
  1719.  
  1720.  
  1721.  
  1722. public int newWalkCmdX[] = new int[walkingQueueSize];
  1723. public int newWalkCmdY[] = new int[walkingQueueSize];
  1724. public int newWalkCmdSteps = 0;
  1725. public boolean newWalkCmdIsRunning = false;
  1726. public int travelBackX[] = new int[walkingQueueSize];
  1727. public int travelBackY[] = new int[walkingQueueSize];
  1728. public int numTravelBackSteps = 0;
  1729.  
  1730. public void preProcessing() {
  1731. newWalkCmdSteps = 0;
  1732. }
  1733.  
  1734. public abstract void process();
  1735. public abstract boolean processQueuedPackets();
  1736.  
  1737. public void postProcessing() {
  1738. if(newWalkCmdSteps > 0) {
  1739. int firstX = getNewWalkCmdX()[0], firstY = getNewWalkCmdY()[0];
  1740.  
  1741. int lastDir = 0;
  1742. boolean found = false;
  1743. numTravelBackSteps = 0;
  1744. int ptr = wQueueReadPtr;
  1745. int dir = Misc.direction(currentX, currentY, firstX, firstY);
  1746. if(dir != -1 && (dir&1) != 0) {
  1747. do {
  1748. lastDir = dir;
  1749. if(--ptr < 0)
  1750. ptr = walkingQueueSize-1;
  1751.  
  1752. travelBackX[numTravelBackSteps] = walkingQueueX[ptr];
  1753. travelBackY[numTravelBackSteps++] = walkingQueueY[ptr];
  1754. dir = Misc.direction(walkingQueueX[ptr], walkingQueueY[ptr], firstX, firstY);
  1755. if(lastDir != dir) {
  1756. found = true;
  1757. break;
  1758. }
  1759.  
  1760. } while(ptr != wQueueWritePtr);
  1761. }
  1762. else found = true;
  1763.  
  1764. if(!found) println_debug("Fatal: couldn't find connection vertex! Dropping packet.");
  1765. else {
  1766. wQueueWritePtr = wQueueReadPtr;
  1767.  
  1768. addToWalkingQueue(currentX, currentY);
  1769.  
  1770. if(dir != -1 && (dir&1) != 0) {
  1771.  
  1772.  
  1773. for(int i = 0; i < numTravelBackSteps-1; i++) {
  1774. addToWalkingQueue(travelBackX[i], travelBackY[i]);
  1775. }
  1776. int wayPointX2 = travelBackX[numTravelBackSteps-1], wayPointY2 = travelBackY[numTravelBackSteps-1];
  1777. int wayPointX1, wayPointY1;
  1778. if(numTravelBackSteps == 1) {
  1779. wayPointX1 = currentX;
  1780. wayPointY1 = currentY;
  1781. }
  1782. else {
  1783. wayPointX1 = travelBackX[numTravelBackSteps-2];
  1784. wayPointY1 = travelBackY[numTravelBackSteps-2];
  1785. }
  1786.  
  1787. dir = Misc.direction(wayPointX1, wayPointY1, wayPointX2, wayPointY2);
  1788. if(dir == -1 || (dir&1) != 0) {
  1789. println_debug("Fatal: The walking queue is corrupt! wp1=("+wayPointX1+", "+wayPointY1+"), "+
  1790. "wp2=("+wayPointX2+", "+wayPointY2+")");
  1791. }
  1792. else {
  1793. dir >>= 1;
  1794. found = false;
  1795. int x = wayPointX1, y = wayPointY1;
  1796. while(x != wayPointX2 || y != wayPointY2) {
  1797. x += Misc.directionDeltaX[dir];
  1798. y += Misc.directionDeltaY[dir];
  1799. if((Misc.direction(x, y, firstX, firstY)&1) == 0) {
  1800. found = true;
  1801. break;
  1802. }
  1803. }
  1804. if(!found) {
  1805. println_debug("Fatal: Internal error: unable to determine connection vertex!"+
  1806. " wp1=("+wayPointX1+", "+wayPointY1+"), wp2=("+wayPointX2+", "+wayPointY2+"), "+
  1807. "first=("+firstX+", "+firstY+")");
  1808. }
  1809. else addToWalkingQueue(wayPointX1, wayPointY1);
  1810. }
  1811. }
  1812. else {
  1813. for(int i = 0; i < numTravelBackSteps; i++) {
  1814. addToWalkingQueue(travelBackX[i], travelBackY[i]);
  1815. }
  1816. }
  1817.  
  1818.  
  1819. for(int i = 0; i < newWalkCmdSteps; i++) {
  1820. addToWalkingQueue(getNewWalkCmdX()[i], getNewWalkCmdY()[i]);
  1821. }
  1822.  
  1823. }
  1824.  
  1825. isRunning = isNewWalkCmdIsRunning() || isRunning2;
  1826. }
  1827. }
  1828.  
  1829. public int getMapRegionX() {
  1830. return mapRegionX;
  1831. }
  1832. public int getMapRegionY() {
  1833. return mapRegionY;
  1834. }
  1835.  
  1836. public int getX() {
  1837. return absX;
  1838. }
  1839.  
  1840. public int getY() {
  1841. return absY;
  1842. }
  1843.  
  1844. public int getId() {
  1845. return playerId;
  1846. }
  1847.  
  1848. public boolean inPcBoat() {
  1849. return absX >= 2660 && absX <= 2663 && absY >= 2638 && absY <= 2643;
  1850. }
  1851.  
  1852. public boolean inPcGame() {
  1853. return absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <= 2619;
  1854. }
  1855.  
  1856.  
  1857. public void setHitDiff(int hitDiff) {
  1858. this.hitDiff = hitDiff;
  1859. }
  1860.  
  1861. public void setHitDiff2(int hitDiff2) {
  1862. this.hitDiff2 = hitDiff2;
  1863. }
  1864.  
  1865.  
  1866. public int getHitDiff() {
  1867. return hitDiff;
  1868. }
  1869.  
  1870.  
  1871. public void setHitUpdateRequired(boolean hitUpdateRequired) {
  1872. this.hitUpdateRequired = hitUpdateRequired;
  1873. }
  1874.  
  1875. public void setHitUpdateRequired2(boolean hitUpdateRequired2) {
  1876. this.hitUpdateRequired2 = hitUpdateRequired2;
  1877. }
  1878.  
  1879.  
  1880. public boolean isHitUpdateRequired() {
  1881. return hitUpdateRequired;
  1882. }
  1883.  
  1884. public boolean getHitUpdateRequired() {
  1885. return hitUpdateRequired;
  1886. }
  1887.  
  1888. public boolean getHitUpdateRequired2() {
  1889. return hitUpdateRequired2;
  1890. }
  1891.  
  1892.  
  1893. public void setAppearanceUpdateRequired(boolean appearanceUpdateRequired) {
  1894. this.appearanceUpdateRequired = appearanceUpdateRequired;
  1895. }
  1896.  
  1897.  
  1898. public boolean isAppearanceUpdateRequired() {
  1899. return appearanceUpdateRequired;
  1900. }
  1901.  
  1902.  
  1903. public void setChatTextEffects(int chatTextEffects) {
  1904. this.chatTextEffects = chatTextEffects;
  1905. }
  1906.  
  1907.  
  1908. public int getChatTextEffects() {
  1909. return chatTextEffects;
  1910. }
  1911.  
  1912.  
  1913. public void setChatTextSize(byte chatTextSize) {
  1914. this.chatTextSize = chatTextSize;
  1915. }
  1916.  
  1917.  
  1918. public byte getChatTextSize() {
  1919. return chatTextSize;
  1920. }
  1921.  
  1922.  
  1923. public void setChatTextUpdateRequired(boolean chatTextUpdateRequired) {
  1924. this.chatTextUpdateRequired = chatTextUpdateRequired;
  1925. }
  1926.  
  1927.  
  1928. public boolean isChatTextUpdateRequired() {
  1929. return chatTextUpdateRequired;
  1930. }
  1931.  
  1932.  
  1933. public void setChatText(byte chatText[]) {
  1934. this.chatText = chatText;
  1935. }
  1936.  
  1937.  
  1938. public byte[] getChatText() {
  1939. return chatText;
  1940. }
  1941.  
  1942.  
  1943. public void setChatTextColor(int chatTextColor) {
  1944. this.chatTextColor = chatTextColor;
  1945. }
  1946.  
  1947.  
  1948. public int getChatTextColor() {
  1949. return chatTextColor;
  1950. }
  1951.  
  1952.  
  1953. public void setNewWalkCmdX(int newWalkCmdX[]) {
  1954. this.newWalkCmdX = newWalkCmdX;
  1955. }
  1956.  
  1957.  
  1958. public int[] getNewWalkCmdX() {
  1959. return newWalkCmdX;
  1960. }
  1961.  
  1962.  
  1963. public void setNewWalkCmdY(int newWalkCmdY[]) {
  1964. this.newWalkCmdY = newWalkCmdY;
  1965. }
  1966.  
  1967.  
  1968. public int[] getNewWalkCmdY() {
  1969. return newWalkCmdY;
  1970. }
  1971.  
  1972.  
  1973. public void setNewWalkCmdIsRunning(boolean newWalkCmdIsRunning) {
  1974. this.newWalkCmdIsRunning = newWalkCmdIsRunning;
  1975. }
  1976.  
  1977.  
  1978. public boolean isNewWalkCmdIsRunning() {
  1979. return newWalkCmdIsRunning;
  1980. }
  1981.  
  1982. private ISAACRandomGen inStreamDecryption = null, outStreamDecryption = null;
  1983.  
  1984. public void setInStreamDecryption(ISAACRandomGen inStreamDecryption) {
  1985. this.inStreamDecryption = inStreamDecryption;
  1986. }
  1987.  
  1988. public void setOutStreamDecryption(ISAACRandomGen outStreamDecryption) {
  1989. this.outStreamDecryption = outStreamDecryption;
  1990. }
  1991.  
  1992. public boolean samePlayer() {
  1993. for (int j = 0; j < Server.playerHandler.players.length; j++) {
  1994. if (j == playerId)
  1995. continue;
  1996. if (Server.playerHandler.players[j] != null) {
  1997. if (Server.playerHandler.players[j].playerName.equalsIgnoreCase(playerName)) {
  1998. disconnected = true;
  1999. return true;
  2000. }
  2001. }
  2002. }
  2003. return false;
  2004. }
  2005.  
  2006. public void putInCombat(int attacker) {
  2007. underAttackBy = attacker;
  2008. logoutDelay = System.currentTimeMillis();
  2009. singleCombatDelay = System.currentTimeMillis();
  2010. }
  2011.  
  2012. public void dealDamage(int damage) {
  2013. if (teleTimer <= 0)
  2014. playerLevel[3] -= damage;
  2015. else {
  2016. if (hitUpdateRequired)
  2017. hitUpdateRequired = false;
  2018. if (hitUpdateRequired2)
  2019. hitUpdateRequired2 = false;
  2020. }
  2021.  
  2022. }
  2023.  
  2024. public int[] damageTaken = new int[Config.MAX_PLAYERS];
  2025.  
  2026. public void handleHitMask(int damage) {
  2027. if (!hitUpdateRequired) {
  2028. hitUpdateRequired = true;
  2029. hitDiff = damage;
  2030. } else if (!hitUpdateRequired2) {
  2031. hitUpdateRequired2 = true;
  2032. hitDiff2 = damage;
  2033. }
  2034. updateRequired = true;
  2035. }
  2036.  
  2037. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement