1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 1996, 2003 - 3D Realms Entertainment
4 Copyright (C) 2017-2019 Nuke.YKT
5
6 This file is part of Duke Nukem 3D version 1.5 - Atomic Edition
7
8 Duke Nukem 3D is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17 See the GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 Original Source: 1996 - Todd Replogle
24 Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
25 */
26 //-------------------------------------------------------------------------
27
28 #include "duke3d.h"
29
30 extern short otherp;
31
32 #ifdef RRRA
33 extern long WindTime;
34 extern long WindDir;
35 extern short word_119BD8;
36 extern short word_119BDA;
37 extern short word_119BDC;
38 #endif
39
40 static short g_i,g_p;
41 static long g_x;
42 static long *g_t;
43 static spritetype *g_sp;
44
dodge(spritetype * s)45 char dodge(spritetype *s)
46 {
47 short i;
48 long bx,by,mx,my,bxvect,byvect,mxvect,myvect,d;
49
50 mx = s->x;
51 my = s->y;
52 mxvect = sintable[(s->ang+512)&2047]; myvect = sintable[s->ang&2047];
53
54 for(i=headspritestat[4];i>=0;i=nextspritestat[i]) //weapons list
55 {
56 if( OW == i || SECT != s->sectnum)
57 continue;
58
59 bx = SX-mx;
60 by = SY-my;
61 bxvect = sintable[(SA+512)&2047]; byvect = sintable[SA&2047];
62
63 if (mxvect*bx + myvect*by >= 0)
64 if (bxvect*bx + byvect*by < 0)
65 {
66 d = bxvect*by - byvect*bx;
67 if (klabs(d) < 65536*64)
68 {
69 s->ang -= 512+(TRAND&1024);
70 return 1;
71 }
72 }
73 }
74 return 0;
75 }
76
furthestangle(short i,short angs)77 short furthestangle(short i,short angs)
78 {
79 short j, hitsect,hitwall,hitspr,furthest_angle, angincs;
80 long hx, hy, hz, d, greatestd;
81 spritetype *s = &sprite[i];
82
83 greatestd = -(1<<30);
84 angincs = 2048/angs;
85
86 if(s->picnum != APLAYER)
87 if( (g_t[0]&63) > 2 ) return( s->ang + 1024 );
88
89 for(j=s->ang;j<(2048+s->ang);j+=angincs)
90 {
91 hitscan(s->x, s->y, s->z-(8<<8), s->sectnum,
92 sintable[(j+512)&2047],
93 sintable[j&2047],0,
94 &hitsect,&hitwall,&hitspr,&hx,&hy,&hz,CLIPMASK1);
95
96 d = klabs(hx-s->x) + klabs(hy-s->y);
97
98 if(d > greatestd)
99 {
100 greatestd = d;
101 furthest_angle = j;
102 }
103 }
104 return (furthest_angle&2047);
105 }
106
furthestcanseepoint(short i,spritetype * ts,long * dax,long * day)107 short furthestcanseepoint(short i,spritetype *ts,long *dax,long *day)
108 {
109 short j, hitsect,hitwall,hitspr, angincs, tempang;
110 long hx, hy, hz, d, da;//, d, cd, ca,tempx,tempy,cx,cy;
111 spritetype *s = &sprite[i];
112
113 if( (g_t[0]&63) ) return -1;
114
115 if(ud.multimode < 2 && ud.player_skill < 3)
116 angincs = 2048/2;
117 else angincs = 2048/(1+(TRAND&1));
118
119 for(j=ts->ang;j<(2048+ts->ang);j+=(angincs-(TRAND&511)))
120 {
121 hitscan(ts->x, ts->y, ts->z-(16<<8), ts->sectnum,
122 sintable[(j+512)&2047],
123 sintable[j&2047],16384-(TRAND&32767),
124 &hitsect,&hitwall,&hitspr,&hx,&hy,&hz,CLIPMASK1);
125
126 d = klabs(hx-ts->x)+klabs(hy-ts->y);
127 da = klabs(hx-s->x)+klabs(hy-s->y);
128
129 if( d < da )
130 if(cansee(hx,hy,hz,hitsect,s->x,s->y,s->z-(16<<8),s->sectnum))
131 {
132 *dax = hx;
133 *day = hy;
134 return hitsect;
135 }
136 }
137 return -1;
138 }
139
alterang(short a)140 void alterang(short a)
141 {
142 short aang, angdif, goalang,j;
143 long ticselapsed, *moveptr;
144
145 moveptr = (long *)g_t[1];
146
147 ticselapsed = (g_t[0])&31;
148
149 aang = g_sp->ang;
150
151 g_sp->xvel += (*moveptr-g_sp->xvel)/5;
152 if(g_sp->zvel < 648) g_sp->zvel += ((*(moveptr+1)<<4)-g_sp->zvel)/5;
153
154 #ifdef RRRA
155 if(a&windang)
156 g_sp->ang = WindDir;
157 else
158 #endif
159
160 if(a&seekplayer)
161 {
162 g_sp->owner = ps[g_p].i;
163
164 if(sprite[g_sp->owner].picnum == APLAYER)
165 goalang = getangle(hittype[g_i].lastvx-g_sp->x,hittype[g_i].lastvy-g_sp->y);
166 else
167 goalang = getangle(sprite[g_sp->owner].x-g_sp->x,sprite[g_sp->owner].y-g_sp->y);
168
169 if(g_sp->xvel && g_sp->picnum != DRONE)
170 {
171 angdif = getincangle(aang,goalang);
172
173 if(ticselapsed < 2)
174 {
175 if( klabs(angdif) < 256)
176 {
177 j = 128-(TRAND&256);
178 g_sp->ang += j;
179 if( hits(g_i) < 844 )
180 g_sp->ang -= j;
181 }
182 }
183 else if(ticselapsed > 18 && ticselapsed < 26) // choose
184 {
185 if(klabs(angdif>>2) < 128) g_sp->ang = goalang;
186 else g_sp->ang += angdif>>2;
187 }
188 }
189 else g_sp->ang = goalang;
190 }
191
192 if(ticselapsed < 1)
193 {
194 j = 2;
195 if(a&furthestdir)
196 {
197 goalang = furthestangle(g_i,j);
198 g_sp->ang = goalang;
199 g_sp->owner = ps[g_p].i;
200 }
201
202 if(a&fleeenemy)
203 {
204 goalang = furthestangle(g_i,j);
205 g_sp->ang = goalang; // += angdif; // = getincangle(aang,goalang)>>1;
206 }
207 }
208 }
209
move()210 void move()
211 {
212 long l, *moveptr;
213 short j, a, goalang, angdif;
214 long daxvel;
215
216 a = g_sp->hitag;
217
218 if(a == -1) a = 0;
219
220 g_t[0]++;
221
222 if(a&face_player)
223 {
224 if(ps[g_p].newowner >= 0)
225 goalang = getangle(ps[g_p].oposx-g_sp->x,ps[g_p].oposy-g_sp->y);
226 else goalang = getangle(ps[g_p].posx-g_sp->x,ps[g_p].posy-g_sp->y);
227 angdif = getincangle(g_sp->ang,goalang)>>2;
228 if(angdif > -8 && angdif < 0) angdif = 0;
229 g_sp->ang += angdif;
230 }
231
232 if(a&spin)
233 g_sp->ang += sintable[ ((g_t[0]<<3)&2047) ]>>6;
234
235 if(a&face_player_slow)
236 {
237 if(ps[g_p].newowner >= 0)
238 goalang = getangle(ps[g_p].oposx-g_sp->x,ps[g_p].oposy-g_sp->y);
239 else goalang = getangle(ps[g_p].posx-g_sp->x,ps[g_p].posy-g_sp->y);
240 angdif = ksgn(getincangle(g_sp->ang,goalang))<<5;
241 if(angdif > -32 && angdif < 0)
242 {
243 angdif = 0;
244 g_sp->ang = goalang;
245 }
246 g_sp->ang += angdif;
247 }
248
249 #ifdef RRRA
250 if(a&antifaceplayerslow)
251 {
252 if(ps[g_p].newowner >= 0)
253 goalang = (getangle(ps[g_p].oposx-g_sp->x,ps[g_p].oposy-g_sp->y)+1024)&2047;
254 else goalang = (getangle(ps[g_p].posx-g_sp->x,ps[g_p].posy-g_sp->y)+1024)&2047;
255 angdif = ksgn(getincangle(g_sp->ang,goalang))<<5;
256 if(angdif > -32 && angdif < 0)
257 {
258 angdif = 0;
259 g_sp->ang = goalang;
260 }
261 g_sp->ang += angdif;
262 }
263
264 if((a&jumptoplayer) == jumptoplayer)
265 {
266 if(g_sp->picnum == CHEER)
267 {
268 if(g_t[0] < 16)
269 g_sp->zvel -= (sintable[(512+(g_t[0]<<4))&2047]/40);
270 }
271 else
272 {
273 if(g_t[0] < 16)
274 g_sp->zvel -= (sintable[(512+(g_t[0]<<4))&2047]>>5);
275 }
276 }
277 if(a&justjump1)
278 {
279 if(g_sp->picnum == RABBIT)
280 {
281 if(g_t[0] < 8)
282 g_sp->zvel -= (sintable[(512+(g_t[0]<<4))&2047]/30);
283 }
284 else if(g_sp->picnum == MAMA)
285 {
286 if(g_t[0] < 8)
287 g_sp->zvel -= (sintable[(512+(g_t[0]<<4))&2047]/35);
288 }
289 }
290 if(a&justjump2)
291 {
292 if(g_sp->picnum == RABBIT)
293 {
294 if(g_t[0] < 8)
295 g_sp->zvel -= (sintable[(512+(g_t[0]<<4))&2047]/24);
296 }
297 else if(g_sp->picnum == MAMA)
298 {
299 if(g_t[0] < 8)
300 g_sp->zvel -= (sintable[(512+(g_t[0]<<4))&2047]/28);
301 }
302 }
303 if(a&windang)
304 {
305 if(g_t[0] < 8)
306 g_sp->zvel -= (sintable[(512+(g_t[0]<<4))&2047]/24);
307 }
308 #else
309 if ((a&jumptoplayer) == jumptoplayer)
310 {
311 if (g_t[0] < 16)
312 g_sp->zvel -= (sintable[(512 + (g_t[0] << 4)) & 2047] >> 5);
313 }
314 #endif
315
316
317 if(a&face_player_smart)
318 {
319 long newx,newy;
320
321 newx = ps[g_p].posx+(ps[g_p].posxv/768);
322 newy = ps[g_p].posy+(ps[g_p].posyv/768);
323 goalang = getangle(newx-g_sp->x,newy-g_sp->y);
324 angdif = getincangle(g_sp->ang,goalang)>>2;
325 if(angdif > -8 && angdif < 0) angdif = 0;
326 g_sp->ang += angdif;
327 }
328
329 if( g_t[1] == 0 || a == 0 )
330 {
331 if( ( badguy(g_sp) && g_sp->extra <= 0 ) || (hittype[g_i].bposx != g_sp->x) || (hittype[g_i].bposy != g_sp->y) )
332 {
333 hittype[g_i].bposx = g_sp->x;
334 hittype[g_i].bposy = g_sp->y;
335 setsprite(g_i,g_sp->x,g_sp->y,g_sp->z);
336 }
337 if (badguy(g_sp) && g_sp->extra <= 0)
338 {
339 if (sector[g_sp->sectnum].ceilingstat & 1)
340 {
341 if (shadedsector[g_sp->sectnum] == 1)
342 {
343 g_sp->shade += (16-g_sp->shade)>>1;
344 }
345 else
346 {
347 g_sp->shade += (sector[g_sp->sectnum].ceilingshade-g_sp->shade)>>1;
348 }
349 }
350 else
351 {
352 g_sp->shade += (sector[g_sp->sectnum].floorshade-g_sp->shade)>>1;
353 }
354 }
355 return;
356 }
357
358 moveptr = (long *)g_t[1];
359
360 if(a&geth) g_sp->xvel += (*moveptr-g_sp->xvel)>>1;
361 if(a&getv) g_sp->zvel += ((*(moveptr+1)<<4)-g_sp->zvel)>>1;
362
363 if(a&dodgebullet)
364 dodge(g_sp);
365
366 if(g_sp->picnum != APLAYER)
367 alterang(a);
368
369 if(g_sp->xvel > -6 && g_sp->xvel < 6 ) g_sp->xvel = 0;
370
371 a = badguy(g_sp);
372
373 if(g_sp->xvel || g_sp->zvel)
374 {
375 if(a)
376 {
377 if( g_sp->picnum == DRONE && g_sp->extra > 0)
378 {
379 if( g_sp->zvel > 0 )
380 {
381 hittype[g_i].floorz = l = getflorzofslope(g_sp->sectnum,g_sp->x,g_sp->y);
382 #ifdef RRRA
383 if( g_sp->z > (l-(28<<8)) )
384 g_sp->z = l-(28<<8);
385 #else
386 if( g_sp->z > (l-(30<<8)) )
387 g_sp->z = l-(30<<8);
388 #endif
389 }
390 else
391 {
392 hittype[g_i].ceilingz = l = getceilzofslope(g_sp->sectnum,g_sp->x,g_sp->y);
393 if( (g_sp->z-l) < (50<<8) )
394 {
395 g_sp->z = l+(50<<8);
396 g_sp->zvel = 0;
397 }
398 }
399 }
400 if(g_sp->zvel > 0 && hittype[g_i].floorz < g_sp->z)
401 g_sp->z = hittype[g_i].floorz;
402 if( g_sp->zvel < 0)
403 {
404 l = getceilzofslope(g_sp->sectnum,g_sp->x,g_sp->y);
405 if( (g_sp->z-l) < (66<<8) )
406 {
407 g_sp->z = l+(66<<8);
408 g_sp->zvel >>= 1;
409 }
410 }
411 }
412 else if(g_sp->picnum == APLAYER)
413 if( (g_sp->z-hittype[g_i].ceilingz) < (32<<8) )
414 g_sp->z = hittype[g_i].ceilingz+(32<<8);
415
416 daxvel = g_sp->xvel;
417 angdif = g_sp->ang;
418
419 if( a )
420 {
421 if( g_x < 960 && g_sp->xrepeat > 16 )
422 {
423
424 daxvel = -(1024-g_x);
425 angdif = getangle(ps[g_p].posx-g_sp->x,ps[g_p].posy-g_sp->y);
426
427 if(g_x < 512)
428 {
429 ps[g_p].posxv = 0;
430 ps[g_p].posyv = 0;
431 }
432 else
433 {
434 ps[g_p].posxv = mulscale(ps[g_p].posxv,rdnkfriction-0x2000,16);
435 ps[g_p].posyv = mulscale(ps[g_p].posyv,rdnkfriction-0x2000,16);
436 }
437 }
438 #ifdef RRRA
439 else if(g_sp->picnum != DRONE && g_sp->picnum != SHARK && g_sp->picnum != UFO1)
440 #else
441 else if(g_sp->picnum != DRONE && g_sp->picnum != SHARK && g_sp->picnum != UFO1
442 && g_sp->picnum != UFO2 && g_sp->picnum != UFO3 && g_sp->picnum != UFO4 && g_sp->picnum != UFO5)
443 #endif
444 {
445 if( hittype[g_i].bposz != g_sp->z || ( ud.multimode < 2 && ud.player_skill < 2 ) )
446 {
447 if( (g_t[0]&1) || ps[g_p].actorsqu == g_i ) return;
448 else daxvel <<= 1;
449 }
450 else
451 {
452 if( (g_t[0]&3) || ps[g_p].actorsqu == g_i ) return;
453 else daxvel <<= 2;
454 }
455 }
456 }
457 #ifdef RRRA
458 if (sector[g_sp->sectnum].lotag != 1)
459 {
460 switch (g_sp->picnum)
461 {
462 case MINIONBOAT:
463 case HULKBOAT:
464 case CHEERBOAT:
465 daxvel >>= 1;
466 break;
467 }
468 }
469 else if (sector[g_sp->sectnum].lotag == 1)
470 {
471 switch (g_sp->picnum)
472 {
473 case BIKERB:
474 case BIKERBV2:
475 case CHEERB:
476 daxvel >>= 1;
477 break;
478 }
479 }
480 #endif
481
482 hittype[g_i].movflag = movesprite(g_i,
483 (daxvel*(sintable[(angdif+512)&2047]))>>14,
484 (daxvel*(sintable[angdif&2047]))>>14,g_sp->zvel,CLIPMASK0);
485 }
486
487 if( a )
488 {
489 if (sector[g_sp->sectnum].ceilingstat&1)
490 {
491 if(shadedsector[g_sp->sectnum] == 1)
492 {
493 g_sp->shade += (16-g_sp->shade)>>1;
494 }
495 else
496 {
497 g_sp->shade += (sector[g_sp->sectnum].ceilingshade-g_sp->shade)>>1;
498 }
499 }
500 else g_sp->shade += (sector[g_sp->sectnum].floorshade-g_sp->shade)>>1;
501
502 if( sector[g_sp->sectnum].floorpicnum == MIRROR )
503 deletesprite(g_i);
504 }
505 }
506
507 char parse(void);
508
parseifelse(long condition)509 void parseifelse(long condition)
510 {
511 if( condition )
512 {
513 insptr+=2;
514 parse();
515 }
516 else
517 {
518 insptr = (long *) *(insptr+1);
519 if(*insptr == 10)
520 {
521 insptr+=2;
522 parse();
523 }
524 }
525 }
526
527 // long *it = 0x00589a04;
528
parse(void)529 char parse(void)
530 {
531 long j, l, s, nextj;
532
533 if(killit_flag) return 1;
534
535 // if(*it == 1668249134L) gameexit("\nERR");
536
537 switch(*insptr)
538 {
539 case 3:
540 insptr++;
541 parseifelse( rnd(*insptr));
542 break;
543 case 45:
544
545 if(g_x > 1024)
546 {
547 short temphit, sclip, angdif;
548
549 if( badguy(g_sp) && g_sp->xrepeat > 56 )
550 {
551 sclip = 3084;
552 angdif = 48;
553 }
554 else
555 {
556 sclip = 768;
557 angdif = 16;
558 }
559
560 j = hitasprite(g_i,&temphit);
561 if(j == (1<<30))
562 {
563 parseifelse(1);
564 break;
565 }
566 if(j > sclip)
567 {
568 if(temphit >= 0 && sprite[temphit].picnum == g_sp->picnum)
569 j = 0;
570 else
571 {
572 g_sp->ang += angdif;j = hitasprite(g_i,&temphit);g_sp->ang -= angdif;
573 if(j > sclip)
574 {
575 if(temphit >= 0 && sprite[temphit].picnum == g_sp->picnum)
576 j = 0;
577 else
578 {
579 g_sp->ang -= angdif;j = hitasprite(g_i,&temphit);g_sp->ang += angdif;
580 if( j > 768 )
581 {
582 if(temphit >= 0 && sprite[temphit].picnum == g_sp->picnum)
583 j = 0;
584 else j = 1;
585 }
586 else j = 0;
587 }
588 }
589 else j = 0;
590 }
591 }
592 else j = 0;
593 }
594 else j = 1;
595
596 parseifelse(j);
597 break;
598 case 91:
599 j = cansee(g_sp->x,g_sp->y,g_sp->z-((TRAND&41)<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz/*-((TRAND&41)<<8)*/,sprite[ps[g_p].i].sectnum);
600 parseifelse(j);
601 if( j ) hittype[g_i].timetosleep = SLEEPTIME;
602 break;
603 case 110:
604 j = cansee(g_sp->x,g_sp->y,g_sp->z,g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz,sprite[ps[g_p].i].sectnum);
605 parseifelse(j);
606 if( j ) hittype[g_i].timetosleep = SLEEPTIME;
607 break;
608
609 case 49:
610 parseifelse(hittype[g_i].actorstayput == -1);
611 break;
612 case 5:
613 {
614 spritetype *s;
615 short sect;
616
617 s = &sprite[ps[g_p].i];
618
619 j = cansee(g_sp->x,g_sp->y,g_sp->z-(TRAND&((47<<8))),g_sp->sectnum,
620 s->x,s->y,s->z-(28<<8),s->sectnum);
621
622 if(j == 0)
623 {
624 if( ( klabs(hittype[g_i].lastvx-g_sp->x)+klabs(hittype[g_i].lastvy-g_sp->y) ) <
625 ( klabs(hittype[g_i].lastvx-s->x)+klabs(hittype[g_i].lastvy-s->y) ) )
626 j = 0;
627
628 if( j == 0 )
629 {
630 j = furthestcanseepoint(g_i,s,&hittype[g_i].lastvx,&hittype[g_i].lastvy);
631
632 if(j == -1) j = 0;
633 else j = 1;
634 }
635 }
636 else
637 {
638 hittype[g_i].lastvx = s->x;
639 hittype[g_i].lastvy = s->y;
640 }
641
642 if( j == 1 && ( g_sp->statnum == 1 || g_sp->statnum == 6 ) )
643 hittype[g_i].timetosleep = SLEEPTIME;
644
645 parseifelse(j == 1);
646 break;
647 }
648
649 case 6:
650 parseifelse(ifhitbyweapon(g_i) >= 0);
651 break;
652 case 27:
653 parseifelse( ifsquished(g_i, g_p) == 1);
654 break;
655 case 26:
656 {
657 j = g_sp->extra;
658 if(g_sp->picnum == APLAYER)
659 j--;
660 parseifelse(j < 0);
661 }
662 break;
663 case 24:
664 insptr++;
665 g_t[5] = *insptr;
666 g_t[4] = *(long *)(g_t[5]); // Action
667 g_t[1] = *(long *)(g_t[5]+4); // move
668 g_sp->hitag = *(long *)(g_t[5]+8); // Ai
669 g_t[0] = g_t[2] = g_t[3] = 0;
670 if(g_sp->hitag&random_angle)
671 g_sp->ang = TRAND&2047;
672 insptr++;
673 break;
674 case 7:
675 insptr++;
676 g_t[2] = 0;
677 g_t[3] = 0;
678 g_t[4] = *insptr;
679 insptr++;
680 break;
681
682 case 8:
683 insptr++;
684 parseifelse(g_x < *insptr);
685 if(g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0)
686 hittype[g_i].timetosleep = SLEEPTIME;
687 break;
688 case 9:
689 insptr++;
690 parseifelse(g_x > *insptr);
691 if(g_x > MAXSLEEPDIST && hittype[g_i].timetosleep == 0)
692 hittype[g_i].timetosleep = SLEEPTIME;
693 break;
694 case 10:
695 insptr = (long *) *(insptr+1);
696 break;
697 case 100:
698 insptr++;
699 g_sp->extra += *insptr;
700 insptr++;
701 break;
702 case 11:
703 insptr++;
704 g_sp->extra = *insptr;
705 insptr++;
706 break;
707 #ifdef RRRA
708 case 133:
709 switch (TRAND&1)
710 {
711 case 0:
712 g_sp->ang = (+512+g_sp->ang+(TRAND&511))&2047;
713 break;
714 case 1:
715 g_sp->ang = (-512+g_sp->ang-(TRAND&511))&2047;
716 break;
717 }
718 insptr++;
719 break;
720 case 136:
721 word_119BD8++;
722 switch (word_119BD8)
723 {
724 default:
725 break;
726 case 1:
727 spawn(g_i,PIG);
728 break;
729 case 2:
730 spawn(g_i,MINION);
731 break;
732 case 3:
733 spawn(g_i,CHEER);
734 break;
735 case 4:
736 spawn(g_i,VIXEN);
737 operateactivators(666,ps[g_p].i);
738 break;
739 }
740 insptr++;
741 break;
742 case 146:
743 g_sp->ang = TRAND&2047;
744 g_sp->xvel = 25;
745 insptr++;
746 break;
747 case 137:
748 operateactivators(667,ps[g_p].i);
749 insptr++;
750 break;
751 case 138:
752 if (word_119BDA)
753 {
754 word_119BDA--;
755 spawn(g_i, RABBIT);
756 }
757 insptr++;
758 break;
759 case 139:
760 if (g_sp->pal == 31)
761 earthquaketime = 4;
762 else if (g_sp->pal == 32)
763 earthquaketime = 6;
764 insptr++;
765 break;
766 case 143:
767 if (word_119BDC == 0)
768 {
769 short rnum = (TRAND&3)+1;
770 if (rnum == 4)
771 {
772 spritesound(262, g_i);
773 word_119BDC = 262;
774 }
775 else if (rnum == 1)
776 {
777 spritesound(272, g_i);
778 word_119BDC = 272;
779 }
780 else if (rnum == 2)
781 {
782 spritesound(273, g_i);
783 word_119BDC = 273;
784 }
785 else
786 {
787 spritesound(273, g_i);
788 word_119BDC = 273;
789 }
790 }
791 else
792 {
793 if (Sound[word_119BDC].num == 0)
794 spritesound(word_119BDC, g_i);
795 }
796 insptr++;
797 break;
798 case 144:
799 if (Sound[411].num == 0)
800 spritesound(411, g_i);
801 insptr++;
802 break;
803 #endif
804 case 94:
805 insptr++;
806
807 if(ud.coop >= 1 && ud.multimode > 1)
808 {
809 if(*insptr == 0)
810 {
811 for(j=0;j < ps[g_p].weapreccnt;j++)
812 if( ps[g_p].weaprecs[j] == g_sp->picnum )
813 break;
814
815 parseifelse(j < ps[g_p].weapreccnt && g_sp->owner == g_i);
816 }
817 else if(ps[g_p].weapreccnt < 256)
818 {
819 ps[g_p].weaprecs[ps[g_p].weapreccnt++] = g_sp->picnum;
820 parseifelse(g_sp->owner == g_i);
821 }
822 }
823 else parseifelse(0);
824 break;
825 case 95:
826 insptr++;
827 if(g_sp->picnum == APLAYER)
828 g_sp->pal = ps[g_sp->yvel].palookup;
829 else g_sp->pal = hittype[g_i].tempang;
830 hittype[g_i].tempang = 0;
831 break;
832 case 104:
833 insptr++;
834 checkweapons(&ps[g_sp->yvel]);
835 break;
836 case 106:
837 insptr++;
838 break;
839 case 97:
840 insptr++;
841 if(Sound[g_sp->yvel].num == 0)
842 spritesound(g_sp->yvel,g_i);
843 break;
844 case 96:
845 insptr++;
846
847 if( ud.multimode > 1 && g_sp->picnum == APLAYER )
848 {
849 if(ps[otherp].quick_kick == 0)
850 ps[otherp].quick_kick = 14;
851 }
852 else if(g_sp->picnum != APLAYER && ps[g_p].quick_kick == 0)
853 ps[g_p].quick_kick = 14;
854 break;
855 case 28:
856 insptr++;
857
858 j = ((*insptr)-g_sp->xrepeat)<<1;
859 g_sp->xrepeat += ksgn(j);
860
861 insptr++;
862
863 if( ( g_sp->picnum == APLAYER && g_sp->yrepeat < 36 ) || *insptr < g_sp->yrepeat || ((g_sp->yrepeat*(tilesizy[g_sp->picnum]+8))<<2) < (hittype[g_i].floorz - hittype[g_i].ceilingz) )
864 {
865 j = ((*insptr)-g_sp->yrepeat)<<1;
866 if( klabs(j) ) g_sp->yrepeat += ksgn(j);
867 }
868
869 insptr++;
870
871 break;
872 case 99:
873 insptr++;
874 g_sp->xrepeat = (char) *insptr;
875 insptr++;
876 g_sp->yrepeat = (char) *insptr;
877 insptr++;
878 break;
879 case 13:
880 insptr++;
881 shoot(g_i,(short)*insptr);
882 insptr++;
883 break;
884 case 127:
885 insptr++;
886 parseifelse((short)*insptr == ambientlotag[g_sp->ang]);
887 break;
888 case 128:
889 insptr++;
890 if (*insptr == 0)
891 parseifelse(ambienthitag[g_sp->ang] > g_x);
892 else if (*insptr == 1)
893 parseifelse(ambienthitag[g_sp->ang] < g_x);
894 insptr++;
895 break;
896 case 126:
897 insptr++;
898 spritesound(ambientlotag[g_sp->ang],g_i);
899 break;
900 case 125:
901 insptr++;
902 if (Sound[ambientlotag[g_sp->ang]].num == 0)
903 spritesound(ambientlotag[g_sp->ang],g_i);
904 break;
905 case 87:
906 insptr++;
907 if( Sound[*insptr].num == 0 )
908 spritesound((short) *insptr,g_i);
909 insptr++;
910 break;
911 case 89:
912 insptr++;
913 if( Sound[*insptr].num > 0 )
914 stopsound((short)*insptr);
915 insptr++;
916 break;
917 case 92:
918 insptr++;
919 if(g_p == screenpeek || ud.coop==1)
920 spritesound((short) *insptr,ps[screenpeek].i);
921 insptr++;
922 break;
923 case 124:
924 insptr++;
925 #ifdef RRRA
926 if (g_sp->pal != 105)
927 {
928 ps[myconnectindex].gm = MODE_EOL;
929 ud.level_number++;
930 if (ud.level_number > 6)
931 ud.level_number = 0;
932 ud.m_level_number = ud.level_number;
933 }
934 #else
935 ps[myconnectindex].gm = MODE_EOL;
936 ud.level_number++;
937 if (ud.level_number > 6)
938 ud.level_number = 0;
939 ud.m_level_number = ud.level_number;
940 #endif
941 break;
942 #ifdef RRRA
943 case 141:
944 insptr++;
945 ps[myconnectindex].raat609 = 150;
946 break;
947 #endif
948 case 119:
949 insptr++;
950 parseifelse(g_sp->extra > (short)*insptr);
951 break;
952 case 120:
953 insptr++;
954 parseifelse(g_sp->extra < (short)*insptr);
955 break;
956 case 15:
957 insptr++;
958 spritesound((short) *insptr,g_i);
959 insptr++;
960 break;
961 case 84:
962 insptr++;
963 ps[g_p].tipincs = 26;
964 break;
965 case 112:
966 if (g_sp->filler == 1)
967 {
968 j = 1;
969 g_sp->filler++;
970 }
971 else
972 j = 0;
973 parseifelse(j > 0);
974 break;
975 case 111:
976 if (g_sp->filler == 1)
977 {
978 j = 1;
979 g_sp->filler++;
980 }
981 else
982 j = 0;
983 parseifelse(j > 0);
984 break;
985 case 123:
986 insptr++;
987 j = headspritesect[g_sp->sectnum];
988 while (j != -1)
989 {
990 nextj = nextspritesect[j];
991 if (sprite[j].picnum == DESTRUCTO)
992 {
993 hittype[j].picnum = SHOTSPARK1;
994 hittype[j].extra = 1;
995 }
996 j = nextj;
997 }
998 break;
999 case 16:
1000 insptr++;
1001 g_sp->xoffset = 0;
1002 g_sp->yoffset = 0;
1003 // if(!gotz)
1004 {
1005 long c;
1006 short sphit;
1007
1008 sphit = 0;
1009 #ifdef RRRA
1010 if (sector[g_sp->sectnum].lotag == 801)
1011 {
1012 if (g_sp->picnum == ROCK)
1013 {
1014 spawn(g_i, ROCK2);
1015 spawn(g_i, ROCK2);
1016 deletesprite(g_i);
1017 }
1018 }
1019 else if (sector[g_sp->sectnum].lotag == 802)
1020 {
1021 if (g_sp->picnum != APLAYER && badguy(g_sp) && g_sp->z == hittype[g_i].floorz-FOURSLEIGHT)
1022 {
1023 guts(g_sp, JIBS6, 5, g_p);
1024 spritesound(SQUISHED, g_i);
1025 deletesprite(g_i);
1026 }
1027 }
1028 else if (sector[g_sp->sectnum].lotag == 803)
1029 {
1030 if (g_sp->picnum == ROCK2)
1031 deletesprite(g_i);
1032 }
1033 else
1034 #endif
1035 if(sector[g_sp->sectnum].lotag == 800)
1036 {
1037 if (g_sp->picnum == 40)
1038 {
1039 deletesprite(g_i);
1040 break;
1041 }
1042 #ifdef RRRA
1043 if (g_sp->picnum != APLAYER && (badguy(g_sp) || g_sp->picnum == HEN || g_sp->picnum == COW || g_sp->picnum == PIG || g_sp->picnum == DOGRUN || g_sp->picnum == RABBIT) && g_sp->filler < 128)
1044 #else
1045 if (g_sp->picnum != APLAYER && (badguy(g_sp) || g_sp->picnum == HEN || g_sp->picnum == COW || g_sp->picnum == PIG || g_sp->picnum == DOGRUN) && g_sp->filler < 128)
1046 #endif
1047 {
1048 g_sp->z = hittype[g_i].floorz-FOURSLEIGHT;
1049 g_sp->zvel = 8000;
1050 g_sp->extra = 0;
1051 g_sp->filler++;
1052 sphit = 1;
1053 }
1054 else if (g_sp->picnum != APLAYER)
1055 {
1056 if (!g_sp->filler)
1057 deletesprite(g_i);
1058 break;
1059 }
1060 hittype[g_i].picnum = SHOTSPARK1;
1061 hittype[g_i].extra = 1;
1062 }
1063 #ifdef RRRA
1064 else if (sector[g_sp->sectnum].floorpicnum == RRTILE7820 || sector[g_sp->sectnum].floorpicnum == RRTILE7768)
1065 {
1066 if (g_sp->picnum != MINION && g_sp->pal != 19)
1067 {
1068 if ((TRAND&3) == 1)
1069 {
1070 hittype[g_i].picnum = SHOTSPARK1;
1071 hittype[g_i].extra = 5;
1072 }
1073 }
1074 }
1075 #endif
1076 if( floorspace(g_sp->sectnum) )
1077 c = 0;
1078 else
1079 {
1080 if( ceilingspace(g_sp->sectnum) || sector[g_sp->sectnum].lotag == 2)
1081 c = gc/6;
1082 else c = gc;
1083 }
1084
1085 if( hittype[g_i].cgg <= 0 || (sector[g_sp->sectnum].floorstat&2) )
1086 {
1087 getglobalz(g_i);
1088 hittype[g_i].cgg = 6;
1089 }
1090 else hittype[g_i].cgg --;
1091
1092 if( g_sp->z < (hittype[g_i].floorz-FOURSLEIGHT) )
1093 {
1094 g_sp->zvel += c;
1095 g_sp->z+=g_sp->zvel;
1096
1097 if(g_sp->zvel > 6144) g_sp->zvel = 6144;
1098 }
1099 else
1100 {
1101 g_sp->z = hittype[g_i].floorz - FOURSLEIGHT;
1102
1103 if( badguy(g_sp) || ( g_sp->picnum == APLAYER && g_sp->owner >= 0) )
1104 {
1105
1106 if( g_sp->zvel > 3084 && g_sp->extra <= 1)
1107 {
1108 if(g_sp->pal != 1 && g_sp->picnum != DRONE)
1109 {
1110 if(g_sp->picnum == APLAYER && g_sp->extra > 0)
1111 goto SKIPJIBS;
1112 if (sphit)
1113 {
1114 guts(g_sp,JIBS6,5,g_p);
1115 spritesound(69,g_i);
1116 }
1117 else
1118 {
1119 guts(g_sp,JIBS6,15,g_p);
1120 spritesound(69,g_i);
1121 spawn(g_i,BLOODPOOL);
1122 }
1123 }
1124
1125 SKIPJIBS:
1126
1127 hittype[g_i].picnum = SHOTSPARK1;
1128 hittype[g_i].extra = 1;
1129 g_sp->zvel = 0;
1130 }
1131 else if(g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != 1)
1132 {
1133
1134 j = g_sp->sectnum;
1135 pushmove(&g_sp->x,&g_sp->y,&g_sp->z,&j,128L,(4L<<8),(4L<<8),CLIPMASK0);
1136 if(j != g_sp->sectnum && j >= 0 && j < MAXSECTORS)
1137 changespritesect(g_i,j);
1138
1139 spritesound(158,g_i);
1140 }
1141 }
1142 if(sector[g_sp->sectnum].lotag == 1)
1143 switch (g_sp->picnum)
1144 {
1145 #ifdef RRRA
1146 case HULKBOAT:
1147 g_sp->z += (12<<8);
1148 break;
1149 case MINIONBOAT:
1150 g_sp->z += (3<<8);
1151 break;
1152 case CHEERBOAT:
1153 case EMPTYBOAT:
1154 g_sp->z += (6<<8);
1155 break;
1156 case DRONE:
1157 break;
1158 case BIKER:
1159 g_sp->z += (24<<8);
1160 break;
1161 #else
1162 case DRONE:
1163 break;
1164 #endif
1165 default:
1166 g_sp->z += (24<<8);
1167 break;
1168 }
1169 else g_sp->zvel = 0;
1170 }
1171 }
1172 break;
1173 case 4:
1174 case 12:
1175 case 18:
1176 return 1;
1177 case 30:
1178 insptr++;
1179 return 1;
1180 case 2:
1181 insptr++;
1182 if( ps[g_p].ammo_amount[*insptr] >= max_ammo_amount[*insptr] )
1183 {
1184 killit_flag = 2;
1185 break;
1186 }
1187 addammo( *insptr, &ps[g_p], *(insptr+1) );
1188 if(ps[g_p].curr_weapon == KNEE_WEAPON)
1189 if( ps[g_p].gotweapon[*insptr] )
1190 addweapon( &ps[g_p], *insptr );
1191 insptr += 2;
1192 break;
1193 case 86:
1194 insptr++;
1195 lotsofmoney(g_sp,*insptr);
1196 insptr++;
1197 break;
1198 case 102:
1199 insptr++;
1200 lotsofmail(g_sp,*insptr);
1201 insptr++;
1202 break;
1203 case 105:
1204 insptr++;
1205 hittype[g_i].timetosleep = (short)*insptr;
1206 insptr++;
1207 break;
1208 case 103:
1209 insptr++;
1210 lotsofpaper(g_sp,*insptr);
1211 insptr++;
1212 break;
1213 case 88:
1214 insptr++;
1215 if (g_sp->filler < 1)
1216 {
1217 if (actorfella(g_sp))
1218 ps[g_p].actors_killed += *insptr;
1219 }
1220 else if (g_sp->filler == 128)
1221 {
1222 if (actorfella(g_sp))
1223 ps[g_p].actors_killed += *insptr;
1224 }
1225 hittype[g_i].actorstayput = -1;
1226 insptr++;
1227 break;
1228 case 93:
1229 insptr++;
1230 spriteglass(g_i,*insptr);
1231 insptr++;
1232 break;
1233 case 22:
1234 insptr++;
1235 killit_flag = 1;
1236 break;
1237 case 23:
1238 insptr++;
1239 if( ps[g_p].gotweapon[*insptr] == 0 ) addweapon( &ps[g_p], *insptr );
1240 else if( ps[g_p].ammo_amount[*insptr] >= max_ammo_amount[*insptr] )
1241 {
1242 killit_flag = 2;
1243 break;
1244 }
1245 addammo( *insptr, &ps[g_p], *(insptr+1) );
1246 if(ps[g_p].curr_weapon == KNEE_WEAPON)
1247 if( ps[g_p].gotweapon[*insptr] )
1248 addweapon( &ps[g_p], *insptr );
1249 insptr+=2;
1250 break;
1251 case 68:
1252 insptr++;
1253 printf("%ld\n",*insptr);
1254 insptr++;
1255 break;
1256 case 69:
1257 insptr++;
1258 ps[g_p].timebeforeexit = *insptr;
1259 ps[g_p].customexitsound = -1;
1260 ud.eog = 1;
1261 insptr++;
1262 break;
1263 case 113:
1264 insptr++;
1265 ps[g_p].drink_amt += *insptr;
1266 j = sprite[ps[g_p].i].extra;
1267 if (j > 0)
1268 j += *insptr;
1269 if (j > max_player_health * 2)
1270 j = max_player_health * 2;
1271 if (j < 0)
1272 j = 0;
1273
1274 if(ud.god == 0)
1275 {
1276 if(*insptr > 0)
1277 {
1278 if( ( j - *insptr ) < (max_player_health>>2) &&
1279 j >= (max_player_health>>2) )
1280 spritesound(DUKE_GOTHEALTHATLOW,ps[g_p].i);
1281
1282 ps[g_p].last_extra = j;
1283 }
1284
1285 sprite[ps[g_p].i].extra = j;
1286 }
1287 if (ps[g_p].drink_amt > 100)
1288 ps[g_p].drink_amt = 100;
1289 ps[g_p].at596 = 1;
1290
1291 if (sprite[ps[g_p].i].extra >= max_player_health)
1292 {
1293 sprite[ps[g_p].i].extra = max_player_health;
1294 ps[g_p].last_extra = max_player_health;
1295 }
1296 insptr++;
1297 break;
1298 case 117:
1299 insptr++;
1300 movesprite(g_i,sintable[(g_sp->ang+1024)&2047]>>10,sintable[(g_sp->ang+512)&2047]>>10,g_sp->zvel,CLIPMASK0);
1301 break;
1302 case 118:
1303 insptr++;
1304 movesprite(g_i,sintable[(g_sp->ang-0)&2047]>>10,sintable[(g_sp->ang-512)&2047]>>10,g_sp->zvel,CLIPMASK0);
1305 break;
1306 case 116:
1307 insptr++;
1308 ps[g_p].posz = sector[sprite[ps[g_p].i].sectnum].ceilingz;
1309 sprite[ps[g_p].i].z = ps[g_p].posz;
1310 break;
1311 case 115:
1312 insptr++;
1313 {
1314 spritetype *js;
1315 short lotag, hitag;
1316 short k, jj;
1317 short wi, wj;
1318 short spr;
1319 short nextk, nextjj;
1320 short wallstart2, wallend2;
1321 short sectnum;
1322 short wallstart, wallend;
1323
1324 hitag = 0;
1325 k = headspritesect[g_sp->sectnum];
1326 while (k != -1)
1327 {
1328 nextk = nextspritesect[k];
1329 if (sprite[k].picnum == RRTILE63)
1330 {
1331 lotag = sprite[k].lotag;
1332 spr = k;
1333 if (sprite[k].hitag)
1334 hitag = sprite[k].hitag;
1335 }
1336 k = nextk;
1337 }
1338 jj = headspritestat[100];
1339 while (jj >= 0)
1340 {
1341 nextjj = nextspritestat[jj];
1342 js = &sprite[jj];
1343 if (hitag)
1344 if (hitag == js->hitag)
1345 {
1346 k = headspritesect[js->sectnum];
1347 while (k != -1)
1348 {
1349 nextk = nextspritesect[k];
1350 if (sprite[k].picnum == DESTRUCTO)
1351 {
1352 hittype[k].picnum = SHOTSPARK1;
1353 hittype[k].extra = 1;
1354 }
1355 k = nextk;
1356 }
1357 }
1358 if (sprite[spr].sectnum != js->sectnum)
1359 if (lotag == js->lotag)
1360 {
1361 sectnum = sprite[spr].sectnum;
1362 wallstart = sector[sectnum].wallptr;
1363 wallend = wallstart+sector[sectnum].wallnum;
1364 wallstart2 = sector[js->sectnum].wallptr;
1365 wallend2 = wallstart2+sector[js->sectnum].wallnum;
1366 for (wi = wallstart,wj = wallstart2; wi < wallend; wi++,wj++)
1367 {
1368 wall[wi].picnum = wall[wj].picnum;
1369 wall[wi].overpicnum = wall[wj].overpicnum;
1370 wall[wi].shade = wall[wj].shade;
1371 wall[wi].xrepeat = wall[wj].xrepeat;
1372 wall[wi].yrepeat = wall[wj].yrepeat;
1373 wall[wi].xpanning = wall[wj].xpanning;
1374 wall[wi].ypanning = wall[wj].ypanning;
1375 #ifdef RRRA
1376 if (wall[wi].nextwall != -1)
1377 {
1378 wall[wi].cstat = 0;
1379 wall[wall[wi].nextwall].cstat = 0;
1380 }
1381 #endif
1382 }
1383 sector[sectnum].floorz = sector[js->sectnum].floorz;
1384 sector[sectnum].ceilingz = sector[js->sectnum].ceilingz;
1385 sector[sectnum].ceilingstat = sector[js->sectnum].ceilingstat;
1386 sector[sectnum].floorstat = sector[js->sectnum].floorstat;
1387 sector[sectnum].ceilingpicnum = sector[js->sectnum].ceilingpicnum;
1388 sector[sectnum].ceilingheinum = sector[js->sectnum].ceilingheinum;
1389 sector[sectnum].ceilingshade = sector[js->sectnum].ceilingshade;
1390 sector[sectnum].ceilingpal = sector[js->sectnum].ceilingpal;
1391 sector[sectnum].ceilingxpanning = sector[js->sectnum].ceilingxpanning;
1392 sector[sectnum].ceilingypanning = sector[js->sectnum].ceilingypanning;
1393 sector[sectnum].floorpicnum = sector[js->sectnum].floorpicnum;
1394 sector[sectnum].floorheinum = sector[js->sectnum].floorheinum;
1395 sector[sectnum].floorshade = sector[js->sectnum].floorshade;
1396 sector[sectnum].floorpal = sector[js->sectnum].floorpal;
1397 sector[sectnum].floorxpanning = sector[js->sectnum].floorxpanning;
1398 sector[sectnum].floorypanning = sector[js->sectnum].floorypanning;
1399 sector[sectnum].visibility = sector[js->sectnum].visibility;
1400 sector[sectnum].filler = sector[js->sectnum].filler;
1401 sector[sectnum].lotag = sector[js->sectnum].lotag;
1402 sector[sectnum].hitag = sector[js->sectnum].hitag;
1403 sector[sectnum].extra = sector[js->sectnum].extra;
1404 }
1405 jj = nextjj;
1406 }
1407 k = headspritesect[g_sp->sectnum];
1408 while (k != -1)
1409 {
1410 nextk = nextspritesect[k];
1411 switch (sprite[k].picnum)
1412 {
1413 case DESTRUCTO:
1414 case RRTILE63:
1415 case TORNADO:
1416 case APLAYER:
1417 case COOT:
1418 break;
1419 default:
1420 deletesprite(k);
1421 break;
1422 }
1423 k = nextk;
1424 }
1425 }
1426 break;
1427 case 114:
1428 insptr++;
1429 ps[g_p].eat += *insptr;
1430 if (ps[g_p].eat > 100)
1431 {
1432 ps[g_p].eat = 100;
1433 }
1434 ps[g_p].drink_amt -= *insptr;
1435 if (ps[g_p].drink_amt < 0)
1436 ps[g_p].drink_amt = 0;
1437 j = sprite[ps[g_p].i].extra;
1438 if (g_sp->picnum != ATOMICHEALTH)
1439 {
1440 if (j > max_player_health && *insptr > 0)
1441 {
1442 insptr++;
1443 break;
1444 }
1445 else
1446 {
1447 if (j > 0)
1448 j += (*insptr)*3;
1449 if ( j > max_player_health && *insptr > 0 )
1450 j = max_player_health;
1451 }
1452 }
1453 else
1454 {
1455 if( j > 0 )
1456 j += *insptr;
1457 if ( j > (max_player_health<<1) )
1458 j = (max_player_health<<1);
1459 }
1460
1461 if(j < 0) j = 0;
1462
1463 if(ud.god == 0)
1464 {
1465 if(*insptr > 0)
1466 {
1467 if( ( j - *insptr ) < (max_player_health>>2) &&
1468 j >= (max_player_health>>2) )
1469 spritesound(229,ps[g_p].i);
1470
1471 ps[g_p].last_extra = j;
1472 }
1473
1474 sprite[ps[g_p].i].extra = j;
1475 }
1476
1477 insptr++;
1478 break;
1479 case 25:
1480 insptr++;
1481
1482 j = sprite[ps[g_p].i].extra;
1483
1484 if(g_sp->picnum != ATOMICHEALTH)
1485 {
1486 if( j > max_player_health && *insptr > 0 )
1487 {
1488 insptr++;
1489 break;
1490 }
1491 else
1492 {
1493 if(j > 0)
1494 j += *insptr;
1495 if ( j > max_player_health && *insptr > 0 )
1496 j = max_player_health;
1497 }
1498 }
1499 else
1500 {
1501 if( j > 0 )
1502 j += *insptr;
1503 if ( j > (max_player_health<<1) )
1504 j = (max_player_health<<1);
1505 }
1506
1507 if(j < 0) j = 0;
1508
1509 if(ud.god == 0)
1510 {
1511 if(*insptr > 0)
1512 {
1513 if( ( j - *insptr ) < (max_player_health>>2) &&
1514 j >= (max_player_health>>2) )
1515 spritesound(229,ps[g_p].i);
1516
1517 ps[g_p].last_extra = j;
1518 }
1519
1520 sprite[ps[g_p].i].extra = j;
1521 }
1522
1523 insptr++;
1524 break;
1525 case 17:
1526 {
1527 long *tempscrptr;
1528
1529 tempscrptr = insptr+2;
1530
1531 insptr = (long *) *(insptr+1);
1532 while(1) if(parse()) break;
1533 insptr = tempscrptr;
1534 }
1535 break;
1536 case 29:
1537 insptr++;
1538 while(1) if(parse()) break;
1539 break;
1540 case 32:
1541 g_t[0]=0;
1542 insptr++;
1543 g_t[1] = *insptr;
1544 insptr++;
1545 g_sp->hitag = *insptr;
1546 insptr++;
1547 if(g_sp->hitag&random_angle)
1548 g_sp->ang = TRAND&2047;
1549 break;
1550 case 31:
1551 insptr++;
1552 if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
1553 spawn(g_i,*insptr);
1554 insptr++;
1555 break;
1556 case 33:
1557 insptr++;
1558 parseifelse( hittype[g_i].picnum == *insptr);
1559 break;
1560 case 21:
1561 insptr++;
1562 parseifelse(g_t[5] == *insptr);
1563 break;
1564 case 34:
1565 insptr++;
1566 parseifelse(g_t[4] == *insptr);
1567 break;
1568 case 35:
1569 insptr++;
1570 parseifelse(g_t[2] >= *insptr);
1571 break;
1572 case 36:
1573 insptr++;
1574 g_t[2] = 0;
1575 break;
1576 case 37:
1577 {
1578 short dnum;
1579
1580 insptr++;
1581 dnum = *insptr;
1582 insptr++;
1583
1584 if(g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
1585 for(j=(*insptr)-1;j>=0;j--)
1586 {
1587 if(dnum == SCRAP1)
1588 s = 0;
1589 else s = (TRAND%3);
1590
1591 l = EGS(g_sp->sectnum,
1592 g_sp->x+(TRAND&255)-128,g_sp->y+(TRAND&255)-128,g_sp->z-(8<<8)-(TRAND&8191),
1593 dnum+s,g_sp->shade,32+(TRAND&15),32+(TRAND&15),
1594 TRAND&2047,(TRAND&127)+32,
1595 -(TRAND&2047),g_i,5);
1596 if(dnum == SCRAP1)
1597 sprite[l].yvel = weaponsandammosprites[j%14];
1598 else sprite[l].yvel = -1;
1599 sprite[l].pal = g_sp->pal;
1600 }
1601 insptr++;
1602 }
1603 break;
1604 case 52:
1605 insptr++;
1606 g_t[0] = (short) *insptr;
1607 insptr++;
1608 break;
1609 case 101:
1610 insptr++;
1611 g_sp->cstat |= (short)*insptr;
1612 insptr++;
1613 break;
1614 case 40:
1615 insptr++;
1616 g_sp->cstat = (short) *insptr;
1617 insptr++;
1618 break;
1619 #ifdef RRRA
1620 case 140:
1621 insptr++;
1622 g_sp->clipdist = (char)*insptr;
1623 insptr++;
1624 break;
1625 case 142:
1626 insptr++;
1627 g_sp->picnum = (short)*insptr;
1628 insptr++;
1629 break;
1630 #endif
1631 case 41:
1632 insptr++;
1633 parseifelse(g_t[1] == *insptr);
1634 break;
1635 case 42:
1636 insptr++;
1637
1638 if(ud.multimode < 2)
1639 {
1640 if( lastsavedpos >= 0 && ud.recstat != 2 )
1641 {
1642 ps[g_p].gm = MODE_MENU;
1643 KB_ClearKeyDown(sc_Space);
1644 cmenu(15000);
1645 }
1646 else ps[g_p].gm = MODE_RESTART;
1647 killit_flag = 2;
1648 }
1649 else
1650 {
1651 pickrandomspot(g_p);
1652 g_sp->x = hittype[g_i].bposx = ps[g_p].bobposx = ps[g_p].oposx = ps[g_p].posx;
1653 g_sp->y = hittype[g_i].bposy = ps[g_p].bobposy = ps[g_p].oposy =ps[g_p].posy;
1654 g_sp->z = hittype[g_i].bposy = ps[g_p].oposz =ps[g_p].posz;
1655 updatesector(ps[g_p].posx,ps[g_p].posy,&ps[g_p].cursectnum);
1656 setsprite(ps[g_p].i,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+PHEIGHT);
1657 g_sp->cstat = 257;
1658
1659 g_sp->shade = -12;
1660 g_sp->clipdist = 32;
1661 g_sp->xrepeat = 24;
1662 g_sp->yrepeat = 17;
1663 g_sp->owner = g_i;
1664 g_sp->xoffset = 0;
1665 g_sp->pal = ps[g_p].palookup;
1666
1667 ps[g_p].last_extra = g_sp->extra = max_player_health;
1668 ps[g_p].wantweaponfire = -1;
1669 ps[g_p].horiz = 100;
1670 ps[g_p].on_crane = -1;
1671 ps[g_p].frag_ps = g_p;
1672 ps[g_p].horizoff = 0;
1673 ps[g_p].opyoff = 0;
1674 ps[g_p].wackedbyactor = -1;
1675 ps[g_p].shield_amount = max_armour_amount;
1676 ps[g_p].dead_flag = 0;
1677 ps[g_p].pals_time = 0;
1678 ps[g_p].footprintcount = 0;
1679 ps[g_p].weapreccnt = 0;
1680 ps[g_p].fta = 0;
1681 ps[g_p].ftq = 0;
1682 ps[g_p].posxv = ps[g_p].posyv = 0;
1683
1684 ps[g_p].falling_counter = 0;
1685
1686 hittype[g_i].extra = -1;
1687 hittype[g_i].owner = g_i;
1688
1689 hittype[g_i].cgg = 0;
1690 hittype[g_i].movflag = 0;
1691 hittype[g_i].tempang = 0;
1692 hittype[g_i].actorstayput = -1;
1693 hittype[g_i].dispicnum = 0;
1694 hittype[g_i].owner = ps[g_p].i;
1695
1696 resetinventory(g_p);
1697 resetweapons(g_p);
1698
1699 cameradist = 0;
1700 cameraclock = totalclock;
1701 }
1702 setpal(&ps[g_p]);
1703
1704 break;
1705 case 130:
1706 parseifelse(ud.coop || numplayers > 2);
1707 break;
1708 case 129:
1709 parseifelse( klabs(g_sp->z-sector[g_sp->sectnum].floorz) < (32<<8) && sector[g_sp->sectnum].floorpicnum == 3073);
1710 break;
1711 case 43:
1712 parseifelse( klabs(g_sp->z-sector[g_sp->sectnum].floorz) < (32<<8) && sector[g_sp->sectnum].lotag == 1);
1713 break;
1714 #ifdef RRRA
1715 case 131:
1716 parseifelse(ps[g_p].MotoSpeed > 60);
1717 break;
1718 case 134:
1719 parseifelse(ps[g_p].OnMotorcycle == 1);
1720 break;
1721 case 135:
1722 parseifelse(ps[g_p].OnBoat == 1);
1723 break;
1724 case 145:
1725 g_sp->xrepeat--;
1726 g_sp->yrepeat--;
1727 parseifelse(g_sp->xrepeat <= 5);
1728 break;
1729 case 132:
1730 parseifelse(WindTime > 0);
1731 break;
1732 #endif
1733 case 44:
1734 parseifelse( sector[g_sp->sectnum].lotag == 2);
1735 break;
1736 case 46:
1737 insptr++;
1738 parseifelse(g_t[0] >= *insptr);
1739 break;
1740 case 53:
1741 insptr++;
1742 parseifelse(g_sp->picnum == *insptr);
1743 break;
1744 case 47:
1745 insptr++;
1746 g_t[0] = 0;
1747 break;
1748 case 48:
1749 insptr+=2;
1750 switch(*(insptr-1))
1751 {
1752 case 0:
1753 ps[g_p].steroids_amount = *insptr;
1754 ps[g_p].inven_icon = 2;
1755 break;
1756 case 1:
1757 ps[g_p].shield_amount += *insptr;// 100;
1758 if(ps[g_p].shield_amount > max_player_health)
1759 ps[g_p].shield_amount = max_player_health;
1760 break;
1761 case 2:
1762 ps[g_p].scuba_amount = *insptr;// 1600;
1763 ps[g_p].inven_icon = 6;
1764 break;
1765 case 3:
1766 ps[g_p].holoduke_amount = *insptr;// 1600;
1767 ps[g_p].inven_icon = 3;
1768 break;
1769 case 4:
1770 ps[g_p].jetpack_amount = *insptr;// 1600;
1771 ps[g_p].inven_icon = 4;
1772 break;
1773 case 6:
1774 switch(g_sp->lotag)
1775 {
1776 case 100: ps[g_p].keys[1] = 1;break;
1777 case 101: ps[g_p].keys[2] = 1;break;
1778 case 102: ps[g_p].keys[3] = 1;break;
1779 case 103: ps[g_p].keys[4] = 1;break;
1780 }
1781 break;
1782 case 7:
1783 ps[g_p].heat_amount = *insptr;
1784 ps[g_p].inven_icon = 5;
1785 break;
1786 case 9:
1787 ps[g_p].inven_icon = 1;
1788 ps[g_p].firstaid_amount = *insptr;
1789 break;
1790 case 10:
1791 ps[g_p].inven_icon = 7;
1792 ps[g_p].boot_amount = *insptr;
1793 break;
1794 }
1795 insptr++;
1796 break;
1797 case 50:
1798 hitradius(g_i,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5));
1799 insptr+=6;
1800 break;
1801 case 51:
1802 {
1803 insptr++;
1804
1805 l = *insptr;
1806 j = 0;
1807
1808 s = g_sp->xvel;
1809
1810 if( (l&8) && ps[g_p].on_ground && (sync[g_p].bits&2) )
1811 j = 1;
1812 else if( (l&16) && ps[g_p].jumping_counter == 0 && !ps[g_p].on_ground &&
1813 ps[g_p].poszv > 2048 )
1814 j = 1;
1815 else if( (l&32) && ps[g_p].jumping_counter > 348 )
1816 j = 1;
1817 else if( (l&1) && s >= 0 && s < 8)
1818 j = 1;
1819 else if( (l&2) && s >= 8 && !(sync[g_p].bits&(1<<5)) )
1820 j = 1;
1821 else if( (l&4) && s >= 8 && sync[g_p].bits&(1<<5) )
1822 j = 1;
1823 else if( (l&64) && ps[g_p].posz < (g_sp->z-(48<<8)) )
1824 j = 1;
1825 else if( (l&128) && s <= -8 && !(sync[g_p].bits&(1<<5)) )
1826 j = 1;
1827 else if( (l&256) && s <= -8 && (sync[g_p].bits&(1<<5)) )
1828 j = 1;
1829 else if( (l&512) && ( ps[g_p].quick_kick > 0 || ( ps[g_p].curr_weapon == KNEE_WEAPON && ps[g_p].kickback_pic > 0 ) ) )
1830 j = 1;
1831 else if( (l&1024) && sprite[ps[g_p].i].xrepeat < 8 )
1832 j = 1;
1833 else if( (l&2048) && ps[g_p].jetpack_on )
1834 j = 1;
1835 else if( (l&4096) && ps[g_p].steroids_amount > 0 && ps[g_p].steroids_amount < 400 )
1836 j = 1;
1837 else if( (l&8192) && ps[g_p].on_ground)
1838 j = 1;
1839 else if( (l&16384) && sprite[ps[g_p].i].xrepeat > 8 && sprite[ps[g_p].i].extra > 0 && ps[g_p].timebeforeexit == 0 )
1840 j = 1;
1841 else if( (l&32768) && sprite[ps[g_p].i].extra <= 0)
1842 j = 1;
1843 else if( (l&65536L) )
1844 {
1845 if(g_sp->picnum == APLAYER && ud.multimode > 1)
1846 j = getincangle(ps[otherp].ang,getangle(ps[g_p].posx-ps[otherp].posx,ps[g_p].posy-ps[otherp].posy));
1847 else
1848 j = getincangle(ps[g_p].ang,getangle(g_sp->x-ps[g_p].posx,g_sp->y-ps[g_p].posy));
1849
1850 if( j > -128 && j < 128 )
1851 j = 1;
1852 else
1853 j = 0;
1854 }
1855
1856 parseifelse((long) j);
1857
1858 }
1859 break;
1860 case 56:
1861 insptr++;
1862 parseifelse(g_sp->extra <= *insptr);
1863 break;
1864 case 58:
1865 insptr += 2;
1866 guts(g_sp,*(insptr-1),*insptr,g_p);
1867 insptr++;
1868 break;
1869 case 59:
1870 insptr++;
1871 // if(g_sp->owner >= 0 && sprite[g_sp->owner].picnum == *insptr)
1872 // parseifelse(1);
1873 // else
1874 parseifelse( hittype[g_i].picnum == *insptr);
1875 break;
1876 case 121:
1877 insptr++;
1878 forceplayerangle(&ps[g_p]);
1879 ps[g_p].posxv -= sintable[(ps[g_p].ang+512)&2047]<<7;
1880 ps[g_p].posyv -= sintable[ps[g_p].ang&2047]<<7;
1881 return 0;
1882 case 61:
1883 insptr++;
1884 ps[g_p].posxv -= sintable[(ps[g_p].ang+512)&2047]<<10;
1885 ps[g_p].posyv -= sintable[ps[g_p].ang&2047]<<10;
1886 ps[g_p].jumping_counter = 767;
1887 ps[g_p].jumping_toggle = 1;
1888 return 0;
1889 case 62:
1890 insptr++;
1891 parseifelse( (( hittype[g_i].floorz - hittype[g_i].ceilingz ) >> 8 ) < *insptr);
1892 break;
1893 case 63:
1894 parseifelse( sync[g_p].bits&(1<<29));
1895 break;
1896 case 64:
1897 parseifelse(sector[g_sp->sectnum].ceilingstat&1);
1898 break;
1899 case 65:
1900 parseifelse(ud.multimode > 1);
1901 break;
1902 case 66:
1903 insptr++;
1904 if( sector[g_sp->sectnum].lotag == 0 )
1905 {
1906 neartag(g_sp->x,g_sp->y,g_sp->z-(32<<8),g_sp->sectnum,g_sp->ang,&neartagsector,&neartagwall,&neartagsprite,&neartaghitdist,768L,1);
1907 if( neartagsector >= 0 && isanearoperator(sector[neartagsector].lotag) )
1908 if( (sector[neartagsector].lotag&0xff) == 23 || sector[neartagsector].floorz == sector[neartagsector].ceilingz )
1909 if( (sector[neartagsector].lotag&16384) == 0 )
1910 if( (sector[neartagsector].lotag&32768) == 0 )
1911 {
1912 j = headspritesect[neartagsector];
1913 while(j >= 0)
1914 {
1915 if(sprite[j].picnum == ACTIVATOR)
1916 break;
1917 j = nextspritesect[j];
1918 }
1919 if(j == -1)
1920 operatesectors(neartagsector,g_i);
1921 }
1922 }
1923 break;
1924 case 67:
1925 parseifelse(ceilingspace(g_sp->sectnum));
1926 break;
1927
1928 case 74:
1929 insptr++;
1930 if(g_sp->picnum != APLAYER)
1931 hittype[g_i].tempang = g_sp->pal;
1932 g_sp->pal = *insptr;
1933 insptr++;
1934 break;
1935
1936 case 77:
1937 insptr++;
1938 g_sp->picnum = *insptr;
1939 insptr++;
1940 break;
1941
1942 case 70:
1943 parseifelse( dodge(g_sp) == 1);
1944 break;
1945 case 71:
1946 if( badguy(g_sp) )
1947 parseifelse( ud.respawn_monsters );
1948 else if( inventory(g_sp) )
1949 parseifelse( ud.respawn_inventory );
1950 else
1951 parseifelse( ud.respawn_items );
1952 break;
1953 case 72:
1954 insptr++;
1955 // getglobalz(g_i);
1956 parseifelse( (hittype[g_i].floorz - g_sp->z) <= ((*insptr)<<8));
1957 break;
1958 case 73:
1959 insptr++;
1960 // getglobalz(g_i);
1961 parseifelse( ( g_sp->z - hittype[g_i].ceilingz ) <= ((*insptr)<<8));
1962 break;
1963 case 14:
1964
1965 insptr++;
1966 ps[g_p].pals_time = *insptr;
1967 insptr++;
1968 for(j=0;j<3;j++)
1969 {
1970 ps[g_p].pals[j] = *insptr;
1971 insptr++;
1972 }
1973 break;
1974
1975 /* case 74:
1976 insptr++;
1977 getglobalz(g_i);
1978 parseifelse( (( hittype[g_i].floorz - hittype[g_i].ceilingz ) >> 8 ) >= *insptr);
1979 break;
1980 */
1981 case 78:
1982 insptr++;
1983 parseifelse( sprite[ps[g_p].i].extra < *insptr);
1984 break;
1985
1986 case 75:
1987 {
1988 insptr++;
1989 j = 0;
1990 switch(*(insptr++))
1991 {
1992 case 0:if( ps[g_p].steroids_amount != *insptr)
1993 j = 1;
1994 break;
1995 case 1:if(ps[g_p].shield_amount != max_player_health )
1996 j = 1;
1997 break;
1998 case 2:if(ps[g_p].scuba_amount != *insptr) j = 1;break;
1999 case 3:if(ps[g_p].holoduke_amount != *insptr) j = 1;break;
2000 case 4:if(ps[g_p].jetpack_amount != *insptr) j = 1;break;
2001 case 6:
2002 switch(g_sp->lotag)
2003 {
2004 case 100: if(ps[g_p].keys[1]) j = 1;break;
2005 case 101: if(ps[g_p].keys[2]) j = 1;break;
2006 case 102: if(ps[g_p].keys[3]) j = 1;break;
2007 case 103: if(ps[g_p].keys[4]) j = 1;break;
2008 }
2009 break;
2010 case 7:if(ps[g_p].heat_amount != *insptr) j = 1;break;
2011 case 9:
2012 if(ps[g_p].firstaid_amount != *insptr) j = 1;break;
2013 case 10:
2014 if(ps[g_p].boot_amount != *insptr) j = 1;break;
2015 }
2016
2017 parseifelse(j);
2018 break;
2019 }
2020 case 38:
2021 insptr++;
2022 if( ps[g_p].knee_incs == 0 && sprite[ps[g_p].i].xrepeat >= 9 )
2023 if( cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+(16<<8),sprite[ps[g_p].i].sectnum) )
2024 {
2025 ps[g_p].knee_incs = 1;
2026 if(ps[g_p].weapon_pos == 0)
2027 ps[g_p].weapon_pos = -1;
2028 ps[g_p].actorsqu = g_i;
2029 }
2030 break;
2031 case 90:
2032 {
2033 short s1;
2034
2035 s1 = g_sp->sectnum;
2036
2037 j = 0;
2038
2039 updatesector(g_sp->x+108,g_sp->y+108,&s1);
2040 if( s1 == g_sp->sectnum )
2041 {
2042 updatesector(g_sp->x-108,g_sp->y-108,&s1);
2043 if( s1 == g_sp->sectnum )
2044 {
2045 updatesector(g_sp->x+108,g_sp->y-108,&s1);
2046 if( s1 == g_sp->sectnum )
2047 {
2048 updatesector(g_sp->x-108,g_sp->y+108,&s1);
2049 if( s1 == g_sp->sectnum )
2050 j = 1;
2051 }
2052 }
2053 }
2054 parseifelse( j );
2055 }
2056
2057 break;
2058 case 80:
2059 insptr++;
2060 FTA(*insptr,&ps[g_p]);
2061 insptr++;
2062 break;
2063 case 81:
2064 parseifelse( floorspace(g_sp->sectnum));
2065 break;
2066 case 82:
2067 parseifelse( (hittype[g_i].movflag&49152) > 16384 );
2068 break;
2069 case 83:
2070 insptr++;
2071 switch(g_sp->picnum)
2072 {
2073 case FEM10:
2074 case NAKED1:
2075 case STATUE:
2076 if(g_sp->yvel) operaterespawns(g_sp->yvel);
2077 break;
2078 default:
2079 if(g_sp->hitag >= 0) operaterespawns(g_sp->hitag);
2080 break;
2081 }
2082 break;
2083 case 85:
2084 insptr++;
2085 parseifelse( g_sp->pal == *insptr);
2086 break;
2087
2088 case 109:
2089
2090 for(j=0;j<NUM_SOUNDS;j++)
2091 if( SoundOwner[j][0].i == g_i )
2092 break;
2093
2094 parseifelse( j == NUM_SOUNDS );
2095 break;
2096 default:
2097 killit_flag = 1;
2098 break;
2099 }
2100 return 0;
2101 }
2102
execute(short i,short p,long x)2103 void execute(short i,short p,long x)
2104 {
2105 char done;
2106
2107 g_i = i;
2108 g_p = p;
2109 g_x = x;
2110 g_sp = &sprite[g_i];
2111 g_t = &hittype[g_i].temp_data[0];
2112
2113 if( actorscrptr[g_sp->picnum] == 0 ) return;
2114
2115 insptr = 4 + (actorscrptr[g_sp->picnum]);
2116
2117 killit_flag = 0;
2118
2119 if(g_sp->sectnum < 0 || g_sp->sectnum >= MAXSECTORS)
2120 {
2121 if(badguy(g_sp))
2122 ps[g_p].actors_killed++;
2123 deletesprite(g_i);
2124 return;
2125 }
2126
2127 if(g_t[4])
2128 {
2129 g_sp->lotag += TICSPERFRAME;
2130 if(g_sp->lotag > *(long *)(g_t[4]+16) )
2131 {
2132 g_t[2]++;
2133 g_sp->lotag = 0;
2134 g_t[3] += *(long *)( g_t[4]+12 );
2135 }
2136 if( klabs(g_t[3]) >= klabs( *(long *)(g_t[4]+4) * *(long *)(g_t[4]+12) ) )
2137 g_t[3] = 0;
2138 }
2139
2140 do
2141 done = parse();
2142 while( done == 0 );
2143
2144 if(killit_flag == 1)
2145 {
2146 if(ps[g_p].actorsqu == g_i)
2147 ps[g_p].actorsqu = -1;
2148 deletesprite(g_i);
2149 }
2150 else
2151 {
2152 move();
2153
2154 if( g_sp->statnum == 1)
2155 {
2156 if( badguy(g_sp) )
2157 {
2158 if( g_sp->xrepeat > 60 ) return;
2159 if( ud.respawn_monsters == 1 && g_sp->extra <= 0 ) return;
2160 }
2161 else if( ud.respawn_items == 1 && (g_sp->cstat&32768) ) return;
2162
2163 if(hittype[g_i].timetosleep > 1)
2164 hittype[g_i].timetosleep--;
2165 else if(hittype[g_i].timetosleep == 1)
2166 changespritestat(g_i,2);
2167 }
2168
2169 else if(g_sp->statnum == 6)
2170 switch(g_sp->picnum)
2171 {
2172 case RUBBERCAN:
2173 case EXPLODINGBARREL:
2174 case WOODENHORSE:
2175 case HORSEONSIDE:
2176 case CANWITHSOMETHING:
2177 case FIREBARREL:
2178 case NUKEBARREL:
2179 case NUKEBARRELDENTED:
2180 case NUKEBARRELLEAKED:
2181 case EGG:
2182 if(hittype[g_i].timetosleep > 1)
2183 hittype[g_i].timetosleep--;
2184 else if(hittype[g_i].timetosleep == 1)
2185 changespritestat(g_i,2);
2186 break;
2187 }
2188 }
2189 }
2190
2191