Advertisement
Guest User

Untitled

a guest
Sep 15th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 59.51 KB | None | 0 0
  1. /*
  2. * Class Player
  3. *
  4. * Version 1.0
  5. *
  6. * Thursday, August 14, 2008
  7. *
  8. * Created by Palidino76
  9. */
  10.  
  11. package palidino76.rs2.players;
  12.  
  13. import java.io.FileWriter;
  14. import java.io.BufferedWriter;
  15. import java.io.IOException;
  16. import java.net.Socket;
  17. import java.util.List;
  18. import java.util.ArrayList;
  19. import java.util.LinkedList;
  20. import palidino76.rs2.Engine;
  21. import palidino76.rs2.Server;
  22. import palidino76.rs2.io.PacketManager;
  23. import palidino76.rs2.io.Frames;
  24. import palidino76.rs2.net.PlayerSocket;
  25. import palidino76.rs2.net.SocketListener;
  26. import palidino76.rs2.util.*;
  27. import palidino76.rs2.npcs.NPC;
  28. import palidino76.rs2.npcs.combat.NPCPlayerCombat;
  29. import palidino76.rs2.players.items.PlayerWeapon;
  30. import palidino76.rs2.players.misc.LevelUp;
  31. import palidino76.rs2.players.trade.Trade;
  32. import palidino76.rs2.io.packets.*;
  33. import palidino76.rs2.players.combat.MagicNPC;
  34. import palidino76.rs2.Skills.runeCrafting.runecrafting;
  35. import palidino76.rs2.Skills.*;
  36. import palidino76.rs2.world.RandomMessages;
  37.  
  38. public class Player {
  39.  
  40.  
  41.  
  42. /**
  43. *Autoskillcape Trimming
  44. */
  45. public int[] untrimmedSkillcapes= {
  46. 9747, 9750, 9753, 9756, 9759, 9762,
  47. 9765, 9768, 9771, 9774, 9777, 9780,
  48. 9783, 9786, 9789, 9792, 9795, 9798,
  49. 9801, 9804, 9807, 9810, 9948, 12169
  50. };
  51.  
  52. public int[] trimmedSkillcapes= {
  53. 9748, 9751, 9754, 9757, 9760, 9763,
  54. 9766, 9769, 9772, 9775, 9778, 9781,
  55. 9784, 9787, 9790, 9793, 9796, 9799,
  56. 9802, 9805, 9808, 9811, 9949, 12170
  57. };
  58.  
  59. public boolean needsTrimmedCape() {
  60. int maxedOutSkills = 0;
  61. for (int i = 0; i < 25; i++) {
  62. if (this.getLevelForXP(i) == 99) {
  63. maxedOutSkills++;
  64. }
  65. }
  66. if (maxedOutSkills >= 2) {
  67. return true;
  68. } else {
  69. return false;
  70. }
  71. }
  72.  
  73. public void replaceUntrimmedWithTrimmedCapes(Player p) {
  74. for (int i = 0; i < untrimmedSkillcapes.length; i++) {
  75. for (int i2 = 0; i2 < p.bankItems.length; i2++) {
  76. if (p.bankItems[i2] == untrimmedSkillcapes[i]) {
  77. p.bankItems[i2] = trimmedSkillcapes[i];
  78. }
  79. }
  80. for (int i3 = 0; i3 < p.items.length; i3++) {
  81. if (p.items[i3] == untrimmedSkillcapes[i]) {
  82. p.items[i3] = trimmedSkillcapes[i];
  83. }
  84. }
  85. if (p.equipment[1] == untrimmedSkillcapes[i]) {
  86. p.equipment[1] = trimmedSkillcapes[i];
  87. }
  88. }
  89. }
  90. }
  91.  
  92. /**
  93. *Donator Shop
  94. */
  95. public boolean IsShopping = false;
  96. public int MyShopID = 0;
  97. public boolean UpdateShop = false;
  98.  
  99.  
  100. /*
  101. *Poisonning
  102. */
  103. public int poisonDelay;
  104. public int poisonHitCount;
  105. public boolean isPoisoned;
  106.  
  107. /**
  108. * Random Message
  109. */
  110. public int time = 0;
  111.  
  112. /**
  113. * Skills Cooking/Herb/Farming/Smithing/Mining/Fishing
  114. */
  115. public int CookTimer = -1;
  116. public int CookAmount = 0;
  117. public int CookXP = 0;
  118. public int CookGet = 0;
  119. public int CookID = 0;
  120.  
  121. public int HerbloreTimer = -1;
  122. public int HerbloreType = 0;
  123. public int HerbType = 0;
  124.  
  125. public int FishTimer = -1;
  126. public int FishAmount = 0;
  127. public int FishXP = 0;
  128. public int FishGet = 0;
  129. public int FishEmote = 0;
  130.  
  131. public boolean Farm = false;
  132.  
  133. public boolean Cooking = false;
  134. public boolean Smithing = false;
  135.  
  136.  
  137. public int SmithingTimer = -1;
  138. public int SmithingAmount = 0;
  139. public int SmithingXP = 0;
  140. public int SmithingGet = 0;
  141. public int SmithingID = 0;
  142.  
  143. public int FletchTimer = -1;
  144. public int FletchAmount = 0;
  145. public int FletchXP = 0;
  146. public int FletchGet = 0;
  147. public int FletchID = 0;
  148.  
  149. public int oreType;
  150. public int oreDelay;
  151. public boolean isMining;
  152. public Mining mining = new Mining(this);
  153. public Mining getMining() {
  154. return mining;
  155. }
  156.  
  157. public void ResetSkillSuff()
  158. {
  159. CookTimer = -1;
  160. CookAmount = 0;
  161. CookXP = 0;
  162. CookGet = 0;
  163. CookID = 0;
  164. FletchTimer = -1;
  165. FletchAmount = 0;
  166. FletchXP = 0;
  167. FletchGet = 0;
  168. FishTimer = -1;
  169. FishAmount = 0;
  170. FishXP = 0;
  171. FishGet = 0;
  172. FishEmote = 0;
  173. FletchID = 0;
  174. SmithingTimer = -1;
  175. SmithingAmount = 0;
  176. SmithingXP = 0;
  177. SmithingGet = 0;
  178. SmithingID = 0;
  179. Cooking = false;
  180. Smithing = false;
  181. }
  182.  
  183. public void SmeltThat(Player p, int XP, int ID, int Get)
  184. {
  185. if(Engine.playerItems.HasItemAmount(this, ID, 1) == false)
  186. {
  187. ResetSkillSuff();
  188. p.frames.sendMessage(this, "You ran out of ore to smelt.");
  189. }
  190. else
  191. {
  192. p.requestAnim(899, 0);
  193. Engine.playerItems.deleteItem(this, ID, Engine.playerItems.getItemSlot(this, ID), 1);
  194. Engine.playerItems.addItem(this, Get, 1);
  195. p.addSkillXP(XP*p.skillLvl[13] ,13);
  196. p.frames.sendMessage(this, "You make a metal bar.");
  197. SmithingTimer = 3;
  198. SmithingAmount -= 1;
  199. }
  200. }
  201.  
  202. public void CookThat(Player p, int XP, int ID, int Get)
  203. {
  204. if(Engine.playerItems.HasItemAmount(this, ID, 1) == false)
  205. {
  206. ResetSkillSuff();
  207. p.frames.sendMessage(this, "You ran out of fish to cook.");
  208. }
  209. else
  210. {
  211. p.requestAnim(883, 0);
  212. Engine.playerItems.deleteItem(this, ID, Engine.playerItems.getItemSlot(this, ID), 1);
  213. Engine.playerItems.addItem(this, Get, 1);
  214. p.addSkillXP(XP*p.skillLvl[7] ,7);
  215. p.frames.sendMessage(this, "You cook the fish.");
  216. CookTimer = 3;
  217. CookAmount -= 1;
  218. }
  219. }
  220.  
  221.  
  222. public void FletchThat(Player p, int XP, int ID, int Get)
  223. {
  224. if(Engine.playerItems.HasItemAmount(this, ID, 1) == false)
  225. {
  226. ResetSkillSuff();
  227. p.frames.sendMessage(this, "You ran out of logs to carve.");
  228. p.requestAnim(standEmote, 0);
  229. }
  230. else
  231. {
  232. p.requestAnim(1248, 0);
  233. Engine.playerItems.deleteItem(this, ID, Engine.playerItems.getItemSlot(this, ID), 1);
  234. Engine.playerItems.addItem(this, Get, 1);
  235. p.addSkillXP(XP*p.skillLvl[9] ,9);
  236. p.frames.sendMessage(this, "You make a half bow.");
  237. FletchTimer = 3;
  238. FletchAmount -= 1;
  239. }
  240. }
  241.  
  242. public void FishThat(Player p, int XP, int Get, int Emote)
  243. {
  244. int index = Engine.playerItems.findInvSlot(this);
  245. if(index >= 0)
  246. {
  247. p.requestAnim(Emote, 0);
  248. Engine.playerItems.addItem(this, Get, 1);
  249. p.addSkillXP(XP*p.skillLvl[10] ,10);
  250. p.frames.sendMessage(this, "You caught a fish.");
  251. FishTimer = 3;
  252. FishAmount -= 1;
  253. }
  254. }
  255.  
  256. /**
  257. * Loads objects at Map region loading.
  258. */
  259. public void loadStaticObjects() {
  260. frames.createGlobalObject(1307, 0, 2694, 3426, 0, 10); //Maple Tree
  261. frames.createGlobalObject(1309, 0, 2700, 3420, 0, 10); //Yew Tree
  262. frames.createGlobalObject(28214, 0, 2855, 3329, 0, 10); //Donator Portal
  263. frames.createGlobalObject(11402, 0, 2864, 3335, 0, 10); //Bank outside cooking
  264. frames.createGlobalObject(16687, 0, 3041, 4834, 0, 10); //rune ess
  265. frames.createGlobalObject(16687, 0, 3040, 4834, 0, 10); //rune ess
  266. frames.createGlobalObject(16687, 0, 3039, 4834, 0, 10); //rune ess
  267. frames.createGlobalObject(16687, 0, 3038, 4834, 0, 10); //rune ess
  268. frames.createGlobalObject(11402, 0, 2822, 3346, 0, 10); //Bank @ Home
  269. frames.createGlobalObject(11402, 0, 2821, 3346, 0, 10); //Bank @ Home
  270. frames.createGlobalObject(611, 0, 2827, 3356, 0, 10); //Picnic Bench @ Home
  271. frames.createGlobalObject(2873, 0, 2827, 3344, 0, 10); //Saradomin Statue
  272. frames.createGlobalObject(2029, 0, 2879, 3335, 0, 10); //Fishing
  273. frames.createGlobalObject(2029, 0, 2879, 3338, 0, 10); //Fishing
  274. frames.createGlobalObject(2028, 0, 2879, 3339, 0, 10); //Fishing
  275. frames.createGlobalObject(2028, 0, 2879, 3334, 0, 10); //Fishing
  276. frames.createGlobalObject(2029, 0, 2877, 3342, 0, 10); //Fishing
  277. frames.createGlobalObject(2028, 0, 2875, 3342, 0, 10); //Fishing
  278. frames.createGlobalObject(2515, 0, 2876, 3330, 1, 10); //Row Boat
  279. frames.createGlobalObject(14859, 0, 2943, 3285, 1, 10); //Rune
  280. frames.createGlobalObject(14859, 0, 2943, 3286, 1, 10); //Rune
  281. frames.createGlobalObject(11941, 0, 2943, 3287, 1, 10); //Addy
  282. frames.createGlobalObject(11941, 0, 2943, 3288, 1, 10); //Addy
  283. frames.createGlobalObject(11944, 0, 2943, 3289, 1, 10); //Mith
  284. }
  285. /**
  286. * deadItemDelay
  287. */
  288. public int deadItemDelay;
  289. public boolean needItemDelay;
  290. /**
  291. *Agility
  292. */
  293. public boolean isJumping = false;
  294. public int NewEmote = 0;
  295. public int wallTimer1 = -1;
  296. public int wallTimer2 = -1;
  297. public int wallTimer3 = -1;
  298. public int wallTimer4 = -1;
  299. public int wallTimer5 = -1;
  300. public int SwingTimer1 = -1;
  301. public int SwingTimer2 = -1;
  302. public int SwingTimer3 = -1;
  303. public int LogTimer = -1;
  304. public int AgilityXP = 0;
  305. public int AgilityTimer = -1;
  306. public int NetTimer = -1;
  307.  
  308. /**
  309. *Donator Shop Items
  310. */
  311. public int[] shop12 = {11724,11726,11728,11694,11696,11698,11700,11718,11720,11722,1050,1053,1055,1057,1037,1419};
  312. public int[] shop12n = {10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10};
  313. public int[] shop12p = {5,5,2,15,6,10,8,2,5,5,20,18,18,18,20,25};
  314.  
  315. public int shopid = 0;
  316. public int ShopID = 0;
  317. public int viewings = 0;
  318. public int[] ShopItems = new int[32];
  319. public int[] ShopItemCost = new int[32];
  320. public int[] ShopItemsA = new int[32];
  321.  
  322.  
  323. /**
  324. *Followplayer
  325. */
  326. public int FamiliarID = 0;
  327. public int FamiliarType = 0;
  328. public int followPlayer = 0;
  329. public boolean followingPlayer = false;
  330.  
  331. /**
  332. *Firemaking
  333. */
  334. public int[] firemaking = new int[4];
  335. public int objectX = 0;
  336. public int objectY = 0;
  337. public int objectHeight = 0;
  338. public int firedelay = 0;
  339. public void fmwalk(int x, int y) {
  340. int firstX = x - (mapRegionX - 6) * 8; int firstY = y - (mapRegionY - 6) * 8;
  341. Engine.playerMovement.resetWalkingQueue(this);
  342. Engine.playerMovement.addStepToWalkingQueue(firstX-1, firstY, this);
  343. }
  344. /**
  345. *Runecrafting
  346. */
  347. public runecrafting runecrafting = new runecrafting();
  348. /**
  349. *Magic on NPC
  350. */
  351. public MagicNPC magicNPC;
  352. /**
  353. *Woodcutting
  354. */
  355. public Woodcutting wc;
  356. /**
  357. * Lagg
  358. */
  359. public long LogOut = System.currentTimeMillis();
  360. public long Login = System.currentTimeMillis();
  361. /**
  362. * Starter
  363. */
  364. public int firstLog = 0;
  365. public int started = 0;
  366. /**
  367. * Bury Bones
  368. */
  369. public int buryDelay = 0;
  370. /**
  371. * Fishing Delay
  372. */
  373. public int FishingDelay = 0;
  374. /**
  375. * Yell Command
  376. */
  377. public int yellTimer = 0;
  378. /**
  379. * Summoning Delay
  380. */
  381. public int SummonDelay = 0;
  382. /**
  383. * Muted
  384. */
  385. public int muted = 0;
  386. /**
  387. * Dragon Claws
  388. */
  389. public int secHit2;
  390. public int thirdHit2;
  391. public int fourHit2;
  392. public void dClaw3(Player p) {
  393. NPC n = Engine.npcs[p.attackNPC];
  394. requestAnim(2068, 0);
  395. requestGFX(274, 100);
  396. n.appendHit((thirdHit2), 0);
  397. n.appendHit((fourHit2), 0);
  398. }
  399. public int clawTimer2;
  400. public boolean UseClaws2;
  401. /**
  402. * Vengeance
  403. */
  404. public long lastVeng;
  405. public boolean vengOn = false;
  406. /**
  407. * Magic.
  408. */
  409. public int mageDamage;
  410. public int projectileTimer = -1;
  411. public boolean normalHomeTele = false;
  412. public boolean ancientsHomeTele = false;
  413. public int homeTele = 0;
  414. public int homeTeleDelay = 0;
  415. public int magicDelay = 0;
  416. public int freezeDelay = 0;
  417. /**
  418. * Option variable
  419. */
  420. public int optionId;
  421. public int maxArrays = 10;
  422. public boolean[] optionArray = new boolean[maxArrays];
  423. /**
  424. *Eat delay
  425. */
  426. public int eatDelay = 0;
  427. /**
  428. * trade.
  429. */
  430. public Trade trade;
  431. /**
  432. * Destroy item arrays
  433. */
  434. public int[] destroyItem = new int[28];
  435. public int[] destroyItemAmt = new int[28];
  436. /**
  437. * Npc Dialogues Stage.
  438. */
  439. public boolean[] stage = new boolean[maxArrays];
  440. public int iStage;
  441. public int iiStage;
  442. /**
  443. * Destroy item variable
  444. */
  445. public int destroyItemInt;
  446. /**
  447. * Attacking interface data.
  448. */
  449. public int attackStyle = 0;
  450. public int autoRetaliate = 0;
  451. /**
  452. * Private messages.
  453. * Friends
  454. * Ignores
  455. */
  456. public boolean splitChat = false;
  457. public List<Long> friends = new ArrayList<Long>(200);
  458. public List<Long> ignores = new ArrayList<Long>(100);
  459. /**
  460. * Set Drinking
  461. */
  462. public int drinkDelay = 0;
  463. public int statPotRestoreDelay = 5;
  464. /**
  465. * Player's Note's.
  466. */
  467. public boolean swapAsNote = false;
  468. /**
  469. * Prayer settings.
  470. */
  471. public int prayerDrain = 100;
  472. public int drainRate = 0;
  473. public int defLow = 0;
  474. public int strLow = 1;
  475. public int atkLow = 2;
  476. public int rangeLow = 3;
  477. public int mageLow = 4;
  478. public int defMid = 5;
  479. public int strMid = 6;
  480. public int atkMid = 7;
  481. public int rapidRestore = 8;
  482. public int rapidHeal = 9;
  483. public int protItems = 10;
  484. public int rangeMid = 11;
  485. public int Hitter = 5;
  486. public int mageMid = 12;
  487. public int defHigh = 13;
  488. public int strHigh = 14;
  489. public int atkHigh = 15;
  490. public int prayMage = 16;
  491. public int prayRange = 17;
  492. public int prayMelee = 18;
  493. public int rangeHigh = 19;
  494. public int mageHigh = 20;
  495. public int retribution = 21;
  496. public int redemption = 22;
  497. public int smite = 23;
  498. public int praySummon = 24;
  499. public int chivalry = 25;
  500. public int piety = 26;
  501. public boolean prayOn[] = new boolean[27];
  502. /**
  503. * NPC combat.
  504. */
  505. public int attackNPC = 0;
  506. public boolean attackingNPC = false;
  507. /**
  508. * Player's Skilltab's.
  509. */
  510. public int skillMenu = 0;
  511. /**
  512. * Player's index.
  513. */
  514. public int playerId = 0;
  515. /**
  516. * Class for storing and converting bytes.
  517. */
  518. public Stream stream = new Stream(500, 5000);
  519. /**
  520. * Player's socket for handling most io operations.
  521. */
  522. public PlayerSocket socket;
  523. /**
  524. * Set to true if the player has finished the login stage.
  525. */
  526. public boolean online = false;
  527. /**
  528. * This is for Welcome Interface.
  529. */
  530. public int RandomMessage = Misc.random(9);
  531. public int messageCount = 1;
  532. public int memberCount = 0;
  533. /**
  534. * Player's username.
  535. */
  536. public String username = "null";
  537. /**
  538. * Player's password.
  539. */
  540. public String password = "";
  541. /**
  542. * Player's rights.
  543. */
  544. public int rights = 0;
  545. /**
  546. * 1 set to true means socket disconnected but logged in, both for removing the player.
  547. */
  548. public boolean[] disconnected = new boolean[2];
  549. /**
  550. * Gives quick access to the frame class.
  551. */
  552. public Frames frames = Engine.frames;
  553. /**
  554. * The region this player is in.
  555. */
  556. public int mapRegionX = 0;
  557. public int mapRegionY = 0;
  558. /**
  559. * The position this player is at in the map region.
  560. */
  561. public int currentX = 0;
  562. public int currentY = 0;
  563. /**
  564. * The slot at which each bank tab starts at
  565. */
  566. public int[] tabStartSlot = new int[11];
  567. /**
  568. * The amount of items that you have last withrawn/deposited with the X function
  569. */
  570. public int bankX = 50;
  571. /**
  572. * The tab you are viewing, used to store items in it when depositing
  573. */
  574. public int viewingBankTab = 10;
  575. /**
  576. * Skull
  577. */
  578. public boolean isSkulled;
  579. /**
  580. * Items Kept on Death
  581. */
  582. public int[] ikod = new int[3];
  583. /**
  584. * If you are withrawing items as a note
  585. */
  586. public boolean withdrawNote;
  587. /**
  588. * If you are using insert mode
  589. */
  590. public boolean insertMode;
  591.  
  592. /**
  593. * Absolute coordinates this player is at.
  594. */
  595. public int absX = 0;
  596. public int absY = 0;
  597. /**
  598. * The height level this player is at.
  599. */
  600. public int heightLevel = 0;
  601. /**
  602. * If either are above -1 then the player is in motion.
  603. */
  604. public int walkDir = -1;
  605. public int runDir = -1;
  606. /**
  607. * True if the player is running, false if it isn't.
  608. */
  609. public boolean isRunning = false;
  610. /**
  611. * Set to true if the player has entered a new map region.
  612. */
  613. public boolean mapRegionDidChange = false;
  614. /**
  615. *Player config.
  616. */
  617. public boolean Mouse = false;
  618. public boolean Chat = false;
  619. public boolean Aid = false;
  620. /**
  621. * Set to true if teleported.
  622. */
  623. public boolean didTeleport = false;
  624. /**
  625. * Set Absolute coordinates to these.
  626. */
  627. public int teleportToX = -1;
  628. public int teleportToY = -1;
  629. /**
  630. * True if the player is Reqing an update.
  631. */
  632. public boolean updateReq = false;
  633. /**
  634. * Max number of steps this player can have pending.
  635. */
  636. public int walkingQueueSize = 50;
  637. public int wQueueReadPtr = 0;
  638. public int wQueueWritePtr = 0;
  639.  
  640. /**
  641. * Positions the player is Reqing to walk to.
  642. */
  643. public int[] walkingQueueX = new int[walkingQueueSize];
  644. public int[] walkingQueueY = new int[walkingQueueSize];
  645. public int[] walkingQueue = new int[walkingQueueSize];
  646. /**
  647. * All the players within distance.
  648. */
  649. public Player[] playerList = new Player[Engine.players.length];
  650. /**
  651. * All the players stored in distance.
  652. */
  653. public byte[] playersInList = new byte[Engine.players.length];
  654. public int playerListSize = 0;
  655. /**
  656. * True if chatting is Reqing to be sent.
  657. */
  658. public boolean chatTextUpdateReq = false;
  659. public String chatText = "";
  660. public int chatTextEffects = 0;
  661. /**
  662. * True if an appearance update is needed.
  663. */
  664. public boolean appearanceUpdateReq = false;
  665. /**
  666. * Animation data.
  667. */
  668. public boolean animUpdateReq = false;
  669. public int animReq = -1;
  670. public int animDelay = 0;
  671. /**
  672. * GFX data.
  673. */
  674. public boolean gfxUpdateReq = false;
  675. public int gfxReq = -1;
  676. public int gfxDelay = 0;
  677. /**
  678. * Player and NPC facing data.
  679. */
  680. public boolean faceToUpdateReq = false;
  681. public int faceToReq = -1;
  682. /**
  683. * Damage data.
  684. */
  685. public boolean hit1UpdateReq = false;
  686. public boolean hit2UpdateReq = false;
  687. public int hitDiff1 = 0;
  688. public int hitDiff2 = 0;
  689. public int posionHit1 = 0;
  690. public int posionHit2 = 0;
  691. /**
  692. * Skill level data.
  693. */
  694. public int[] skillLvl = new int[25];
  695. public int[] skillXP = new int[25];
  696. public int combatLevel = 0;
  697. /**
  698. * Player headicons.
  699. */
  700. public int pkIcon = -1;
  701. public int prayerIcon = -1;
  702. public int headIcon = -1;
  703. /**
  704. * Wilderness variables.
  705. */
  706. public int wildyLevel;
  707. /**
  708. * If player updated the Wilderness level.
  709. */
  710. public boolean updatedLevel;
  711. /**
  712. * Wild ditch jumping.
  713. */
  714. public int jumpDelay = 0;
  715. public boolean jumpUpdateReq = false;
  716. public int enemyIndex;
  717. /**
  718. * Equipment data.
  719. */
  720. public int[] equipment = new int[14];
  721. public int[] equipmentN = new int[14];
  722. public int[] equipmentBonus = new int[12];
  723. /**
  724. * Player appearance.
  725. */
  726. public int[] color = new int[5];
  727. public int[] look = new int[7];
  728. public int npcType = -1;
  729. public int gender = 0;
  730. public int[] colour = new int[5];
  731. /**
  732. * Player emotes.
  733. */
  734. public int runEmote = 0x338;
  735. public int walkEmote = 0x333;
  736. public int standEmote = 0x328;
  737. public int attackEmote = 422;
  738. public int BlockEmote = 425;
  739. /**
  740. * Turn anim
  741. */
  742. public int turnAnimation = 7040;
  743. public int turnAnimation180 = 7045;
  744. public int turnAnimationC90 = 7044;
  745. public int turnAnimationCC90 = 7043;
  746. /**
  747. * All the NPCs within distance.
  748. */
  749. public NPC[] npcList = new NPC[Engine.npcs.length];
  750. /**
  751. * All the npcs stored in distance.
  752. */
  753. public byte[] npcsInList = new byte[Engine.npcs.length];
  754. public int npcListSize = 0;
  755. /**
  756. * Rebuild the entire NPC list.
  757. */
  758. public boolean rebuildNPCList = false;
  759. /**
  760. * An array storing all the players items.
  761. */
  762. public int[] items = new int[28];
  763. public int[] itemsN = new int[28];
  764. /**
  765. * Open interfaces, use these to confirm an interface is open when trying to use one.
  766. */
  767. public int interfaceId = -1;
  768. public int chatboxInterfaceId = -1;
  769. /**
  770. * The current position in the login stage.
  771. */
  772. public int loginStage = 0;
  773. /**
  774. * Click x position.
  775. */
  776. public int clickX = 0;
  777. /**
  778. * Click y position.
  779. */
  780. public int clickY = 0;
  781. /**
  782. * Click id.
  783. */
  784. public int clickId = 0;
  785. /**
  786. * True if the player is trying to pickup an item.
  787. */
  788. public boolean itemPickup = false;
  789. /**
  790. * True if the player is dead.
  791. */
  792. public boolean isDead = false;
  793. /**
  794. * Set run energy.
  795. */
  796. public boolean runEnergyUpdateReq = false;
  797. /**
  798. * Amount of current run energy.
  799. */
  800. public int runEnergy = 100;
  801. /**
  802. * Delay before run energy can increase.
  803. */
  804. public int runEnergyDelay = 0;
  805. /**
  806. * Clicked the first option on a player.
  807. */
  808. public boolean playerOption1 = false;
  809. /**
  810. * Clicked the second option on a player.
  811. */
  812. public boolean playerOption2 = false;
  813. /**
  814. * Clicked the third option on a player.
  815. */
  816. public boolean playerOption3 = false;
  817.  
  818. /**
  819. * Clicked the first option on an object.
  820. */
  821. public boolean objectOption1 = false;
  822. /**
  823. * Setting the players weapon.
  824. */
  825. public PlayerWeapon playerWeapon = new PlayerWeapon(this);
  826. /**
  827. * Clicked the second option on an object.
  828. */
  829. public boolean objectOption2 = false;
  830. /**
  831. * Clicked the options on a NPC.
  832. */
  833. public boolean npcOption2 = false;
  834. public boolean npcOption1 = false;
  835. public boolean npcOption3 = false;
  836. /**
  837. * Forced chat.
  838. */
  839. public String forceChat = "";
  840. public boolean forceChatUpdateReq = false;
  841. /**
  842. * Stat restore delay.
  843. */
  844. public int statRestoreDelay = 75;
  845. /**
  846. * Teleporting variables.
  847. */
  848. public int teleX = -1;
  849. public int teleY = -1;
  850. public int teleDelay = -1;
  851. public int teleFinishGFX = 0;
  852. public int teleFinishGFXHeight = 0;
  853. public int teleFinishAnim = 0;
  854. /**
  855. * Wilderness level
  856. */
  857. public int wildLevel;
  858. /**
  859. * Face coords
  860. */
  861. public boolean updateFaceCoords = false;
  862. public int faceX = -1;
  863. public int faceY = -1;
  864. /**
  865. * Special bar data.
  866. */
  867. public boolean specialAmountUpdateReq = false;
  868. public int specialAmountDelay = 0;
  869. public int specialAmount = 100;
  870. public boolean SpecialBar = false;
  871. public boolean usingSpecial = false;
  872. /**
  873. * Delay before recieving packets.
  874. */
  875. public int clickDelay = -1;
  876. public int attackDelay = 5;
  877. public long loginTimeout = System.currentTimeMillis();
  878. public int attackPlayer = 0;
  879. public boolean attackingPlayer = false;
  880. public int combatDelay = 0;
  881. public int npcDelay = 0;
  882. public int deathDelay = 7;
  883. /**
  884. * Set leveled up
  885. */
  886. public boolean[] leveledUp = new boolean[24];
  887. public int leveledUpSkill = 0;
  888.  
  889. /**
  890. * UserInput.
  891. */
  892. public UserInput input = new UserInput(this);
  893. /**
  894. * Arrays holding the items + their amounts of your bank
  895. */
  896. public int[] bankItems = new int[Engine.playerBank.SIZE];
  897. public int[] bankItemsN = new int[Engine.playerBank.SIZE];
  898.  
  899. /**
  900. * Constructs a new Player.
  901. * @param socket The socket this Player belongs to.
  902. * @param id The index this player is at.
  903. */
  904. public Player(Socket socket, int id) {
  905. wc = new Woodcutting(this);
  906. magicNPC = new MagicNPC(this);
  907. this.socket = new PlayerSocket(this, socket);
  908. playerId = id;
  909. look[1] = 10;
  910. look[2] = 18;
  911. look[3] = 26;
  912. look[4] = 33;
  913. look[5] = 36;
  914. look[6] = 42;
  915. for (int i = 0; i < skillLvl.length; i++) {
  916. skillLvl[i] = 1;
  917. skillXP[i] = 0;
  918. skillLvl[3] = 10;
  919. skillXP[3] = 1154;
  920. }
  921. for (int i = 0; i < items.length; i++) {
  922. items[i] = -1;
  923. }
  924. for (int i = 0; i < equipment.length; i++) {
  925. equipment[i] = -1;
  926. }
  927. for (int i = 0; i < bankItems.length; i++) {
  928. bankItems[i] = -1;
  929. }
  930. trade = new Trade(this);
  931. }
  932.  
  933. /**
  934. * This method is called every 600 milliseconds.
  935. * <p>While this is good for for changing integers, this
  936. * should not be abused. Things that can be handled else where should
  937. * be done in that way, such as clicking the accept button in trade
  938. * should update in the ActionsButton class rather than Reqing
  939. * an update for the process to handle.
  940. */
  941. public void process() {
  942. if (poisonDelay > 0) {
  943. poisonDelay--;
  944. }
  945. if (isPoisoned && poisonDelay == 0) {
  946. appendHit(Misc.random(6), 1);
  947. if (posionHit1 == 0) {
  948. posionHit1 = 4;
  949. }
  950. poisonHitCount++;
  951. poisonDelay = 45;
  952. }
  953. if (isPoisoned && poisonHitCount >= 7) {
  954. isPoisoned = false;
  955. poisonHitCount = 0;
  956. frames.sendMessage(this, "Poison has faded away..");
  957. }
  958. wc.process();
  959. RandomMessages RM = new RandomMessages(this);
  960. RM.process(this);
  961. if (oreDelay > 0) {
  962. oreDelay--;
  963. }
  964. if (oreDelay == 0 && isMining) {
  965. getMining().receiveOre();
  966. }
  967. if (HerbloreTimer > 0) {
  968. HerbloreTimer--;
  969. }
  970. if(HerbloreTimer == 0)
  971. {
  972.  
  973. if(HerbloreType == 7871 || HerbloreType == 7941 || HerbloreType == 8111 || HerbloreType == 7855)
  974. {
  975. HerbloreTimer = -1;
  976. HerbloreType = 0;
  977. HerbType = 0;
  978. }
  979. else
  980. {
  981. HerbloreTimer = 30;
  982. if(HerbType == 1)
  983. {
  984. frames.createGlobalObject(HerbloreType+1, heightLevel, 2809, 3463, 0, 10);
  985. }
  986. else
  987. {
  988. frames.createGlobalObject(HerbloreType+1, heightLevel, 2813, 3463, 0, 10);
  989. }
  990. HerbloreType += 1;
  991. }
  992. }
  993. if(FishTimer > 0) FishTimer -= 1;
  994. if(FishTimer == 0)
  995. {
  996. FishThat(this, FishXP, FishGet, FishEmote);
  997. }
  998. if(CookTimer > 0) CookTimer -= 1;
  999.  
  1000. if(CookTimer == 0)
  1001. {
  1002. if(CookAmount == 0)
  1003. {
  1004. CookTimer = -1;
  1005. }
  1006. else
  1007. {
  1008. CookThat(this, CookXP, CookID, CookGet);
  1009. }
  1010. }
  1011.  
  1012. if(SmithingTimer > 0) SmithingTimer -= 1;
  1013.  
  1014. if(SmithingTimer == 0)
  1015. {
  1016. if(SmithingAmount == 0)
  1017. {
  1018. SmithingTimer = -1;
  1019. }
  1020. else
  1021. {
  1022. SmeltThat(this, SmithingXP, SmithingID, SmithingGet);
  1023. }
  1024. }
  1025.  
  1026.  
  1027. if(FletchTimer > 0) FletchTimer -= 1;
  1028.  
  1029. if(FletchTimer == 0)
  1030. {
  1031. if(FletchAmount == 0)
  1032. {
  1033. FletchTimer = -1;
  1034. }
  1035. else
  1036. {
  1037. FletchThat(this, FletchXP, FletchID, FletchGet);
  1038. }
  1039. }
  1040.  
  1041. if (deadItemDelay <= 0 && needItemDelay) {
  1042. needItemDelay = false;
  1043. }
  1044. if((absX >= 2949 && absX <= 3400 && absY >= 3525 && absY <=4462))
  1045. {
  1046. frames.setPlayerOption(this, "Attack", 1);
  1047. }
  1048. else
  1049. {
  1050. frames.setPlayerOption(this, "null", 1);
  1051. }
  1052. if (buryDelay > 0) {
  1053. buryDelay--;
  1054. }
  1055. if(SwingTimer1 > 0) SwingTimer1 -= 1;
  1056. if(SwingTimer1 == 0)
  1057. {
  1058. SwingTimer2 = 2;
  1059. SwingTimer1 = -1;
  1060. reqWalkQueue(2553,3554);
  1061. }
  1062. if(SwingTimer2 > 0) SwingTimer2 -= 1;
  1063. if(SwingTimer2 == 0)
  1064. {
  1065. chatText = "I'm going around!";
  1066. chatTextUpdateReq = true;
  1067. updateReq = true;
  1068. SwingTimer2 = -1;
  1069. reqWalkQueue(2553,3549);
  1070. SwingTimer3 = 4;
  1071. }
  1072.  
  1073. if(LogTimer > 0) LogTimer -= 1;
  1074. if(LogTimer == 0)
  1075. {
  1076. chatText = "Easy peasy lemon squeezy...";
  1077. chatTextUpdateReq = true;
  1078. updateReq = true;
  1079. LogTimer = -1;
  1080. }
  1081.  
  1082. if(SwingTimer3 > 0) SwingTimer3 -= 1;
  1083. if(SwingTimer3 == 0)
  1084. {
  1085. SwingTimer3 = -1;
  1086. reqWalkQueue(2551,3546);
  1087. addSkillXP(75*skillLvl[16] ,16);
  1088. frames.sendMessage(this, "You earn some Agility XP for running...");
  1089. }
  1090. if (firedelay > 0) { firedelay--; } if (firedelay == 0) {
  1091. frames.createGlobalObject(-1, objectHeight, objectX, objectY, 0, 10);
  1092. Engine.items.createGroundItem(592, 1, objectX, objectY, heightLevel, username);
  1093. firedelay = -1; }
  1094. if (FishingDelay > 0) {
  1095. FishingDelay--;
  1096. }
  1097. if (SummonDelay > 0) {
  1098. SummonDelay--;
  1099. }
  1100. if(clawTimer2 > 0) clawTimer2--;
  1101. if(clawTimer2 == 0 && UseClaws2)
  1102. {
  1103. dClaw3(this);
  1104. UseClaws2 = false;
  1105. }
  1106. addWildernessUpdating();
  1107. if (disconnected[0]) {
  1108. if (trade.getPartner() != null) {
  1109. trade.declineTrade();
  1110. }
  1111. disconnected[1] = true;
  1112. }
  1113. if (statRestoreDelay > 0) {
  1114. statRestoreDelay--;
  1115. }
  1116. if (drinkDelay > 0) {
  1117. drinkDelay--;
  1118. }
  1119. if (magicDelay > 0) {
  1120. magicDelay--;
  1121. } else if(!magicNPC.canCast) {
  1122. magicNPC.canCast=true;
  1123. }
  1124. if (homeTeleDelay > 0){
  1125. homeTeleDelay--;
  1126. }
  1127. if (homeTele > 0 && homeTeleDelay <= 0 && normalHomeTele){
  1128. homeTeleport(3221,3221);
  1129. homeTele--;
  1130. }
  1131. if (freezeDelay > 0) {
  1132. freezeDelay--;
  1133. stopMovement(this);
  1134. } else if (freezeDelay == 0) {// your allowed to walk, what more you want.
  1135. }
  1136. if (eatDelay > 0) {
  1137. eatDelay--;
  1138. }
  1139. if (jumpDelay > 0) {
  1140. jumpDelay--;
  1141. jumpUpdateReq();
  1142. }
  1143. if (clickDelay > 0) {
  1144. clickDelay--;
  1145. }
  1146. if (specialAmountDelay > 0) {
  1147. specialAmountDelay--;
  1148. } else {
  1149. if (specialAmount < 100) {
  1150. specialAmount++;
  1151. specialAmountUpdateReq = true;
  1152. }
  1153. specialAmountDelay = 2;
  1154. }
  1155. if (isDead) {
  1156. attackingPlayer = false;
  1157. deathDelay--;
  1158.  
  1159. applyDead();
  1160. }
  1161. if (combatDelay > 0) {
  1162. combatDelay--;
  1163. }
  1164. if (teleDelay > 0) {
  1165. teleDelay--;
  1166. }
  1167. if (npcDelay > 0) {
  1168. npcDelay--;
  1169. }
  1170. if (runEnergyDelay > 0) {
  1171. runEnergyDelay--;
  1172. } else {
  1173. if (runEnergy < 100) {
  1174. runEnergy++;
  1175. runEnergyUpdateReq = true;
  1176. }
  1177. if (runEnergy < 0) {
  1178. frames.setConfig(this, 173, 0);
  1179. isRunning = false;
  1180. }
  1181. runEnergyDelay = 4;
  1182. }
  1183.  
  1184. if (itemPickup) {
  1185. Engine.packets.pickupItem.handlePacket(this, 0, 0);
  1186. }
  1187. if (playerOption1) {
  1188. Engine.packets.playerOption1.handlePacket(this, 0, 0);
  1189. }
  1190. if (playerOption2) {
  1191. Engine.packets.playerOption2.handlePacket(this, 0, 0);
  1192. }
  1193. if (playerOption3) {
  1194. Engine.packets.playerOption3.handlePacket(this, 0, 0);
  1195. }
  1196. if (npcOption1) {
  1197. Engine.packets.npcOption1.handlePacket(this, 0, 0);
  1198. }
  1199. if (npcOption2) {
  1200. Engine.packets.npcOption2.handlePacket(this, 0, 0);
  1201. }
  1202. if (objectOption1) {
  1203. Engine.packets.objectOption1.handlePacket(this, 0, 0);
  1204. }
  1205. if (objectOption2) {
  1206. Engine.packets.objectOption2.handlePacket(this, 0, 0);
  1207. }
  1208. if (attackingPlayer) {
  1209. Engine.playerCombat.attackPlayer(this);
  1210. }
  1211. if (attackingNPC) {
  1212. Engine.playerNPCCombat.attackNPC(this);
  1213. }
  1214. if (runEnergyUpdateReq) {
  1215. frames.setEnergy(this);
  1216. runEnergyUpdateReq = false;
  1217. }
  1218. if (specialAmountUpdateReq) {
  1219. checkAmount(this);
  1220. specialAmountUpdateReq = false;
  1221. }
  1222. if (statRestoreDelay <= 0) {
  1223. for (int i1 = 0; i1 < skillLvl.length; i1++) {
  1224. int xpLvl = getLevelForXP(i1);
  1225. if (skillLvl[i1] < xpLvl) {
  1226. skillLvl[i1]++;
  1227. frames.setSkillLvl(this, i1);
  1228. } else if (skillLvl[i1] > xpLvl) {
  1229. skillLvl[i1]--;
  1230. frames.setSkillLvl(this, i1);
  1231. }
  1232. }
  1233. statRestoreDelay = 75;
  1234. }
  1235. prayerDrain -= drainRate;
  1236. if (prayerDrain <= 0 && skillLvl[5] > 0) {
  1237. skillLvl[5]--;
  1238. frames.setSkillLvl(this, 5);
  1239. if (skillLvl[5] <= 0) {
  1240. Prayer pr = new Prayer(null, BlockEmote);
  1241.  
  1242. pr.resetPrayers(this);
  1243. frames.sendMessage(this, "You have run out of prayer points.");
  1244. }
  1245. prayerDrain = 100;
  1246. }
  1247. if (teleDelay == 0) {
  1248. teleDelay = -1;
  1249. setCoords(teleX, teleY, heightLevel);
  1250. requestAnim(teleFinishAnim, 0);
  1251. requestGFX(teleFinishGFX, teleFinishGFXHeight);
  1252. teleX = teleY = -1;
  1253. }
  1254. if (clickDelay == 0) {
  1255. clickDelay = -1;
  1256. }
  1257. }
  1258.  
  1259. public void openShop() {
  1260.  
  1261.  
  1262.  
  1263. frames.setConfig2(this, 563, 4194304);
  1264. frames.setConfig2(this, 1248, -2013265920);
  1265. frames.showInterface(this, 278);
  1266. // frames.setInventory(this, 763); //Inventory Set
  1267. frames.setBankOptions(this);
  1268.  
  1269. frames.setString(this, " General Store", 278, 88);//Title
  1270.  
  1271.  
  1272.  
  1273. frames.setString(this, "", 200, 14);//Confirm
  1274. frames.setItems(this, 278, 89, 94, ShopItems, ShopItemsA);
  1275.  
  1276. }
  1277.  
  1278. public void stopMovement(Player p) {
  1279. if (p == null) {
  1280. return;
  1281. }
  1282. if (p.teleportToX == -1 && p.teleportToY == -1) {
  1283. p.teleportToX = p.absX;
  1284. p.teleportToY = p.absY;
  1285. }
  1286. p.walkingQueueX[0] = 0;
  1287. p.walkingQueueY[0] = 0;
  1288. p.walkingQueue[0] = 0;
  1289. }
  1290.  
  1291. /**
  1292. * home Teleporting method.
  1293. */
  1294. public void homeTeleport(int telex, int teley) {
  1295. if (homeTele == 16) {
  1296. requestAnim(1722, 0);
  1297. } else if (homeTele == 15) {
  1298. requestAnim(1723, 0);
  1299. requestGFX(800, 0);
  1300. } else if (homeTele == 14) {
  1301. requestAnim(1724, 0);
  1302. requestGFX(801, 0);
  1303. } else if (homeTele == 13) {
  1304. requestAnim(1725, 0);
  1305. requestGFX(802, 0);
  1306. } else if (homeTele == 12) {
  1307. requestAnim(2798, 0);
  1308. requestGFX(1703, 0);
  1309. } else if (homeTele == 11) {
  1310. requestAnim(2799, 0);
  1311. requestGFX(1704, 0);
  1312. } else if (homeTele == 10) {
  1313. requestAnim(2800, 0);
  1314. requestGFX(1705, 0);
  1315. } else if (homeTele == 9) {
  1316. requestAnim(4847, 0);
  1317. requestGFX(1706, 0);
  1318. } else if (homeTele == 8) {
  1319. requestAnim(4848, 0);
  1320. requestGFX(1707, 0);
  1321. } else if (homeTele == 7) {
  1322. requestAnim(4849, 0);
  1323. requestGFX(1708, 0);
  1324. } else if (homeTele == 6) {
  1325. requestAnim(4849, 0);
  1326. requestGFX(1709, 0);
  1327. } else if (homeTele == 5) {
  1328. requestAnim(4849, 0);
  1329. requestGFX(1710, 0);
  1330. } else if (homeTele == 4) {
  1331. requestAnim(4850, 0);
  1332. requestGFX(1711, 0);
  1333. } else if (homeTele == 3) {
  1334. requestAnim(4851, 0);
  1335. requestGFX(1712, 0);
  1336. } else if (homeTele == 2) {
  1337. requestAnim(4852, 0);
  1338. requestGFX(1713, 0);
  1339. } else if (homeTele == 1) {
  1340. homeTeleDelay = 3600;
  1341. homeTele = 16;
  1342. setCoords(telex, teley, 0);
  1343. normalHomeTele = false;
  1344. ancientsHomeTele = false;
  1345. }
  1346. }
  1347.  
  1348. /**
  1349. * Private messages.
  1350. * Friends
  1351. * Ignores
  1352. */
  1353. public void friendsLoggedIn() {
  1354. for(Long friend : friends) {
  1355. frames.sendFriend(this, friend, getWorld(friend));
  1356. }
  1357. long[] array = new long[ignores.size()];
  1358. int i = 0;
  1359. for(Long ignore : ignores) {
  1360. if(ignore != null)
  1361. array[i++] = ignore;
  1362. }
  1363. frames.sendIgnores(this, array);
  1364. long me = Misc.stringToLong(username);
  1365. for(Player p : Engine.players) {
  1366. if(p == null) continue;
  1367. if(p.friends.contains(me)) {
  1368. p.frames.sendFriend(p, me, 66);
  1369. }
  1370. }
  1371. }
  1372. public int getWorld(long friend) {
  1373. for(Player p : Engine.players) {
  1374. if(p != null && p.online) {
  1375. if(Misc.stringToLong(p.username) == friend) {
  1376. return 66;
  1377. }
  1378. }
  1379. }
  1380. return 0;
  1381. }
  1382.  
  1383. /**
  1384. * reqWalkQueue & reqWalkQueueBack method.
  1385. */
  1386. public void reqWalkQueue(int x, int y) {
  1387. int firstX = x - (mapRegionX - 6) * 8;
  1388. int firstY = y - (mapRegionY - 6) * 8;
  1389. Engine.playerMovement.resetWalkingQueue(this);
  1390. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY, this);
  1391. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY+1, this);
  1392. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY+2, this);
  1393. }
  1394.  
  1395. public void reqWalkQueueBack(int x, int y) {
  1396. int firstX = x - (mapRegionX - 6) * 8;
  1397. int firstY = y - (mapRegionY - 6) * 8;
  1398. Engine.playerMovement.resetWalkingQueue(this);
  1399. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY, this);
  1400. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY-1, this);
  1401. Engine.playerMovement.addStepToWalkingQueue(firstX, firstY-2, this);
  1402. }
  1403. /**
  1404. * cantattackplayer method.
  1405. */
  1406. public boolean canAttackPlayer(Player p) {
  1407.  
  1408. if (p == null || p.isDead) {
  1409. return false;
  1410. } else if (p.attackPlayer < 1 || p.attackPlayer >= Engine.players.length
  1411. || Engine.players[p.attackPlayer] == null) {
  1412. return false;
  1413. }
  1414. if(absX >= 3093 && absY >= 3920 && absX <= 3120 && absY <= 3950)
  1415. {
  1416. return false;
  1417. }
  1418. return true;
  1419.  
  1420. }
  1421. /**
  1422. * restore tabs, hide tabs, used for trading fix bug and equipements bonus...
  1423. */
  1424. public void restoreTabs(Player p) {
  1425. for (int b = 16; b <= 21; b++) {
  1426. p.frames.setInterfaceConfig(p, 548, b, false);
  1427. }
  1428.  
  1429. for (int a = 32; a <= 38; a++) {
  1430. p.frames.setInterfaceConfig(p, 548, a, false);
  1431. }
  1432. p.calculateEquipmentBonus();
  1433.  
  1434. p.frames.setInterfaceConfig(p, 548, 14, false);
  1435. p.frames.setInterfaceConfig(p, 548, 31, false);
  1436. p.frames.setInterfaceConfig(p, 548, 63, false);
  1437.  
  1438. p.frames.setInterfaceConfig(p, 548, 72, false);
  1439. }
  1440.  
  1441. public void hideTabs(Player p) {
  1442. for (int b = 16; b <= 21; b++) {
  1443. p.frames.setInterfaceConfig(p, 548, b, true);
  1444. }
  1445.  
  1446. for (int a = 32; a <= 38; a++) {
  1447. p.frames.setInterfaceConfig(p, 548, a, true);
  1448. }
  1449. p.calculateEquipmentBonus();
  1450.  
  1451. p.frames.setInterfaceConfig(p, 548, 14, true);
  1452. p.frames.setInterfaceConfig(p, 548, 31, true);
  1453. p.frames.setInterfaceConfig(p, 548, 63, true);
  1454.  
  1455. p.frames.setInterfaceConfig(p, 548, 72, true);
  1456. }
  1457.  
  1458. public void calculateIKOD() {
  1459. int amountOfKeptItems = isSkulled ? (prayOn[protItems] ? 1 : 0) : (prayOn[protItems] ? 4 : 3);
  1460. int[] allItems = new int[items.length + equipment.length];
  1461. int[] allItemsN = new int[itemsN.length + equipmentN.length];
  1462. int[] keptItems = new int[amountOfKeptItems];
  1463. int[] toAdd = new int[keptItems.length];
  1464. if (items == null){
  1465. System.arraycopy(equipment, 0, allItems, items.length, equipment.length);
  1466. System.arraycopy(equipmentN, 0, allItemsN, itemsN.length, equipmentN.length);
  1467. } else {
  1468. System.arraycopy(items, 0, allItems, 0, items.length);
  1469. System.arraycopy(itemsN, 0, allItemsN, 0, itemsN.length);
  1470. System.arraycopy(equipment, 0, allItems, items.length, equipment.length);
  1471. System.arraycopy(equipmentN, 0, allItemsN, itemsN.length, equipmentN.length);
  1472. }
  1473. for (int i = 0; i < keptItems.length; i++) {
  1474. int index = 0;
  1475. int standing = 0;
  1476. for (int j = 0; j < allItems.length; j++) {
  1477. if (allItems[j] < 1) {
  1478. continue;
  1479. }
  1480. int price = (int)Math.round(1.10 * (1 * Engine.items.getItemValue(allItems[j])));
  1481. if (price > standing) {
  1482. index = j;
  1483. standing = price;
  1484. }
  1485. }
  1486. keptItems[i] = allItems[index];
  1487. toAdd[i] = allItems[index];
  1488. allItemsN[index]--;
  1489. if (allItemsN[index] == 0) {
  1490. allItems[index] = 0;
  1491. }
  1492. }
  1493. for (int i = 0; i < keptItems.length; i++) {
  1494. ikod[i] = keptItems[i];
  1495. if (ikod[i] == 0) ikod[i] = 6564;
  1496. }
  1497. }
  1498.  
  1499.  
  1500. public void noMapdata() {
  1501. setCoords(2827,3343,0);
  1502. Engine.playerMovement.getNextPlayerMovement(this);
  1503. this.frames.setMapRegion(this);
  1504. this.frames.sendMessage(this, "Missing mapdata.Please contact Your Administrator");
  1505. }
  1506.  
  1507. public LinkedList<Integer> getRegion() {
  1508. LinkedList<Integer> regions = new LinkedList<Integer>();
  1509. boolean forceSend = true;
  1510. if ((((mapRegionX / 8) == 48) || ((mapRegionX / 8) == 49)) && ((mapRegionY / 8) == 48)) {
  1511. forceSend = false;
  1512. }
  1513.  
  1514. if (((mapRegionX / 8) == 48) && ((mapRegionY / 8) == 148)) {
  1515. forceSend = false;
  1516. }
  1517.  
  1518. for (int xCalc = (mapRegionX - 6) / 8; xCalc <= ((mapRegionX + 6) / 8); xCalc++) {
  1519. for (int yCalc = (mapRegionY - 6) / 8; yCalc <= ((mapRegionY + 6) / 8); yCalc++) {
  1520. if (forceSend || ((yCalc != 49) && (yCalc != 149) && (yCalc != 147) && (xCalc != 50) && ((xCalc != 49) || (yCalc != 47)))) {
  1521. regions.add(yCalc + (xCalc << 1786653352));
  1522.  
  1523. }
  1524. }
  1525. }
  1526. return regions;
  1527. }
  1528.  
  1529. /**
  1530. * Ip Banning.
  1531. */
  1532. public void appendIPBan() {
  1533. BufferedWriter bw = null;
  1534. try {
  1535. bw = new BufferedWriter(new FileWriter("./data/banned/bannedhosts.dat", true));
  1536. bw.write(SocketListener.getAddress(this.socket.socket));
  1537. bw.newLine();
  1538. bw.flush();
  1539. } catch (IOException ioe) {
  1540. } finally {
  1541. if (bw != null) {
  1542. try {
  1543. bw.close();
  1544. } catch (IOException ioe2) {
  1545. }
  1546. }
  1547. }
  1548. }
  1549. /**
  1550. * Ip Mute.
  1551. */
  1552. public void appendIPMute() {
  1553. BufferedWriter bw = null;
  1554. try {
  1555. bw = new BufferedWriter(new FileWriter("./data/banned/mutedhosts.dat", true));
  1556. bw.write(SocketListener.getAddress(this.socket.socket));
  1557. bw.newLine();
  1558. bw.flush();
  1559. } catch (IOException ioe) {
  1560. } finally {
  1561. if (bw != null) {
  1562. try {
  1563. bw.close();
  1564. } catch (IOException ioe2) {
  1565. }
  1566. }
  1567. }
  1568. }
  1569. /**
  1570. * Bann.
  1571. */
  1572. public void appendToBanned(String player) {
  1573. BufferedWriter bw = null;
  1574. try {
  1575. bw = new BufferedWriter(new FileWriter("./data/banned/bannedusers.dat", true));
  1576. bw.write(player);
  1577. bw.newLine();
  1578. bw.flush();
  1579. } catch (IOException ioe) {
  1580. } finally {
  1581. if (bw != null) {
  1582. try {
  1583. bw.close();
  1584. } catch (IOException ioe2) {
  1585. }
  1586. }
  1587. }
  1588. }
  1589. /**
  1590. * Mute The Player
  1591. */
  1592. public void appendToMuted(String player) {
  1593. BufferedWriter bw = null;
  1594. try {
  1595. bw = new BufferedWriter(new FileWriter("./data/banned/mutedusers.dat", true));
  1596. bw.write(player);
  1597. bw.newLine();
  1598. bw.flush();
  1599. } catch (IOException ioe) {
  1600. } finally {
  1601. if (bw != null) {
  1602. try {
  1603. bw.close();
  1604. } catch (IOException ioe2) {
  1605. }
  1606. }
  1607. }
  1608. }
  1609. /**
  1610. * Checks if a user is Muted
  1611. * @param username The name to check.
  1612. * @return Returns if the name was found.
  1613. */
  1614. public boolean checkMutedUsers(String username) {
  1615. if (username == null) {
  1616. return true;
  1617. }
  1618. for (int i = 0; i < Server.mutedUsers.length; i++) {
  1619. if (Server.mutedUsers[i] != null && username.equalsIgnoreCase(Server.mutedUsers[i])) {
  1620. return true;
  1621. }
  1622. }
  1623. return false;
  1624. }
  1625. /**
  1626. * Checks to make sure the host isnt IP muted.
  1627. */
  1628. public boolean checkMutedHosts(String hostName) {
  1629. if (hostName == null) {
  1630. return true;
  1631. }
  1632. for (int i = 0; i < SocketListener.mutedHosts.length; i++) {
  1633. if (SocketListener.mutedHosts[i] != null && (hostName.startsWith(SocketListener.mutedHosts[i]) || hostName.equals(SocketListener.mutedHosts[i]))) {
  1634. return true;
  1635. }
  1636. }
  1637. return false;
  1638. }
  1639. /*================================Start of Wild Methods================================*\
  1640. /**
  1641. * Calculates wilderness Levels.
  1642. */
  1643. public int getWildernessLevel() {
  1644. wildLevel = (absY - 3520) / 8 + 1;
  1645. if (wildLevel < 1)
  1646. wildLevel = 1;
  1647. return wildLevel;
  1648. }
  1649. /**
  1650. * the wilderness Area.
  1651. */
  1652.  
  1653. public boolean wildy() {
  1654. if((absX >= 2949 && absX <= 3400 && absY >= 3525 && absY <=4462))
  1655. return true;
  1656. else
  1657. return false;
  1658. }
  1659.  
  1660. public void faceCoords(int x, int y) {
  1661. faceX = 2 * x + 1;
  1662. faceY = 2 * y + 1;
  1663. updateFaceCoords = true;
  1664. updateReq = true;
  1665. }
  1666. /**
  1667. * Update the wilderness levels.
  1668. */
  1669. public void addWildernessUpdating() {
  1670. frames.setString(this, "Level: "+getWildernessLevel(), 381, 1);
  1671. if (updatedLevel != Engine.wildernessArea(absX, absY)) {
  1672. updatedLevel = Engine.wildernessArea(absX, absY);
  1673. if (updatedLevel) {
  1674. frames.setOverlay(this, 381);
  1675. } else {
  1676. wildyLevel = 0;
  1677. frames.removeOverlay(this);
  1678. }
  1679. }
  1680. }
  1681.  
  1682. /*================================END of Wild Methods================================*\
  1683. /**
  1684. * Get xp based on your level.
  1685. * @param skillId The skill level to get the level based off XP for.
  1686. * @return Returns the level based on the amount of XP the specified skill has.
  1687. */
  1688. public int getLevelForXP(int skillId) {
  1689. int exp = skillXP[skillId];
  1690. int points = 0;
  1691. int output = 0;
  1692. for (int lvl = 1; lvl < 100; lvl++) {
  1693. points += Math.floor((double)lvl + 300.0 * Math.pow(2.0, (double)lvl / 7.0));
  1694. output = (int)Math.floor(points / 4);
  1695. if ((output - 1) >= exp) {
  1696. return lvl;
  1697. }
  1698. }
  1699. return 99;
  1700. }
  1701. public void jumpUpdateReq() {
  1702. if (jumpDelay >= 1) {
  1703. runEmote = walkEmote = 2750;
  1704. updateReq = appearanceUpdateReq = true;
  1705. }
  1706. if (jumpDelay <= 0) {
  1707. playerWeapon.setWeapon();
  1708. jumpDelay = 0;
  1709. updateReq = appearanceUpdateReq = true;
  1710. }
  1711. jumpUpdateReq = false;
  1712. }
  1713. public void afterDeathUpdateReq() {
  1714. for (int i = 0; i < skillLvl.length; i++) {
  1715. skillLvl[i] = getLevelForXP(i);
  1716. frames.setSkillLvl(this, i);
  1717. }
  1718. Prayer pr = new Prayer(null, BlockEmote);
  1719.  
  1720. pr.resetPrayers(this);
  1721. runEnergy = 100;
  1722. specialAmount = 100;
  1723. deathDelay = 8;
  1724. runEnergyUpdateReq = true;
  1725. specialAmountUpdateReq = true;
  1726. isDead = false;
  1727.  
  1728. }
  1729. /**
  1730. * Death data.
  1731. */
  1732. public void appendItemPK(Player p) {
  1733. Player p2 = Engine.players[p.attackPlayer];
  1734.  
  1735. if (p2 == null) {
  1736. return;
  1737. }
  1738. for (int i = 0; i < items.length; i++) {
  1739. if (items[i] > 0) {
  1740. if (Engine.items.isUntradable(items[i])) {
  1741. Engine.items.createGroundItem(items[i], itemsN[i], absX,
  1742. absY, heightLevel, username);
  1743. } else {
  1744. Engine.items.createGroundItem(items[i], itemsN[i], absX,
  1745. absY, heightLevel, p2.username);
  1746. }
  1747. items[i] = -1;
  1748. itemsN[i] = 0;
  1749. }
  1750. }
  1751. Engine.items.createGroundItem(526, 1, absX, absY, heightLevel, p2.username);
  1752. for (int i = 0; i < equipment.length; i++) {
  1753. if (equipment[i] > 0) {
  1754. if (Engine.items.isUntradable(equipment[i])) {
  1755. Engine.items.createGroundItem(equipment[i], equipmentN[i],
  1756. absX, absY, heightLevel, username);
  1757. } else {
  1758. Engine.items.createGroundItem(equipment[i], equipmentN[i],
  1759. absX, absY, heightLevel, p2.username);
  1760. }
  1761. equipment[i] = -1;
  1762. equipmentN[i] = 0;
  1763. }
  1764. }
  1765. frames.setItems(this, 149, 0, 93, items, itemsN);
  1766. frames.setItems(this, 387, 28, 94, equipment, equipmentN);
  1767. playerWeapon.setWeapon();
  1768. calculateEquipmentBonus();
  1769. }
  1770. public void applyDead() {
  1771.  
  1772.  
  1773. requestAnim(7197, 0);
  1774. if(deathDelay <= 0)
  1775. {
  1776. frames.removeOverlay(this);
  1777. frames.sendMessage(this, "Oh dear you are dead!");
  1778. appendItemPK(this);
  1779. isDead = false;
  1780. afterDeathUpdateReq();
  1781. attackingPlayer = false;
  1782. requestFaceTo(65535);
  1783. pkIcon = -1;
  1784. setCoords(2827,3343,0);
  1785. for(int i = 0; i < skillLvl.length; i++)
  1786. {
  1787. skillLvl[i] = getLevelForXP(i);
  1788. frames.setSkillLvl(this, i);
  1789. }
  1790. requestAnim(-1, 0);
  1791. updateReq = true;
  1792. appearanceUpdateReq = true;
  1793. faceToUpdateReq = true;
  1794. }
  1795. }
  1796. /**
  1797. * Add experiance to a specific skill.
  1798. * @param amount The amoubt of XP you want to add.
  1799. * @param skill The skill id you want to add it to.
  1800. */
  1801. public void addSkillXP(double amount, int skill) {
  1802. if(skill > skillXP.length || skill < 0) {
  1803. return;
  1804. }
  1805. int oldLevel = getLevelForXP(skill);
  1806. skillXP[skill] += amount;
  1807. int newLevel = getLevelForXP(skill);
  1808. if(oldLevel < newLevel) {
  1809. if(skill == 3) {
  1810. updateHP(newLevel - oldLevel, true);
  1811. } else {
  1812. skillLvl[skill] += (newLevel - oldLevel);
  1813. }
  1814. frames.setSkillLvl(this, skill);
  1815. new LevelUp(this, skill);
  1816. appearanceUpdateReq = true;
  1817. updateReq = true;
  1818.  
  1819. }
  1820. frames.setSkillLvl(this, skill);
  1821. if (needsTrimmedCape()) {
  1822. replaceUntrimmedWithTrimmedCapes();
  1823. frames.setItems(this, 149, 0, 93, this.items, this.itemsN);
  1824. frames.setItems(this, -1, 64207, 95, this.bankItems, this.bankItemsN);
  1825. frames.setItems(this, 387, 28, 93, this.equipment, this.equipmentN);
  1826. this.appearanceUpdateReq = true;
  1827. this.updateReq = true;
  1828. }
  1829. }
  1830. /**
  1831. * Calculates equipment bonus.
  1832. */
  1833. public void calculateEquipmentBonus() {
  1834. for (int i = 0; i < equipmentBonus.length; i++) {
  1835. equipmentBonus[i] = 0;
  1836. }
  1837. for (int i = 0; i < equipment.length; i++) {
  1838. if (equipment[i] > -1) {
  1839. for (int j = 0; j < Engine.items.maxListedItems; j++) {
  1840. if (Engine.items.itemLists[j] != null) {
  1841. if (Engine.items.itemLists[j].itemId == equipment[i]) {
  1842. for (int k = 0; k < equipmentBonus.length; k++) {
  1843. equipmentBonus[k] += Engine.items.itemLists[j].bonuses[k];
  1844. }
  1845. break;
  1846. }
  1847. }
  1848. }
  1849. }
  1850. }
  1851. }
  1852.  
  1853.  
  1854. /**
  1855. * Writes the equipment bonus.
  1856. */
  1857. public void setEquipmentBonus() {
  1858. String[] bonusNames = Misc.bonusNames;
  1859. int id = 35;
  1860. for (int i = 0; i < equipmentBonus.length; i++) {
  1861. frames.setString(this, bonusNames[i] + ": " + (equipmentBonus[i] >= 0 ? "+" : "") + equipmentBonus[i], 667, id++);
  1862. if (id == 45) {
  1863. id = 47;
  1864. }
  1865. }
  1866. frames.setString(this, "Summoning: +0", 667, 45);
  1867. }
  1868.  
  1869. public void openBank() {
  1870. frames.setConfig2(this, 563, 4194304);
  1871. frames.setConfig2(this, 1248, -2013265920);
  1872. frames.setConfig(this, 115, withdrawNote ? 1 : 0);
  1873. frames.setConfig(this, 305, insertMode ? 1 : 0);
  1874. Engine.playerBank.sendTabConfig(this);
  1875. frames.showInterface(this, 762);
  1876. frames.setInventory(this, 763);
  1877. frames.setBankOptions(this);
  1878. frames.setString(this, "The Carrscape bank", 762, 24);
  1879. frames.setItems(this, -1, 64207, 95, bankItems, bankItemsN);
  1880. frames.setItems(this, -1, 64209, 93, items, itemsN);
  1881. //hideTabs(this);
  1882. viewingBankTab = 10;
  1883. frames.setString(this, ""+Engine.playerBank.getFreeBankSlot(this), 762, 97);
  1884. frames.setString(this, ""+Engine.playerBank.SIZE, 762, 98);
  1885. }
  1886. public void updateHP(int chHp, boolean heal) {
  1887. if (heal) {
  1888. skillLvl[3] += chHp;
  1889. if (skillLvl[3] > getLevelForXP(3)) {
  1890. skillLvl[3] = getLevelForXP(3);
  1891. }
  1892. } else if (!heal) {
  1893. skillLvl[3] -= chHp;
  1894. if (skillLvl[3] <= 0) {
  1895. skillLvl[3] = 0;
  1896. isDead = true;
  1897. Engine.playerMovement.resetWalkingQueue(this);
  1898. }
  1899. }
  1900. frames.setSkillLvl(this, 3);
  1901. }
  1902. public void updatePRAY(int chPR, boolean pray) {
  1903. if (pray) {
  1904. skillLvl[5] += chPR;
  1905. if (skillLvl[5] > getLevelForXP(5)) {
  1906. skillLvl[5] = getLevelForXP(5);
  1907. }
  1908. }
  1909. frames.setSkillLvl(this, 5);
  1910. }
  1911.  
  1912.  
  1913. /**
  1914. * Teleports a player.
  1915. * @param x The x coordinate to teleport to.
  1916. * @param y The y coordinate to teleport to.
  1917. * @param height The height level to teleport to.
  1918. * @param delay The delay before the teleport is done.
  1919. * @param distance The offset you can teleport to, such as 1 for a max offset of x +/- 1 and y +/- 1.
  1920. * @param emoteStart The emote to do right away.
  1921. * @param emoteEnd The emote to do after teleporting.
  1922. * @param gfxStart The graphic to do right away.
  1923. * @param gfxStartH The height level to create the start graphic at.
  1924. * @param gfxEnd The graphic to do after the teleport is done.
  1925. * @param gfxEndH The finish graphic height.
  1926. */
  1927. public void teleportTo(int x, int y, int height, int delay, int distance, int emoteStart, int emoteEnd, int gfxStart,
  1928. int gfxStartH, int gfxEnd, int gfxEndH) {
  1929. wc.resetWoodcutting();
  1930. ResetSkillSuff();
  1931. itemPickup = false;
  1932. playerOption1 = false;
  1933. playerOption2 = false;
  1934. playerOption3 = false;
  1935. npcOption1 = false;
  1936. npcOption2 = false;
  1937. objectOption1 = false;
  1938. objectOption2 = false;
  1939. attackingPlayer = false;
  1940. clickDelay = delay + 2;
  1941. teleDelay = delay;
  1942. if (distance > 0) {
  1943. int xType = Misc.random(1);
  1944. int yType = Misc.random(1);
  1945. int xOffset = Misc.random(distance);
  1946. int yOffset = Misc.random(distance);
  1947. if (xType == 1)
  1948. x += -xOffset;
  1949. else
  1950. x += xOffset;
  1951. if(yType == 1)
  1952. y += -yOffset;
  1953. else
  1954. y += yOffset;
  1955. }
  1956. teleX = x;
  1957. teleY = y;
  1958. heightLevel = height;
  1959. Engine.playerMovement.resetWalkingQueue(this);
  1960. requestAnim(emoteStart, 0);
  1961. requestGFX(gfxStart, gfxStartH);
  1962. teleFinishGFX = gfxEnd;
  1963. teleFinishGFXHeight = gfxEndH;
  1964. teleFinishAnim = emoteEnd;
  1965. }
  1966.  
  1967. /**
  1968. * Set the player's coordinates.
  1969. * @param x The x coordinate to teleport to.
  1970. * @param y The y coordinate to teleport to.
  1971. */
  1972. public void setCoords(int x, int y, int height) {
  1973. ResetSkillSuff();
  1974. wc.resetWoodcutting();
  1975. teleportToX = x;
  1976. teleportToY = y;
  1977. heightLevel = height;
  1978. didTeleport = true;
  1979. }
  1980.  
  1981. /**
  1982. * Req an animation for this player.
  1983. * @param animId The amination to perform.
  1984. * @param animD The delay before doing the animation.
  1985. */
  1986. public void requestAnim(int animId, int animD) {
  1987. animReq = animId;
  1988. animDelay = animD;
  1989. animUpdateReq = true;
  1990. updateReq = true;
  1991. }
  1992.  
  1993. /**
  1994. * Req an graphic for this player.
  1995. * @param gfxId The graphic to perform.
  1996. * @param gfxD The delay or height or the gfx depending on the value.
  1997. */
  1998. public void requestGFX(int gfxId, int gfxD) {
  1999. if (gfxD >= 100) {
  2000. gfxD += 6553500;
  2001. }
  2002. gfxReq = gfxId;
  2003. gfxDelay = gfxD;
  2004. gfxUpdateReq = true;
  2005. updateReq = true;
  2006. }
  2007.  
  2008. /**
  2009. * Req this player faces NPC or player.
  2010. * @param faceId The target to face.
  2011. */
  2012. public void requestFaceTo(int faceId) {
  2013. faceToReq = faceId;
  2014. faceToUpdateReq = true;
  2015. updateReq = true;
  2016. }
  2017.  
  2018. /**
  2019. * Append damage.
  2020. */
  2021. public void appendHit(int damage, int posion) {
  2022. if (damage > skillLvl[3]) {
  2023. damage = skillLvl[3];
  2024. }
  2025. updateHP(damage, false);
  2026. if (!hit1UpdateReq) {
  2027. hitDiff1 = damage;
  2028. posionHit1 = posion;
  2029. hit1UpdateReq = true;
  2030. } else {
  2031. hitDiff2 = damage;
  2032. posionHit2 = posion;
  2033. hit2UpdateReq = true;
  2034. }
  2035. updateReq = true;
  2036. }
  2037.  
  2038. /**
  2039. * Force chat text.
  2040. */
  2041. public void requestForceChat(String s) {
  2042. forceChat = s;
  2043. forceChatUpdateReq = true;
  2044. updateReq = true;
  2045. }
  2046. public void objects() {
  2047. frames.createGlobalObject(1307, 0, 2694, 3426, 0, 10); //Maple Tree
  2048. frames.createGlobalObject(1309, 0, 2700, 3420, 0, 10); //Yew Tree
  2049. frames.createGlobalObject(28214, 0, 2855, 3329, 0, 10); //Donator Portal
  2050. frames.createGlobalObject(11402, 0, 2864, 3335, 0, 10); //Bank outside cooking
  2051. frames.createGlobalObject(11402, 0, 2822, 3346, 0, 10); //Bank @ Home
  2052. frames.createGlobalObject(11402, 0, 2821, 3346, 0, 10); //Bank @ Home
  2053. frames.createGlobalObject(611, 0, 2827, 3356, 0, 10); //Picnic Bench @ Home
  2054. frames.createGlobalObject(16687, 0, 3041, 4834, 0, 10); //rune ess
  2055. frames.createGlobalObject(16687, 0, 3040, 4834, 0, 10); //rune ess
  2056. frames.createGlobalObject(16687, 0, 3039, 4834, 0, 10); //rune ess
  2057. frames.createGlobalObject(16687, 0, 3038, 4834, 0, 10); //rune ess
  2058. frames.createGlobalObject(2873, 0, 2827, 3344, 0, 10); //Saradomin Statue
  2059. frames.createGlobalObject(2029, 0, 2879, 3335, 0, 10); //Fishing
  2060. frames.createGlobalObject(2029, 0, 2879, 3338, 0, 10); //Fishing
  2061. frames.createGlobalObject(2028, 0, 2879, 3339, 0, 10); //Fishing
  2062. frames.createGlobalObject(2028, 0, 2879, 3334, 0, 10); //Fishing
  2063. frames.createGlobalObject(2029, 0, 2877, 3342, 0, 10); //Fishing
  2064. frames.createGlobalObject(2028, 0, 2875, 3342, 0, 10); //Fishing
  2065. frames.createGlobalObject(2515, 0, 2876, 3330, 0, 10); //Row Boat
  2066. frames.createGlobalObject(14859, 0, 2943, 3285, 1, 10); //Rune
  2067. frames.createGlobalObject(14859, 0, 2943, 3286, 1, 10); //Rune
  2068. frames.createGlobalObject(11941, 0, 2943, 3287, 1, 10); //Addy
  2069. frames.createGlobalObject(11941, 0, 2943, 3288, 1, 10); //Addy
  2070. frames.createGlobalObject(11944, 0, 2943, 3289, 1, 10); //Mith
  2071. }
  2072. /**
  2073. * Checks special amount and gets config.
  2074. */
  2075. public void checkAmount(Player p) {
  2076. int amount = p.specialAmount;
  2077. if (amount == 100) {
  2078. p.frames.setConfig(p, 300, 1000);
  2079. } else if (amount >= 80){
  2080. p.frames.setConfig(p, 300, 800);
  2081. } else if (amount >= 60){
  2082. p.frames.setConfig(p, 300, 600);
  2083. } else if (amount >= 50){
  2084. p.frames.setConfig(p, 300, 500);
  2085. } else if (amount >= 40){
  2086. p.frames.setConfig(p, 300, 400);
  2087. } else if (amount >= 20){
  2088. p.frames.setConfig(p, 300, 200);
  2089. } else if (amount >= 0){
  2090. p.frames.setConfig(p, 300, 0);
  2091. } else {
  2092. // nothing
  2093. }
  2094. }
  2095.  
  2096. /**
  2097. * Prepare player for removal.
  2098. */
  2099. public void destruct() {
  2100. stream = null;
  2101. long me = Misc.stringToLong(username);
  2102. for(Player p : Engine.players) {
  2103. if(p == null) continue;
  2104. if(p.friends.contains(me)) {
  2105. p.frames.sendFriend(p, me, 0);
  2106. }
  2107. }
  2108. try {
  2109. socket.input.close();
  2110. socket.output.close();
  2111. socket.socket.close();
  2112. } catch (Exception e) {
  2113. }
  2114. socket.input = null;
  2115. socket.output = null;
  2116. socket.socket = null;
  2117. socket = null;
  2118. absX = absY = mapRegionX = mapRegionY = -1;
  2119. }
  2120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement