2 Copyright (C) Prikol Software 1996-1997
3 Copyright (C) Aleksey Volynskov 1996-1997
4 Copyright (C) <ARembo@gmail.com> 2011
6 This file is part of the Doom2D:Rembo project.
8 Doom2D:Rembo is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as
10 published by the Free Software Foundation.
12 Doom2D:Rembo is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/> or
19 write to the Free Software Foundation, Inc.,
20 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
46 SLEEP
,GO
,RUN
,CLIMB
,DIE
,DEAD
,ATTACK
,SHOOT
,PAIN
,WAIT
,REVIVE
,RUNOUT
50 int r
, h
, l
, mp
, rv
, jv
, sp
, minp
;
55 static char *sleepanim
[MN_TN
]={
56 "AAABBB","AAABBB","AAABBB","AAABBB","AAABBB","AAABBB","AAABBB","AAABBB",
57 "A","AAABBB","AAABBB","AAABBB","AAABBB","AAABBB","AAABBB","AAABBB","AAABBB",
60 "AABBCCDD","AABBCCDD","AABBDDAACCDD","AABBDDAACCDD","AABBDDCCDDBB",
61 "AABBDDAACCDD","AABBCCDD","AABBCCDD","A","AABB","AABBCCBB",
62 "AABBCCDDEEFF","AABBCCDDEEFF","AABBCCDDEEFF","AABBCCDDEEFF","AABBCCDDEEFF",
63 "AABB","A","DDEEFFGGHHIIJJKKLLAABBCC","ACDABD"
65 "H","H","G","G","G","G","H","H","F","E","G","I","I","J","L","Q","EECCDDCC",
68 "A","A","A","A","A","A","A","A","A","AABB","A","A","A","I","K","A","A",
70 }, *attackanim
[MN_TN
]={
71 "EEFFGG","EEFFGG","EEEEEF","EEEEEF","EEEEEF","EF","EEFFGG","EEFFGG",
72 "BBCCDD","CCDD","DDEEFF","GH","GH","GGGGHH","GGHHII",
73 "QQGGGHHHIIJJKKLLMMNNOOPP","BBFFAA","A","OOPPQQ","EEEEFF"
75 "IIIJJJKKKLLLMMM","IIIJJJKKKLLL","HHHIIIJJJKKK","HHHIIIJJJKKK",
76 "HHHIIIJJJKKKLLLMMMNNNOOO","HHHIIIJJJKKKLLLMMM",
77 "IIIJJJKKKLLLMMMNNN","IIIJJJKKKLLLMMMNNN","GGGHHHIIIJJJKKK",
78 "FFFGGGHHHIIIJJJKKK","HHHIIIJJJKKKLLLMMM",
79 "JJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRR","JJJKKKLLLMMMNNNOOO",
80 "KKKLLLMMMNNNOOOPPPRRRSSS","MMMNNNOOOPPP","RRRSSSTTTUUUVVVWWWXXXYYY",
81 "DDDD","CCCDDDEEEFFFGGG","D","HHHHIIIIJJJJKKKKLLLLMMMM"
83 "","NNNOOOPPPRRRSSSTTT","MMMNNNOOOPPPRRRSSSTTT","MMMNNNOOOPPPRRRSSSTTT","",
84 "OOOPPPQQQRRRSSS","","","","","","","","","","","","","","OOPPQQRRSSTTUUVV"
86 "N","M","L","L","P","N","O","O","L","","","S","P","T","Q","Z","C","","D","N"
88 "","U","U","U","","T","","","","","","","","","","","","","","W"
94 static void *fsnd
,*pauksnd
,*trupsnd
;
95 static void *snd
[MN_TN
][5],*impsitsnd
[2],*impdthsnd
[2],*firsnd
,*slopsnd
,*gsnd
[4];
96 static void *swgsnd
,*pchsnd
,*telesnd
;
97 static void *positsnd
[3],*podthsnd
[3];
98 static int mnum
,gsndt
;
99 static mnsz_t mnsz
[MN_TN
+1]={
100 //rad ht life pain rv jv slop min_pn
101 0, 0, 0, 0, 0, 0, 0, 0, // none
102 15, 28, 60, 20, 7,10, 0, 10, // demon
103 10, 28, 25, 15, 3,10, 30, 0, // imp
104 10, 28, 15, 10, 3,10, 30, 0, // zomby
105 10, 28, 20, 10, 3,10, 30, 0, // sergeant
106 20, 55, 500, 70, 5,10, 0, 50, // cyberdemon
107 12, 28, 60, 20, 3,10, 30, 10, // chaingunner
108 12, 32, 150, 40, 3,10, 0, 30, // baron of hell
109 12, 32, 75, 40, 3,10, 0, 30, // hell knight
110 15, 28, 100, 10, 4, 4, 0, 0, // cacodemon
111 8, 18, 60, 10, 4, 4, 0, 0, // lost soul
112 15, 28, 100, 10, 4, 4, 0, 0, // pain elemental
113 64, 50, 500, 70, 4,10, 0, 50, // spider mastermind
114 25, 27, 150, 20, 4,10, 0, 0, // arachnotron
115 18, 30, 200, 40, 3, 7, 0, 20, // mancubus
116 17, 36, 200, 40, 6,11, 0, 20, // revenant
117 17, 36, 150, 30, 7,12, 0, 10, // archvile
118 5, 5, 35, 20,14, 6, 0, 10, // fish
119 5, 17, 20, 0, 7, 6, 0, 0, // barrel
120 17, 38, 20, 40, 3, 6, 0, 20, // robot
121 8, 26, 400, 70, 8,10, 30, 50 // man
124 static void setst(int i
,int st
) {
130 if(st
!=DEAD
&& st
!=REVIVE
) return;
134 switch(mn
[i
].st
=st
) {
135 case SLEEP
: a
=sleepanim
[t
];break;
136 case PAIN
: a
=painanim
[t
];break;
137 case WAIT
: a
=waitanim
[t
];break;
139 case RUN
: case RUNOUT
:
140 case GO
: a
=goanim
[t
];break;
142 if(t
==MN_SKEL
-1) {a
="KKKKJJ";break;}
143 if(t
==MN_ROBO
-1) {a
="MN";break;}
144 case ATTACK
: a
=attackanim
[t
];
145 if(st
==ATTACK
&& t
==MN_VILE
-1) a
="[[\\\\]]";
148 if(g_map
==9 && t
==MN_BSP
-1) Z_sound(pauksnd
,128);
152 if(mn
[i
].ap
==slopanim
[t
]) a
=messanim
[t
];
153 if(t
==MN_BARREL
-1) {mn
[i
].t
=0;}
156 a
=(mn
[i
].ap
==messanim
[t
])?slopanim
[t
]:dieanim
[t
];
157 mn
[i
].ac
=strlen(a
)-1;
158 mn
[i
].o
.r
=mnsz
[t
+1].r
;mn
[i
].o
.h
=mnsz
[t
+1].h
;
159 mn
[i
].life
=mnsz
[t
+1].l
;mn
[i
].ammo
=mn
[i
].pain
=0;
166 void MN_savegame (FILE *h
) {
168 for (n
= MAXMN
- 1; n
>= 0 && mn
[n
].t
== 0; n
--) {
173 for (i
= 0; i
< n
; i
++) {
174 myfwrite32(mn
[i
].o
.x
, h
);
175 myfwrite32(mn
[i
].o
.y
, h
);
176 myfwrite32(mn
[i
].o
.xv
, h
);
177 myfwrite32(mn
[i
].o
.yv
, h
);
178 myfwrite32(mn
[i
].o
.vx
, h
);
179 myfwrite32(mn
[i
].o
.vy
, h
);
180 myfwrite32(mn
[i
].o
.r
, h
);
181 myfwrite32(mn
[i
].o
.h
, h
);
182 myfwrite8(mn
[i
].t
, h
);
183 myfwrite8(mn
[i
].d
, h
);
184 myfwrite8(mn
[i
].st
, h
);
185 myfwrite8(mn
[i
].ftime
, h
);
186 myfwrite32(mn
[i
].fobj
, h
);
187 myfwrite32(mn
[i
].s
, h
);
188 myfwrite32(0, h
); // mn[i].ap useless, changed after load
189 myfwrite32(mn
[i
].aim
, h
);
190 myfwrite32(mn
[i
].life
, h
);
191 myfwrite32(mn
[i
].pain
, h
);
192 myfwrite32(mn
[i
].ac
, h
);
193 myfwrite32(mn
[i
].tx
, h
);
194 myfwrite32(mn
[i
].ty
, h
);
195 myfwrite32(mn
[i
].ammo
, h
);
196 myfwrite16(mn
[i
].atm
, h
);
199 myfwrite32(gsndt
, h
);
202 void MN_loadgame (FILE *h
) {
205 for (i
= 0; i
< n
; i
++) {
206 mn
[i
].o
.x
= myfread32(h
);
207 mn
[i
].o
.y
= myfread32(h
);
208 mn
[i
].o
.xv
= myfread32(h
);
209 mn
[i
].o
.yv
= myfread32(h
);
210 mn
[i
].o
.vx
= myfread32(h
);
211 mn
[i
].o
.vy
= myfread32(h
);
212 mn
[i
].o
.r
= myfread32(h
);
213 mn
[i
].o
.h
= myfread32(h
);
214 mn
[i
].t
= myfread8(h
);
215 mn
[i
].d
= myfread8(h
);
216 mn
[i
].st
= myfread8(h
);
217 mn
[i
].ftime
= myfread8(h
);
218 mn
[i
].fobj
= myfread32(h
);
219 mn
[i
].s
= myfread32(h
);
220 mn
[i
].ap
= NULL
; myfread32(h
); // useless, changed after loading
221 mn
[i
].aim
= myfread32(h
);
222 mn
[i
].life
= myfread32(h
);
223 mn
[i
].pain
= myfread32(h
);
224 mn
[i
].ac
= myfread32(h
);
225 mn
[i
].tx
= myfread32(h
);
226 mn
[i
].ty
= myfread32(h
);
227 mn
[i
].ammo
= myfread32(h
);
228 mn
[i
].atm
= myfread16(h
);
231 gsndt
= myfread32(h
);
232 for (n
= 0; n
< MAXMN
; ++n
) {
241 #define GGAS_TOTAL (MN__LAST-MN_DEMON+16+10)
243 void MN_alloc (void) {
245 static char sn
[MN_TN
][5][6]={
246 {"DMACT","DMPAIN","SGTATK","SGTSIT","SGTDTH"},
247 {"BGACT","POPAIN","CLAW","",""},
248 {"POSACT","POPAIN","","",""},
249 {"POSACT","POPAIN","","",""},
250 {"","DMPAIN","HOOF","CYBSIT","CYBDTH"},
251 {"POSACT","POPAIN","","",""},
252 {"","DMPAIN","","BRSSIT","BRSDTH"},
253 {"","DMPAIN","","KNTSIT","KNTDTH"},
254 {"DMACT","DMPAIN","","CACSIT","CACDTH"},
255 {"DMACT","DMPAIN","SKLATK","SKLATK","FIRXPL"},
256 {"DMACT","PEPAIN","","PESIT","PEDTH"},
257 {"","DMPAIN","METAL","SPISIT","SPIDTH"},
258 {"BSPACT","DMPAIN","BSPWLK","BSPSIT","BSPDTH"},
259 {"DMACT","MNPAIN","MANATK","MANSIT","MANDTH"},
260 {"SKEACT","POPAIN","SKEATK","SKESIT","SKEDTH"},
261 {"VILACT","VIPAIN","VILATK","VILSIT","VILDTH"},
262 {"","","BITE1","",""},
263 {"","","","","BAREXP"},
264 {"BSPACT","","BSPWLK","BSPSIT","BSPDTH"},
265 {"HAHA1","PLPAIN","","STOP1","PDIEHI"}
267 static char gsn
[6]="GOOD0";
268 for(j
=0;j
<MN_TN
;++j
) {
271 snd
[j
][i
]=Z_getsnd(sn
[j
][i
]);
274 logo_gas(j
+5,GGAS_TOTAL
);
276 impsitsnd
[0]=Z_getsnd("BGSIT1");
277 impsitsnd
[1]=Z_getsnd("BGSIT2");
278 impdthsnd
[0]=Z_getsnd("BGDTH1");
279 impdthsnd
[1]=Z_getsnd("BGDTH2");
280 positsnd
[0]=Z_getsnd("POSIT1");
281 positsnd
[1]=Z_getsnd("POSIT2");
282 positsnd
[2]=Z_getsnd("POSIT3");
283 podthsnd
[0]=Z_getsnd("PODTH1");
284 podthsnd
[1]=Z_getsnd("PODTH2");
285 podthsnd
[2]=Z_getsnd("PODTH3");
286 fsnd
=Z_getsnd("FLAME");
287 firsnd
=Z_getsnd("FIRSHT");
288 slopsnd
=Z_getsnd("SLOP");
289 swgsnd
=Z_getsnd("SKESWG");
290 pchsnd
=Z_getsnd("SKEPCH");
291 telesnd
=Z_getsnd("TELEPT");
292 pauksnd
=Z_getsnd("PAUK1");
293 trupsnd
=Z_getsnd("UTRUP");
294 for(i
=0;i
<4;++i
) {gsn
[4]=i
+'1';gsnd
[i
]=Z_getsnd(gsn
);}
297 void MN_init (void) {
299 for(i
=0;i
<MAXMN
;++i
) {mn
[i
].t
=0;mn
[i
].st
=SLEEP
;}
303 int MN_spawn (int x
, int y
, byte d
, int t
) {
306 if(g_dm
&& nomon
&& t
<MN_PL_DEAD
) return -1;
307 for(i
=0;i
<MAXMN
;++i
) if(!mn
[i
].t
) goto ok
;
308 for(i
=0;i
<MAXMN
;++i
) if(mn
[i
].t
>=MN_PL_DEAD
) goto ok
;
311 mn
[i
].o
.x
=x
;mn
[i
].o
.y
=y
;
312 mn
[i
].o
.xv
=mn
[i
].o
.yv
=mn
[i
].o
.vx
=mn
[i
].o
.vy
=0;
316 mn
[i
].o
.r
=mnsz
[t
].r
;mn
[i
].o
.h
=mnsz
[t
].h
;
317 mn
[i
].life
=mnsz
[t
].l
;
318 setst(i
,SLEEP
);mn
[i
].s
=myrand(18);
320 }else {mn
[i
].o
.r
=8;mn
[i
].o
.h
=6;mn
[i
].life
=0;mn
[i
].st
=DEAD
;}
321 mn
[i
].aim
=-3;mn
[i
].atm
=0;
328 int MN_spawn_deadpl (obj_t
*o
, byte c
, int t
) {
331 if((i
=MN_spawn(o
->x
,o
->y
,c
,t
+MN_PL_DEAD
))==-1) return -1;
335 static int isfriend(int a
,int b
) {
336 if(a
==MN_BARREL
|| b
==MN_BARREL
) return 1;
338 case MN_IMP
: case MN_DEMON
:
339 case MN_BARON
: case MN_KNIGHT
:
340 case MN_CACO
: case MN_SOUL
:
341 case MN_MANCUB
: case MN_SKEL
:
345 if(a
==MN_SOUL
&& b
==MN_PAIN
) return 1;
346 if(b
==MN_SOUL
&& a
==MN_PAIN
) return 1;
350 static int MN_findnewprey(int i
) {
354 if(_2pl
) b
=!PL_isdead(&pl2
); else b
=0;
356 if(b
) mn
[i
].aim
=(abs(mn
[i
].o
.x
-pl1
.o
.x
)+abs(mn
[i
].o
.y
-pl1
.o
.y
)
357 <= abs(mn
[i
].o
.x
-pl2
.o
.x
)+abs(mn
[i
].o
.y
-pl2
.o
.y
))?-1:-2;
362 for(a
=0,b
=32000,mn
[i
].aim
=-3;a
<MAXMN
;++a
)
363 if(mn
[a
].t
&& mn
[a
].st
!=DEAD
&& a
!=i
&& !isfriend(mn
[a
].t
,mn
[i
].t
))
364 if((l
=abs(mn
[i
].o
.x
-mn
[a
].o
.x
)+abs(mn
[i
].o
.y
-mn
[a
].o
.y
))<b
)
366 if(mn
[i
].aim
<0) {mn
[i
].atm
=MAX_ATM
;return 0;} else mn
[i
].atm
=0;
372 int Z_getobjpos (int i
, obj_t
*o
) {
373 if(i
==-1) {*o
=pl1
.o
;return !PL_isdead(&pl1
);}
374 if(_2pl
) if(i
==-2) {*o
=pl2
.o
;return !PL_isdead(&pl2
);}
375 if(i
>=0 && i
<MAXMN
) if(mn
[i
].t
&& mn
[i
].st
!=DEAD
)
376 {*o
=mn
[i
].o
;return 1;}
380 static void *wakeupsnd(int t
) {
382 case MN_IMP
: return impsitsnd
[myrand(2)];
383 case MN_ZOMBY
: case MN_SERG
: case MN_CGUN
:
384 return positsnd
[myrand(3)];
389 static void *dthsnd(int t
) {
391 case MN_IMP
: return impdthsnd
[myrand(2)];
392 case MN_ZOMBY
: case MN_SERG
: case MN_CGUN
:
393 return podthsnd
[myrand(3)];
398 static int canshoot(int t
) {
400 case MN_DEMON
: case MN_FISH
: case MN_BARREL
:
406 static int shoot(int i
,obj_t
*o
,int n
) {
409 if(mn
[i
].ammo
<0) return 0;
410 if(!n
) switch(mn
[i
].t
) {
411 case MN_FISH
: case MN_BARREL
:
412 case MN_DEMON
: return 0;
416 if(++mn
[i
].ammo
>=50) mn
[i
].ammo
=(mn
[i
].t
==MN_ROBO
)?-200:-50;
421 if(++mn
[i
].ammo
>=5) mn
[i
].ammo
=-50;
424 if(++mn
[i
].ammo
>=100) mn
[i
].ammo
=-50;
427 if(rand()&1) return 0;
428 if(++mn
[i
].ammo
>=10) mn
[i
].ammo
=-50;
430 case MN_BARON
: case MN_KNIGHT
:
431 if(rand()&7) return 0;
434 if(rand()&31) return 0;
437 if(rand()&7) return 0;
440 if(rand()&7) return 0;
443 if(rand()&15) return 0;
445 if(!Z_look(&mn
[i
].o
,o
,mn
[i
].d
)) return 0;
447 mn
[i
].tx
=o
->x
+(o
->xv
+o
->vx
)*6;mn
[i
].ty
=o
->y
-o
->h
/2+(o
->yv
+o
->vy
)*6;
448 if(abs(mn
[i
].tx
-mn
[i
].o
.x
)<abs(mn
[i
].ty
-mn
[i
].o
.y
+mn
[i
].o
.h
/2)) return 0;
450 case MN_IMP
: case MN_BARON
: case MN_KNIGHT
: case MN_CACO
:
451 setst(i
,SHOOT
);Z_sound(firsnd
,128);break;
453 setst(i
,SHOOT
);Z_sound(snd
[MN_SKEL
-1][2],128);break;
455 mn
[i
].tx
=o
->x
;mn
[i
].ty
=o
->y
;
456 setst(i
,SHOOT
);Z_sound(fsnd
,128);
457 Z_sound(snd
[MN_VILE
-1][2],128);break;
459 setst(i
,ATTACK
);Z_sound(snd
[MN_SOUL
-1][2],128);
460 yd
=mn
[i
].ty
-mn
[i
].o
.y
+mn
[i
].o
.h
/2;xd
=mn
[i
].tx
-mn
[i
].o
.x
;
461 if(!(m
=max(abs(xd
),abs(yd
)))) m
=1;
462 mn
[i
].o
.xv
=xd
*16/m
;mn
[i
].o
.yv
=yd
*16/m
;
464 case MN_MANCUB
: if(mn
[i
].ammo
==1) Z_sound(snd
[MN_MANCUB
-1][2],128);
465 case MN_ZOMBY
: case MN_SERG
: case MN_BSP
: case MN_ROBO
:
466 case MN_CYBER
: case MN_CGUN
: case MN_SPIDER
:
467 case MN_PAIN
: case MN_MAN
:
468 setst(i
,SHOOT
);break;
475 static int kick(int i
,obj_t
*o
) {
478 setst(i
,ATTACK
);return 1;
480 setst(i
,ATTACK
);Z_sound(snd
[0][2],128);return 1;
482 setst(i
,ATTACK
);Z_sound(snd
[1][2],128);return 1;
484 setst(i
,ATTACK
);Z_sound(swgsnd
,128);return 1;
486 setst(i
,ATTACK
);Z_sound(swgsnd
,128);return 1;
487 case MN_BARON
: case MN_KNIGHT
: case MN_CACO
: case MN_MANCUB
:
493 static int iscorpse(obj_t
*o
,int n
) {
496 if(!n
) if(rand()&7) return -3;
497 for(i
=0;i
<MAXMN
;++i
) if(mn
[i
].t
) if(mn
[i
].st
==DEAD
)
498 if(Z_overlap(o
,&mn
[i
].o
)) switch(mn
[i
].t
) {
499 case MN_SOUL
: case MN_PAIN
:
500 case MN_CYBER
: case MN_SPIDER
:
501 case MN_PL_DEAD
: case MN_PL_MESS
:
502 case MN_VILE
: case MN_BARREL
:
510 static int Z_hitobj (int obj
, int d
, int own
, int t
) {
512 if(obj
==-1) return PL_hit(&pl1
,d
,own
,t
);
513 else if(obj
==-2 && _2pl
) return PL_hit(&pl2
,d
,own
,t
);
514 else if(obj
<0 || obj
>=MAXMN
) return 0;
515 if(mn
[obj
].t
) return MN_hit(obj
,d
,own
,t
);
522 static int pt_x
=0,pt_xs
=1,pt_y
=0,pt_ys
=1;
524 if(abs(pt_x
+=pt_xs
) > 123) pt_xs
=-pt_xs
;
525 if(abs(pt_y
+=pt_ys
) > 50) pt_ys
=-pt_ys
;
526 if(gsndt
>0) if(--gsndt
==0) {
527 Z_sound(gsnd
[myrand(4)],128);
529 for(i
=0;i
<MAXMN
;++i
) if((t
=mn
[i
].t
)!=0) {
532 if(!Z_inwater(mn
[i
].o
.x
,mn
[i
].o
.y
,mn
[i
].o
.r
,mn
[i
].o
.h
)) break;
533 case MN_SOUL
: case MN_PAIN
: case MN_CACO
:
534 if(mn
[i
].st
!=DIE
&& mn
[i
].st
!=DEAD
) --mn
[i
].o
.yv
;
536 }z_mon
=1;st
=Z_moveobj(&mn
[i
].o
);z_mon
=0;
537 BM_mark(&mn
[i
].o
,BM_MONSTER
);
539 if(t
==MN_ROBO
) g_exit
=1;
540 mn
[i
].t
=0;--mnum
;continue;
542 if(st
&Z_HITWATER
) Z_splash(&mn
[i
].o
,mn
[i
].o
.r
+mn
[i
].o
.h
);
543 SW_press(mn
[i
].o
.x
,mn
[i
].o
.y
,mn
[i
].o
.r
,mn
[i
].o
.h
,8,i
);
546 SMK_flame(mn
[i
].o
.x
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,
547 mn
[i
].o
.xv
+mn
[i
].o
.vx
,mn
[i
].o
.yv
+mn
[i
].o
.vy
,
548 mn
[i
].o
.r
/2,mn
[i
].o
.h
/2,rand()%(200*2+1)-200,-500,1,mn
[i
].fobj
);
550 if(st
&Z_INWATER
) mn
[i
].ftime
=0;
551 if(mn
[i
].st
==DEAD
) continue;
552 if(st
&Z_INWATER
) if(!(rand()&31)) switch(t
) {
555 case MN_ROBO
: case MN_BARREL
:
556 case MN_PL_DEAD
: case MN_PL_MESS
:
557 FX_bubble(mn
[i
].o
.x
+((rand()&1)*2-1)*myrand(mn
[i
].o
.r
+1),
558 mn
[i
].o
.y
-myrand(mn
[i
].o
.h
+1),0,0,1
562 FX_bubble(mn
[i
].o
.x
,mn
[i
].o
.y
-mn
[i
].o
.h
*3/4,0,0,5);
567 if(!mn
[i
].ap
[++mn
[i
].ac
]) {
568 mn
[i
].ac
=0;if(mn
[i
].st
==DIE
|| mn
[i
].st
==DEAD
) {mn
[i
].t
=0;}
569 }else if(mn
[i
].st
==DIE
&& mn
[i
].ac
==2) Z_explode(mn
[i
].o
.x
,mn
[i
].o
.y
-8,30,mn
[i
].aim
);
572 if(t
==MN_SOUL
) if(st
&Z_HITAIR
) Z_set_speed(&mn
[i
].o
,16);
573 if(mn
[i
].ammo
<0) ++mn
[i
].ammo
;
575 if(st
&Z_INWATER
) mn
[i
].o
.yv
=-4;
579 if(mn
[i
].pain
>=mnsz
[t
].mp
)
580 {mn
[i
].pain
=mnsz
[t
].mp
;Z_sound(snd
[t
-1][1],128);}
581 if((mn
[i
].pain
-=5)<=mnsz
[t
].minp
)
582 {setst(i
,GO
);mn
[i
].pain
=0;mn
[i
].ammo
=-9;}
585 if(++mn
[i
].s
>=18) mn
[i
].s
=0; else break;
586 if(Z_look(&mn
[i
].o
,&pl1
.o
,mn
[i
].d
))
587 {setst(i
,GO
);mn
[i
].aim
=-1;mn
[i
].atm
=0;Z_sound(wakeupsnd(t
),128);}
588 if(_2pl
) if(Z_look(&mn
[i
].o
,&pl2
.o
,mn
[i
].d
))
589 {setst(i
,GO
);mn
[i
].aim
=-2;mn
[i
].atm
=0;Z_sound(wakeupsnd(t
),128);}
592 if(--mn
[i
].s
<0) setst(i
,GO
);
595 if(st
&Z_BLOCK
) {mn
[i
].d
^=1;setst(i
,RUNOUT
);mn
[i
].s
=40;break;}
596 if(t
==MN_VILE
) if(iscorpse(&mn
[i
].o
,0)>=0) {
597 setst(i
,ATTACK
);mn
[i
].o
.xv
=0;break;
599 if(!Z_getobjpos(mn
[i
].aim
,&o
) || mn
[i
].atm
>MAX_ATM
)
600 if(!MN_findnewprey(i
)) {
602 o
.x
=mn
[i
].o
.x
+pt_x
;o
.y
=mn
[i
].o
.y
+pt_y
;
603 o
.xv
=o
.vx
=o
.yv
=o
.vy
=o
.r
=0;o
.h
=1;
604 }else Z_getobjpos(mn
[i
].aim
,&o
);
605 if(Z_overlap(&mn
[i
].o
,&o
)) {
607 if(kick(i
,&o
)) break;
610 sy
=o
.y
-o
.h
/2-mn
[i
].o
.y
+mn
[i
].o
.h
/2;
611 if(!(st
&Z_BLOCK
)) if(abs(sx
)<20)
612 if(t
!=MN_FISH
) {setst(i
,RUN
);mn
[i
].s
=15;mn
[i
].d
=rand()&1;break;}
614 if(SW_press(mn
[i
].o
.x
,mn
[i
].o
.y
,mn
[i
].o
.r
,mn
[i
].o
.h
,2,i
))
615 {setst(i
,WAIT
);mn
[i
].s
=4;break;}
617 case MN_CACO
: case MN_SOUL
: case MN_PAIN
: case MN_FISH
:
620 if(Z_canstand(mn
[i
].o
.x
,mn
[i
].o
.y
,mn
[i
].o
.r
))
621 {mn
[i
].o
.yv
=-mnsz
[t
].jv
;setst(i
,CLIMB
);break;}
626 if(abs(sx
)>abs(sy
)) if(shoot(i
,&o
,0)) break;
630 if(!(st
&Z_INWATER
)) {
631 if(Z_canstand(mn
[i
].o
.x
,mn
[i
].o
.y
,mn
[i
].o
.r
)) {
633 mn
[i
].o
.vx
+=rand()%17
-8;
634 }setst(i
,PAIN
);mn
[i
].pain
+=50;break;
636 case MN_CACO
: case MN_SOUL
: case MN_PAIN
:
637 if(abs(sy
)>4) mn
[i
].o
.yv
=(sy
<0)?-4:4; else mn
[i
].o
.yv
=0;
638 if(t
==MN_FISH
) if(mn
[i
].o
.yv
<0)
639 if(!Z_inwater(mn
[i
].o
.x
,mn
[i
].o
.y
-8,mn
[i
].o
.r
,mn
[i
].o
.h
))
640 {mn
[i
].o
.yv
=0;setst(i
,RUN
);mn
[i
].d
=rand()&1;mn
[i
].s
=20;}
643 if(sy
<-20) if(Z_canstand(mn
[i
].o
.x
,mn
[i
].o
.y
,mn
[i
].o
.r
))
644 if(!(rand()&3)) mn
[i
].o
.yv
=-mnsz
[t
].jv
;
648 if(!(rand()&7)) Z_sound(snd
[t
-1][0],128);
650 mn
[i
].o
.xv
=((mn
[i
].d
)?1:-1)*mnsz
[t
].rv
;
651 if(st
&Z_INWATER
) mn
[i
].o
.xv
/=2;
652 else if(t
==MN_FISH
) mn
[i
].o
.xv
=0;
655 if(st
&Z_BLOCK
) {setst(i
,RUNOUT
);mn
[i
].d
^=1;mn
[i
].s
=40;break;}
656 if(--mn
[i
].s
<=0 || ((st
&Z_HITWALL
) && mn
[i
].o
.yv
+mn
[i
].o
.vy
==0)) {
657 setst(i
,GO
);mn
[i
].s
=0;if(st
&(Z_HITWALL
|Z_BLOCK
)) mn
[i
].d
^=1;
658 if(!(rand()&7)) Z_sound(snd
[t
-1][0],128);
659 }mn
[i
].o
.xv
=((mn
[i
].d
)?1:-1)*mnsz
[t
].rv
;
660 if(st
&Z_INWATER
) mn
[i
].o
.xv
/=2;
661 else if(t
==MN_FISH
) mn
[i
].o
.xv
=0;
664 if(!(st
&Z_BLOCK
) && mn
[i
].s
>0) mn
[i
].s
=0;
666 setst(i
,GO
);mn
[i
].s
=0;if(st
&(Z_HITWALL
|Z_BLOCK
)) mn
[i
].d
^=1;
667 if(!(rand()&7)) Z_sound(snd
[t
-1][0],128);
668 }mn
[i
].o
.xv
=((mn
[i
].d
)?1:-1)*mnsz
[t
].rv
;
669 if(st
&Z_INWATER
) mn
[i
].o
.xv
/=2;
670 else if(t
==MN_FISH
) mn
[i
].o
.xv
=0;
673 if(mn
[i
].o
.yv
+mn
[i
].o
.vy
>=0 || !(st
&Z_HITWALL
)) {
674 setst(i
,GO
);mn
[i
].s
=0;
675 if(st
&(Z_HITWALL
|Z_BLOCK
)) {mn
[i
].d
^=1;setst(i
,RUN
);mn
[i
].s
=15;}
676 }mn
[i
].o
.xv
=((mn
[i
].d
)?1:-1)*mnsz
[t
].rv
;
677 if(st
&Z_INWATER
) mn
[i
].o
.xv
/=2;
678 else if(t
==MN_FISH
) mn
[i
].o
.xv
=0;
682 if(t
==MN_SOUL
) {if(st
&(Z_HITWALL
|Z_HITCEIL
|Z_HITLAND
)) setst(i
,GO
); break;}
683 if(t
!=MN_FISH
) mn
[i
].o
.xv
=Z_dec(mn
[i
].o
.xv
,1);
684 if(t
==MN_VILE
&& mn
[i
].st
==SHOOT
) {
685 if(!Z_getobjpos(mn
[i
].aim
,&o
)) {setst(i
,GO
);break;}
686 if(!Z_look(&mn
[i
].o
,&o
,mn
[i
].d
)) {setst(i
,GO
);break;}
687 if(Z_inwater(o
.x
,o
.y
,o
.r
,o
.h
)) {setst(i
,GO
);break;}
688 mn
[i
].tx
=o
.x
;mn
[i
].ty
=o
.y
;
689 Z_hitobj(mn
[i
].aim
,2,i
,HIT_SOME
);
692 if(mn
[i
].st
==REVIVE
) {
693 if(--mn
[i
].ac
==0) setst(i
,GO
);
695 if(!mn
[i
].ap
[mn
[i
].ac
]) switch(mn
[i
].st
) {
698 case MN_SOUL
: mn
[i
].ac
=0;
701 if(Z_hit(&mn
[i
].o
,15,i
,HIT_SOME
)) if(t
==MN_SOUL
) setst(i
,GO
);
704 if(Z_hit(&mn
[i
].o
,10,i
,HIT_SOME
))
705 Z_sound(snd
[MN_FISH
-1][2],128);
707 case MN_SKEL
: case MN_ROBO
:
708 o
=mn
[i
].o
;o
.xv
=mn
[i
].d
?50:-50;
709 if(Z_hit(&o
,50,i
,HIT_SOME
)) Z_sound(pchsnd
,128);
712 sx
=iscorpse(&mn
[i
].o
,1);
714 if(!mn
[sx
].t
|| mn
[sx
].st
!=DEAD
) break;
715 setst(sx
,REVIVE
);Z_sound(slopsnd
,128);
716 hit_xv
=hit_yv
=0;MN_hit(i
,5,-3,HIT_SOME
);
718 }if(t
!=MN_SOUL
&& mn
[i
].st
!=DIE
) setst(i
,GO
);
723 WP_ball1(mn
[i
].o
.x
+(mn
[i
].d
*2-1)*mn
[i
].o
.r
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
);
726 WP_pistol(mn
[i
].o
.x
+(mn
[i
].d
*2-1)*mn
[i
].o
.r
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
);
729 WP_shotgun(mn
[i
].o
.x
+(mn
[i
].d
*2-1)*mn
[i
].o
.r
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
);
732 WP_dshotgun(mn
[i
].o
.x
+(mn
[i
].d
*2-1)*mn
[i
].o
.r
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
);
733 mn
[i
].ammo
=-36;break;
735 WP_rocket(mn
[i
].o
.x
+(mn
[i
].d
*2-1)*mn
[i
].o
.r
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
);
738 WP_revf(mn
[i
].o
.x
+(mn
[i
].d
*2-1)*mn
[i
].o
.r
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
,mn
[i
].aim
);
742 WP_mgun(mn
[i
].o
.x
+(mn
[i
].d
*2-1)*mn
[i
].o
.r
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
);
745 WP_aplasma(mn
[i
].o
.x
+(mn
[i
].d
*2-1)*mn
[i
].o
.r
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
);
748 WP_plasma(mn
[i
].o
.x
+(mn
[i
].d
*2-1)*15,mn
[i
].o
.y
-30,mn
[i
].tx
,mn
[i
].ty
,i
);
751 WP_manfire(mn
[i
].o
.x
+(mn
[i
].d
*2-1)*mn
[i
].o
.r
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
);
753 case MN_BARON
: case MN_KNIGHT
:
754 WP_ball7(mn
[i
].o
.x
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
);
757 WP_ball2(mn
[i
].o
.x
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,mn
[i
].tx
,mn
[i
].ty
,i
);
760 if((sx
=MN_spawn(mn
[i
].o
.x
,mn
[i
].o
.y
,mn
[i
].d
,MN_SOUL
))==-1) break;
761 Z_getobjpos(mn
[sx
].aim
=mn
[i
].aim
,&o
);mn
[sx
].atm
=0;
765 if(t
==MN_CGUN
|| t
==MN_SPIDER
|| t
==MN_BSP
|| t
==MN_MANCUB
|| t
==MN_ROBO
)
766 if(!Z_getobjpos(mn
[i
].aim
,&o
)) MN_findnewprey(i
);
767 else if(shoot(i
,&o
,0)) break;
771 if(t
==MN_PAIN
|| t
==MN_SOUL
) mn
[i
].ftime
=0;
773 if((sx
=MN_spawn(mn
[i
].o
.x
-15,mn
[i
].o
.y
,0,MN_SOUL
))==-1) break;
775 if((sx
=MN_spawn(mn
[i
].o
.x
+15,mn
[i
].o
.y
,1,MN_SOUL
))==-1) break;
777 if((sx
=MN_spawn(mn
[i
].o
.x
,mn
[i
].o
.y
-10,1,MN_SOUL
))==-1) break;
783 case GO
: case RUN
: case CLIMB
: case RUNOUT
:
784 if(t
==MN_CYBER
|| t
==MN_SPIDER
|| t
==MN_BSP
) {
785 if(mn
[i
].ac
==0 || mn
[i
].ac
==6) Z_sound(snd
[t
-1][2],128);
787 if(mn
[i
].ac
==0 || mn
[i
].ac
==12) Z_sound(snd
[t
-1][2],128);
792 void MN_mark (void) {
794 for(i
=0;i
<MAXMN
;++i
) if(mn
[i
].t
!=0) BM_mark(&mn
[i
].o
,BM_MONSTER
);
797 int MN_hit(int n
,int d
,int o
,int t
) {
800 if(mn
[n
].st
==DEAD
|| mn
[n
].st
==DIE
) return 0;
802 if(t
!=HIT_ROCKET
&& t
!=HIT_ELECTRO
) return 0;
803 if(mn
[n
].t
==MN_CYBER
|| mn
[n
].t
==MN_BARREL
) return 1;
806 if(mn
[o
].t
==MN_SOUL
&& mn
[n
].t
==MN_PAIN
) return 0;
807 if(mn
[o
].t
==mn
[n
].t
) switch(mn
[n
].t
) {
808 case MN_IMP
: case MN_DEMON
:
809 case MN_BARON
: case MN_KNIGHT
:
810 case MN_CACO
: case MN_SOUL
:
811 case MN_MANCUB
: case MN_SKEL
:
816 if(t
==HIT_FLAME
) if(mn
[n
].ftime
&& mn
[n
].fobj
==o
) {if(g_time
&31) return 1;}
817 else {mn
[n
].ftime
=255;mn
[n
].fobj
=o
;}
818 if(t
==HIT_ELECTRO
) if(mn
[n
].t
==MN_FISH
)
819 {setst(n
,RUN
);mn
[n
].s
=20;mn
[n
].d
=rand()&1;return 1;}
820 if(t
==HIT_TRAP
) mn
[n
].life
=-100;
821 if(mn
[n
].t
==MN_ROBO
) d
=0;
822 if((mn
[n
].life
-=d
)<=0) --mnum
;
823 if(!mn
[n
].pain
) mn
[n
].pain
=3;
826 if(mn
[n
].pain
>=mnsz
[mn
[n
].t
].minp
) setst(n
,PAIN
);
828 if(mn
[n
].t
!=MN_BARREL
)
829 DOT_blood(mn
[n
].o
.x
,mn
[n
].o
.y
-mn
[n
].o
.h
/2,hit_xv
,hit_yv
,d
*2);
830 mn
[n
].aim
=o
;mn
[n
].atm
=0;
832 if(mn
[n
].t
!=MN_BARREL
)
833 if(o
==-1) ++pl1
.kills
;
834 else if(o
==-2) ++pl2
.kills
;
837 case MN_ZOMBY
: i
=I_CLIP
;break;
838 case MN_SERG
: i
=I_SGUN
;break;
839 case MN_CGUN
: i
=I_MGUN
;break;
840 case MN_MAN
: i
=I_KEYR
;break;
842 }if(i
) IT_spawn(mn
[n
].o
.x
,mn
[n
].o
.y
,i
);
843 mn
[n
].o
.xv
=0;mn
[n
].o
.h
=6;
844 if(mn
[n
].life
<=-mnsz
[mn
[n
].t
].sp
)
846 case MN_IMP
: case MN_ZOMBY
: case MN_SERG
: case MN_CGUN
:
848 mn
[n
].ap
=slopanim
[mn
[n
].t
-1];
849 Z_sound(slopsnd
,128);
851 case MN_BSP
: if(g_map
==9) break;
853 Z_sound(dthsnd(mn
[n
].t
),128);
855 else if(mn
[n
].t
!=MN_BSP
|| g_map
!=9) Z_sound(dthsnd(mn
[n
].t
),128);
857 }else if(mn
[n
].st
==SLEEP
) {setst(n
,GO
);mn
[n
].pain
=mnsz
[mn
[n
].t
].mp
;}
861 #define hit(o,x,y) (y<=o.y && y>o.y-o.h && x>=o.x-o.r && x<=o.x+o.r)
863 int Z_gunhit (int x
, int y
, int o
, int xv
, int yv
) {
866 if(o
!=-1) if(hit(pl1
.o
,x
,y
)) if(PL_hit(&pl1
,3,o
,HIT_SOME
))
867 {pl1
.o
.vx
+=xv
;pl1
.o
.vy
+=yv
;return -1;}
868 if(_2pl
&& o
!=-2) if(hit(pl2
.o
,x
,y
)) if(PL_hit(&pl2
,3,o
,HIT_SOME
))
869 {pl2
.o
.vx
+=xv
;pl2
.o
.vy
+=yv
;return -2;}
871 for(i
=0;i
<MAXMN
;++i
) if(mn
[i
].t
&& o
!=i
)
872 if(hit(mn
[i
].o
,x
,y
)) if(MN_hit(i
,3,o
,HIT_SOME
))
873 {mn
[i
].o
.vx
+=xv
;mn
[i
].o
.vy
+=yv
;return 1;}
877 static void goodsnd(void) {
882 int Z_hit (obj_t
*o
, int d
, int own
, int t
) {
887 if(Z_overlap(o
,&pl1
.o
)) if(PL_hit(&pl1
,d
,own
,t
)) {
888 pl1
.o
.vx
+=(o
->xv
+o
->vx
)*((t
==HIT_BFG
)?8:1)/4;
889 pl1
.o
.vy
+=(o
->yv
+o
->vy
)*((t
==HIT_BFG
)?8:1)/4;
890 if(t
==HIT_BFG
) goodsnd();
893 if(_2pl
) if(Z_overlap(o
,&pl2
.o
)) if(PL_hit(&pl2
,d
,own
,t
)) {
894 pl2
.o
.vx
+=(o
->xv
+o
->vx
)*((t
==HIT_BFG
)?8:1)/4;
895 pl2
.o
.vy
+=(o
->yv
+o
->vy
)*((t
==HIT_BFG
)?8:1)/4;
896 if(t
==HIT_BFG
) goodsnd();
900 for(i
=0;i
<MAXMN
;++i
) if(mn
[i
].t
)
901 if(Z_overlap(o
,&mn
[i
].o
)) if(MN_hit(i
,d
,own
,t
)) {
902 mn
[i
].o
.vx
+=(o
->xv
+o
->vx
)*((t
==HIT_BFG
)?8:1)/4;
903 mn
[i
].o
.vy
+=(o
->yv
+o
->vy
)*((t
==HIT_BFG
)?8:1)/4;
909 void MN_killedp (void) {
911 for(i
=0;i
<MAXMN
;++i
) if(mn
[i
].t
==MN_MAN
)
912 if(mn
[i
].st
!=DEAD
&& mn
[i
].st
!=DIE
&& mn
[i
].st
!=SLEEP
)
913 Z_sound(trupsnd
,128);
916 void Z_explode (int x
,int y
,int rad
,int own
) {
920 if(x
<-100 || x
>FLDW
*CELW
+100) return;
921 if(y
<-100 || y
>FLDH
*CELH
+100) return;
923 dx
=pl1
.o
.x
-x
;dy
=pl1
.o
.y
-pl1
.o
.h
/2-y
;
924 if((long)dx
*dx
+(long)dy
*dy
<r
) {
925 if(!(m
=max(abs(dx
),abs(dy
)))) m
=1;
926 pl1
.o
.vx
+=hit_xv
=dx
*10/m
;
927 pl1
.o
.vy
+=hit_yv
=dy
*10/m
;
928 PL_hit(&pl1
,100*(rad
-m
)/rad
,own
,HIT_ROCKET
);
931 dx
=pl2
.o
.x
-x
;dy
=pl2
.o
.y
-pl2
.o
.h
/2-y
;
932 if((long)dx
*dx
+(long)dy
*dy
<r
) {
933 if(!(m
=max(abs(dx
),abs(dy
)))) m
=1;
934 pl2
.o
.vx
+=hit_xv
=dx
*10/m
;
935 pl2
.o
.vy
+=hit_yv
=dy
*10/m
;
936 PL_hit(&pl2
,100*(rad
-m
)/rad
,own
,HIT_ROCKET
);
939 for(i
=0;i
<MAXMN
;++i
) if(mn
[i
].t
) {
940 dx
=mn
[i
].o
.x
-x
;dy
=mn
[i
].o
.y
-mn
[i
].o
.h
/2-y
;
941 if((long)dx
*dx
+(long)dy
*dy
<r
) {
942 if(!(m
=max(abs(dx
),abs(dy
)))) m
=1;
943 mn
[i
].o
.vx
+=hit_xv
=dx
*10/m
;
944 mn
[i
].o
.vy
+=hit_yv
=dy
*10/m
;
945 MN_hit(i
,mn
[i
].o
.r
*10*(rad
-m
)/rad
,own
,HIT_ROCKET
);
950 void Z_bfg9000 (int x
,int y
,int own
) {
954 if(x
<-100 || x
>FLDW
*CELW
+100) return;
955 if(y
<-100 || y
>FLDH
*CELH
+100) return;
956 dx
=pl1
.o
.x
-x
;dy
=pl1
.o
.y
-pl1
.o
.h
/2-y
;
957 if(own
!=-1) if((long)dx
*dx
+(long)dy
*dy
<16000)
958 if(Z_cansee(x
,y
,pl1
.o
.x
,pl1
.o
.y
-pl1
.o
.h
/2)) {
959 if(PL_hit(&pl1
,50,own
,HIT_SOME
))
960 WP_bfghit(pl1
.o
.x
,pl1
.o
.y
-pl1
.o
.h
/2,own
);
963 dx
=pl2
.o
.x
-x
;dy
=pl2
.o
.y
-pl2
.o
.h
/2-y
;
964 if(own
!=-2) if((long)dx
*dx
+(long)dy
*dy
<16000)
965 if(Z_cansee(x
,y
,pl2
.o
.x
,pl2
.o
.y
-pl2
.o
.h
/2)) {
966 if(PL_hit(&pl2
,50,own
,HIT_SOME
))
967 WP_bfghit(pl2
.o
.x
,pl2
.o
.y
-pl2
.o
.h
/2,own
);
970 for(i
=0;i
<MAXMN
;++i
) if(mn
[i
].t
&& own
!=i
) {
971 dx
=mn
[i
].o
.x
-x
;dy
=mn
[i
].o
.y
-mn
[i
].o
.h
/2-y
;
972 if((long)dx
*dx
+(long)dy
*dy
<16000)
973 if(Z_cansee(x
,y
,mn
[i
].o
.x
,mn
[i
].o
.y
-mn
[i
].o
.h
/2)) {
974 if(MN_hit(i
,50,own
,HIT_SOME
))
975 WP_bfghit(mn
[i
].o
.x
,mn
[i
].o
.y
-mn
[i
].o
.h
/2,own
);
980 int Z_chktrap (int t
, int d
, int o
, int ht
) {
985 if(Z_istrapped(pl1
.o
.x
,pl1
.o
.y
,pl1
.o
.r
,pl1
.o
.h
)) {
987 if(t
) PL_hit(&pl1
,d
,o
,ht
);
989 if(_2pl
) if(Z_istrapped(pl2
.o
.x
,pl2
.o
.y
,pl2
.o
.r
,pl2
.o
.h
)) {
991 if(t
) PL_hit(&pl2
,d
,o
,ht
);
993 for(i
=0;i
<MAXMN
;++i
) if(mn
[i
].t
&& mn
[i
].st
!=DEAD
)
994 if(Z_istrapped(mn
[i
].o
.x
,mn
[i
].o
.y
,mn
[i
].o
.r
,mn
[i
].o
.h
)) {
996 if(t
) MN_hit(i
,d
,o
,ht
);
1001 void Z_teleobj (int o
, int x
, int y
) {
1005 else if(o
==-2) p
=&pl2
.o
;
1006 else if(o
>=0 && o
<MAXMN
) p
=&mn
[o
].o
;
1008 FX_tfog(p
->x
,p
->y
);FX_tfog(p
->x
=x
,p
->y
=y
);
1009 Z_sound(telesnd
,128);
1012 void MN_warning (int l
,int t
,int r
,int b
) {
1015 for(i
=0;i
<MAXMN
;++i
) if(mn
[i
].t
&& mn
[i
].t
!=MN_CACO
&& mn
[i
].t
!=MN_SOUL
1016 && mn
[i
].t
!=MN_PAIN
&& mn
[i
].t
!=MN_FISH
)
1017 if(mn
[i
].st
!=DIE
&& mn
[i
].st
!=DEAD
&& mn
[i
].st
!=SLEEP
)
1018 if(mn
[i
].o
.x
+mn
[i
].o
.r
>=l
&& mn
[i
].o
.x
-mn
[i
].o
.r
<=r
1019 && mn
[i
].o
.y
>=t
&& mn
[i
].o
.y
-mn
[i
].o
.h
<=b
)
1020 if(Z_canstand(mn
[i
].o
.x
,mn
[i
].o
.y
,mn
[i
].o
.r
))
1021 mn
[i
].o
.yv
=-mnsz
[mn
[i
].t
].jv
;