1: /* $Header: play.c,v 7.0.1.1 86/10/16 10:52:39 lwall Exp $ */
2:
3: /* $Log: play.c,v $
4: * Revision 7.0.1.1 86/10/16 10:52:39 lwall
5: * Added Damage. Fixed random bugs.
6: *
7: * Revision 7.0 86/10/08 15:13:09 lwall
8: * Split into separate files. Added amoebas and pirates.
9: *
10: */
11:
12: #include "EXTERN.h"
13: #include "warp.h"
14: #include "bang.h"
15: #include "score.h"
16: #include "object.h"
17: #include "move.h"
18: #include "term.h"
19: #include "them.h"
20: #include "us.h"
21: #include "util.h"
22: #include "weapon.h"
23: #include "INTERN.h"
24: #include "play.h"
25:
26: void
27: play_init()
28: {
29: ;
30: }
31:
32: void
33: play()
34: {
35: bool done = FALSE;
36: Reg1 OBJECT *curobj;
37: Reg2 OBJECT *to;
38: Reg3 int i;
39: Reg4 int x;
40: Reg5 int y;
41:
42: display_status();
43: #ifdef TIOCOUTQ
44: while (output_pending() > charsperhalfsec)
45: sleep(1); /* allow buffers to empty */
46: #endif
47: sleep(3);
48: do {
49: timer++;
50: nxtbang = 0;
51: banging = FALSE;
52: display_status();
53: #ifdef TIOCOUTQ
54: while (output_pending() > charsperhalfsec)
55: sleep(1);
56: #endif
57: if (lowspeed)
58: roundsleep(2);
59: else
60: roundsleep(1);
61: if (ent) {
62: evely = ent->vely;
63: evelx = ent->velx;
64: if (cloaking && ent->energy >= 250 && !damflag[NOCLOAKING]) {
65: if (!rand_mod(300)) {
66: damage++;
67: damflag[NOCLOAKING] = rand_mod(smarts+1)+2;
68: }
69: ent->energy -= ent->energy/40;
70: }
71: else
72: cloaking = FALSE;
73: cloaked = cloaking;
74: }
75: if (base) {
76: bvely = base->vely;
77: bvelx = base->velx;
78: }
79: get_commands(&done);
80: if (done)
81: break;
82: their_smarts();
83: apolloflag = 0;
84: if (ent) {
85: if (numapollos) {
86: if (numstars) {
87: if (realapollo) {
88: if (lookfor(realapollo->posy,realapollo->posx,
89: Enterprise)) {
90: apolloflag = 1;
91: }
92: }
93: else if (lookfor(root.next->posy,root.next->posx,
94: Enterprise)) {
95: apolloflag = 1;
96: realapollo = root.next;
97: mvaddch(realapollo->posy+1,realapollo->posx*2,
98: 'A');
99: realapollo->image = 'A';
100: realapollo->mass = 6000;
101: inumapollos = 1;
102: numenemies++;
103: inumenemies++;
104: possiblescore += 5000;
105: }
106: if (apolloflag) {
107: if (blast[realapollo->posy][realapollo->posx] <= 32000)
108: evely = evelx = 0;
109: realapollo->energy = 32000;
110: }
111: }
112: else
113: numapollos = 0;
114: }
115: ent->vely = evely;
116: ent->velx = evelx;
117: }
118: if (base) {
119: if (numapollos) {
120: if (numstars) {
121: if (realapollo) {
122: if (lookfor(realapollo->posy,realapollo->posx,
123: Base)) {
124: apolloflag |= 2;
125: }
126: }
127: else if (lookfor(root.next->posy,root.next->posx,
128: Base)) {
129: apolloflag |= 2;
130: realapollo = root.next;
131: mvaddch(realapollo->posy+1,realapollo->posx*2,
132: 'A');
133: realapollo->image = 'A';
134: realapollo->mass = 6000;
135: inumapollos = 1;
136: numenemies++;
137: inumenemies++;
138: possiblescore += 5000;
139: }
140: if (apolloflag & 2) {
141: if (blast[realapollo->posy][realapollo->posx] <= 32000)
142: bvely = bvelx = 0;
143: realapollo->energy = 32000;
144: }
145: }
146: else
147: numapollos = 0;
148: }
149: base->vely = bvely;
150: base->velx = bvelx;
151: }
152: if (aretorps) {
153: aretorps = 0;
154: for (i=0;i<2;i++) for (y=0;y<3;y++) for (x=0;x<3;x++) {
155: if (curobj = isatorp[i][y][x]) {
156: to = occupant[(curobj->posy+curobj->vely+YSIZE00)%YSIZE]
157: [(curobj->posx+curobj->velx+XSIZE00)%XSIZE];
158: if (to && !to->vely && !to->velx) {
159: unmake_object(curobj);
160: if (i)
161: btorp++;
162: else
163: etorp++;
164: }
165: isatorp[i][y][x]=0;
166: }
167: }
168: }
169: move_universe();
170: if (finish) {
171: finish--;
172: if (!finish && (!(numenemies || numos) || (!ent && !base))) {
173: done = TRUE;
174: timer -= 5;
175: }
176: }
177: else if (!banging && (!(numenemies || numos) || (!ent && !base)))
178: finish = 5;
179: } while (!done);
180: }
Defined functions
play
defined in line
32; used 2 times