Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.96 KB | None | 0 0
  1. package palidino76.rs2.players;
  2.  
  3. import java.awt.Point;
  4. import java.io.FileWriter;
  5. import java.io.BufferedWriter;
  6. import java.io.IOException;
  7. import java.net.Socket;
  8. import java.util.Iterator;
  9. import java.util.List;
  10. import java.util.ArrayList;
  11. import java.util.LinkedList;
  12.  
  13. import palidino76.rs2.Engine;
  14. import palidino76.rs2.Server;
  15. import palidino76.rs2.io.Frames;
  16. import palidino76.rs2.net.PlayerSocket;
  17. import palidino76.rs2.util.*;
  18. import palidino76.rs2.players.Trade.Trade;
  19. import palidino76.rs2.npcs.NPC;
  20. import palidino76.rs2.players.items.PlayerWeapon;
  21. import palidino76.rs2.io.packets.*;
  22. import palidino76.rs2.net.*;
  23. import palidino76.rs2.players.update.*;
  24. import palidino76.rs2.players.skills.*;
  25.  
  26. public class Player {
  27.  
  28. public Fishing fishy = new Fishing();
  29. public Mining mini = new Mining();
  30. public Woodcutting woody = new Woodcutting();
  31. public PrayerBury pray = new PrayerBury();
  32. public NPC n;
  33.  
  34. public long lastVeng;
  35. public boolean vengOn = false;
  36. public boolean attackingNPC = false;
  37. public int playerPKDelay = 0;
  38.  
  39. public int combatTimer = 0;
  40. public int prayTimer = 0;
  41.  
  42. public boolean isDoingDfsSpecial = false;
  43. public int dfsCharges = 0;
  44. public boolean canPerformDfsSpecial = true;
  45. public int secondsTillNextDfsSpecial = 0;
  46.  
  47. public int timeoutTimer = 0;
  48.  
  49. public boolean autoRetaliating;
  50.  
  51. public int skullDelay;
  52. public boolean hasSkull;
  53.  
  54. public int muted;
  55. public int muteTimer;
  56. public String clanRoom = "";
  57. public boolean inClanChat = false;
  58. public int tutorial = 0;
  59. public int attackNPC = 0;
  60. public int npcDelay = 0;
  61. public int flaxTimer = 0;
  62.  
  63. public boolean tutorialCompleted = false;
  64.  
  65. public int followPlayer = 0;
  66. public boolean followingPlayer = false;
  67.  
  68. public int newPlayerTimer = 0;
  69.  
  70.  
  71. /**
  72. * Resetting animation
  73. */
  74. public int resetAnimTimer;
  75.  
  76. public void walkingTo(int x, int y) {
  77. int firstX = x - (mapRegionX - 6) * 8;
  78. int firstY = y - (mapRegionY - 6) * 8;
  79. Engine.playerMovement.resetWalkingQueue(this);
  80. Engine.playerMovement.addToWalkingQueue(this, firstX, firstY);
  81. appearanceUpdateReq = true;
  82. updateReq = true;
  83. }
  84.  
  85. /**
  86. * UserInput.
  87. */
  88. public UserInput input = new UserInput(this);
  89.  
  90. /**
  91. * Magic.
  92. */
  93. public int mageDamage;
  94. public int projectileTimer = -1;
  95. public boolean normalHomeTele = false;
  96. public boolean ancientsHomeTele = false;
  97. public int homeTele = 0;
  98. public int homeTeleDelay = 0;
  99. public double arenaSpellPower = 1;
  100. public int magicDelay = 0;
  101. public int freezeDelay = 0;
  102. /**
  103. * Option variable
  104. */
  105. public int optionId;
  106. public int maxArrays = 10;
  107. public boolean[] optionArray = new boolean[maxArrays];
  108.  
  109. /**
  110. * Poisoning
  111. */
  112. public int poisonDelay;
  113. public int poisonHitCount;
  114. public boolean isPoisoned;
  115.  
  116. /**
  117. *Eat delay
  118. */
  119. public int eatDelay = 0;
  120.  
  121. /**
  122. * trade.
  123. */
  124. public Trade trade;
  125. /**
  126. * Destroy item arrays
  127. */
  128. public int[] destroyItem = new int[28];
  129. public int[] destroyItemAmt = new int[28];
  130.  
  131. /**
  132. * NPC Dialogues Stage.
  133. */
  134. public boolean[] stage = new boolean[2];
  135. public int iStage;
  136.  
  137. /**
  138. * Destroy item variable
  139. */
  140. public int destroyItemInt;
  141.  
  142. /**
  143. * Attacking interface data.
  144. */
  145. public int attackStyle = 0;
  146. public int autoRetaliate = 0;
  147.  
  148. /**
  149. * Private messages. Friends Ignores
  150. */
  151. public boolean splitChat = false;
  152. public List<Long> friends = new ArrayList<Long>(200);
  153. public List<Long> ignores = new ArrayList<Long>(100);
  154. /**
  155. * Set Drinking
  156. */
  157. public int drinkDelay = 0;
  158. public int statPotRestoreDelay = 5;
  159. /**
  160. * Player's Note's.
  161. */
  162. public boolean swapAsNote = false;
  163.  
  164. /**
  165. * Prayer settings.
  166. */
  167. public int prayerDrain = 100;
  168. public int drainRate = 0;
  169. public int defLow = 0;
  170. public int strLow = 1;
  171. public int atkLow = 2;
  172. public int rangeLow = 3;
  173. public int mageLow = 4;
  174. public int defMid = 5;
  175. public int strMid = 6;
  176. public int atkMid = 7;
  177. public int rapidRestore = 8;
  178. public int rapidHeal = 9;
  179. public int protItems = 10;
  180. public int rangeMid = 11;
  181. public int Hitter = 5;
  182. public int mageMid = 12;
  183. public int defHigh = 13;
  184. public int strHigh = 14;
  185. public int atkHigh = 15;
  186. public int prayMage = 16;
  187. public int prayRange = 17;
  188. public int prayMelee = 18;
  189. public int rangeHigh = 19;
  190. public int mageHigh = 20;
  191. public int retribution = 21;
  192. public int redepmtion = 22;
  193. public int smite = 23;
  194. public int praySummon = 24;
  195. public int chivalry = 25;
  196. public int piety = 26;
  197. public boolean prayOn[] = new boolean[27];
  198.  
  199. /**
  200. * Player's Skilltab's.
  201. */
  202. public int skillMenu = 0;
  203. /**
  204. * Player's index.
  205. */
  206. public int playerId = 0;
  207. /**
  208. * Class for storing and converting bytes.
  209. */
  210. public Stream stream = new Stream(500, 5000);
  211. /**
  212. * Player's socket for handling most io operations.
  213. */
  214. public PlayerSocket socket;
  215. /**
  216. * Set to true if the player has finished the login stage.
  217. */
  218. public boolean online = false;
  219. /**
  220. * This is for Welcome Interface.
  221. */
  222. public int randomMessage = Misc.random(9);
  223. public int messageCount = 1;
  224. public int memberCount = 0;
  225. /**
  226. * Player's username.
  227. */
  228. public String username = "null";
  229. /**
  230. * Player's password.
  231. */
  232. public String password = "";
  233. /**
  234. * Player's rights.
  235. */
  236. public int rights = 0;
  237.  
  238. public int firstLog = 0;
  239. /**
  240. * 1 set to true means socket disconnected but logged in, both for removing
  241. * the player.
  242. */
  243. public boolean[] disconnected = new boolean[2];
  244. /**
  245. * Gives quick access to the frame class.
  246. */
  247. public Frames frames = Engine.frames;
  248. /**
  249. * The region this player is in.
  250. */
  251. public int mapRegionX = 0;
  252. public int mapRegionY = 0;
  253. /**
  254. * The position this player is at in the map region.
  255. */
  256. public int currentX = 0;
  257. public int currentY = 0;
  258.  
  259. /**
  260. * The slot at which each bank tab starts at
  261. */
  262. public int[] tabStartSlot = new int[11];
  263. /**
  264. * The amount of items that you have last withdrew/deposited with the X
  265. * function
  266. */
  267. public int bankX = 50;
  268. /**
  269. * The tab you are viewing, used to store items in it when depositing
  270. */
  271. public int viewingBankTab = 10;
  272. /**
  273. * If you are withdrawing items as a note
  274. */
  275. public boolean withdrawNote;
  276. /**
  277. * If you are using insert mode
  278. */
  279. public boolean insertMode;
  280.  
  281. /**
  282. * Absolute coordinates this player is at.
  283. */
  284. public int absX = 0;
  285. public int absY = 0;
  286. /**
  287. * KilledBy.
  288. */
  289. public int[] killedBy = new int[Engine.players.length];
  290. /**
  291. * The height level this player is at.
  292. */
  293. public int heightLevel = 0;
  294. /**
  295. * If either are above -1 then the player is in motion.
  296. */
  297. public int walkDir = -1;
  298. public int runDir = -1;
  299. /**
  300. * True if the player is running, false if it isn't.
  301. */
  302. public boolean isRunning = false;
  303. /**
  304. * Set to true if the player has entered a new map region.
  305. */
  306. public boolean mapRegionDidChange = false;
  307. public boolean mouse = false;
  308. public boolean chat = false;
  309. public boolean aid = false;
  310. /**
  311. * Set to true if teleported.
  312. */
  313. public boolean didTeleport = false;
  314. /**
  315. * Set Absolute coordinates to these.
  316. */
  317. public int teleportToX = -1;
  318. public int teleportToY = -1;
  319. /**
  320. * True if the player is requiring an update.
  321. */
  322. public boolean updateReq = false;
  323. /**
  324. * Max number of steps this player can have pending.
  325. */
  326. public int walkingQueueSize = 50;
  327. public int wQueueReadPtr = 0;
  328. public int wQueueWritePtr = 0;
  329.  
  330. /**
  331. * Positions the player is requiring to walk to.
  332. */
  333. public int[] walkingQueueX = new int[walkingQueueSize];
  334. public int[] walkingQueueY = new int[walkingQueueSize];
  335. public int[] walkingQueue = new int[walkingQueueSize];
  336. /**
  337. * All the players within distance.
  338. */
  339. public Player[] playerList = new Player[Engine.players.length];
  340. /**
  341. * All the players stored in distance.
  342. */
  343. public byte[] playersInList = new byte[Engine.players.length];
  344. public int playerListSize = 0;
  345. /**
  346. * True if chat is requiring to be sent.
  347. */
  348. public boolean chatTextUpdateReq = false;
  349. public String chatText = "";
  350. public int chatTextEffects = 0;
  351. /**
  352. * True if an appearance update is needed.
  353. */
  354. public boolean appearanceUpdateReq = false;
  355. /**
  356. * Animation data.
  357. */
  358. public boolean animUpdateReq = false;
  359. public int animReq = -1;
  360. public int animDelay = 0;
  361. /**
  362. * GFX data.
  363. */
  364. public boolean gfxUpdateReq = false;
  365. public int gfxReq = -1;
  366. public int gfxDelay = 0;
  367. /**
  368. * Player and NPC facing data.
  369. */
  370. public boolean faceToUpdateReq = false;
  371. public int faceToReq = -1;
  372. /**
  373. * Damage data.
  374. */
  375. public boolean hit1UpdateReq = false;
  376. public boolean hit2UpdateReq = false;
  377. public int hitDiff1 = 0;
  378. public int hitDiff2 = 0;
  379. public int posionHit1 = 0;
  380. public int posionHit2 = 0;
  381. /**
  382. * Skill level data.
  383. */
  384. public int[] skillLvl = new int[25];
  385. public int[] skillXP = new int[25];
  386. public int combatLevel = 0;
  387. /**
  388. * Player head icons.
  389. */
  390. public int pkIcon = -1;
  391. public int prayerIcon = -1;
  392. public int headIcon = -1;
  393. /**
  394. * Wilderness variables.
  395. */
  396. public int wildyLevel;
  397. /**
  398. * If player updated the Wilderness level.
  399. */
  400. public boolean updatedLevel;
  401. /**
  402. * Wild ditch jumping.
  403. */
  404. public int jumpDelay = 0;
  405. public boolean jumpUpdateReq = false;
  406. public int enemyIndex;
  407. /**
  408. * Equipment data.
  409. */
  410. public int[] equipment = new int[14];
  411. public int[] equipmentN = new int[14];
  412. public int[] equipmentBonus = new int[12];
  413. /**
  414. * Player appearance.
  415. */
  416. public int[] color = new int[5];
  417. public int[] look = new int[7];
  418. public int npcType = -1;
  419. public int gender = 0;
  420. public int[] colour = new int[5];
  421. /**
  422. * Player emotions.
  423. */
  424. public int runEmote = 0x338;
  425. public int walkEmote = 0x333;
  426. public int standEmote = 0x328;
  427. public int attackEmote = 422;
  428. public int BlockEmote = 421;
  429. /**
  430. * All the NPCs within distance.
  431. */
  432. public NPC[] npcList = new NPC[Engine.npcs.length];
  433. /**
  434. * All the NPCs stored in distance.
  435. */
  436. public byte[] npcsInList = new byte[Engine.npcs.length];
  437. public int npcListSize = 0;
  438. /**
  439. * Rebuild the entire NPC list.
  440. */
  441. public boolean rebuildNPCList = false;
  442. /**
  443. * An array storing all the players items.
  444. */
  445. public int[] items = new int[28];
  446. public int[] itemsN = new int[28];
  447. /**
  448. * Open interfaces, use these to confirm an interface is open when trying to
  449. * use one.
  450. */
  451. public int interfaceId = -1;
  452. public int chatboxInterfaceId = -1;
  453. /**
  454. * The current position in the login stage.
  455. */
  456. public int loginStage = 0;
  457. /**
  458. * Click x position.
  459. */
  460. public int clickX = 0;
  461. /**
  462. * Click y position.
  463. */
  464. public int clickY = 0;
  465. /**
  466. * Click id.
  467. */
  468. public int clickId = 0;
  469. /**
  470. * True if the player is trying to pickup an item.
  471. */
  472. public boolean itemPickup = false;
  473. /**
  474. * True if the player is dead.
  475. */
  476. public boolean isDead = false;
  477. /**
  478. * Set run energy.
  479. */
  480. public boolean runEnergyUpdateReq = false;
  481. /**
  482. * Amount of current run energy.
  483. */
  484. public int runEnergy = 100;
  485. /**
  486. * Delay before run energy can increase.
  487. */
  488. public int runEnergyDelay = 0;
  489. /**
  490. * Clicked the first option on a player.
  491. */
  492. public boolean playerOption1 = false;
  493. /**
  494. * Clicked the second option on a player.
  495. */
  496. public boolean playerOption2 = false;
  497. /**
  498. * Clicked the third option on a player.
  499. */
  500. public boolean playerOption3 = false;
  501.  
  502. /**
  503. * Clicked the first option on an object.
  504. */
  505. public boolean objectOption1 = false;
  506. /**
  507. * Setting the players weapon.
  508. */
  509. public PlayerWeapon playerWeapon = new PlayerWeapon(this);
  510. /**
  511. * Clicked the second option on an object.
  512. */
  513. public boolean objectOption2 = false;
  514. /**
  515. * Clicked the options on a NPC.
  516. */
  517. public boolean npcOption2 = false;
  518. public boolean npcOption1 = false;
  519. public boolean npcOption3 = false;
  520. /**
  521. * Forced chat.
  522. */
  523. public String forceChat = "";
  524. public boolean forceChatUpdateReq = false;
  525. /**
  526. * Stat restore delay.
  527. */
  528. public int statRestoreDelay = 75;
  529. /**
  530. * Teleporting variables.
  531. */
  532. public int teleX = -1;
  533. public int teleY = -1;
  534. public int teleDelay = -1;
  535. public int teleFinishGFX = 0;
  536. public int teleFinishGFXHeight = 0;
  537. public int teleFinishAnim = 0;
  538.  
  539. /**
  540. * Special bar data.
  541. */
  542. public boolean specialAmountUpdateReq = false;
  543. public int specialAmountDelay = 0;
  544. public int specialAmount = 100;
  545. public boolean SpecialBar = false;
  546. public boolean usingSpecial = false;
  547. /**
  548. * Delay before receiving packets.
  549. */
  550. public int clickDelay = -1;
  551. public int attackDelay = 5;
  552. public long loginTimeout = System.currentTimeMillis();
  553. public int attackPlayer = 0;
  554. public boolean attackingPlayer = false;
  555. public int combatDelay = 0;
  556. public int deathDelay = 7;
  557. public boolean afterDeathUpdateReq = false;
  558. public int deathMessage = 0;
  559. /**
  560. * Arrays holding the items + their amounts of your bank
  561. */
  562. public int[] bankItems = new int[Engine.playerBank.SIZE];
  563. public int[] bankItemsN = new int[Engine.playerBank.SIZE];
  564.  
  565. @SuppressWarnings("unused")
  566. private boolean mouseOptions = false;
  567. @SuppressWarnings("unused")
  568. private boolean genderOptions = false;
  569. @SuppressWarnings("unused")
  570. private boolean headOptions = false;
  571. @SuppressWarnings("unused")
  572. private boolean bodyOptions = false;
  573.  
  574.  
  575. /**
  576. * Home teleport method.
  577. */
  578. public void homeTeleport(int telex, int teley) {
  579.  
  580. if (homeTele == 16) {
  581. requestAnim(1722, 0);
  582. } else if (homeTele == 15) {
  583. requestAnim(1723, 0);
  584. requestGFX(800, 0);
  585. } else if (homeTele == 14) {
  586. requestAnim(1724, 0);
  587. requestGFX(801, 0);
  588. } else if (homeTele == 13) {
  589. requestAnim(1725, 0);
  590. requestGFX(802, 0);
  591. } else if (homeTele == 12) {
  592. requestAnim(2798, 0);
  593. requestGFX(1703, 0);
  594. } else if (homeTele == 11) {
  595. requestAnim(2799, 0);
  596. requestGFX(1704, 0);
  597. } else if (homeTele == 10) {
  598. requestAnim(2800, 0);
  599. requestGFX(1705, 0);
  600. } else if (homeTele == 9) {
  601. requestAnim(4847, 0);
  602. requestGFX(1706, 0);
  603. } else if (homeTele == 8) {
  604. requestAnim(4848, 0);
  605. requestGFX(1707, 0);
  606. } else if (homeTele == 7) {
  607. requestAnim(4849, 0);
  608. requestGFX(1708, 0);
  609. } else if (homeTele == 6) {
  610. requestAnim(4849, 0);
  611. requestGFX(1709, 0);
  612. } else if (homeTele == 5) {
  613. requestAnim(4849, 0);
  614. requestGFX(1710, 0);
  615. } else if (homeTele == 4) {
  616. requestAnim(4850, 0);
  617. requestGFX(1711, 0);
  618. } else if (homeTele == 3) {
  619. requestAnim(4851, 0);
  620. requestGFX(1712, 0);
  621. } else if (homeTele == 2) {
  622. requestAnim(4852, 0);
  623. requestGFX(1713, 0);
  624. } else if (homeTele == 1) {
  625. homeTeleDelay = 3600;
  626. homeTele = 16;
  627. setCoords(telex, teley, 0);
  628. normalHomeTele = false;
  629. ancientsHomeTele = false;
  630. }
  631. }
  632.  
  633. /**
  634. * Private messages. Friends Ignores
  635. */
  636. public void friendsLoggedIn() {
  637. for (Long friend : friends) {
  638. frames.sendFriend(this, friend, getWorld(friend));
  639. }
  640. long[] array = new long[ignores.size()];
  641. int i = 0;
  642. for (Long ignore : ignores) {
  643. if (ignore != null)
  644. array[i++] = ignore;
  645. }
  646. frames.sendIgnores(this, array);
  647. long me = Misc.stringToLong(username);
  648. for (Player p : Engine.players) {
  649. if (p == null)
  650. continue;
  651. if (p.friends.contains(me)) {
  652. p.frames.sendFriend(p, me, 66);
  653. }
  654. }
  655. }
  656.  
  657. public int getWorld(long friend) {
  658. for (Player p : Engine.players) {
  659. if (p != null && p.online) {
  660. if (Misc.stringToLong(p.username) == friend) {
  661. return 66;
  662. }
  663. }
  664. }
  665. return 0;
  666. }
  667.  
  668. /**
  669. * reqWalkQueue & reqWalkQueueBack method.
  670. */
  671. public void reqWalkQueue(int x, int y) {
  672. int firstX = x - (mapRegionX - 6) * 8;
  673. int firstY = y - (mapRegionY - 6) * 8;
  674. Engine.playerMovement.resetWalkingQueue(this);
  675. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY, this);
  676. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY + 1, this);
  677. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY + 2, this);
  678. }
  679.  
  680. public void reqWalkQueueBack(int x, int y) {
  681. int firstX = x - (mapRegionX - 6) * 8;
  682. int firstY = y - (mapRegionY - 6) * 8;
  683. Engine.playerMovement.resetWalkingQueue(this);
  684. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY, this);
  685. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY - 1, this);
  686. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY - 2, this);
  687. }
  688.  
  689. /**
  690. * Working Flared trousers method.
  691. */
  692. public boolean FlaredEquiped() {
  693. if (equipment[7] == 10394) {
  694. return true;
  695. }
  696. return false;
  697. }
  698.  
  699. /**
  700. * canAttackPlayer method.
  701. */
  702. public boolean canAttackPlayer(Player p) {
  703. @SuppressWarnings("unused")
  704. Player p2 = Engine.players[p.attackPlayer];
  705.  
  706. if (p == null || p.isDead) {
  707. return false;
  708. } else if (p.attackPlayer < 1
  709. || p.attackPlayer >= Engine.players.length
  710. || Engine.players[p.attackPlayer] == null) {
  711. return false;
  712. }
  713. if (absX >= 3093 && absY >= 3920 && absX <= 3120 && absY <= 3950) {
  714. return false;
  715. }
  716. return true;
  717.  
  718. }
  719.  
  720. /**
  721. * Restore tabs, hide tabs, used for trading fix bug and equipment bonus.
  722. */
  723. public void restoreTabs(Player p) {
  724. for (int b = 16; b <= 21; b++) {
  725. p.frames.setInterfaceConfig(p, 548, b, false);
  726. }
  727. for (int a = 32; a <= 38; a++) {
  728. p.frames.setInterfaceConfig(p, 548, a, false);
  729. }
  730. p.calculateEquipmentBonus();
  731. p.frames.setInterfaceConfig(p, 548, 14, false);
  732. p.frames.setInterfaceConfig(p, 548, 31, false);
  733. p.frames.setInterfaceConfig(p, 548, 63, false);
  734. p.frames.setInterfaceConfig(p, 548, 72, false);
  735. }
  736.  
  737. public void hideTabs(Player p) {
  738. for (int b = 16; b <= 21; b++) {
  739. p.frames.setInterfaceConfig(p, 548, b, true);
  740. }
  741. for (int a = 32; a <= 38; a++) {
  742. p.frames.setInterfaceConfig(p, 548, a, true);
  743. }
  744. p.calculateEquipmentBonus();
  745. p.frames.setInterfaceConfig(p, 548, 14, true);
  746. p.frames.setInterfaceConfig(p, 548, 31, true);
  747. p.frames.setInterfaceConfig(p, 548, 63, true);
  748. p.frames.setInterfaceConfig(p, 548, 72, true);
  749. }
  750.  
  751. public void noMapdata() {
  752. setCoords(3211, 3422, 0);
  753. Engine.playerMovement.getNextPlayerMovement(this);
  754. this.frames.setMapRegion(this);
  755. this.frames.sendMessage(this,
  756. "This region of cs508 is not open to the public.\n");
  757. this.frames.sendMessage(this,
  758. "You have been teleported back to Varrock.");
  759. }
  760.  
  761. public LinkedList<Integer> getRegion() {
  762. LinkedList<Integer> regions = new LinkedList<Integer>();
  763. boolean forceSend = true;
  764. if ((((mapRegionX / 8) == 48) || ((mapRegionX / 8) == 49))
  765. && ((mapRegionY / 8) == 48)) {
  766. forceSend = false;
  767. }
  768.  
  769. if (((mapRegionX / 8) == 48) && ((mapRegionY / 8) == 148)) {
  770. forceSend = false;
  771. }
  772.  
  773. for (int xCalc = (mapRegionX - 6) / 8; xCalc <= ((mapRegionX + 6) / 8); xCalc++) {
  774. for (int yCalc = (mapRegionY - 6) / 8; yCalc <= ((mapRegionY + 6) / 8); yCalc++) {
  775. if (forceSend
  776. || ((yCalc != 49) && (yCalc != 149) && (yCalc != 147)
  777. && (xCalc != 50) && ((xCalc != 49) || (yCalc != 47)))) {
  778. regions.add(yCalc + (xCalc << 1786653352));
  779. }
  780. }
  781. }
  782. return regions;
  783. }
  784.  
  785. public void appendIPBan() {
  786. BufferedWriter bw = null;
  787. @SuppressWarnings("unused")
  788. Socket socket = null;
  789. try {
  790. bw = new BufferedWriter(new FileWriter(
  791. "./data/banned/bannedhosts.dat", true));
  792. bw.write(SocketListener.getAddress(this.socket.socket));
  793. bw.newLine();
  794. bw.flush();
  795. } catch (IOException ioe) {
  796.  
  797. } finally {
  798. if (bw != null) {
  799. try {
  800. bw.close();
  801. } catch (IOException ioe2) {
  802. }
  803. }
  804. }
  805. }
  806.  
  807. public void appendBan() {
  808. BufferedWriter bw = null;
  809. @SuppressWarnings("unused")
  810. Socket socket = null;
  811. try {
  812. bw = new BufferedWriter(new FileWriter(
  813. "./data/banned/bannedusers.dat", true));
  814. bw.write(SocketListener.getAddress(this.socket.socket));
  815. bw.newLine();
  816. bw.flush();
  817. } catch (IOException ioe) {
  818.  
  819. } finally {
  820. if (bw != null) {
  821. try {
  822. bw.close();
  823. } catch (IOException ioe2) {
  824. }
  825. }
  826. }
  827. }
  828.  
  829. public void crossDitch() {
  830.  
  831. clickDelay = 5;
  832. int firstX = 0, firstY = 0;
  833. if (Engine.wildernessArea(absX, absY)) {
  834. frames.removeOverlay(this);
  835. firstX = absX - (mapRegionX - 6) * 8;
  836. firstY = absY - 3 - (mapRegionY - 6) * 8;
  837. } else {
  838. frames.setString(this, "Level: " + getWildernessLevel(), 381, 1);
  839. frames.setOverlay(this, 381);
  840. firstX = absX - (mapRegionX - 6) * 8;
  841. firstY = absY + 3 - (mapRegionY - 6) * 8;
  842. }
  843. Engine.playerMovement.resetWalkingQueue(this);
  844. Engine.playerMovement.addToWalkingQueue(this, firstX, firstY);
  845. walkEmote = 2750;
  846. appearanceUpdateReq = true;
  847. updateReq = true;
  848. }
  849.  
  850. /**
  851. * Calculates wilderness Levels.
  852. */
  853. public int getWildernessLevel() {
  854. wildLevel = (absY - 3520) / 8 + 1;
  855. if (wildLevel < 1)
  856. wildLevel = 1;
  857. return wildLevel;
  858. }
  859.  
  860. /**
  861. * Wilderness level
  862. */
  863. public int wildLevel;
  864.  
  865. /**
  866. * The wilderness area.
  867. */
  868. public boolean wildernessArea(int absX, int absY) {
  869. @SuppressWarnings("unused")
  870. Player p2 = Engine.players[enemyIndex];
  871. if (absX >= 2949 && absX <= 3400 && absY >= 3525 && absY <= 4462) {
  872.  
  873. }
  874. return true;
  875. }
  876.  
  877. public boolean wildy() {
  878. if ((absX >= 2949 && absX <= 3400 && absY >= 3525 && absY <= 4462))
  879. return true;
  880. else
  881. return false;
  882. }
  883.  
  884. public boolean updateFaceCoords = false;
  885. public int faceX = -1;
  886. public int faceY = -1;
  887.  
  888. public void faceCoords(int x, int y) {
  889. faceX = 2 * x + 1;
  890. faceY = 2 * y + 1;
  891. updateFaceCoords = true;
  892. updateReq = true;
  893. }
  894.  
  895. void addWildernessUpdating() {
  896. frames.setString(this, "Level: " + getWildernessLevel(), 381, 1);
  897. if (updatedLevel != Engine.wildernessArea(absX, absY)) {
  898. updatedLevel = Engine.wildernessArea(absX, absY);
  899. if (updatedLevel) {
  900. frames.setOverlay(this, 381);
  901. } else {
  902. wildyLevel = 0;
  903. frames.removeOverlay(this);
  904. }
  905. }
  906. }
  907.  
  908. public Player(Socket socket, int id) {
  909.  
  910. this.socket = new PlayerSocket(this, socket);
  911. playerId = id;
  912. look[1] = 10;
  913. look[2] = 18;
  914. look[3] = 26;
  915. look[4] = 33;
  916. look[5] = 36;
  917. look[6] = 42;
  918. for (int i = 0; i < skillLvl.length; i++) {
  919. skillLvl[i] = 1;
  920. skillXP[i] = 0;
  921. skillLvl[3] = 10;
  922. skillXP[3] = 1154;
  923. }
  924. for (int i = 0; i < items.length; i++) {
  925. items[i] = -1;
  926. }
  927. for (int i = 0; i < equipment.length; i++) {
  928. equipment[i] = -1;
  929. }
  930. for (int i = 0; i < bankItems.length; i++) {
  931. bankItems[i] = -1;
  932. }
  933. trade = new Trade(this);
  934. }
  935.  
  936.  
  937. /**
  938. * This method is called every 600 milliseconds. While this is good for for
  939. * changing integers, this should not be abused. Things that can be handled
  940. * else where should be done in that way, such as clicking the accept button
  941. * in trade should update in the ActionsButton class rather than requiring
  942. * an update for the process to handle.
  943. */
  944. public void process() {
  945. if (disconnected[0]) {
  946. if (trade.getPartner() != null) {
  947. trade.declineTrade();
  948. }
  949. disconnected[1] = true;
  950. }
  951. if (Misc.random(20) == 11) {
  952. Iterator itr = mini.rocks.iterator();
  953. Iterator itr2 = mini.rNames.iterator();
  954. while (itr.hasNext() && (itr2.hasNext())) {
  955. Point nx = (Point) itr.next();
  956. String s = (String) itr2.next();
  957. int id = 11554;
  958. if (s.contains("copper"))
  959. id = 11960;
  960. if (s.contains("tin"))
  961. id = 11959;
  962. if (s.contains("iron"))
  963. id = 37307;
  964. if (s.contains("silver"))
  965. id = 37306;
  966. if (s.contains("gold"))
  967. id = 11185;
  968. if (s.contains("coal"))
  969. id = 11930;
  970. if (s.contains("mith"))
  971. id = 11942;
  972. if (s.contains("adam"))
  973. id = 11939;
  974. if (s.contains("rune"))
  975. id = 2107;
  976. if (s.contains("lime"))
  977. id = 4029;
  978. if (s.contains("element"))
  979. id = 6670;
  980. frames.createGlobalObject(id, 0, nx.x, nx.y, 0, 10);
  981. }
  982. }
  983. if (combatTimer > 0)
  984. {
  985. combatTimer--;
  986. }
  987. if (Server.engine.wildernessArea(this.absX, this.absY))
  988. {
  989. frames.setPlayerOption(this, "Attack", 1);
  990. } else
  991. {
  992. frames.setPlayerOption(this, "Trade", 2);
  993. frames.setPlayerOption(this, "Follow", 3);
  994. }
  995.  
  996. if (mini.mining) {
  997. mini.mineTimer--;
  998. System.out.println("Mining and the time left till fish for "
  999. + this.username + " is " + mini.mineTimer + " : Mining : "
  1000. + mini.mining);
  1001.  
  1002. this.requestAnim(mini.mineEmote, 0);
  1003.  
  1004. if (mini.mineTimer == 0) {
  1005. System.out.println("mine");
  1006. mini.mine(this, mini.mineXP, mini.mineGet, mini.mineEmote,
  1007. mini.mineName);
  1008.  
  1009. }
  1010. }
  1011.  
  1012. if (skullDelay > 0) {
  1013. skullDelay--;
  1014. }
  1015. if (prayTimer > 0)
  1016. {
  1017. prayTimer--;
  1018. }
  1019. if (newPlayerTimer > 0)
  1020. {
  1021. newPlayerTimer--;
  1022. }
  1023. if (hasSkull && skullDelay == 0) {
  1024. pkIcon = -1;
  1025. hasSkull = false;
  1026. skullDelay = -1;
  1027. appearanceUpdateReq = true;
  1028. updateReq = true;
  1029. }
  1030.  
  1031. if (fishy.fishing) {
  1032. fishy.fishTimer--;
  1033. System.out.println("Fishing and the time left till fish for "
  1034. + this.username + " is " + fishy.fishTimer);
  1035. if (Misc.random(38) > 35) {
  1036.  
  1037. fishy.resetFishing();
  1038.  
  1039. } else {
  1040.  
  1041. requestAnim(fishy.fishEmote, 0);
  1042.  
  1043. if (fishy.fishTimer == 0) {
  1044. System.out.println("fish");
  1045. fishy.Fish(this, fishy.fishXP, fishy.fishGet,
  1046. fishy.fishEmote, fishy.fishName);
  1047. }
  1048. }
  1049. }
  1050.  
  1051. if (poisonDelay > 0) {
  1052. poisonDelay--;
  1053. }
  1054.  
  1055. if (isPoisoned && poisonDelay == 0) {
  1056. appendHit(Misc.random(6), 1);
  1057. if (posionHit1 == 0) {
  1058. posionHit1 = 4;
  1059. }
  1060. poisonHitCount++;
  1061. poisonDelay = 45;
  1062. }
  1063. if (isPoisoned && poisonHitCount >= 7) {
  1064. isPoisoned = false;
  1065. poisonHitCount = 0;
  1066. frames.sendMessage(this, "After time, the poison has worn off.");
  1067. }
  1068. if (statRestoreDelay > 0) {
  1069. statRestoreDelay--;
  1070. }
  1071. if (drinkDelay > 0) {
  1072. drinkDelay--;
  1073. }
  1074. if (magicDelay > 0) {
  1075. magicDelay--;
  1076. }
  1077. if (homeTeleDelay > 0) {
  1078. homeTeleDelay--;
  1079. }
  1080. if (playerPKDelay > 0)
  1081. {
  1082. playerPKDelay--;
  1083. }
  1084. if (homeTele > 0 && homeTeleDelay <= 0 && normalHomeTele) {
  1085. homeTeleport(3221, 3221);
  1086. homeTele--;
  1087. }
  1088. if (freezeDelay > 0) {
  1089. freezeDelay--;
  1090. stopMovement(this);
  1091. } else if (freezeDelay == 0) {
  1092.  
  1093. }
  1094. if (followingPlayer) {
  1095. Engine.playerFollow.followPlayer(this);
  1096. }
  1097. if (eatDelay > 0) {
  1098. eatDelay--;
  1099. }
  1100. if (flaxTimer > 0) {
  1101. flaxTimer--;
  1102. }
  1103. if (jumpDelay > 0) {
  1104. jumpDelay--;
  1105. jumpUpdateReq = true;
  1106. }
  1107. if (jumpUpdateReq) {
  1108. if (jumpDelay >= 1) {
  1109. runEmote = walkEmote = 2750;
  1110. updateReq = appearanceUpdateReq = true;
  1111. }
  1112. if (jumpDelay <= 0) {
  1113. playerWeapon.setWeapon();
  1114. jumpDelay = 0;
  1115. updateReq = appearanceUpdateReq = true;
  1116. }
  1117. jumpUpdateReq = false;
  1118. }
  1119. if (muteTimer > 0) {
  1120. muteTimer--;
  1121. muted = 2;
  1122. }
  1123. if (clickDelay > 0) {
  1124. clickDelay--;
  1125. }
  1126. if (specialAmountDelay > 0) {
  1127. specialAmountDelay--;
  1128. } else {
  1129. if (specialAmount < 100) {
  1130. specialAmount++;
  1131. specialAmountUpdateReq = true;
  1132. }
  1133. specialAmountDelay = 2;
  1134. }
  1135. if (isDead) {
  1136. attackingPlayer = false;
  1137. deathDelay--;
  1138. applyDead();
  1139. }
  1140. if (combatDelay > 0) {
  1141. combatDelay--;
  1142. }
  1143. if (attackingNPC) {
  1144. Engine.playerNPCCombat.attackNPC(this);
  1145. }
  1146. if (teleDelay > 0) {
  1147. teleDelay--;
  1148. }
  1149. if (runEnergyDelay > 0) {
  1150. runEnergyDelay--;
  1151. } else {
  1152. if (rights >= 2) {
  1153. runEnergy = 100;
  1154. }
  1155. if (runEnergy < 100) {
  1156. runEnergy++;
  1157. runEnergyUpdateReq = true;
  1158. }
  1159. if (runEnergy <= 0) {
  1160. isRunning = false;
  1161. frames.setConfig(this, 173, 0);
  1162. }
  1163. runEnergyDelay = 4;
  1164. }
  1165. if (itemPickup) {
  1166. Engine.packets.pickupItem.handlePacket(this, 0, 0);
  1167. }
  1168. if (playerOption1) {
  1169. Engine.packets.playerOption1.handlePacket(this, 0, 0);
  1170. }
  1171. if (playerOption2) {
  1172. Engine.packets.playerOption2.handlePacket(this, 0, 0);
  1173. }
  1174. if (playerOption3) {
  1175. Engine.packets.playerOption3.handlePacket(this, 0, 0);
  1176. }
  1177. if (npcOption1) {
  1178. Engine.packets.npcOption1.handlePacket(this, 0, 0);
  1179. }
  1180. if (npcOption2) {
  1181. Engine.packets.npcOption2.handlePacket(this, 0, 0);
  1182. }
  1183. if (objectOption1) {
  1184. Engine.packets.objectOption1.handlePacket(this, 0, 0);
  1185. }
  1186. if (objectOption2) {
  1187. Engine.packets.objectOption2.handlePacket(this, 0, 0);
  1188. }
  1189. if (attackingPlayer) {
  1190. Engine.playerCombat.attackPlayer(this);
  1191. }
  1192. if (runEnergyUpdateReq) {
  1193. frames.setEnergy(this);
  1194. runEnergyUpdateReq = false;
  1195. }
  1196. if (specialAmountUpdateReq) {
  1197. checkAmount(this);
  1198. specialAmountUpdateReq = false;
  1199. }
  1200. if (afterDeathUpdateReq) {
  1201. for (int i = 0; i < skillLvl.length; i++) {
  1202. skillLvl[i] = getLevelForXP(i);
  1203. frames.setSkillLvl(this, i);
  1204. }
  1205. Prayer pr = new Prayer();
  1206. pr.resetPrayers(this);
  1207. runEnergy = 100;
  1208. specialAmount = 100;
  1209. deathDelay = 8;
  1210. runEnergyUpdateReq = true;
  1211. specialAmountUpdateReq = true;
  1212. isDead = false;
  1213. afterDeathUpdateReq = false;
  1214. }
  1215. if (statRestoreDelay <= 0) {
  1216. for (int i1 = 0; i1 < skillLvl.length; i1++) {
  1217. int xpLvl = getLevelForXP(i1);
  1218. if (skillLvl[i1] < xpLvl) {
  1219. skillLvl[i1]++;
  1220. frames.setSkillLvl(this, i1);
  1221. } else if (skillLvl[i1] > xpLvl) {
  1222. skillLvl[i1]--;
  1223. frames.setSkillLvl(this, i1);
  1224. }
  1225. }
  1226. statRestoreDelay = 75;
  1227. }
  1228. addWildernessUpdating();
  1229. prayerDrain -= drainRate;
  1230. if (prayerDrain <= 0 && skillLvl[5] > 0) {
  1231. skillLvl[5]--;
  1232. frames.setSkillLvl(this, 5);
  1233. if (skillLvl[5] <= 0) {
  1234. Prayer pr = new Prayer();
  1235. pr.resetPrayers(this);
  1236. frames.sendMessage(this, "You have run out of prayer points.");
  1237. }
  1238. prayerDrain = 100;
  1239. }
  1240. if (teleDelay == 0) {
  1241. teleDelay = -1;
  1242. setCoords(teleX, teleY, heightLevel);
  1243. requestAnim(teleFinishAnim, 0);
  1244. requestGFX(teleFinishGFX, teleFinishGFXHeight);
  1245. teleX = teleY = -1;
  1246. }
  1247. if (clickDelay == 0) {
  1248. clickDelay = -1;
  1249. }
  1250. }
  1251.  
  1252. public void stopMovement(Player p) {
  1253. if (p == null) {
  1254. return;
  1255. }
  1256. if (p.teleportToX == -1 && p.teleportToY == -1) {
  1257. p.teleportToX = p.absX;
  1258. p.teleportToY = p.absY;
  1259. }
  1260. p.walkingQueueX[0] = 0;
  1261. p.walkingQueueY[0] = 0;
  1262. p.walkingQueue[0] = 0;
  1263. }
  1264.  
  1265. public void dropAllItems(Player p) {
  1266. Player p2 = Engine.players[p.attackPlayer];
  1267. if (p2 == null) {
  1268. return;
  1269. }
  1270. for (int i = 0; i < items.length; i++) {
  1271. if (items[i] > 0) {
  1272. if (Engine.items.isUntradable(items[i])) {
  1273. Engine.items.createGroundItem(items[i], itemsN[i], absX,
  1274. absY, heightLevel, username);
  1275. } else {
  1276. Engine.items.createGroundItem(items[i], itemsN[i], absX,
  1277. absY, heightLevel, p2.username);
  1278. }
  1279. items[i] = -1;
  1280. itemsN[i] = 0;
  1281. }
  1282. }
  1283. for (int i = 0; i < equipment.length; i++) {
  1284. if (equipment[i] > 0) {
  1285. if (Engine.items.isUntradable(equipment[i])) {
  1286. Engine.items.createGroundItem(equipment[i], equipmentN[i],
  1287. absX, absY, heightLevel, username);
  1288. } else {
  1289. Engine.items.createGroundItem(equipment[i], equipmentN[i],
  1290. absX, absY, heightLevel, p2.username);
  1291. }
  1292. equipment[i] = -1;
  1293. equipmentN[i] = 0;
  1294. }
  1295. }
  1296. Engine.items.createGroundItem(526, 1, absX, absY, heightLevel,
  1297. p2.username); // drop bones
  1298. deathMessage = Misc.random(8);
  1299. if (deathMessage == 0) {
  1300. p.frames.sendMessage(p2, "With a crushing blow, you defeat "
  1301. + username + ".");
  1302. } else if (deathMessage == 1) {
  1303. p.frames.sendMessage(p2, "It's a humiliating defeat for "
  1304. + username + ".");
  1305. } else if (deathMessage == 2) {
  1306. p.frames.sendMessage(p2, username
  1307. + " didn't stand a chance against you.");
  1308. } else if (deathMessage == 3) {
  1309. p.frames.sendMessage(p2, "You have defeated " + username + ".");
  1310. } else if (deathMessage == 4) {
  1311. p.frames.sendMessage(p2, username
  1312. + " regrets the day they met you in combat.");
  1313. } else if (deathMessage == 5) {
  1314. p.frames.sendMessage(p2, "It's all over for " + username + ".");
  1315. } else if (deathMessage == 6) {
  1316. p.frames.sendMessage(p2, username + " falls before your might.");
  1317. } else if (deathMessage == 7) {
  1318. p.frames.sendMessage(p2, "Can anyone defeat you? Certainly not "
  1319. + username + ".");
  1320. } else if (deathMessage == 8) {
  1321. p.frames.sendMessage(p2, "You were clearly a better fighter than "
  1322. + username + ".");
  1323. }
  1324. frames.setItems(this, 149, 0, 93, items, itemsN);
  1325. frames.setItems(this, 387, 28, 94, equipment, equipmentN);
  1326. playerWeapon.setWeapon();
  1327. calculateEquipmentBonus();
  1328. }
  1329.  
  1330. /**
  1331. * Get XP based on your level.
  1332. *
  1333. * @param skillId
  1334. * The skill level to get the level based off XP for
  1335. * @return Returns the level based on the amount of XP the specified skill
  1336. * has
  1337. */
  1338. public int getLevelForXP(int skillId) {
  1339. int exp = skillXP[skillId];
  1340. int points = 0;
  1341. int output = 0;
  1342. for (int lvl = 1; lvl < 100; lvl++) {
  1343. points += Math.floor((double) lvl + 300.0
  1344. * Math.pow(2.0, (double) lvl / 7.0));
  1345. output = (int) Math.floor(points / 4);
  1346. if ((output - 1) >= exp) {
  1347. return lvl;
  1348. }
  1349. }
  1350. return 99;
  1351. }
  1352.  
  1353. public void applyDead() {
  1354. if (prayerIcon == 3 && deathDelay == 1) {
  1355. for (Player ps : Engine.players) {
  1356. if (ps != null) {
  1357. if (ps.absX < absX + 5 && ps.absY < absY + 5
  1358. && ps.absX > absX - 5 && ps.absY > absY - 5
  1359. && ps.playerId != playerId) {
  1360. ps.requestGFX(437, 0);
  1361. ps.appendHit(5 + Misc.random(15), 0);
  1362. }
  1363. }
  1364. }
  1365. }
  1366.  
  1367. requestAnim(7197, 0);
  1368. if (deathDelay <= 0) {
  1369. dropAllItems(this);
  1370. frames.sendMessage(this, "Oh dear, you have died!");
  1371. if (combatLevel <= 50) {
  1372. frames.showInterface(this, 153);
  1373. }
  1374. isDead = false;
  1375. afterDeathUpdateReq = true;
  1376. attackingPlayer = false;
  1377. requestFaceTo(65535);
  1378. @SuppressWarnings("unused")
  1379. Player en = Engine.players[this.enemyIndex];
  1380. pkIcon = -1;
  1381. teleportToX = 3222 + Misc.random(2);
  1382. teleportToY = 3219 + Misc.random(2);
  1383. pkIcon = -1;
  1384. hasSkull = false;
  1385. skullDelay = -1;
  1386.  
  1387. for (int i = 0; i < skillLvl.length; i++) {
  1388. skillLvl[i] = getLevelForXP(i);
  1389. frames.setSkillLvl(this, i);
  1390. }
  1391. requestAnim(-1, 0);
  1392. updateReq = true;
  1393. appearanceUpdateReq = true;
  1394. faceToUpdateReq = true;
  1395. }
  1396. }
  1397.  
  1398. public boolean[] leveledUp = new boolean[24];
  1399. public int leveledUpSkill = 0;
  1400.  
  1401. public void addSkillXP(double amount, int skill) {
  1402. if (skill > skillXP.length || skill < 0) {
  1403. return;
  1404. }
  1405. int oldLevel = getLevelForXP(skill);
  1406. skillXP[skill] += amount;
  1407. int newLevel = getLevelForXP(skill);
  1408. if (oldLevel < newLevel) {
  1409. if (skill == 3) {
  1410. updateHP(newLevel - oldLevel, true);
  1411. } else {
  1412. skillLvl[skill] += (newLevel - oldLevel);
  1413. }
  1414. frames.setSkillLvl(this, skill);
  1415. @SuppressWarnings("unused")
  1416. LevelUp levelup = new LevelUp(this, skill);
  1417.  
  1418. appearanceUpdateReq = true;
  1419. updateReq = true;
  1420. levelup = null;
  1421. }
  1422. frames.setSkillLvl(this, skill);
  1423. }
  1424.  
  1425. public void calculateEquipmentBonus() {
  1426. for (int i = 0; i < equipmentBonus.length; i++) {
  1427. equipmentBonus[i] = 0;
  1428. }
  1429. for (int i = 0; i < equipment.length; i++) {
  1430. if (equipment[i] > -1) {
  1431. for (int j = 0; j < Engine.items.maxListedItems; j++) {
  1432. if (Engine.items.itemLists[j] != null) {
  1433. if (Engine.items.itemLists[j].itemId == equipment[i]) {
  1434. for (int k = 0; k < equipmentBonus.length; k++) {
  1435. equipmentBonus[k] += Engine.items.itemLists[j].bonuses[k];
  1436. }
  1437. break;
  1438. }
  1439. }
  1440. }
  1441. }
  1442. }
  1443. }
  1444.  
  1445. public void setEquipmentBonus() {
  1446. String[] bonusNames = Misc.bonusNames;
  1447. int id = 35;
  1448. for (int i = 0; i < equipmentBonus.length; i++) {
  1449. frames.setString(this, bonusNames[i] + ": "
  1450. + (equipmentBonus[i] >= 0 ? "+" : "") + equipmentBonus[i],
  1451. 667, id++);
  1452. if (id == 45) {
  1453. id = 47;
  1454. }
  1455. }
  1456. frames.setString(this, "Summoning: +0", 667, 45);
  1457. }
  1458.  
  1459. public void openBank() {
  1460. frames.setConfig2(this, 563, 4194304);
  1461. frames.setConfig2(this, 1248, -2013265920);
  1462. frames.setConfig(this, 115, withdrawNote ? 1 : 0);
  1463. frames.setConfig(this, 305, insertMode ? 1 : 0);
  1464. Engine.playerBank.sendTabConfig(this);
  1465. frames.showInterface(this, 762);
  1466. frames.setInventory(this, 763);
  1467. frames.setBankOptions(this);
  1468. frames.setItems(this, -1, 64207, 95, bankItems, bankItemsN);
  1469. frames.setItems(this, -1, 64209, 93, items, itemsN);
  1470. viewingBankTab = 10;
  1471. frames.setString(this, "" + Engine.playerBank.getFreeBankSlot(this),
  1472. 762, 97);
  1473. frames.setString(this, "" + Engine.playerBank.SIZE, 762, 98);
  1474. }
  1475.  
  1476. public void updateHP(int chHp, boolean heal) {
  1477. if (heal) {
  1478. skillLvl[3] += chHp;
  1479. if (skillLvl[3] > getLevelForXP(3)) {
  1480. skillLvl[3] = getLevelForXP(3);
  1481. }
  1482. } else if (!heal) {
  1483. skillLvl[3] -= chHp;
  1484. if (skillLvl[3] <= 0) {
  1485. skillLvl[3] = 0;
  1486. isDead = true;
  1487. Engine.playerMovement.resetWalkingQueue(this);
  1488. }
  1489. }
  1490. frames.setSkillLvl(this, 3);
  1491. }
  1492.  
  1493. public void updatePRAY(int chPR, boolean pray) {
  1494. if (pray) {
  1495. skillLvl[5] += chPR;
  1496. if (skillLvl[5] > getLevelForXP(5)) {
  1497. skillLvl[5] = getLevelForXP(5);
  1498. }
  1499. }
  1500. frames.setSkillLvl(this, 5);
  1501. }
  1502.  
  1503. /**
  1504. * Teleports a player.
  1505. *
  1506. * @param x
  1507. * The x coordinate to teleport to.
  1508. * @param y
  1509. * The y coordinate to teleport to.
  1510. * @param height
  1511. * The height level to teleport to.
  1512. * @param delay
  1513. * The delay before the teleport is done.
  1514. * @param distance
  1515. * The offset you can teleport to, such as 1 for a max offset of
  1516. * x +/- 1 and y +/- 1.
  1517. * @param emoteStart
  1518. * The emote to do right away.
  1519. * @param emoteEnd
  1520. * The emote to do after teleporting.
  1521. * @param gfxStart
  1522. * The graphic to do right away.
  1523. * @param gfxStartH
  1524. * The height level to create the start graphic at.
  1525. * @param gfxEnd
  1526. * The graphic to do after the teleport is done.
  1527. * @param gfxEndH
  1528. * The finish graphic height.
  1529. */
  1530. public void teleportTo(int x, int y, int height, int delay, int distance,
  1531. int emoteStart, int emoteEnd, int gfxStart, int gfxStartH,
  1532. int gfxEnd, int gfxEndH) {
  1533. itemPickup = false;
  1534. playerOption1 = false;
  1535. playerOption2 = false;
  1536. playerOption3 = false;
  1537. npcOption1 = false;
  1538. npcOption2 = false;
  1539. objectOption1 = false;
  1540. objectOption2 = false;
  1541. attackingPlayer = false;
  1542. clickDelay = delay + 2;
  1543. teleDelay = delay;
  1544. mini.resetMining();
  1545. woody.resetWoodcutting();
  1546. fishy.resetFishing();
  1547. if (distance > 0) {
  1548. int xType = Misc.random(1);
  1549. int yType = Misc.random(1);
  1550. int xOffset = Misc.random(distance);
  1551. int yOffset = Misc.random(distance);
  1552. if (xType == 1)
  1553. x += -xOffset;
  1554. else
  1555. x += xOffset;
  1556. if (yType == 1)
  1557. y += -yOffset;
  1558. else
  1559. y += yOffset;
  1560. }
  1561. teleX = x;
  1562. teleY = y;
  1563. heightLevel = height;
  1564. Engine.playerMovement.resetWalkingQueue(this);
  1565. requestAnim(emoteStart, 0);
  1566. requestGFX(gfxStart, gfxStartH);
  1567. teleFinishGFX = gfxEnd;
  1568. teleFinishGFXHeight = gfxEndH;
  1569. teleFinishAnim = emoteEnd;
  1570. }
  1571.  
  1572. /**
  1573. * Set the player's coordinates.
  1574. *
  1575. * @param x
  1576. * The x coordinate to teleport to.
  1577. * @param y
  1578. * The y coordinate to teleport to.
  1579. */
  1580. public void setCoords(int x, int y, int height) {
  1581.  
  1582. teleportToX = x;
  1583. teleportToY = y;
  1584. heightLevel = height;
  1585. didTeleport = true;
  1586. mini.resetMining();
  1587. woody.resetWoodcutting();
  1588. fishy.resetFishing();
  1589.  
  1590. }
  1591.  
  1592. /**
  1593. * Require an animation for this player.
  1594. *
  1595. * @param animId
  1596. * The animation to perform.
  1597. * @param animD
  1598. * The delay before doing the animation.
  1599. */
  1600. public void requestAnim(int animId, int animD) {
  1601. animReq = animId;
  1602. animDelay = animD;
  1603. animUpdateReq = true;
  1604. updateReq = true;
  1605. }
  1606.  
  1607. /**
  1608. * Require an graphic for this player.
  1609. *
  1610. * @param gfxId
  1611. * The graphic to perform.
  1612. * @param gfxD
  1613. * The delay or height or the GFX depending on the value.
  1614. */
  1615. public void requestGFX(int gfxId, int gfxD) {
  1616. if (gfxD >= 100) {
  1617. gfxD += 6553500;
  1618. }
  1619. gfxReq = gfxId;
  1620. gfxDelay = gfxD;
  1621. gfxUpdateReq = true;
  1622. updateReq = true;
  1623. }
  1624.  
  1625. /**
  1626. * Require this player faces NPC or player.
  1627. *
  1628. * @param faceId
  1629. * The target to face.
  1630. */
  1631. public void requestFaceTo(int faceId) {
  1632. faceToReq = faceId;
  1633. faceToUpdateReq = true;
  1634. updateReq = true;
  1635. }
  1636.  
  1637. /**
  1638. * Append damage.
  1639. */
  1640. public void appendHit(int damage, int posion) {
  1641. boolean useBow = false;
  1642. int wepId = equipment[3];
  1643. if (wepId >= 841 && wepId <= 861 || wepId >= 4212 && wepId <= 4223
  1644. || wepId == 4734 || wepId == 6724 || wepId == 9185) {
  1645. useBow = true;
  1646. }
  1647.  
  1648. if (damage > skillLvl[3]) {
  1649. damage = skillLvl[3];
  1650. }
  1651. updateHP(damage, false);
  1652. if (!hit1UpdateReq) {
  1653. hitDiff1 = damage;
  1654. posionHit1 = posion;
  1655. hit1UpdateReq = true;
  1656. } else {
  1657. hitDiff2 = damage;
  1658. posionHit2 = posion;
  1659. hit2UpdateReq = true;
  1660. }
  1661. updateReq = true;
  1662. }
  1663.  
  1664. /**
  1665. * Force chat text.
  1666. */
  1667. public void requestForceChat(String s) {
  1668. forceChat = s;
  1669. forceChatUpdateReq = true;
  1670. updateReq = true;
  1671. }
  1672.  
  1673. /**
  1674. * Checks special amount and gets configuration.
  1675. */
  1676. public void checkAmount(Player p) {
  1677. int amount = p.specialAmount;
  1678. if (amount == 100) {
  1679. p.frames.setConfig(p, 300, 1000);
  1680. } else if (amount >= 80) {
  1681. p.frames.setConfig(p, 300, 800);
  1682. } else if (amount >= 60) {
  1683. p.frames.setConfig(p, 300, 600);
  1684. } else if (amount >= 50) {
  1685. p.frames.setConfig(p, 300, 500);
  1686. } else if (amount >= 40) {
  1687. p.frames.setConfig(p, 300, 400);
  1688. } else if (amount >= 20) {
  1689. p.frames.setConfig(p, 300, 200);
  1690. } else if (amount >= 0) {
  1691. p.frames.setConfig(p, 300, 0);
  1692. } else {
  1693. // nothing
  1694. }
  1695. }
  1696.  
  1697. /**
  1698. * Prepare player for removal.
  1699. */
  1700. public void destruct() {
  1701. stream = null;
  1702. long me = Misc.stringToLong(username);
  1703. for (Player p : Engine.players) {
  1704. if (p == null)
  1705. continue;
  1706. if (p.friends.contains(me)) {
  1707. p.frames.sendFriend(p, me, 0);
  1708. }
  1709. }
  1710. try {
  1711. socket.input.close();
  1712. socket.output.close();
  1713. socket.socket.close();
  1714. } catch (Exception e) {
  1715. }
  1716. socket.input = null;
  1717. socket.output = null;
  1718. socket.socket = null;
  1719. socket = null;
  1720. absX = absY = mapRegionX = mapRegionY = -1;
  1721. }
  1722. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement