DEADSOFTWARE

update copyrights
[flatwaifu.git] / src / weapons.c
index b778a0ec96c484a448264ae979454c9a9e0b70a7..624fc7e8ef8f862d07c32669e2928066b00b780a 100644 (file)
@@ -1,24 +1,19 @@
-/*
-   Copyright (C) Prikol Software 1996-1997
-   Copyright (C) Aleksey Volynskov 1996-1997
-   Copyright (C) <ARembo@gmail.com> 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 <http://www.gnu.org/licenses/> 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 <http://www.gnu.org/licenses/>.
+ */
 
 #include "glob.h"
 #include <stdlib.h>
 #include "smoke.h"
 #include "weapons.h"
 #include "misc.h"
-
-extern int hit_xv,hit_yv;
-
-void bfg_fly(int x,int y,int own);
+#include "files.h"
+#include "game.h"
+#include "player.h"
+#include "monster.h"
+#include "switch.h"
+#include "my.h"
 
 enum{NONE=0,ROCKET,PLASMA,APLASMA,BALL1,BALL2,BALL7,BFGBALL,BFGHIT,
      MANF,REVF,FIRE};
 
-#pragma pack(1)
-typedef struct{
-  obj_t o;
-  byte t,s;
-  int own;
-  short target;
-}weapon_t;
-#pragma pack()
-
-static void *snd[14],*spr[49*2];
-static char sprd[49*2];
-static weapon_t wp[MAXWPN];
+weapon_t wp[MAXWPN];
 
+static void *snd[14];
 static void throw(int,int,int,int,int,int,int,int);
 
-void WP_savegame(FILE* h) {
-  int n;
-
-  for(n=MAXWPN;--n;) if(wp[n].t) break;
-  ++n;myfwrite(&n,1,4,h);myfwrite(wp,1,n*sizeof(wp[0]),h);
-}
-
-void WP_loadgame(FILE* h) {
-  int n;
-
-  myfread(&n,1,4,h);myfread(wp,1,n*sizeof(wp[0]),h);
-}
-
-void WP_alloc(void) {
+void WP_alloc (void) {
   int i;
   static char nm[14][6]={
        "PISTOL",
@@ -82,69 +56,16 @@ void WP_alloc(void) {
        "SPARK1",
        "SPARK2"
   };
-
-  for(i=0;i<4;++i) {
-       spr[i*2]=Z_getspr("MISL",i,1,sprd+i*2);
-       spr[i*2+1]=Z_getspr("MISL",i,2,sprd+i*2+1);
-  }
-  for(;i<6;++i) {
-       spr[i*2]=Z_getspr("PLSS",i-4,1,sprd+i*2);
-       spr[i*2+1]=Z_getspr("PLSS",i-4,2,sprd+i*2+1);
-  }
-  for(;i<11;++i) {
-    spr[i*2]=Z_getspr("PLSE",i-6,1,sprd+i*2);
-    spr[i*2+1]=Z_getspr("PLSE",i-6,2,sprd+i*2+1);
-  }
-  for(;i<13;++i) {
-    spr[i*2]=Z_getspr("APLS",i-11,1,sprd+i*2);
-    spr[i*2+1]=Z_getspr("APLS",i-11,2,sprd+i*2+1);
-  }
-  for(;i<18;++i) {
-    spr[i*2]=Z_getspr("APBX",i-13,1,sprd+i*2);
-    spr[i*2+1]=Z_getspr("APBX",i-13,2,sprd+i*2+1);
-  }
-  for(;i<20;++i) {
-    spr[i*2]=Z_getspr("BFS1",i-18,1,sprd+i*2);
-    spr[i*2+1]=Z_getspr("BFS1",i-18,2,sprd+i*2+1);
-  }
-  for(;i<26;++i) {
-       spr[i*2]=Z_getspr("BFE1",i-20,1,sprd+i*2);
-       spr[i*2+1]=Z_getspr("BFE1",i-20,2,sprd+i*2+1);
-  }
-  for(;i<30;++i) {
-    spr[i*2]=Z_getspr("BFE2",i-26,1,sprd+i*2);
-    spr[i*2+1]=Z_getspr("BFE2",i-26,2,sprd+i*2+1);
-  }
-  for(;i<32;++i) {
-    spr[i*2]=Z_getspr("MISL",i-30+4,1,sprd+i*2);
-    spr[i*2+1]=Z_getspr("MISL",i-30+4,2,sprd+i*2+1);
-  }
-  for(;i<37;++i) {
-       spr[i*2]=Z_getspr("BAL1",i-32,1,sprd+i*2);
-       spr[i*2+1]=Z_getspr("BAL1",i-32,2,sprd+i*2+1);
-  }
-  for(;i<42;++i) {
-       spr[i*2]=Z_getspr("BAL7",i-37,1,sprd+i*2);
-       spr[i*2+1]=Z_getspr("BAL7",i-37,2,sprd+i*2+1);
-  }
-  for(;i<47;++i) {
-       spr[i*2]=Z_getspr("BAL2",i-42,1,sprd+i*2);
-       spr[i*2+1]=Z_getspr("BAL2",i-42,2,sprd+i*2+1);
-  }
-  for(;i<49;++i) {
-       spr[i*2]=Z_getspr("MANF",i-47,1,sprd+i*2);
-       spr[i*2+1]=Z_getspr("MANF",i-47,2,sprd+i*2+1);
-  }
   for(i=0;i<14;++i) snd[i]=Z_getsnd(nm[i]);
 }
 
-void WP_init(void) {
+void WP_init (void) {
   int i;
 
   for(i=0;i<MAXWPN;++i) wp[i].t=NONE;
 }
 
-void WP_act(void) {
+void WP_act (void) {
   int i,st;
   static obj_t o;
 
@@ -224,49 +145,7 @@ void WP_act(void) {
   }
 }
 
-void WP_draw(void) {
-  int i,s,d,x,y;
-
-  for(i=0;i<MAXWPN;++i) {
-    s=-1;d=0;
-    switch(wp[i].t) {
-      case NONE: default: break;
-      case REVF:
-      case ROCKET:
-               if((d=wp[i].s)<2) {
-                 d=(wp[i].o.xv>0)?1:0;
-                 x=abs(wp[i].o.xv);y=wp[i].o.yv;s=0;
-                 if(y<0) {if(-y>=x) s=30;}
-                 else if(y>0) if(y>=x/2) s=31;
-               }else {s=(d-2)/2+1;d=0;}
-               break;
-         case MANF:
-           if((s=wp[i].s)>=2) {s/=2;break;}
-         case PLASMA:
-         case APLASMA:
-         case BALL1:
-         case BALL7:
-         case BALL2:
-               if((s=wp[i].s)>=2) s=s/2+1;
-               switch(wp[i].t) {
-                 case PLASMA: s+=4;break;
-                 case APLASMA: s+=11;break;
-                 case BALL1: s+=32;break;
-                 case BALL2: s+=42;break;
-                 case BALL7: s+=37;d=(wp[i].o.xv>=0)?1:0;break;
-                 case MANF: s+=47;d=(wp[i].o.xv>=0)?1:0;break;
-               }break;
-         case BFGBALL:
-               if((s=wp[i].s)>=2) s=s/2+1;
-               s+=18;break;
-         case BFGHIT:
-               s=wp[i].s/2+26;break;
-    }
-    if(s>=0) Z_drawspr(wp[i].o.x,wp[i].o.y,spr[s*2+d],sprd[s*2+d]);
-  }
-}
-
-void WP_gun(int x,int y,int xd,int yd,int o,int v) {
+void WP_gun (int x, int y, int xd, int yd, int o, int v) {
   register dword d,m;
   int sx,sy,lx,ly;
   dword xe,ye,s;
@@ -320,7 +199,7 @@ void WP_gun(int x,int y,int xd,int yd,int o,int v) {
   }
 }
 
-void WP_punch(int x,int y,int d,int own) {
+void WP_punch (int x, int y, int d, int own) {
   obj_t o;
 
   o.x=x;o.y=y;o.r=12;o.h=26;
@@ -328,7 +207,7 @@ void WP_punch(int x,int y,int d,int own) {
   if(Z_hit(&o,d,own,HIT_SOME)) Z_sound(snd[9],128);
 }
 
-int WP_chainsaw(int x,int y,int d,int own) {
+int WP_chainsaw (int x, int y, int d, int own) {
   obj_t o;
 
   o.x=x;o.y=y;o.r=12;o.h=26;
@@ -348,7 +227,7 @@ static void throw(int i,int x,int y,int xd,int yd,int r,int h,int s) {
   wp[i].o.vx=wp[i].o.vy=0;
 }
 
-void WP_rocket(int x,int y,int xd,int yd,int o) {
+void WP_rocket (int x, int y, int xd, int yd, int o) {
   int i;
 
   for(i=0;i<MAXWPN;++i) if(!wp[i].t) {
@@ -360,7 +239,7 @@ void WP_rocket(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_revf(int x,int y,int xd,int yd,int o,int t) {
+void WP_revf (int x, int y, int xd, int yd, int o, int t) {
   int i;
 
   for(i=0;i<MAXWPN;++i) if(!wp[i].t) {
@@ -372,7 +251,7 @@ void WP_revf(int x,int y,int xd,int yd,int o,int t) {
   }
 }
 
-void WP_plasma(int x,int y,int xd,int yd,int o) {
+void WP_plasma (int x, int y, int xd, int yd, int o) {
   int i;
 
   for(i=0;i<MAXWPN;++i) if(!wp[i].t) {
@@ -384,7 +263,7 @@ void WP_plasma(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_ball1(int x,int y,int xd,int yd,int o) {
+void WP_ball1 (int x, int y, int xd, int yd, int o) {
   int i;
 
   for(i=0;i<MAXWPN;++i) if(!wp[i].t) {
@@ -395,7 +274,7 @@ void WP_ball1(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_ball2(int x,int y,int xd,int yd,int o) {
+void WP_ball2 (int x, int y, int xd, int yd, int o) {
   int i;
 
   for(i=0;i<MAXWPN;++i) if(!wp[i].t) {
@@ -406,7 +285,7 @@ void WP_ball2(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_ball7(int x,int y,int xd,int yd,int o) {
+void WP_ball7 (int x, int y, int xd, int yd, int o) {
   int i;
 
   for(i=0;i<MAXWPN;++i) if(!wp[i].t) {
@@ -417,7 +296,7 @@ void WP_ball7(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_aplasma(int x,int y,int xd,int yd,int o) {
+void WP_aplasma (int x, int y, int xd, int yd, int o) {
   int i;
 
   for(i=0;i<MAXWPN;++i) if(!wp[i].t) {
@@ -429,7 +308,7 @@ void WP_aplasma(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_manfire(int x,int y,int xd,int yd,int o) {
+void WP_manfire (int x, int y, int xd, int yd, int o) {
   int i;
 
   for(i=0;i<MAXWPN;++i) if(!wp[i].t) {
@@ -441,7 +320,7 @@ void WP_manfire(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_bfgshot(int x,int y,int xd,int yd,int o) {
+void WP_bfgshot (int x, int y, int xd, int yd, int o) {
   int i;
 
   for(i=0;i<MAXWPN;++i) if(!wp[i].t) {
@@ -452,7 +331,7 @@ void WP_bfgshot(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_bfghit(int x,int y,int o) {
+void WP_bfghit (int x, int y, int o) {
   int i;
 
   for(i=0;i<MAXWPN;++i) if(!wp[i].t) {
@@ -466,7 +345,7 @@ void WP_bfghit(int x,int y,int o) {
   }
 }
 
-void WP_pistol(int x,int y,int xd,int yd,int o) {
+void WP_pistol (int x,int y,int xd,int yd,int o) {
   Z_sound(snd[0],96);
   WP_gun(x,y,xd,yd,o,1);
   if(g_dm) {
@@ -475,12 +354,12 @@ void WP_pistol(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_mgun(int x,int y,int xd,int yd,int o) {
+void WP_mgun (int x, int y, int xd, int yd, int o) {
   Z_sound(snd[11],128);
   WP_gun(x,y,xd,yd,o,1);
 }
 
-void WP_shotgun(int x,int y,int xd,int yd,int o) {
+void WP_shotgun (int x, int y, int xd, int yd, int o) {
   int i,j;
 
   Z_sound(snd[1],128);
@@ -490,7 +369,7 @@ void WP_shotgun(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_dshotgun(int x,int y,int xd,int yd,int o) {
+void WP_dshotgun (int x, int y, int xd, int yd, int o) {
   int i,j;
 
   Z_sound(snd[2],128);
@@ -500,7 +379,7 @@ void WP_dshotgun(int x,int y,int xd,int yd,int o) {
   }
 }
 
-void WP_ognemet(int x,int y,int xd,int yd,int xv,int yv,int o) {
+void WP_ognemet (int x, int y, int xd, int yd, int xv, int yv, int o) {
   int m;
 
   m=abs(xd-x);if(!m) m=abs(yd-y);