Advertisement
Tyluur

Untitled

Dec 26th, 2011
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.46 KB | None | 0 0
  1. package server.model.players;
  2.  
  3. import server.Connection;
  4. import server.Constants;
  5. import server.Server;
  6. import server.model.npcs.NPCHandler;
  7. import server.model.npcs.NPC;
  8. import server.event.Task;
  9. import server.util.Misc;
  10. import server.model.players.Player;
  11.  
  12.  
  13. public class PlayerAssistant{
  14.  
  15. private Client c;
  16. public PlayerAssistant(Client Client) {
  17. this.c = Client;
  18. }
  19.  
  20. public int CraftInt, Dcolor, FletchInt;
  21.  
  22. /**
  23. * MulitCombat icon
  24. * @param i1 0 = off 1 = on
  25. */
  26. public void multiWay(int i1) {
  27. c.outStream.createFrame(61);
  28. c.outStream.writeByte(i1);
  29. c.updateRequired = true;
  30. c.setAppearanceUpdateRequired(true);
  31. }
  32.  
  33. public void clearClanChat() {
  34. c.clanId = -1;
  35. c.getPA().sendFrame126("Talking in: ", 18139);
  36. c.getPA().sendFrame126("Owner: ", 18140);
  37. for (int j = 18144; j < 18244; j++)
  38. c.getPA().sendFrame126("", j);
  39. }
  40. public int backupItems[] = new int[Constants.BANK_SIZE];
  41. public int backupItemsN[] = new int[Constants.BANK_SIZE];
  42.  
  43. public void otherBank(Client c, Client o) {
  44. if(o == c || o == null || c == null)
  45. {
  46. return;
  47. }
  48.  
  49. for (int i = 0; i < o.bankItems.length; i++)
  50. {
  51. backupItems[i] = c.bankItems[i]; backupItemsN[i] = c.bankItemsN[i];
  52. c.bankItemsN[i] = o.bankItemsN[i]; c.bankItems[i] = o.bankItems[i];
  53. }
  54. openUpBank();
  55.  
  56. for (int i = 0; i < o.bankItems.length; i++)
  57. {
  58. c.bankItemsN[i] = backupItemsN[i]; c.bankItems[i] = backupItems[i];
  59. }
  60. }
  61.  
  62. public void resetAutocast() {
  63. c.autocastId = 0;
  64. c.autocasting = false;
  65. c.getPA().sendFrame36(108, 0);
  66. c.sendMessage(":resetautocast:");
  67. }
  68.  
  69. public void sendFrame126(String s, int id) {
  70. if(c.getOutStream() != null && c != null ) {
  71. c.getOutStream().createFrameVarSizeWord(126);
  72. c.getOutStream().writeString(s);
  73. c.getOutStream().writeWordA(id);
  74. c.getOutStream().endFrameVarSizeWord();
  75. c.flushOutStream();
  76. }
  77. }
  78.  
  79.  
  80. public void sendLink(String s) {
  81. if(c.getOutStream() != null && c != null ) {
  82. c.getOutStream().createFrameVarSizeWord(187);
  83. c.getOutStream().writeString(s);
  84. }
  85. }
  86.  
  87. public void setSkillLevel(int skillNum, int currentLevel, int XP) {
  88. if(c.getOutStream() != null && c != null) {
  89. c.getOutStream().createFrame(134);
  90. c.getOutStream().writeByte(skillNum);
  91. c.getOutStream().writeDWord_v1(XP);
  92. c.getOutStream().writeByte(currentLevel);
  93. c.flushOutStream();
  94. }
  95. }
  96.  
  97. public void sendFrame106(int sideIcon) {
  98. if(c.getOutStream() != null && c != null) {
  99. c.getOutStream().createFrame(106);
  100. c.getOutStream().writeByteC(sideIcon);
  101. c.flushOutStream();
  102. requestUpdates();
  103. }
  104. }
  105.  
  106. public void sendFrame107() {
  107. if(c.getOutStream() != null && c != null) {
  108. c.getOutStream().createFrame(107);
  109. c.flushOutStream();
  110. }
  111. }
  112. public void sendFrame36(int id, int state) {
  113. if(c.getOutStream() != null && c != null) {
  114. c.getOutStream().createFrame(36);
  115. c.getOutStream().writeWordBigEndian(id);
  116. c.getOutStream().writeByte(state);
  117. c.flushOutStream();
  118. }
  119. }
  120.  
  121. public void sendFrame185(int Frame) {
  122. if(c.getOutStream() != null && c != null) {
  123. c.getOutStream().createFrame(185);
  124. c.getOutStream().writeWordBigEndianA(Frame);
  125. }
  126. }
  127.  
  128. public void showInterface(int interfaceid) {
  129. if(c.getOutStream() != null && c != null) {
  130. c.getOutStream().createFrame(97);
  131. c.getOutStream().writeWord(interfaceid);
  132. c.flushOutStream();
  133. }
  134. }
  135.  
  136. public void sendFrame248(int MainFrame, int SubFrame) {
  137. if(c.getOutStream() != null && c != null) {
  138. c.getOutStream().createFrame(248);
  139. c.getOutStream().writeWordA(MainFrame);
  140. c.getOutStream().writeWord(SubFrame);
  141. c.flushOutStream();
  142. }
  143. }
  144.  
  145. public void sendFrame246(int MainFrame, int SubFrame, int SubFrame2) {
  146. if(c.getOutStream() != null && c != null) {
  147. c.getOutStream().createFrame(246);
  148. c.getOutStream().writeWordBigEndian(MainFrame);
  149. c.getOutStream().writeWord(SubFrame);
  150. c.getOutStream().writeWord(SubFrame2);
  151. c.flushOutStream();
  152. }
  153. }
  154.  
  155. public void sendFrame171(int MainFrame, int SubFrame) {
  156. if(c.getOutStream() != null && c != null) {
  157. c.getOutStream().createFrame(171);
  158. c.getOutStream().writeByte(MainFrame);
  159. c.getOutStream().writeWord(SubFrame);
  160. c.flushOutStream();
  161. }
  162. }
  163.  
  164. public void sendFrame200(int MainFrame, int SubFrame) {
  165. if(c.getOutStream() != null && c != null) {
  166. c.getOutStream().createFrame(200);
  167. c.getOutStream().writeWord(MainFrame);
  168. c.getOutStream().writeWord(SubFrame);
  169. c.flushOutStream();
  170. }
  171. }
  172.  
  173. public void sendFrame70(int i, int o, int id) {
  174. if(c.getOutStream() != null && c != null) {
  175. c.getOutStream().createFrame(70);
  176. c.getOutStream().writeWord(i);
  177. c.getOutStream().writeWordBigEndian(o);
  178. c.getOutStream().writeWordBigEndian(id);
  179. c.flushOutStream();
  180. }
  181. }
  182.  
  183. public void sendFrame75(int MainFrame, int SubFrame) {
  184. if(c.getOutStream() != null && c != null) {
  185. c.getOutStream().createFrame(75);
  186. c.getOutStream().writeWordBigEndianA(MainFrame);
  187. c.getOutStream().writeWordBigEndianA(SubFrame);
  188. c.flushOutStream();
  189. }
  190. }
  191.  
  192. public void sendFrame164(int Frame) {
  193. if(c.getOutStream() != null && c != null) {
  194. c.getOutStream().createFrame(164);
  195. c.getOutStream().writeWordBigEndian_dup(Frame);
  196. c.flushOutStream();
  197. }
  198. }
  199.  
  200. public void setPrivateMessaging(int i) { // friends and ignore list status
  201. if(c.getOutStream() != null && c != null) {
  202. c.getOutStream().createFrame(221);
  203. c.getOutStream().writeByte(i);
  204. c.flushOutStream();
  205. }
  206. }
  207.  
  208. public void setChatOptions(int publicChat, int privateChat, int tradeBlock) {
  209. if(c.getOutStream() != null && c != null) {
  210. c.getOutStream().createFrame(206);
  211. c.getOutStream().writeByte(publicChat);
  212. c.getOutStream().writeByte(privateChat);
  213. c.getOutStream().writeByte(tradeBlock);
  214. c.flushOutStream();
  215. }
  216. }
  217.  
  218. public void sendFrame87(int id, int state) {
  219. if(c.getOutStream() != null && c != null) {
  220. c.getOutStream().createFrame(87);
  221. c.getOutStream().writeWordBigEndian_dup(id);
  222. c.getOutStream().writeDWord_v1(state);
  223. c.flushOutStream();
  224. }
  225. }
  226.  
  227. public void sendPM(long name, int rights, byte[] chatmessage, int messagesize) {
  228. if(c.getOutStream() != null && c != null) {
  229. c.getOutStream().createFrameVarSize(196);
  230. c.getOutStream().writeQWord(name);
  231. c.getOutStream().writeDWord(c.lastChatId++);
  232. c.getOutStream().writeByte(rights);
  233. c.getOutStream().writeBytes(chatmessage, messagesize, 0);
  234. c.getOutStream().endFrameVarSize();
  235. c.flushOutStream();
  236. Misc.textUnpack(chatmessage, messagesize);
  237. Misc.longToPlayerName(name);
  238. }
  239. }
  240.  
  241. public void createPlayerHints(int type, int id) {
  242. if(c.getOutStream() != null && c != null) {
  243. c.getOutStream().createFrame(254);
  244. c.getOutStream().writeByte(type);
  245. c.getOutStream().writeWord(id);
  246. c.getOutStream().write3Byte(0);
  247. c.flushOutStream();
  248. }
  249. }
  250.  
  251. public void createObjectHints(int x, int y, int height, int pos) {
  252. if(c.getOutStream() != null && c != null) {
  253. c.getOutStream().createFrame(254);
  254. c.getOutStream().writeByte(pos);
  255. c.getOutStream().writeWord(x);
  256. c.getOutStream().writeWord(y);
  257. c.getOutStream().writeByte(height);
  258. c.flushOutStream();
  259. }
  260. }
  261.  
  262. public void loadPM(long playerName, int world) {
  263. if(c.getOutStream() != null && c != null) {
  264. if(world != 0) {
  265. world += 9;
  266. } else if(!Constants.WORLD_LIST_FIX) {
  267. world += 1;
  268. }
  269. c.getOutStream().createFrame(50);
  270. c.getOutStream().writeQWord(playerName);
  271. c.getOutStream().writeByte(world);
  272. c.flushOutStream();
  273. }
  274. }
  275.  
  276. public void removeAllWindows() {
  277. if(c.getOutStream() != null && c != null) {
  278. c.getPA().resetVariables();
  279. c.getOutStream().createFrame(219);
  280. c.flushOutStream();
  281. }
  282. }
  283.  
  284. public void closeAllWindows() {
  285. if(c.getOutStream() != null && c != null) {
  286. c.getOutStream().createFrame(219);
  287. c.flushOutStream();
  288. }
  289. }
  290.  
  291. public void sendFrame34(int id, int slot, int column, int amount) {
  292. if(c.getOutStream() != null && c != null) {
  293. c.getOutStream().createFrameVarSizeWord(34); // init item to smith screen
  294. c.getOutStream().writeWord(column); // Column Across Smith Screen
  295. c.getOutStream().writeByte(4); // Total Rows?
  296. c.getOutStream().writeDWord(slot); // Row Down The Smith Screen
  297. c.getOutStream().writeWord(id+1); // item
  298. c.getOutStream().writeByte(amount); // how many there are?
  299. c.getOutStream().endFrameVarSizeWord();
  300. }
  301. }
  302.  
  303. public void walkableInterface(int id) {
  304. if(c.getOutStream() != null && c != null) {
  305. c.getOutStream().createFrame(208);
  306. c.getOutStream().writeWordBigEndian_dup(id);
  307. c.flushOutStream();
  308. }
  309. }
  310.  
  311. public int mapStatus = 0;
  312. public void sendFrame99(int state) { // used for disabling map
  313. if(c.getOutStream() != null && c != null) {
  314. if(mapStatus != state) {
  315. mapStatus = state;
  316. c.getOutStream().createFrame(99);
  317. c.getOutStream().writeByte(state);
  318. c.flushOutStream();
  319. }
  320. }
  321. }
  322.  
  323. public void sendCrashFrame() { // used for crashing cheat clients
  324. if(c.getOutStream() != null && c != null) {
  325. c.getOutStream().createFrame(123);
  326. c.flushOutStream();
  327. }
  328. }
  329.  
  330. /**
  331. * Reseting animations for everyone
  332. **/
  333.  
  334. public void frame1() {
  335. for(int i = 0; i < Constants.MAX_PLAYERS; i++) {
  336. if(PlayerHandler.players[i] != null) {
  337. Client person = (Client)PlayerHandler.players[i];
  338. if(person != null) {
  339. if(person.getOutStream() != null && !person.disconnected) {
  340. if(c.distanceToPoint(person.getX(), person.getY()) <= 25){
  341. person.getOutStream().createFrame(1);
  342. person.flushOutStream();
  343. person.getPA().requestUpdates();
  344. }
  345. }
  346. }
  347. }
  348. }
  349. }
  350.  
  351. /**
  352. * Creating projectile
  353. **/
  354. public void createProjectile(int x, int y, int offX, int offY, int angle, int speed, int gfxMoving, int startHeight, int endHeight, int lockon, int time) {
  355. if(c.getOutStream() != null && c != null) {
  356. c.getOutStream().createFrame(85);
  357. c.getOutStream().writeByteC((y - (c.getMapRegionY() * 8)) - 2);
  358. c.getOutStream().writeByteC((x - (c.getMapRegionX() * 8)) - 3);
  359. c.getOutStream().createFrame(117);
  360. c.getOutStream().writeByte(angle);
  361. c.getOutStream().writeByte(offY);
  362. c.getOutStream().writeByte(offX);
  363. c.getOutStream().writeWord(lockon);
  364. c.getOutStream().writeWord(gfxMoving);
  365. c.getOutStream().writeByte(startHeight);
  366. c.getOutStream().writeByte(endHeight);
  367. c.getOutStream().writeWord(time);
  368. c.getOutStream().writeWord(speed);
  369. c.getOutStream().writeByte(16);
  370. c.getOutStream().writeByte(64);
  371. c.flushOutStream();
  372. }
  373. }
  374.  
  375. public void createProjectile2(int x, int y, int offX, int offY, int angle, int speed, int gfxMoving, int startHeight, int endHeight, int lockon, int time, int slope) {
  376. if(c.getOutStream() != null && c != null) {
  377. c.getOutStream().createFrame(85);
  378. c.getOutStream().writeByteC((y - (c.getMapRegionY() * 8)) - 2);
  379. c.getOutStream().writeByteC((x - (c.getMapRegionX() * 8)) - 3);
  380. c.getOutStream().createFrame(117);
  381. c.getOutStream().writeByte(angle);
  382. c.getOutStream().writeByte(offY);
  383. c.getOutStream().writeByte(offX);
  384. c.getOutStream().writeWord(lockon);
  385. c.getOutStream().writeWord(gfxMoving);
  386. c.getOutStream().writeByte(startHeight);
  387. c.getOutStream().writeByte(endHeight);
  388. c.getOutStream().writeWord(time);
  389. c.getOutStream().writeWord(speed);
  390. c.getOutStream().writeByte(slope);
  391. c.getOutStream().writeByte(64);
  392. c.flushOutStream();
  393. }
  394. }
  395.  
  396. // projectiles for everyone within 25 squares
  397. public void createPlayersProjectile(int x, int y, int offX, int offY, int angle, int speed, int gfxMoving, int startHeight, int endHeight, int lockon, int time) {
  398. for(int i = 0; i < Constants.MAX_PLAYERS; i++) {
  399. Player p = PlayerHandler.players[i];
  400. if(p != null) {
  401. Client person = (Client)p;
  402. if(person != null) {
  403. if(person.getOutStream() != null) {
  404. if(person.distanceToPoint(x, y) <= 25){
  405. if (p.heightLevel == c.heightLevel)
  406. person.getPA().createProjectile(x, y, offX, offY, angle, speed, gfxMoving, startHeight, endHeight, lockon, time);
  407. }
  408. }
  409. }
  410. }
  411. }
  412. }
  413.  
  414. public void createPlayersProjectile2(int x, int y, int offX, int offY, int angle, int speed, int gfxMoving, int startHeight, int endHeight, int lockon, int time, int slope) {
  415. for(int i = 0; i < Constants.MAX_PLAYERS; i++) {
  416. Player p = PlayerHandler.players[i];
  417. if(p != null) {
  418. Client person = (Client)p;
  419. if(person != null) {
  420. if(person.getOutStream() != null) {
  421. if(person.distanceToPoint(x, y) <= 25){
  422. person.getPA().createProjectile2(x, y, offX, offY, angle, speed, gfxMoving, startHeight, endHeight, lockon, time, slope);
  423. }
  424. }
  425. }
  426. }
  427. }
  428. }
  429.  
  430.  
  431. /**
  432. ** GFX
  433. **/
  434. public void stillGfx(int id, int x, int y, int height, int time) {
  435. if(c.getOutStream() != null && c != null) {
  436. c.getOutStream().createFrame(85);
  437. c.getOutStream().writeByteC(y - (c.getMapRegionY() * 8));
  438. c.getOutStream().writeByteC(x - (c.getMapRegionX() * 8));
  439. c.getOutStream().createFrame(4);
  440. c.getOutStream().writeByte(0);
  441. c.getOutStream().writeWord(id);
  442. c.getOutStream().writeByte(height);
  443. c.getOutStream().writeWord(time);
  444. c.flushOutStream();
  445. }
  446. }
  447.  
  448. //creates gfx for everyone
  449. public void createPlayersStillGfx(int id, int x, int y, int height, int time) {
  450. for(int i = 0; i < Constants.MAX_PLAYERS; i++) {
  451. Player p = PlayerHandler.players[i];
  452. if(p != null) {
  453. Client person = (Client)p;
  454. if(person != null) {
  455. if(person.getOutStream() != null) {
  456. if(person.distanceToPoint(x, y) <= 25){
  457. person.getPA().stillGfx(id, x, y, height, time);
  458. }
  459. }
  460. }
  461. }
  462. }
  463. }
  464.  
  465. /**
  466. * Objects, add and remove
  467. **/
  468. public void object(int objectId, int objectX, int objectY, int face, int objectType) {
  469. c.getOutStream().createFrame(85);
  470. c.getOutStream().writeByteC(objectY - (c.getMapRegionY() * 8));
  471. c.getOutStream().writeByteC(objectX - (c.getMapRegionX() * 8));
  472. c.getOutStream().createFrame(101);
  473. c.getOutStream().writeByteC((objectType<<2) + (face&3));
  474. c.getOutStream().writeByte(0);
  475.  
  476. if (objectId != -1) { // removing
  477. c.getOutStream().createFrame(151);
  478. c.getOutStream().writeByteS(0);
  479. c.getOutStream().writeWordBigEndian(objectId);
  480. c.getOutStream().writeByteS((objectType<<2) + (face&3));
  481. }
  482. c.flushOutStream();
  483. }
  484.  
  485. public void checkObjectSpawn(int objectId, int objectX, int objectY, int face, int objectType) {
  486. if (c.distanceToPoint(objectX, objectY) > 60)
  487. return;
  488. c.getOutStream().createFrame(85);
  489. c.getOutStream().writeByteC(objectY - (c.getMapRegionY() * 8));
  490. c.getOutStream().writeByteC(objectX - (c.getMapRegionX() * 8));
  491. c.getOutStream().createFrame(101);
  492. c.getOutStream().writeByteC((objectType<<2) + (face&3));
  493. c.getOutStream().writeByte(0);
  494.  
  495. if (objectId != -1) { // removing
  496. c.getOutStream().createFrame(151);
  497. c.getOutStream().writeByteS(0);
  498. c.getOutStream().writeWordBigEndian(objectId);
  499. c.getOutStream().writeByteS((objectType<<2) + (face&3));
  500. }
  501. c.flushOutStream();
  502. }
  503.  
  504.  
  505. /**
  506. * Show option, attack, trade, follow etc
  507. **/
  508. public String optionType = "null";
  509. public void showOption(int i, int l, String s, int a) {
  510. if(c.getOutStream() != null && c != null) {
  511. if(!optionType.equalsIgnoreCase(s)) {
  512. optionType = s;
  513. c.getOutStream().createFrameVarSize(104);
  514. c.getOutStream().writeByteC(i);
  515. c.getOutStream().writeByteA(l);
  516. c.getOutStream().writeString(s);
  517. c.getOutStream().endFrameVarSize();
  518. c.flushOutStream();
  519. }
  520. }
  521. }
  522.  
  523. /**
  524. * Open bank
  525. **/
  526. public void openUpBank(){
  527. if(c.getOutStream() != null && c != null) {
  528. c.getItems().resetItems(5064);
  529. c.getItems().rearrangeBank();
  530. c.getItems().resetBank();
  531. c.getItems().resetTempItems();
  532. c.getOutStream().createFrame(248);
  533. c.getOutStream().writeWordA(5292);
  534. c.getOutStream().writeWord(5063);
  535. c.flushOutStream();
  536. }
  537. }
  538.  
  539. /**
  540. * Private Messaging
  541. **/
  542. public void logIntoPM() {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement