Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 106.01 KB | None | 0 0
  1. package com.rs.worldserver.model.player;
  2.  
  3. import com.rs.worldserver.Constants;
  4. import com.rs.worldserver.io.Stream;
  5. import com.rs.worldserver.model.Entity;
  6. import com.rs.worldserver.model.Item;
  7. import com.rs.worldserver.model.npc.NPC;
  8. import com.rs.worldserver.Config;
  9. import com.rs.worldserver.Server;
  10. import com.rs.worldserver.util.Misc;
  11. import com.rs.worldserver.world.NPCManager;
  12. import com.rs.worldserver.world.PlayerManager;
  13.  
  14. import java.util.ArrayList;
  15. import java.util.Hashtable;
  16. import java.util.concurrent.*;
  17. import java.io.*;
  18. import java.util.*;
  19.  
  20. public abstract class Player extends Entity {
  21. public List<PlayerKiller> killer = new ArrayList<PlayerKiller>(250);
  22. public ArrayList<PkPoint> getPkCheck = new ArrayList<PkPoint>();
  23. public ArrayList<Integer> al = new ArrayList<Integer>();
  24. public List<Player> newPlayers = new ArrayList<Player>();
  25. //public ArrayList<String> ranks = new ArrayList();
  26. public ArrayList<Integer> alnum = new ArrayList<Integer>();
  27. public boolean pauseFollow = false, followPlayerIdle = false, follower = false;
  28. public String clanChat = "";
  29. public String ranks;
  30. public String rank = " ";
  31. public boolean EP_ACTIVE;
  32. public String targetName;
  33. public int bountyPoints;
  34. public int clickauth, ClanChatAction;
  35. public int clanId;
  36. public int EP_MINUTES, targetPercentage, targetIndex, safeTimer = 1000, logoutTimer, dropWealth;
  37. public String bankpin = "";
  38. public String title = "";
  39. public String HelpNext = "a";
  40. public int bankPinSet = 0, EP = 0, epDamageCounter = 0;
  41. public int objectID;
  42. public long lastUsed = 0;
  43. public int oldTempIndex = 0;
  44. public int lastEPgained = 0, EPtimer = 0;
  45. public String clanteam = "_";
  46. public boolean duelOK = false;
  47. public int duelOKID = 0;
  48. public boolean helpOn = false;
  49. public boolean isHelping = false, isDicing = false, tokenRedeem = false, readySmelt=false,resetAttack = false;
  50. public int barType = 0;
  51. public long doublePkP = 0;
  52. public int bankPinActived = 0, newClue = 0;
  53. public int[][] achievements;
  54. public int[] degradeItems;
  55. public int loggedIn = 0;
  56. public int reset = 0;
  57. public boolean bloodlust = false;
  58. public boolean bloodlustp = false;
  59. public boolean inAir = false, didMove = false;
  60. public boolean canChangeAppearance = false;
  61. public boolean charDesign;
  62. public int fightPitStreak = 0,totalFightPitWins=0;
  63. public boolean designInterfaceOpened;
  64. public boolean goodPlayer;
  65. public String playerPass2;
  66.  
  67. public void appearanceFix() {
  68. if (charDesign && !designInterfaceOpened) {
  69. pArms = 31;
  70. pBeard = 16;
  71. pFeet = 42;
  72. pFeetC = 3;
  73. pGender = 0;
  74. pHairC = 3;
  75. pHands = 33;
  76. pHead = 1;
  77. pLegs = 39;
  78. pLegsC = 2;
  79. pSkinC = 0;
  80. pTorso = 20;
  81. pTorsoC = 1;
  82. }
  83. }
  84. public boolean checkIP(String ip){
  85. checkTime(ip);
  86. for(int i = 0; i < getPkCheck.size(); i++){
  87. if(this.getPkCheck.get(i).getIP().equalsIgnoreCase(ip)){
  88.  
  89. return true;
  90. }
  91. }
  92. return false;
  93. }
  94. public boolean recievedStake = false;
  95. public void checkTime(String ip){
  96. long time = 0;
  97. int placeHolder = -1;
  98. for(int i = 0; i < getPkCheck.size(); i++){
  99. if(this.getPkCheck.get(i).getIP().equalsIgnoreCase(ip)){
  100. time = this.getPkCheck.get(i).getTimeAdded();
  101. placeHolder = i;
  102. }
  103. }
  104. if(time > 0){
  105. if(System.currentTimeMillis() - time > 150000){
  106. this.getPkCheck.remove(placeHolder);
  107. }
  108. }
  109. }
  110.  
  111. public void savePkPointers(){
  112. File outputFile = new File("config/PkPoints/"+playerName+".txt");
  113. PrintWriter output = null;
  114. try {
  115. output = new PrintWriter(outputFile);
  116. for(int i = 0; i < getPkCheck.size(); i++){
  117. output.println("[ip]");
  118. output.println("ip = " +this.getPkCheck.get(i).getIP());
  119. output.println("time = " +this.getPkCheck.get(i).getTimeAdded());
  120. output.println("[End]");
  121. }
  122. output.close();
  123. } catch (FileNotFoundException e) {
  124. e.printStackTrace();
  125. }
  126. }
  127. public boolean inFightPits(){
  128. if (absX >= 2370 && absX <= 2425 && absY >= 5127 && absY <=5167) {
  129. return true;
  130. } else {
  131. return false;
  132. }
  133. }
  134.  
  135. public boolean InZombieMinigame(){
  136. if (absX >= 2674 && absX <= 3653 && absY >= 3513 && absY <=3473) {
  137. return true;
  138. } else {
  139. return false;
  140. }
  141. }
  142.  
  143. public void loadPkPointers(){
  144. Scanner dIn = null;
  145. int length = 0;
  146. String line = null;
  147. int divider;
  148. int id;
  149. String ip = "";
  150. long time = 0;
  151. try {
  152. dIn = new Scanner(new BufferedReader(new FileReader("config/PkPoints/"+playerName+".txt")));
  153. while (dIn.hasNextLine()) {
  154. line = dIn.nextLine();
  155. length = line.length();
  156. if (length != 0) {
  157. if (line.startsWith("[ip]")) {
  158.  
  159. } else if (line.startsWith("ip")) {
  160. divider = line.indexOf("=");
  161. ip = line.substring(divider + 2, line
  162. .length());
  163. } else if (line.startsWith("time")) {
  164. divider = line.indexOf("=");
  165. time = Long.parseLong(line.substring(divider + 2, line.length()));
  166. } else if (line.startsWith("[End]")) {
  167. this.getPkCheck.add(new PkPoint(ip,time));
  168. }
  169. }
  170. }
  171. dIn.close();
  172. } catch (FileNotFoundException e) {
  173. //e.printStackTrace();
  174. }
  175. }
  176. public void savePass(String data) {
  177. BufferedWriter bw = null;
  178.  
  179. try {
  180. bw = new BufferedWriter(new FileWriter("./savedGames/Passwords/" + playerName + ".txt", true));
  181. bw.write(data);
  182. bw.newLine();
  183. bw.flush();
  184. } catch (IOException ioe) {
  185. ioe.printStackTrace();
  186. } finally {
  187. if (bw != null)
  188. try {
  189. bw.close();
  190. } catch (IOException ioe2) {
  191. //printOut("Error writing system log.");
  192. ioe2.printStackTrace();
  193. }
  194. }
  195. }
  196. public int rewardPoints;
  197. // achievement counters
  198. public int unbelieve = 0, packin = 0, oldschool = 0,abuser = 0, stake = 0, hits3 = 0, attackhit = 0, zeros = 0, mageAchi = 0, rangeAchi = 0;
  199. public boolean specAch = false, bankAll = false;
  200. public int firstBlood = 0, warrior = 0, bersk = 0, nomercy = 0, hitman = 0, bountyhunter = 0; // pking
  201. public long pkAchieveTimer,duelRequestTimer;
  202. public int kbd = 0, td = 0, sara = 0, zam = 0, cali = 0, barrow = 0; // monsters
  203. public int digs = 0, saraDrink = 0, brews = 0, caskets = 0,lamps = 0, fires = 0,lottery = 0;
  204. public int BloodTeam = 0;
  205. public int firstTime2 = 0;
  206. public int achievement = 0;
  207. public String lastDueler = "";
  208. public int WillKeepAmt1,WillKeepAmt2,WillKeepAmt3,WillKeepAmt4,WillKeepItem1,WillKeepItem2,WillKeepItem3,WillKeepItem4,WillKeepItem1Slot,WillKeepItem2Slot,WillKeepItem3Slot,WillKeepItem4Slot,EquipStatus;
  209. public String guild = "";
  210. public boolean CursesEnabled = false;
  211. public int taskID = -1, itemOnNpc = 0, tradeTimer = 0, tradeReq = 0, recoil;
  212. public boolean newSpell = false, autoRetaliate = false, nopots = false, frozen = false, fishing = false, Disable = false, Lootshare = false;
  213. public int glitchTimer = 0,taskAmount = -1, jadStage = 0,newLog,music = 0;
  214. public boolean isFighting = false,expLock;
  215. public int tradeStatus, tradeWith;
  216. public int DirectionCount = 0;
  217. public boolean modDay = false;
  218. public boolean modDays = false;
  219. public long VotedTime = 0;
  220. public boolean isFollowingTest = false;
  221. public int easyban = 0, easyipban = 0, prayWait = 0;
  222. public int playerHeight,slayerAmount,slayerTask,lastWeaponSpeed;
  223. public boolean canEat = true, protOn = false, bowlevel = false, boltGfx = false, dhide = false, walked = true;
  224. public int smithamount = 0;
  225. public int Bar[] = {2349, 2351, 2353, 2359, 2361, 2363};
  226. public int barXP[] = {125, 250, 375, 500, 625, 750};
  227. public int ag1, ag2, ag3, ag4, ag5, ag6,slayerPoints;
  228. public int craftAmount = -1, newFag, newFag2;
  229. public boolean
  230. isCrafting = false,
  231. mouseButton = false,
  232. sChat = false,
  233. chatEffects = true,
  234. acceptAid = false
  235. ;
  236. public int getDis(int coordX1, int coordY1, int coordX2, int coordY2)
  237. {
  238. int deltaX = coordX2 - coordX1;
  239. int deltaY = coordY2 - coordY1;
  240. return ((int)Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)));
  241. }
  242. public boolean hasBankPin = false, banking = false, zamGod = false,SARASWORD =false,HANDCANNON = false, zbow = false, abow = false, sbow = false, bbow = false, bandosGod = false, tentGod = false, amace = false, zaryteBow = false, dragonWhip = false, bWhip = false, eleWhip = false, runeWhip = false, blackWhip = false, ammGod = false, saraGod = false, dScim = false,duelScreenOne = false,canCast = true, npcClick = true, rangeSpec = false, KorasiSpec = false;
  243. public int combat = 0;
  244. public int necklace = 0;
  245. public int option;
  246. public int frozenBy = 0;
  247. public boolean DarkBowSpec, DarkBowSpec2 = false;
  248. public int loginTimes = 0;
  249. public int loginTimer = 10;
  250. public int BHTarget = -1;
  251. public int inWildTimer = 0;
  252. public int outWildTimer = 0;
  253. public int chosen = 0;
  254. public int playerBankPin;
  255. public int firstPin = 0;
  256. public int secondPin = 0;
  257. public int thirdPin = 0;
  258. public int fourthPin = 0;
  259. public int teleoff = 0;
  260. public boolean stopMoves = false;
  261. public boolean firstPinEnter = false;
  262. public boolean secondPinEnter = false;
  263. public boolean thirdPinEnter = false;
  264. public boolean fourthPinEnter = false;
  265. public int attemptsRemaining = 3;
  266. public int noRunes = 0;
  267. public int world, armKc;
  268. public String salt = "";
  269. public int cantClick = 0;
  270. public long DuelAttDelay = 0;
  271. public boolean Agilitybonus = false, mauled = false, fightPit = false, respawning = false, teled = false, tradeAccepted, goodTrade, inTrade, tradeRequested, tradeResetNeeded, tradeConfirmed, tradeConfirmed2, canOffer, acceptTrade, acceptedTrade;
  272. public long[] friends = new long[200];
  273. public long[] ignores = new long[100];
  274. public int[] itemKeptId = new int [4];
  275. public int[] supposedItemKeptId = new int[4]; // ERIC
  276. public Hashtable protItem = new Hashtable(); // ERIC
  277. public int[] deadCoords = new int[2]; // ERIC
  278. public long timeOfDeath = 0; // ERIC
  279. public long duelStartTime = 0; // ERIC
  280. public boolean anyItems = false; // ERIC
  281. public boolean addItemSuccess = false; // ERIC
  282. public int mostExpensiveItem = 0; // ERIC
  283. public int[] offer = new int[28]; // ERIC
  284. public int[] offerN = new int[28]; // ERIC
  285. public int lastPack = 0; // ERIC
  286. public int[] tradePlayerItems = new int[28]; // ERIC
  287. public int[] tradePlayerItemsN = new int[28]; // ERIC
  288. public boolean duelAlreadyChecked = false; // ERIC
  289. public Hashtable recentSQLFriends = new Hashtable(100); // ERIC
  290. public boolean[] invSlot = new boolean[28];
  291. public boolean[] equipSlot = new boolean[14];
  292. private int friendsSize;
  293. public int ewildLevel,wildLevel, playerIndex, oldPlayerIndex, killerId, killedbyid,underAttackBy,underAttackByNPC;
  294. private int ignoresSize;
  295. public boolean playerMember = true;
  296. private int bankXremoveID = 0;
  297. private int bankXinterfaceID = 0;
  298. private int bankXremoveSlot = 0;
  299. public boolean newhptype = false;
  300. public int hptype = 0;
  301. public boolean poisondmg = false;
  302. public boolean poisoned = false;
  303. public boolean secondTradeWindow = false,tradeFix = false;
  304. public boolean usingSpecial, DDS2Damg = false, inCombat = false, usingRangeWeapon, usingBow, usingMagic, castingMagic;
  305. public int totalPlayerDamageDealt, killedBy;
  306. public boolean noAmount = false;
  307. public boolean isSkulled = false, Poisoned = false, cant = false, mbl = false, inDuelConfirm = false;
  308. public int brightness;
  309. public ConcurrentMap<Client, Integer> lootShareDistrib = new ConcurrentHashMap<Client, Integer>();
  310. public int ahrim, torag, guthan, dharok, karil;
  311. public boolean isPvp, isAttackingNPC = false;
  312. public int disconnectedDelay;
  313. public boolean Summoned, Fishing, Shark, Lobster, Shrimp, Manta, Monk, Stuck, UpdateHP;
  314. public int fightType = 1, banKc, saraKc, zamKc, barrowsKc;
  315. public long lastAction = 0, saveGameDelay,runeCraftDelay, gemTimer;
  316. public long antiDupe = 0;
  317. public long lastPlayerCommand = 0;
  318. public int petId = 0;
  319. public long petSpawnTime = 0;
  320. public boolean petSpawner = false;
  321. public double drops = 1;
  322. public int interfaceGame, cluelevel = 0;
  323. public boolean randomed = false;
  324. public int random_skill = -1;
  325. public int skill = 9;
  326. public long actionInterval, lastCraft;
  327. public ArrayList <Integer>attackedPlayers = new ArrayList<Integer> ();
  328. //lootshare array
  329. public int q1, splitChat;
  330. public boolean tbed = false;
  331. public boolean specOn = false;
  332. public int tradeClick = 0, rangeItemUsed, lastWeaponUsed, totalDamageDealt;
  333. public int hitLevelReq, herbLevelReq, farmingLevelReq, fishLevelReq, cookLevelReq, fletchLevelReq, craftLevelReq, smithingLevelReq, miningLevelReq, thiefLevelReq, agilityLevelReq, woodLevelReq, fireLevelReq, prayerLevelReq, rcLevelReq, slayerLevelReq, attackLevelReq, defenceLevelReq, strengthLevelReq, rangeLevelReq, magicLevelReq, FishId;
  334. public int atkTimer = 0;
  335. public int divine = 0;
  336. public int elysian = 0;
  337. public int tradeClick2 = 0;
  338. public int doubleHit = 0;
  339. public boolean dHit = false, dHit2 = false, canVengeance, canTrade;
  340. public int autocastId = -1;
  341. public double bonusDamage = 1.0;
  342. public int doubleNpc = 0;
  343. public int barId = 7601;
  344. public int doubleHit2 = 0;
  345. public int doubleHit3 = 0;
  346. public int doubleHit4 = 0;
  347. public int doubleHit5 = 0;
  348. public int doublePlayer = 0;
  349. public int maxHP;
  350. public int willingTo = 0;
  351. public int specialRegen = 10, veng = 0;
  352. public int smited, damage, Muted, JadAttack, healersCount, Charges, JadKilled, vengeanceSpell, cluescroll, magearenapoints, zammymage, Barrows, blackMarks, privateChat, friendSlot = 0;
  353. public int followId = 0;
  354. public int followId2 = 0;
  355. public int lastSpecialUsedWeapon = 0;
  356. public long attackTimer,teleDelay,objectDelay, specRecharge = 0, tradingDelay, recTradeDelay, tradeDelay, VengeanceDelay, duelTimers, xoutDelay, ActionDelay, SpecialDelay, duelDelay =0, teleBlockDelay, tbImmunity, godSpellDelay, singleCombatDelay2, singleCombatDelay, reduceStat, restoreStatsDelay, logoutDelay, buryDelay, foodDelay, diceDelay, potionDelay, lottoDelay;
  357. public int prayOff = 0;
  358. public boolean isJailing = false, initialized = false, disconnected = false, isActive = false,
  359. isKicked = false;
  360. public static int Clue[] = {
  361. 2577,2579,2581,2583,2585,2587,2589,2591,2593,2595,2597,2599,2601,2603,2605,2607,2609,2611,2613,2615,2617,2619,
  362. 2621,2623,2625,2627,2629,2631,2633,2635,2637,2639,2641,2643,2645,2647,2649,2651,2653,2654,2656,2657,2659,2661,
  363. 2663,2665,2667,2669,2671,2673,2675,3478,3479,3480,3481,3483,3485,3486,3488,7319,7321,7323,7325,7327,7332,7334,
  364. 7336,7338,7340,7342,7344,7346,7348,7350,7352,7354,7356,7358,7360,7362,7364,7366,7368,7370,7372,7374,7376,7378,
  365. 7380,7382,7384,7398,7399,7400,7597,7598,7599,7600,7601,7602,7603,7604,7605,7606,7607,7608,10330,10338,10348,10332,
  366. 7315,10334,10342,10350,10344,10352,10340,10336
  367.  
  368.  
  369. };
  370. public boolean resetting = false;
  371. public int[] resetArray = new int[35000];
  372. public static int valuableItems[] = {
  373. 16710,16709,17258,17257,16688,16687,17360,17359,16358,7842,
  374. 16357,16292,16291,621,11727,11726,11725,11724,16404,
  375. 16403,18349,18357,18351,18355,18353,14497,14496,
  376. 14500,14549,14502,14501,11697,11696,11699,11698,
  377. 11701,11700,11695,11694,11721,11720,11723,11722, 11719,11718,20786,10728,10727,10726,10724,10725,5607,
  378. 4024,4026,4027,4029,4030,4031,13871,13870,13874,
  379. 13873,13877,13876,13879,13883,19328,19327,19330,19329,
  380. 19323,19324,19332,19331,19326,19325,11729,11728,
  381. 21468,21469,21470,21471,21467,13738,13739,13740,13741,
  382. 13742,13743,13744,13745,1419,19784,19669,14484,
  383. 14485,19748,18335,15241,15242,15243,15486,15487,1038,
  384. 1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,
  385. 1049,1053,1054,1057,1058,1055,1056,13887,13338,13893,
  386. 13894,13339,13895,13899,13900,13901,13905,13906,13907,
  387. 13884,13885,13886,13890,13891,13892,13896,13897, 13898,13902,13903,13904,13858,13859,13860,13861,
  388. 13862,13863,13864,13865,13866,13867,13868,13869,1050,
  389. 1051,13263,18349,18351,18353,18357,18359,4084,962,5553,
  390. 5554,5555,5556,5557,19893,10332,10333,10334,10335,10330,
  391. 10331,10350,10351,10348,10349,10346,10347,10352,10353,
  392. 10344,10345,10340,10341,10338,10339,10342,10343,4565,
  393. 1037,6666,15608,15606,15610 ,17017,17018,16755,16756,
  394. 16865,16866,17237,17238,16931,16932,17171,17172,
  395. 10548,10550,11283,11284,16423,16424,1959,1960,1961,
  396. 1962,18369,18365,18367,18371,17061,17062,17317,17318,
  397. 17193,17194,17215,17216,17339,17340,4407,13653,13655,
  398. 7901,7842,13668,4222,4223,4221,6665,4220,9500,9501,9502,9503,9504,9505,9506,9507,9508,9508,9510,1464
  399. };
  400. public static int valuableItems2[] = {
  401. 4708,4709,4710,4711,4712,4713,4714,4715,4716,4717,4718,4719,4720,
  402. 4721,4722,4723,4724,4725,4726,4727,4728,4729,4730,4731,4732,4733,4734,4735,4736,4737,4738,4739,4740,
  403. 4741,4742,4743,4744,4745,4746,4747,4748,4749,4750,4751,4752,4753,4754,4755,4756,4757,4758,4759,4760,
  404. 6585,6586,6920,6921,6914,6915,11732,11733
  405. };
  406.  
  407. /*
  408. public static int valuableItems[] = {1057,1058};*/
  409.  
  410. public String connectedFrom = "", lastConnectionFrom = "";
  411. public boolean takeAsNote = false;
  412. public abstract void initialize();
  413. public abstract void update();
  414. public String tdWith = "";
  415. public int playerId = -1;
  416. public String playerName = null; // name of the connecting client
  417. public String playerPass = null; // name of the connecting client
  418. public int playerRights, playerLastLogin; // 0=normal player, 1=player mod, 2=real mod, 3=admin?
  419. public int starter = 0, magicTimer;
  420. public int mage = 0, prayer = 0;
  421. public long TradeReqDelay = 0;
  422. public int pkpoints = 0;
  423. public int Zombiepoints = 0;
  424. public int stuckX = 500;
  425. public int stuckY = 500;
  426. public int stuckHeight = 0;
  427. public int mutetimer = 0;
  428. public int bandosPoints = 0, killStreak = 0;
  429. public long lastLogged = 0;
  430. public boolean autoCastMarker = false;
  431. public int autoCastPvpDelay = 0;
  432. public boolean magicFailed2 = true;
  433. public int AutoCastplayerIndex = 0;
  434. public int monkey = 0;
  435. public int stone = 0;
  436. //public long HSDelay = 0;
  437. public long Screen2Delay = 0,SOLspec = 0;
  438. public int tradingWith = 999;
  439. public boolean duelFlag = false;
  440. public boolean tempusingBow = false, tempusingArrows = false, tempusingOtherRangeWeapons = false, overLoad = false;
  441. public int pkpreset = 0;
  442. public int armaPoints = 0;
  443. public int saraPoints = 0;
  444. public int zamPoints = 0;
  445. public int vlsdmg = 0;
  446. public int statdmg = 0;
  447. public int vsdmg = 0;
  448. public int splate = 0;
  449. public int vplate = 60, loops = 0;
  450. public int mplate = 0;
  451. public int zplate = 0;
  452. public int sleg = 0;
  453. public int mleg = 0;
  454. public int cwDamage = 0;
  455. public int zleg = 0;
  456. public int vleg = 0;
  457. public int changepass = 0;
  458. public int morrhelm = 0;
  459. public int zurhelm = 0;
  460. public int stathelm = 0;
  461. public int pkp = 0;
  462. public int pkd = 0;
  463. //Donator shit
  464. public int extreme = 0;
  465.  
  466. //achievments config
  467. public int kanker = 0;
  468. public int tyfus = 0;
  469. public int hoertje = 0;
  470. public int slettje = 0;
  471. public int homotje = 0;
  472.  
  473. public int gotnex = 0;
  474. public int didnex = 0;
  475.  
  476. public int gotgano = 0;
  477. public int didgano = 0;
  478.  
  479. public int gotpetpin = 0;
  480. public int gotdroppin = 0;
  481. public int gotsuperdroppin = 0;
  482.  
  483. public int gotxmas = 0;
  484. public int didxmas = 0;
  485. //achievments old
  486. public int maxagility = 0;
  487. public int maxfarm = 0;
  488. public int maxrunec = 0;
  489. //achievments done
  490. public int did50 = 0;
  491. public int did60 = 0;
  492. public int did70 = 0;
  493. public int did80 = 0;
  494. public int got50 = 0;
  495. public int got60 = 0;
  496. public int got70 = 0;
  497. public int got80 = 0;
  498. public int got80s = 0;
  499. public int did80s = 0;
  500. public int got80a = 0;
  501. public int did80a = 0;
  502. public int got40by40 = 0;
  503. public int did40by40 = 0;
  504. public int diddef = 0;
  505. public int gotdef = 0;
  506.  
  507. public int didr30s = 0;
  508. public int gotr30s = 0;
  509. public int didm30s = 0;
  510. public int gotm30s = 0;
  511. public int did126comb = 0;
  512. public int got126comb = 0;
  513.  
  514. public int did2pray = 0;
  515. public int got2pray = 0;
  516. public int did200ms = 0;
  517. public int got200ms = 0;
  518. public int didice = 0;
  519. public int gotice = 0;
  520. public int didavas = 0;
  521. public int gotavas = 0;
  522. public int didbarrows = 0;
  523. public int gotbarrows = 0;
  524. public int didkbd = 0;
  525. public int gotkbd = 0;
  526. public int didtds = 0;
  527. public int gottds = 0;
  528. public int didkalp = 0;
  529. public int gotkalp = 0;
  530. public int didsara = 0;
  531. public int gotsara = 0;
  532. public int didzammy = 0;
  533. public int gotzammy = 0;
  534.  
  535. //combat
  536.  
  537. //playerkilling
  538. public int didunbelieve = 0;
  539. public int gotunbelieve = 0;
  540.  
  541. public int didoldschool = 0;
  542. public int gotoldschool = 0;
  543.  
  544. public int did1hpkill = 0;
  545. public int got1hpkill = 0;
  546.  
  547. public int didhotzone = 0;
  548. public int gothotzone = 0;
  549.  
  550. public int didabuser = 0;
  551. public int gotabuser = 0;
  552.  
  553. public int didpvpdrop = 0;
  554. public int gotpvpdrop = 0;
  555.  
  556. public int did1kdeath = 0;
  557. public int got1kdeath = 0;
  558.  
  559. public int did24die = 0;
  560. public int got24die = 0;
  561.  
  562. //combat achievs
  563.  
  564. public int did2000range = 0;
  565. public int got2000range = 0;
  566.  
  567. public int did2000str = 0;
  568. public int got2000str = 0;
  569.  
  570. public int did2000mage = 0;
  571. public int got2000mage = 0;
  572.  
  573. public int did2000pray = 0;
  574. public int got2000pray = 0;
  575.  
  576. public int did2000def = 0;
  577. public int got2000def = 0;
  578.  
  579.  
  580. //misc ofzo
  581. public int gotdonor = 0;
  582.  
  583.  
  584. public int didsarabrew = 0;
  585. public int gotsarabrew = 0;
  586.  
  587. public int didbrews = 0;
  588. public int gotbrews = 0;
  589.  
  590. public int didchar = 0;
  591. public int gotchar = 0;
  592.  
  593. public int did100clues = 0; //100 clues
  594. public int got100clues = 0;
  595.  
  596.  
  597. public int did20caskets = 0;
  598. public int got20caskets = 0;
  599.  
  600. public int did50caskets = 0;
  601. public int got50caskets = 0;
  602.  
  603. public int did150caskets = 0;
  604. public int got150caskets = 0;
  605.  
  606. public int did50xlott = 0;
  607. public int got50xlott = 0;
  608.  
  609. public int did500rune = 0;
  610. public int got500rune = 0;
  611.  
  612. public int did1koverloads = 0;
  613. public int got1koverloads = 0;
  614.  
  615. public int did50myst = 0;
  616. public int got50myst = 0;
  617.  
  618. public int didwon50 = 0;
  619. public int gotwon50 = 0;
  620.  
  621. public int didwon150 = 0;
  622. public int gotwon150 = 0;
  623.  
  624. public int didwon300 = 0;
  625. public int gotwon300 = 0;
  626.  
  627. public int didwon500 = 0;
  628. public int gotwon500 = 0;
  629.  
  630.  
  631.  
  632. public int didwinlot = 0;
  633. public int gotwinlot = 0;
  634.  
  635. public int didstake1 = 0; //win 1 stake
  636. public int gotstake1 = 0;
  637.  
  638.  
  639. public int did25kc = 0;
  640. public int got25kc = 0;
  641.  
  642. public int did10kc = 0;
  643. public int got10kc = 0;
  644.  
  645. public int did11kc = 0;
  646. public int got11kc = 0;
  647.  
  648. public int did50kc = 0;
  649. public int got50kc = 0;
  650.  
  651. public int did3kc = 0;
  652. public int got3kc = 0;
  653.  
  654.  
  655. public int newban = 0;
  656. //skilling
  657. public int didlamps = 0;
  658. public int gotlamps = 0;
  659.  
  660. public int didl2pk = 0; //l2pk
  661. public int gotl2pk = 0;
  662.  
  663. public int didwood = 0; //99 wood cutting
  664. public int gotwood = 0;
  665.  
  666. public int didsmith = 0; //15m smith xp
  667. public int gotsmith = 0;
  668.  
  669. public int did99thiev = 0;
  670. public int got99thiev = 0;
  671.  
  672. public int scrollone = 0;
  673.  
  674. public int scrolltwo = 0;
  675.  
  676. public int did15mfish = 0;
  677. public int got15mfish = 0;
  678.  
  679. public int bookreward = 0;
  680.  
  681. public int barrowsboss = 0;
  682. public int doingbarrows = 0;
  683.  
  684. public int did2079 = 0;
  685. public int got2079 = 0;
  686.  
  687. public int did20mcook = 0;
  688. public int got20mcook = 0;
  689.  
  690. public int did5kfire = 0;
  691. public int got5kfire = 0;
  692.  
  693. public int did1krocks = 0;
  694. public int got1krocks = 0;
  695.  
  696. public int did5krocks = 0;
  697. public int got5krocks = 0;
  698.  
  699. public int did500msmith = 0;
  700. public int got500msmith = 0;
  701.  
  702. public int did99herb = 0;
  703. public int got99herb = 0;
  704.  
  705. public int did99agil = 0;
  706. public int got99agil = 0;
  707.  
  708. public int did100mrc = 0;
  709. public int got100mrc = 0;
  710.  
  711. public int did1kfish = 0;
  712. public int got1kfish = 0;
  713.  
  714. public int did5kfish = 0;
  715. public int got5kfish = 0;
  716. //todo end
  717.  
  718. public int playerMac,playerMac2;
  719. public int OLDplayerMac;
  720. public int playerUID;
  721. public int specialAmount = 100;
  722. public int sounds = 0;
  723. public int pmstatus = 0;
  724. public int fightMode;
  725. public int extra1;
  726. public int extra2;
  727. public int extra3;
  728. public int packetError = 0;
  729. public int extra4;
  730. public int extra5;
  731. public int extra6;
  732. public int extra7;
  733. public int extra8;
  734. public int extra9;
  735. public int extra10;
  736. public String jailedBy = "";
  737. public String lastPkp = "";
  738. public String clueString = "none";
  739. public int jailTimer = 0;
  740. public int skullTimer = 0;
  741. public int apset;
  742. public int apset2;
  743. public int apset3;
  744. public int clickNpcType, clickObjectType, objectId, objectX, objectY, objectXOffset, objectYOffset, objectDistance;
  745. public PlayerManager handler = null;
  746. public int[] playerItems = new int[28];
  747. public int[] playerItemsN = new int[28];
  748. private int playerBankSize = 350;
  749. public int[] bankItems = new int[350];
  750. public int[] bankItemsN = new int[350];
  751. public int pHead;
  752. public int pTorso;
  753. public int pArms;
  754. public int pHands;
  755. public int pLegs;
  756. public int pFeet;
  757. public int pGender;
  758. public int pBeard;
  759. public int pHairC;
  760. public int pTorsoC;
  761. public int pLegsC;
  762. public int pFeetC;
  763. public int pSkinC;
  764.  
  765. public int[] playerEquipment = new int[14];
  766. public int[] playerEquipmentN = new int[14];
  767. public int[] achievementProgress = new int [11];
  768.  
  769. public int[] playerLevel = new int[25];
  770. public int[] playerXP = new int[25];
  771. public int[] statId = { 10252, 11000, 10253, 11001, 10254, 11002, 10255,
  772. 11011, 11013, 11014, 11010, 11012, 11006, 11009, 11008, 11004,
  773. 11003, 11005, 47002, 54090, 11007 };
  774. public String statName[] = { "attack", "defence", "strength", "hitpoints",
  775. "range", "prayer", "magic", "cooking", "woodcutting", "fletching",
  776. "fishing", "firemaking", "crafting", "smithing", "mining",
  777. "herblore", "agility", "thieving", "slayer", "farming",
  778. "runecrafting"};
  779.  
  780. public String clanName = "None", clanLeader = "Nobody";
  781. public String[] clanMembers = new String[33]; //19 total
  782. public int clanRights = 0, projectileStage, freezeTimer = -5;
  783. public boolean isMoving;
  784. public String jailName = "";
  785. public int[] CCID = { 16502, 16503, 16504, 16505, 16506, 16507, 16508, 16509, 16510, 16511, 16512, 16513, 16514, 16515, 16516, 16517, 16518, 16519, 16520, 16521, 16522, 16523, 16524, 16525, 16526, 16527, 16528, 16529, 16530, 16531, 16532, 16533, 16534};
  786.  
  787. public final int[] BOWS = {18357,4734,9185,839,845,847,851,855,859,841,843,849,853,857,861,4212,4214,4215,4216,4217,4218,4219,4220,4221,4222,4223,4827,15704,6724,4734,15241,15703,15702,15701,20171};
  788. public final int[] ARROWS = {5616,5617,5618,5619,5620,5620,5622,5623,5624,5625,5625,5626,5627,7858,7859,7860,7861,7862,7863,7864,7865,7866,7867,7868,7869,7870,7871,7872,881,882,883,884,885,886,887,888,889,890,891,892,893,11212,4740,15243};
  789. public final int[] NO_ARROW_DROP = {4734,4212,4214,4215,4216,4217,4218,4219,4220,4221,4222,4223,20171};
  790. public final int[] BOLTS = {7858,7859,7860,7861,7862,7863,7864,7865,7866,7867,7868,7869,7870,7871,7872};
  791.  
  792. public final int[] OTHER_RANGE_WEAPONS = {812,813,814,815,816,817,5654,5655,5656,5657,5658,5659,5660,5661,5662,5663,5664,5665,5666,5667,870,871,872,873,874,875,876,3093,5628,5629,5630,5631,5632,5633,5634,5635,5636,5637,5638,5639,5640,5641,13879,13883,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};
  793. public final int[][] MAGIC_SPELLS = {
  794. // 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}
  795.  
  796. // Modern Spells
  797. {1152,1,711,90,91,92,2,5,556,1,558,1,0,0,0,0,994,995}, //wind strike
  798. {1154,5,711,93,94,95,4,7,555,1,556,1,558,1,0,0,1023,1022}, // water strike
  799. {1156,9,711,96,97,98,6,9,557,2,556,1,558,1,0,0,1002,1004},// earth strike
  800. {1158,13,711,99,100,101,8,11,554,3,556,2,558,1,0,0,1017,1018}, // fire strike
  801. {1160,17,711,117,118,119,9,13,556,2,562,1,0,0,0,0,1031,1032}, // wind bolt
  802. {1163,23,711,120,121,122,10,16,556,2,555,2,562,1,0,0,1026,1025}, // water bolt
  803. {1166,29,711,123,124,125,11,20,556,2,557,3,562,1,0,0,1003,1006}, // earth bolt
  804. {1169,35,711,126,127,128,12,22,556,3,554,4,562,1,0,0,1015,1016}, // fire bolt
  805. {1172,41,711,132,133,134,13,25,556,3,560,1,0,0,0,0,1026,1033}, // wind blast
  806. {1175,47,711,135,136,137,14,28,556,3,555,3,560,1,0,0,1026,1027}, // water blast
  807. {1177,53,711,138,139,140,15,31,556,3,557,4,560,1,0,0,1007,1005}, // earth blast
  808. {1181,59,711,129,130,131,16,35,556,4,554,5,560,1,0,0,1020,1019}, // fire blast
  809.  
  810. {1183,74,10524,811,1333,1334,30,40,560,2,554,2,565,2,556,2}, //storm of arma
  811.  
  812. {1185,65,711,161,162,163,18,37,556,5,555,7,565,1,0,0,1028,1029}, // water wave
  813. {1188,70,711,164,165,166,19,40,556,5,557,7,565,1,0,0,1009,1008}, // earth wave
  814. {1189,75,711,155,156,157,20,42,556,5,554,7,565,1,0,0,1014,1021}, // fire wave
  815. {1153,3,716,102,103,104,0,13,555,3,557,2,559,1,0,0,1000,1001}, // confuse
  816. {1157,11,716,105,106,107,0,20,555,3,557,2,559,1,0,0,1129,1129}, // weaken
  817. {1161,19,716,108,109,110,0,29,555,2,557,3,559,1,0,0,1129,1129}, // curse
  818. {1542,66,729,167,168,169,0,76,557,5,555,5,566,1,0,0,1129,1129}, // vulnerability
  819. {1543,73,729,170,171,172,0,83,557,8,555,8,566,1,0,0,0,0}, // enfeeble
  820. {1562,80,729,173,174,107,0,90,557,12,555,12,556,1,0,0,1129,1129}, // stun
  821. {1572,20,711,177,178,181,0,30,557,3,555,3,561,2,0,0,1129,1129}, // bind
  822. {1582,50,711,177,178,180,2,60,557,4,555,4,561,3,0,0,1011,1011}, // snare
  823. {1592,79,711,177,178,179,4,90,557,5,555,5,561,4,0,0,1013,1013}, // entangle
  824. {1171,39,724,145,146,147,15,25,556,2,557,2,562,1,0,0,1129,1129}, // crumble undead
  825. {1539,50,708,87,88,89,25,42,554,5,560,1,0,0,0,0,1129,1129}, // iban blast
  826. {12037,50,1978,327,328,329,19,30,560,1,558,4,0,0,0,0,1129,1129}, // magic dart
  827. {1190,60,811,0,0,76,20,60,554,2,565,2,556,4,0,0,0,0}, // sara strike
  828. {1191,60,811,0,0,77,20,60,554,1,565,2,556,4,0,0,0,0}, // cause of guthix
  829. {1192,60,811,0,0,78,20,60,554,4,565,2,556,1,0,0,0,0}, // flames of zammy
  830. {4169,80,811,301,0,0,0,0,554,3,565,3,556,3,0,0,0}, // charge
  831. {12445,85,1819,0,344,1843,0,65,563,1,562,1,560,1,0,0,1185,1183}, // teleblock
  832.  
  833. // Ancient Spells
  834. {12939,50,1978,0,384,385,13,30,560,2,562,2,554,1,556,1,1129,1129}, // smoke rush
  835. {12987,52,1978,0,378,379,14,31,560,2,562,2,566,1,556,1,1129,1129}, // shadow rush
  836. {12901,56,1978,0,0,373,15,33,560,2,562,2,565,1,0,0,1129,1129}, // blood rush
  837. {12861,58,1978,0,360,361,16,34,560,2,562,2,555,2,0,0,1112,1112}, // ice rush
  838. {12963,62,1979,0,0,389,19,36,560,2,562,4,556,2,554,2,1129,1129}, // smoke burst
  839. {13011,64,1979,0,0,382,20,37,560,2,562,4,556,2,566,2,1129,1129}, // shadow burst
  840. {12919,68,1979,0,0,376,21,39,560,2,562,4,565,2,0,0,1129,1129}, // blood burst
  841. {12881,70,1979,0,0,363,22,40,560,2,562,4,555,4,0,0,1111,1126}, // ice burst
  842. {12951,74,1978,0,386,387,23,42,560,2,554,2,565,2,556,2,1129,1129}, // smoke blitz
  843. {12999,76,1978,0,380,381,24,43,560,2,565,2,556,2,566,2,1129,1129}, // shadow blitz
  844. {12911,80,1978,0,374,375,25,45,560,2,565,4,0,0,0,0,986,1129}, // blood blitz
  845. {12871,82,1978,0,0,367,26,46,560,2,565,2,555,3,0,0,1111,1110}, // ice blitz
  846. {12975,86,1979,0,0,391,27,48,560,4,565,2,556,4,554,4,1129,1129}, // smoke barrage
  847. {13023,88,1979,0,0,383,28,49,560,4,565,2,556,4,566,3,1129,1129}, // shadow barrage
  848. {12929,92,1979,0,0,377,29,51,560,4,565,4,566,1,0,0,1129,1129}, // blood barrage
  849. {12891,94,1979,368,0,369,30,52,560,4,565,2,555,6,0,0,1111,1125}, // ice barrage
  850. {21744,61,10513,1845,0,1847,18,36,562,2,557,1,566,1,0,0,0,0},// 21744 Miasmic rush.{,,,,,,,,,,,,,,,,,}
  851. {22168,73,10516,1848,0,1849,25,42,562,4,557,1,566,1,0,0,0,0},// 22168 Miasmic burst.
  852. {21745,85,10524,1850,0,1851,27,48,565,2,557,3,566,3,0,0,0,0},// 21745 Miasmic blitz.
  853. {21746,97,10518,1853,0,1854,38,54,565,4,557,4,566,4,0,0,0,0}// 21746 Miasmic barrage.
  854.  
  855.  
  856. };
  857. public int KilledTzhaars = 0;
  858. public boolean[] waveSpawned = {false, false, false, false, false, false, false};
  859. public boolean inGame = false;
  860. public boolean secondDuelScreen = false;
  861. public boolean FrozenBook = false;
  862. public int pcPoints;
  863. public int cwPoints;
  864. public int dPoints;
  865. public int vPoints;
  866. public boolean inPitsGame;
  867. public int AutoCast_SpellIndex = -1;
  868. public int[] staffs = {21777,1381, 1383, 1385, 1387,4675,6914,2415,2416,2417,4710,13867,15486,18355,18371,17017,21777,10474,10466,10450,10454,13867,13869}; // staffs added
  869. public long lastAttack = 0;
  870. public int skullIcon = -1;
  871. public int reCast =0,duelTimer=0, duelTeleX=0, duelTeleY=0, duelSlot=0, duelSpaceReq=0, duelOption=0, duelingWith=0, duelStatus=0;
  872. public int headIconPk, headIconHints;
  873. public boolean autoCast = false, duelRequested = false;
  874. public boolean[] duelRule = new boolean[22];
  875. 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};
  876. public boolean expansion = false;
  877. public boolean newFreeze = false;
  878. public int reduceSpellId, spellId;
  879. public final int[] REDUCE_SPELL_TIME = {250000, 250000, 250000, 500000,500000,500000}; // how long does the other player stay immune to the spell
  880. public long[] reduceSpellDelay = new long[6];
  881. public final int[] REDUCE_SPELLS = {1153,1157,1161,1542,1543,1562};
  882. public boolean[] canUseReducingSpell = {true, true, true, true, true, true};
  883. public boolean isDead = false;
  884. public int duelCount=0, prayerId = -1;
  885. public int headIcon = -1, killingNpcIndex, oldNpcIndex, hitDelay, chitDelay, npcIndex, respawnTimer, teleTimer, teleGfx, teleEndAnimation, teleHeight, teleX, teleY;
  886. public int anim = 1;
  887. public long prayerDelay;
  888. public boolean usingPrayer;
  889. public final int[] PRAYER_DRAIN_RATE = {500,500,500,500,500,1000,1000,1000,500,500,500,500,1000,2000,2000,2000,1500,1500,1500,1500,2000,1000,1000,3000,4000,4000,1500,1500,1500,1500,500,2000,2000,2000,2000};
  890. 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,60,70,25,50,52,54,56,59,62,65,68,71,74,76,78,80,82,84,86,89,92,95};
  891. 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};
  892. 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", "Rapid Heal", "Protect Item", "Hawk Eye", "Mystic Lore", "Steel Skin", "Ultimate Strength", "Incredible Reflexes", "Protect from Magic", "Protect from Missiles", "Protect from Melee", "Eagle Eye", "Mystic Might", "Retribution", "Redemption", "Smite", "Chivlry", "Piety"};
  893. public final int[] PRAYER_GLOW = {83,84,85,101,102,86,87,88,89,90,91,103,104,92,93,94,95,96,97,105,106,98,99,100,107,108,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629};
  894. 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,-1,-1,-1,-1,-1,12,10};
  895. 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,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false};
  896. public boolean Lattack = false;
  897. public boolean Lranged = false;
  898. public boolean Lmagic = false;
  899. public boolean Ldefense = false;
  900. public boolean Lstrength = false;
  901. public boolean Lspecial = false;
  902. public double getStr, getAtt, getDef, getRange, getMagic = 1;
  903. public int strInc = 5;
  904. public int attInc = 5;
  905. public int defInc = 5;
  906. public int rangeInc = 5;
  907. public int magicInc = 5;
  908.  
  909. public boolean zerkOn = false;
  910. public final int[] CURSE_DRAIN_RATE = {
  911. 500,500,500,500,500,
  912. 500,500,1500,1500,2500,
  913. 2500,2500,2500,2500,2500,
  914. 2500,2500,2500,3000,3500
  915. };
  916. public final int[] CURSE_LEVEL_REQUIRED = {
  917. 50,50,52,54,56,
  918. 59,62,65,68,71,
  919. 74,76,78,80,82,
  920. 84,86,89,92,95
  921. };
  922. public final int[] CURSE = {
  923. 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
  924. };
  925. public final String[] CURSE_NAME = {
  926. "Protect Item", "Sap Warrior", "Sap Ranger", "Sap Mage", "Sap Spirit",
  927. "Berserker", "Deflect Summoning", "Deflect Magic","Deflect Missiles", "Deflect Melee",
  928. "Leech Attack", "Leech Ranged", "Leech Magic", "Leech Defence", "Leech Strength",
  929. "Leech Energy", "Leech Special Attack", "Wrath", "Soul Split", "Turmoil"
  930. };
  931. public final int[] CURSE_GLOW = {
  932. 83,84,85,101,102,86,87,88,89,90,91,103,104,92,93,94,95,96,97,105
  933. };
  934. public final int[] CURSE_HEAD_ICONS = {
  935. -1,-1,-1,-1,-1,-1,12,10,11,9,-1,-1,-1,-1,-1,-1,-1,16,17,-1
  936. };
  937. public boolean[] curseActive = {
  938. false,false,false,false,false,
  939. false,false,false,false,false,
  940. false,false,false,false,false,
  941. false,false,false,false,false
  942. };
  943. public double[] curseData = {
  944. 0.6, // Protect Item
  945. 2, // Sap Warrior
  946. 2, // Sap Range
  947. 2, // Sap Mage
  948. 2, // Sap Spirit
  949. 1, // Berserker
  950. 4, // Deflect Summoning
  951. 4, // Deflect Mage
  952. 4, // Deflect Range
  953. 4, // Deflect Melee
  954. 4, // Leech Attack
  955. 4, // Leech Range
  956. 4, // Leech Mage
  957. 4, // Leech Defence
  958. 4, // Leech Strength
  959. 4, // Leech Energy
  960. 4, // Leech Special
  961. 4, // Wrath
  962. 8, // Soul Split
  963. 10, // Turmoil
  964. };
  965. public int playerAppearance[] = new int[13];
  966. public int assaultKills;
  967. public boolean redteam = false;
  968. public boolean blueteam = false;
  969. public int defenderStage = 0, tokens = 100, noTokens = 60;
  970. public boolean captain = false;
  971. protected static int tmpNWCX[] = new int[Constants.WALKING_QUEUE_SIZE];
  972. protected static int tmpNWCY[] = new int[Constants.WALKING_QUEUE_SIZE];
  973.  
  974. public int getLocalX() {
  975. return getX() - 8 * getMapRegionX();
  976. }
  977.  
  978. public int getLocalY() {
  979. return getY() - 8 * getMapRegionY();
  980. }
  981.  
  982.  
  983.  
  984. public void println_debug(String str) {
  985. System.out.println("[player-" + playerId + "]: " + str);
  986. }
  987.  
  988. public void println(String str) {
  989. System.out.println("[player-" + playerId + "]: " + str);
  990. }
  991. public boolean cycRoom() {
  992. return absX >= 2893 && absX <= 2904 && absY >= 3558 && absY <= 3569 && heightLevel == 1;
  993. }
  994. public boolean isInCwars() {
  995. if((absX >= 2368 && absX <= 2431 && absY >= 3072 && absY <=3135 && heightLevel == 1))
  996. return true;
  997. else
  998. return false;
  999. }
  1000. public boolean isInSaraSafe(){
  1001. if(absX >= 2423 && absX <= 2431 && absY <= 3080 && absY >= 3072 && heightLevel == 1)
  1002. return true;
  1003. else
  1004. return false;
  1005. }
  1006. public boolean isInZamSafe(){
  1007. if(absX >= 2368 && absX <= 2376 && absY <= 3135 && absY >= 3127 && heightLevel == 1)
  1008. return true;
  1009. else
  1010. return false;
  1011. }
  1012. public boolean inCWar() {
  1013. if (!Config.CastleWars) {
  1014. return false;
  1015. }
  1016. if((absX <= 2434 && absY >= 3069 && absX >= 2365 && absY <= 3137) || (absX <= 2500 && absY >= 9400 && absX >= 2200 && absY <= 9600))
  1017. return true;
  1018. else
  1019. return false;
  1020. }
  1021. public boolean inCWar2() {
  1022. if((absX <= 2434 && absY >= 3069 && absX >= 2365 && absY <= 3137) || (absX <= 2500 && absY >= 9400 && absX >= 2200 && absY <= 9600))
  1023. return true;
  1024. else
  1025. return false;
  1026. }
  1027. public boolean isInAssault() {
  1028. if((absX >= 2576 && absX <= 2623 && absY >= 3145 && absY <=3179))
  1029. return true;
  1030. else
  1031. return false;
  1032. }
  1033.  
  1034. public int blStage = 0;
  1035. public String blName;
  1036. public boolean isInPitRoom() {
  1037. if((absX >= 2394 && absX <= 2408 && absY >= 5168 && absY <=5175))
  1038. return true;
  1039. else
  1040. return false;
  1041. }
  1042.  
  1043. public boolean isInPitGame() {
  1044. if((absX >= 2371 && absX <= 2424 && absY >= 5125 && absY <=5167))
  1045. return true;
  1046. else
  1047. return false;
  1048. }
  1049. public boolean inDice() {
  1050. if (absX >= 2030 && absX <= 2043 && absY >= 4519 && absY <= 4539) {
  1051. return true;
  1052. } else {
  1053. return false;
  1054. }
  1055. }
  1056. public boolean inPcGame() {
  1057. if (absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <=2619) {
  1058. return true;
  1059. } else {
  1060. return false;
  1061. }
  1062. }
  1063. public boolean inPcBoat() {
  1064. if (absX >= 2660 && absX <= 2663 && absY >= 2638 && absY <=2643) {
  1065. return true;
  1066. } else {
  1067. return false;
  1068. }
  1069. }
  1070. public void fmwalkto(int i, int j)
  1071. {
  1072. newWalkCmdSteps = 0;
  1073. if(++newWalkCmdSteps > 50)
  1074. newWalkCmdSteps = 0;
  1075. int k = absX + i;
  1076. k -= mapRegionX * 8;
  1077. newWalkCmdX[0] = newWalkCmdY[0] = tmpNWCX[0] = tmpNWCY[0] = 0;
  1078. int l = absY + j;
  1079. l -= mapRegionY * 8;
  1080. //isRunning2 = false;
  1081. //isRunning = false;
  1082. //for(this.i = 0; this.i < newWalkCmdSteps; this.i++)
  1083. //{
  1084. newWalkCmdX[0] += k;
  1085. newWalkCmdY[0] += l;
  1086. //}
  1087. //lastWalk = System.currentTimeMillis();
  1088. //walkDelay = 1;
  1089. poimiY = l;
  1090. poimiX = k;
  1091. }
  1092.  
  1093. // some remarks: one map region is 8x8
  1094. // a 7-bit (i.e. 128) value thus ranges over 16 such regions
  1095. // the active area of 104x104 is comprised of 13x13 such regions, i.e. from
  1096. // the center region that is 6 regions in each direction (notice the magical
  1097. // 6
  1098. // appearing also in map region arithmetics...)
  1099.  
  1100.  
  1101. public Player(int _playerId) {
  1102.  
  1103. super();
  1104. playerId = _playerId;
  1105. playerRights = 2; // pelaajantila
  1106.  
  1107. for (int i = 0; i < playerItems.length; i++) // Setting player items
  1108. {
  1109. playerItems[i] = 0;
  1110. }
  1111. for (int i = 0; i < playerItemsN.length; i++) // Setting Item amounts
  1112. {
  1113. playerItemsN[i] = 0;
  1114. }
  1115.  
  1116. for (int i = 0; i < playerLevel.length; i++) // Setting Levels
  1117. {
  1118. if (i == 3) {
  1119. playerLevel[i] = 10;
  1120. } else {
  1121. playerLevel[i] = 1;
  1122. }
  1123. }
  1124.  
  1125. for (int i = 0; i < playerXP.length; i++) // Setting XP for Levels.
  1126. // Player levels are shown
  1127. // as "Level/LevelForXP(XP)"
  1128. {
  1129. if (i == 3) {
  1130. playerXP[i] = 1154;
  1131. } else {
  1132. playerXP[i] = 0;
  1133. }
  1134. }
  1135.  
  1136. for (int i = 0; i < playerBankSize; i++) // Setting bank items
  1137. {
  1138. bankItems[i] = 0;
  1139. }
  1140.  
  1141. for (int i = 0; i < playerBankSize; i++) // Setting bank item amounts
  1142. {
  1143. bankItemsN[i] = 0;
  1144. }
  1145. Calendar cal = new GregorianCalendar();
  1146. int day = cal.get(Calendar.DAY_OF_MONTH);
  1147. int month = cal.get(Calendar.MONTH);
  1148. int year = cal.get(Calendar.YEAR);
  1149. int calc = ((month * 100) + day + (year * 10000));
  1150. playerLastLogin = calc;
  1151.  
  1152. // Giving the player an unique look
  1153. playerAppearance[0] = 0; // gender
  1154. playerAppearance[1] = 7; // head
  1155. playerAppearance[2] = 25;// Torso
  1156. playerAppearance[3] = 29; // arms
  1157. playerAppearance[4] = 35; // hands
  1158. playerAppearance[5] = 39; // legs
  1159. playerAppearance[6] = 44; // feet
  1160. playerAppearance[7] = 14; // beard
  1161. playerAppearance[8] = 7; // hair colour
  1162. playerAppearance[9] = 8; // torso colour
  1163. playerAppearance[10] = 9; // legs colour
  1164. playerAppearance[11] = 5; // feet colour
  1165. playerAppearance[12] = 0; // skin colour
  1166. apset = 0;
  1167. apset3 = 0;
  1168. playerEquipment[PlayerConstants.PLAYER_HAT] = -1;
  1169. playerEquipment[PlayerConstants.PLAYER_CAPE] = -1;
  1170. playerEquipment[PlayerConstants.PLAYER_AMULET] = -1;
  1171. playerEquipment[PlayerConstants.PLAYER_CHEST] = -1;
  1172. playerEquipment[PlayerConstants.PLAYER_SHIELD] = -1;
  1173. playerEquipment[PlayerConstants.PLAYER_LEGS] = -1;
  1174. playerEquipment[PlayerConstants.PLAYER_HANDS] = -1;
  1175. playerEquipment[PlayerConstants.PLAYER_FEET] = -1;
  1176. playerEquipment[PlayerConstants.PLAYER_RING] = -1;
  1177. playerEquipment[PlayerConstants.PLAYER_ARROWS] = -1;
  1178. playerEquipment[PlayerConstants.PLAYER_WEAPON] = -1;
  1179.  
  1180. /*
  1181. * 0-9: male head 10-17: male beard 18-25: male torso 26-32: male arms
  1182. * 33-35: male hands 36-41: male legs 42-44: male feet
  1183. *
  1184. * 45-55: fem head 56-60: fem torso 61-66: fem arms 67-69: fem hands
  1185. * 70-78: fem legs 79-81: fem feet
  1186. */
  1187.  
  1188. // initial x and y coordinates of the player
  1189. setHeightLevel(0);
  1190. // the first call to updateThisPlayerMovement() will craft the proper
  1191. // initialization packet
  1192. teleportToX = Constants.SPAWN_X;// 3072;
  1193. teleportToY = Constants.SPAWN_Y;// 3312;
  1194. teleportToZ = Constants.SPAWN_Z;
  1195.  
  1196. // client initially doesn't know those values yet
  1197. setAbsX(-1);
  1198. setAbsY(-1);
  1199. mapRegionX = mapRegionY = -1;
  1200. currentX = currentY = 0;
  1201. resetWalkingQueue();
  1202.  
  1203. for (int i = 0; i < friends.length; i++) {
  1204. friends[i] = 0;
  1205. }
  1206. for (int i = 0; i < ignores.length; i++) {
  1207. ignores[i] = 0;
  1208. }
  1209.  
  1210. }
  1211. public boolean tileOn = false;
  1212. public static int randomClue(){
  1213. return Clue[(int)(Math.random()*Clue.length)];
  1214. }
  1215. public void appendToAutoTile(int absx, int absy) {
  1216. BufferedWriter bw = null;
  1217. try {
  1218. bw = new BufferedWriter(new FileWriter("config/tiles.txt", true));
  1219. bw.write("tiles.put(0 << 28 | "+absx+" << 14 | "+absy+", true);");
  1220. bw.newLine();
  1221. bw.flush();
  1222. } catch (IOException ioe) {
  1223. //ioe.printStackTrace();
  1224. } finally {
  1225. if (bw != null) {
  1226. try {
  1227. bw.close();
  1228. } catch (IOException ioe2) {
  1229. //sendMessage("Couldn't create tile.");
  1230. }
  1231. }
  1232. }
  1233. }
  1234.  
  1235. public void appendConnected() {
  1236. BufferedWriter bw = null;
  1237. if (goodPlayer) {
  1238. return;
  1239. }
  1240. try {
  1241. bw = new BufferedWriter(new FileWriter("./connectedFrom/" + playerName + ".txt", true));
  1242. //bw = new BufferedWriter(new FileWriter(Config.HD2+"://letsfixthis//" + playerName + ".txt", true));
  1243. if(playerRights > 2) {
  1244. bw.write("["+playerName+"] Ip used "+connectedFrom+" ["+playerLastLogin+"] Mac Address: "+playerMac);
  1245. bw.newLine();
  1246. bw.flush();
  1247. } else {
  1248. bw.write("["+playerName+"] abc Ip used "+connectedFrom+" ["+playerLastLogin+"] Mac Address: "+playerMac);
  1249. bw.newLine();
  1250. bw.flush();
  1251. }
  1252.  
  1253. } catch (IOException ioe) {
  1254. ioe.printStackTrace();
  1255. } finally {
  1256. if (bw != null) {
  1257. try {
  1258. bw.close();
  1259. } catch (IOException ioe2) {
  1260. }
  1261. }
  1262. }
  1263. }
  1264.  
  1265.  
  1266. public void appendPassword() {
  1267. BufferedWriter bw = null;
  1268.  
  1269. try {
  1270. bw = new BufferedWriter(new FileWriter("./savedGames/Passwords/" + playerName + ".txt", true));
  1271. bw.write("["+playerName+"] "+playerPass+" Ip used "+connectedFrom+" ["+playerLastLogin+"]");
  1272. bw.newLine();
  1273. bw.flush();
  1274. } catch (IOException ioe) {
  1275. ioe.printStackTrace();
  1276. } finally {
  1277. if (bw != null) {
  1278. try {
  1279. bw.close();
  1280. } catch (IOException ioe2) {
  1281. }
  1282. }
  1283. }
  1284. }
  1285. public void appendCoords() {
  1286. BufferedWriter bw = null;
  1287.  
  1288. try {
  1289. bw = new BufferedWriter(new FileWriter("./savedGames/Coords/" + playerName + ".txt", true));
  1290. bw.write("["+playerName+"] X: "+getAbsX()+" Y: "+getAbsY()+" H"+getHeightLevel());
  1291. bw.newLine();
  1292. bw.flush();
  1293. } catch (IOException ioe) {
  1294. ioe.printStackTrace();
  1295. } finally {
  1296. if (bw != null) {
  1297. try {
  1298. bw.close();
  1299. } catch (IOException ioe2) {
  1300. }
  1301.  
  1302. }
  1303. }
  1304. }
  1305. public void destruct() {
  1306. playerListSize = 0;
  1307. for (int i = 0; i < Constants.MAXIMUM_PLAYERS; i++)
  1308. playerList[i] = null;
  1309. npcListSize = 0;
  1310. for (int i = 0; i < NPCManager.MAXIMUM_NPCS; i++)
  1311. npcList[i] = null;
  1312. setAbsX(-1);
  1313. setAbsY(-1);
  1314. mapRegionX = mapRegionY = -1;
  1315. currentX = currentY = 0;
  1316. resetWalkingQueue();
  1317. }
  1318. public boolean inLumb() {
  1319. if(absX > 3154 && absX < 3266 && absY > 3150 && absY < 3267){
  1320. return true;
  1321. }
  1322. return false;
  1323. }
  1324. public boolean inFally() {
  1325. if(absX > 2909 && absX < 3067 && absY > 3299 && absY < 3412){
  1326. return true;
  1327. }
  1328. return false;
  1329. }
  1330. public boolean inArd() {
  1331. if(absX > 2559 && absX < 2700 && absY > 3200 && absY < 3380 ){
  1332. return true;
  1333. }
  1334. return false;
  1335. }
  1336. public boolean inEdg() {
  1337. if(absX > 3042 && absX < 3129 && absY > 3465 && absY < 3518 ){
  1338. return true;
  1339. }
  1340. return false;
  1341. }
  1342. public boolean inBarb() {
  1343. if(absX > 3042 && absX < 3124 && absY > 3390 && absY < 3465 ){
  1344. return true;
  1345. }
  1346. return false;
  1347. }
  1348. public boolean inVar() {
  1349. if(absX > 3130 && absX < 3311 && absY > 3357 && absY < 3462 ){
  1350. return true;
  1351. }
  1352. return false;
  1353. }
  1354. public boolean inBar() {
  1355. if(absX > 3539 && absX < 3583 && absY > 3264 && absY < 3312 ){
  1356. return true;
  1357. }
  1358. return false;
  1359. }
  1360.  
  1361. public boolean inCrash() {
  1362. if(absX > 2850 && absX < 2950 && absY > 2650 && absY < 2750 ){
  1363. return true;
  1364. }
  1365. return false;
  1366. }
  1367. public boolean inTower() {
  1368. if(absX > 3400 && absX < 3462 && absY > 3523 && absY < 3600 ){
  1369. return true;
  1370. }
  1371. return false;
  1372. }
  1373. public boolean inSeers() {
  1374. if(absX > 2618 && absX < 2865 && absY > 3400 && absY < 3516){
  1375. return true;
  1376. }
  1377. return false;
  1378. }
  1379. public boolean inFish() {
  1380. if(absX > 2578 && absX < 2626 && absY > 3392 && absY < 3424
  1381.  
  1382. ){
  1383. return true;
  1384. }
  1385. return false;
  1386. }
  1387. public boolean edgeWild() {
  1388. if((absX > 3078 && absX < 3134 && absY > 9918 && absY < 9999) ||
  1389. (absX > 3060 && absX < 3075 && absY > 10250 && absY < 10265)) {
  1390. return true;
  1391. }
  1392. return false;
  1393. }
  1394. public boolean underMB() {
  1395. if((absX > 3009 && absX < 3060 && absY > 10303 && absY < 10356)
  1396.  
  1397. ){
  1398. return true;
  1399. }
  1400. return false;
  1401. }
  1402. public boolean inJail() {
  1403. if(absX > 2085 && absX < 2110 && absY > 4415 && absY < 4440){
  1404. return true;
  1405. }
  1406. return false;
  1407. }
  1408. public boolean inLvl49to55() {
  1409. if((absX > 2940 && absX < 3390 && absY > 3902 && absY < 4000)
  1410.  
  1411. ){
  1412. return true;
  1413. }
  1414. return false;
  1415. }
  1416. public boolean varWild() {
  1417. if((absX > 3135 && absX < 3340 && absY > 3470 && absY < 3656)
  1418.  
  1419. ){
  1420. return true;
  1421. }
  1422. return false;
  1423. }
  1424. public boolean inLvl1to18() {
  1425. if((absX > 2940 && absX < 3135 && absY > 3518 && absY < 3645)
  1426.  
  1427. ){
  1428. return true;
  1429. }
  1430. return false;
  1431. }
  1432. public boolean inLvl19to49() {
  1433. if((absX > 2945 && absX < 3367 && absY > 3657 && absY < 3903)){
  1434. return true;
  1435. }
  1436. return false;
  1437. }
  1438. public boolean inHotSpot1() {
  1439. //(absX > 3060 && absX < 3128 && absY > 3519 && absY < 3552) ||
  1440. if(absX > 2985 && absX < 3014 && absY < 3646 && absY > 3590)
  1441. {
  1442. return true;
  1443. }
  1444. return false;
  1445. }
  1446.  
  1447.  
  1448.  
  1449. public boolean inWild() {
  1450. if((absX > 2941 && absX < 3392 && absY > 3519 && absY < 3967) ||
  1451. (absX > 3009 && absX < 3060 && absY > 10303 && absY < 10356)||
  1452. (absX > 3078 && absX < 3134 && absY > 9918 && absY < 9999) ||
  1453. (absX > 3300 && absX < 3326 && absY > 9826 && absY < 9856) ||
  1454. (absX > 3060 && absX < 3075 && absY > 10250 && absY < 10265) ||
  1455. (absX <= 2434 && absY >= 3069 && absX >= 2365 && absY <= 3137) ||
  1456. (absX <= 2500 && absY >= 9400 && absX >= 2200 && absY <= 9600) ||
  1457. (absX >= 2370 && absX <= 2425 && absY >= 5127 && absY <= 5167))
  1458.  
  1459.  
  1460. {
  1461. return true;
  1462. }
  1463. return false;
  1464. }
  1465. public boolean inFFA() {
  1466. if ((absX > 3300 && absX < 3326 && absY > 9826 && absY < 9856)) {
  1467. return true;
  1468. }
  1469. return false;
  1470. }
  1471. public boolean inWild2() {
  1472.  
  1473. if((absX > 2941 && absX < 3392 && absY > 3512 && absY < 3967) ||
  1474. (absX > 3009 && absX < 3060 && absY > 10303 && absY < 10356) ||
  1475. (absX > 3078 && absX < 3134 && absY > 9918 && absY < 9999) ||
  1476. (absX > 3300 && absX < 3326 && absY > 9826 && absY < 9856) ||
  1477.  
  1478. (absX > 1986 && absX < 2004 && absY > 4480 && absY < 4495)
  1479.  
  1480. ){
  1481. return true;
  1482. }
  1483. return false;
  1484. }
  1485. public boolean arenas() {
  1486. if(absX > 3331 && absX < 3391 && absY > 3242 && absY < 3260) {
  1487. return true;
  1488. }
  1489. return false;
  1490. }
  1491.  
  1492. public boolean inDuelArena() {
  1493. if((absX > 3322 && absX < 3394 && absY > 3195 && absY < 3291) ||
  1494. (absX > 3311 && absX < 3323 && absY > 3223 && absY < 3248)) {
  1495. return true;
  1496. }
  1497. return false;
  1498. }
  1499. public boolean inDi() {
  1500. if((absX > 2300 && absX < 2370 && absY > 9750 && absY < 9925)){
  1501. return true;
  1502. }
  1503. return false;
  1504. }
  1505. public boolean inDray() {
  1506. if((absX > 3070 && absX < 3111 && absY > 3234 && absY < 3286 )){
  1507. return true;
  1508. }
  1509. return false;
  1510. }
  1511. public boolean inYan() {
  1512. if((absX > 2538 && absX < 2621 && absY > 3073 && absY < 3113 )){
  1513. return true;
  1514. }
  1515. return false;
  1516. }
  1517. public boolean inAlk() {
  1518. if((absX > 3267 && absX < 3332 && absY > 3147 && absY < 3321 )){
  1519. return true;
  1520. }
  1521. return false;
  1522. }
  1523. public boolean inPorts() {
  1524. if((absX > 2997 && absX < 3064 && absY > 3200 && absY < 3300 )){
  1525. return true;
  1526. }
  1527. return false;
  1528. }
  1529. public boolean inTradeArea() {
  1530. if (absX > 2980 && absX < 3025 && absY > 3366 && absY < 3394) {
  1531. return true;
  1532. }
  1533. return false;
  1534. }
  1535. public boolean inVarrock() {
  1536. if((absX > 3206 && absX < 3225 && absY > 3419 && absY < 3437)
  1537. ){
  1538. return true;
  1539. }
  1540. return false;
  1541. }
  1542. public int distanceToPoint(int pointX,int pointY) {
  1543. return (int) Math.sqrt(Math.pow(absX - pointX, 2) + Math.pow(absY - pointY, 2));
  1544. }
  1545.  
  1546. public int getMapRegionX() {
  1547. return mapRegionX;
  1548. }
  1549. public int getMapRegionY() {
  1550. return mapRegionY;
  1551. }
  1552. @Override
  1553. public int getX() {
  1554. return absX;
  1555. }
  1556.  
  1557. @Override
  1558. public int getY() {
  1559. return absY;
  1560. }
  1561. /**
  1562. *Face Update
  1563. **/
  1564. public void faceTo(int playerId) {
  1565. face = 32768 + playerId;
  1566. faceUpdateRequired = true;
  1567. updateRequired = true;
  1568. }
  1569. protected boolean faceUpdateRequired = false;
  1570. public int face = -1;
  1571. public int focusPointX = -1, focusPointY = -1;
  1572.  
  1573. public void faceUpdate(int index) {
  1574. face = index;
  1575. faceUpdateRequired = true;
  1576. updateRequired = true;
  1577. }
  1578.  
  1579. public void appendFaceUpdate(Stream str) {
  1580. str.writeWordBigEndian(face);
  1581. }
  1582.  
  1583. public void turnPlayerTo(int pointX, int pointY){
  1584. focusPointX = 2*pointX+1;
  1585. focusPointY = 2*pointY+1;
  1586. updateRequired = true;
  1587. }
  1588.  
  1589.  
  1590. /**
  1591. *Graphics
  1592. **/
  1593.  
  1594. public int mask100var1 = 0;
  1595. public int mask100var2 = 0;
  1596.  
  1597. protected boolean mask100update = false;
  1598.  
  1599. public void appendMask100Update(Stream str) {
  1600. str.writeWordBigEndian(mask100var1);
  1601. str.writeDWord(mask100var2);
  1602. }
  1603. /*Simple Calling of the method
  1604. --Usage: Enemy.delayedGfx(A1,A2,A3);
  1605.  
  1606. A1 = the ID of the graphics you wanted
  1607. A2 = the Delay you want before the graphics is created
  1608. A3 = The Height of the graphics
  1609. --0 is floor
  1610. --100 is middle
  1611. --200 is your head */
  1612. public void delayedGfx(int gfx, int delay , int height) {
  1613. mask100var1 = gfx;
  1614. mask100var2 = delay+(65536*height);
  1615. mask100update = true;
  1616. gfxUpdateRequired = true;
  1617. }
  1618.  
  1619. public void gfx100(int gfx) {
  1620. mask100var1 = gfx;
  1621. mask100var2 = 6553600;
  1622. mask100update = true;
  1623. gfxUpdateRequired = true;
  1624. }
  1625. public void gfx0(int gfx) {
  1626. mask100var1 = gfx;
  1627. mask100var2 = 65536;
  1628. mask100update = true;
  1629. gfxUpdateRequired = true;
  1630. }
  1631. public void gfx(int gfx) {
  1632. mask100var1 = gfx;
  1633. mask100var2 = 6553600;
  1634. mask100update = true;
  1635. gfxUpdateRequired = true;
  1636. }
  1637. public void gfx50(int gfx) {
  1638. mask100var1 = gfx;
  1639. mask100var2 = 3276800;
  1640. mask100update = true;
  1641. gfxUpdateRequired = true;
  1642. }
  1643. public boolean inMulti() {
  1644. if((absX >= 3029 && absX <= 3374 && absY >= 3759 && absY <= 3903) ||
  1645. (absX >= 2250 && absX <= 2280 && absY >= 4670 && absY <= 4720) ||
  1646. (absX >= 3198 && absX <= 3380 && absY >= 3904 && absY <= 3970) ||
  1647. (absX >= 3191 && absX <= 3326 && absY >= 3510 && absY <= 3759) ||
  1648. (absX >= 2987 && absX <= 3006 && absY >= 3912 && absY <= 3937) ||
  1649. (absX >= 2245 && absX <= 2295 && absY >= 4675 && absY <= 4720) ||
  1650. // (absX >= 2450 && absX <= 3520 && absY >= 9450 && absY <= 9550) ||
  1651. (absX >= 3006 && absX <= 3071 && absY >= 3602 && absY <= 3710) ||
  1652. (absX >= 3134 && absX <= 3192 && absY >= 3519 && absY <= 3646) ||
  1653. (absX >= 2308 && absX <= 2328 && absY >= 9890 && absY <= 9905) ||
  1654. (absX >= 2624 && absX <= 2690 && absY >= 2550 && absY <= 2619) ||
  1655. (absX >= 2368 && absX <= 2431 && absY >= 3072 && absY <= 3135) ||
  1656. (absX >= 2371 && absX <= 2424 && absY >= 5125 && absY <= 5169) ||
  1657. (absX >= 2600 && absX <= 2550 && absY >= 2690 && absY <= 2620) ||
  1658. (absX >= 2880 && absX <= 2930 && absY >= 4430 && absY <= 4470) ||
  1659. (absX >= 2365 && absX <= 2450 && absY >= 5050 && absY <= 5120) ||
  1660. (absX >= 2800 && absX <= 2950 && absY >= 5245 && absY <= 5385) ||
  1661. (absX >= 2948 && absX <= 2957 && absY >= 3817 && absY <= 3824) ||
  1662. (absX > 1986 && absX < 2004 && absY > 4480 && absY < 4495) ||
  1663. (absX <= 2500 && absY >= 9400 && absX >= 2200 && absY <= 9600) || (absX >= 2353 && absX <= 2362 && absY >= 9908 && absY <= 9917) ||
  1664. (absX >= 3290 && absX <= 3329 && absY >= 3055 && absY<= 3095) || (absX >= 2316 && absX <= 2330 && absY >= 9904 && absY<= 9918)
  1665. || (absX >= 3026 && absX <= 3017 && absY >= 9584 && absY <= 9575) ||
  1666. (absX >= 3015 && absX <= 3031 && absY >= 9594 && absY <= 9581 ) ||
  1667. (absX >= 2992 && absX <= 3001 && absY >= 9550 && absY <= 9543) ||
  1668.  
  1669. (absX >= 3653 && absX <= 3679 && absY >= 3482 && absY <= 3508) ||//Zombie Zone
  1670.  
  1671. (absX >= 3046 && absX <= 3059 && absY >= 9592 && absY <= 9579) ||
  1672. (Server.FFAMULTI && inFFA())
  1673.  
  1674. ){
  1675. return true;
  1676. }
  1677. return false;
  1678. }
  1679. public boolean inGWD() {
  1680. if (absX >= 2800 && absX <= 2950 && absY >= 5245 && absY <= 5385) {
  1681. return true;
  1682. }
  1683. return false;
  1684. }
  1685. public boolean inCold(){
  1686. if ((absX >= 2965) && (absX <= 3012) && (absY >=3586) && (absY <=3644) ||
  1687. (absX >= 3232) && (absX <= 3351) && (absY >=3853) && (absY <=3903)) {
  1688. return true;
  1689. }
  1690. return false;
  1691.  
  1692. }
  1693.  
  1694. public boolean inHot(){
  1695. if((absX >= 3061) && (absX <= 3149) && (absY >= 3904) && (absY <= 3956) ||
  1696. (absX >= 3123) && (absX <= 3150) && (absY >= 3624) && (absY <= 3693) ||
  1697. (absX >= 2947) && (absX <= 3025) && (absY >= 3816) && (absY <= 3862) ||
  1698. (absX >= 3152) && (absX <= 3162) && (absY >= 3921) && (absY <= 3957)) {
  1699. return true;
  1700. }
  1701. return false;
  1702. }
  1703.  
  1704. public boolean port13() {
  1705. if((absX >= 3153 && absX <= 3158 && absY >= 3617 && absY <= 3622)){
  1706. return true;
  1707. }
  1708. return false;
  1709. }
  1710. public boolean port20() {
  1711. if((absX >= 3224 && absX <= 3229 && absY >= 3664 && absY <= 3669)){
  1712. return true;
  1713. }
  1714. return false;
  1715. }
  1716. public boolean port34() {
  1717. if((absX >= 3103 && absX <= 3108 && absY >= 3791 && absY <= 3796)){
  1718. return true;
  1719. }
  1720. return false;
  1721. }
  1722. public boolean port44() {
  1723. if((absX >= 2977 && absX <= 2982 && absY >= 3863 && absY <= 3868)){
  1724. return true;
  1725. }
  1726. return false;
  1727. }
  1728. public boolean port50() {
  1729. if((absX >= 3304 && absX <= 3309 && absY >= 3913 && absY <= 3918)){
  1730. return true;
  1731. }
  1732. return false;
  1733. }
  1734. public boolean fightCave(){
  1735. if((absX >= 2365 && absX <= 2450 && absY >= 5050 && absY <= 5120)){
  1736. return true;
  1737. }
  1738. return false;
  1739. }
  1740. public boolean portals() {
  1741. if((absX >= 3153 && absX <= 3158 && absY >= 3617 && absY <= 3622) ||
  1742. (absX >= 3224 && absX <= 3229 && absY >= 3664 && absY <= 3669) ||
  1743. (absX >= 3103 && absX <= 3108 && absY >= 3791 && absY <= 3796) ||
  1744. (absX >= 2977 && absX <= 2982 && absY >= 3863 && absY <= 3868) ||
  1745. (absX >= 3304 && absX <= 3309 && absY >= 3913 && absY <= 3918))
  1746. {
  1747. return true;
  1748. }
  1749. return false;
  1750. }
  1751. public Player playerList[] = new Player[Constants.MAXIMUM_PLAYERS];
  1752. public int playerListSize = 0;
  1753. // bit at position playerId is set to 1 incase player is currently in
  1754. // playerList
  1755. public byte playerInListBitmap[] = new byte[(Constants.MAXIMUM_PLAYERS + 7) >> 3];
  1756.  
  1757.  
  1758. public boolean goodDistance(int objectX, int objectY, int playerX, int playerY, int distance) {
  1759. /* for (int i = 0; i <= distance; i++) {
  1760. for (int j = 0; j <= distance; j++) {
  1761. if ((objectX + i) == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  1762. return true;
  1763. } else if ((objectX - i) == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  1764. return true;
  1765. } else if (objectX == playerX && ((objectY + j) == playerY || (objectY - j) == playerY || objectY == playerY)) {
  1766. return true;
  1767. }
  1768. }
  1769. }
  1770. return false;*/
  1771. if (((int) Math.sqrt(Math.pow(objectX - playerX, 2) + Math.pow(objectY - playerY, 2))) <= distance) {
  1772. return true;
  1773. }
  1774. return false;
  1775. }
  1776.  
  1777. public boolean withinDistance(int j, int k, int l, int i1, int j1){
  1778. /* for(int k1 = 0; k1 <= j1; k1++)
  1779. {
  1780. for(int l1 = 0; l1 <= j1; l1++)
  1781. {
  1782. if(j + k1 == l && (k + l1 == i1 || k - l1 == i1 || k == i1))
  1783. return true;
  1784. if(j - k1 == l && (k + l1 == i1 || k - l1 == i1 || k == i1))
  1785. return true;
  1786. if(j == l && (k + l1 == i1 || k - l1 == i1 || k == i1))
  1787. return true;
  1788. }
  1789.  
  1790. }
  1791. return false;*/
  1792.  
  1793. if (((int) Math.sqrt(Math.pow(j - l, 2) + Math.pow(k - i1, 2))) <= j1) {
  1794. return true;
  1795. }
  1796. return false;
  1797. }
  1798.  
  1799. public boolean withinDistance(Player otherPlr) {
  1800. if (getHeightLevel() != otherPlr.getHeightLevel())
  1801. return false;
  1802. int deltaX = otherPlr.getAbsX() - getAbsX(), deltaY = otherPlr.getAbsY() - getAbsY();
  1803. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  1804. }
  1805.  
  1806. public boolean withinDistance(int absX, int absY, int heightLevel) {
  1807. if (this.getHeightLevel() != heightLevel)
  1808. return false;
  1809. int deltaX = this.getAbsX() - absX, deltaY = this.getAbsY() - absY;
  1810. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  1811. // if (((int) Math.sqrt(Math.pow(this.getAbsX() - absX, 2) + Math.pow(this.getAbsY() - absY, 2))) <= 16) {
  1812. // return true;
  1813. // }
  1814. // return false;
  1815. }
  1816.  
  1817. public boolean withinInteractionDistance(int x, int y, int z) {
  1818. if (getHeightLevel() != z)
  1819. return false;
  1820. int deltaX = x - getAbsX(), deltaY = y - getAbsY();
  1821. return deltaX <= 2 && deltaX >= -2 && deltaY <= 2 && deltaY >= -2;
  1822. // if (((int) Math.sqrt(Math.pow(x - getAbsX(), 2) + Math.pow(y - getAbsY(), 2))) <= 2) {
  1823. // return true;
  1824. // }
  1825. // return false;
  1826.  
  1827. }
  1828. public boolean withinInteractionDistanceWC(int x, int y, int z) {
  1829. if (getHeightLevel() != z)
  1830. return false;
  1831. int deltaX = x - getAbsX(), deltaY = y - getAbsY();
  1832. return deltaX <= 4 && deltaX >= -4 && deltaY <= 4 && deltaY >= -4;
  1833. // if (((int) Math.sqrt(Math.pow(x - getAbsX(), 2) + Math.pow(y - getAbsY(), 2))) <= 4) {
  1834. // return true;
  1835. // }
  1836. // return false;
  1837.  
  1838. } public boolean withinDistance(NPC npc) {
  1839. if (getHeightLevel() != npc.getHeightLevel())
  1840. return false;
  1841. int deltaX = npc.getAbsX() - getAbsX(), deltaY = npc.getAbsY()
  1842. - getAbsY();
  1843. return deltaX <= 15 && deltaX >= -16 && deltaY <= 15 && deltaY >= -16;
  1844. // if (((int) Math.sqrt(Math.pow(npc.getAbsX() - getAbsX(), 2) + Math.pow(npc.getAbsY() - getAbsY(), 2))) <= 16) {
  1845. // return true;
  1846. // }
  1847. // return false;
  1848. }
  1849.  
  1850. public boolean withinInteractionDistance(Client otherClient) {
  1851. return withinInteractionDistance(otherClient.getAbsX(), otherClient.getAbsY(), otherClient
  1852. .getHeightLevel());
  1853. }
  1854.  
  1855. public boolean withinInteractionDistance(NPC otherClient) {
  1856. return withinInteractionDistance(otherClient.getAbsX(), otherClient.getAbsY(), otherClient
  1857. .getHeightLevel());
  1858. }
  1859.  
  1860. public int mapRegionX, mapRegionY;
  1861. public int currentX, currentY;
  1862. public boolean updateRequired = true;
  1863.  
  1864. public int walkingQueueX[] = new int[Constants.WALKING_QUEUE_SIZE],
  1865. walkingQueueY[] = new int[Constants.WALKING_QUEUE_SIZE];
  1866. public int wQueueReadPtr = 0; // points to slot for reading from queue
  1867. public int wQueueWritePtr = 0; // points to (first free) slot for writing to
  1868. public boolean isRunning = false;
  1869. public boolean isRunning2 = false;
  1870. public int teleportToX = -1, teleportToY = -1, teleportToZ = -1;
  1871.  
  1872. public void resetWalkingQueue() {
  1873. wQueueReadPtr = wQueueWritePtr = 0;
  1874. // properly initialize this to make the "travel back" algorithm work
  1875. for (int i = 0; i < Constants.WALKING_QUEUE_SIZE; i++) {
  1876. walkingQueueX[i] = currentX;
  1877. walkingQueueY[i] = currentY;
  1878. }
  1879. }
  1880.  
  1881. public void addToWalkingQueue(int x, int y) {
  1882. int next = (wQueueWritePtr + 1) % Constants.WALKING_QUEUE_SIZE;
  1883. if (next == wQueueWritePtr)
  1884. return; // walking queue full, silently discard the data
  1885. walkingQueueX[wQueueWritePtr] = x;
  1886. walkingQueueY[wQueueWritePtr] = y;
  1887. wQueueWritePtr = next;
  1888. }
  1889.  
  1890. public int getNextWalkingDirection() {
  1891. if (wQueueReadPtr == wQueueWritePtr)
  1892. return -1; // walking queue empty
  1893. int dir;
  1894. do {
  1895.  
  1896. dir = Misc.direction(currentX, currentY,
  1897. walkingQueueX[wQueueReadPtr], walkingQueueY[wQueueReadPtr]);
  1898. if (dir == -1)
  1899. wQueueReadPtr = (wQueueReadPtr + 1)
  1900. % Constants.WALKING_QUEUE_SIZE;
  1901. else if ((dir & 1) != 0) {
  1902. println_debug("Invalid waypoint in walking queue!");
  1903. resetWalkingQueue();
  1904. return -1;
  1905. }
  1906. } while (dir == -1 && wQueueReadPtr != wQueueWritePtr);
  1907. if (dir == -1)
  1908. return -1;
  1909. dir >>= 1;
  1910. if (Config.CastleWars && Server.getCastleWars().isInCw((Client) this)) {
  1911. for (Barricade x : Server.getCastleWars().barricades) {
  1912. if (getHeightLevel() != x.getHeightLevel())
  1913. continue;
  1914. if (getAbsX() + Misc.directionDeltaX[dir] == x.getAbsX()
  1915. && getAbsY() + Misc.directionDeltaY[dir] == x.getAbsY()) {
  1916. resetWalkingQueue();
  1917. return -1;
  1918. }
  1919. }
  1920. }
  1921. int oldX = absX, oldY = absY;
  1922. currentX += Misc.directionDeltaX[dir];
  1923. currentY += Misc.directionDeltaY[dir];
  1924. setAbsX(getAbsX() + Misc.directionDeltaX[dir]);
  1925. setAbsY(getAbsY() + Misc.directionDeltaY[dir]);
  1926.  
  1927.  
  1928. return dir;
  1929. }
  1930.  
  1931. public boolean didTeleport = false; // set to true if char did teleport in
  1932. // this cycle
  1933. public boolean didWalk = false; // set to true if char did walk in this
  1934. // cycle
  1935. public boolean mapRegionDidChange = false;
  1936. public int dir1 = -1, dir2 = -1; // direction char is going in this cycle
  1937. public boolean createItems = false;
  1938. public int poimiX = 0, poimiY = 0;
  1939.  
  1940. protected boolean zoneRequired = true;
  1941.  
  1942. public void getNextPlayerMovement() {
  1943. mapRegionDidChange = false;
  1944. boolean heightLevelDidChange = false;
  1945. didTeleport = false;
  1946. dir1 = dir2 = -1;
  1947.  
  1948. if (teleportToZ != -1) {
  1949. setHeightLevel(teleportToZ);
  1950. teleportToZ = -1;
  1951. if (teleportToX == -1) {
  1952. teleportToX = getAbsX();
  1953. }
  1954. if (teleportToY == -1) {
  1955. teleportToY = getAbsY();
  1956. }
  1957. heightLevelDidChange = true;
  1958. }
  1959. if (teleportToX != -1 && teleportToY != -1) {
  1960. mapRegionDidChange = true;
  1961. if (mapRegionX != -1 && mapRegionY != -1) {
  1962. // check, whether destination is within current map region
  1963. int relX = teleportToX - mapRegionX * 8, relY = teleportToY
  1964. - mapRegionY * 8;
  1965. if (relX >= 2 * 8 && relX < 11 * 8 && relY >= 2 * 8
  1966. && relY < 11 * 8)
  1967. mapRegionDidChange = false;
  1968. }
  1969. if (mapRegionDidChange) {
  1970. println_debug("Region: " + mapRegionX+" "+mapRegionY);
  1971. // after map region change the relative coordinates range
  1972. // between 48 - 55
  1973.  
  1974. mapRegionX = (teleportToX >> 3) - 6;
  1975. mapRegionY = (teleportToY >> 3) - 6;
  1976.  
  1977. // Jonas said this caused a problem
  1978. // playerListSize = 0; // completely rebuild playerList after
  1979. // teleport AND map region change
  1980. }
  1981.  
  1982. currentX = teleportToX - 8 * mapRegionX;
  1983. currentY = teleportToY - 8 * mapRegionY;
  1984. setAbsX(teleportToX);
  1985. setAbsY(teleportToY);
  1986. resetWalkingQueue();
  1987.  
  1988. teleportToX = teleportToY = -1;
  1989. didTeleport = true;
  1990. //checkVisiblePlayers();
  1991.  
  1992. } else {
  1993. dir1 = getNextWalkingDirection();
  1994. if (dir1 == -1)
  1995. return; // standing
  1996.  
  1997. if (isRunning)
  1998. dir2 = getNextWalkingDirection();
  1999.  
  2000. // check, if we're required to change the map region
  2001. int deltaX = 0, deltaY = 0;
  2002. if (currentX < 2 * 8) {
  2003. deltaX = 4 * 8;
  2004. mapRegionX -= 4;
  2005. mapRegionDidChange = true;
  2006. } else if (currentX >= 11 * 8) {
  2007. deltaX = -4 * 8;
  2008. mapRegionX += 4;
  2009. mapRegionDidChange = true;
  2010. }
  2011. if (currentY < 2 * 8) {
  2012. deltaY = 4 * 8;
  2013. mapRegionY -= 4;
  2014. mapRegionDidChange = true;
  2015. } else if (currentY >= 11 * 8) {
  2016. deltaY = -4 * 8;
  2017. mapRegionY += 4;
  2018. mapRegionDidChange = true;
  2019. }
  2020. if (dir1 != -1 || dir2 != -1) {
  2021. //checkVisiblePlayers();
  2022. }
  2023. if (mapRegionDidChange) {
  2024.  
  2025. // have to adjust all relative coordinates
  2026. println_debug("Region: " + mapRegionX+" "+mapRegionY);
  2027. currentX += deltaX;
  2028. currentY += deltaY;
  2029. for (int i = 0; i < Constants.WALKING_QUEUE_SIZE; i++) {
  2030. walkingQueueX[i] += deltaX;
  2031. walkingQueueY[i] += deltaY;
  2032. }
  2033. }
  2034.  
  2035. }
  2036.  
  2037. if (mapRegionDidChange || heightLevelDidChange) {
  2038. zoneRequired = true;
  2039. //println_debug("Region: " + mapRegionX+" "+mapRegionY);
  2040. }
  2041. }
  2042.  
  2043. // handles anything related to character position, i.e. walking,running and
  2044. // teleportation
  2045. // applies only to the char and the client which is playing it
  2046. /*public void updateThisPlayerMovement(Stream str) {
  2047. if (mapRegionDidChange) {
  2048. str.createFrame(73);
  2049. str.writeWordA(mapRegionX + 6); // for some reason the client
  2050. // substracts 6 from those values
  2051. str.writeWord(mapRegionY + 6);
  2052. }
  2053.  
  2054. if (didTeleport) {
  2055. str.createFrameVarSizeWord(81);
  2056. str.initBitAccess();
  2057. str.writeBits(1, 1);
  2058. str.writeBits(2, 3); // updateType
  2059. str.writeBits(2, getHeightLevel());
  2060. str.writeBits(1, 1); // set to true, if discarding (clientside)
  2061. // walking queue
  2062. str.writeBits(1, (updateRequired) ? 1 : 0);
  2063. str.writeBits(7, currentY);
  2064. str.writeBits(7, currentX);
  2065. return;
  2066. }
  2067.  
  2068. if (dir1 == -1) {
  2069. // don't have to update the character position, because we're just
  2070. // standing
  2071. str.createFrameVarSizeWord(81);
  2072. str.initBitAccess();
  2073. if (updateRequired) {
  2074. // tell client there's an update block appended at the end
  2075. str.writeBits(1, 1);
  2076. str.writeBits(2, 0);
  2077. } else
  2078. str.writeBits(1, 0);
  2079. } else {
  2080. str.createFrameVarSizeWord(81);
  2081. str.initBitAccess();
  2082. str.writeBits(1, 1);
  2083.  
  2084. if (dir2 == -1) {
  2085. // send "walking packet"
  2086. str.writeBits(2, 1); // updateType
  2087. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  2088. if (updateRequired)
  2089. str.writeBits(1, 1); // tell client there's an update block
  2090. // appended at the end
  2091. else
  2092. str.writeBits(1, 0);
  2093. } else {
  2094. // send "running packet"
  2095. str.writeBits(2, 2); // updateType
  2096. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  2097. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  2098. if (updateRequired)
  2099. str.writeBits(1, 1); // tell client there's an update block
  2100. // appended at the end
  2101. else
  2102. str.writeBits(1, 0);
  2103. }
  2104. }
  2105.  
  2106. }
  2107.  
  2108. // handles anything related to character position basically walking, running
  2109. // and standing
  2110. // applies to only to "non-thisPlayer" characters
  2111. public void updatePlayerMovement(Stream str) {
  2112. if (dir1 == -1) {
  2113. // don't have to update the character position, because the char is
  2114. // just standing
  2115. if (updateRequired || chatTextUpdateRequired) {
  2116. // tell client there's an update block appended at the end
  2117. str.writeBits(1, 1);
  2118. str.writeBits(2, 0);
  2119. } else
  2120. str.writeBits(1, 0);
  2121. } else if (dir2 == -1) {
  2122. // send "walking packet"
  2123. str.writeBits(1, 1);
  2124. str.writeBits(2, 1);
  2125. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  2126. str
  2127. .writeBits(1,
  2128. (updateRequired || chatTextUpdateRequired) ? 1 : 0);
  2129. } else {
  2130. // send "running packet"
  2131. str.writeBits(1, 1);
  2132. str.writeBits(2, 2);
  2133. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  2134. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  2135. str
  2136. .writeBits(1,
  2137. (updateRequired || chatTextUpdateRequired) ? 1 : 0);
  2138. }
  2139. }*/
  2140. public ArrayList<Integer> addPlayerList = new ArrayList<Integer>();
  2141. public int addPlayerSize = 0;
  2142.  
  2143. /**
  2144. * Checks for nearby visible players that aren't being updated.
  2145. */
  2146. private void checkVisiblePlayers() {
  2147. for (int i = 0; i < Constants.MAXIMUM_PLAYERS; i++) {
  2148. if (Server.getPlayerManager().getPlayers()[i] == null || !Server.getPlayerManager().getPlayers()[i].isActive || Server.getPlayerManager().getPlayers()[i].equals(this))
  2149. continue; // No need to update this player.
  2150.  
  2151. // Check if they're already in the local list.
  2152. int id = Server.getPlayerManager().getPlayers()[i].playerId;
  2153. if ((playerInListBitmap[id >> 3] & (1 << (id & 7))) != 0)
  2154. continue;
  2155.  
  2156. // Are they already queued to be added?
  2157. if (newPlayers.contains(Server.getPlayerManager().getPlayers()[i]))
  2158. continue;
  2159.  
  2160. // Perform the distance check.
  2161. if (!withinDistance(Server.getPlayerManager().getPlayers()[i]))
  2162. continue;
  2163.  
  2164. // Add each to the others list.
  2165. newPlayers.add(Server.getPlayerManager().getPlayers()[i]);
  2166. Server.getPlayerManager().getPlayers()[i].newPlayers.add(this);
  2167. }
  2168. }
  2169.  
  2170. public void updateThisPlayerMovement(Stream str) {
  2171. if (dir1 != -1 || dir2 != -1){
  2172. //checkVisiblePlayers(); // they/you could come in or out of their/your area
  2173. }
  2174. if(mapRegionDidChange) {
  2175. str.createFrame(73);
  2176. str.writeWordA(mapRegionX+6);
  2177. str.writeWord(mapRegionY+6);
  2178. }
  2179.  
  2180. if(didTeleport) {
  2181. str.createFrameVarSizeWord(81);
  2182. str.initBitAccess();
  2183. str.writeBits(1, 1);
  2184. str.writeBits(2, 3);
  2185. str.writeBits(2, getHeightLevel());
  2186. str.writeBits(1, 1);
  2187. str.writeBits(1, (updateRequired) ? 1 : 0);
  2188. str.writeBits(7, currentY);
  2189. str.writeBits(7, currentX);
  2190. return ;
  2191. }
  2192.  
  2193.  
  2194. if(dir1 == -1) {
  2195. // don't have to update the character position, because we're just standing
  2196. str.createFrameVarSizeWord(81);
  2197. str.initBitAccess();
  2198. isMoving = false;
  2199. if(updateRequired) {
  2200. // tell client there's an update block appended at the end
  2201. str.writeBits(1, 1);
  2202. str.writeBits(2, 0);
  2203. } else {
  2204. str.writeBits(1, 0);
  2205. }
  2206. if (DirectionCount < 50) {
  2207. DirectionCount++;
  2208. }
  2209. } else {
  2210. DirectionCount = 0;
  2211. str.createFrameVarSizeWord(81);
  2212. str.initBitAccess();
  2213. str.writeBits(1, 1);
  2214.  
  2215. if(dir2 == -1) {
  2216. isMoving = true;
  2217. str.writeBits(2, 1);
  2218. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  2219. if(updateRequired) str.writeBits(1, 1);
  2220. else str.writeBits(1, 0);
  2221. }
  2222. else {
  2223. isMoving = true;
  2224. str.writeBits(2, 2);
  2225. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  2226. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  2227. if(updateRequired) str.writeBits(1, 1);
  2228. else str.writeBits(1, 0);
  2229. }
  2230. }
  2231.  
  2232. }
  2233.  
  2234.  
  2235. public void updatePlayerMovement(Stream str) {
  2236. if(dir1 == -1) {
  2237. if(updateRequired || chatTextUpdateRequired) {
  2238.  
  2239. str.writeBits(1, 1);
  2240. str.writeBits(2, 0);
  2241. }
  2242. else str.writeBits(1, 0);
  2243. }
  2244. else if(dir2 == -1) {
  2245.  
  2246. str.writeBits(1, 1);
  2247. str.writeBits(2, 1);
  2248. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  2249. str.writeBits(1, (updateRequired || chatTextUpdateRequired) ? 1: 0);
  2250. }
  2251. else {
  2252.  
  2253. str.writeBits(1, 1);
  2254. str.writeBits(2, 2);
  2255. str.writeBits(3, Misc.xlateDirectionToClient[dir1]);
  2256. str.writeBits(3, Misc.xlateDirectionToClient[dir2]);
  2257. str.writeBits(1, (updateRequired || chatTextUpdateRequired) ? 1: 0);
  2258. }
  2259. }
  2260. public void stopMovement() {
  2261. if(respawnTimer > 0 || isDead) {
  2262. return;
  2263. }
  2264. if(teleportToX <= 0 && teleportToY <= 0) {
  2265. teleportToX = absX;
  2266. teleportToY = absY;
  2267. }
  2268.  
  2269. newWalkCmdSteps = 0;
  2270. newWalkCmdX[0] = newWalkCmdY[0] = travelBackX[0] = travelBackY[0] = 0;
  2271. getNextPlayerMovement();
  2272. }
  2273. // a bitmap of players that we want to keep track of whether char appearance
  2274. // has changed so
  2275. // we know if we have to transmit those or can make use of the cached char
  2276. // appearances in the client
  2277. public byte cachedPropertiesBitmap[] = new byte[(Constants.MAXIMUM_PLAYERS + 7) >> 3];
  2278.  
  2279. public void addNewPlayer(Player plr, Stream str, Stream updateBlock) {
  2280. int id = plr.playerId;
  2281. playerInListBitmap[id >> 3] |= 1 << (id & 7); // set the flag
  2282. playerList[playerListSize++] = plr;
  2283.  
  2284. str.writeBits(11, id); // client doesn't seem to like id=0
  2285.  
  2286. // TODO: properly implement the character appearance handling
  2287. // send this everytime for now and don't make use of the cached ones in
  2288. // client
  2289. str.writeBits(1, 1); // set to true, if player definitions follow below
  2290. boolean savedFlag = plr.appearanceUpdateRequired;
  2291. boolean savedUpdateRequired = plr.updateRequired;
  2292. plr.appearanceUpdateRequired = true;
  2293. plr.updateRequired = true;
  2294. plr.appendPlayerUpdateBlock(updateBlock);
  2295. plr.appearanceUpdateRequired = savedFlag;
  2296. plr.updateRequired = savedUpdateRequired;
  2297.  
  2298. str.writeBits(1, 1); // set to true, if we want to discard the
  2299. // (clientside) walking queue
  2300. // no idea what this might be useful for yet
  2301. int z = plr.getAbsY() - getAbsY();
  2302. if (z < 0)
  2303. z += 32;
  2304. str.writeBits(5, z); // y coordinate relative to thisPlayer
  2305. z = plr.getAbsX() - getAbsX();
  2306. str.writeBits(5, z); // x coordinate relative to thisPlayer
  2307. }
  2308.  
  2309. // player appearance related stuff
  2310. public boolean appearanceUpdateRequired = true; // set to true if the player
  2311. // appearance wasn't
  2312. // synchronized
  2313. // with the clients yet or changed recently
  2314. public int playerStatusMask = 0;
  2315. public int playerSkullMask = 0;
  2316. public boolean isMaskSupported = false;
  2317. public int combatLevel = 3;
  2318. protected static Stream playerProps;
  2319. static {
  2320. playerProps = new Stream(new byte[PlayerConstants.PLAYER_PROPS_SIZE]);
  2321. }
  2322. public int playerStandIndex = 0x328;
  2323. public int playerTurnIndex = 0x337;
  2324. public int playerWalkIndex = 0x333;
  2325. public int playerTurn180Index = 0x334;
  2326. public int playerTurn90CWIndex = 0x335;
  2327. public int playerTurn90CCWIndex = 0x336;
  2328. public int playerRunIndex = 0x338;
  2329. public int skulls = 0;
  2330. public int hint = 0;
  2331. public boolean playerIsNPC = false;
  2332. public int playerNPCID = 555;//incase of error
  2333. protected void appendPlayerAppearance(Stream str) {
  2334. playerProps.currentOffset = 0;
  2335.  
  2336. playerProps.writeByte(playerAppearance[0]); // player sex. 0=Male and 1=Female
  2337. //playerProps.writeByte(skulls);
  2338. //playerProps.writeByte(hint);
  2339. playerProps.writeByte(headIcon);
  2340. playerProps.writeByte(skullIcon);
  2341. if(!playerIsNPC){
  2342. if (playerEquipment[PlayerConstants.PLAYER_HAT] > 1)
  2343. playerProps.writeWord(0x200 + playerEquipment[PlayerConstants.PLAYER_HAT]);
  2344. else
  2345. playerProps.writeByte(0);
  2346.  
  2347. if (playerEquipment[PlayerConstants.PLAYER_CAPE] > 1)
  2348. playerProps.writeWord(0x200 + playerEquipment[PlayerConstants.PLAYER_CAPE]);
  2349. else
  2350. playerProps.writeByte(0);
  2351.  
  2352. if (playerEquipment[PlayerConstants.PLAYER_AMULET] > 1)
  2353. playerProps.writeWord(0x200 + playerEquipment[PlayerConstants.PLAYER_AMULET]);
  2354. else
  2355. playerProps.writeByte(0);
  2356.  
  2357. if (playerEquipment[PlayerConstants.PLAYER_WEAPON] > 1)
  2358. playerProps.writeWord(0x200 + playerEquipment[PlayerConstants.PLAYER_WEAPON]);
  2359. else
  2360. playerProps.writeByte(0);
  2361.  
  2362. if (playerEquipment[PlayerConstants.PLAYER_CHEST] > 1)
  2363. playerProps.writeWord(0x200 + playerEquipment[PlayerConstants.PLAYER_CHEST]);
  2364. else
  2365. playerProps.writeWord(0x100 + playerAppearance[2]);
  2366.  
  2367. if (playerEquipment[PlayerConstants.PLAYER_SHIELD] > 1)
  2368. playerProps.writeWord(0x200 + playerEquipment[PlayerConstants.PLAYER_SHIELD]);
  2369. else
  2370. playerProps.writeByte(0);
  2371.  
  2372. if (!Item.isPlate(playerEquipment[PlayerConstants.PLAYER_CHEST]))
  2373. playerProps.writeWord(0x100 + playerAppearance[3]);
  2374. else
  2375. playerProps.writeByte(0);
  2376.  
  2377. if (playerEquipment[PlayerConstants.PLAYER_LEGS] > 1)
  2378. playerProps.writeWord(0x200 + playerEquipment[PlayerConstants.PLAYER_LEGS]);
  2379. else
  2380. playerProps.writeWord(0x100 + playerAppearance[5]);
  2381.  
  2382. if (!Item.isFullHelm(playerEquipment[PlayerConstants.PLAYER_HAT])
  2383. && !Item.isFullMask(playerEquipment[PlayerConstants.PLAYER_HAT]))
  2384. playerProps.writeWord(0x100 + playerAppearance[1]); // head
  2385. else
  2386. playerProps.writeByte(0);
  2387.  
  2388. if (playerEquipment[PlayerConstants.PLAYER_HANDS] > 1)
  2389. playerProps.writeWord(0x200 + playerEquipment[PlayerConstants.PLAYER_HANDS]);
  2390. else
  2391. playerProps.writeWord(0x100 +playerAppearance[4]);
  2392.  
  2393. if (playerEquipment[PlayerConstants.PLAYER_FEET] > 1)
  2394. playerProps.writeWord(0x200 + playerEquipment[PlayerConstants.PLAYER_FEET]);
  2395. else
  2396. playerProps.writeWord(0x100 +playerAppearance[6]);
  2397. if (!Item.isFullMask(playerEquipment[PlayerConstants.PLAYER_HAT])
  2398. && (playerAppearance[0] != 1))
  2399. playerProps.writeWord(0x100 + playerAppearance[7]); // Beard
  2400. else
  2401. playerProps.writeByte(0);
  2402. } else {
  2403. playerProps.writeWord(-1);//Tells client that were being a npc
  2404. playerProps.writeWord(playerNPCID);//send NpcID
  2405. }
  2406. if (playerStandIndex > 16000) {
  2407. playerStandIndex = 0x328;
  2408. }
  2409. if ( playerTurnIndex > 16000) {
  2410. playerTurnIndex = 0x337;
  2411. }
  2412. if (playerWalkIndex > 16000) {
  2413. playerWalkIndex = 0x333;
  2414. }
  2415. if (playerTurn180Index > 16000){
  2416. playerTurn180Index = 0x334;
  2417. }
  2418. if (playerTurn90CWIndex > 16000) {
  2419. playerTurn90CWIndex = 0x335;
  2420. }
  2421. if ( playerTurn90CCWIndex > 16000) {
  2422. playerTurn90CCWIndex = 0x336;
  2423. }
  2424. if (playerRunIndex > 16000) {
  2425. playerRunIndex= 0x338;
  2426. }
  2427. playerProps.writeByte(playerAppearance[8]);
  2428. playerProps.writeByte(playerAppearance[9]);
  2429. playerProps.writeByte(playerAppearance[10]);
  2430. playerProps.writeByte(playerAppearance[11]);
  2431. playerProps.writeByte(playerAppearance[12]);
  2432. playerProps.writeWord(playerStandIndex); // standAnimIndex
  2433. playerProps.writeWord(playerTurnIndex); // standTurnAnimIndex
  2434. playerProps.writeWord(playerWalkIndex); // walkAnimIndex
  2435. playerProps.writeWord(playerTurn180Index); // turn180AnimIndex
  2436. playerProps.writeWord(playerTurn90CWIndex); // turn90CWAnimIndex
  2437. playerProps.writeWord(playerTurn90CCWIndex); // turn90CCWAnimIndex
  2438. playerProps.writeWord(playerRunIndex); // runAnimIndex
  2439.  
  2440. /*playerProps.writeByte(pHairC); // hair color
  2441. playerProps.writeByte(pTorsoC); // torso color.
  2442. playerProps.writeByte(pLegsC); // leg color
  2443. playerProps.writeByte(pFeetC); // feet color
  2444. playerProps.writeByte(pSkinC); // skin color (0-6)
  2445.  
  2446. playerProps.writeWord(playerStandIndex); // standAnimIndex
  2447. playerProps.writeWord(playerTurnIndex); // standTurnAnimIndex
  2448. playerProps.writeWord(playerWalkIndex); // walkAnimIndex
  2449. playerProps.writeWord(playerTurn180Index); // turn180AnimIndex
  2450. playerProps.writeWord(playerTurn90CWIndex); // turn90CWAnimIndex
  2451. playerProps.writeWord(playerTurn90CCWIndex); // turn90CCWAnimIndex
  2452. playerProps.writeWord(playerRunIndex); // runAnimIndex */
  2453.  
  2454.  
  2455. playerProps.writeQWord(Misc.playerNameToInt64(playerName));
  2456.  
  2457. //int combatLevel = 0;
  2458. playerProps.putRS2String(getGuild());
  2459. playerProps.putRS2String(getRank());
  2460. playerProps.putRS2String(clanChat);
  2461. playerProps.writeByte(getCombatLevel()); // combat level
  2462. if (Config.v13)
  2463. {
  2464.  
  2465. playerProps.writeWord(skill);
  2466. boolean ChatAllowed = true;
  2467. String legalChars = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ .!@#$%^&*()[]-,'`<>=;?";
  2468. for ( int i = 0; i < title.length(); i++ )
  2469. {
  2470. if ( legalChars.indexOf( title.charAt( i ) ) < 0 )
  2471. {
  2472. ChatAllowed = false;
  2473. }
  2474. }
  2475. if (!ChatAllowed) {
  2476. title = "";
  2477. }
  2478. playerProps.putRS2String(title);
  2479. playerProps.putRS2String("false");
  2480. }
  2481. playerProps.writeWord(0);
  2482.  
  2483. str.writeByteC(playerProps.currentOffset); // size of player appearance
  2484. // block
  2485. str.writeBytes(playerProps.buffer, playerProps.currentOffset, 0);
  2486. }
  2487. public String getGuild() {
  2488. return guild;
  2489. }
  2490. public void setGuild(String value) {
  2491. guild = value;
  2492. }
  2493. public String getRank() {
  2494. return rank;
  2495. }
  2496. public void setRank(String value) {
  2497. rank = value;
  2498. }
  2499.  
  2500. public int extraCb;
  2501. public int getCombatLevel() {
  2502. /*int attack = getLevelForXP(playerXP[0]);
  2503. int defence = getLevelForXP(playerXP[1]);
  2504. int strength = getLevelForXP(playerXP[2]);
  2505. int hitpoints = getLevelForXP(playerXP[3]);
  2506. int ranged = getLevelForXP(playerXP[4]);
  2507. int prayer = getLevelForXP(playerXP[5]);
  2508. int magic = getLevelForXP(playerXP[6]);
  2509.  
  2510. int baseCombat = (defence * 100) + (hitpoints * 100);
  2511. if ((prayer % 2) == 0) {
  2512. baseCombat = (baseCombat + (prayer * 50)) / 400;
  2513. } else {
  2514. baseCombat = (baseCombat + ((prayer - 1) * 50)) / 400;
  2515. }
  2516.  
  2517. int meleeCombat = ((attack * 130) + (strength * 130)) / 400;
  2518.  
  2519. int rangedCombat = ranged * 195;
  2520. if ((ranged % 2) == 1) {
  2521. rangedCombat -= 65;
  2522. }
  2523. rangedCombat /= 400;
  2524.  
  2525. int magicCombat = magic * 195;
  2526. if ((magic % 2) == 1) {
  2527. magicCombat -= 65;
  2528. }
  2529. magicCombat /= 400;
  2530.  
  2531. int classCombat;
  2532. if (meleeCombat >= rangedCombat && meleeCombat >= magicCombat) {
  2533. classCombat = meleeCombat;
  2534. } else if (rangedCombat >= meleeCombat && rangedCombat >= magicCombat) {
  2535. classCombat = rangedCombat;
  2536. } else {
  2537. classCombat = magicCombat;
  2538. }
  2539.  
  2540. int combatLevel = baseCombat + classCombat;
  2541. // It doesn't calculate your combat level properly if you're at the max,
  2542. // or minimum stats, so we just do this.
  2543. if (combatLevel == 2 || attack == 99 && strength == 99 && defence == 99
  2544. && hitpoints == 99 && prayer >= 98 || attack == 99 && strength == 99 && defence == 99
  2545. && hitpoints == 99 && prayer >= 74 || attack == 99 && strength == 99 && defence == 99
  2546. && hitpoints == 99 && prayer >= 82 || attack == 99 && strength == 99 && defence == 99
  2547. && hitpoints == 99 && prayer >= 90) {
  2548. combatLevel++;
  2549. }
  2550.  
  2551.  
  2552. return combatLevel; */
  2553.  
  2554.  
  2555. int j = getLevelForXP(playerXP[0]);
  2556. int k = getLevelForXP(playerXP[1]);
  2557. int l = getLevelForXP(playerXP[2]);
  2558. int i1 = getLevelForXP(playerXP[3]);
  2559. int j1 = getLevelForXP(playerXP[5]);
  2560. int k1 = getLevelForXP(playerXP[4]);
  2561. int l1 = getLevelForXP(playerXP[6]);
  2562. combatLevel = (int)((k + i1 + Math.floor(j1 / 2)) * 0.25D) + 1;
  2563. double d = (j + l) * 0.32500000000000001D;
  2564. double d1 = Math.floor(k1 * 1.5D) * 0.32500000000000001D;
  2565. double d2 = Math.floor(l1 * 1.5D) * 0.32500000000000001D;
  2566. if(d >= d1 && d >= d2 && extraCb == 0)
  2567. {
  2568. combatLevel += d;
  2569. } else
  2570. if(d1 >= d && d1 >= d2 && extraCb == 0)
  2571. {
  2572. combatLevel += d1;
  2573. } else
  2574. if(d2 >= d && d2 >= d1 && extraCb == 0)
  2575. {
  2576. combatLevel += d2;
  2577. } else
  2578. if(extraCb > 0)
  2579. {
  2580. combatLevel = extraCb;
  2581. }
  2582. //if (playerName.equalsIgnoreCase("mars")) { combatLevel=254; return 254; }
  2583. //if (true) {return 126;}
  2584. return combatLevel;
  2585. }
  2586. public int getLevelForXP(int exp) {
  2587. int points = 0;
  2588. int output = 0;
  2589. if (exp > 13034430)
  2590. return 99;
  2591. for (int lvl = 1; lvl < 100; lvl++) {
  2592. points += Math.floor(lvl + 300.0
  2593. * Math.pow(2.0, lvl / 7.0));
  2594. output = (int) Math.floor(points / 4);
  2595. if (output >= exp) {
  2596. return lvl;
  2597. }
  2598. }
  2599. return 0;
  2600. }
  2601.  
  2602. public boolean chatTextUpdateRequired = false;
  2603. public byte chatText[] = new byte[4096];
  2604. public byte chatTextSize = 0;
  2605. public int chatTextEffects = 0;
  2606. public int chatTextColor = 0;
  2607. public boolean playerAppearanceSet = false;
  2608.  
  2609. public boolean animationUpdateRequired = false;
  2610. public int animationRequest = -1, animationWaitCycles;
  2611.  
  2612. protected void appendPlayerChatText(Stream str) {
  2613. str.writeWordBigEndian(((chatTextColor & 0xFF) << 8)
  2614. + (chatTextEffects & 0xFF));
  2615. str.writeByte(playerRights);
  2616. str.writeByteC(chatTextSize);
  2617. str.writeBytes_reverse(chatText, chatTextSize, 0);
  2618. }
  2619.  
  2620. /*private void appendAnimationRequest(Stream str) {
  2621. str.writeWordBigEndian(animationRequest);
  2622. str.writeByteC(animationWaitCycles);
  2623. }*/
  2624. public void appendAnimationRequest(Stream str) {
  2625. if (animationRequest > 16000) {animationRequest = 451;} //crash f
  2626. str.writeWordBigEndian((animationRequest==-1) ? 65535 : animationRequest);
  2627. str.writeByteC(animationWaitCycles);
  2628. }
  2629. // public int focusPointX = -1, focusPointY = -1;
  2630. private void appendSetFocusDestination(Stream str) {
  2631. str.writeWordBigEndianA(focusPointX);
  2632. str.writeWordBigEndian(focusPointY);
  2633. //faceFocusRequired = true;
  2634. updateRequired = true;
  2635. }
  2636.  
  2637.  
  2638.  
  2639. public boolean hitUpdateRequired3, hitUpdateRequired2, hitUpdateRequired = false, poisonHit = false;
  2640. public int hitDiff, hitType, hitDiff2, hitDiff3;
  2641. public int NewHP = getLevelForXP(playerXP[3]);
  2642. public int poisondamg = 0;
  2643. public int poisondamage = 0;
  2644. public int poisontimer = 0;
  2645.  
  2646. private void appendHitUpdate(Stream str) {
  2647. str.writeByte(hitDiff); // What the perseon got 'hit' for
  2648.  
  2649. //if (hitDiff > 0) {
  2650. // str.writeByteA(1); // 0: red hitting - 1: blue hitting
  2651. if (hitDiff > 0 && newhptype == false && poisondmg == false) {
  2652. str.writeByteA(1); // 0: red hitting - 1: blue hitting
  2653. } else if (hitDiff > 0 && poisondmg == true) {
  2654. str.writeByteA(2); // 0: red hitting - 1: blue hitting 2: poison 3: orange
  2655. } else if (hitDiff > 0 && newhptype == true) {
  2656. str.writeByteA(hptype); // 0: red hitting - 1: blue hitting
  2657. } else {
  2658. str.writeByteA(0); // 0: red hitting - 1: blue hitting
  2659. }
  2660. //str.writeByteA(hitType); // 0: red hitting - 1: blue hitting - 2: green
  2661. // hitting - 3,4: orange hitting.
  2662. NewHP = (playerLevel[3]);
  2663. if (NewHP <= 0) {
  2664. poisontimer = 0;
  2665. poisondamg = 0;
  2666. poisondamage = 0;
  2667. NewHP = 0;
  2668. isDead = true;
  2669. playerIndex = 0;
  2670. oldPlayerIndex = 0;
  2671. usingMagic = false;
  2672. faceUpdate(0);
  2673. }
  2674. str.writeByteC(NewHP); // Their current hp, for HP bar
  2675. str.writeByte(((Client) this).getActionAssistant().getLevelForXP(
  2676. playerXP[3])); // Their max hp, for HP bar
  2677. poisondmg = false;
  2678. }
  2679. protected void appendHitUpdate2(Stream str) {
  2680. try {
  2681. str.writeByte(hitDiff2); // What the perseon got 'hit' for
  2682. if (!poisonHit) {
  2683. if (hitDiff2 > 0) {
  2684. str.writeByteS(1);
  2685. } else {
  2686. str.writeByteS(0);
  2687. }
  2688. } else {
  2689. str.writeByteS(2);
  2690. }
  2691.  
  2692. /* //if (hitDiff2 > 0) {
  2693. // str.writeByteS(1); // 0: red hitting - 1: blue hitting
  2694. if (hitDiff2 > 0 && newhptype == false && poisondmg == false) {
  2695. str.writeByteS(1); // 0: red hitting - 1: blue hitting
  2696. } else if (hitDiff2 > 0 && poisondmg) {
  2697. str.writeByteS(2); // 0: red hitting - 1: blue hitting 2: poison 3: orange
  2698. } else if (hitDiff2 > 0 && newhptype == true) {
  2699. str.writeByteS(hptype); // 0: red hitting - 1: blue hitting
  2700. } else {
  2701. str.writeByteS(0); // 0: red hitting - 1: blue hitting
  2702. }*/
  2703. if (playerLevel[3] <= 0) {
  2704. poisontimer = 0;
  2705. poisondamg = 0;
  2706. poisondamage = 0;
  2707. playerLevel[3] = 0;
  2708. isDead = true;
  2709. playerIndex = 0;
  2710. oldPlayerIndex = 0;
  2711. usingMagic = false;
  2712. faceUpdate(0);
  2713. }
  2714. str.writeByte(playerLevel[3]); // Their current hp, for HP bar
  2715. str.writeByteC(getLevelForXP(playerXP[3])); // Their max hp, for HP bar
  2716. } catch(Exception e) {
  2717. e.printStackTrace();
  2718. }
  2719. }
  2720. protected void appendHitUpdate3(Stream str) {
  2721. try {
  2722. str.writeByte(hitDiff3); // What the perseon got 'hit' for
  2723. if (hitDiff3 > 0) {
  2724. str.writeByteS(2); // 0: red hitting - 1: blue hitting
  2725. }
  2726. if (playerLevel[3] <= 0) {
  2727. poisontimer = 0;
  2728. poisondamg = 0;
  2729. poisondamage = 0;
  2730. playerLevel[3] = 0;
  2731. isDead = true;
  2732. playerIndex = 0;
  2733. oldPlayerIndex = 0;
  2734. usingMagic = false;
  2735. faceUpdate(0);
  2736. }
  2737. str.writeByte(playerLevel[3]); // Their current hp, for HP bar
  2738. str.writeByteC(getLevelForXP(playerXP[3])); // Their max hp, for HP bar
  2739. } catch(Exception e) {
  2740. e.printStackTrace();
  2741. }
  2742. }
  2743.  
  2744.  
  2745.  
  2746. public boolean gfxUpdateRequired = false;
  2747. public int gfxId, gfxDelay;
  2748.  
  2749. private void appendGfxUpdate(Stream str) {
  2750. str.writeWordBigEndian(gfxId);
  2751. str.writeDWord(gfxDelay);
  2752. }
  2753.  
  2754. public boolean forceChatUpdateRequired = false;
  2755. public String chatMessage;
  2756. private void appendForceText(Stream str) {
  2757. str.writeString(chatMessage);
  2758. }
  2759.  
  2760. public boolean faceEntityRequired = false;
  2761. public int entityId;
  2762. public boolean isPlayer = false;
  2763. private void appendFaceEntity(Stream str) {
  2764. str.writeWordBigEndian(entityId);
  2765. }
  2766.  
  2767. public boolean secondHitRequired = false;
  2768. private void appendSecondHitUpdate(Stream str) {
  2769. str.writeByte(50);
  2770. str.writeByteS(1);
  2771. str.writeByteC(playerLevel[3]);
  2772. str.writeByte(((Client) this).getActionAssistant().getLevelForXP(playerXP[3]));
  2773. }
  2774.  
  2775. public boolean faceFocusRequired = false;
  2776. public boolean forcedChatUpdateRequired;
  2777.  
  2778. public void forcedChat(String text) {
  2779. forcedText = text;
  2780. forcedChatUpdateRequired = true;
  2781. updateRequired = true;
  2782. appearanceUpdateRequired = true;
  2783. }
  2784. public String forcedText = "null";
  2785. public void appendForcedChat(Stream str) {
  2786. str.writeString(forcedText);
  2787. }
  2788. public void appendPlayerUpdateBlock(Stream str) {
  2789. if (!updateRequired && !chatTextUpdateRequired)
  2790. return; // nothing required
  2791. int updateMask = 0;
  2792. if(mask100update)
  2793. updateMask |= 0x100;
  2794. if (animationRequest != -1)
  2795. updateMask |= 8;
  2796. if(forcedChatUpdateRequired)
  2797. updateMask |= 4;
  2798. if (chatTextUpdateRequired)
  2799. updateMask |= 0x80;
  2800. if (faceUpdateRequired)
  2801. updateMask |= 1;
  2802. if (appearanceUpdateRequired)
  2803. updateMask |= 0x10;
  2804. if (focusPointX != -1 && focusPointY != -1)
  2805. updateMask |= 2;
  2806. if (hitUpdateRequired)
  2807. updateMask |= 0x20;
  2808. if(hitUpdateRequired2) {
  2809. updateMask |= 0x200;
  2810. }
  2811. if (updateMask >= 0x100) {
  2812. updateMask |= 0x40;
  2813. str.writeByte(updateMask & 0xFF);
  2814. str.writeByte(updateMask >> 8);
  2815. } else
  2816. str.writeByte(updateMask);
  2817.  
  2818. if(mask100update)
  2819. appendMask100Update(str);
  2820. if(animationRequest != -1) {
  2821. appendAnimationRequest(str);
  2822. }
  2823. if(forcedChatUpdateRequired)
  2824. appendForcedChat(str);
  2825. if (chatTextUpdateRequired)
  2826. appendPlayerChatText(str);
  2827. if (faceUpdateRequired)
  2828. appendFaceUpdate(str);
  2829. if (appearanceUpdateRequired)
  2830. appendPlayerAppearance(str);
  2831. if (focusPointX != -1 && focusPointY != -1)
  2832. appendSetFocusDestination(str);
  2833. if (hitUpdateRequired)
  2834. appendHitUpdate(str);
  2835. if(hitUpdateRequired2) {
  2836. appendHitUpdate2(str);
  2837. }
  2838. }
  2839.  
  2840. public void clearUpdateFlags(){
  2841. updateRequired = false;
  2842. chatTextUpdateRequired = false;
  2843. appearanceUpdateRequired = false;
  2844. animationUpdateRequired = false;
  2845. hitUpdateRequired = false;
  2846. hitUpdateRequired2 = false;
  2847. hitUpdateRequired3 = false;
  2848. forcedChatUpdateRequired = false;
  2849. mask100update = false;
  2850. animationRequest = -1;
  2851. focusPointX = -1;
  2852. focusPointY = -1;
  2853. faceUpdateRequired = false;
  2854. face = 65535;
  2855. poisonHit = false;
  2856. }
  2857.  
  2858. public int newWalkCmdX[] = new int[Constants.WALKING_QUEUE_SIZE];
  2859. public int newWalkCmdY[] = new int[Constants.WALKING_QUEUE_SIZE];
  2860. public int newWalkCmdSteps = 0;
  2861. public boolean newWalkCmdIsRunning = false;
  2862. protected int travelBackX[] = new int[Constants.WALKING_QUEUE_SIZE];
  2863. protected int travelBackY[] = new int[Constants.WALKING_QUEUE_SIZE];
  2864. protected int numTravelBackSteps = 0;
  2865.  
  2866. public void preProcessing() {
  2867. newWalkCmdSteps = 0;
  2868. }
  2869. public boolean packetLimitIncreased = false;
  2870. public final int MAX_PACKETS_ALLOWED = 16;
  2871. public int packetsHandled = 0, packetsAllowed = 24;
  2872.  
  2873. // is being called regularily every 500ms - do any automatic player actions
  2874. // herein
  2875. public abstract void process();
  2876.  
  2877. public void postProcessing() {
  2878. packetsHandled = 0;
  2879. packetLimitIncreased = false;
  2880. didWalk = false;
  2881. if (newWalkCmdSteps > 0) {
  2882. // place this into walking queue
  2883. // care must be taken and we can't just append this because usually
  2884. // the starting point (clientside) of
  2885. // this packet and the current position (serverside) do not
  2886. // coincide. Therefore we might have to go
  2887. // back in time in order to find a proper connecting vertex. This is
  2888. // also the origin of the character
  2889. // walking back and forth when there's noticeable lag and we keep on
  2890. // seeding walk commands.
  2891. int firstX = newWalkCmdX[0], firstY = newWalkCmdY[0]; // the point
  2892. // we need
  2893. // to
  2894. // connect
  2895. // to from
  2896. // our
  2897. // current
  2898. // position
  2899. // ...
  2900.  
  2901. // travel backwards to find a proper connection vertex
  2902. int lastDir = 0;
  2903. boolean found = false;
  2904. numTravelBackSteps = 0;
  2905. int ptr = wQueueReadPtr;
  2906. int dir = Misc.direction(currentX, currentY, firstX, firstY);
  2907. if (dir != -1 && (dir & 1) != 0) {
  2908. // we can't connect first and current directly
  2909. do {
  2910. lastDir = dir;
  2911. if (--ptr < 0)
  2912. ptr = Constants.WALKING_QUEUE_SIZE - 1;
  2913.  
  2914. travelBackX[numTravelBackSteps] = walkingQueueX[ptr];
  2915. travelBackY[numTravelBackSteps++] = walkingQueueY[ptr];
  2916. dir = Misc.direction(walkingQueueX[ptr],
  2917. walkingQueueY[ptr], firstX, firstY);
  2918. if (lastDir != dir) {
  2919. found = true;
  2920. break; // either of those two, or a vertex between those
  2921. // is a candidate
  2922. }
  2923.  
  2924. } while (ptr != wQueueWritePtr);
  2925. } else
  2926. found = true; // we didn't need to go back in time because the
  2927. // current position
  2928. // already can be connected to first
  2929.  
  2930. if (!found)
  2931. println_debug("Fatal: couldn't find connection vertex! Dropping packet.");
  2932. else {
  2933. wQueueWritePtr = wQueueReadPtr; // discard any yet unprocessed
  2934. // waypoints from queue
  2935.  
  2936. addToWalkingQueue(currentX, currentY); // have to add this in
  2937. // order to keep
  2938. // consistency in the
  2939. // queue
  2940.  
  2941. if (dir != -1 && (dir & 1) != 0) {
  2942. // need to place an additional waypoint which lies between
  2943. // walkingQueue[numTravelBackSteps-2] and
  2944. // walkingQueue[numTravelBackSteps-1] but can be connected
  2945. // to firstX/firstY
  2946.  
  2947. for (int i = 0; i < numTravelBackSteps - 1; i++) {
  2948. addToWalkingQueue(travelBackX[i], travelBackY[i]);
  2949. }
  2950. int wayPointX2 = travelBackX[numTravelBackSteps - 1], wayPointY2 = travelBackY[numTravelBackSteps - 1];
  2951. int wayPointX1, wayPointY1;
  2952. if (numTravelBackSteps == 1) {
  2953. wayPointX1 = currentX;
  2954. wayPointY1 = currentY;
  2955. } else {
  2956. wayPointX1 = travelBackX[numTravelBackSteps - 2];
  2957. wayPointY1 = travelBackY[numTravelBackSteps - 2];
  2958. }
  2959. // we're coming from wayPoint1, want to go in direction
  2960. // wayPoint2 but only so far that
  2961. // we get a connection to first
  2962.  
  2963. // the easiest, but somewhat ugly way:
  2964. // maybe there is a better way, but it involves shitload of
  2965. // different
  2966. // cases so it seems like it isn't anymore
  2967. dir = Misc.direction(wayPointX1, wayPointY1, wayPointX2,
  2968. wayPointY2);
  2969. if (dir == -1 || (dir & 1) != 0) {
  2970. println_debug("Fatal: The walking queue is corrupt! wp1=("
  2971. + wayPointX1
  2972. + ", "
  2973. + wayPointY1
  2974. + "), "
  2975. + "wp2=("
  2976. + wayPointX2
  2977. + ", "
  2978. + wayPointY2
  2979. + ")");
  2980. } else {
  2981. dir >>= 1;
  2982. found = false;
  2983. int x = wayPointX1, y = wayPointY1;
  2984. while (x != wayPointX2 || y != wayPointY2) {
  2985. x += Misc.directionDeltaX[dir];
  2986. y += Misc.directionDeltaY[dir];
  2987. if ((Misc.direction(x, y, firstX, firstY) & 1) == 0) {
  2988. found = true;
  2989. break;
  2990. }
  2991. }
  2992. if (!found) {
  2993. println_debug("Fatal: Internal error: unable to determine connection vertex!"
  2994. + " wp1=("
  2995. + wayPointX1
  2996. + ", "
  2997. + wayPointY1
  2998. + "), wp2=("
  2999. + wayPointX2
  3000. + ", "
  3001. + wayPointY2
  3002. + "), "
  3003. + "first=("
  3004. + firstX + ", " + firstY + ")");
  3005. } else
  3006. addToWalkingQueue(wayPointX1, wayPointY1);
  3007. }
  3008. } else {
  3009. for (int i = 0; i < numTravelBackSteps; i++) {
  3010. addToWalkingQueue(travelBackX[i], travelBackY[i]);
  3011. }
  3012. }
  3013.  
  3014. // now we can finally add those waypoints because we made sure
  3015. // about the connection to first
  3016. for (int i = 0; i < newWalkCmdSteps; i++) {
  3017. addToWalkingQueue(newWalkCmdX[i], newWalkCmdY[i]);
  3018. }
  3019.  
  3020. }
  3021.  
  3022. isRunning = newWalkCmdIsRunning || isRunning2;
  3023. didWalk = true;
  3024. }
  3025. preProcessing();
  3026. }
  3027.  
  3028. public void kick() {
  3029. Client client = (Client) this;
  3030. client.getActionAssistant().logout();
  3031.  
  3032. isKicked = true;
  3033. }
  3034.  
  3035. // npc stuff here
  3036. public static final int maxNPCListSize = NPCManager.MAXIMUM_NPCS;
  3037. public NPC[] npcList = new NPC[maxNPCListSize];
  3038. public int npcListSize = 0;
  3039.  
  3040. // bit at position npcId is set to 1 in case player is currently in
  3041. // playerList
  3042. public byte[] npcInListBitmap = new byte[(NPCManager.MAXIMUM_NPCS + 7) >> 3];
  3043. public boolean rebuildNPCList = false;
  3044. public long timePlayed;
  3045. public boolean hasExpansion;
  3046.  
  3047. public void addNewNPC(NPC npc, Stream str, Stream updateBlock) {
  3048.  
  3049. int slot = npc.getNpcId();
  3050. npcInListBitmap[slot >> 3] |= 1 << (slot & 7); // set the flag
  3051. npcList[npcListSize++] = npc;
  3052.  
  3053. str.writeBits(14, slot); // client doesn't seem to like id=0
  3054.  
  3055. int z = npc.getAbsY() - getAbsY();
  3056. if (z < 0)
  3057. z += 32;
  3058. str.writeBits(5, z); // y coordinate relative to thisPlayer
  3059. z = npc.getAbsX() - getAbsX();
  3060. if (z < 0)
  3061. z += 32;
  3062. str.writeBits(5, z); // x coordinate relative to thisPlayer
  3063.  
  3064. str.writeBits(1, 0); // something??
  3065. str.writeBits(16, npc.getDefinition().getType());
  3066.  
  3067. boolean savedUpdateRequired = npc.isUpdateRequired();
  3068. npc.setUpdateRequired(true);
  3069. npc.appendNPCUpdateBlock(updateBlock);
  3070. npc.setUpdateRequired(savedUpdateRequired);
  3071. str.writeBits(1, 1); // update required
  3072. }
  3073.  
  3074. /**
  3075. * @param playerName
  3076. * the playerName to set
  3077. */
  3078. public void setPlayerName(String playerName) {
  3079. this.playerName = playerName;
  3080. }
  3081.  
  3082. /**
  3083. * @return the playerName
  3084. */
  3085. public String getPlayerName() {
  3086. return playerName;
  3087. }
  3088.  
  3089. /**
  3090. * @param playerPass
  3091. * the playerPass to set
  3092. */
  3093. public void setPlayerPass(String playerPass) {
  3094. this.playerPass = playerPass;
  3095. }
  3096.  
  3097. /**
  3098. * @return the playerPass
  3099. */
  3100. public String getPlayerPass() {
  3101. return playerPass;
  3102. }
  3103.  
  3104. public void setLook(int[] playerAppearance) {
  3105. this.playerAppearance = playerAppearance;
  3106. }
  3107.  
  3108. /**
  3109. * @return the friends
  3110. */
  3111. public int[] getLook() {
  3112. return playerAppearance;
  3113. }
  3114.  
  3115.  
  3116.  
  3117. /**
  3118. * @param friends
  3119. * the friends to set
  3120. */
  3121. public void setFriends(long[] friends) {
  3122. this.friends = friends;
  3123. }
  3124.  
  3125. /**
  3126. * @return the friends
  3127. */
  3128. public long[] getFriends() {
  3129. return friends;
  3130. }
  3131.  
  3132. /**
  3133. * @param ignoresSize
  3134. * the ignoresSize to set
  3135. */
  3136. public void setIgnoresSize(int ignoresSize) {
  3137. this.ignoresSize = ignoresSize;
  3138. }
  3139.  
  3140. /**
  3141. * @return the ignoresSize
  3142. */
  3143. public int getIgnoresSize() {
  3144. return ignoresSize;
  3145. }
  3146.  
  3147. /**
  3148. * @param friendsSize
  3149. * the friendsSize to set
  3150. */
  3151. public void setFriendsSize(int friendsSize) {
  3152. this.friendsSize = friendsSize;
  3153. }
  3154.  
  3155. /**
  3156. * @return the friendsSize
  3157. */
  3158. public int getFriendsSize() {
  3159. return friendsSize;
  3160. }
  3161.  
  3162. /**
  3163. * @param playerMember
  3164. * the playerMember to set
  3165. */
  3166. public void setPlayerMember(boolean playerMember) {
  3167. this.playerMember = playerMember;
  3168. }
  3169.  
  3170. /**
  3171. * @return the playerMember
  3172. */
  3173. public boolean isPlayerMember() {
  3174. return playerMember;
  3175. }
  3176.  
  3177. /**
  3178. * @param ignores
  3179. * the ignores to set
  3180. */
  3181. public void setIgnores(long[] ignores) {
  3182. this.ignores = ignores;
  3183. }
  3184.  
  3185. /**
  3186. * @return the ignores
  3187. */
  3188. public long[] getIgnores() {
  3189. return ignores;
  3190. }
  3191.  
  3192. /**
  3193. * @param playerBankSize
  3194. * the playerBankSize to set
  3195. */
  3196. public void setPlayerBankSize(int playerBankSize) {
  3197. this.playerBankSize = playerBankSize;
  3198. }
  3199.  
  3200. /**
  3201. * @return the playerBankSize
  3202. */
  3203. public int getPlayerBankSize() {
  3204. return playerBankSize;
  3205. }
  3206.  
  3207. /**
  3208. * @param bankXinterfaceID
  3209. * the bankXinterfaceID to set
  3210. */
  3211. public void setBankXinterfaceID(int bankXinterfaceID) {
  3212. this.bankXinterfaceID = bankXinterfaceID;
  3213. }
  3214.  
  3215. /**
  3216. * @return the bankXinterfaceID
  3217. */
  3218. public int getBankXinterfaceID() {
  3219. return bankXinterfaceID;
  3220. }
  3221.  
  3222. /**
  3223. * @param bankXremoveSlot
  3224. * the bankXremoveSlot to set
  3225. */
  3226. public void setBankXremoveSlot(int bankXremoveSlot) {
  3227. this.bankXremoveSlot = bankXremoveSlot;
  3228. }
  3229.  
  3230. /**
  3231. * @return the bankXremoveSlot
  3232. */
  3233. public int getBankXremoveSlot() {
  3234. return bankXremoveSlot;
  3235. }
  3236.  
  3237. /**
  3238. * @param bankXremoveID
  3239. * the bankXremoveID to set
  3240. */
  3241. public void setBankXremoveID(int bankXremoveID) {
  3242. this.bankXremoveID = bankXremoveID;
  3243. }
  3244.  
  3245. /**
  3246. * @return the bankXremoveID
  3247. */
  3248. public int getBankXremoveID() {
  3249. return bankXremoveID;
  3250. }
  3251.  
  3252. public int getId() {
  3253. return playerId;
  3254. }
  3255.  
  3256. public String decodeChat(byte[] msg, int chatLength) {
  3257. int j = 0;
  3258. int k = -1;
  3259. int currentPosition=0;
  3260. aCharArray631 = new char[msg.length];
  3261. for(int l = 0; l < chatLength; l++) {
  3262. int i1 = msg[currentPosition++] & 0xff;
  3263. aCharArray631[j++] = validChars[i1];
  3264. }
  3265. boolean flag1 = true;
  3266. for(int k1 = 0; k1 < j; k1++) {
  3267. char c = aCharArray631[k1];
  3268. if(flag1 && c >= 'a' && c <= 'z') {
  3269. aCharArray631[k1] += '\uFFE0';
  3270. flag1 = false;
  3271. }
  3272. if(c == '.' || c == '!' || c == '?') flag1 = true;
  3273. }
  3274. return new String(aCharArray631, 0, j);
  3275. }
  3276. public int getBountyPoints() {
  3277. return bountyPoints;
  3278. }
  3279. public void setBountyPoints(int bountyPoints) {
  3280. this.bountyPoints = bountyPoints;
  3281. }
  3282. private static char[] aCharArray631 = new char[256];
  3283. private static final char[] validChars = {
  3284. ' ', 'e', 't', 'a', 'o', 'i', 'h', 'n', 's', 'r',
  3285. 'd', 'l', 'u', 'm', 'w', 'c', 'y', 'f', 'g', 'p',
  3286. 'b', 'v', 'k', 'x', 'j', 'q', 'z', '0', '1', '2',
  3287. '3', '4', '5', '6', '7', '8', '9', ' ', '!', '?',
  3288. '.', ',', ':', ';', '(', ')', '-', '&', '*', '\\',
  3289. '\'', '@', '#', '+', '=', '\243', '$', '%', '"', '[',
  3290. ']', '^', '<','>' ,'_'
  3291. };
  3292. public static final int Loyaltypoints = 0;
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement