Advertisement
Guest User

Untitled

a guest
Jun 28th, 2011
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.12 KB | None | 0 0
  1. // Emacs style mode select -*- C++ -*-
  2. //-----------------------------------------------------------------------------
  3. //
  4. // Copyright(C) 1993-1996 Id Software, Inc.
  5. // Copyright(C) 2005 Simon Howard
  6. // Modifications(C) 2011 Whoo
  7. //
  8. // This program is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU General Public License
  10. // as published by the Free Software Foundation; either version 2
  11. // of the License, or (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  21. // 02111-1307, USA.
  22. //
  23. // DESCRIPTION:
  24. // Weapon sprite animation, weapon objects.
  25. // Action functions for weapons.
  26. //
  27. //-----------------------------------------------------------------------------
  28.  
  29.  
  30. #include "doomdef.h"
  31. #include "d_event.h"
  32.  
  33. #include "deh_misc.h"
  34.  
  35. #include "m_random.h"
  36. #include "p_local.h"
  37. #include "s_sound.h"
  38.  
  39. // State.
  40. #include "doomstat.h"
  41.  
  42. // Data.
  43. #include "sounds.h"
  44.  
  45. #include "p_pspr.h"
  46.  
  47. #define LOWERSPEED FRACUNIT*6
  48. #define RAISESPEED FRACUNIT*6
  49.  
  50. #define WEAPONBOTTOM 128*FRACUNIT
  51. #define WEAPONTOP 32*FRACUNIT
  52.  
  53.  
  54.  
  55. //
  56. // P_SetPsprite
  57. //
  58. void
  59. P_SetPsprite
  60. ( player_t* player,
  61. int position,
  62. statenum_t stnum )
  63. {
  64. pspdef_t* psp;
  65. state_t* state;
  66.  
  67. psp = &player->psprites[position];
  68.  
  69. do
  70. {
  71. if (!stnum)
  72. {
  73. // object removed itself
  74. psp->state = NULL;
  75. break;
  76. }
  77.  
  78. state = &states[stnum];
  79. psp->state = state;
  80. psp->tics = state->tics; // could be 0
  81.  
  82. if (state->misc1)
  83. {
  84. // coordinate set
  85. psp->sx = state->misc1 << FRACBITS;
  86. psp->sy = state->misc2 << FRACBITS;
  87. }
  88.  
  89. // Call action routine.
  90. // Modified handling.
  91. if (state->action.acp2)
  92. {
  93. state->action.acp2(player, psp);
  94. if (!psp->state)
  95. break;
  96. }
  97.  
  98. stnum = psp->state->nextstate;
  99.  
  100. } while (!psp->tics);
  101. // an initial state of 0 could cycle through
  102. }
  103.  
  104.  
  105.  
  106. //
  107. // P_CalcSwing
  108. //
  109. fixed_t swingx;
  110. fixed_t swingy;
  111.  
  112. void P_CalcSwing (player_t* player)
  113. {
  114. fixed_t swing;
  115. int angle;
  116.  
  117. // OPTIMIZE: tablify this.
  118. // A LUT would allow for different modes,
  119. // and add flexibility.
  120.  
  121. swing = player->bob;
  122.  
  123. angle = (FINEANGLES/70*leveltime)&FINEMASK;
  124. swingx = FixedMul ( swing, finesine[angle]);
  125.  
  126. angle = (FINEANGLES/70*leveltime+FINEANGLES/2)&FINEMASK;
  127. swingy = -FixedMul ( swingx, finesine[angle]);
  128. }
  129.  
  130.  
  131.  
  132. //
  133. // P_BringUpWeapon
  134. // Starts bringing the pending weapon up
  135. // from the bottom of the screen.
  136. // Uses player
  137. //
  138. void P_BringUpWeapon (player_t* player)
  139. {
  140. statenum_t newstate;
  141.  
  142. if (player->pendingweapon == wp_nochange)
  143. player->pendingweapon = player->readyweapon;
  144.  
  145. if (player->pendingweapon == wp_chainsaw)
  146. S_StartSound (player->mo, sfx_sawup);
  147.  
  148. newstate = weaponinfo[player->pendingweapon].upstate;
  149.  
  150. player->pendingweapon = wp_nochange;
  151. player->psprites[ps_weapon].sy = WEAPONBOTTOM;
  152.  
  153. P_SetPsprite (player, ps_weapon, newstate);
  154. }
  155.  
  156. //
  157. // P_CheckAmmo
  158. // Returns true if there is enough ammo to shoot.
  159. // If not, selects the next weapon to use.
  160. //
  161. boolean P_CheckAmmo (player_t* player)
  162. {
  163. ammotype_t ammo;
  164. int count;
  165.  
  166. ammo = weaponinfo[player->readyweapon].ammo;
  167.  
  168. // Minimal amount for one shot varies.
  169. if (player->readyweapon == wp_bfg)
  170. count = deh_bfg_cells_per_shot;
  171. else if (player->readyweapon == wp_supershotgun)
  172. count = 2; // Double barrel.
  173. else
  174. count = 1; // Regular.
  175.  
  176. // Some do not need ammunition anyway.
  177. // Return if current ammunition sufficient.
  178. if (ammo == am_noammo || player->ammo[ammo] >= count)
  179. return true;
  180.  
  181. // Out of ammo, pick a weapon to change to.
  182. // Preferences are set here.
  183. do
  184. {
  185. if (player->weaponowned[wp_plasma]
  186. && player->ammo[am_cell]
  187. && (gamemode != shareware) )
  188. {
  189. player->pendingweapon = wp_plasma;
  190. }
  191. else if (player->weaponowned[wp_supershotgun]
  192. && player->ammo[am_shell]>2
  193. && (gamemode == commercial) )
  194. {
  195. player->pendingweapon = wp_supershotgun;
  196. }
  197. else if (player->weaponowned[wp_chaingun]
  198. && player->ammo[am_clip])
  199. {
  200. player->pendingweapon = wp_chaingun;
  201. }
  202. else if (player->weaponowned[wp_shotgun]
  203. && player->ammo[am_shell])
  204. {
  205. player->pendingweapon = wp_shotgun;
  206. }
  207. else if (player->ammo[am_clip])
  208. {
  209. player->pendingweapon = wp_pistol;
  210. }
  211. else if (player->weaponowned[wp_chainsaw])
  212. {
  213. player->pendingweapon = wp_chainsaw;
  214. }
  215. else if (player->weaponowned[wp_missile]
  216. && player->ammo[am_misl])
  217. {
  218. player->pendingweapon = wp_missile;
  219. }
  220. else if (player->weaponowned[wp_bfg]
  221. && player->ammo[am_cell]>40
  222. && (gamemode != shareware) )
  223. {
  224. player->pendingweapon = wp_bfg;
  225. }
  226. else
  227. {
  228. // If everything fails.
  229. player->pendingweapon = wp_fist;
  230. }
  231.  
  232. } while (player->pendingweapon == wp_nochange);
  233.  
  234. // Now set appropriate weapon overlay.
  235. P_SetPsprite (player,
  236. ps_weapon,
  237. weaponinfo[player->readyweapon].downstate);
  238.  
  239. return false;
  240. }
  241.  
  242.  
  243. //
  244. // P_FireWeapon.
  245. //
  246. void P_FireWeapon (player_t* player)
  247. {
  248. statenum_t newstate;
  249.  
  250. if (!P_CheckAmmo (player))
  251. return;
  252.  
  253. P_SetMobjState (player->mo, S_PLAY_ATK1);
  254. newstate = weaponinfo[player->readyweapon].atkstate;
  255. P_SetPsprite (player, ps_weapon, newstate);
  256. P_NoiseAlert (player->mo, player->mo);
  257. }
  258.  
  259.  
  260.  
  261. //
  262. // P_DropWeapon
  263. // Player died, so put the weapon away.
  264. //
  265. void P_DropWeapon (player_t* player)
  266. {
  267. P_SetPsprite (player,
  268. ps_weapon,
  269. weaponinfo[player->readyweapon].downstate);
  270. }
  271.  
  272.  
  273.  
  274. //
  275. // A_WeaponReady
  276. // The player can fire the weapon
  277. // or change to another weapon at this time.
  278. // Follows after getting weapon up,
  279. // or after previous attack/fire sequence.
  280. //
  281. void
  282. A_WeaponReady
  283. ( player_t* player,
  284. pspdef_t* psp )
  285. {
  286. statenum_t newstate;
  287. int angle;
  288.  
  289. // get out of attack state
  290. if (player->mo->state == &states[S_PLAY_ATK1]
  291. || player->mo->state == &states[S_PLAY_ATK2] )
  292. {
  293. P_SetMobjState (player->mo, S_PLAY);
  294. }
  295.  
  296. if (player->readyweapon == wp_chainsaw
  297. && psp->state == &states[S_SAW])
  298. {
  299. S_StartSound (player->mo, sfx_sawidl);
  300. }
  301.  
  302. // check for change
  303. // if player is dead, put the weapon away
  304. if (player->pendingweapon != wp_nochange || !player->health)
  305. {
  306. // change weapon
  307. // (pending weapon should allready be validated)
  308. newstate = weaponinfo[player->readyweapon].downstate;
  309. P_SetPsprite (player, ps_weapon, newstate);
  310. return;
  311. }
  312.  
  313. // check for fire
  314. // the missile launcher and bfg do not auto fire
  315. if (player->cmd.buttons & BT_ATTACK)
  316. {
  317. if ( !player->attackdown
  318. || (player->readyweapon != wp_missile
  319. && player->readyweapon != wp_bfg) )
  320. {
  321. player->attackdown = true;
  322. P_FireWeapon (player);
  323. return;
  324. }
  325. }
  326. else
  327. player->attackdown = false;
  328.  
  329. // bob the weapon based on movement speed
  330. angle = (128*leveltime)&FINEMASK;
  331. psp->sx = FRACUNIT + FixedMul (player->bob, finecosine[angle]);
  332. angle &= FINEANGLES/2-1;
  333.  
  334. // Below is the original code for the \/ shaped bob - Whoo
  335. // psp->sy = WEAPONTOP + FixedMul (player->bob, finesine[angle]);
  336.  
  337.  
  338. // This modification changes the vertical angle of the bob, but if the sprites are
  339. // not vertically long enough you will see the cut off portion of the bottom. - Whoo
  340. psp->sy = WEAPONTOP - FixedMul (player->bob, finesine[angle]);
  341.  
  342. }
  343.  
  344.  
  345.  
  346. //
  347. // A_ReFire
  348. // The player can re-fire the weapon
  349. // without lowering it entirely.
  350. //
  351. void A_ReFire
  352. ( player_t* player,
  353. pspdef_t* psp )
  354. {
  355.  
  356. // check for fire
  357. // (if a weaponchange is pending, let it go through instead)
  358. if ( (player->cmd.buttons & BT_ATTACK)
  359. && player->pendingweapon == wp_nochange
  360. && player->health)
  361. {
  362. player->refire++;
  363. P_FireWeapon (player);
  364. }
  365. else
  366. {
  367. player->refire = 0;
  368. P_CheckAmmo (player);
  369. }
  370. }
  371.  
  372.  
  373. void
  374. A_CheckReload
  375. ( player_t* player,
  376. pspdef_t* psp )
  377. {
  378. P_CheckAmmo (player);
  379. #if 0
  380. if (player->ammo[am_shell]<2)
  381. P_SetPsprite (player, ps_weapon, S_DSNR1);
  382. #endif
  383. }
  384.  
  385.  
  386.  
  387. //
  388. // A_Lower
  389. // Lowers current weapon,
  390. // and changes weapon at bottom.
  391. //
  392. void
  393. A_Lower
  394. ( player_t* player,
  395. pspdef_t* psp )
  396. {
  397. psp->sy += LOWERSPEED;
  398.  
  399. // Is already down.
  400. if (psp->sy < WEAPONBOTTOM )
  401. return;
  402.  
  403. // Player is dead.
  404. if (player->playerstate == PST_DEAD)
  405. {
  406. psp->sy = WEAPONBOTTOM;
  407.  
  408. // don't bring weapon back up
  409. return;
  410. }
  411.  
  412. // The old weapon has been lowered off the screen,
  413. // so change the weapon and start raising it
  414. if (!player->health)
  415. {
  416. // Player is dead, so keep the weapon off screen.
  417. P_SetPsprite (player, ps_weapon, S_NULL);
  418. return;
  419. }
  420.  
  421. player->readyweapon = player->pendingweapon;
  422.  
  423. P_BringUpWeapon (player);
  424. }
  425.  
  426.  
  427. //
  428. // A_Raise
  429. //
  430. void
  431. A_Raise
  432. ( player_t* player,
  433. pspdef_t* psp )
  434. {
  435. statenum_t newstate;
  436.  
  437. psp->sy -= RAISESPEED;
  438.  
  439. if (psp->sy > WEAPONTOP )
  440. return;
  441.  
  442. psp->sy = WEAPONTOP;
  443.  
  444. // The weapon has been raised all the way,
  445. // so change to the ready state.
  446. newstate = weaponinfo[player->readyweapon].readystate;
  447.  
  448. P_SetPsprite (player, ps_weapon, newstate);
  449. }
  450.  
  451.  
  452.  
  453. //
  454. // A_GunFlash
  455. //
  456. void
  457. A_GunFlash
  458. ( player_t* player,
  459. pspdef_t* psp )
  460. {
  461. P_SetMobjState (player->mo, S_PLAY_ATK2);
  462. P_SetPsprite (player,ps_flash,weaponinfo[player->readyweapon].flashstate);
  463. }
  464.  
  465.  
  466.  
  467. //
  468. // WEAPON ATTACKS
  469. //
  470.  
  471.  
  472. //
  473. // A_Punch
  474. //
  475. void
  476. A_Punch
  477. ( player_t* player,
  478. pspdef_t* psp )
  479. {
  480. angle_t angle;
  481. int damage;
  482. int slope;
  483.  
  484. damage = (P_Random ()%10+1)<<1;
  485.  
  486. if (player->powers[pw_strength])
  487. damage *= 10;
  488.  
  489. angle = player->mo->angle;
  490. angle += (P_Random()-P_Random())<<18;
  491. slope = P_AimLineAttack (player->mo, angle, MELEERANGE);
  492. P_LineAttack (player->mo, angle, MELEERANGE, slope, damage);
  493.  
  494. // turn to face target
  495. if (linetarget)
  496. {
  497. S_StartSound (player->mo, sfx_punch);
  498. player->mo->angle = R_PointToAngle2 (player->mo->x,
  499. player->mo->y,
  500. linetarget->x,
  501. linetarget->y);
  502. }
  503. }
  504.  
  505.  
  506. //
  507. // A_Saw
  508. //
  509. void
  510. A_Saw
  511. ( player_t* player,
  512. pspdef_t* psp )
  513. {
  514. angle_t angle;
  515. int damage;
  516. int slope;
  517.  
  518. damage = 2*(P_Random ()%10+1);
  519. angle = player->mo->angle;
  520. angle += (P_Random()-P_Random())<<18;
  521.  
  522. // use meleerange + 1 se the puff doesn't skip the flash
  523. slope = P_AimLineAttack (player->mo, angle, MELEERANGE+1);
  524. P_LineAttack (player->mo, angle, MELEERANGE+1, slope, damage);
  525.  
  526. if (!linetarget)
  527. {
  528. S_StartSound (player->mo, sfx_sawful);
  529. return;
  530. }
  531. S_StartSound (player->mo, sfx_sawhit);
  532.  
  533. // turn to face target
  534. angle = R_PointToAngle2 (player->mo->x, player->mo->y,
  535. linetarget->x, linetarget->y);
  536. if (angle - player->mo->angle > ANG180)
  537. {
  538. if ((signed int) (angle - player->mo->angle) < -ANG90/20)
  539. player->mo->angle = angle + ANG90/21;
  540. else
  541. player->mo->angle -= ANG90/20;
  542. }
  543. else
  544. {
  545. if (angle - player->mo->angle > ANG90/20)
  546. player->mo->angle = angle - ANG90/21;
  547. else
  548. player->mo->angle += ANG90/20;
  549. }
  550. player->mo->flags |= MF_JUSTATTACKED;
  551. }
  552.  
  553. // Doom does not check the bounds of the ammo array. As a result,
  554. // it is possible to use an ammo type > 4 that overflows into the
  555. // maxammo array and affects that instead. Through dehacked, for
  556. // example, it is possible to make a weapon that decreases the max
  557. // number of ammo for another weapon. Emulate this.
  558.  
  559. static void DecreaseAmmo(player_t *player, int ammonum, int amount)
  560. {
  561. if (ammonum < NUMAMMO)
  562. {
  563. player->ammo[ammonum] -= amount;
  564. }
  565. else
  566. {
  567. player->maxammo[ammonum - NUMAMMO] -= amount;
  568. }
  569. }
  570.  
  571.  
  572. //
  573. // A_FireMissile
  574. //
  575. void
  576. A_FireMissile
  577. ( player_t* player,
  578. pspdef_t* psp )
  579. {
  580. DecreaseAmmo(player, weaponinfo[player->readyweapon].ammo, 1);
  581. P_SpawnPlayerMissile (player->mo, MT_ROCKET);
  582. }
  583.  
  584.  
  585. //
  586. // A_FireBFG
  587. //
  588. void
  589. A_FireBFG
  590. ( player_t* player,
  591. pspdef_t* psp )
  592. {
  593. DecreaseAmmo(player, weaponinfo[player->readyweapon].ammo,
  594. deh_bfg_cells_per_shot);
  595. P_SpawnPlayerMissile (player->mo, MT_BFG);
  596. }
  597.  
  598.  
  599.  
  600. //
  601. // A_FirePlasma
  602. //
  603. void
  604. A_FirePlasma
  605. ( player_t* player,
  606. pspdef_t* psp )
  607. {
  608. DecreaseAmmo(player, weaponinfo[player->readyweapon].ammo, 1);
  609.  
  610. P_SetPsprite (player,
  611. ps_flash,
  612. weaponinfo[player->readyweapon].flashstate+(P_Random ()&1) );
  613.  
  614. P_SpawnPlayerMissile (player->mo, MT_PLASMA);
  615. }
  616.  
  617.  
  618.  
  619. //
  620. // P_BulletSlope
  621. // Sets a slope so a near miss is at aproximately
  622. // the height of the intended target
  623. //
  624. fixed_t bulletslope;
  625.  
  626.  
  627. void P_BulletSlope (mobj_t* mo)
  628. {
  629. angle_t an;
  630.  
  631. // see which target is to be aimed at
  632. an = mo->angle;
  633. bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);
  634.  
  635. if (!linetarget)
  636. {
  637. an += 1<<26;
  638. bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);
  639. if (!linetarget)
  640. {
  641. an -= 2<<26;
  642. bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);
  643. }
  644. }
  645. }
  646.  
  647.  
  648. //
  649. // P_GunShot
  650. //
  651. void
  652. P_GunShot
  653. ( mobj_t* mo,
  654. boolean accurate )
  655. {
  656. angle_t angle;
  657. int damage;
  658.  
  659. damage = 5*(P_Random ()%3+1);
  660. angle = mo->angle;
  661.  
  662. if (!accurate)
  663. angle += (P_Random()-P_Random())<<18;
  664.  
  665. P_LineAttack (mo, angle, MISSILERANGE, bulletslope, damage);
  666. }
  667.  
  668.  
  669. //
  670. // A_FirePistol
  671. //
  672. void
  673. A_FirePistol
  674. ( player_t* player,
  675. pspdef_t* psp )
  676. {
  677. S_StartSound (player->mo, sfx_pistol);
  678.  
  679. P_SetMobjState (player->mo, S_PLAY_ATK2);
  680. DecreaseAmmo(player, weaponinfo[player->readyweapon].ammo, 1);
  681.  
  682. P_SetPsprite (player,
  683. ps_flash,
  684. weaponinfo[player->readyweapon].flashstate);
  685.  
  686. P_BulletSlope (player->mo);
  687. P_GunShot (player->mo, !player->refire);
  688. }
  689.  
  690.  
  691. //
  692. // A_FireShotgun
  693. //
  694. void
  695. A_FireShotgun
  696. ( player_t* player,
  697. pspdef_t* psp )
  698. {
  699. int i;
  700.  
  701. S_StartSound (player->mo, sfx_shotgn);
  702. P_SetMobjState (player->mo, S_PLAY_ATK2);
  703.  
  704. DecreaseAmmo(player, weaponinfo[player->readyweapon].ammo, 1);
  705.  
  706. P_SetPsprite (player,
  707. ps_flash,
  708. weaponinfo[player->readyweapon].flashstate);
  709.  
  710. P_BulletSlope (player->mo);
  711.  
  712. for (i=0 ; i<7 ; i++)
  713. P_GunShot (player->mo, false);
  714. }
  715.  
  716.  
  717.  
  718. //
  719. // A_FireShotgun2
  720. //
  721. void
  722. A_FireShotgun2
  723. ( player_t* player,
  724. pspdef_t* psp )
  725. {
  726. int i;
  727. angle_t angle;
  728. int damage;
  729.  
  730.  
  731. S_StartSound (player->mo, sfx_dshtgn);
  732. P_SetMobjState (player->mo, S_PLAY_ATK2);
  733.  
  734. DecreaseAmmo(player, weaponinfo[player->readyweapon].ammo, 2);
  735.  
  736. P_SetPsprite (player,
  737. ps_flash,
  738. weaponinfo[player->readyweapon].flashstate);
  739.  
  740. P_BulletSlope (player->mo);
  741.  
  742. for (i=0 ; i<20 ; i++)
  743. {
  744. damage = 5*(P_Random ()%3+1);
  745. angle = player->mo->angle;
  746. angle += (P_Random()-P_Random())<<19;
  747. P_LineAttack (player->mo,
  748. angle,
  749. MISSILERANGE,
  750. bulletslope + ((P_Random()-P_Random())<<5), damage);
  751. }
  752. }
  753.  
  754.  
  755. //
  756. // A_FireCGun
  757. //
  758. void
  759. A_FireCGun
  760. ( player_t* player,
  761. pspdef_t* psp )
  762. {
  763. S_StartSound (player->mo, sfx_pistol);
  764.  
  765. if (!player->ammo[weaponinfo[player->readyweapon].ammo])
  766. return;
  767.  
  768. P_SetMobjState (player->mo, S_PLAY_ATK2);
  769. DecreaseAmmo(player, weaponinfo[player->readyweapon].ammo, 1);
  770.  
  771. P_SetPsprite (player,
  772. ps_flash,
  773. weaponinfo[player->readyweapon].flashstate
  774. + psp->state
  775. - &states[S_CHAIN1] );
  776.  
  777. P_BulletSlope (player->mo);
  778.  
  779. P_GunShot (player->mo, !player->refire);
  780. }
  781.  
  782.  
  783.  
  784. //
  785. // ?
  786. //
  787. void A_Light0 (player_t *player, pspdef_t *psp)
  788. {
  789. player->extralight = 0;
  790. }
  791.  
  792. void A_Light1 (player_t *player, pspdef_t *psp)
  793. {
  794. player->extralight = 1;
  795. }
  796.  
  797. void A_Light2 (player_t *player, pspdef_t *psp)
  798. {
  799. player->extralight = 2;
  800. }
  801.  
  802.  
  803. //
  804. // A_BFGSpray
  805. // Spawn a BFG explosion on every monster in view
  806. //
  807. void A_BFGSpray (mobj_t* mo)
  808. {
  809. int i;
  810. int j;
  811. int damage;
  812. angle_t an;
  813.  
  814. // offset angles from its attack angle
  815. for (i=0 ; i<40 ; i++)
  816. {
  817. an = mo->angle - ANG90/2 + ANG90/40*i;
  818.  
  819. // mo->target is the originator (player)
  820. // of the missile
  821. P_AimLineAttack (mo->target, an, 16*64*FRACUNIT);
  822.  
  823. if (!linetarget)
  824. continue;
  825.  
  826. P_SpawnMobj (linetarget->x,
  827. linetarget->y,
  828. linetarget->z + (linetarget->height>>2),
  829. MT_EXTRABFG);
  830.  
  831. damage = 0;
  832. for (j=0;j<15;j++)
  833. damage += (P_Random()&7) + 1;
  834.  
  835. P_DamageMobj (linetarget, mo->target,mo->target, damage);
  836. }
  837. }
  838.  
  839.  
  840. //
  841. // A_BFGsound
  842. //
  843. void
  844. A_BFGsound
  845. ( player_t* player,
  846. pspdef_t* psp )
  847. {
  848. S_StartSound (player->mo, sfx_bfg);
  849. }
  850.  
  851.  
  852.  
  853. //
  854. // P_SetupPsprites
  855. // Called at start of level for each player.
  856. //
  857. void P_SetupPsprites (player_t* player)
  858. {
  859. int i;
  860.  
  861. // remove all psprites
  862. for (i=0 ; i<NUMPSPRITES ; i++)
  863. player->psprites[i].state = NULL;
  864.  
  865. // spawn the gun
  866. player->pendingweapon = player->readyweapon;
  867. P_BringUpWeapon (player);
  868. }
  869.  
  870.  
  871.  
  872.  
  873. //
  874. // P_MovePsprites
  875. // Called every tic by player thinking routine.
  876. //
  877. void P_MovePsprites (player_t* player)
  878. {
  879. int i;
  880. pspdef_t* psp;
  881. state_t* state;
  882.  
  883. psp = &player->psprites[0];
  884. for (i=0 ; i<NUMPSPRITES ; i++, psp++)
  885. {
  886. // a null state means not active
  887. if ( (state = psp->state) )
  888. {
  889. // drop tic count and possibly change state
  890.  
  891. // a -1 tic count never changes
  892. if (psp->tics != -1)
  893. {
  894. psp->tics--;
  895. if (!psp->tics)
  896. P_SetPsprite (player, i, psp->state->nextstate);
  897. }
  898. }
  899. }
  900.  
  901. player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx;
  902. player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy;
  903. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement