Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.74 KB | None | 0 0
  1. import "std.zh"
  2.  
  3. ////////////////////////////////////////////////////////////////
  4. // Charge Bow
  5. // by grayswandir
  6. ////////////////////////////////////////////////////////////////
  7. // Description:
  8. //
  9. // This is an 8-way bow that you can charge-up, aim, and shoot. If an arrow
  10. // hits a flame source, it'll turn into a flamming arrow (fire-type weapon).
  11. ////////////////////////////////////////////////////////////////
  12. // Setup:
  13. //
  14. // This requires std.zh.
  15. //
  16. // Read through the following Integration section and change all the values to
  17. // suit your quest.
  18. //
  19. // Make sure to load the ChargeBow ffc script, and the ChargeBow_Use item
  20. // script.
  21. //
  22. // Set ChargeBow_Use as the item use script of the item used to fire
  23. // it. Change it from an arrow to a Custom Item class. (Also remember to
  24. // change the subscreen slot from arrow to that custom item class as well.)
  25. // Make the first provided argument to the script the item's id. The second
  26. // should be the first arrow tile. The tiles should be in order of Up, Down,
  27. // Left, Right, Left-Up, Right-Up, Left-Down, Right-Down. The third and fourth
  28. // arguments are the csets to use for normal arrows and fire arrows.
  29. //
  30. // This makes use of global variables, so it will invalidate saves when added.
  31.  
  32. ////////////////////////////////////////////////////////////////
  33. // Integration
  34. ////////////////
  35. // This section is the part that needs to be set manually for each quest. Read
  36. // the description for each part and set it accordingly.
  37. ////////////////
  38.  
  39. ////////////////////////////////////////////////////////////////
  40. // Arrow Animation Setup
  41.  
  42. // How fast arrows animate.
  43. const int CHARGEBOW_ARROW_ASPEED = 8;
  44.  
  45. // The offset from the normal tiles for the fire animation.
  46. const int CHARGEBOW_FIRE_TILE_OFFSET = 20;
  47.  
  48. // The number of frames the fire animation has.
  49. const int CHARGEBOW_FIRE_FRAMECOUNT = 2;
  50.  
  51. ////////////////////////////////////////////////////////////////
  52. // Link Animation Setup
  53.  
  54. // Each link animation is a block of tiles. Advancing to the right moves
  55. // through the different directions. (The order is Up, Down, Left, Right,
  56. // Left-Up, Right-Up, Left-Down, Right-Down). The first row is with the bow &
  57. // arrow, the second row is without the arrow. Each frame is a 2 by 2 tile
  58. // that is centered on Link.
  59.  
  60. // Higher number costumes take precedence.
  61.  
  62. //// Default Costume
  63.  
  64. // The starting tile for the link animation.
  65. const int CHARGEBOW_LINK_C0_TILE = 1300;
  66.  
  67. // The cset the link animation uses.
  68. const int CHARGEBOW_LINK_C0_CSET = 6;
  69.  
  70. //// Costume 1
  71.  
  72. // The item that marks using costume 1. Set to 0 to disable.
  73. const int CHARGEBOW_LINK_C1_ITEM = 17;
  74.  
  75. // The starting tile for the link animation.
  76. const int CHARGEBOW_LINK_C1_TILE = 1300;
  77.  
  78. // The cset the link animation uses.
  79. const int CHARGEBOW_LINK_C1_CSET = 7;
  80.  
  81. //// Costume 2
  82.  
  83. // The item that marks using costume 2. Set to 0 to disable.
  84. const int CHARGEBOW_LINK_C2_ITEM = 0;
  85.  
  86. // The starting tile for the link animation.
  87. const int CHARGEBOW_LINK_C2_TILE = 0;
  88.  
  89. // The cset the link animation uses.
  90. const int CHARGEBOW_LINK_C2_CSET = 6;
  91.  
  92. //// Costume 3
  93.  
  94. // The item that marks using costume 3. Set to 0 to disable.
  95. const int CHARGEBOW_LINK_C3_ITEM = 0;
  96.  
  97. // The starting tile for the link animation.
  98. const int CHARGEBOW_LINK_C3_TILE = 0;
  99.  
  100. // The cset the link animation uses.
  101. const int CHARGEBOW_LINK_C3_CSET = 6;
  102.  
  103. //// Costume 4
  104.  
  105. // The item that marks using costume 4. Set to 0 to disable.
  106. const int CHARGEBOW_LINK_C4_ITEM = 0;
  107.  
  108. // The starting tile for the link animation.
  109. const int CHARGEBOW_LINK_C4_TILE = 0;
  110.  
  111. // The cset the link animation uses.
  112. const int CHARGEBOW_LINK_C4_CSET = 6;
  113.  
  114. ////////////////////////////////////////////////////////////////
  115. // Gameplay Setup
  116.  
  117. // This is the sound played when you try to fire without any arrows. Set to 0
  118. // for no sound.
  119. const int CHARGEBOW_FAIL_SOUND = 21;
  120.  
  121. //// Charge Level 0
  122.  
  123. // This is the sound played when you first use the bow. Set to 0 for no sound.
  124. const int CHARGEBOW_START_SOUND = 0;
  125.  
  126. // This is the sound played when you release a level 0 shot. Set to 0 for no sound.
  127. const int CHARGEBOW_L0_SHOT_SOUND = 1;
  128.  
  129. // This is the amount of ammo this level shot uses.
  130. const int CHARGEBOW_L0_AMMO = 1;
  131.  
  132. // This is the amount of magic this level shot uses.
  133. const int CHARGEBOW_L0_MAGIC = 0;
  134.  
  135. //// Charge Level 1
  136.  
  137. // This is the item id that unlocks this charge level. Set to 0 for no item
  138. // needed.
  139. const int CHARGEBOW_L1_ITEM_ID = 0;
  140.  
  141. // This is the cumulative frames you need to charge for this charge level.
  142. const int CHARGEBOW_L1_CHARGE_TIME = 60;
  143.  
  144. // This is the sound played when you reach charge level 1. Set to 0 for no
  145. // sound.
  146. const int CHARGEBOW_L1_CHARGE_SOUND = 35;
  147.  
  148. // This is the sound played when you release a level 1 shot. Set to 0 for no
  149. // sound.
  150. const int CHARGEBOW_L1_SHOT_SOUND = 1;
  151.  
  152. // This is the amount of ammo this level shot uses.
  153. const int CHARGEBOW_L1_AMMO = 1;
  154.  
  155. // This is the amount of magic this level shot uses.
  156. const int CHARGEBOW_L1_MAGIC = 8;
  157.  
  158. //// Charge Level 2
  159.  
  160. // This is the item id that unlocks this charge level. Set to 0 for no item
  161. // needed.
  162. const int CHARGEBOW_L2_ITEM_ID = 0;
  163.  
  164. // This is the cumulative frames you need to charge for this charge level.
  165. const int CHARGEBOW_L2_CHARGE_TIME = 150;
  166.  
  167. // This is the sound played when you reach charge level 2. Set to 0 for no
  168. // sound.
  169. const int CHARGEBOW_L2_CHARGE_SOUND = 36;
  170.  
  171. // This is the sound played when you release a level 2 shot. Set to 0 for no
  172. // sound.
  173. const int CHARGEBOW_L2_SHOT_SOUND = 1;
  174.  
  175. // This is the amount of ammo this level shot uses.
  176. const int CHARGEBOW_L2_AMMO = 3;
  177.  
  178. // This is the amount of magic this level shot uses.
  179. const int CHARGEBOW_L2_MAGIC = 32;
  180.  
  181. //// Effects
  182.  
  183. // This is the combo flag that sets an arrow on fire. Defaults to script 1.
  184. const int CHARGEBOW_BURN_FLAG = 98;
  185.  
  186. // This is the sound that's made when the arrow catches on fire. Set to 0 for
  187. // no sound.
  188. const int CHARGEBOW_BURN_SOUND = 0;
  189.  
  190. // This is the amount of damage the arrow does.
  191. int ChargeBow_Damage(int item_id, int charge_level, int element) {
  192. itemdata data = Game->LoadItemData(item_id);
  193. int damage = data->Power;
  194. if (element == CHARGEBOW_ELEMENT_FIRE) {damage *= 2;}
  195. return damage;
  196. }
  197.  
  198. // The amount of speed each level of charge adds to the arrow.
  199. const int CHARGEBOW_ARROW_CHARGE_SPEED = 1;
  200.  
  201. // Return the strongest bow link has, or -1 for none.
  202. int ChargeBow_StrongestBow() {
  203. int bow_id = -1;
  204. int bow_level = -1;
  205. itemdata data;
  206.  
  207. // Find the highest level bow item the player has.
  208. for (int i = 0; i < 256; ++i) {
  209. data = Game->LoadItemData(i);
  210. if (!Link->Item[i]) {continue;}
  211. if (IC_BOW != data->Family) {continue;}
  212. if (data->Level > bow_level) {
  213. bow_id = i;
  214. bow_level = data->Level;
  215. }
  216. }
  217.  
  218. return bow_id;
  219. }
  220.  
  221. // This is the speed the arrow flies at. For reference, Link's movement is
  222. // 1.5. Defaults to the strongest bow that Link has. Return -1 for no bow.
  223. int ChargeBow_Speed(int item_id, int charge_level, int element) {
  224. int bow_id = ChargeBow_StrongestBow();
  225. itemdata data = Game->LoadItemData(bow_id);
  226. int speed = data->Power;
  227.  
  228. // Add speed for each charge level.
  229. speed += charge_level * CHARGEBOW_ARROW_CHARGE_SPEED;
  230.  
  231. return speed;
  232. }
  233.  
  234. ////////////////////////////////////////////////////////////////
  235. // Main Script
  236.  
  237. const int CHARGEBOW_ELEMENT_NONE = 0;
  238. const int CHARGEBOW_ELEMENT_FIRE = 1;
  239.  
  240. item script ChargeBow_Use {
  241. void run(int item_id, int tile, int cset, int fire_cset) {
  242. int i; ffc f;
  243.  
  244. // Cancel out if there's already an arrow on screen.
  245. if (ChargeBow.IsActive()) {return;}
  246.  
  247. // Check to see that we pressed the button instead of held it.
  248. if ((GetEquipmentA() == item_id && !Link->PressA)
  249. || (GetEquipmentB() == item_id && !Link->PressB)) {
  250. return;
  251. }
  252.  
  253. // Make sure we actually possess a bow.
  254. if (-1 == ChargeBow_StrongestBow()) {return;}
  255.  
  256. // Look for a free FFC slot.
  257. for (i = 1; i <= 32; ++i) {
  258. f = Screen->LoadFFC(i);
  259. if (0 == f->Data && 0 == f->Script) {break;}
  260. }
  261. // If we didn't find a free ffc, quit.
  262. if (33 == i) {return;}
  263.  
  264. // Start up the ffc script.
  265. f->Script = ChargeBow.ScriptId();
  266. f->InitD[0] = item_id;
  267. f->InitD[1] = tile;
  268. f->InitD[2] = cset;
  269. f->InitD[3] = fire_cset;
  270.  
  271. // Play the start sound.
  272. if (CHARGEBOW_START_SOUND) {Game->PlaySound(CHARGEBOW_START_SOUND);}
  273. }
  274. }
  275.  
  276. ffc script ChargeBow {
  277.  
  278. // Get the script number for this script.
  279. int ScriptId() {
  280. int name[] = "ChargeBow";
  281. return Game->GetFFCScript(name);
  282. }
  283.  
  284. // If the chargebow ffc is currently active.
  285. bool IsActive() {
  286. int script_id = ChargeBow.ScriptId();
  287. for (int i = 1; i <= 32; ++i) {
  288. ffc f = Screen->LoadFFC(i);
  289. if (script_id == f->Script) {return true;}
  290. }
  291. return false;
  292. }
  293.  
  294. // Get a multiplier for the x component of a direction.
  295. int DirX(int dir) {
  296. if (DIR_LEFT == dir || DIR_LEFTUP == dir || DIR_LEFTDOWN == dir) {return -1;}
  297. else if (DIR_RIGHT == dir || DIR_RIGHTUP == dir || DIR_RIGHTDOWN == dir) {return 1;}
  298. else {return 0;}
  299. }
  300.  
  301. // Get a multiplier for the y component of a direction.
  302. int DirY(int dir) {
  303. if (DIR_UP == dir || DIR_LEFTUP == dir || DIR_RIGHTUP == dir) {return -1;}
  304. else if (DIR_DOWN == dir || DIR_LEFTDOWN == dir || DIR_RIGHTDOWN == dir) {return 1;}
  305. else {return 0;}
  306. }
  307.  
  308. // Get the direction rotated n steps counter-clockwise, using 8
  309. // directions. Negatives allow for clockwise.
  310. int RotateDir8(int dir, int count) {
  311. while (count < 0) {count += 8;}
  312. while (count > 0) {
  313. if (DIR_RIGHT == dir) {dir = DIR_RIGHTUP;}
  314. else if (DIR_RIGHTUP == dir) {dir = DIR_UP;}
  315. else if (DIR_UP == dir) {dir = DIR_LEFTUP;}
  316. else if (DIR_LEFTUP == dir) {dir = DIR_LEFT;}
  317. else if (DIR_LEFT == dir) {dir = DIR_LEFTDOWN;}
  318. else if (DIR_LEFTDOWN == dir) {dir = DIR_DOWN;}
  319. else if (DIR_DOWN == dir) {dir = DIR_RIGHTDOWN;}
  320. else if (DIR_RIGHTDOWN == dir) {dir = DIR_RIGHT;}
  321. --count;
  322. }
  323. return dir;
  324. }
  325.  
  326. // Get the facing based on held buttons. If nothing is held returns Link->Dir.
  327. int LinkInputDir() {
  328. if (Link->InputUp) {
  329. if (Link->InputLeft) {return DIR_LEFTUP;}
  330. else if (Link->InputRight) {return DIR_RIGHTUP;}
  331. else {return DIR_UP;}
  332. }
  333. else if (Link->InputDown) {
  334. if (Link->InputLeft) {return DIR_LEFTDOWN;}
  335. else if (Link->InputRight) {return DIR_RIGHTDOWN;}
  336. else {return DIR_DOWN;}
  337. }
  338. else if (Link->InputLeft) {return DIR_LEFT;}
  339. else if (Link->InputRight) {return DIR_RIGHT;}
  340. else {return Link->Dir;}
  341. }
  342.  
  343. // If we can activate the given charge level, based on items and ammo.
  344. bool CanCharge(int level) {
  345. if (0 == level) {
  346. return Game->Counter[CR_ARROWS] >= CHARGEBOW_L0_AMMO
  347. && Game->Counter[CR_MAGIC] >= CHARGEBOW_L0_MAGIC;
  348. }
  349. if (1 == level) {
  350. return (!CHARGEBOW_L1_ITEM_ID || Link->Item[CHARGEBOW_L1_ITEM_ID])
  351. && Game->Counter[CR_ARROWS] >= CHARGEBOW_L1_AMMO
  352. && Game->Counter[CR_MAGIC] >= CHARGEBOW_L1_MAGIC;
  353. }
  354. if (2 == level) {
  355. return (!CHARGEBOW_L2_ITEM_ID || Link->Item[CHARGEBOW_L2_ITEM_ID])
  356. && Game->Counter[CR_ARROWS] >= CHARGEBOW_L2_AMMO
  357. && Game->Counter[CR_MAGIC] >= CHARGEBOW_L2_MAGIC;
  358. }
  359. return false;
  360. }
  361.  
  362. // The amount of time needed to reach this charge level.
  363. int ChargeTime(int level) {
  364. if (1 == level) {return CHARGEBOW_L1_CHARGE_TIME;}
  365. if (2 == level) {return CHARGEBOW_L2_CHARGE_TIME;}
  366. return 0;
  367. }
  368.  
  369. // Use up the ammo for a given charge level.
  370. void UseAmmo(int level) {
  371. if (0 == level) {
  372. Game->Counter[CR_ARROWS] -= CHARGEBOW_L0_AMMO;
  373. Game->Counter[CR_MAGIC] -= CHARGEBOW_L0_MAGIC;
  374. }
  375. if (1 == level) {
  376. Game->Counter[CR_ARROWS] -= CHARGEBOW_L1_AMMO;
  377. Game->Counter[CR_MAGIC] -= CHARGEBOW_L1_MAGIC;
  378. }
  379. if (2 == level) {
  380. Game->Counter[CR_ARROWS] -= CHARGEBOW_L2_AMMO;
  381. Game->Counter[CR_MAGIC] -= CHARGEBOW_L2_MAGIC;
  382. }
  383. }
  384.  
  385. // Play the charge sound for a given level.
  386. int PlayChargeSound(int level) {
  387. int sound = 0;
  388. if (1 == level) {sound = CHARGEBOW_L1_CHARGE_SOUND;}
  389. else if (2 == level) {sound = CHARGEBOW_L2_CHARGE_SOUND;}
  390. if (sound) {Game->PlaySound(sound);}
  391. }
  392.  
  393. // Play the shot sound for a given level.
  394. int PlayShotSound(int level) {
  395. int sound = 0;
  396. if (0 == level) {sound = CHARGEBOW_L0_SHOT_SOUND;}
  397. else if (1 == level) {sound = CHARGEBOW_L1_SHOT_SOUND;}
  398. else if (2 == level) {sound = CHARGEBOW_L2_SHOT_SOUND;}
  399. if (sound) {Game->PlaySound(sound);}
  400. }
  401.  
  402. // Get the tile base for link's graphic.
  403. int LinkTileBase() {
  404. if (CHARGEBOW_LINK_C4_ITEM && Link->Item[CHARGEBOW_LINK_C4_ITEM]) {return CHARGEBOW_LINK_C4_TILE;}
  405. else if (CHARGEBOW_LINK_C3_ITEM && Link->Item[CHARGEBOW_LINK_C3_ITEM]) {return CHARGEBOW_LINK_C3_TILE;}
  406. else if (CHARGEBOW_LINK_C2_ITEM && Link->Item[CHARGEBOW_LINK_C2_ITEM]) {return CHARGEBOW_LINK_C2_TILE;}
  407. else if (CHARGEBOW_LINK_C1_ITEM && Link->Item[CHARGEBOW_LINK_C1_ITEM]) {return CHARGEBOW_LINK_C1_TILE;}
  408. else {return CHARGEBOW_LINK_C0_TILE;}
  409. }
  410.  
  411. // Get the cset for link's graphic.
  412. int LinkCSet() {
  413. if (CHARGEBOW_LINK_C4_ITEM && Link->Item[CHARGEBOW_LINK_C4_ITEM]) {return CHARGEBOW_LINK_C4_CSET;}
  414. else if (CHARGEBOW_LINK_C3_ITEM && Link->Item[CHARGEBOW_LINK_C3_ITEM]) {return CHARGEBOW_LINK_C3_CSET;}
  415. else if (CHARGEBOW_LINK_C2_ITEM && Link->Item[CHARGEBOW_LINK_C2_ITEM]) {return CHARGEBOW_LINK_C2_CSET;}
  416. else if (CHARGEBOW_LINK_C1_ITEM && Link->Item[CHARGEBOW_LINK_C1_ITEM]) {return CHARGEBOW_LINK_C1_CSET;}
  417. else {return CHARGEBOW_LINK_C0_CSET;}
  418. }
  419.  
  420. // Make sure that Link is facing a cardinal direction.
  421. void ForceCardinal() {
  422. if (Link->Dir == DIR_LEFTUP) {Link->Dir = Choose(DIR_LEFT, DIR_UP);}
  423. if (Link->Dir == DIR_RIGHTUP) {Link->Dir = Choose(DIR_RIGHT, DIR_UP);}
  424. if (Link->Dir == DIR_LEFTDOWN) {Link->Dir = Choose(DIR_LEFT, DIR_DOWN);}
  425. if (Link->Dir == DIR_RIGHTDOWN) {Link->Dir = Choose(DIR_RIGHT, DIR_DOWN);}
  426. }
  427.  
  428. // Make an arrow.
  429. lweapon MakeArrow(int item_id, int arrow_tile, int arrow_cset, int charge_level, int element, int dir) {
  430. int dx = ChargeBow.DirX(dir);
  431. int dy = ChargeBow.DirY(dir);
  432. lweapon arrow = Screen->CreateLWeapon(LW_ARROW);
  433. arrow->Damage = ChargeBow_Damage(item_id, charge_level, element);
  434. arrow->Dir = dir;
  435. arrow->X = Link->X + dx * 16;
  436. arrow->Y = Link->Y + dy * 16;
  437. arrow->Step = ChargeBow_Speed(item_id, charge_level, element) * 100;
  438. arrow->OriginalTile = arrow_tile + dir;
  439. arrow->OriginalCSet = arrow_cset;
  440. arrow->Tile = arrow_tile + dir;
  441. arrow->CSet = arrow_cset;
  442. arrow->NumFrames = 1;
  443. return arrow;
  444. }
  445.  
  446. void run(int item_id, int arrow_tile, int arrow_cset, int fire_cset) {
  447. int i;
  448.  
  449. // Hide Link.
  450. Link->Invisible = true;
  451.  
  452. // Grab Link's graphic.
  453. int tile = ChargeBow.LinkTileBase();
  454. int cset = ChargeBow.LinkCSet();
  455.  
  456. // Check for ammo.
  457. bool have_ammo = CanCharge(0);
  458. if (!have_ammo) {tile += 40;}
  459.  
  460. // Find what button we're using.
  461. bool button_a = GetEquipmentA() == item_id;
  462.  
  463. // Charge the shot.
  464. int charge_timer = 0;
  465. int charge_level = Cond(have_ammo, 0, -1);
  466. while (true) {
  467. // If link got hurt, quit the script.
  468. if (LA_GOTHURTLAND == Link->Action || LA_GOTHURTWATER == Link->Action) {
  469. Link->Invisible = false;
  470. ForceCardinal();
  471. Quit();
  472. }
  473.  
  474. // Exit the loop if we've let go of the button.
  475. if (!Cond(button_a, Link->InputA, Link->InputB)) {break;}
  476.  
  477. // Charge if we can reach the next level.
  478. if (CanCharge(charge_level + 1)) {
  479. // Increment the charge timer.
  480. ++charge_timer;
  481.  
  482. // Check if we've passed to the next level.
  483. if (charge_timer >= ChargeTime(charge_level + 1)) {
  484. ++charge_level;
  485. PlayChargeSound(charge_level);
  486. }
  487. }
  488.  
  489. // Set Link's direction.
  490. Link->Dir = ChargeBow.LinkInputDir();
  491.  
  492. // Prevent normal commands.
  493. NoAction();
  494.  
  495. // Disable shield.
  496. Link->Action = LA_NONE;
  497. Link->Action = LA_ATTACKING;
  498.  
  499. // Draw Link.
  500. Screen->DrawTile(2, Link->X - 8, Link->Y - 8, tile + Link->Dir * 2, 2, 2,
  501. cset, -1, -1, 0, 0, 0, 0, true, OP_OPAQUE);
  502.  
  503. // Wait for the next frame.
  504. Waitframe();
  505. }
  506.  
  507. // Make Link visible again.
  508. Link->Invisible = false;
  509.  
  510. // If we don't have ammo, play the fail sound and exit.
  511. if (!have_ammo) {
  512. if (CHARGEBOW_FAIL_SOUND) {Game->PlaySound(CHARGEBOW_FAIL_SOUND);}
  513. ForceCardinal();
  514. Quit();
  515. }
  516.  
  517. lweapon arrows[3];
  518.  
  519. // Create the arrow.
  520. int dir = ChargeBow.LinkInputDir();
  521. arrows[0] = ChargeBow.MakeArrow(
  522. item_id, arrow_tile, arrow_cset, charge_level, CHARGEBOW_ELEMENT_NONE, dir);
  523.  
  524. // Triple shot for charge level 2.
  525. if (2 == charge_level) {
  526. arrows[1] = ChargeBow.MakeArrow(
  527. item_id, arrow_tile, arrow_cset, charge_level,
  528. CHARGEBOW_ELEMENT_NONE, RotateDir8(dir, 1));
  529. arrows[2] = ChargeBow.MakeArrow(
  530. item_id, arrow_tile, arrow_cset, charge_level,
  531. CHARGEBOW_ELEMENT_NONE, RotateDir8(dir, -1));
  532. }
  533.  
  534. UseAmmo(charge_level);
  535.  
  536. PlayShotSound(charge_level);
  537.  
  538. ForceCardinal();
  539.  
  540. while (true) {
  541.  
  542. bool any_valid = false;
  543.  
  544. // Loop through all arrows.
  545. for (i = 0; i < 3; ++i) {
  546. // Make sure arrow exists.
  547. lweapon arrow = arrows[i];
  548. if (!arrow->isValid()) {continue;}
  549. any_valid = true;
  550.  
  551. // Check for burning the arrow.
  552. if (LW_ARROW == arrow->ID && ComboFI(arrow->X + 8, arrow->Y + 8, CHARGEBOW_BURN_FLAG)) {
  553. // Make the new weapon in the same spot.
  554. lweapon new_arrow = Screen->CreateLWeapon(LW_FIRE);
  555. new_arrow->Damage = ChargeBow_Damage(item_id, charge_level, CHARGEBOW_ELEMENT_FIRE);
  556. new_arrow->Dir = arrow->Dir;
  557. new_arrow->X = arrow->X;
  558. new_arrow->Y = arrow->Y;
  559. new_arrow->Step = 0;
  560. new_arrow->OriginalTile = arrow_tile + CHARGEBOW_FIRE_TILE_OFFSET
  561. + arrow->Dir * CHARGEBOW_FIRE_FRAMECOUNT;
  562. new_arrow->Tile = arrow_tile + CHARGEBOW_FIRE_TILE_OFFSET
  563. + arrow->Dir * CHARGEBOW_FIRE_FRAMECOUNT;
  564. new_arrow->OriginalCSet = fire_cset;
  565. new_arrow->CSet = fire_cset;
  566. new_arrow->NumFrames = CHARGEBOW_FIRE_FRAMECOUNT;
  567. new_arrow->ASpeed = CHARGEBOW_ARROW_ASPEED;
  568.  
  569. // Start tracking the new weapon instead.
  570. Remove(arrow);
  571. arrow = new_arrow;
  572. arrows[i] = arrow;
  573.  
  574. // Play the burn sound.
  575. if (CHARGEBOW_BURN_SOUND) {Game->PlaySound(CHARGEBOW_BURN_SOUND);}
  576. }
  577.  
  578. // If the arrow is a fire arrow, move it manually, since we don't want it to stop.
  579. if (LW_FIRE == arrow->ID) {
  580. int speed = ChargeBow_Speed(item_id, charge_level, CHARGEBOW_ELEMENT_FIRE);
  581. arrow->X += ChargeBow.DirX(arrow->Dir) * speed;
  582. arrow->Y += ChargeBow.DirY(arrow->Dir) * speed;
  583. arrow->DeadState = WDS_ALIVE;
  584.  
  585. // Get rid of if it hits the edge of the screen.
  586. if (arrow->X < 0 || 256 <= arrow->X || arrow->Y < 0 || 176 <= arrow->Y) {Remove(arrow);}
  587. }
  588.  
  589.  
  590. }
  591.  
  592. // Quit if there's no arrows left.
  593. if (!any_valid) {Quit();}
  594.  
  595. Waitframe();
  596. }
  597. }
  598. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement