X-Git-Url: https://deadsoftware.ru/gitweb?p=flatwaifu.git;a=blobdiff_plain;f=src%2Fmonster.c;h=1d4743023c777807591226d1019440042a41c818;hp=935b5c608faaf56cc6e27ddf7031976e27a699e5;hb=ef16dea09f87b15fc6d58fae0aa0832e0648c00e;hpb=534310c1f131bb9a53be865c32d90342ed026734 diff --git a/src/monster.c b/src/monster.c index 935b5c6..1d47430 100644 --- a/src/monster.c +++ b/src/monster.c @@ -1,29 +1,23 @@ -/* - Copyright (C) Prikol Software 1996-1997 - Copyright (C) Aleksey Volynskov 1996-1997 - Copyright (C) 2011 - - This file is part of the Doom2D:Rembo project. - - Doom2D:Rembo is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. - - Doom2D:Rembo is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see or - write to the Free Software Foundation, Inc., - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ +/* Copyright (C) 1996-1997 Aleksey Volynskov + * Copyright (C) 2011 Rambo + * Copyright (C) 2020 SovietPony + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License ONLY. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "glob.h" #include #include -#include "vga.h" #include "files.h" #include "view.h" #include "bmap.h" @@ -37,20 +31,21 @@ #include "fx.h" #include "smoke.h" #include "my.h" +#include "player.h" +#include "error.h" +#include "game.h" #define MAX_ATM 90 -extern byte z_mon; - enum{ SLEEP,GO,RUN,CLIMB,DIE,DEAD,ATTACK,SHOOT,PAIN,WAIT,REVIVE,RUNOUT }; -typedef struct{ - int r,h,l,mp,rv,jv,sp,minp; -}mnsz_t; +typedef struct { + int r, h, l, mp, rv, jv, sp, minp; +} mnsz_t; -byte nomon=1; +byte nomon = 1; static char *sleepanim[MN_TN]={ "AAABBB","AAABBB","AAABBB","AAABBB","AAABBB","AAABBB","AAABBB","AAABBB", @@ -88,14 +83,14 @@ static char *sleepanim[MN_TN]={ "","U","U","U","","T","","","","","","","","","","","","","","W" }; -int hit_xv,hit_yv; +int hit_xv, hit_yv; mn_t mn[MAXMN]; +int mnum, gsndt; static void *fsnd,*pauksnd,*trupsnd; static void *snd[MN_TN][5],*impsitsnd[2],*impdthsnd[2],*firsnd,*slopsnd,*gsnd[4]; static void *swgsnd,*pchsnd,*telesnd; static void *positsnd[3],*podthsnd[3]; -static int mnum,gsndt; static mnsz_t mnsz[MN_TN+1]={ //rad ht life pain rv jv slop min_pn 0, 0, 0, 0, 0, 0, 0, 0, // none @@ -121,88 +116,51 @@ static mnsz_t mnsz[MN_TN+1]={ 8, 26, 400, 70, 8,10, 30, 50 // man }; -void MN_savegame (FILE *h) { - int i, n; - for (n = MAXMN - 1; n >= 0 && mn[n].t == 0; n--) { - // empty - } - n += 1; - myfwrite32(n, h); - for (i = 0; i < n; i++) { - myfwrite32(mn[i].o.x, h); - myfwrite32(mn[i].o.y, h); - myfwrite32(mn[i].o.xv, h); - myfwrite32(mn[i].o.yv, h); - myfwrite32(mn[i].o.vx, h); - myfwrite32(mn[i].o.vy, h); - myfwrite32(mn[i].o.r, h); - myfwrite32(mn[i].o.h, h); - myfwrite8(mn[i].t, h); - myfwrite8(mn[i].d, h); - myfwrite8(mn[i].st, h); - myfwrite8(mn[i].ftime, h); - myfwrite32(mn[i].fobj, h); - myfwrite32(mn[i].s, h); - myfwrite32(0, h); // mn[i].ap useless, changed after load - myfwrite32(mn[i].aim, h); - myfwrite32(mn[i].life, h); - myfwrite32(mn[i].pain, h); - myfwrite32(mn[i].ac, h); - myfwrite32(mn[i].tx, h); - myfwrite32(mn[i].ty, h); - myfwrite32(mn[i].ammo, h); - myfwrite16(mn[i].atm, h); - } - myfwrite32(mnum, h); - myfwrite32(gsndt, h); -} - -static void setst(int,int); - -static int MN_hit(int n,int d,int o,int t); +void setst (int i, int st) { + char *a; + int t; -void MN_loadgame (FILE *h) { - int i, n, c; - n = myfread32(h); - for (i = 0; i < n; i++) { - mn[i].o.x = myfread32(h); - mn[i].o.y = myfread32(h); - mn[i].o.xv = myfread32(h); - mn[i].o.yv = myfread32(h); - mn[i].o.vx = myfread32(h); - mn[i].o.vy = myfread32(h); - mn[i].o.r = myfread32(h); - mn[i].o.h = myfread32(h); - mn[i].t = myfread8(h); - mn[i].d = myfread8(h); - mn[i].st = myfread8(h); - mn[i].ftime = myfread8(h); - mn[i].fobj = myfread32(h); - mn[i].s = myfread32(h); - mn[i].ap = NULL; myfread32(h); // useless, changed after loading - mn[i].aim = myfread32(h); - mn[i].life = myfread32(h); - mn[i].pain = myfread32(h); - mn[i].ac = myfread32(h); - mn[i].tx = myfread32(h); - mn[i].ty = myfread32(h); - mn[i].ammo = myfread32(h); - mn[i].atm = myfread16(h); + switch(mn[i].st) { + case DIE: case DEAD: + if(st!=DEAD && st!=REVIVE) return; } - mnum = myfread32(h); - gsndt = myfread32(h); - for (n = 0; n < MAXMN; ++n) { - if (mn[n].t) { - c = mn[n].ac; - setst(n, mn[n].st); - mn[n].ac = c; - } + mn[i].ac=0; + t=mn[i].t-1; + switch(mn[i].st=st) { + case SLEEP: a=sleepanim[t];break; + case PAIN: a=painanim[t];break; + case WAIT: a=waitanim[t];break; + case CLIMB: + case RUN: case RUNOUT: + case GO: a=goanim[t];break; + case SHOOT: + if(t==MN_SKEL-1) {a="KKKKJJ";break;} + if(t==MN_ROBO-1) {a="MN";break;} + case ATTACK: a=attackanim[t]; + if(st==ATTACK && t==MN_VILE-1) a="[[\\\\]]"; + break; + case DIE: + if(g_map==9 && t==MN_BSP-1) Z_sound(pauksnd,128); + a=dieanim[t];break; + case DEAD: + a=deadanim[t]; + if(mn[i].ap==slopanim[t]) a=messanim[t]; + if(t==MN_BARREL-1) {mn[i].t=0;} + break; + case REVIVE: + a=(mn[i].ap==messanim[t])?slopanim[t]:dieanim[t]; + mn[i].ac=strlen(a)-1; + mn[i].o.r=mnsz[t+1].r;mn[i].o.h=mnsz[t+1].h; + mn[i].life=mnsz[t+1].l;mn[i].ammo=mn[i].pain=0; + ++mnum; + break; } + mn[i].ap=a; } #define GGAS_TOTAL (MN__LAST-MN_DEMON+16+10) -void MN_alloc(void) { +void MN_alloc (void) { int i,j; static char sn[MN_TN][5][6]={ {"DMACT","DMPAIN","SGTATK","SGTSIT","SGTDTH"}, @@ -256,56 +214,13 @@ void MN_alloc(void) { for(i=0;i<4;++i) {gsn[4]=i+'1';gsnd[i]=Z_getsnd(gsn);} } -void MN_init(void) { +void MN_init (void) { int i; - for(i=0;ix,o->y,c,t+MN_PL_DEAD))==-1) return -1; @@ -374,7 +289,7 @@ static int MN_findnewprey(int i) { return 1; } -int Z_getobjpos(int i,obj_t *o) { +int Z_getobjpos (int i, obj_t *o) { if(i==-1) {*o=pl1.o;return !PL_isdead(&pl1);} if(_2pl) if(i==-2) {*o=pl2.o;return !PL_isdead(&pl2);} if(i>=0 && i=MAXMN) return 0; + if(mn[obj].t) return MN_hit(obj,d,own,t); + return 0; +} + +void MN_act (void) { int i,st,sx,sy,t; static obj_t o; static int pt_x=0,pt_xs=1,pt_y=0,pt_ys=1; @@ -785,7 +709,7 @@ void MN_act(void) { } } -void MN_mark(void) { +void MN_mark (void) { int i; for(i=0;io.y-o.h && x>=o.x-o.r && x<=o.x+o.r) -int Z_gunhit(int x,int y,int o,int xv,int yv) { +int Z_gunhit (int x, int y, int o, int xv, int yv) { int i; if(o!=-1) if(hit(pl1.o,x,y)) if(PL_hit(&pl1,3,o,HIT_SOME)) @@ -875,7 +799,7 @@ static void goodsnd(void) { gsndt=18; } -int Z_hit(obj_t *o,int d,int own,int t) { +int Z_hit (obj_t *o, int d, int own, int t) { int i; hit_xv=o->xv+o->vx; @@ -902,24 +826,14 @@ int Z_hit(obj_t *o,int d,int own,int t) { return 0; } -void MN_killedp(void) { +void MN_killedp (void) { int i; - for(i=0;i=MAXMN) return 0; - if(mn[obj].t) return MN_hit(obj,d,own,t); - return 0; -} - -void Z_explode(int x,int y,int rad,int own) { +void Z_explode (int x,int y,int rad,int own) { long r; int dx,dy,m,i; @@ -953,7 +867,7 @@ void Z_explode(int x,int y,int rad,int own) { } } -void Z_bfg9000(int x,int y,int own) { +void Z_bfg9000 (int x,int y,int own) { int dx,dy,i; hit_xv=hit_yv=0; @@ -983,7 +897,7 @@ void Z_bfg9000(int x,int y,int own) { } } -int Z_chktrap(int t,int d,int o,int ht) { +int Z_chktrap (int t, int d, int o, int ht) { int i,s; hit_xv=hit_yv=0; @@ -1004,7 +918,7 @@ int Z_chktrap(int t,int d,int o,int ht) { return s; } -void Z_teleobj(int o,int x,int y) { +void Z_teleobj (int o, int x, int y) { obj_t *p; if(o==-1) p=&pl1.o; @@ -1015,7 +929,7 @@ void Z_teleobj(int o,int x,int y) { Z_sound(telesnd,128); } -void MN_warning(int l,int t,int r,int b) { +void MN_warning (int l,int t,int r,int b) { int i; for(i=0;i