summaryrefslogtreecommitdiffstats
path: root/mystery.c
blob: 71b07ddbb243894d658fed4a989e9129d6d74ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * 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 */
    if ( gp.Life >= 6 )
      goto again;
    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 */

    if ( gp.Bombs <= 0 )
      goto again;

    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);
  }
}