Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.51 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. // This is the speed the arrow flies at. For reference, Link's movement is
  202. // 1.5. Defaults to the strongest bow that Link has.
  203. int ChargeBow_Speed(int item_id, int charge_level, int element) {
  204. int bow_id = -1;
  205. int bow_level = -1;
  206. itemdata data;
  207.  
  208. // Find the highest level bow item the player has.
  209. for (int i = 0; i < 256; ++i) {
  210. data = Game->LoadItemData(i);
  211. if (!Link->Item[i]) {continue;}
  212. if (IC_BOW != data->Family) {continue;}
  213. if (data->Level > bow_level) {
  214. bow_id = i;
  215. bow_level = data->Level;
  216. }
  217. }
  218.  
  219. // Grab the speed from that bow.
  220. data = Game->LoadItemData(bow_id);
  221. int speed = data->Power;
  222.  
  223. // Add speed for each charge level.
  224. speed += charge_level * CHARGEBOW_ARROW_CHARGE_SPEED;
  225.  
  226. return speed;
  227. }
  228.  
  229. ////////////////////////////////////////////////////////////////
  230. // Main Script
  231.  
  232. const int CHARGEBOW_ELEMENT_NONE = 0;
  233. const int CHARGEBOW_ELEMENT_FIRE = 1;
  234.  
  235. item script ChargeBow_Use {
  236. void run(int item_id, int tile, int cset, int fire_cset) {
  237. int i; ffc f;
  238.  
  239. // Cancel out if there's already an arrow on screen.
  240. if (ChargeBow.IsActive()) {return;}
  241.  
  242. // Check to see that we pressed the button instead of held it.
  243. if ((GetEquipmentA() == item_id && !Link->PressA)
  244. || (GetEquipmentB() == item_id && !Link->PressB)) {
  245. return;
  246. }
  247.  
  248. // Look for a free FFC slot.
  249. for (i = 1; i <= 32; ++i) {
  250. f = Screen->LoadFFC(i);
  251. if (0 == f->Data && 0 == f->Script) {break;}
  252. }
  253. // If we didn't find a free ffc, quit.
  254. if (33 == i) {return;}
  255.  
  256. // Start up the ffc script.
  257. f->Script = ChargeBow.ScriptId();
  258. f->InitD[0] = item_id;
  259. f->InitD[1] = tile;
  260. f->InitD[2] = cset;
  261. f->InitD[3] = fire_cset;
  262.  
  263. // Play the start sound.
  264. if (CHARGEBOW_START_SOUND) {Game->PlaySound(CHARGEBOW_START_SOUND);}
  265. }
  266. }
  267.  
  268. ffc script ChargeBow {
  269.  
  270. // Get the script number for this script.
  271. int ScriptId() {
  272. int name[] = "ChargeBow";
  273. return Game->GetFFCScript(name);
  274. }
  275.  
  276. // If the chargebow ffc is currently active.
  277. bool IsActive() {
  278. int script_id = ChargeBow.ScriptId();
  279. for (int i = 1; i <= 32; ++i) {
  280. ffc f = Screen->LoadFFC(i);
  281. if (script_id == f->Script) {return true;}
  282. }
  283. return false;
  284. }
  285.  
  286. // Get a multiplier for the x component of a direction.
  287. int DirX(int dir) {
  288. if (DIR_LEFT == dir || DIR_LEFTUP == dir || DIR_LEFTDOWN == dir) {return -1;}
  289. else if (DIR_RIGHT == dir || DIR_RIGHTUP == dir || DIR_RIGHTDOWN == dir) {return 1;}
  290. else {return 0;}
  291. }
  292.  
  293. // Get a multiplier for the y component of a direction.
  294. int DirY(int dir) {
  295. if (DIR_UP == dir || DIR_LEFTUP == dir || DIR_RIGHTUP == dir) {return -1;}
  296. else if (DIR_DOWN == dir || DIR_LEFTDOWN == dir || DIR_RIGHTDOWN == dir) {return 1;}
  297. else {return 0;}
  298. }
  299.  
  300. // Get the direction rotated n steps counter-clockwise, using 8
  301. // directions. Negatives allow for clockwise.
  302. int RotateDir8(int dir, int count) {
  303. while (count < 0) {count += 8;}
  304. while (count > 0) {
  305. if (DIR_RIGHT == dir) {dir = DIR_RIGHTUP;}
  306. else if (DIR_RIGHTUP == dir) {dir = DIR_UP;}
  307. else if (DIR_UP == dir) {dir = DIR_LEFTUP;}
  308. else if (DIR_LEFTUP == dir) {dir = DIR_LEFT;}
  309. else if (DIR_LEFT == dir) {dir = DIR_LEFTDOWN;}
  310. else if (DIR_LEFTDOWN == dir) {dir = DIR_DOWN;}
  311. else if (DIR_DOWN == dir) {dir = DIR_RIGHTDOWN;}
  312. else if (DIR_RIGHTDOWN == dir) {dir = DIR_RIGHT;}
  313. --count;
  314. }
  315. return dir;
  316. }
  317.  
  318. // Get the facing based on held buttons. If nothing is held returns Link->Dir.
  319. int LinkInputDir() {
  320. if (Link->InputUp) {
  321. if (Link->InputLeft) {return DIR_LEFTUP;}
  322. else if (Link->InputRight) {return DIR_RIGHTUP;}
  323. else {return DIR_UP;}
  324. }
  325. else if (Link->InputDown) {
  326. if (Link->InputLeft) {return DIR_LEFTDOWN;}
  327. else if (Link->InputRight) {return DIR_RIGHTDOWN;}
  328. else {return DIR_DOWN;}
  329. }
  330. else if (Link->InputLeft) {return DIR_LEFT;}
  331. else if (Link->InputRight) {return DIR_RIGHT;}
  332. else {return Link->Dir;}
  333. }
  334.  
  335. // If we can activate the given charge level, based on items and ammo.
  336. bool CanCharge(int level) {
  337. if (0 == level) {
  338. return Game->Counter[CR_ARROWS] >= CHARGEBOW_L0_AMMO
  339. && Game->Counter[CR_MAGIC] >= CHARGEBOW_L0_MAGIC;
  340. }
  341. if (1 == level) {
  342. return (!CHARGEBOW_L1_ITEM_ID || Link->Item[CHARGEBOW_L1_ITEM_ID])
  343. && Game->Counter[CR_ARROWS] >= CHARGEBOW_L1_AMMO
  344. && Game->Counter[CR_MAGIC] >= CHARGEBOW_L1_MAGIC;
  345. }
  346. if (2 == level) {
  347. return (!CHARGEBOW_L2_ITEM_ID || Link->Item[CHARGEBOW_L2_ITEM_ID])
  348. && Game->Counter[CR_ARROWS] >= CHARGEBOW_L2_AMMO
  349. && Game->Counter[CR_MAGIC] >= CHARGEBOW_L2_MAGIC;
  350. }
  351. return false;
  352. }
  353.  
  354. // The amount of time needed to reach this charge level.
  355. int ChargeTime(int level) {
  356. if (1 == level) {return CHARGEBOW_L1_CHARGE_TIME;}
  357. if (2 == level) {return CHARGEBOW_L2_CHARGE_TIME;}
  358. return 0;
  359. }
  360.  
  361. // Use up the ammo for a given charge level.
  362. void UseAmmo(int level) {
  363. if (0 == level) {
  364. Game->Counter[CR_ARROWS] -= CHARGEBOW_L0_AMMO;
  365. Game->Counter[CR_MAGIC] -= CHARGEBOW_L0_MAGIC;
  366. }
  367. if (1 == level) {
  368. Game->Counter[CR_ARROWS] -= CHARGEBOW_L1_AMMO;
  369. Game->Counter[CR_MAGIC] -= CHARGEBOW_L1_MAGIC;
  370. }
  371. if (2 == level) {
  372. Game->Counter[CR_ARROWS] -= CHARGEBOW_L2_AMMO;
  373. Game->Counter[CR_MAGIC] -= CHARGEBOW_L2_MAGIC;
  374. }
  375. }
  376.  
  377. // Play the charge sound for a given level.
  378. int PlayChargeSound(int level) {
  379. int sound = 0;
  380. if (1 == level) {sound = CHARGEBOW_L1_CHARGE_SOUND;}
  381. else if (2 == level) {sound = CHARGEBOW_L2_CHARGE_SOUND;}
  382. if (sound) {Game->PlaySound(sound);}
  383. }
  384.  
  385. // Play the shot sound for a given level.
  386. int PlayShotSound(int level) {
  387. int sound = 0;
  388. if (0 == level) {sound = CHARGEBOW_L0_SHOT_SOUND;}
  389. else if (1 == level) {sound = CHARGEBOW_L1_SHOT_SOUND;}
  390. else if (2 == level) {sound = CHARGEBOW_L2_SHOT_SOUND;}
  391. if (sound) {Game->PlaySound(sound);}
  392. }
  393.  
  394. // Get the tile base for link's graphic.
  395. int LinkTileBase() {
  396. if (CHARGEBOW_LINK_C4_ITEM && Link->Item[CHARGEBOW_LINK_C4_ITEM]) {return CHARGEBOW_LINK_C4_TILE;}
  397. else if (CHARGEBOW_LINK_C3_ITEM && Link->Item[CHARGEBOW_LINK_C3_ITEM]) {return CHARGEBOW_LINK_C3_TILE;}
  398. else if (CHARGEBOW_LINK_C2_ITEM && Link->Item[CHARGEBOW_LINK_C2_ITEM]) {return CHARGEBOW_LINK_C2_TILE;}
  399. else if (CHARGEBOW_LINK_C1_ITEM && Link->Item[CHARGEBOW_LINK_C1_ITEM]) {return CHARGEBOW_LINK_C1_TILE;}
  400. else {return CHARGEBOW_LINK_C0_TILE;}
  401. }
  402.  
  403. // Get the cset for link's graphic.
  404. int LinkCSet() {
  405. if (CHARGEBOW_LINK_C4_ITEM && Link->Item[CHARGEBOW_LINK_C4_ITEM]) {return CHARGEBOW_LINK_C4_CSET;}
  406. else if (CHARGEBOW_LINK_C3_ITEM && Link->Item[CHARGEBOW_LINK_C3_ITEM]) {return CHARGEBOW_LINK_C3_CSET;}
  407. else if (CHARGEBOW_LINK_C2_ITEM && Link->Item[CHARGEBOW_LINK_C2_ITEM]) {return CHARGEBOW_LINK_C2_CSET;}
  408. else if (CHARGEBOW_LINK_C1_ITEM && Link->Item[CHARGEBOW_LINK_C1_ITEM]) {return CHARGEBOW_LINK_C1_CSET;}
  409. else {return CHARGEBOW_LINK_C0_CSET;}
  410. }
  411.  
  412. // Make sure that Link is facing a cardinal direction.
  413. void ForceCardinal() {
  414. if (Link->Dir == DIR_LEFTUP) {Link->Dir = Choose(DIR_LEFT, DIR_UP);}
  415. if (Link->Dir == DIR_RIGHTUP) {Link->Dir = Choose(DIR_RIGHT, DIR_UP);}
  416. if (Link->Dir == DIR_LEFTDOWN) {Link->Dir = Choose(DIR_LEFT, DIR_DOWN);}
  417. if (Link->Dir == DIR_RIGHTDOWN) {Link->Dir = Choose(DIR_RIGHT, DIR_DOWN);}
  418. }
  419.  
  420. // Make an arrow.
  421. lweapon MakeArrow(int item_id, int arrow_tile, int arrow_cset, int charge_level, int element, int dir) {
  422. int dx = ChargeBow.DirX(dir);
  423. int dy = ChargeBow.DirY(dir);
  424. lweapon arrow = Screen->CreateLWeapon(LW_ARROW);
  425. arrow->Damage = ChargeBow_Damage(item_id, charge_level, element);
  426. arrow->Dir = dir;
  427. arrow->X = Link->X + dx * 16;
  428. arrow->Y = Link->Y + dy * 16;
  429. arrow->Step = ChargeBow_Speed(item_id, charge_level, element) * 100;
  430. arrow->OriginalTile = arrow_tile + dir;
  431. arrow->OriginalCSet = arrow_cset;
  432. arrow->Tile = arrow_tile + dir;
  433. arrow->CSet = arrow_cset;
  434. arrow->NumFrames = 1;
  435. return arrow;
  436. }
  437.  
  438. void run(int item_id, int arrow_tile, int arrow_cset, int fire_cset) {
  439. int i;
  440.  
  441. // Hide Link.
  442. Link->Invisible = true;
  443.  
  444. // Grab Link's graphic.
  445. int tile = ChargeBow.LinkTileBase();
  446. int cset = ChargeBow.LinkCSet();
  447.  
  448. // Check for ammo.
  449. bool have_ammo = CanCharge(0);
  450. if (!have_ammo) {tile += 40;}
  451.  
  452. // Find what button we're using.
  453. bool button_a = GetEquipmentA() == item_id;
  454.  
  455. // Charge the shot.
  456. int charge_timer = 0;
  457. int charge_level = Cond(have_ammo, 0, -1);
  458. while (true) {
  459. // If link got hurt, quit the script.
  460. if (LA_GOTHURTLAND == Link->Action || LA_GOTHURTWATER == Link->Action) {
  461. Link->Invisible = false;
  462. ForceCardinal();
  463. Quit();
  464. }
  465.  
  466. // Exit the loop if we've let go of the button.
  467. if (!Cond(button_a, Link->InputA, Link->InputB)) {break;}
  468.  
  469. // Charge if we can reach the next level.
  470. if (CanCharge(charge_level + 1)) {
  471. // Increment the charge timer.
  472. ++charge_timer;
  473.  
  474. // Check if we've passed to the next level.
  475. if (charge_timer >= ChargeTime(charge_level + 1)) {
  476. ++charge_level;
  477. PlayChargeSound(charge_level);
  478. }
  479. }
  480.  
  481. // Set Link's direction.
  482. Link->Dir = ChargeBow.LinkInputDir();
  483.  
  484. // Prevent normal commands.
  485. NoAction();
  486.  
  487. // Disable shield.
  488. Link->Action = LA_NONE;
  489. Link->Action = LA_ATTACKING;
  490.  
  491. // Draw Link.
  492. Screen->DrawTile(2, Link->X - 8, Link->Y - 8, tile + Link->Dir * 2, 2, 2,
  493. cset, -1, -1, 0, 0, 0, 0, true, OP_OPAQUE);
  494.  
  495. // Wait for the next frame.
  496. Waitframe();
  497. }
  498.  
  499. // Make Link visible again.
  500. Link->Invisible = false;
  501.  
  502. // If we don't have ammo, play the fail sound and exit.
  503. if (!have_ammo) {
  504. if (CHARGEBOW_FAIL_SOUND) {Game->PlaySound(CHARGEBOW_FAIL_SOUND);}
  505. ForceCardinal();
  506. Quit();
  507. }
  508.  
  509. lweapon arrows[3];
  510.  
  511. // Create the arrow.
  512. int dir = ChargeBow.LinkInputDir();
  513. arrows[0] = ChargeBow.MakeArrow(
  514. item_id, arrow_tile, arrow_cset, charge_level, CHARGEBOW_ELEMENT_NONE, dir);
  515.  
  516. // Triple shot for charge level 2.
  517. if (2 == charge_level) {
  518. arrows[1] = ChargeBow.MakeArrow(
  519. item_id, arrow_tile, arrow_cset, charge_level,
  520. CHARGEBOW_ELEMENT_NONE, RotateDir8(dir, 1));
  521. arrows[2] = ChargeBow.MakeArrow(
  522. item_id, arrow_tile, arrow_cset, charge_level,
  523. CHARGEBOW_ELEMENT_NONE, RotateDir8(dir, -1));
  524. }
  525.  
  526. UseAmmo(charge_level);
  527.  
  528. PlayShotSound(charge_level);
  529.  
  530. ForceCardinal();
  531.  
  532. while (true) {
  533.  
  534. bool any_valid = false;
  535.  
  536. // Loop through all arrows.
  537. for (i = 0; i < 3; ++i) {
  538. // Make sure arrow exists.
  539. lweapon arrow = arrows[i];
  540. if (!arrow->isValid()) {continue;}
  541. any_valid = true;
  542.  
  543. // Check for burning the arrow.
  544. if (LW_ARROW == arrow->ID && ComboFI(arrow->X + 8, arrow->Y + 8, CHARGEBOW_BURN_FLAG)) {
  545. // Make the new weapon in the same spot.
  546. lweapon new_arrow = Screen->CreateLWeapon(LW_FIRE);
  547. new_arrow->Damage = ChargeBow_Damage(item_id, charge_level, CHARGEBOW_ELEMENT_FIRE);
  548. new_arrow->Dir = arrow->Dir;
  549. new_arrow->X = arrow->X;
  550. new_arrow->Y = arrow->Y;
  551. new_arrow->Step = 0;
  552. new_arrow->OriginalTile = arrow_tile + CHARGEBOW_FIRE_TILE_OFFSET
  553. + arrow->Dir * CHARGEBOW_FIRE_FRAMECOUNT;
  554. new_arrow->Tile = arrow_tile + CHARGEBOW_FIRE_TILE_OFFSET
  555. + arrow->Dir * CHARGEBOW_FIRE_FRAMECOUNT;
  556. new_arrow->OriginalCSet = fire_cset;
  557. new_arrow->CSet = fire_cset;
  558. new_arrow->NumFrames = CHARGEBOW_FIRE_FRAMECOUNT;
  559. new_arrow->ASpeed = CHARGEBOW_ARROW_ASPEED;
  560.  
  561. // Start tracking the new weapon instead.
  562. Remove(arrow);
  563. arrow = new_arrow;
  564. arrows[i] = arrow;
  565.  
  566. // Play the burn sound.
  567. if (CHARGEBOW_BURN_SOUND) {Game->PlaySound(CHARGEBOW_BURN_SOUND);}
  568. }
  569.  
  570. // If the arrow is a fire arrow, move it manually, since we don't want it to stop.
  571. if (LW_FIRE == arrow->ID) {
  572. int speed = ChargeBow_Speed(item_id, charge_level, CHARGEBOW_ELEMENT_FIRE);
  573. arrow->X += ChargeBow.DirX(arrow->Dir) * speed;
  574. arrow->Y += ChargeBow.DirY(arrow->Dir) * speed;
  575. arrow->DeadState = WDS_ALIVE;
  576.  
  577. // Get rid of if it hits the edge of the screen.
  578. if (arrow->X < 0 || 256 <= arrow->X || arrow->Y < 0 || 176 <= arrow->Y) {Remove(arrow);}
  579. }
  580.  
  581.  
  582. }
  583.  
  584. // Quit if there's no arrows left.
  585. if (!any_valid) {Quit();}
  586.  
  587. Waitframe();
  588. }
  589. }
  590. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement