]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/them.c
1 /* Header: them.c,v 7.0.1.5 86/12/12 17:05:41 lwall Exp */
4 * Revision 7.0.1.5 86/12/12 17:05:41 lwall
5 * Baseline for net release.
7 * Revision 7.0.1.4 86/10/20 12:32:38 lwall
8 * Wasn't clearing FRIENDLY flag on pirate creation.
10 * Revision 7.0.1.3 86/10/20 12:15:33 lwall
11 * Was trying to create pirates from cloaked pirates.
13 * Revision 7.0.1.2 86/10/17 10:03:44 lwall
14 * Fixed Romulan writing spaces while cloaked.
16 * Revision 7.0.1.1 86/10/16 10:53:39 lwall
17 * Added Damage. Fixed random bugs.
19 * Revision 7.0 86/10/08 15:14:15 lwall
20 * Split into separate files. Added amoebas and pirates.
53 if (numcrushes
&& (obj
=movers
)->type
== Crusher
) {
56 x
= (obj
->posx
+(obj
->image
=='<'?1:-1)+XSIZE00
)%XSIZE
;
57 if (amb
[y
][x
] == '~') {
58 obj
->velx
= 0; /* stop and munch amoeba */
59 modify_amoeba(y
,x
,1,' ',(int)rand_mod(5+ambsize
/10)+1);
60 if (occupant
[y
][x
] == nuke
) /* except go for nucleus */
61 obj
->velx
= (obj
->image
=='<' ? 1 : -1);
63 else if (!obj
->velx
) {
65 obj
->image
= rand_mod(2) ? '<' : '>';
66 obj
->velx
= obj
->image
== '<' ? 1 : -1;
69 obj
->vely
+= (rand_mod(222) - 111) / 100;
70 if (!(rand_mod(100))) {
71 setimage(obj
, (obj
->velx
*= -1) < 0 ? '>' : '<');
76 nuke
->velx
= nuke
->vely
= 0;
77 if (nuke
->strategy
&& ambsize
< 90 && !rand_mod(200-smarts
))
78 modify_amoeba(0,0,0,'~',(int)rand_mod(10));
79 if (ambsize
> 200 || (ambsize
> 100 && !rand_mod(15)))
80 modify_amoeba(yamblast
,xamblast
,2,' ',(ambsize
-100)/5);
82 for (curkl
= enemies
; curkl
->type
== Enemy
; curkl
= curkl
->next
) {
83 if ((curkl
->flags
& (CLOAKS
|FRIENDLY
)) == CLOAKS
&&
84 (curkl
->image
!= ' ') &&
85 (curkl
->energy
> 300 || massacre
) ) {
90 else if (curkl
->vely
|| curkl
->velx
)
91 prob
= massacre
?10:20;
92 else if ((curkl
->flags
& (PIRATE
|FRIENDLY
)) == PIRATE
) {
93 /* pirates want to sit sometimes */
94 if (curkl
->strategy
) {
95 if ((obj
= lookimg(curkl
->posy
, curkl
->posx
, '@')) ||
96 (obj
= lookimg(curkl
->posy
, curkl
->posx
, 'B')) ) {
97 make_plink(obj
->posy
, obj
->posx
);
98 if (!--curkl
->strategy
) { /* clock ran down */
99 if (obj
->image
== '@') {
102 if (obj
->flags
& STATIC
)
103 mvaddch(obj
->posy
+1,obj
->posx
*2,obj
->image
);
104 if (curkl
->energy
< 20000)
105 curkl
->energy
+= 5000;
107 prob
= 2; /* our work here is done */
109 else if (obj
->image
== 'B') {
110 btorp
-= rand_mod(50);
113 obj
->energy
-= rand_mod(500);
116 prob
= 10000; /* stay here */
121 else { /* it went away--go elsewhere */
126 else if (lookimg(curkl
->posy
, curkl
->posx
, '@') ||
127 lookimg(curkl
->posy
, curkl
->posx
, 'B')) {
128 curkl
->strategy
= rand_mod(15)+5;
134 else if (curkl
->image
== 'M') { /* Mudd wants to sit sometimes */
135 if ((obj
= lookimg(curkl
->posy
, curkl
->posx
, 'E')) ||
136 (obj
= lookimg(curkl
->posy
, curkl
->posx
, 'B')) ) {
137 if (obj
->image
== 'B') {
138 btorp
-= rand_mod(40);
141 obj
->energy
-= rand_mod(100);
145 else if (!obj
->vely
&& !obj
->velx
) {
146 etorp
-= rand_mod(10);
149 obj
->energy
-= rand_mod(20);
153 prob
= 10000; /* stay here */
155 else /* it went away--go elsewhere */
158 else if (curkl
->flags
& FRIENDLY
) {
159 if (curkl
->energy
< 10000 &&
160 lookimg(curkl
->posy
, curkl
->posx
, '@') ) {
161 curkl
->energy
+= 100;
162 prob
= 20; /* do some loading */
167 else if (curkl
->image
== '&') {
168 if (curkl
->flags
& COUNTDOWN
) {
172 curkl
->flags
&= ~COUNTDOWN
;
173 prob
= 100; /* someone's feeding us, so sit still */
179 prob
= 4; /* don't sit still too long */
182 if (--count
<= 0) /* no opening, just ram something */
188 if (!(rand_mod(prob
))) /* turn randomly occasionally */
191 y
=(curkl
->posy
+curkl
->vely
+YSIZE00
)%YSIZE
; /* find prospective */
192 x
=(curkl
->posx
+curkl
->velx
+XSIZE00
)%XSIZE
; /* new position */
196 if (amb
[y
][x
] != '~')
197 goto accell
; /* never move nucleus from protoplasm */
200 if (amb
[y
][x
] == '~' && rand_mod(2)) {
208 obj
= occupant
[y
][x
];
209 if (!obj
) break; /* is anyone there? */
213 if (obj
->image
== '@' && (curkl
->flags
& PIRATE
)) {
214 if (curkl
->image
!= 'P' && curkl
->image
!= ' ') {
215 if (curkl
->flags
& FRIENDLY
) {
216 curkl
->flags
&= ~FRIENDLY
;
217 curkl
->energy
+= 1000;
218 possiblescore
+= curkl
->mass
;
226 break; /* go ahead and ram the star */
228 goto accell
; /* try not to ram stars */
230 if (!obj
->vely
&& !obj
->velx
&& (rand_mod(100) <= smarts
) &&
231 (obj
->image
== 'o' || obj
->image
== 'O' || obj
->image
== 'X'))
232 goto accell
; /* try not to ram "friendly" torps */
235 if (curkl
->image
!= 'T')
236 goto accell
; /* non-Tholians shouldn't ram web */
238 break; /* Tholians retrace web if desperate */
242 (curkl
->velx
==curkl
->vely
?
253 ) goto accell
; /* Tholians try not to retrace web */
254 break; /* No problem with crossing web */
256 break; /* okay to move over object */
259 /* determine maximum velocity */
260 if (massacre
&& curkl
->image
!= 'T') {
261 curkl
->vely
= rand_mod(7) - 3;
262 curkl
->velx
= rand_mod(7) - 3;
264 else if (curkl
->image
== '&') {
266 curkl
->vely
= rand_mod(3) - 1;
267 curkl
->velx
= rand_mod(3) - 1;
270 curkl
->vely
= curkl
->strategy
& 3;
273 curkl
->velx
= (curkl
->strategy
>> 2) & 3;
278 else if (curkl
->energy
>= 2500 && curkl
->image
!= 'T') {
279 curkl
->vely
= rand_mod(5) - 2;
280 curkl
->velx
= rand_mod(5) - 2;
283 curkl
->vely
= rand_mod(3) - 1;
284 curkl
->velx
= rand_mod(3) - 1;
288 if (curkl
->image
== ' ') {
289 setimage(curkl
, curkl
->flags
& PIRATE
? 'P' : 'R');
296 if (curkl
->image
== 'G' && (base
||ent
) &&
297 !rand_mod((103-smarts
)*10) ) {
300 for (xxx
= -1; xxx
<=1; xxx
++)
301 for (yyy
= -1; yyy
<=1; yyy
++)
302 if ((xxx
||yyy
) && rand_mod(2))
303 fire_torp(curkl
,yyy
,xxx
);
305 else if (curkl
->image
== 'T' && (curkl
->velx
|| curkl
->vely
)) {
309 (curkl
->velx
==curkl
->vely
?
319 curkl
->posy
,curkl
->posx
,0,0,32767L,32767L,&root
);
320 if (obj
&& obj
->type
== Web
) {
322 occupant
[y
][x
] = NULL
;
326 /* klingon-style fighting */
330 if (ent
&& (!cloaked
|| ent
->image
=='E' || ent
->image
=='e'))
335 modify_amoeba(int y
, int x
, int where
, int ch
, int quant
)
343 if (!where
|| (where
==1 && rand_mod(2))) {
347 if (nuke
->strategy
&& rand_mod(3)) {
348 dy
= nuke
->strategy
& 3;
351 dx
= (nuke
->strategy
>> 2) & 3;
354 if (ch
== ' ') { /* take from the tail */
359 nuke
->strategy
= rand_mod(256);
362 dy
= rand_mod(3) - 1;
363 dx
= rand_mod(3) - 1;
370 y
= (y
+ dy
+ YSIZE00
) % YSIZE
;
371 x
= (x
+ dx
+ XSIZE00
) % XSIZE
;
372 } while (amb
[y
][x
] != ' ');
374 y
= (y
- dy
+ YSIZE00
) % YSIZE
;
375 x
= (x
- dx
+ XSIZE00
) % XSIZE
;
377 if (ambsize
> 100 && quant
> 2) {
378 quant
>>= (ambsize
/100);
380 if ((nuke
->energy
+= quant
<< 6) > 32767)
381 nuke
->energy
= 32767;
382 count
= quant
<< 3; /* endless loop catcher */
383 while (count
-- > 0 && quant
> 0) {
384 if (amb
[y
][x
] != ch
) {
398 y
= (y
+ rand_mod(3) + YSIZE99
) % YSIZE
;
399 x
= (x
+ rand_mod(3) + XSIZE99
) % XSIZE
;