Wolf3D-Mac/PlStuff.c

1 line
11 KiB
C
Raw Normal View History

#include "wolfdef.h" /********************************** Do damage to the player and show the killer if you die. **********************************/ void TakeDamage(Word points,Word x,Word y) { int angle; if (gamestate.godmode) { /* Don't do anything else if a god */ return; } if (gamestate.health <= points) { /* Died? */ playstate = EX_DIED; /* Kill off the player */ gamestate.health = 0; /* No health */ killx = x; /* Mark the x,y of the killer */ killy = y; } else { PlaySound((w_rnd()&1)+SND_OUCH1); /* Ouch! */ gamestate.health -= points; /* Remove the hit points */ } IO_DrawHealth(gamestate.health); /* Draw the health */ /* change face to look at attacker */ angle = PointToAngle(x,y) - (gamestate.viewangle<<SHORTTOANGLESHIFT); if (angle > 0) { if (angle > 0x2000) { faceframe = 3; } else { faceframe = 1; } } else { if (angle < -0x2000) { faceframe = 2; } else { faceframe = 0; } } if (gamestate.health <= 25) { /* Feel'n pretty bad? */ faceframe += 5; /* use beat up frames*/ } IO_DrawFace(faceframe); /* Draw the face */ facecount = 120; /* Hold for 2 seconds */ } /********************************** Heal the player **********************************/ void HealSelf(Word points) { gamestate.health += points; /* Add in the health */ if (gamestate.health>100) { gamestate.health = 100; /* Maximum */ } IO_DrawHealth(gamestate.health); /* Draw the health */ if (gamestate.health <= 25) { /* Feel'n good? */ faceframe = 5; /* Use beat up frames*/ } else { faceframe = 0; } IO_DrawFace(faceframe); /* Redraw the face */ } /********************************** Award a free life **********************************/ void GiveExtraMan(void) { if (gamestate.lives<10) { /* Too many already? */ ++gamestate.lives; /* +1 life */ IO_DrawLives(gamestate.lives); /* Redraw the lives */ } PlaySound(SND_EXTRA); /* Play a sound */ } /********************************** Award some score to the player and give free lives if enough points have been accumulated **********************************/ void GivePoints(LongWord points) { gamestate.score += points; /* Add to the score */ while (gamestate.score >= gamestate.nextextra) { gamestate.nextextra += EXTRAPOINTS; /* New free man score */ GiveExtraMan(); /* Give a free man */ } IO_DrawScore(gamestate.score); /* Draw the new score */ } /********************************** Award some score to the player and give free lives if enough points have been accumulated **********************************/ void GiveTreasure(void) { ++gamestate.treasure; /* Add the value of the treasure */ while (gamestate.treasure >= 50) { gamestate.treasure -= 50; /* Give a free man for 50 treasures */ GiveExtraMan(); } IO_DrawTreasure(gamestate.treasure); /* Draw the treasure amount */ } /********************************** Award a new weapon, use it if better than what the player already has. **********************************/ void GiveWeapon(weapontype weapon) { if (gamestate.pendingweapon < weapon) { /* Better? */ gamestate.pendingweapon = weapon; /* Use it! */ } } /********************************** Award some ammo, rearm weapon if knife was the current weapon **********************************/ void GiveAmmo(Word ammo) { gamestate.ammo += ammo; /* Add the ammo */ if (gamestate.ammo > gamestate.maxammo) { gamestate.ammo = gamestate.maxammo; /* Force maximum */ } switch(gamestate.weapon) { case WP_PISTOL: case WP_MACHINEGUN: case WP_CHAINGUN: IO_DrawAmmo(gamestate.ammo); /* Draw the ammo */ break; case WP_KNIFE: /* Was it the knife? */ if (gamestate.ammo == ammo) { /* Only equip if I had NO ammo */ gamestate.pendingweapon = WP_PISTOL; if (gamestate.machinegun) { gamestate.pendingweapon = WP_MACHINEGUN; } if (gamestate.chaingun) { /* Use the best weapon */ gamestate.pendingweapon = WP_CHAINGUN; } } } } /********************************** Award some gasoline, rearm flamethrower if knife was the current