aboutsummaryrefslogtreecommitdiffstats
path: root/mystery.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2003-03-24 16:31:19 +0000
committerH. Peter Anvin <hpa@zytor.com>2003-03-24 16:31:19 +0000
commit1128ad360b5cccb1b82de092505e5ca1c4dbed8d (patch)
tree89c7ebe649b47fa1b901872d646a2183df023c8d /mystery.c
downloadgrv-1128ad360b5cccb1b82de092505e5ca1c4dbed8d.tar.gz
grv-1128ad360b5cccb1b82de092505e5ca1c4dbed8d.tar.xz
grv-1128ad360b5cccb1b82de092505e5ca1c4dbed8d.zip
Port of "gršvning" to C/SDL, started 2003-03-22
Diffstat (limited to 'mystery.c')
-rw-r--r--mystery.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/mystery.c b/mystery.c
new file mode 100644
index 0000000..f5b8f3a
--- /dev/null
+++ b/mystery.c
@@ -0,0 +1,108 @@
+/*
+ * mystery.c
+ *
+ * Handle "mystery treasures" (?-marks)
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <math.h>
+#include "graphics.h"
+#include "grv.h"
+
+void mystery(void)
+{
+ int myst;
+ int tlife;
+
+ color(0,gp.c);
+
+ again:
+ tlife = (6-gp.Life)*20;
+ myst = irnd(1230+tlife) - tlife;
+
+ if ( myst < 0 ) {
+ /* Extra life */
+ gp.Life++;
+ message(0,"Treasure: Extra Life");
+ color(14,gp.c);
+ lprintf(1,16+2*gp.Life, "\x01");
+ } else if ( myst < 150 ) {
+ /* Stingy extra points */
+ int SSq = (irnd(200)+100)*gp.Level;
+
+ gp.Sc += SSq;
+ message(0,"Treasure: %d points", SSq);
+ update_score();
+ } else if ( myst < 350 ) {
+ /* Moderate extra points */
+ int SSq = (irnd(800)+400)*gp.Level;
+
+ gp.Sc += SSq;
+ message(0,"Treasure: %d points", SSq);
+ update_score();
+ } else if ( myst < 400 ) {
+ /* Decent extra points */
+ int SSq = (irnd(2000)+1000)*gp.Level;
+
+ gp.Sc += SSq;
+ message(0,"Treasure: %d points", SSq);
+ update_score();
+ } else if ( myst < 470 ) {
+ message(0,"Treasure: End of Level");
+ mymssleep(gp.Speed*7);
+ gp.Status = Status_Quit;
+ } else if ( myst < 650 ) {
+ /* Ghost freeze */
+ int e;
+ double thaw;
+
+ if ( gp.FS != 0 )
+ goto again;
+
+ message(0,"Treasure: Ghost freeze");
+ gp.FS = 0; /* Ghosts frozen */
+
+ color(10,0);
+ for ( e = 0 ; e < MAXGHOST ; e++ ) {
+ if ( !ghost[e].dead )
+ lprint(ghost[e].x, ghost[e].y, "\x02");
+ }
+
+ /* Just in case we have scared ghosts right now... */
+ removeaction(0, 0, act_ghost_thaw);
+ removeaction(0, 0, act_ghost_normal);
+
+ thaw = gp.Tid + 32.0 + 60.0*rnd();
+ addaction(0, 0, thaw, act_ghost_thaw);
+ addaction(0, 0, thaw+8.0, act_ghost_normal);
+ } else if ( myst < 790 ) {
+ /* Extra ammo */
+ int NewKulSpr = irnd(3) + 2;
+
+ gp.KulSpr += NewKulSpr;
+ message(0,"Treasure: %d extra shots", NewKulSpr);
+ update_shots();
+ } else if ( myst < 930 ) {
+ /* Bomb detonation */
+
+ message(0,"Treasure: Bomb detonation... OOPS!");
+ retime_all(gp.Tid+4.0, act_bomb);
+ } else if ( myst < 1060 ) {
+ /* Smash! */
+
+ message(0,"Treasure: *** SMASH ***");
+ addaction(0, 0, gp.Tid+5.0, act_smash);
+ } else {
+ /* Scared ghosts */
+ if ( gp.FS != 1 )
+ goto again;
+
+ message(0, "Treasure: Scared ghosts");
+
+ gp.FS = -1; /* Reverse direction */
+ addaction(0, 0, gp.Tid+80.0, act_ghost_normal);
+ }
+}