]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/us.c
98cbab097f899ccdeec0a2adf385d8cbe826aaed
1 /* Header: us.c,v 7.0.1.3 87/01/13 17:13:21 lwall Exp */
4 * Revision 7.0.1.3 87/01/13 17:13:21 lwall
5 * Partially fixed ^S behavior. It now just ignores ^S.
7 * Revision 7.0.1.2 86/12/12 17:06:09 lwall
8 * Baseline for net release.
10 * Revision 7.0.1.1 86/10/16 10:53:50 lwall
11 * Added Damage. Fixed random bugs.
13 * Revision 7.0 86/10/08 15:14:21 lwall
14 * Split into separate files. Added amoebas and pirates.
37 do_direction(int dy
, int dx
)
47 ch
= (ent
->energy
>= 500?'E':'e');
48 if (ch
!= ent
->image
) {
52 decr
= 5+abs(evely
)+abs(evelx
)+tractor
*tractor
;
53 if (ent
->energy
>= decr
) {
56 if (!damage
|| !damflag
[NOTRACTORS
]) {
59 damflag
[NOTRACTORS
] = rand_mod(smarts
+10)+2;
61 if (tract(ent
,dy
,dx
,tractor
)) {
68 (!entmode
&& !damflag
[NOIMPULSE
]) ||
69 (entmode
&& !damflag
[NOWARP
]) ) {
70 if (!rand_mod(30+500/(abs(evely
)+abs(evelx
)+1))) {
72 damflag
[entmode
?NOWARP
:NOIMPULSE
] = rand_mod(smarts
+10)+2;
78 (obj
=occupant
[(ent
->posy
+evely
+YSIZE00
)%YSIZE
]
79 [(ent
->posx
+evelx
+XSIZE00
)%XSIZE
] ) &&
84 else if (status
== 2) {
85 decr
= 500+abs(bvely
)*5+abs(bvelx
)*5+tractor
*tractor
*100;
86 if (base
->energy
>= decr
) {
89 if (tract(base
,dy
,dx
,tractor
)) {
99 (obj
=occupant
[(base
->posy
+bvely
+YSIZE00
)%YSIZE
]
100 [(base
->posx
+bvelx
+XSIZE00
)%XSIZE
] ) &&
109 ctrl_direction(int dy
, int dx
)
116 ch
= (ent
->energy
>= 500?'E':'e');
117 if (ch
!= ent
->image
) {
121 if (!damage
|| !damflag
[NOPHASERS
]) {
122 if (!rand_mod(200)) {
124 damflag
[NOPHASERS
] = rand_mod(smarts
+10)+2;
126 fire_phaser(ent
, dy
, dx
);
129 else if (status
== 2)
130 fire_phaser(base
, dy
, dx
);
134 shift_direction(int dy
, int dx
)
141 ch
= (ent
->energy
>= 500?'E':'e');
142 if (ch
!= ent
->image
) {
146 if (!damage
|| !damflag
[NOTORPS
]) {
147 if (!rand_mod(300)) {
149 damflag
[NOTORPS
] = rand_mod(smarts
+10)+2;
151 fire_torp(ent
, dy
, dx
);
154 else if (status
== 2)
155 fire_torp(base
, dy
, dx
);
159 get_commands(bool *done
)
165 char numdestructs
= 0, numzaps
= 0;
168 while ((count
= read_nd(ch
,(sizeof ch
)))) {
169 for (i
=0; i
<count
; i
++) {
176 if (ch
[i
] == 'q' || ch
[i
] == BREAKCH
|| ch
[i
] == INTRCH
) {
178 static char quest
[] = "Do you wish to escape from reality? ";
180 if (timer
>= whenok
) {
181 mvaddstr(12,22,quest
);
184 } while (ch
[i
] != 'y' && ch
[i
] != 'n');
191 for (x
=11; x
<=28; x
++) {
194 ? occupant
[11][x
]->image
211 for (i
=0; i
<count
; i
++) {
215 ctrl_direction(1, -1);
218 ctrl_direction(1, 0);
221 ctrl_direction(1, 1);
224 ctrl_direction(0, -1);
227 ctrl_direction(0, 1);
230 ctrl_direction(-1, -1);
233 ctrl_direction(-1, 0);
236 ctrl_direction(-1, 1);
245 while (!input_pending())
272 if (ent
&& (!damage
|| !damflag
[NOIMPULSE
])) {
278 if (ent
&& (!damage
|| !damflag
[NOWARP
])) {
293 else if (status
== 2) {
308 if (ent
->energy
>= 250)
313 if (ent
&& (!damage
|| !damflag
[NOZAPPER
])) {
315 if (!rand_mod(100/numzaps
)) {
317 damflag
[NOZAPPER
] = rand_mod(smarts
+10)+2;
319 if (nxtbang
&& bangm
[nxtbang
-1] < 0)
320 --nxtbang
; /* consolidate zaps */
321 make_blast(evely
*2+ent
->posy
,evelx
*2+ent
->posx
,
322 -5000000L, 3*numzaps
);
327 if (status
< 2 && (!damage
|| !damflag
[NODESTRUCT
])) {
328 if (ent
&& !rand_mod(10)) {
330 damflag
[NODESTRUCT
] = rand_mod(smarts
+10)+2;
332 if (++numdestructs
<= 2)
333 make_blast(evely
*2+ent
->posy
,evelx
*2+ent
->posx
,
337 else if (status
== 2) {
339 base
->energy
= base
->energy
/ 2;
340 if (++numdestructs
<= 2)
341 make_blast(base
->posy
, base
->posx
, 15000L, 5);
345 if ((!damage
|| !damflag
[NODESTRUCT
]) && (base
||ent
)) {
349 if (ent
&& !rand_mod(200)) {
351 damflag
[NODESTRUCT
] = rand_mod(smarts
+10)+2;
353 for (obj
= root
.prev
;
356 if (obj
->image
== '+') {
357 blast
[y
=(obj
->posy
+obj
->vely
+YSIZE00
)%YSIZE
]
358 [x
=(obj
->posx
+obj
->velx
+XSIZE00
)%XSIZE
]
363 obj
->mass
= (massacre
?3000:4000);
369 if ((!damage
|| !damflag
[NODESTRUCT
]) && (base
||ent
)) {
371 if (ent
&& !rand_mod(200)) {
373 damflag
[NODESTRUCT
] = rand_mod(smarts
+10)+2;
375 for (obj
= root
.prev
;
376 obj
->type
== Torp
|| obj
->type
== Web
||
379 if (obj
->image
== '+')
380 obj
->vely
= obj
->velx
= 0;
456 if (status
< 2 && ent
->energy
>= 10) {
462 case '%': case '\177': case '_':
463 shift_direction(0, -1);
464 shift_direction(0, 1);
465 shift_direction(-1, 0);
466 shift_direction(1, 0);
467 shift_direction(-1, -1);
468 shift_direction(-1, 1);
469 shift_direction(1, -1);
470 shift_direction(1, 1);
473 shift_direction(1, -1);
476 shift_direction(1, 0);
479 shift_direction(1, 1);
482 shift_direction(0, -1);
485 shift_direction(0, 1);
488 shift_direction(-1, -1);
491 shift_direction(-1, 0);
494 shift_direction(-1, 1);