From 18896fd0cd2dddb05830b5d45626affd55a3d3b1 Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 13 Jan 2009 12:23:18 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@1208 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/build.h | 21 +- polymer/eduke32/build/src/build.c | 322 +- polymer/eduke32/build/src/engine.c | 611 +-- polymer/eduke32/build/src/polymost.c | 56 +- polymer/eduke32/source/actors.c | 194 +- polymer/eduke32/source/astub.c | 150 +- polymer/eduke32/source/duke3d.h | 11 +- polymer/eduke32/source/funct.h | 2 +- polymer/eduke32/source/game.c | 278 +- polymer/eduke32/source/gameexec.c | 138 +- polymer/eduke32/source/gamevars.c | 36 +- polymer/eduke32/source/global.c | 4 +- polymer/eduke32/source/mapster32.h | 3 +- polymer/eduke32/source/osdcmds.c | 10 +- polymer/eduke32/source/player.c | 5384 +++++++++++++------------ polymer/eduke32/source/premap.c | 8 +- polymer/eduke32/source/sector.c | 37 +- polymer/eduke32/source/sounds.c | 7 +- 18 files changed, 3702 insertions(+), 3570 deletions(-) diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index bd6a49094..2ec2508c4 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -402,6 +402,17 @@ OTHER VARIABLES: you call the loadboard function. ***************************************************************************/ +typedef struct BPACK { + int32_t x, y, z; +} vec3_t; + +typedef struct { + vec3_t pos; + int16_t hitsprite; + int16_t hitwall; + int16_t hitsect; +} hitdata_t; + int32_t preinitengine(void); // a partial setup of the engine used for launch windows int32_t initengine(void); void uninitengine(void); @@ -443,12 +454,12 @@ void drawline256(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col); int32_t printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, char *name, char fontsize); void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, char *name, char fontsize); -int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype); +int32_t clipmove(vec3_t *vect, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype); int32_t clipinsidebox(int32_t x, int32_t y, int16_t wallnum, int32_t walldist); int32_t clipinsideboxline(int32_t x, int32_t y, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t walldist); -int32_t pushmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype); -void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit, int32_t walldist, uint32_t cliptype); -int32_t hitscan(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz, int16_t *hitsect, int16_t *hitwall, int16_t *hitsprite, int32_t *hitx, int32_t *hity, int32_t *hitz, uint32_t cliptype); +int32_t pushmove(vec3_t *vect, int16_t *sectnum, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype); +void getzrange(const vec3_t *vect, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit, int32_t walldist, uint32_t cliptype); +int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz, hitdata_t *hitinfo, uint32_t cliptype); int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite, int32_t *neartaghitdist, int32_t neartagrange, char tagsearch); int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2); void updatesector(int32_t x, int32_t y, int16_t *sectnum); @@ -476,7 +487,7 @@ int32_t insertsprite(int16_t sectnum, int16_t statnum); int32_t deletesprite(int16_t spritenum); int32_t changespritesect(int16_t spritenum, int16_t newsectnum); int32_t changespritestat(int16_t spritenum, int16_t newstatnum); -int32_t setsprite(int16_t spritenum, int32_t newx, int32_t newy, int32_t newz); +int32_t setsprite(int16_t spritenum, vec3_t *new); int32_t screencapture(char *filename, char inverseit); diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index ade1d3cac..2ed6fcf61 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -66,7 +66,8 @@ uint8_t buildkeys[NUMBUILDKEYS] = 0x9c,0x1c,0xd,0xc,0xf,0x29 }; -int32_t posx, posy, posz, horiz = 100; +vec3_t pos; +int32_t horiz = 100; int32_t mousexsurp = 0, mouseysurp = 0; int16_t ang, cursectnum; int32_t hvel; @@ -394,15 +395,15 @@ int32_t app_main(int32_t argc, const char **argv) for (i=0;i>14; - posy += yvect>>14; - updatesector(posx,posy,&cursectnum); + pos.x += xvect>>14; + pos.y += yvect>>14; + updatesector(pos.x,pos.y,&cursectnum); } - else clipmove(&posx,&posy,&posz,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); + else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); } else if (!mlook && (bstatus&2) && !(bstatus&(1|4))) { @@ -669,14 +670,14 @@ void editinput(void) zmode = 2; xvect = -((mousx*(int32_t)sintable[(ang+2048)&2047])<>14; - posy += yvect>>14; - updatesectorz(posx,posy,posz,&cursectnum); + pos.x += xvect>>14; + pos.y += yvect>>14; + updatesectorz(pos.x,pos.y,pos.z,&cursectnum); } - else clipmove(&posx,&posy,&posz,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); + else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); } else if (bstatus&4) { @@ -696,14 +697,14 @@ void editinput(void) zvect = mousy*(((int32_t)sintable[(tempint+2048)&2047])>>(10-pk_uedaccel)); - posz += zvect; + pos.z += zvect; if (noclip) { - posx += xvect>>16; - posy += yvect>>16; - updatesectorz(posx,posy,posz,&cursectnum); + pos.x += xvect>>16; + pos.y += yvect>>16; + updatesectorz(pos.x,pos.y,pos.z,&cursectnum); } - else clipmove(&posx,&posy,&posz,&cursectnum,xvect>>2,yvect>>2,128L,4L<<8,4L<<8,CLIPMASK0); + else clipmove(&pos,&cursectnum,xvect>>2,yvect>>2,128L,4L<<8,4L<<8,CLIPMASK0); } } @@ -747,10 +748,10 @@ void editinput(void) // showmouse(); -// if (keystatus[0x3b] > 0) posx--; -// if (keystatus[0x3c] > 0) posx++; -// if (keystatus[0x3d] > 0) posy--; -// if (keystatus[0x3e] > 0) posy++; +// if (keystatus[0x3b] > 0) pos.x--; +// if (keystatus[0x3c] > 0) pos.x++; +// if (keystatus[0x3d] > 0) pos.y--; +// if (keystatus[0x3e] > 0) pos.y++; // if (keystatus[0x43] > 0) ang--; // if (keystatus[0x44] > 0) ang++; @@ -799,19 +800,19 @@ void editinput(void) } if (noclip) { - posx += xvect>>14; - posy += yvect>>14; - updatesector(posx,posy,&cursectnum); + pos.x += xvect>>14; + pos.y += yvect>>14; + updatesector(pos.x,pos.y,&cursectnum); } - else clipmove(&posx,&posy,&posz,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); + else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); } - getzrange(posx,posy,posz,cursectnum,&hiz,&hihit,&loz,&lohit,128L,CLIPMASK0); + getzrange(&pos,cursectnum,&hiz,&hihit,&loz,&lohit,128L,CLIPMASK0); /* if (keystatus[0x3a] > 0) { zmode++; if (zmode == 3) zmode = 0; - if (zmode == 1) zlock = (loz-posz)&0xfffffc00; + if (zmode == 1) zlock = (loz-pos.z)&0xfffffc00; keystatus[0x3a] = 0; }*/ @@ -848,19 +849,19 @@ void editinput(void) } } - if (goalz != posz) + if (goalz != pos.z) { - if (posz < goalz) hvel += 64; - if (posz > goalz) hvel = ((goalz-posz)>>3); + if (pos.z < goalz) hvel += 64; + if (pos.z > goalz) hvel = ((goalz-pos.z)>>3); - posz += hvel; - if (posz > loz-(4<<8)) posz = loz-(4<<8), hvel = 0; - if (posz < hiz+(4<<8)) posz = hiz+(4<<8), hvel = 0; + pos.z += hvel; + if (pos.z > loz-(4<<8)) pos.z = loz-(4<<8), hvel = 0; + if (pos.z < hiz+(4<<8)) pos.z = hiz+(4<<8), hvel = 0; } } else { - goalz = posz; + goalz = pos.z; if (keystatus[buildkeys[BK_MOVEUP]]) //A { if (keystatus[0x1d]|keystatus[0x9d]) @@ -903,21 +904,21 @@ void editinput(void) } if (zmode == 1) goalz = loz-zlock; if (!noclip && (goalz < hiz+(4<<8))) goalz = ((loz+hiz)>>1); //ceiling&floor too close - if (zmode == 1) posz = goalz; + if (zmode == 1) pos.z = goalz; - if (goalz != posz) + if (goalz != pos.z) { - //if (posz < goalz) hvel += (32< goalz) hvel -= (32< goalz) hvel = ((synctics*-192)< goalz) hvel -= (32< goalz) hvel = ((synctics*-192)< loz-(4<<8)) posz = loz-(4<<8), hvel = 0; - if (posz < hiz+(4<<8)) posz = hiz+(4<<8), hvel = 0; + if (pos.z > loz-(4<<8)) pos.z = loz-(4<<8), hvel = 0; + if (pos.z < hiz+(4<<8)) pos.z = hiz+(4<<8), hvel = 0; } } else @@ -936,19 +937,19 @@ void editinput(void) day = divscale14(searchx-(xdim>>1),xdim>>1); rotatepoint(0,0,dax,day,ang,&dax,&day); - hitscan(posx,posy,posz,cursectnum, //Start position + hitscan((const vec3_t *)&pos,cursectnum, //Start position dax,day,(scale(searchy,200,ydim)-horiz)*2000, //vector of 3D ang - &hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + &hitinfo,CLIPMASK1); - if (hitsect >= 0) + if (hitinfo.hitsect >= 0) { - dax = hitx; - day = hity; + dax = hitinfo.pos.x; + day = hitinfo.pos.x; if ((gridlock > 0) && (grid > 0)) { if ((searchstat == 0) || (searchstat == 4)) { - hitz = (hitz&0xfffffc00); + hitinfo.pos.y = (hitinfo.pos.y&0xfffffc00); } else { @@ -957,7 +958,7 @@ void editinput(void) } } - i = insertsprite(hitsect,0); + i = insertsprite(hitinfo.hitsect,0); sprite[i].x = dax, sprite[i].y = day; sprite[i].cstat = defaultspritecstat; sprite[i].shade = 0; @@ -1011,22 +1012,27 @@ void editinput(void) j = ((tilesizy[sprite[i].picnum]*sprite[i].yrepeat)<<1); if ((sprite[i].cstat&128) == 0) - sprite[i].z = min(max(hitz,getceilzofslope(hitsect,hitx,hity)+(j<<1)),getflorzofslope(hitsect,hitx,hity)); + sprite[i].z = min(max(hitinfo.pos.y, + getceilzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)+(j<<1)), + getflorzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)); else - sprite[i].z = min(max(hitz,getceilzofslope(hitsect,hitx,hity)+j),getflorzofslope(hitsect,hitx,hity)-j); + sprite[i].z = min(max(hitinfo.pos.y, + getceilzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)+j), + getflorzofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y)-j); if ((searchstat == 0) || (searchstat == 4)) { sprite[i].cstat = (sprite[i].cstat&~48)|(16+64); - if (hitwall >= 0) - sprite[i].ang = ((getangle(wall[wall[hitwall].point2].x-wall[hitwall].x,wall[wall[hitwall].point2].y-wall[hitwall].y)+512)&2047); + if (hitinfo.hitwall >= 0) + sprite[i].ang = ((getangle(wall[wall[hitinfo.hitwall].point2].x-wall[hitinfo.hitwall].x, + wall[wall[hitinfo.hitwall].point2].y-wall[hitinfo.hitwall].y)+512)&2047); //Make sure sprite's in right sector if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) { - j = wall[hitwall].point2; - sprite[i].x -= ksgn(wall[j].y-wall[hitwall].y); - sprite[i].y += ksgn(wall[j].x-wall[hitwall].x); + j = wall[hitinfo.hitwall].point2; + sprite[i].x -= ksgn(wall[j].y-wall[hitinfo.hitwall].y); + sprite[i].y += ksgn(wall[j].x-wall[hitinfo.hitwall].x); } } else @@ -1448,10 +1454,9 @@ void overheadeditor(void) int16_t circlepoints, circleang1, circleang2, circleangdir; int32_t sectorhighlightx=0, sectorhighlighty=0; int16_t cursectorhighlight, sectorhighlightstat; - int16_t hitsect, hitwall, hitsprite; - int32_t hitx, hity, hitz; walltype *wal; int32_t prefixarg = 0; + hitdata_t hitinfo; //qsetmode640480(); qsetmodeany(xdim2d,ydim2d); @@ -1463,7 +1468,7 @@ void overheadeditor(void) searchx = scale(searchx,xdim2d,xdimgame); searchy = scale(searchy,ydim2d-STATUS2DSIZ,ydimgame); - oposz = posz; + oposz = pos.z; begindrawing(); //{{{ clearbuf((char *)(frameplace + (ydim16*bytesperline)), (bytesperline*STATUS2DSIZ) >> 2, 0x00000000l); @@ -1560,10 +1565,10 @@ void overheadeditor(void) if (searchy < 8) searchy = 8; if (searchy > ydim-8-1) searchy = ydim-8-1; - /* if (keystatus[0x3b] > 0) posx--, keystatus[0x3b] = 0; - if (keystatus[0x3c] > 0) posx++, keystatus[0x3c] = 0; - if (keystatus[0x3d] > 0) posy--, keystatus[0x3d] = 0; - if (keystatus[0x3e] > 0) posy++, keystatus[0x3e] = 0; + /* if (keystatus[0x3b] > 0) pos.x--, keystatus[0x3b] = 0; + if (keystatus[0x3c] > 0) pos.x++, keystatus[0x3c] = 0; + if (keystatus[0x3d] > 0) pos.y--, keystatus[0x3d] = 0; + if (keystatus[0x3e] > 0) pos.y++, keystatus[0x3e] = 0; if (keystatus[0x43] > 0) ang--, keystatus[0x43] = 0; if (keystatus[0x44] > 0) ang++, keystatus[0x44] = 0; */ if (angvel != 0) //ang += angvel * constant @@ -1593,11 +1598,11 @@ void overheadeditor(void) } if (noclip) { - posx += xvect>>14; - posy += yvect>>14; - updatesector(posx,posy,&cursectnum); + pos.x += xvect>>14; + pos.y += yvect>>14; + updatesector(pos.x,pos.y,&cursectnum); } - else clipmove(&posx,&posy,&posz,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); + else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); } getpoint(searchx,searchy,&mousxplc,&mousyplc); @@ -1634,18 +1639,18 @@ void overheadeditor(void) if (graphicsmode == 2) totalclocklock = totalclock; - drawmapview(posx, posy, zoom, 1536); + drawmapview(pos.x, pos.y, zoom, 1536); yxaspect = i; ydim = j; xyaspect = ii; } - draw2dgrid(posx,posy,ang,zoom,grid); + draw2dgrid(pos.x,pos.y,ang,zoom,grid); ExtPreCheckKeys(); - x2 = mulscale14(startposx-posx,zoom); //Draw brown arrow (start) - y2 = mulscale14(startposy-posy,zoom); + x2 = mulscale14(startposx-pos.x,zoom); //Draw brown arrow (start) + y2 = mulscale14(startposy-pos.y,zoom); if (((halfxdim16+x2) >= 2) && ((halfxdim16+x2) <= xdim-3)) if (((midydim16+y2) >= 2) && ((midydim16+y2) <= ydim16-3)) { @@ -1658,7 +1663,7 @@ void overheadeditor(void) enddrawing(); //}}} } - draw2dscreen(posx,posy,ang,zoom,grid); + draw2dscreen(pos.x,pos.y,ang,zoom,grid); begindrawing(); //{{{ if (showtags == 1) @@ -1684,8 +1689,8 @@ void overheadeditor(void) day /= (endwall-startwall+1); } - dax = mulscale14(dax-posx,zoom); - day = mulscale14(day-posy,zoom); + dax = mulscale14(dax-pos.x,zoom); + day = mulscale14(day-pos.y,zoom); x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1); y1 = midydim16+day-4; @@ -1704,10 +1709,10 @@ void overheadeditor(void) } } - x3 = divscale14(-halfxdim16,zoom)+posx; - y3 = divscale14(-(midydim16-4),zoom)+posy; - x4 = divscale14(halfxdim16,zoom)+posx; - y4 = divscale14(ydim16-(midydim16-4),zoom)+posy; + x3 = divscale14(-halfxdim16,zoom)+pos.x; + y3 = divscale14(-(midydim16-4),zoom)+pos.y; + x4 = divscale14(halfxdim16,zoom)+pos.x; + y4 = divscale14(ydim16-(midydim16-4),zoom)+pos.y; if (newnumwalls >= 0) { @@ -1728,8 +1733,8 @@ void overheadeditor(void) dabuffer = (char *)ExtGetWallCaption(i); if (dabuffer[0] != 0) { - dax = mulscale14(dax-posx,zoom); - day = mulscale14(day-posy,zoom); + dax = mulscale14(dax-pos.x,zoom); + day = mulscale14(day-pos.y,zoom); x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1); y1 = midydim16+day-4; x2 = x1 + (Bstrlen(dabuffer)<<2)+2; @@ -1761,8 +1766,8 @@ void overheadeditor(void) dax = sprite[i].x; day = sprite[i].y; - dax = mulscale14(dax-posx,zoom); - day = mulscale14(day-posy,zoom); + dax = mulscale14(dax-pos.x,zoom); + day = mulscale14(day-pos.y,zoom); x1 = halfxdim16+dax-(Bstrlen(dabuffer)<<1); y1 = midydim16+day-4; x2 = x1 + (Bstrlen(dabuffer)<<2)+2; @@ -1797,7 +1802,7 @@ void overheadeditor(void) } } - printcoords16(posx,posy,ang); + printcoords16(pos.x,pos.y,ang); numwalls = tempint; @@ -1840,8 +1845,8 @@ void overheadeditor(void) if (linehighlight>=0) { getclosestpointonwall(mousxplc,mousyplc,(int32_t)linehighlight,&dax,&day); - x2 = mulscale14(dax-posx,zoom); - y2 = mulscale14(day-posy,zoom); + x2 = mulscale14(dax-pos.x,zoom); + y2 = mulscale14(day-pos.y,zoom); if (wall[linehighlight].nextsector >= 0) drawline16(halfxdim16+x2,midydim16+y2,halfxdim16+x2,midydim16+y2,editorcolors[15]); else @@ -2102,8 +2107,8 @@ void overheadeditor(void) /* j = ydim16; ydim16 = ydim; clear2dscreen(); - draw2dgrid(posx,posy,ang,zoom,grid); - draw2dscreen(posx,posy,ang,zoom,grid); + draw2dgrid(pos.x,pos.y,ang,zoom,grid); + draw2dscreen(pos.x,pos.y,ang,zoom,grid); */ screencapture("captxxxx.tga",keystatus[0x2a]|keystatus[0x36]); @@ -2111,8 +2116,8 @@ void overheadeditor(void) /* ydim16 = j; clear2dscreen(); - draw2dgrid(posx,posy,ang,zoom,grid); - draw2dscreen(posx,posy,ang,zoom,grid); + draw2dgrid(pos.x,pos.y,ang,zoom,grid); + draw2dscreen(pos.x,pos.y,ang,zoom,grid); */ showframe(1); } @@ -2164,25 +2169,24 @@ void overheadeditor(void) asksave = 1; i = (pointhighlight&16383); - hitscan(sprite[i].x,sprite[i].y,sprite[i].z,sprite[i].sectnum, + hitscan((const vec3_t *)&sprite[i],sprite[i].sectnum, sintable[(sprite[i].ang+2560+1024)&2047], sintable[(sprite[i].ang+2048+1024)&2047], - 0, - &hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + 0,&hitinfo,CLIPMASK1); - sprite[i].x = hitx; - sprite[i].y = hity; - sprite[i].z = hitz; - changespritesect(i,hitsect); - if (hitwall >= 0) - sprite[i].ang = ((getangle(wall[wall[hitwall].point2].x-wall[hitwall].x,wall[wall[hitwall].point2].y-wall[hitwall].y)+512)&2047); + sprite[i].x = hitinfo.pos.x; + sprite[i].y = hitinfo.pos.y; + sprite[i].z = hitinfo.pos.z; + changespritesect(i,hitinfo.hitsect); + if (hitinfo.hitwall >= 0) + sprite[i].ang = ((getangle(wall[wall[hitinfo.hitwall].point2].x-wall[hitinfo.hitwall].x,wall[wall[hitinfo.hitwall].point2].y-wall[hitinfo.hitwall].y)+512)&2047); //Make sure sprite's in right sector if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) { - j = wall[hitwall].point2; - sprite[i].x -= ksgn(wall[j].y-wall[hitwall].y); - sprite[i].y += ksgn(wall[j].x-wall[hitwall].x); + j = wall[hitinfo.hitwall].point2; + sprite[i].x -= ksgn(wall[j].y-wall[hitinfo.hitwall].y); + sprite[i].y += ksgn(wall[j].x-wall[hitinfo.hitwall].x); } } } @@ -2388,9 +2392,9 @@ void overheadeditor(void) } if (keystatus[0x46]) //Scroll lock (set starting position) { - startposx = posx; - startposy = posy; - startposz = posz; + startposx = pos.x; + startposy = pos.y; + startposz = pos.z; startang = ang; startsectnum = cursectnum; keystatus[0x46] = 0; @@ -2799,7 +2803,7 @@ void overheadeditor(void) { j = (highlight[i]&16383); - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(j,(vec3_t *)&sprite[j]); tempint = ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2); sprite[j].z = max(sprite[j].z,getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint); @@ -2811,7 +2815,7 @@ void overheadeditor(void) { j = (pointhighlight&16383); - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(j,(vec3_t *)&sprite[j]); tempint = ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2); @@ -3041,8 +3045,8 @@ SKIP: { searchx = halfxdim16; searchy = midydim16; - posx = mousxplc; - posy = mousyplc; + pos.x = mousxplc; + pos.y = mousyplc; } if (circlewall != -1 && (keystatus[0x4a] || (bstatus&32 && !(keystatus[0x1d]|keystatus[0x9d])))) // - @@ -3070,8 +3074,8 @@ SKIP: { searchx = halfxdim16; searchy = midydim16; - posx = mousxplc; - posy = mousyplc; + pos.x = mousxplc; + pos.y = mousyplc; } if (zoom > 16384) zoom = 16384; printmessage16("Zoom: %d",zoom); @@ -3083,8 +3087,8 @@ SKIP: { searchx = halfxdim16; searchy = midydim16; - posx = mousxplc; - posy = mousyplc; + pos.x = mousxplc; + pos.y = mousyplc; } if (zoom < 8) zoom = 8; printmessage16("Zoom: %d",zoom); @@ -3442,7 +3446,7 @@ SKIP: j = insertsprite(sprite[k].sectnum,sprite[k].statnum); Bmemcpy(&sprite[j],&sprite[k],sizeof(spritetype)); sprite[j].sectnum = sprite[k].sectnum; //Don't let memcpy overwrite sector! - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(j,(vec3_t *)&sprite[j]); } updatenumsprites(); printmessage16("Sprites duplicated and stamped."); @@ -3481,8 +3485,8 @@ SKIP: centerx = (((x1+x2) + scale(y1-y2,tempint1,tempint2))>>1); centery = (((y1+y2) + scale(x2-x1,tempint1,tempint2))>>1); - dax = mulscale14(centerx-posx,zoom); - day = mulscale14(centery-posy,zoom); + dax = mulscale14(centerx-pos.x,zoom); + day = mulscale14(centery-pos.y,zoom); drawline16(halfxdim16+dax-2,midydim16+day-2,halfxdim16+dax+2,midydim16+day+2,editorcolors[14]); drawline16(halfxdim16+dax-2,midydim16+day+2,halfxdim16+dax+2,midydim16+day-2,editorcolors[14]); @@ -3518,8 +3522,8 @@ SKIP: insertpoint(circlewall,dax,day); circlewall += m; } - dax = mulscale14(dax-posx,zoom); - day = mulscale14(day-posy,zoom); + dax = mulscale14(dax-pos.x,zoom); + day = mulscale14(day-pos.y,zoom); drawline16(halfxdim16+dax-pointsize,midydim16+day-pointsize,halfxdim16+dax+pointsize,midydim16+day-pointsize,editorcolors[14]); drawline16(halfxdim16+dax+pointsize,midydim16+day-pointsize,halfxdim16+dax+pointsize,midydim16+day+pointsize,editorcolors[14]); drawline16(halfxdim16+dax+pointsize,midydim16+day+pointsize,halfxdim16+dax-pointsize,midydim16+day+pointsize,editorcolors[14]); @@ -3966,7 +3970,7 @@ SKIP: while (j != -1) { k = nextspritesect[j]; - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(j,(vec3_t *)&sprite[j]); j = k; } } @@ -4278,7 +4282,7 @@ SKIP: j = insertsprite(sprite[k].sectnum,sprite[k].statnum); Bmemcpy(&sprite[j],&sprite[k],sizeof(spritetype)); sprite[j].sectnum = sprite[k].sectnum; //Don't let memcpy overwrite sector! - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(j,(vec3_t *)&sprite[j]); } updatenumsprites(); printmessage16("Sprites duplicated and stamped."); @@ -4363,7 +4367,7 @@ SKIP: if (keystatus[buildkeys[BK_MODE2D_3D]]) { - updatesector(posx,posy,&cursectnum); + updatesector(pos.x,pos.y,&cursectnum); if (cursectnum >= 0) keystatus[buildkeys[BK_MODE2D_3D]] = 2; else @@ -4403,9 +4407,9 @@ nextmap: for (i=0;i= editorgridextent) posx = editorgridextent; - if (posy <= -editorgridextent) posy = -editorgridextent; - if (posy >= editorgridextent) posy = editorgridextent; + if (pos.x <= -editorgridextent) pos.x = -editorgridextent; + if (pos.x >= editorgridextent) pos.x = editorgridextent; + if (pos.y <= -editorgridextent) pos.y = -editorgridextent; + if (pos.y >= editorgridextent) pos.y = editorgridextent; - *x = posx + divscale14(searchxe-halfxdim16,zoom); - *y = posy + divscale14(searchye-midydim16,zoom); + *x = pos.x + divscale14(searchxe-halfxdim16,zoom); + *y = pos.y + divscale14(searchye-midydim16,zoom); if (*x <= -editorgridextent) *x = -editorgridextent; if (*x >= editorgridextent) *x = editorgridextent; @@ -5462,7 +5466,7 @@ int32_t _getnumber256(char *namestart, int32_t num, int32_t maxnumber, char sign if (quitevent) quitevent = 0; } - drawrooms(posx,posy,posz,ang,horiz,cursectnum); + drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); #ifdef SUPERBUILD ExtAnalyzeSprites(); #endif @@ -5885,8 +5889,8 @@ int32_t fillsector(int16_t sectnum, char fillcolor) endwall = startwall + sector[sectnum].wallnum - 1; for (z=startwall;z<=endwall;z++) { - y1 = (((wall[z].y-posy)*zoom)>>14)+midydim16; - y2 = (((wall[wall[z].point2].y-posy)*zoom)>>14)+midydim16; + y1 = (((wall[z].y-pos.y)*zoom)>>14)+midydim16; + y2 = (((wall[wall[z].point2].y-pos.y)*zoom)>>14)+midydim16; if (y1 < miny) miny = y1; if (y2 < miny) miny = y2; if (y1 > maxy) maxy = y1; @@ -5897,7 +5901,7 @@ int32_t fillsector(int16_t sectnum, char fillcolor) for (sy=miny+((totalclock>>2)&3);sy<=maxy;sy+=3) // JBF 20040116: numframes%3 -> (totalclock>>2)&3 { - y = posy+(((sy-midydim16)<<14)/zoom); + y = pos.y+(((sy-midydim16)<<14)/zoom); fillist[0] = lborder; fillcnt = 1; for (z=startwall;z<=endwall;z++) @@ -5913,7 +5917,7 @@ int32_t fillsector(int16_t sectnum, char fillcolor) //if (x1*(y-y2) + x2*(y1-y) <= 0) { dax = x1+scale(y-y1,x2-x1,y2-y1); - dax = (((dax-posx)*zoom)>>14)+halfxdim16; + dax = (((dax-pos.x)*zoom)>>14)+halfxdim16; if (dax >= lborder) fillist[fillcnt++] = dax; } @@ -6464,7 +6468,7 @@ void keytimerstuff(void) if (vel < 0) vel = min(vel+6,0); if (vel > 0) vel = max(vel-6,0); /* if(mlook) - posz -= (horiz-101)*(vel/40); */ + pos.z -= (horiz-101)*(vel/40); */ } void _printmessage16(const char *fmt, ...) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 1e9f8835f..8620c6cfd 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -8265,16 +8265,19 @@ int32_t krecip(int32_t num) // // setsprite // -int32_t setsprite(int16_t spritenum, int32_t newx, int32_t newy, int32_t newz) +int32_t setsprite(int16_t spritenum, vec3_t *new) { int16_t tempsectnum; + Bmemcpy(&sprite[spritenum], new, sizeof(vec3_t)); +/* sprite[spritenum].x = newx; sprite[spritenum].y = newy; sprite[spritenum].z = newz; +*/ tempsectnum = sprite[spritenum].sectnum; - updatesector(newx,newy,&tempsectnum); + updatesector(new->x,new->y,&tempsectnum); if (tempsectnum < 0) return(-1); @@ -8284,16 +8287,14 @@ int32_t setsprite(int16_t spritenum, int32_t newx, int32_t newy, int32_t newz) return(0); } -int32_t setspritez(int16_t spritenum, int32_t newx, int32_t newy, int32_t newz) +int32_t setspritez(int16_t spritenum, vec3_t *new) { int16_t tempsectnum; - sprite[spritenum].x = newx; - sprite[spritenum].y = newy; - sprite[spritenum].z = newz; + Bmemcpy(&sprite[spritenum], new, sizeof(vec3_t)); tempsectnum = sprite[spritenum].sectnum; - updatesectorz(newx,newy,newz,&tempsectnum); + updatesectorz(new->x,new->y,new->z,&tempsectnum); if (tempsectnum < 0) return(-1); @@ -8473,9 +8474,8 @@ int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, in // // hitscan // -int32_t hitscan(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz, - int16_t *hitsect, int16_t *hitwall, int16_t *hitsprite, - int32_t *hitx, int32_t *hity, int32_t *hitz, uint32_t cliptype) +int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz, + hitdata_t *hitinfo, uint32_t cliptype) { sectortype *sec; walltype *wal, *wal2; @@ -8489,10 +8489,10 @@ int32_t hitscan(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int32_t vx, int16_t nextsector; char clipyou; - *hitsect = -1; *hitwall = -1; *hitsprite = -1; + hitinfo->hitsect = -1; hitinfo->hitwall = -1; hitinfo->hitsprite = -1; if (sectnum < 0) return(-1); - *hitx = hitscangoalx; *hity = hitscangoaly; + hitinfo->pos.x = hitscangoalx; hitinfo->pos.y = hitscangoaly; dawalclipmask = (cliptype&65535); dasprclipmask = (cliptype>>16); @@ -8515,239 +8515,239 @@ int32_t hitscan(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int32_t vx, j = (vz<<8)-dmulscale15(dax,vy,-day,vx); if (j != 0) { - i = ((sec->ceilingz-zs)<<8)+dmulscale15(dax,ys-wal->y,-day,xs-wal->x); + i = ((sec->ceilingz-sv->z)<<8)+dmulscale15(dax,sv->y-wal->y,-day,sv->x-wal->x); if (((i^j) >= 0) && ((klabs(i)>>1) < klabs(j))) { i = divscale30(i,j); - x1 = xs + mulscale30(vx,i); - y1 = ys + mulscale30(vy,i); - z1 = zs + mulscale30(vz,i); + x1 = sv->x + mulscale30(vx,i); + y1 = sv->y + mulscale30(vy,i); + z1 = sv->z + mulscale30(vz,i); } } } - else if ((vz < 0) && (zs >= sec->ceilingz)) + else if ((vz < 0) && (sv->z >= sec->ceilingz)) { - z1 = sec->ceilingz; i = z1-zs; + z1 = sec->ceilingz; i = z1-sv->z; if ((klabs(i)>>1) < -vz) { i = divscale30(i,vz); - x1 = xs + mulscale30(vx,i); - y1 = ys + mulscale30(vy,i); + x1 = sv->x + mulscale30(vx,i); + y1 = sv->y + mulscale30(vy,i); } } - if ((x1 != 0x7fffffff) && (klabs(x1-xs)+klabs(y1-ys) < klabs((*hitx)-xs)+klabs((*hity)-ys))) + if ((x1 != 0x7fffffff) && (klabs(x1-sv->x)+klabs(y1-sv->y) < klabs((hitinfo->pos.x)-sv->x)+klabs((hitinfo->pos.y)-sv->y))) if (inside(x1,y1,dasector) != 0) { - *hitsect = dasector; *hitwall = -1; *hitsprite = -1; - *hitx = x1; *hity = y1; *hitz = z1; + hitinfo->hitsect = dasector; hitinfo->hitwall = -1; hitinfo->hitsprite = -1; + hitinfo->pos.x = x1; hitinfo->pos.y = y1; hitinfo->pos.z = z1; } - x1 = 0x7fffffff; - if (sec->floorstat&2) - { - wal = &wall[sec->wallptr]; wal2 = &wall[wal->point2]; - dax = wal2->x-wal->x; day = wal2->y-wal->y; - i = nsqrtasm(dax*dax+day*day); if (i == 0) continue; - i = divscale15(sec->floorheinum,i); - dax *= i; day *= i; - - j = (vz<<8)-dmulscale15(dax,vy,-day,vx); - if (j != 0) + x1 = 0x7fffffff; + if (sec->floorstat&2) { - i = ((sec->floorz-zs)<<8)+dmulscale15(dax,ys-wal->y,-day,xs-wal->x); - if (((i^j) >= 0) && ((klabs(i)>>1) < klabs(j))) + wal = &wall[sec->wallptr]; wal2 = &wall[wal->point2]; + dax = wal2->x-wal->x; day = wal2->y-wal->y; + i = nsqrtasm(dax*dax+day*day); if (i == 0) continue; + i = divscale15(sec->floorheinum,i); + dax *= i; day *= i; + + j = (vz<<8)-dmulscale15(dax,vy,-day,vx); + if (j != 0) { - i = divscale30(i,j); - x1 = xs + mulscale30(vx,i); - y1 = ys + mulscale30(vy,i); - z1 = zs + mulscale30(vz,i); + i = ((sec->floorz-sv->z)<<8)+dmulscale15(dax,sv->y-wal->y,-day,sv->x-wal->x); + if (((i^j) >= 0) && ((klabs(i)>>1) < klabs(j))) + { + i = divscale30(i,j); + x1 = sv->x + mulscale30(vx,i); + y1 = sv->y + mulscale30(vy,i); + z1 = sv->z + mulscale30(vz,i); + } } } - } - else if ((vz > 0) && (zs <= sec->floorz)) - { - z1 = sec->floorz; i = z1-zs; - if ((klabs(i)>>1) < vz) + else if ((vz > 0) && (sv->z <= sec->floorz)) { - i = divscale30(i,vz); - x1 = xs + mulscale30(vx,i); - y1 = ys + mulscale30(vy,i); - } - } - if ((x1 != 0x7fffffff) && (klabs(x1-xs)+klabs(y1-ys) < klabs((*hitx)-xs)+klabs((*hity)-ys))) - if (inside(x1,y1,dasector) != 0) - { - *hitsect = dasector; *hitwall = -1; *hitsprite = -1; - *hitx = x1; *hity = y1; *hitz = z1; + z1 = sec->floorz; i = z1-sv->z; + if ((klabs(i)>>1) < vz) + { + i = divscale30(i,vz); + x1 = sv->x + mulscale30(vx,i); + y1 = sv->y + mulscale30(vy,i); + } } + if ((x1 != 0x7fffffff) && (klabs(x1-sv->x)+klabs(y1-sv->y) < klabs((hitinfo->pos.x)-sv->x)+klabs((hitinfo->pos.y)-sv->y))) + if (inside(x1,y1,dasector) != 0) + { + hitinfo->hitsect = dasector; hitinfo->hitwall = -1; hitinfo->hitsprite = -1; + hitinfo->pos.x = x1; hitinfo->pos.y = y1; hitinfo->pos.z = z1; + } - startwall = sec->wallptr; endwall = startwall + sec->wallnum; - for (z=startwall,wal=&wall[startwall];zpoint2]; - x1 = wal->x; y1 = wal->y; x2 = wal2->x; y2 = wal2->y; + startwall = sec->wallptr; endwall = startwall + sec->wallnum; + for (z=startwall,wal=&wall[startwall];zpoint2]; + x1 = wal->x; y1 = wal->y; x2 = wal2->x; y2 = wal2->y; - if ((x1-xs)*(y2-ys) < (x2-xs)*(y1-ys)) continue; - if (rintersect(xs,ys,zs,vx,vy,vz,x1,y1,x2,y2,&intx,&inty,&intz) == 0) continue; + if ((x1-sv->x)*(y2-sv->y) < (x2-sv->x)*(y1-sv->y)) continue; + if (rintersect(sv->x,sv->y,sv->z,vx,vy,vz,x1,y1,x2,y2,&intx,&inty,&intz) == 0) continue; - if (klabs(intx-xs)+klabs(inty-ys) >= klabs((*hitx)-xs)+klabs((*hity)-ys)) continue; + if (klabs(intx-sv->x)+klabs(inty-sv->y) >= klabs((hitinfo->pos.x)-sv->x)+klabs((hitinfo->pos.y)-sv->y)) continue; - nextsector = wal->nextsector; - if ((nextsector < 0) || (wal->cstat&dawalclipmask)) - { - *hitsect = dasector; *hitwall = z; *hitsprite = -1; - *hitx = intx; *hity = inty; *hitz = intz; - continue; - } - getzsofslope(nextsector,intx,inty,&daz,&daz2); - if ((intz <= daz) || (intz >= daz2)) - { - *hitsect = dasector; *hitwall = z; *hitsprite = -1; - *hitx = intx; *hity = inty; *hitz = intz; - continue; - } + nextsector = wal->nextsector; + if ((nextsector < 0) || (wal->cstat&dawalclipmask)) + { + hitinfo->hitsect = dasector; hitinfo->hitwall = z; hitinfo->hitsprite = -1; + hitinfo->pos.x = intx; hitinfo->pos.y = inty; hitinfo->pos.z = intz; + continue; + } + getzsofslope(nextsector,intx,inty,&daz,&daz2); + if ((intz <= daz) || (intz >= daz2)) + { + hitinfo->hitsect = dasector; hitinfo->hitwall = z; hitinfo->hitsprite = -1; + hitinfo->pos.x = intx; hitinfo->pos.y = inty; hitinfo->pos.z = intz; + continue; + } - for (zz=tempshortnum-1;zz>=0;zz--) - if (clipsectorlist[zz] == nextsector) break; - if (zz < 0) clipsectorlist[tempshortnum++] = nextsector; - } + for (zz=tempshortnum-1;zz>=0;zz--) + if (clipsectorlist[zz] == nextsector) break; + if (zz < 0) clipsectorlist[tempshortnum++] = nextsector; + } - for (z=headspritesect[dasector];z>=0;z=nextspritesect[z]) - { - spr = &sprite[z]; - cstat = spr->cstat; + for (z=headspritesect[dasector];z>=0;z=nextspritesect[z]) + { + spr = &sprite[z]; + cstat = spr->cstat; #ifdef POLYMOST - if (!hitallsprites) + if (!hitallsprites) #endif - if ((cstat&dasprclipmask) == 0) continue; + if ((cstat&dasprclipmask) == 0) continue; - x1 = spr->x; y1 = spr->y; z1 = spr->z; - switch (cstat&48) - { - case 0: - topt = vx*(x1-xs) + vy*(y1-ys); if (topt <= 0) continue; - bot = vx*vx + vy*vy; if (bot == 0) continue; + x1 = spr->x; y1 = spr->y; z1 = spr->z; + switch (cstat&48) + { + case 0: + topt = vx*(x1-sv->x) + vy*(y1-sv->y); if (topt <= 0) continue; + bot = vx*vx + vy*vy; if (bot == 0) continue; - intz = zs+scale(vz,topt,bot); + intz = sv->z+scale(vz,topt,bot); - i = (tilesizy[spr->picnum]*spr->yrepeat<<2); - if (cstat&128) z1 += (i>>1); - if (picanm[spr->picnum]&0x00ff0000) z1 -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); - if ((intz > z1) || (intz < z1-i)) continue; - topu = vx*(y1-ys) - vy*(x1-xs); + i = (tilesizy[spr->picnum]*spr->yrepeat<<2); + if (cstat&128) z1 += (i>>1); + if (picanm[spr->picnum]&0x00ff0000) z1 -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if ((intz > z1) || (intz < z1-i)) continue; + topu = vx*(y1-sv->y) - vy*(x1-sv->x); - offx = scale(vx,topu,bot); - offy = scale(vy,topu,bot); - dist = offx*offx + offy*offy; - i = tilesizx[spr->picnum]*spr->xrepeat; i *= i; - if (dist > (i>>7)) continue; - intx = xs + scale(vx,topt,bot); - inty = ys + scale(vy,topt,bot); + offx = scale(vx,topu,bot); + offy = scale(vy,topu,bot); + dist = offx*offx + offy*offy; + i = tilesizx[spr->picnum]*spr->xrepeat; i *= i; + if (dist > (i>>7)) continue; + intx = sv->x + scale(vx,topt,bot); + inty = sv->y + scale(vy,topt,bot); - if (klabs(intx-xs)+klabs(inty-ys) > klabs((*hitx)-xs)+klabs((*hity)-ys)) continue; + if (klabs(intx-sv->x)+klabs(inty-sv->y) > klabs((hitinfo->pos.x)-sv->x)+klabs((hitinfo->pos.y)-sv->y)) continue; - *hitsect = dasector; *hitwall = -1; *hitsprite = z; - *hitx = intx; *hity = inty; *hitz = intz; - break; - case 16: - //These lines get the 2 points of the rotated sprite - //Given: (x1, y1) starts out as the center point - tilenum = spr->picnum; - xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); - if ((cstat&4) > 0) xoff = -xoff; - k = spr->ang; l = spr->xrepeat; - dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; - l = tilesizx[tilenum]; k = (l>>1)+xoff; - x1 -= mulscale16(dax,k); x2 = x1+mulscale16(dax,l); - y1 -= mulscale16(day,k); y2 = y1+mulscale16(day,l); + hitinfo->hitsect = dasector; hitinfo->hitwall = -1; hitinfo->hitsprite = z; + hitinfo->pos.x = intx; hitinfo->pos.y = inty; hitinfo->pos.z = intz; + break; + case 16: + //These lines get the 2 points of the rotated sprite + //Given: (x1, y1) starts out as the center point + tilenum = spr->picnum; + xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); + if ((cstat&4) > 0) xoff = -xoff; + k = spr->ang; l = spr->xrepeat; + dax = sintable[k&2047]*l; day = sintable[(k+1536)&2047]*l; + l = tilesizx[tilenum]; k = (l>>1)+xoff; + x1 -= mulscale16(dax,k); x2 = x1+mulscale16(dax,l); + y1 -= mulscale16(day,k); y2 = y1+mulscale16(day,l); - if ((cstat&64) != 0) //back side of 1-way sprite - if ((x1-xs)*(y2-ys) < (x2-xs)*(y1-ys)) continue; + if ((cstat&64) != 0) //back side of 1-way sprite + if ((x1-sv->x)*(y2-sv->y) < (x2-sv->x)*(y1-sv->y)) continue; - if (rintersect(xs,ys,zs,vx,vy,vz,x1,y1,x2,y2,&intx,&inty,&intz) == 0) continue; + if (rintersect(sv->x,sv->y,sv->z,vx,vy,vz,x1,y1,x2,y2,&intx,&inty,&intz) == 0) continue; - if (klabs(intx-xs)+klabs(inty-ys) > klabs((*hitx)-xs)+klabs((*hity)-ys)) continue; + if (klabs(intx-sv->x)+klabs(inty-sv->y) > klabs((hitinfo->pos.x)-sv->x)+klabs((hitinfo->pos.y)-sv->y)) continue; - k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); - if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; - if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); - if ((intz < daz) && (intz > daz-k)) - { - *hitsect = dasector; *hitwall = -1; *hitsprite = z; - *hitx = intx; *hity = inty; *hitz = intz; - } - break; - case 32: - if (vz == 0) continue; - intz = z1; - if (((intz-zs)^vz) < 0) continue; - if ((cstat&64) != 0) - if ((zs > intz) == ((cstat&8)==0)) continue; + k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); + if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; + if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if ((intz < daz) && (intz > daz-k)) + { + hitinfo->hitsect = dasector; hitinfo->hitwall = -1; hitinfo->hitsprite = z; + hitinfo->pos.x = intx; hitinfo->pos.y = inty; hitinfo->pos.z = intz; + } + break; + case 32: + if (vz == 0) continue; + intz = z1; + if (((intz-sv->z)^vz) < 0) continue; + if ((cstat&64) != 0) + if ((sv->z > intz) == ((cstat&8)==0)) continue; -#if 1 // Abyss crash prevention code ((intz-zs)*zx overflowing a 8-bit word) - zz=(int32_t)((intz-zs)*vx); - intx = xs+scale(zz,1,vz); - zz=(int32_t)((intz-zs)*vy); - inty = ys+scale(zz,1,vz); +#if 1 // Abyss crash prevention code ((intz-sv->z)*zx overflowing a 8-bit word) + zz=(int32_t)((intz-sv->z)*vx); + intx = sv->x+scale(zz,1,vz); + zz=(int32_t)((intz-sv->z)*vy); + inty = sv->y+scale(zz,1,vz); #else - intx = xs+scale(intz-zs,vx,vz); - inty = ys+scale(intz-zs,vy,vz); + intx = sv->x+scale(intz-sv->z,vx,vz); + inty = sv->y+scale(intz-sv->z,vy,vz); #endif - if (klabs(intx-xs)+klabs(inty-ys) > klabs((*hitx)-xs)+klabs((*hity)-ys)) continue; + if (klabs(intx-sv->x)+klabs(inty-sv->y) > klabs((hitinfo->pos.x)-sv->x)+klabs((hitinfo->pos.y)-sv->y)) continue; - tilenum = spr->picnum; - xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); - yoff = (int32_t)((int8_t)((picanm[tilenum]>>16)&255))+((int32_t)spr->yoffset); - if ((cstat&4) > 0) xoff = -xoff; - if ((cstat&8) > 0) yoff = -yoff; + tilenum = spr->picnum; + xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); + yoff = (int32_t)((int8_t)((picanm[tilenum]>>16)&255))+((int32_t)spr->yoffset); + if ((cstat&4) > 0) xoff = -xoff; + if ((cstat&8) > 0) yoff = -yoff; - ang = spr->ang; - cosang = sintable[(ang+512)&2047]; sinang = sintable[ang]; - xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; - yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; + ang = spr->ang; + cosang = sintable[(ang+512)&2047]; sinang = sintable[ang]; + xspan = tilesizx[tilenum]; xrepeat = spr->xrepeat; + yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; - dax = ((xspan>>1)+xoff)*xrepeat; day = ((yspan>>1)+yoff)*yrepeat; - x1 += dmulscale16(sinang,dax,cosang,day)-intx; - y1 += dmulscale16(sinang,day,-cosang,dax)-inty; - l = xspan*xrepeat; - x2 = x1 - mulscale16(sinang,l); - y2 = y1 + mulscale16(cosang,l); - l = yspan*yrepeat; - k = -mulscale16(cosang,l); x3 = x2+k; x4 = x1+k; - k = -mulscale16(sinang,l); y3 = y2+k; y4 = y1+k; + dax = ((xspan>>1)+xoff)*xrepeat; day = ((yspan>>1)+yoff)*yrepeat; + x1 += dmulscale16(sinang,dax,cosang,day)-intx; + y1 += dmulscale16(sinang,day,-cosang,dax)-inty; + l = xspan*xrepeat; + x2 = x1 - mulscale16(sinang,l); + y2 = y1 + mulscale16(cosang,l); + l = yspan*yrepeat; + k = -mulscale16(cosang,l); x3 = x2+k; x4 = x1+k; + k = -mulscale16(sinang,l); y3 = y2+k; y4 = y1+k; - clipyou = 0; - if ((y1^y2) < 0) - { - if ((x1^x2) < 0) clipyou ^= (x1*y2= 0) clipyou ^= 1; - } - if ((y2^y3) < 0) - { - if ((x2^x3) < 0) clipyou ^= (x2*y3= 0) clipyou ^= 1; - } - if ((y3^y4) < 0) - { - if ((x3^x4) < 0) clipyou ^= (x3*y4= 0) clipyou ^= 1; - } - if ((y4^y1) < 0) - { - if ((x4^x1) < 0) clipyou ^= (x4*y1= 0) clipyou ^= 1; - } + clipyou = 0; + if ((y1^y2) < 0) + { + if ((x1^x2) < 0) clipyou ^= (x1*y2= 0) clipyou ^= 1; + } + if ((y2^y3) < 0) + { + if ((x2^x3) < 0) clipyou ^= (x2*y3= 0) clipyou ^= 1; + } + if ((y3^y4) < 0) + { + if ((x3^x4) < 0) clipyou ^= (x3*y4= 0) clipyou ^= 1; + } + if ((y4^y1) < 0) + { + if ((x4^x1) < 0) clipyou ^= (x4*y1= 0) clipyou ^= 1; + } - if (clipyou != 0) - { - *hitsect = dasector; *hitwall = -1; *hitsprite = z; - *hitx = intx; *hity = inty; *hitz = intz; + if (clipyou != 0) + { + hitinfo->hitsect = dasector; hitinfo->hitwall = -1; hitinfo->hitsprite = z; + hitinfo->pos.x = intx; hitinfo->pos.y = inty; hitinfo->pos.z = intz; + } + break; + } } - break; - } - } - tempshortcnt++; + tempshortcnt++; } while (tempshortcnt < tempshortnum); return(0); @@ -8967,9 +8967,9 @@ int32_t clipmoveboxtracenum = 3; // // clipmove // -int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, - int32_t xvect, int32_t yvect, - int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) +int32_t clipmove(vec3_t *vect, int16_t *sectnum, + int32_t xvect, int32_t yvect, + int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) { walltype *wal, *wal2; spritetype *spr; @@ -8988,16 +8988,16 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, oxvect = xvect; oyvect = yvect; - goalx = (*x) + (xvect>>14); - goaly = (*y) + (yvect>>14); + goalx = (vect->x) + (xvect>>14); + goaly = (vect->y) + (yvect>>14); clipnum = 0; - cx = (((*x)+goalx)>>1); - cy = (((*y)+goaly)>>1); + cx = (((vect->x)+goalx)>>1); + cy = (((vect->y)+goaly)>>1); //Extra walldist for sprites on sector lines - gx = goalx-(*x); gy = goaly-(*y); + gx = goalx-(vect->x); gy = goaly-(vect->y); rad = nsqrtasm(gx*gx + gy*gy) + MAXCLIPDIST+walldist + 8; xmin = cx-rad; ymin = cy-rad; xmax = cx+rad; ymax = cy+rad; @@ -9023,7 +9023,7 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, x1 = wal->x; y1 = wal->y; x2 = wal2->x; y2 = wal2->y; dx = x2-x1; dy = y2-y1; - if (dx*((*y)-y1) < ((*x)-x1)*dy) continue; //If wall's not facing you + if (dx*((vect->y)-y1) < ((vect->x)-x1)*dy) continue; //If wall's not facing you if (dx > 0) dax = dx*(ymin-y1); else dax = dx*(ymax-y1); if (dy > 0) day = dy*(xmax-x1); else day = dy*(xmin-x1); @@ -9033,22 +9033,22 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, if ((wal->nextsector < 0) || (wal->cstat&dawalclipmask)) clipyou = 1; else if (editstatus == 0) { - if (rintersect(*x,*y,0,gx,gy,0,x1,y1,x2,y2,&dax,&day,&daz) == 0) - dax = *x, day = *y; + if (rintersect(vect->x,vect->y,0,gx,gy,0,x1,y1,x2,y2,&dax,&day,&daz) == 0) + dax = vect->x, day = vect->y; daz = getflorzofslope((int16_t)dasect,dax,day); daz2 = getflorzofslope(wal->nextsector,dax,day); sec2 = §or[wal->nextsector]; if (daz2 < daz-(1<<8)) if ((sec2->floorstat&1) == 0) - if ((*z) >= daz2-(flordist-1)) clipyou = 1; + if ((vect->z) >= daz2-(flordist-1)) clipyou = 1; if (clipyou == 0) { daz = getceilzofslope((int16_t)dasect,dax,day); daz2 = getceilzofslope(wal->nextsector,dax,day); if (daz2 > daz+(1<<8)) if ((sec2->ceilingstat&1) == 0) - if ((*z) <= daz2+(ceildist-1)) clipyou = 1; + if ((vect->z) <= daz2+(ceildist-1)) clipyou = 1; } } @@ -9088,7 +9088,7 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, k = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); if (cstat&128) daz = spr->z+(k>>1); else daz = spr->z; if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); - if (((*z) < daz+ceildist) && ((*z) > daz-k-flordist)) + if (((vect->z) < daz+ceildist) && ((vect->z) > daz-k-flordist)) { bsz = (spr->clipdist<<2)+walldist; if (gx < 0) bsz = -bsz; addclipline(x1-bsz,y1-bsz,x1-bsz,y1+bsz,(int16_t)j+49152); @@ -9103,7 +9103,7 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); daz2 = daz-k; daz += ceildist; daz2 -= flordist; - if (((*z) < daz) && ((*z) > daz2)) + if (((vect->z) < daz) && ((vect->z) > daz2)) { //These lines get the 2 points of the rotated sprite //Given: (x1, y1) starts out as the center point @@ -9120,7 +9120,7 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, dax = mulscale14(sintable[(spr->ang+256+512)&2047],walldist); day = mulscale14(sintable[(spr->ang+256)&2047],walldist); - if ((x1-(*x))*(y2-(*y)) >= (x2-(*x))*(y1-(*y))) //Front + if ((x1-(vect->x))*(y2-(vect->y)) >= (x2-(vect->x))*(y1-(vect->y))) //Front { addclipline(x1+dax,y1+day,x2+day,y2-dax,(int16_t)j+49152); } @@ -9131,20 +9131,20 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, } //Side blocker - if ((x2-x1)*((*x)-x1) + (y2-y1)*((*y)-y1) < 0) - { addclipline(x1-day,y1+dax,x1+dax,y1+day,(int16_t)j+49152); } - else if ((x1-x2)*((*x)-x2) + (y1-y2)*((*y)-y2) < 0) - { addclipline(x2+day,y2-dax,x2-dax,y2-day,(int16_t)j+49152); } + if ((x2-x1)*((vect->x)-x1) + (y2-y1)*((vect->y)-y1) < 0) + { addclipline(x1-day,y1+dax,x1+dax,y1+day,(int16_t)j+49152); } + else if ((x1-x2)*((vect->x)-x2) + (y1-y2)*((vect->y)-y2) < 0) + { addclipline(x2+day,y2-dax,x2-dax,y2-day,(int16_t)j+49152); } } } break; case 32: daz = spr->z+ceildist; daz2 = spr->z-flordist; - if (((*z) < daz) && ((*z) > daz2)) + if (((vect->z) < daz) && ((vect->z) > daz2)) { if ((cstat&64) != 0) - if (((*z) > spr->z) == ((cstat&8)==0)) continue; + if (((vect->z) > spr->z) == ((cstat&8)==0)) continue; tilenum = spr->picnum; xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); @@ -9170,23 +9170,23 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, dax = mulscale14(sintable[(spr->ang-256+512)&2047],walldist); day = mulscale14(sintable[(spr->ang-256)&2047],walldist); - if ((rxi[0]-(*x))*(ryi[1]-(*y)) < (rxi[1]-(*x))*(ryi[0]-(*y))) + if ((rxi[0]-(vect->x))*(ryi[1]-(vect->y)) < (rxi[1]-(vect->x))*(ryi[0]-(vect->y))) { if (clipinsideboxline(cx,cy,rxi[1],ryi[1],rxi[0],ryi[0],rad) != 0) addclipline(rxi[1]-day,ryi[1]+dax,rxi[0]+dax,ryi[0]+day,(int16_t)j+49152); } - else if ((rxi[2]-(*x))*(ryi[3]-(*y)) < (rxi[3]-(*x))*(ryi[2]-(*y))) + else if ((rxi[2]-(vect->x))*(ryi[3]-(vect->y)) < (rxi[3]-(vect->x))*(ryi[2]-(vect->y))) { if (clipinsideboxline(cx,cy,rxi[3],ryi[3],rxi[2],ryi[2],rad) != 0) addclipline(rxi[3]+day,ryi[3]-dax,rxi[2]-dax,ryi[2]-day,(int16_t)j+49152); } - if ((rxi[1]-(*x))*(ryi[2]-(*y)) < (rxi[2]-(*x))*(ryi[1]-(*y))) + if ((rxi[1]-(vect->x))*(ryi[2]-(vect->y)) < (rxi[2]-(vect->x))*(ryi[1]-(vect->y))) { if (clipinsideboxline(cx,cy,rxi[2],ryi[2],rxi[1],ryi[1],rad) != 0) addclipline(rxi[2]-dax,ryi[2]-day,rxi[1]-day,ryi[1]+dax,(int16_t)j+49152); } - else if ((rxi[3]-(*x))*(ryi[0]-(*y)) < (rxi[0]-(*x))*(ryi[3]-(*y))) + else if ((rxi[3]-(vect->x))*(ryi[0]-(vect->y)) < (rxi[0]-(vect->x))*(ryi[3]-(vect->y))) { if (clipinsideboxline(cx,cy,rxi[0],ryi[0],rxi[3],ryi[3],rad) != 0) addclipline(rxi[0]+dax,ryi[0]+day,rxi[3]+day,ryi[3]-dax,(int16_t)j+49152); @@ -9204,7 +9204,7 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, do { intx = goalx; inty = goaly; - if ((hitwall = raytrace(*x, *y, &intx, &inty)) >= 0) + if ((hitwall = raytrace(vect->x, vect->y, &intx, &inty)) >= 0) { lx = clipit[hitwall].x2-clipit[hitwall].x1; ly = clipit[hitwall].y2-clipit[hitwall].y1; @@ -9228,7 +9228,7 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, tempint2 = dmulscale6(clipit[j].x2-clipit[j].x1,oxvect,clipit[j].y2-clipit[j].y1,oyvect); if ((tempint1^tempint2) < 0) { - updatesector(*x,*y,sectnum); + updatesector(vect->x,vect->y,sectnum); return(retval); } } @@ -9242,58 +9242,58 @@ int32_t clipmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, } cnt--; - *x = intx; - *y = inty; + vect->x = intx; + vect->y = inty; } while (((xvect|yvect) != 0) && (hitwall >= 0) && (cnt > 0)); for (j=0;jx,vect->y,clipsectorlist[j]) == 1) { *sectnum = clipsectorlist[j]; return(retval); } - *sectnum = -1; tempint1 = 0x7fffffff; - for (j=numsectors-1;j>=0;j--) - if (inside(*x,*y,j) == 1) - { - if (sector[j].ceilingstat&2) - tempint2 = (getceilzofslope((int16_t)j,*x,*y)-(*z)); - else - tempint2 = (sector[j].ceilingz-(*z)); - - if (tempint2 > 0) + *sectnum = -1; tempint1 = 0x7fffffff; + for (j=numsectors-1;j>=0;j--) + if (inside(vect->x,vect->y,j) == 1) { - if (tempint2 < tempint1) - { *sectnum = j; tempint1 = tempint2; } - } - else - { - if (sector[j].floorstat&2) - tempint2 = ((*z)-getflorzofslope((int16_t)j,*x,*y)); + if (sector[j].ceilingstat&2) + tempint2 = (getceilzofslope((int16_t)j,vect->x,vect->y)-(vect->z)); else - tempint2 = ((*z)-sector[j].floorz); + tempint2 = (sector[j].ceilingz-(vect->z)); - if (tempint2 <= 0) + if (tempint2 > 0) { - *sectnum = j; - return(retval); - } - if (tempint2 < tempint1) + if (tempint2 < tempint1) { *sectnum = j; tempint1 = tempint2; } - } - } + } + else + { + if (sector[j].floorstat&2) + tempint2 = ((vect->z)-getflorzofslope((int16_t)j,vect->x,vect->y)); + else + tempint2 = ((vect->z)-sector[j].floorz); - return(retval); + if (tempint2 <= 0) + { + *sectnum = j; + return(retval); + } + if (tempint2 < tempint1) + { *sectnum = j; tempint1 = tempint2; } + } + } + + return(retval); } // // pushmove // -int32_t pushmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, - int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) +int32_t pushmove(vec3_t *vect, int16_t *sectnum, + int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) { sectortype *sec, *sec2; walltype *wal; @@ -9320,35 +9320,35 @@ int32_t pushmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, /*Push FACE sprites for(i=headspritesect[clipsectorlist[clipsectcnt]];i>=0;i=nextspritesect[i]) { - spr = &sprite[i]; - if (((spr->cstat&48) != 0) && ((spr->cstat&48) != 48)) continue; - if ((spr->cstat&dasprclipmask) == 0) continue; + spr = &sprite[i]; + if (((spr->cstat&48) != 0) && ((spr->cstat&48) != 48)) continue; + if ((spr->cstat&dasprclipmask) == 0) continue; - dax = (*x)-spr->x; day = (*y)-spr->y; - t = (spr->clipdist<<2)+walldist; - if ((klabs(dax) < t) && (klabs(day) < t)) - { - t = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); - if (spr->cstat&128) daz = spr->z+(t>>1); else daz = spr->z; - if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); - if (((*z) < daz+ceildist) && ((*z) > daz-t-flordist)) - { - t = (spr->clipdist<<2)+walldist; + dax = (vect->x)-spr->x; day = (vect->y)-spr->y; + t = (spr->clipdist<<2)+walldist; + if ((klabs(dax) < t) && (klabs(day) < t)) + { + t = ((tilesizy[spr->picnum]*spr->yrepeat)<<2); + if (spr->cstat&128) daz = spr->z+(t>>1); else daz = spr->z; + if (picanm[spr->picnum]&0x00ff0000) daz -= ((int32_t)((int8_t)((picanm[spr->picnum]>>16)&255))*spr->yrepeat<<2); + if (((vect->z) < daz+ceildist) && ((vect->z) > daz-t-flordist)) + { + t = (spr->clipdist<<2)+walldist; - j = getangle(dax,day); - dx = (sintable[(j+512)&2047]>>11); - dy = (sintable[(j)&2047]>>11); - bad2 = 16; - do - { - *x = (*x) + dx; *y = (*y) + dy; - bad2--; if (bad2 == 0) break; - } while ((klabs((*x)-spr->x) < t) && (klabs((*y)-spr->y) < t)); - bad = -1; - k--; if (k <= 0) return(bad); - updatesector(*x,*y,sectnum); - } - } + j = getangle(dax,day); + dx = (sintable[(j+512)&2047]>>11); + dy = (sintable[(j)&2047]>>11); + bad2 = 16; + do + { + vect->x = (vect->x) + dx; vect->y = (vect->y) + dy; + bad2--; if (bad2 == 0) break; + } while ((klabs((vect->x)-spr->x) < t) && (klabs((vect->y)-spr->y) < t)); + bad = -1; + k--; if (k <= 0) return(bad); + updatesector(vect->x,vect->y,sectnum); + } + } }*/ sec = §or[clipsectorlist[clipsectcnt]]; @@ -9358,7 +9358,7 @@ int32_t pushmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, endwall = sec->wallptr, startwall = endwall + sec->wallnum; for (i=startwall,wal=&wall[startwall];i!=endwall;i+=dir,wal+=dir) - if (clipinsidebox(*x,*y,i,walldist-4) == 1) + if (clipinsidebox(vect->x,vect->y,i,walldist-4) == 1) { j = 0; if (wal->nextsector < 0) j = 1; @@ -9368,10 +9368,10 @@ int32_t pushmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, sec2 = §or[wal->nextsector]; - //Find closest point on wall (dax, day) to (*x, *y) + //Find closest point on wall (dax, day) to (vect->x, vect->y) dax = wall[wal->point2].x-wal->x; day = wall[wal->point2].y-wal->y; - daz = dax*((*x)-wal->x) + day*((*y)-wal->y); + daz = dax*((vect->x)-wal->x) + day*((vect->y)-wal->y); if (daz <= 0) t = 0; else @@ -9386,12 +9386,12 @@ int32_t pushmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, daz = getflorzofslope(clipsectorlist[clipsectcnt],dax,day); daz2 = getflorzofslope(wal->nextsector,dax,day); if ((daz2 < daz-(1<<8)) && ((sec2->floorstat&1) == 0)) - if (*z >= daz2-(flordist-1)) j = 1; + if (vect->z >= daz2-(flordist-1)) j = 1; daz = getceilzofslope(clipsectorlist[clipsectcnt],dax,day); daz2 = getceilzofslope(wal->nextsector,dax,day); if ((daz2 > daz+(1<<8)) && ((sec2->ceilingstat&1) == 0)) - if (*z <= daz2+(ceildist-1)) j = 1; + if (vect->z <= daz2+(ceildist-1)) j = 1; } if (j != 0) { @@ -9401,13 +9401,13 @@ int32_t pushmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, bad2 = 16; do { - *x = (*x) + dx; *y = (*y) + dy; + vect->x = (vect->x) + dx; vect->y = (vect->y) + dy; bad2--; if (bad2 == 0) break; } - while (clipinsidebox(*x,*y,i,walldist-4) != 0); + while (clipinsidebox(vect->x,vect->y,i,walldist-4) != 0); bad = -1; k--; if (k <= 0) return(bad); - updatesector(*x,*y,sectnum); + updatesector(vect->x,vect->y,sectnum); } else { @@ -9417,7 +9417,7 @@ int32_t pushmove(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, } } - clipsectcnt++; + clipsectcnt++; } while (clipsectcnt < clipsectnum); dir = -dir; @@ -9548,7 +9548,7 @@ int32_t krand(void) // // getzrange // -void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, +void getzrange(const vec3_t *vect, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit, int32_t walldist, uint32_t cliptype) { @@ -9560,6 +9560,7 @@ void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, int32_t x1, y1, x2, y2, x3, y3, x4, y4, ang, cosang, sinang; int32_t xspan, yspan, xrepeat, yrepeat, dasprclipmask, dawalclipmask; int16_t cstat; + char clipyou; if (sectnum < 0) @@ -9571,10 +9572,10 @@ void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, //Extra walldist for sprites on sector lines i = walldist+MAXCLIPDIST+1; - xmin = x-i; ymin = y-i; - xmax = x+i; ymax = y+i; + xmin = vect->x-i; ymin = vect->y-i; + xmax = vect->x+i; ymax = vect->y+i; - getzsofslope(sectnum,x,y,ceilz,florz); + getzsofslope(sectnum,vect->x,vect->y,ceilz,florz); *ceilhit = sectnum+16384; *florhit = sectnum+16384; dawalclipmask = (cliptype&65535); @@ -9601,7 +9602,7 @@ void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, if ((y1 > ymax) && (y2 > ymax)) continue; dx = x2-x1; dy = y2-y1; - if (dx*(y-y1) < (x-x1)*dy) continue; //back + if (dx*(vect->y-y1) < (vect->x-x1)*dy) continue; //back if (dx > 0) dax = dx*(ymin-y1); else dax = dx*(ymax-y1); if (dy > 0) day = dy*(xmax-x1); else day = dy*(xmin-x1); if (dax >= day) continue; @@ -9610,8 +9611,8 @@ void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, sec = §or[k]; if (editstatus == 0) { - if (((sec->ceilingstat&1) == 0) && (z <= sec->ceilingz+(3<<8))) continue; - if (((sec->floorstat&1) == 0) && (z >= sec->floorz-(3<<8))) continue; + if (((sec->ceilingstat&1) == 0) && (vect->z <= sec->ceilingz+(3<<8))) continue; + if (((sec->floorstat&1) == 0) && (vect->z >= sec->floorz-(3<<8))) continue; } for (i=clipsectnum-1;i>=0;i--) if (clipsectorlist[i] == k) break; @@ -9626,7 +9627,7 @@ void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, if (dax >= day) continue; //It actually got here, through all the continue's!!! - getzsofslope((int16_t)k,x,y,&daz,&daz2); + getzsofslope((int16_t)k,vect->x,vect->y,&daz,&daz2); if (daz > *ceilz) { *ceilz = daz; *ceilhit = k+16384; } if (daz2 < *florz) { *florz = daz2; *florhit = k+16384; } } @@ -9650,7 +9651,7 @@ void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, { case 0: k = walldist+(spr->clipdist<<2)+1; - if ((klabs(x1-x) <= k) && (klabs(y1-y) <= k)) + if ((klabs(x1-vect->x) <= k) && (klabs(y1-vect->y) <= k)) { daz = spr->z; k = ((tilesizy[spr->picnum]*spr->yrepeat)<<1); @@ -9669,7 +9670,7 @@ void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, l = tilesizx[tilenum]; k = (l>>1)+xoff; x1 -= mulscale16(dax,k); x2 = x1+mulscale16(dax,l); y1 -= mulscale16(day,k); y2 = y1+mulscale16(day,l); - if (clipinsideboxline(x,y,x1,y1,x2,y2,walldist+1) != 0) + if (clipinsideboxline(vect->x,vect->y,x1,y1,x2,y2,walldist+1) != 0) { daz = spr->z; k = ((tilesizy[spr->picnum]*spr->yrepeat)<<1); if (cstat&128) daz += k; @@ -9682,7 +9683,7 @@ void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, daz = spr->z; daz2 = daz; if ((cstat&64) != 0) - if ((z > daz) == ((cstat&8)==0)) continue; + if ((vect->z > daz) == ((cstat&8)==0)) continue; tilenum = spr->picnum; xoff = (int32_t)((int8_t)((picanm[tilenum]>>8)&255))+((int32_t)spr->xoffset); @@ -9696,8 +9697,8 @@ void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, yspan = tilesizy[tilenum]; yrepeat = spr->yrepeat; dax = ((xspan>>1)+xoff)*xrepeat; day = ((yspan>>1)+yoff)*yrepeat; - x1 += dmulscale16(sinang,dax,cosang,day)-x; - y1 += dmulscale16(sinang,day,-cosang,dax)-y; + x1 += dmulscale16(sinang,dax,cosang,day)-vect->x; + y1 += dmulscale16(sinang,day,-cosang,dax)-vect->y; l = xspan*xrepeat; x2 = x1 - mulscale16(sinang,l); y2 = y1 + mulscale16(cosang,l); @@ -9735,8 +9736,8 @@ void getzrange(int32_t x, int32_t y, int32_t z, int16_t sectnum, if (clipyou != 0) { - if ((z > daz) && (daz > *ceilz)) { *ceilz = daz; *ceilhit = j+49152; } - if ((z < daz2) && (daz2 < *florz)) { *florz = daz2; *florhit = j+49152; } + if ((vect->z > daz) && (daz > *ceilz)) { *ceilz = daz; *ceilhit = j+49152; } + if ((vect->z < daz2) && (daz2 < *florz)) { *florz = daz2; *florhit = j+49152; } } } } diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 39e7ade3f..dae4ee122 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -4421,9 +4421,10 @@ void polymost_drawrooms() if (searchit == 2) { - int16_t hitsect, hitwall, hitsprite; - int32_t vx, vy, vz, hitx, hity, hitz; + int32_t vx, vy, vz; int32_t cz, fz; + hitdata_t hitinfo; + vec3_t vect; double ratio = 1.05; if (glwidescreen == 1) @@ -4458,37 +4459,41 @@ void polymost_drawrooms() vy = (int32_t)(ox2*((float)singlobalang) + oy2*((float)cosglobalang)); vz = (int32_t)(oz2*16384.0); + vect.x = globalposx; + vect.y = globalposy; + vect.z = globalposz; + hitallsprites = 1; - hitscan(globalposx,globalposy,globalposz,globalcursectnum, //Start position - vx>>12,vy>>12,vz>>8,&hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,0xffff0030); - getzsofslope(hitsect,hitx,hity,&cz,&fz); + hitscan((const vec3_t *)&vect,globalcursectnum, //Start position + vx>>12,vy>>12,vz>>8,&hitinfo,0xffff0030); + getzsofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz); hitallsprites = 0; - searchsector = hitsect; - if (hitzfz) searchstat = 2;else - if (hitwall >= 0) + searchsector = hitinfo.hitsect; + if (hitinfo.pos.zfz) searchstat = 2;else + if (hitinfo.hitwall >= 0) { - searchwall = hitwall; searchstat = 0; - if (wall[hitwall].nextwall >= 0) + searchwall = hitinfo.hitwall; searchstat = 0; + if (wall[hitinfo.hitwall].nextwall >= 0) { int32_t cz, fz; - getzsofslope(wall[hitwall].nextsector,hitx,hity,&cz,&fz); - if (hitz > fz) + getzsofslope(wall[hitinfo.hitwall].nextsector,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz); + if (hitinfo.pos.z > fz) { - if (wall[hitwall].cstat&2) //'2' bottoms of walls - searchwall = wall[hitwall].nextwall; + if (wall[hitinfo.hitwall].cstat&2) //'2' bottoms of walls + searchwall = wall[hitinfo.hitwall].nextwall; } - else if ((hitz > cz) && (wall[hitwall].cstat&(16+32))) //masking or 1-way + else if ((hitinfo.pos.z > cz) && (wall[hitinfo.hitwall].cstat&(16+32))) //masking or 1-way searchstat = 4; } } - else if (hitsprite >= 0) { searchwall = hitsprite; searchstat = 3; } + else if (hitinfo.hitsprite >= 0) { searchwall = hitinfo.hitsprite; searchstat = 3; } else { int32_t cz, fz; - getzsofslope(hitsect,hitx,hity,&cz,&fz); - if ((hitz<<1) < cz+fz) searchstat = 1; else searchstat = 2; + getzsofslope(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,&cz,&fz); + if ((hitinfo.pos.z<<1) < cz+fz) searchstat = 1; else searchstat = 2; //if (vz < 0) searchstat = 1; else searchstat = 2; //Won't work for slopes :/ } searchit = 0; @@ -4563,6 +4568,7 @@ void polymost_drawmaskwall(int32_t damaskwallcnt) float fy, x0, x1, sx0, sy0, sx1, sy1, xp0, yp0, xp1, yp1, oxp0, oyp0, ryp0, ryp1; float r, t, t0, t1, csy[4], fsy[4]; int32_t i, j, n, n2, z, sectnum, z1, z2, cz[4], fz[4], method; + int32_t m0, m1; sectortype *sec, *nsec; walltype *wal, *wal2; @@ -4604,10 +4610,14 @@ void polymost_drawmaskwall(int32_t damaskwallcnt) if (yp1 < SCISDIST) { t1 = (SCISDIST-oyp0)/(yp1-oyp0); xp1 = (xp1-oxp0)*t1+oxp0; yp1 = SCISDIST; } else { t1 = 1.f; } - getzsofslope(sectnum,(int32_t)((wal2->x-wal->x)*t0+wal->x),(int32_t)((wal2->y-wal->y)*t0+wal->y),&cz[0],&fz[0]); - getzsofslope(wal->nextsector,(int32_t)((wal2->x-wal->x)*t0+wal->x),(int32_t)((wal2->y-wal->y)*t0+wal->y),&cz[1],&fz[1]); - getzsofslope(sectnum,(int32_t)((wal2->x-wal->x)*t1+wal->x),(int32_t)((wal2->y-wal->y)*t1+wal->y),&cz[2],&fz[2]); - getzsofslope(wal->nextsector,(int32_t)((wal2->x-wal->x)*t1+wal->x),(int32_t)((wal2->y-wal->y)*t1+wal->y),&cz[3],&fz[3]); + m0 = (int32_t)((wal2->x-wal->x)*t0+wal->x); + m1 = (int32_t)((wal2->y-wal->y)*t0+wal->y); + getzsofslope(sectnum,m0,m1,&cz[0],&fz[0]); + getzsofslope(wal->nextsector,m0,m1,&cz[1],&fz[1]); + m0 = (int32_t)((wal2->x-wal->x)*t1+wal->x); + m1 = (int32_t)((wal2->y-wal->y)*t1+wal->y); + getzsofslope(sectnum,m0,m1,&cz[2],&fz[2]); + getzsofslope(wal->nextsector,m0,m1,&cz[3],&fz[3]); ryp0 = 1.f/yp0; ryp1 = 1.f/yp1; diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index eb771738a..94b20fcaf 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -475,10 +475,11 @@ BOLT: int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) { - int32_t daz, oldx, oldy; + int32_t oldx, oldy; int32_t retval; int16_t dasectnum, cd; int32_t bg = A_CheckEnemySprite(&sprite[spritenum]); + int32_t dazoff = ((tilesizy[sprite[spritenum].picnum]*sprite[spritenum].yrepeat)<<1); if (sprite[spritenum].statnum == 5 || (bg && sprite[spritenum].xrepeat < 4)) { @@ -486,13 +487,13 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) sprite[spritenum].y += (change->y*TICSPERFRAME)>>2; sprite[spritenum].z += (change->z*TICSPERFRAME)>>2; if (bg) - setsprite(spritenum,sprite[spritenum].x,sprite[spritenum].y,sprite[spritenum].z); + setsprite(spritenum,(vec3_t *)&sprite[spritenum]); return 0; } dasectnum = sprite[spritenum].sectnum; - daz = sprite[spritenum].z - ((tilesizy[sprite[spritenum].picnum]*sprite[spritenum].yrepeat)<<1); +// daz = sprite[spritenum].z - ; if (bg) { @@ -500,7 +501,11 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) oldy = sprite[spritenum].y; if (sprite[spritenum].xrepeat > 60) - retval = clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),1024L,(4<<8),(4<<8),cliptype); + { + sprite[spritenum].z -= dazoff; + retval = clipmove((vec3_t *)&sprite[spritenum],&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),1024L,(4<<8),(4<<8),cliptype); + sprite[spritenum].z += dazoff; + } else { if (sprite[spritenum].picnum == LIZMAN) @@ -510,7 +515,9 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) else cd = 192L; - retval = clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),cd,(4<<8),(4<<8),cliptype); + sprite[spritenum].z -= dazoff; + retval = clipmove((vec3_t *)&sprite[spritenum],&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),cd,(4<<8),(4<<8),cliptype); + sprite[spritenum].z += dazoff; } if (dasectnum < 0 || (dasectnum >= 0 && @@ -523,11 +530,13 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) { sprite[spritenum].x = oldx; sprite[spritenum].y = oldy; - /* if (dasectnum >= 0 && sector[dasectnum].lotag == 1 && sprite[spritenum].picnum == LIZMAN) - sprite[spritenum].ang = (krand()&2047); - else if ((ActorExtra[spritenum].temp_data[0]&3) == 1 && sprite[spritenum].picnum != COMMANDER) - sprite[spritenum].ang = (krand()&2047); */ - setsprite(spritenum,oldx,oldy,sprite[spritenum].z); + /* + if (dasectnum >= 0 && sector[dasectnum].lotag == 1 && sprite[spritenum].picnum == LIZMAN) + sprite[spritenum].ang = (krand()&2047); + else if ((ActorExtra[spritenum].temp_data[0]&3) == 1 && sprite[spritenum].picnum != COMMANDER) + sprite[spritenum].ang = (krand()&2047); + */ + setsprite(spritenum,(vec3_t *)&sprite[spritenum]); if (dasectnum < 0) dasectnum = 0; return (16384+dasectnum); } @@ -535,22 +544,28 @@ int32_t A_MoveSprite(int32_t spritenum, const vec3_t *change, uint32_t cliptype) } else { + sprite[spritenum].z -= dazoff; if (sprite[spritenum].statnum == 4) retval = - clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),8L,(4<<8),(4<<8),cliptype); + clipmove((vec3_t *)&sprite[spritenum],&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),8L,(4<<8),(4<<8),cliptype); else retval = - clipmove(&sprite[spritenum].x,&sprite[spritenum].y,&daz,&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),(int32_t)(sprite[spritenum].clipdist<<2),(4<<8),(4<<8),cliptype); + clipmove((vec3_t *)&sprite[spritenum],&dasectnum,((change->x*TICSPERFRAME)<<11),((change->y*TICSPERFRAME)<<11),(int32_t)(sprite[spritenum].clipdist<<2),(4<<8),(4<<8),cliptype); + sprite[spritenum].z += dazoff; } - if (dasectnum >= 0) - if ((dasectnum != sprite[spritenum].sectnum)) - changespritesect(spritenum,dasectnum); - daz = sprite[spritenum].z + ((change->z*TICSPERFRAME)>>3); - if ((daz > ActorExtra[spritenum].ceilingz) && (daz <= ActorExtra[spritenum].floorz)) - sprite[spritenum].z = daz; - else if (retval == 0) - return(16384+dasectnum); + { + int32_t daz; + + if (dasectnum >= 0) + if ((dasectnum != sprite[spritenum].sectnum)) + changespritesect(spritenum,dasectnum); + daz = sprite[spritenum].z + ((change->z*TICSPERFRAME)>>3); + if ((daz > ActorExtra[spritenum].ceilingz) && (daz <= ActorExtra[spritenum].floorz)) + sprite[spritenum].z = daz; + else if (retval == 0) + return(16384+dasectnum); + } return(retval); } @@ -1023,7 +1038,7 @@ void A_MoveDummyPlayers(void) SX += (g_player[p].ps->posx-g_player[p].ps->oposx); SY += (g_player[p].ps->posy-g_player[p].ps->oposy); - setsprite(i,SX,SY,SZ); + setsprite(i,(vec3_t *)&sprite[i]); BOLT: @@ -1054,7 +1069,7 @@ static void G_MovePlayers(void) //Players s->y = p->oposy; ActorExtra[i].bposz = s->z = p->oposz+PHEIGHT; s->ang = p->oang; - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); } else { @@ -1155,7 +1170,7 @@ static void G_MovePlayers(void) //Players else { s->ang = 2047-p->ang; - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); } } @@ -1408,10 +1423,18 @@ static void G_MoveStandables(void) case 2: case 6: case 10: + { + vec3_t vect; + + vect.x = msx[t[4]+1]; + vect.y = msy[t[4]+1]; + vect.z = sprite[j].z; s->ang = getangle(msx[t[4]+1]-s->x,msy[t[4]+1]-s->y); - setsprite(j,msx[t[4]+1],msy[t[4]+1],sprite[j].z); + setsprite(j,&vect); t[0]++; goto BOLT; + + } } j = nextj; } @@ -1465,7 +1488,7 @@ static void G_MoveStandables(void) s->picnum++; if (s->picnum == (CRANE+2)) { - p = CheckPlayerInSector(t[1]); + p = G_CheckPlayerInSector(t[1]); if (p >= 0 && g_player[p].ps->on_ground) { s->owner = -2; @@ -1527,7 +1550,13 @@ static void G_MoveStandables(void) else if (t[0]==9) t[0] = 0; - setsprite(msy[t[4]+2],s->x,s->y,s->z-(34<<8)); + { + vec3_t vect; + Bmemcpy(&vect,s,sizeof(vec3_t)); + vect.z -= (34<<8); + setsprite(msy[t[4]+2],&vect); + } + if (s->owner != -1) { @@ -1545,7 +1574,7 @@ static void G_MoveStandables(void) if (s->owner >= 0) { - setsprite(s->owner,s->x,s->y,s->z); + setsprite(s->owner,(vec3_t *)s); ActorExtra[s->owner].bposx = s->x; ActorExtra[s->owner].bposy = s->y; @@ -1555,10 +1584,17 @@ static void G_MoveStandables(void) } else if (s->owner == -2) { + vec3_t vect; + g_player[p].ps->oposx = g_player[p].ps->posx = s->x-(sintable[(g_player[p].ps->ang+512)&2047]>>6); g_player[p].ps->oposy = g_player[p].ps->posy = s->y-(sintable[g_player[p].ps->ang&2047]>>6); g_player[p].ps->oposz = g_player[p].ps->posz = s->z+(2<<8); - setsprite(g_player[p].ps->i,g_player[p].ps->posx,g_player[p].ps->posy,g_player[p].ps->posz); + + vect.x = g_player[p].ps->posx; + vect.y = g_player[p].ps->posy; + vect.z = g_player[p].ps->posz; + + setsprite(g_player[p].ps->i,&vect); g_player[p].ps->cursectnum = sprite[g_player[p].ps->i].sectnum; } } @@ -1711,7 +1747,7 @@ static void G_MoveStandables(void) s->x += sintable[(T6+512)&2047]>>9; s->y += sintable[(T6)&2047]>>9; s->z -= (3<<8); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); x = A_CheckHitSprite(i,&m); @@ -1729,7 +1765,7 @@ static void G_MoveStandables(void) while (x > 0) { j = A_Spawn(i,LASERLINE); - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(j,(vec3_t *)&sprite[j]); sprite[j].hitag = s->hitag; ActorExtra[j].temp_data[1] = sprite[j].z; @@ -1748,7 +1784,7 @@ static void G_MoveStandables(void) s->x = T4; s->y = T5; s->z += (3<<8); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); T4 = 0; // if( m >= 0 && lTripBombControl & TRIPBOMB_TRIPWIRE) if (m >= 0 && ActorExtra[i].temp_data[6] != 1) @@ -1769,14 +1805,14 @@ static void G_MoveStandables(void) s->x += sintable[(T6+512)&2047]>>9; s->y += sintable[(T6)&2047]>>9; s->z -= (3<<8); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); x = A_CheckHitSprite(i,&m); s->x = T4; s->y = T5; s->z += (3<<8); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); // if( ActorExtra[i].lastvx != x && lTripBombControl & TRIPBOMB_TRIPWIRE) if (ActorExtra[i].lastvx != x && ActorExtra[i].temp_data[6] != 1) @@ -2211,7 +2247,7 @@ CLEAR_THE_BOLT: else { sector[sect].floorz += sector[sect].extra; - p = CheckPlayerInSector(sect); + p = G_CheckPlayerInSector(sect); if (p >= 0) g_player[p].ps->posz += sector[sect].extra; } } @@ -2225,7 +2261,7 @@ CLEAR_THE_BOLT: else { sector[sect].floorz -= sector[sect].extra; - p = CheckPlayerInSector(sect); + p = G_CheckPlayerInSector(sect); if (p >= 0) g_player[p].ps->posz -= sector[sect].extra; } @@ -2235,7 +2271,7 @@ CLEAR_THE_BOLT: if (t[5] == 1) goto BOLT; - p = CheckPlayerInSector(sect); + p = G_CheckPlayerInSector(sect); if (p >= 0 && (g_player[p].ps->on_ground || s->ang == 512)) { if (t[0] == 0 && !G_CheckActivatorMotion(s->lotag)) @@ -2680,10 +2716,10 @@ static void G_MoveWeapons(void) } else { - vec3_t tmpvect; - setsprite(i,davect.x,davect.y,davect.z); - Bmemcpy(&tmpvect, s, sizeof(int32_t) * 3); - A_DamageWall(i,j,&tmpvect,s->picnum); +// vec3_t tmpvect; + setsprite(i,&davect); +// Bmemcpy(&tmpvect, s, sizeof(int32_t) * 3); + A_DamageWall(i,j,(vec3_t *)s,s->picnum); if (ActorExtra[i].projectile.workslike & PROJECTILE_BOUNCESOFFWALLS) { @@ -2709,7 +2745,7 @@ static void G_MoveWeapons(void) } else if ((j&49152) == 16384) { - setsprite(i,davect.x,davect.y,davect.z); + setsprite(i,&davect); if (s->zvel < 0) { @@ -3002,7 +3038,7 @@ static void G_MoveWeapons(void) else { vec3_t tmpvect; - setsprite(i,davect.x,davect.y,davect.z); + setsprite(i,&davect); Bmemcpy(&tmpvect, s, sizeof(int32_t) * 3); A_DamageWall(i,j,&tmpvect,s->picnum); @@ -3024,7 +3060,7 @@ static void G_MoveWeapons(void) } else if ((j&49152) == 16384) { - setsprite(i,davect.x,davect.y,davect.z); + setsprite(i,&davect); if (s->zvel < 0) { @@ -3284,6 +3320,7 @@ static void G_MoveTransports(void) if (k == 1) { + vec3_t vect; g_player[p].ps->oposx = g_player[p].ps->posx += sprite[OW].x-SX; g_player[p].ps->oposy = g_player[p].ps->posy += sprite[OW].y-SY; @@ -3292,7 +3329,12 @@ static void G_MoveTransports(void) g_player[p].ps->cursectnum = sprite[OW].sectnum; changespritesect(j,sprite[OW].sectnum); - setsprite(g_player[p].ps->i,g_player[p].ps->posx,g_player[p].ps->posy,g_player[p].ps->posz+PHEIGHT); + + vect.x = g_player[p].ps->posx; + vect.y = g_player[p].ps->posy; + vect.z = g_player[p].ps->posz+PHEIGHT; + + setsprite(g_player[p].ps->i,&vect); P_UpdateScreenPal(g_player[p].ps); @@ -3387,7 +3429,7 @@ static void G_MoveTransports(void) case 0: if (onfloorz) { - if (sprite[j].statnum == 4 || (CheckPlayerInSector(sect) == -1 && CheckPlayerInSector(sprite[OW].sectnum) == -1)) + if (sprite[j].statnum == 4 || (G_CheckPlayerInSector(sect) == -1 && G_CheckPlayerInSector(sprite[OW].sectnum) == -1)) { sprite[j].x += (sprite[OW].x-SX); sprite[j].y += (sprite[OW].y-SY); @@ -3627,7 +3669,7 @@ static void G_MoveActors(void) j = nextj; } - j = clipmove(&s->x,&s->y,&s->z,&s->sectnum, + j = clipmove((vec3_t *)s,&s->sectnum, (((s->xvel*(sintable[(s->ang+512)&2047]))>>14)*TICSPERFRAME)<<11, (((s->xvel*(sintable[s->ang&2047]))>>14)*TICSPERFRAME)<<11, 24L,(4<<8),(4<<8),CLIPMASK1); @@ -4037,7 +4079,7 @@ static void G_MoveActors(void) goto BOLT; } - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); s->ang = g_player[p].ps->ang; @@ -5017,7 +5059,7 @@ static void G_MoveMisc(void) // STATNUM 5 A_SetSprite(i,CLIPMASK0); if ((krand()&3) == 0) - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); if (s->sectnum == -1) KILLIT(i); l = getflorzofslope(s->sectnum,s->x,s->y); @@ -5068,7 +5110,7 @@ static void G_MoveMisc(void) // STATNUM 5 if (s->zvel > 1024 && s->zvel < 1280) { - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); sect = s->sectnum; } @@ -5298,7 +5340,7 @@ static void G_MoveMisc(void) // STATNUM 5 s->xrepeat >>= 1; s->yrepeat >>= 1; if (rnd(96)) - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); t[0]++;//Number of bounces } else if (t[0] == 3) KILLIT(i); @@ -5323,7 +5365,7 @@ static void G_MoveMisc(void) // STATNUM 5 if (s->zvel > 1024 && s->zvel < 1280) { - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); sect = s->sectnum; } @@ -5357,7 +5399,7 @@ static void G_MoveMisc(void) // STATNUM 5 if (s->picnum == SCRAP1 && s->yvel > 0) { j = A_Spawn(i,s->yvel); - setsprite(j,s->x,s->y,s->z); + setsprite(j,(vec3_t *)s); A_GetZLimits(j); sprite[j].hitag = sprite[j].lotag = 0; } @@ -5678,7 +5720,7 @@ static void G_MoveEffectors(void) //STATNUM 3 g_player[p].ps->posy = s->y; g_player[p].ps->cursectnum = s->sectnum; - setsprite(g_player[p].ps->i,s->x,s->y,s->z); + setsprite(g_player[p].ps->i,(vec3_t *)s); P_QuickKill(g_player[p].ps); } } @@ -5742,7 +5784,7 @@ static void G_MoveEffectors(void) //STATNUM 3 } ms(i); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); if ((sc->floorz-sc->ceilingz) < (108<<8)) { @@ -5758,7 +5800,7 @@ static void G_MoveEffectors(void) //STATNUM 3 g_player[p].ps->oposy = g_player[p].ps->posy = s->y; g_player[p].ps->cursectnum = s->sectnum; - setsprite(g_player[p].ps->i,s->x,s->y,s->z); + setsprite(g_player[p].ps->i,(vec3_t *)s); P_QuickKill(g_player[p].ps); } } @@ -5857,7 +5899,7 @@ static void G_MoveEffectors(void) //STATNUM 3 g_player[p].ps->posy = s->y; g_player[p].ps->cursectnum = s->sectnum; - setsprite(g_player[p].ps->i,s->x,s->y,s->z); + setsprite(g_player[p].ps->i,(vec3_t *)s); P_QuickKill(g_player[p].ps); } } @@ -5910,7 +5952,7 @@ static void G_MoveEffectors(void) //STATNUM 3 } ms(i); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); if ((sc->floorz-sc->ceilingz) < (108<<8)) { @@ -5930,7 +5972,7 @@ static void G_MoveEffectors(void) //STATNUM 3 g_player[p].ps->cursectnum = s->sectnum; - setsprite(g_player[p].ps->i,s->x,s->y,s->z); + setsprite(g_player[p].ps->i,(vec3_t *)s); P_QuickKill(g_player[p].ps); } } @@ -6018,12 +6060,12 @@ static void G_MoveEffectors(void) //STATNUM 3 { sprite[j].x+=m; sprite[j].y+=x; - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(j,(vec3_t *)&sprite[j]); } j = nextj; } ms(i); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); } break; @@ -6203,7 +6245,7 @@ static void G_MoveEffectors(void) //STATNUM 3 sc->ceilingz += s->zvel; sector[t[0]].ceilingz += s->zvel; ms(i); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); break; @@ -6343,7 +6385,7 @@ static void G_MoveEffectors(void) //STATNUM 3 t[2]-=k; t[4]-=k; ms(i); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); goto BOLT; } k = nextspritestat[k]; @@ -6354,14 +6396,14 @@ static void G_MoveEffectors(void) //STATNUM 3 t[2]+=k; t[4]+=k; ms(i); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); if (t[4] <= -511 || t[4] >= 512) { t[4] = 0; t[2] &= 0xffffff00; ms(i); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); break; } } @@ -6527,7 +6569,7 @@ static void G_MoveEffectors(void) //STATNUM 3 } ms(i); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); } break; @@ -6562,7 +6604,7 @@ static void G_MoveEffectors(void) //STATNUM 3 else sc->ceilingz-=512; ms(i); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); break; @@ -6671,7 +6713,7 @@ static void G_MoveEffectors(void) //STATNUM 3 ActorExtra[k].bposz = sprite[k].z; changespritesect(k,sprite[j].sectnum); - setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); + setsprite(k,(vec3_t *)&sprite[k]); ActorExtra[k].floorz = sector[sprite[j].sectnum].floorz; ActorExtra[k].ceilingz = sector[sprite[j].sectnum].ceilingz; @@ -6889,7 +6931,7 @@ static void G_MoveEffectors(void) //STATNUM 3 { sprite[j].x += x; sprite[j].y += l; - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(j,(vec3_t *)&sprite[j]); if (sector[sprite[j].sectnum].floorstat&2) if (sprite[j].statnum == 2) A_Fall(j); @@ -6903,13 +6945,19 @@ static void G_MoveEffectors(void) //STATNUM 3 TRAVERSE_CONNECT(p) if (g_player[p].ps->cursectnum == s->sectnum && g_player[p].ps->on_ground) { + vec3_t vect; + g_player[p].ps->posx += x; g_player[p].ps->posy += l; g_player[p].ps->oposx = g_player[p].ps->posx; g_player[p].ps->oposy = g_player[p].ps->posy; - setsprite(g_player[p].ps->i,g_player[p].ps->posx,g_player[p].ps->posy,g_player[p].ps->posz+PHEIGHT); + vect.x = g_player[p].ps->posx; + vect.y = g_player[p].ps->posy; + vect.z = g_player[p].ps->posz+PHEIGHT; + + setsprite(g_player[p].ps->i,&vect); } sc->floorxpanning-=x>>3; @@ -7024,7 +7072,7 @@ static void G_MoveEffectors(void) //STATNUM 3 sprite[j].x += x>>2; sprite[j].y += l>>2; - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(j,(vec3_t *)&sprite[j]); if (sector[sprite[j].sectnum].floorstat&2) if (sprite[j].statnum == 2) @@ -7056,7 +7104,7 @@ static void G_MoveEffectors(void) //STATNUM 3 k = A_Spawn(i,SMALLSMOKE); sprite[k].xvel = 96+(krand()&127); A_SetSprite(k,CLIPMASK0); - setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); + setsprite(k,(vec3_t *)&sprite[k]); if (rnd(16)) A_Spawn(i,EXPLOSION2); } @@ -7135,7 +7183,7 @@ static void G_MoveEffectors(void) //STATNUM 3 sprite[j].y += x; sprite[j].z += s->zvel; - setsprite(j,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(j,(vec3_t *)&sprite[j]); } j = nextj; } @@ -7152,7 +7200,7 @@ static void G_MoveEffectors(void) //STATNUM 3 g_player[p].ps->posz += s->zvel; ms(i); - setsprite(i,s->x,s->y,s->z); + setsprite(i,(vec3_t *)s); break; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 8a9bc1b65..f6939ff6c 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif -#define BUILDDATE " 20090105" +#define BUILDDATE " 20090112" #define VERSION " 1.2.0devel" static int32_t floor_over_floor; @@ -323,7 +323,7 @@ void ExtLoadMap(const char *mapname) void ExtSaveMap(const char *mapname) { UNREFERENCED_PARAMETER(mapname); - saveboard("backup.map",&posx,&posy,&posz,&ang,&cursectnum); + saveboard("backup.map",&pos.x,&pos.y,&pos.z,&ang,&cursectnum); } int32_t getTileGroup(const char *groupName) @@ -3091,7 +3091,7 @@ void getnumberptr256(char *namestart, void *num, int32_t bytes, int32_t maxnumbe if (quitevent) quitevent = 0; } - drawrooms(posx,posy,posz,ang,horiz,cursectnum); + drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); #ifdef SUPERBUILD ExtAnalyzeSprites(); #endif @@ -3186,28 +3186,28 @@ void getnumberptr256(char *namestart, void *num, int32_t bytes, int32_t maxnumbe static void DoSpriteOrnament(int32_t i) { int32_t j; - int32_t hitx, hity, hitz; - int16_t hitsect, hitwall, hitsprite; + hitdata_t hitinfo; - hitscan(sprite[i].x,sprite[i].y,sprite[i].z,sprite[i].sectnum, + hitscan((const vec3_t *)&sprite[i],sprite[i].sectnum, sintable[(sprite[i].ang+2560+1024)&2047], sintable[(sprite[i].ang+2048+1024)&2047], 0, - &hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + &hitinfo,CLIPMASK1); - sprite[i].x = hitx; - sprite[i].y = hity; - sprite[i].z = hitz; - changespritesect(i,hitsect); - if (hitwall >= 0) - sprite[i].ang = ((getangle(wall[wall[hitwall].point2].x-wall[hitwall].x,wall[wall[hitwall].point2].y-wall[hitwall].y)+512)&2047); + sprite[i].x = hitinfo.pos.x; + sprite[i].y = hitinfo.pos.y; + sprite[i].z = hitinfo.pos.z; + changespritesect(i,hitinfo.hitsect); + if (hitinfo.hitwall >= 0) + sprite[i].ang = ((getangle(wall[wall[hitinfo.hitwall].point2].x-wall[hitinfo.hitwall].x, + wall[wall[hitinfo.hitwall].point2].y-wall[hitinfo.hitwall].y)+512)&2047); //Make sure sprite's in right sector if (inside(sprite[i].x,sprite[i].y,sprite[i].sectnum) == 0) { - j = wall[hitwall].point2; - sprite[i].x -= ksgn(wall[j].y-wall[hitwall].y); - sprite[i].y += ksgn(wall[j].x-wall[hitwall].x); + j = wall[hitinfo.hitwall].point2; + sprite[i].x -= ksgn(wall[j].y-wall[hitinfo.hitwall].y); + sprite[i].y += ksgn(wall[j].x-wall[hitinfo.hitwall].x); } } @@ -3359,7 +3359,7 @@ ENDFOR1: if (sprite[linebegspr].pal>0) sprite[linebegspr].pal--; } - drawrooms(posx,posy,posz,ang,horiz,cursectnum); + drawrooms(pos.x,pos.y,pos.z,ang,horiz,cursectnum); #ifdef SUPERBUILD ExtAnalyzeSprites(); #endif @@ -3392,10 +3392,13 @@ ENDFOR1: } j = sp->xrepeat*(hgap+tilesizx[sp->picnum]+2); - setsprite(cursor, - dax + ((j*sintable[daang])>>17), - day - ((j*sintable[(daang+512)&2047])>>17), - sp->z); + { + vec3_t vect; + vect.x = dax + ((j*sintable[daang])>>17); + vect.y = day - ((j*sintable[(daang+512)&2047])>>17); + vect.z = sp->z; + setsprite(cursor,&vect); + } if (ch>=33 && ch<=126 && alphabets[alphidx].pic[ch-33] >= 0) { @@ -4000,13 +4003,13 @@ static void Keys3d(void) noclip = i; } - getzrange(posx,posy,posz,cursectnum,&hiz,&hihit,&loz,&lohit,128L,CLIPMASK0); + getzrange(&pos,cursectnum,&hiz,&hihit,&loz,&lohit,128L,CLIPMASK0); if (keystatus[KEYSC_CAPS] || (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_Z])) { zmode++; if (zmode == 3) zmode = 0; - else if (zmode == 1) zlock = (loz-posz)&0xfffffc00; + else if (zmode == 1) zlock = (loz-pos.z)&0xfffffc00; switch (zmode) { case 0: message("Zmode = Gravity");break; @@ -4056,7 +4059,7 @@ static void Keys3d(void) { sprite[searchwall].cstat &= ~8; if ((i&64) > 0) - if (posz > sprite[searchwall].z) + if (pos.z > sprite[searchwall].z) sprite[searchwall].cstat |= 8; } asksave = 1; @@ -5840,9 +5843,9 @@ static void Keys3d(void) int16_t cursectnum=sprite[searchwall].sectnum; xvect = -((mousex*(int32_t)sintable[(ang+2048)&2047])<<3); yvect = -((mousex*(int32_t)sintable[(ang+1536)&2047])<<3); - clipmove(&sprite[searchwall].x,&sprite[searchwall].y,&sprite[searchwall].z, + clipmove((vec3_t *)&sprite[searchwall], &cursectnum,xvect,yvect,128L,4L<<8,4L<<8,spnoclip?1:CLIPMASK0); - setsprite(searchwall,sprite[searchwall].x,sprite[searchwall].y,sprite[searchwall].z); + setsprite(searchwall,(vec3_t *)&sprite[searchwall]); } else { @@ -5946,9 +5949,9 @@ static void Keys3d(void) int16_t cursectnum=sprite[searchwall].sectnum; xvect = -((mousey*(int32_t)sintable[(ang+2560)&2047])<<3); yvect = -((mousey*(int32_t)sintable[(ang+2048)&2047])<<3); - clipmove(&sprite[searchwall].x,&sprite[searchwall].y,&sprite[searchwall].z, + clipmove((vec3_t *)&sprite[searchwall], &cursectnum,xvect,yvect,128L,4L<<8,4L<<8,spnoclip?1:CLIPMASK0); - setsprite(searchwall,sprite[searchwall].x,sprite[searchwall].y,sprite[searchwall].z); + setsprite(searchwall,(vec3_t *)&sprite[searchwall]); } else { @@ -6562,8 +6565,8 @@ static void DoSpriteSearch(int32_t dir) // <0: backwards, >=0: forwards } // found matching sprite - posx = sprite[gs_cursprite].x; - posy = sprite[gs_cursprite].y; + pos.x = sprite[gs_cursprite].x; + pos.y = sprite[gs_cursprite].y; ang = sprite[gs_cursprite].ang; printmessage16("%s Sprite seach%s: found sprite %d", dir<0 ? "<" : ">", @@ -6965,8 +6968,8 @@ static void Keys2d(void) (search_hitag!=0 && search_hitag==wall[i].hitag)) ) { - posx=(wall[i].x)-(((wall[i].x)-(wall[wall[i].point2].x))/2); - posy=(wall[i].y)-(((wall[i].y)-(wall[wall[i].point2].y))/2); + pos.x=(wall[i].x)-(((wall[i].x)-(wall[wall[i].point2].x))/2); + pos.y=(wall[i].y)-(((wall[i].y)-(wall[wall[i].point2].y))/2); printmessage16("< Wall search: found"); // curwallnum--; keystatus[KEYSC_LBRACK]=0; @@ -6995,8 +6998,8 @@ static void Keys2d(void) (search_hitag!=0 && search_hitag==sprite[i].hitag)) ) { - posx=sprite[i].x; - posy=sprite[i].y; + pos.x=sprite[i].x; + pos.y=sprite[i].y; ang= sprite[i].ang; printmessage16("< Sprite search: found"); // curspritenum--; @@ -7031,8 +7034,8 @@ static void Keys2d(void) (search_hitag!=0 && search_hitag==wall[i].hitag)) ) { - posx=(wall[i].x)-(((wall[i].x)-(wall[wall[i].point2].x))/2); - posy=(wall[i].y)-(((wall[i].y)-(wall[wall[i].point2].y))/2); + pos.x=(wall[i].x)-(((wall[i].x)-(wall[wall[i].point2].x))/2); + pos.y=(wall[i].y)-(((wall[i].y)-(wall[wall[i].point2].y))/2); printmessage16("> Wall search: found"); // curwallnum++; keystatus[KEYSC_RBRACK]=0; @@ -7058,8 +7061,8 @@ static void Keys2d(void) (search_hitag!=0 && search_hitag==sprite[i].hitag)) ) { - posx=sprite[i].x; - posy=sprite[i].y; + pos.x=sprite[i].x; + pos.y=sprite[i].y; ang= sprite[i].ang; printmessage16("> Sprite search: found"); // curspritenum++; @@ -7195,7 +7198,7 @@ static void Keys2d(void) { editstatus = 0; zmode = 2; - posz = ((sector[cursectnum].ceilingz+sector[cursectnum].floorz)>>1); + pos.z = ((sector[cursectnum].ceilingz+sector[cursectnum].floorz)>>1); } else { @@ -7229,9 +7232,9 @@ static void Keys2d(void) if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_J]) // ' J { - posx=getnumber16("X-coordinate: ",posx,131072L,1); - posy=getnumber16("Y-coordinate: ",posy,131072L,1); - Bsprintf(tempbuf,"Current pos now (%d, %d)",posx,posy); + pos.x=getnumber16("X-coordinate: ",pos.x,131072L,1); + pos.y=getnumber16("Y-coordinate: ",pos.y,131072L,1); + Bsprintf(tempbuf,"Current pos now (%d, %d)",pos.x,pos.y); printmessage16(tempbuf); keystatus[KEYSC_J]=0; } @@ -8802,7 +8805,7 @@ void ExtPreCheckKeys(void) // just before drawrooms } } } - if (floor_over_floor) SE40Code(posx,posy,posz,ang,horiz); + if (floor_over_floor) SE40Code(pos.x,pos.y,pos.z,ang,horiz); if (purpleon) clearview(255); if (sidemode != 0) { @@ -8882,7 +8885,7 @@ void ExtPreCheckKeys(void) // just before drawrooms if (frames!=0) { if (frames==10) frames=0; - k = 1536;//getangle(tspr->x-posx,tspr->y-posy); + k = 1536;//getangle(tspr->x-pos.x,tspr->y-pos.y); k = (((sprite[i].ang+3072+128-k)&2047)>>8)&7; //This guy has only 5 pictures for 8 angles (3 are x-flipped) if (k <= 4) @@ -8915,8 +8918,8 @@ void ExtPreCheckKeys(void) // just before drawrooms } - xp1 = mulscale14(sprite[i].x-posx,zoom); - yp1 = mulscale14(sprite[i].y-posy-(tilesizy[picnum]<<2),zoom); + xp1 = mulscale14(sprite[i].x-pos.x,zoom); + yp1 = mulscale14(sprite[i].y-pos.y-(tilesizy[picnum]<<2),zoom); if (i+16384 != pointhighlight || !(totalclock&32)) { shade = sprite[i].shade; @@ -8937,8 +8940,8 @@ void ExtPreCheckKeys(void) // just before drawrooms for (i=0;i= 256*/ && sprite[i].sectnum != MAXSECTORS) { - xp1 = mulscale14(sprite[i].x-posx,zoom); - yp1 = mulscale14(sprite[i].y-posy,zoom); + xp1 = mulscale14(sprite[i].x-pos.x,zoom); + yp1 = mulscale14(sprite[i].y-pos.y,zoom); radius = mulscale14(sprite[i].hitag,zoom); col = 6; @@ -9059,7 +9062,7 @@ void ExtAnalyzeSprites(void) if (frames!=0) { if (frames==10) frames=0; - k = getangle(tspr->x-posx,tspr->y-posy); + k = getangle(tspr->x-pos.x,tspr->y-pos.y); k = (((tspr->ang+3072+128-k)&2047)>>8)&7; //This guy has only 5 pictures for 8 angles (3 are x-flipped) if (k <= 4) @@ -9162,7 +9165,7 @@ static void Keys2d3d(void) keystatus[KEYSC_P] = 0; if (!eitherALT) - updatesector(posx, posy, &cursectnum); + updatesector(pos.x, pos.y, &cursectnum); else updatesector(startposx, startposy, &startsectnum); @@ -9225,7 +9228,7 @@ static void Keys2d3d(void) if (eitherALT) saveboard("autosave.map",&startposx,&startposy,&startposz,&startang,&startsectnum); else - saveboard("autosave.map",&posx,&posy,&posz,&ang,&cursectnum); + saveboard("autosave.map",&pos.x,&pos.y,&pos.z,&ang,&cursectnum); message("Board saved to AUTOSAVE.MAP. Starting the game..."); uninitmouse(); @@ -9284,7 +9287,7 @@ static void Keys2d3d(void) if (totalclock < (lastsave + 120*10) || !AskIfSure("Are you sure you want to load the last saved map?")) { - int32_t sposx=posx,sposy=posy,sposz=posz,sang=ang; + int32_t sposx=pos.x,sposy=pos.y,sposz=pos.z,sang=ang; lastsave=totalclock; highlightcnt = -1; @@ -9299,9 +9302,9 @@ static void Keys2d3d(void) for (i=MAXSPRITES-1;i>=0;i--) sprite[i].extra = -1; ExtPreLoadMap(); - i = loadboard(f,(!pathsearchmode&&grponlymode?2:0),&posx,&posy,&posz,&ang,&cursectnum); + i = loadboard(f,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum); loadmhk(); - if (i == -2) i = loadoldboard(f,(!pathsearchmode&&grponlymode?2:0),&posx,&posy,&posz,&ang,&cursectnum); + if (i == -2) i = loadoldboard(f,(!pathsearchmode&&grponlymode?2:0),&pos.x,&pos.y,&pos.z,&ang,&cursectnum); if (i < 0) printmessage16("Invalid map format."); else { @@ -9310,12 +9313,12 @@ static void Keys2d3d(void) else message("Map %s loaded successfully",f); } updatenumsprites(); - startposx = posx; - startposy = posy; - startposz = posz; + startposx = pos.x; + startposy = pos.y; + startposz = pos.z; startang = ang; startsectnum = cursectnum; - posx=sposx;posy=sposy;posz=sposz;ang=sang; + pos.x=sposx;pos.y=sposy;pos.z=sposz;ang=sang; keystatus[KEYSC_L]=0; } } @@ -9468,11 +9471,12 @@ void faketimerhandler(void) return; ototalclock = totalclock; - oposx = posx; - oposy = posy; - hitwall = clipmove(&posx,&posy,&posz,&cursectnum,xvel,yvel,128L,4L<<8,4L<<8,0); - xvel = ((posx-oposx)<<14); - yvel = ((posy-oposy)<<14); + oposx = pos.x; + oposy = pos.y; + + hitwall = clipmove(&pos,&cursectnum,xvel,yvel,128L,4L<<8,4L<<8,0); + xvel = ((pos.x-oposx)<<14); + yvel = ((pos.y-oposy)<<14); yvel += 80000; if ((hitwall&0xc000) == 32768) @@ -9506,18 +9510,18 @@ void faketimerhandler(void) ang = ((ang+((timoff+32-ototalclock)>>4))&2047); } - getzrange(posx,posy,posz,cursectnum,&hiz,&hihit,&loz,&lohit,128L,0); + getzrange(&pos,cursectnum,&hiz,&hihit,&loz,&lohit,128L,0); - oposx -= posx; - oposy -= posy; + oposx -= pos.x; + oposy -= pos.y; dist = ksqrt(oposx*oposx+oposy*oposy); if (ototalclock > timoff+32) dist = 0; daang = mulscale(dist,angvel,9); - posz += (daang<<6); - if (posz > loz-(4<<8)) posz = loz-(4<<8), hvel = 0; - if (posz < hiz+(4<<8)) posz = hiz+(4<<8), hvel = 0; + pos.z += (daang<<6); + if (pos.z > loz-(4<<8)) pos.z = loz-(4<<8), hvel = 0; + if (pos.z < hiz+(4<<8)) pos.z = hiz+(4<<8), hvel = 0; horiz = ((horiz*7+(100-(daang>>1)))>>3); if (horiz < 100) horiz++; @@ -9572,8 +9576,8 @@ static void SearchSectorsForward() { if (sector[ii].lotag==cursector_lotag) { - posx=wall[sector[ii].wallptr].x; - posy=wall[sector[ii].wallptr].y; + pos.x=wall[sector[ii].wallptr].x; + pos.y=wall[sector[ii].wallptr].y; printmessage16("> Sector search: found"); // cursectornum++; keystatus[KEYSC_RBRACK]=0; // ] @@ -9595,8 +9599,8 @@ static void SearchSectorsBackward() { if (sector[ii].lotag==cursector_lotag) { - posx=wall[sector[ii].wallptr].x; - posy=wall[sector[ii].wallptr].y; + pos.x=wall[sector[ii].wallptr].x; + pos.y=wall[sector[ii].wallptr].y; printmessage16("< Sector search: found"); // cursectornum--; keystatus[KEYSC_LBRACK]=0; // [ diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 7aa4299b9..f4a3397c7 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -368,6 +368,7 @@ typedef struct { } config_t; typedef struct { + int32_t camerax,cameray,cameraz; int32_t const_visibility,uw_framerate; int32_t camera_time,folfvel,folavel,folx,foly,fola; int32_t reccnt,crosshairscale; @@ -386,7 +387,6 @@ typedef struct { int32_t m_ffire,ffire,m_player_skill,m_level_number,m_volume_number,multimode; int32_t player_skill,level_number,volume_number,m_marker,marker,mouseflip; - int32_t camerax,cameray,cameraz; int32_t configversion; int16_t cameraang, camerasect, camerahoriz; @@ -420,13 +420,13 @@ extern int32_t fricxv,fricyv; // mywhatever type globals typedef struct { - int32_t zoom, exitx, exity; int32_t posx, posy, posz, horiz, ohoriz, ohorizoff, invdisptime; int32_t bobposx, bobposy, oposx, oposy, oposz, pyoff, opyoff; int32_t posxv, posyv, poszv, last_pissed_time, truefz, truecz; int32_t player_par, visibility; int32_t bobcounter, weapon_sway; int32_t pals_time, randomflamex, crack_time; + int32_t zoom, exitx, exity; uint32_t interface_toggle_flag; @@ -574,10 +574,6 @@ extern int32_t movefifoplc, vel,svel,angvel,horiz; extern int16_t g_mirrorWall[64], g_mirrorSector[64], g_mirrorCount; -typedef struct { - int32_t x, y, z; -} vec3_t; - #include "funct.h" extern int32_t g_screenCapture; @@ -630,7 +626,8 @@ extern int32_t g_networkBroadcastMode; extern char lumplockbyte[11]; //DUKE3D.H - replace the end "my's" with this -extern int32_t myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; +extern vec3_t my; +extern vec3_t my, omy, myvel; extern int16_t myhoriz, omyhoriz, myhorizoff, omyhorizoff, g_skillSoundID; extern int16_t myang, omyang, mycursectnum, myjumpingcounter; extern char myjumpingtoggle, myonground, myhardlanding,myreturntocenter; diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h index 98ccf45b3..eb7fe2a33 100644 --- a/polymer/eduke32/source/funct.h +++ b/polymer/eduke32/source/funct.h @@ -56,7 +56,7 @@ extern int32_t G_CheckActivatorMotion(int32_t lotag); extern int32_t CheckDoorTile(int32_t dapic); extern int32_t isanunderoperator(int32_t lotag); extern int32_t isanearoperator(int32_t lotag); -extern inline int32_t CheckPlayerInSector(int32_t sect); +extern inline int32_t G_CheckPlayerInSector(int32_t sect); extern int32_t ldist(spritetype *s1,spritetype *s2); extern int32_t dist(spritetype *s1,spritetype *s2); extern int32_t __fastcall A_FindPlayer(spritetype *s,int32_t *d); diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 287a96482..5ad9d11a8 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -3742,8 +3742,8 @@ void G_DisplayRest(int32_t smoothratio) { if (screenpeek == myconnectindex && numplayers > 1) { - cposx = omyx+mulscale16((int32_t)(myx-omyx),smoothratio); - cposy = omyy+mulscale16((int32_t)(myy-omyy),smoothratio); + cposx = omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio); + cposy = omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio); cang = omyang+mulscale16((int32_t)(((myang+1024-omyang)&2047)-1024),smoothratio); } else @@ -3954,20 +3954,21 @@ void G_DisplayRest(int32_t smoothratio) G_FadePalette(tempTint.r,tempTint.g,tempTint.b,tempTint.f|128); } -static void G_DoThirdPerson(DukePlayer_t *pp, int32_t *vx, int32_t *vy,int32_t *vz,int16_t *vsectnum, int32_t ang, int32_t horiz) +static void G_DoThirdPerson(DukePlayer_t *pp, vec3_t *vect,int16_t *vsectnum, int32_t ang, int32_t horiz) { spritetype *sp = &sprite[pp->i]; - int32_t i, hx, hy, hitx, hity, hitz; + int32_t i, hx, hy; int32_t nx = (sintable[(ang+1536)&2047]>>4); int32_t ny = (sintable[(ang+1024)&2047]>>4); int32_t nz = (horiz-100)*128; - int16_t hitsect, hitwall, hitsprite, daang; + int16_t daang; int16_t bakcstat = sp->cstat; + hitdata_t hitinfo; sp->cstat &= (int16_t)~0x101; - updatesectorz(*vx,*vy,*vz,vsectnum); - hitscan(*vx,*vy,*vz,*vsectnum,nx,ny,nz,&hitsect,&hitwall,&hitsprite,&hitx,&hity,&hitz,CLIPMASK1); + updatesectorz(vect->x,vect->y,vect->z,vsectnum); + hitscan((const vec3_t *)&vect,*vsectnum,nx,ny,nz,&hitinfo,CLIPMASK1); if (*vsectnum < 0) { @@ -3975,21 +3976,21 @@ static void G_DoThirdPerson(DukePlayer_t *pp, int32_t *vx, int32_t *vy,int32_t * return; } - hx = hitx-(*vx); - hy = hity-(*vy); + hx = hitinfo.pos.x-(vect->x); + hy = hitinfo.pos.y-(vect->y); if (klabs(nx)+klabs(ny) > klabs(hx)+klabs(hy)) { - *vsectnum = hitsect; - if (hitwall >= 0) + *vsectnum = hitinfo.hitsect; + if (hitinfo.hitwall >= 0) { - daang = getangle(wall[wall[hitwall].point2].x-wall[hitwall].x, - wall[wall[hitwall].point2].y-wall[hitwall].y); + daang = getangle(wall[wall[hitinfo.hitwall].point2].x-wall[hitinfo.hitwall].x, + wall[wall[hitinfo.hitwall].point2].y-wall[hitinfo.hitwall].y); i = nx*sintable[daang]+ny*sintable[(daang+1536)&2047]; if (klabs(nx) > klabs(ny)) hx -= mulscale28(nx,i); else hy -= mulscale28(ny,i); } - else if (hitsprite < 0) + else if (hitinfo.hitsprite < 0) { if (klabs(nx) > klabs(ny)) hx -= (nx>>5); else hy -= (ny>>5); @@ -3998,14 +3999,14 @@ static void G_DoThirdPerson(DukePlayer_t *pp, int32_t *vx, int32_t *vy,int32_t * else i = divscale16(hy,ny); if (i < g_cameraDistance) g_cameraDistance = i; } - *vx = (*vx)+mulscale16(nx,g_cameraDistance); - *vy = (*vy)+mulscale16(ny,g_cameraDistance); - *vz = (*vz)+mulscale16(nz,g_cameraDistance); + vect->x = (vect->x)+mulscale16(nx,g_cameraDistance); + vect->y = (vect->y)+mulscale16(ny,g_cameraDistance); + vect->z = (vect->z)+mulscale16(nz,g_cameraDistance); g_cameraDistance = min(g_cameraDistance+((totalclock-g_cameraClock)<<10),65536); g_cameraClock = totalclock; - updatesectorz(*vx,*vy,*vz,vsectnum); + updatesectorz(vect->x,vect->y,vect->z,vsectnum); sp->cstat = bakcstat; } @@ -4459,9 +4460,9 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio) if ((snum == myconnectindex) && (numplayers > 1)) { - ud.camerax = omyx+mulscale16((int32_t)(myx-omyx),smoothratio); - ud.cameray = omyy+mulscale16((int32_t)(myy-omyy),smoothratio); - ud.cameraz = omyz+mulscale16((int32_t)(myz-omyz),smoothratio); + ud.camerax = omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio); + ud.cameray = omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio); + ud.cameraz = omy.z+mulscale16((int32_t)(my.z-omy.z),smoothratio); ud.cameraang = omyang+mulscale16((int32_t)(((myang+1024-omyang)&2047)-1024),smoothratio); ud.camerahoriz = omyhoriz+omyhorizoff+mulscale16((int32_t)(myhoriz+myhorizoff-omyhoriz-omyhorizoff),smoothratio); ud.camerasect = mycursectnum; @@ -4491,7 +4492,7 @@ void G_DrawRooms(int32_t snum,int32_t smoothratio) if (ud.viewbob) ud.cameraz += p->opyoff+mulscale16((int32_t)(p->pyoff-p->opyoff),smoothratio); } - else G_DoThirdPerson(p,&ud.camerax,&ud.cameray,&ud.cameraz,&ud.camerasect,ud.cameraang,ud.camerahoriz); + else G_DoThirdPerson(p,(vec3_t *)&ud,&ud.camerasect,ud.cameraang,ud.camerahoriz); cz = ActorExtra[p->i].ceilingz; fz = ActorExtra[p->i].floorz; @@ -4960,7 +4961,7 @@ int32_t A_Spawn(int32_t j, int32_t pn) case WATERSPLASH2__STATIC: if (j >= 0) { - setsprite(i,sprite[j].x,sprite[j].y,sprite[j].z); + setsprite(i,(vec3_t *)&sprite[j]); sp->xrepeat = sp->yrepeat = 8+(krand()&7); } else sp->xrepeat = sp->yrepeat = 16+(krand()&15); @@ -5054,7 +5055,7 @@ int32_t A_Spawn(int32_t j, int32_t pn) sp->xvel = 128; changespritestat(i,5); A_SetSprite(i,CLIPMASK0); - setsprite(i,sp->x,sp->y,sp->z); + setsprite(i,(vec3_t *)sp); break; case FRAMEEFFECT1_13__STATIC: @@ -5672,7 +5673,7 @@ int32_t A_Spawn(int32_t j, int32_t pn) sprite[s].z = sp->z; sprite[s].shade = sp->shade; - setsprite(s,sprite[s].x,sprite[s].y,sprite[s].z); + setsprite(s,(vec3_t *)&sprite[s]); break; } s = nextspritestat[s]; @@ -7044,9 +7045,9 @@ void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio) t->cstat |= 2; if (screenpeek == myconnectindex && numplayers >= 2) { - t->x = omyx+mulscale16((int32_t)(myx-omyx),smoothratio); - t->y = omyy+mulscale16((int32_t)(myy-omyy),smoothratio); - t->z = omyz+mulscale16((int32_t)(myz-omyz),smoothratio)+(40<<8); + t->x = omy.x+mulscale16((int32_t)(my.x-omy.x),smoothratio); + t->y = omy.y+mulscale16((int32_t)(my.y-omy.y),smoothratio); + t->z = omy.z+mulscale16((int32_t)(my.z-omy.z),smoothratio)+(40<<8); t->ang = omyang+mulscale16((int32_t)(((myang+1024-omyang)&2047)-1024),smoothratio); t->sectnum = mycursectnum; } @@ -12074,15 +12075,15 @@ static void Net_CorrectPrediction(void) if (p->posx == myxbak[i] && p->posy == myybak[i] && p->posz == myzbak[i] && p->horiz == myhorizbak[i] && p->ang == myangbak[i]) return; - myx = p->posx; - omyx = p->oposx; - myxvel = p->posxv; - myy = p->posy; - omyy = p->oposy; - myyvel = p->posyv; - myz = p->posz; - omyz = p->oposz; - myzvel = p->poszv; + my.x = p->posx; + omy.x = p->oposx; + myvel.x = p->posxv; + my.y = p->posy; + omy.y = p->oposy; + myvel.y = p->posyv; + my.z = p->posz; + omy.z = p->oposz; + myvel.z = p->poszv; myang = p->ang; omyang = p->oang; mycursectnum = p->cursectnum; @@ -12127,31 +12128,31 @@ static void Net_DoPrediction(void) if (ud.clipping == 0 && (sector[psect].floorpicnum == MIRROR || psect < 0 || psect >= MAXSECTORS)) { - myx = omyx; - myy = omyy; + my.x = omy.x; + my.y = omy.y; } else { - omyx = myx; - omyy = myy; + omy.x = my.x; + omy.y = my.y; } omyhoriz = myhoriz; omyhorizoff = myhorizoff; - omyz = myz; + omy.z = my.z; omyang = myang; - getzrange(myx,myy,myz,psect,&cz,&hz,&fz,&lz,163L,CLIPMASK0); + getzrange(&my,psect,&cz,&hz,&fz,&lz,163L,CLIPMASK0); - j = getflorzofslope(psect,myx,myy); + j = getflorzofslope(psect,my.x,my.y); - if ((lz&49152) == 16384 && psectlotag == 1 && klabs(myz-j) > PHEIGHT+(16<<8)) + if ((lz&49152) == 16384 && psectlotag == 1 && klabs(my.z-j) > PHEIGHT+(16<<8)) psectlotag = 0; if (p->aim_mode == 0 && myonground && psectlotag != 2 && (sector[psect].floorstat&2)) { - x = myx+(sintable[(myang+512)&2047]>>5); - y = myy+(sintable[myang&2047]>>5); + x = my.x+(sintable[(myang+512)&2047]>>5); + y = my.y+(sintable[myang&2047]>>5); tempsect = psect; updatesector(x,y,&tempsect); if (tempsect >= 0) @@ -12172,7 +12173,7 @@ static void Net_DoPrediction(void) if (sprite[hz].statnum == 1 && sprite[hz].extra >= 0) { hz = 0; - cz = getceilzofslope(psect,myx,myy); + cz = getceilzofslope(psect,my.x,my.y); } } @@ -12186,9 +12187,9 @@ static void Net_DoPrediction(void) } if (A_CheckEnemySprite(&sprite[j]) && sprite[j].xrepeat > 24 && klabs(sprite[p->i].z-sprite[j].z) < (84<<8)) { - j = getangle(sprite[j].x-myx,sprite[j].y-myy); - myxvel -= sintable[(j+512)&2047]<<4; - myyvel -= sintable[j&2047]<<4; + j = getangle(sprite[j].x-my.x,sprite[j].y-my.y); + myvel.x -= sintable[(j+512)&2047]<<4; + myvel.y -= sintable[j&2047]<<4; } } @@ -12198,14 +12199,14 @@ static void Net_DoPrediction(void) { if (p->on_warping_sector == 0) { - if (klabs(myz-fz) > (PHEIGHT>>1)) - myz += 348; + if (klabs(my.z-fz) > (PHEIGHT>>1)) + my.z += 348; } - clipmove(&myx,&myy,&myz,&mycursectnum,0,0,164L,(4L<<8),(4L<<8),CLIPMASK0); + clipmove(&my,&mycursectnum,0,0,164L,(4L<<8),(4L<<8),CLIPMASK0); } - updatesector(myx,myy,&mycursectnum); - pushmove(&myx,&myy,&myz,&mycursectnum,128L,(4L<<8),(20L<<8),CLIPMASK0); + updatesector(my.x,my.y,&mycursectnum); + pushmove(&my,&mycursectnum,128L,(4L<<8),(20L<<8),CLIPMASK0); myhoriz = 100; myhorizoff = 0; @@ -12227,43 +12228,43 @@ static void Net_DoPrediction(void) if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) { - if (myzvel > 0) myzvel = 0; - myzvel -= 348; - if (myzvel < -(256*6)) myzvel = -(256*6); + if (myvel.z > 0) myvel.z = 0; + myvel.z -= 348; + if (myvel.z < -(256*6)) myvel.z = -(256*6); } else if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) { - if (myzvel < 0) myzvel = 0; - myzvel += 348; - if (myzvel > (256*6)) myzvel = (256*6); + if (myvel.z < 0) myvel.z = 0; + myvel.z += 348; + if (myvel.z > (256*6)) myvel.z = (256*6); } else { - if (myzvel < 0) + if (myvel.z < 0) { - myzvel += 256; - if (myzvel > 0) - myzvel = 0; + myvel.z += 256; + if (myvel.z > 0) + myvel.z = 0; } - if (myzvel > 0) + if (myvel.z > 0) { - myzvel -= 256; - if (myzvel < 0) - myzvel = 0; + myvel.z -= 256; + if (myvel.z < 0) + myvel.z = 0; } } - if (myzvel > 2048) myzvel >>= 1; + if (myvel.z > 2048) myvel.z >>= 1; - myz += myzvel; + my.z += myvel.z; - if (myz > (fz-(15<<8))) - myz += ((fz-(15<<8))-myz)>>1; + if (my.z > (fz-(15<<8))) + my.z += ((fz-(15<<8))-my.z)>>1; - if (myz < (cz+(4<<8))) + if (my.z < (cz+(4<<8))) { - myz = cz+(4<<8); - myzvel = 0; + my.z = cz+(4<<8); + myvel.z = 0; } } @@ -12274,23 +12275,23 @@ static void Net_DoPrediction(void) myhardlanding = 0; if (p->jetpack_on < 11) - myz -= (p->jetpack_on<<7); //Goin up + my.z -= (p->jetpack_on<<7); //Goin up if (shrunk) j = 512; else j = 2048; if (TEST_SYNC_KEY(sb_snum, SK_JUMP)) //A - myz -= j; + my.z -= j; if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) //Z - myz += j; + my.z += j; if (shrunk == 0 && (psectlotag == 0 || psectlotag == 2)) k = 32; else k = 16; - if (myz > (fz-(k<<8))) - myz += ((fz-(k<<8))-myz)>>1; - if (myz < (cz+(18<<8))) - myz = cz+(18<<8); + if (my.z > (fz-(k<<8))) + my.z += ((fz-(k<<8))-my.z)>>1; + if (my.z < (cz+(18<<8))) + my.z = cz+(18<<8); } else if (psectlotag != 2) { @@ -12299,49 +12300,49 @@ static void Net_DoPrediction(void) if (shrunk == 0) i = 34; else i = 12; } - if (myz < (fz-(i<<8)) && (G_CheckForSpaceFloor(psect)|G_CheckForSpaceCeiling(psect)) == 0) //falling + if (my.z < (fz-(i<<8)) && (G_CheckForSpaceFloor(psect)|G_CheckForSpaceCeiling(psect)) == 0) //falling { if (!TEST_SYNC_KEY(sb_snum, SK_JUMP) && !TEST_SYNC_KEY(sb_snum, SK_CROUCH) && - myonground && (sector[psect].floorstat&2) && myz >= (fz-(i<<8)-(16<<8))) - myz = fz-(i<<8); + myonground && (sector[psect].floorstat&2) && my.z >= (fz-(i<<8)-(16<<8))) + my.z = fz-(i<<8); else { myonground = 0; - myzvel += (g_spriteGravity+80); + myvel.z += (g_spriteGravity+80); - if (myzvel >= (4096+2048)) myzvel = (4096+2048); + if (myvel.z >= (4096+2048)) myvel.z = (4096+2048); } } else { - if (psectlotag != 1 && psectlotag != 2 && myonground == 0 && myzvel > (6144>>1)) - myhardlanding = myzvel>>10; + if (psectlotag != 1 && psectlotag != 2 && myonground == 0 && myvel.z > (6144>>1)) + myhardlanding = myvel.z>>10; myonground = 1; if (i==40) { //Smooth on the ground - k = ((fz-(i<<8))-myz)>>1; + k = ((fz-(i<<8))-my.z)>>1; if (klabs(k) < 256) k = 0; - myz += k; // ((fz-(i<<8))-myz)>>1; - myzvel -= 768; // 412; - if (myzvel < 0) myzvel = 0; + my.z += k; // ((fz-(i<<8))-my.z)>>1; + myvel.z -= 768; // 412; + if (myvel.z < 0) myvel.z = 0; } else if (myjumpingcounter == 0) { - myz += ((fz-(i<<7))-myz)>>1; //Smooth on the water - if (p->on_warping_sector == 0 && myz > fz-(16<<8)) + my.z += ((fz-(i<<7))-my.z)>>1; //Smooth on the water + if (p->on_warping_sector == 0 && my.z > fz-(16<<8)) { - myz = fz-(16<<8); - myzvel >>= 1; + my.z = fz-(16<<8); + myvel.z >>= 1; } } if (TEST_SYNC_KEY(sb_snum, SK_CROUCH)) - myz += (2048+768); + my.z += (2048+768); if (TEST_SYNC_KEY(sb_snum, SK_JUMP) == 0 && myjumpingtoggle == 1) myjumpingtoggle = 0; @@ -12369,11 +12370,11 @@ static void Net_DoPrediction(void) if (psectlotag == 1 && myjumpingcounter > 768) { myjumpingcounter = 0; - myzvel = -512; + myvel.z = -512; } else { - myzvel -= (sintable[(2048-128+myjumpingcounter)&2047])/12; + myvel.z -= (sintable[(2048-128+myjumpingcounter)&2047])/12; myjumpingcounter += 180; myonground = 0; @@ -12382,18 +12383,18 @@ static void Net_DoPrediction(void) else { myjumpingcounter = 0; - myzvel = 0; + myvel.z = 0; } } - myz += myzvel; + my.z += myvel.z; - if (myz < (cz+(4<<8))) + if (my.z < (cz+(4<<8))) { myjumpingcounter = 0; - if (myzvel < 0) myxvel = myyvel = 0; - myzvel = 128; - myz = cz+(4<<8); + if (myvel.z < 0) myvel.x = myvel.y = 0; + myvel.z = 128; + my.z = cz+(4<<8); } } @@ -12407,8 +12408,8 @@ static void Net_DoPrediction(void) p->kickback_pic < 4)) { doubvel = 0; - myxvel = 0; - myyvel = 0; + myvel.x = 0; + myvel.y = 0; } else if (syn->avel) //p->ang += syncangvel * constant { @@ -12421,42 +12422,42 @@ static void Net_DoPrediction(void) myang &= 2047; } - if (myxvel || myyvel || syn->fvel || syn->svel) + if (myvel.x || myvel.y || syn->fvel || syn->svel) { if (p->jetpack_on == 0 && p->steroids_amount > 0 && p->steroids_amount < 400) doubvel <<= 1; - myxvel += ((syn->fvel*doubvel)<<6); - myyvel += ((syn->svel*doubvel)<<6); + myvel.x += ((syn->fvel*doubvel)<<6); + myvel.y += ((syn->svel*doubvel)<<6); if ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && myonground) || (myonground && TEST_SYNC_KEY(sb_snum, SK_CROUCH))) { - myxvel = mulscale16(myxvel,p->runspeed-0x2000); - myyvel = mulscale16(myyvel,p->runspeed-0x2000); + myvel.x = mulscale16(myvel.x,p->runspeed-0x2000); + myvel.y = mulscale16(myvel.y,p->runspeed-0x2000); } else { if (psectlotag == 2) { - myxvel = mulscale16(myxvel,p->runspeed-0x1400); - myyvel = mulscale16(myyvel,p->runspeed-0x1400); + myvel.x = mulscale16(myvel.x,p->runspeed-0x1400); + myvel.y = mulscale16(myvel.y,p->runspeed-0x1400); } else { - myxvel = mulscale16(myxvel,p->runspeed); - myyvel = mulscale16(myyvel,p->runspeed); + myvel.x = mulscale16(myvel.x,p->runspeed); + myvel.y = mulscale16(myvel.y,p->runspeed); } } - if (klabs(myxvel) < 2048 && klabs(myyvel) < 2048) - myxvel = myyvel = 0; + if (klabs(myvel.x) < 2048 && klabs(myvel.y) < 2048) + myvel.x = myvel.y = 0; if (shrunk) { - myxvel = - mulscale16(myxvel,(p->runspeed)-(p->runspeed>>1)+(p->runspeed>>2)); - myyvel = - mulscale16(myyvel,(p->runspeed)-(p->runspeed>>1)+(p->runspeed>>2)); + myvel.x = + mulscale16(myvel.x,(p->runspeed)-(p->runspeed>>1)+(p->runspeed>>2)); + myvel.y = + mulscale16(myvel.y,(p->runspeed)-(p->runspeed>>1)+(p->runspeed>>2)); } } @@ -12464,11 +12465,11 @@ FAKEHORIZONLY: if (psectlotag == 1 || spritebridge == 1) i = (4L<<8); else i = (20L<<8); - clipmove(&myx,&myy,&myz,&mycursectnum,myxvel,myyvel,164L,4L<<8,i,CLIPMASK0); - pushmove(&myx,&myy,&myz,&mycursectnum,164L,4L<<8,4L<<8,CLIPMASK0); + clipmove(&my,&mycursectnum,myvel.x,myvel.y,164L,4L<<8,i,CLIPMASK0); + pushmove(&my,&mycursectnum,164L,4L<<8,4L<<8,CLIPMASK0); if (p->jetpack_on == 0 && psectlotag != 1 && psectlotag != 2 && shrunk) - myz += 30<<8; + my.z += 30<<8; if (TEST_SYNC_KEY(sb_snum, SK_CENTER_VIEW) || myhardlanding) myreturntocenter = 9; @@ -12530,9 +12531,9 @@ ENDFAKEPROCESSINPUT: X_OnEvent(EVENT_FAKEDOMOVETHINGS, g_player[myconnectindex].ps->i, myconnectindex, -1); - myxbak[predictfifoplc&(MOVEFIFOSIZ-1)] = myx; - myybak[predictfifoplc&(MOVEFIFOSIZ-1)] = myy; - myzbak[predictfifoplc&(MOVEFIFOSIZ-1)] = myz; + myxbak[predictfifoplc&(MOVEFIFOSIZ-1)] = my.x; + myybak[predictfifoplc&(MOVEFIFOSIZ-1)] = my.y; + myzbak[predictfifoplc&(MOVEFIFOSIZ-1)] = my.z; myangbak[predictfifoplc&(MOVEFIFOSIZ-1)] = myang; myhorizbak[predictfifoplc&(MOVEFIFOSIZ-1)] = myhoriz; predictfifoplc++; @@ -12612,29 +12613,30 @@ static int32_t G_DoMoveThings(void) if (ud.idplayers && ud.multimode > 1) { - int32_t sx,sy,sz; - int16_t sect,hw,hs; + hitdata_t hitinfo; for (i=0;iholoduke_on != -1) sprite[g_player[i].ps->holoduke_on].cstat ^= 256; - hitscan(g_player[screenpeek].ps->posx,g_player[screenpeek].ps->posy,g_player[screenpeek].ps->posz,g_player[screenpeek].ps->cursectnum, + hitscan((vec3_t *)g_player[screenpeek].ps,g_player[screenpeek].ps->cursectnum, sintable[(g_player[screenpeek].ps->ang+512)&2047], sintable[g_player[screenpeek].ps->ang&2047], - (100-g_player[screenpeek].ps->horiz-g_player[screenpeek].ps->horizoff)<<11,§,&hw,&hs,&sx,&sy,&sz,0xffff0030); + (100-g_player[screenpeek].ps->horiz-g_player[screenpeek].ps->horizoff)<<11,&hitinfo,0xffff0030); for (i=0;iholoduke_on != -1) sprite[g_player[i].ps->holoduke_on].cstat ^= 256; - if ((hs >= 0) && !(g_player[myconnectindex].ps->gm & MODE_MENU) && sprite[hs].picnum == APLAYER && sprite[hs].yvel != screenpeek && g_player[sprite[hs].yvel].ps->dead_flag == 0) + if ((hitinfo.hitsprite >= 0) && !(g_player[myconnectindex].ps->gm & MODE_MENU) && + sprite[hitinfo.hitsprite].picnum == APLAYER && sprite[hitinfo.hitsprite].yvel != screenpeek && + g_player[sprite[hitinfo.hitsprite].yvel].ps->dead_flag == 0) { if (g_player[screenpeek].ps->fta == 0 || g_player[screenpeek].ps->ftq == 117) { - if (ldist(&sprite[g_player[screenpeek].ps->i],&sprite[hs]) < 9216) + if (ldist(&sprite[g_player[screenpeek].ps->i],&sprite[hitinfo.hitsprite]) < 9216) { - Bsprintf(ScriptQuotes[117],"%s",&g_player[sprite[hs].yvel].user_name[0]); + Bsprintf(ScriptQuotes[117],"%s",&g_player[sprite[hitinfo.hitsprite].yvel].user_name[0]); g_player[screenpeek].ps->fta = 12, g_player[screenpeek].ps->ftq = 117; } } diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 041dae905..9cec6067c 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -202,19 +202,20 @@ int32_t A_GetFurthestAngle(int32_t iActor,int32_t angs) { int32_t furthest_angle=0; - int16_t hitsect,hitwall,hitspr; - int32_t hx, hy, hz, d; + int32_t d; int32_t greatestd = -(1<<30); int32_t angincs = 2048/angs,j; + hitdata_t hitinfo; for (j=s->ang;j<(2048+s->ang);j+=angincs) { - hitscan(s->x, s->y, s->z-(8<<8), s->sectnum, + s->z -= (8<<8); + hitscan((const vec3_t *)s, s->sectnum, sintable[(j+512)&2047], sintable[j&2047],0, - &hitsect,&hitwall,&hitspr,&hx,&hy,&hz,CLIPMASK1); - - d = klabs(hx-s->x) + klabs(hy-s->y); + &hitinfo,CLIPMASK1); + s->z += (8<<8); + d = klabs(hitinfo.pos.x-s->x) + klabs(hitinfo.pos.y-s->y); if (d > greatestd) { @@ -230,10 +231,10 @@ int32_t A_FurthestVisiblePoint(int32_t iActor,spritetype *ts,int32_t *dax,int32_ { if ((ActorExtra[iActor].temp_data[0]&63)) return -1; { - int16_t hitsect,hitwall,hitspr, angincs; - int32_t hx, hy, hz, d, da;//, d, cd, ca,tempx,tempy,cx,cy; - int32_t j; + int32_t d, da;//, d, cd, ca,tempx,tempy,cx,cy; + int32_t j, angincs; spritetype *s = &sprite[iActor]; + hitdata_t hitinfo; if (ud.multimode < 2 && ud.player_skill < 3) angincs = 2048/2; @@ -241,20 +242,24 @@ int32_t A_FurthestVisiblePoint(int32_t iActor,spritetype *ts,int32_t *dax,int32_ for (j=ts->ang;j<(2048+ts->ang);j+=(angincs-(krand()&511))) { - hitscan(ts->x, ts->y, ts->z-(16<<8), ts->sectnum, + ts->z -= (16<<8); + hitscan((const vec3_t *)ts, ts->sectnum, sintable[(j+512)&2047], sintable[j&2047],16384-(krand()&32767), - &hitsect,&hitwall,&hitspr,&hx,&hy,&hz,CLIPMASK1); + &hitinfo,CLIPMASK1); - d = klabs(hx-ts->x)+klabs(hy-ts->y); - da = klabs(hx-s->x)+klabs(hy-s->y); + ts->z += (16<<8); - if (d < da && hitsect > -1) - if (cansee(hx,hy,hz,hitsect,s->x,s->y,s->z-(16<<8),s->sectnum)) + d = klabs(hitinfo.pos.x-ts->x)+klabs(hitinfo.pos.y-ts->y); + da = klabs(hitinfo.pos.x-s->x)+klabs(hitinfo.pos.y-s->y); + + if (d < da && hitinfo.hitsect > -1) + if (cansee(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z, + hitinfo.hitsect,s->x,s->y,s->z-(16<<8),s->sectnum)) { - *dax = hx; - *day = hy; - return hitsect; + *dax = hitinfo.pos.x; + *day = hitinfo.pos.y; + return hitinfo.hitsect; } } return -1; @@ -272,7 +277,9 @@ void A_GetZLimits(int32_t iActor) if (s->statnum == 4) zr = 4L; - getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&ActorExtra[iActor].ceilingz,&hz,&ActorExtra[iActor].floorz,&lz,zr,CLIPMASK0); + s->z -= FOURSLEIGHT; + getzrange((vec3_t *)s,s->sectnum,&ActorExtra[iActor].ceilingz,&hz,&ActorExtra[iActor].floorz,&lz,zr,CLIPMASK0); + s->z += FOURSLEIGHT; if ((lz&49152) == 49152 && (sprite[lz&(MAXSPRITES-1)].cstat&48) == 0) { @@ -321,7 +328,11 @@ void A_Fall(int32_t iActor) } if ((s->statnum == 1 || s->statnum == 10 || s->statnum == 2 || s->statnum == 6)) - getzrange(s->x,s->y,s->z-(FOURSLEIGHT),s->sectnum,&ActorExtra[iActor].ceilingz,&hz,&ActorExtra[iActor].floorz,&lz,127L,CLIPMASK0); + { + s->z -= FOURSLEIGHT; + getzrange((vec3_t *)s,s->sectnum,&ActorExtra[iActor].ceilingz,&hz,&ActorExtra[iActor].floorz,&lz,127L,CLIPMASK0); + s->z += FOURSLEIGHT; + } else { ActorExtra[iActor].ceilingz = sector[s->sectnum].ceilingz; @@ -445,7 +456,7 @@ static void X_Move(void) { ActorExtra[vm.g_i].bposx = vm.g_sp->x; ActorExtra[vm.g_i].bposy = vm.g_sp->y; - setsprite(vm.g_i,vm.g_sp->x,vm.g_sp->y,vm.g_sp->z); + setsprite(vm.g_i,(vec3_t *)vm.g_sp); } return; } @@ -1078,7 +1089,7 @@ static int32_t X_DoExecute(void) else if (vm.g_sp->zvel > 2048 && sector[vm.g_sp->sectnum].lotag != 1) { j = vm.g_sp->sectnum; - pushmove(&vm.g_sp->x,&vm.g_sp->y,&vm.g_sp->z,(int16_t*)&j,128L,(4L<<8),(4L<<8),CLIPMASK0); + pushmove((vec3_t *)vm.g_sp,(int16_t*)&j,128L,(4L<<8),(4L<<8),CLIPMASK0); if (j != vm.g_sp->sectnum && j >= 0 && j < MAXSECTORS) changespritesect(vm.g_i,j); A_PlaySound(THUD,vm.g_i); @@ -2276,48 +2287,62 @@ static int32_t X_DoExecute(void) case CON_GETZRANGE: insptr++; { - int32_t x=Gv_GetVarX(*insptr++), y=Gv_GetVarX(*insptr++), z=Gv_GetVarX(*insptr++); - int32_t sectnum=Gv_GetVarX(*insptr++); - int32_t ceilzvar=*insptr++, ceilhitvar=*insptr++, florzvar=*insptr++, florhitvar=*insptr++; - int32_t walldist=Gv_GetVarX(*insptr++), clipmask=Gv_GetVarX(*insptr++); - int32_t ceilz, ceilhit, florz, florhit; + vec3_t vect; + + vect.x = Gv_GetVarX(*insptr++); + vect.y = Gv_GetVarX(*insptr++); + vect.z = Gv_GetVarX(*insptr++); - if ((sectnum<0 || sectnum>=numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sectnum); - break; + int32_t sectnum=Gv_GetVarX(*insptr++); + int32_t ceilzvar=*insptr++, ceilhitvar=*insptr++, florzvar=*insptr++, florhitvar=*insptr++; + int32_t walldist=Gv_GetVarX(*insptr++), clipmask=Gv_GetVarX(*insptr++); + int32_t ceilz, ceilhit, florz, florhit; + + + if ((sectnum<0 || sectnum>=numsectors) && g_scriptSanityChecks) + { + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sectnum); + break; + } + getzrange(&vect, sectnum, &ceilz, &ceilhit, &florz, &florhit, walldist, clipmask); + Gv_SetVarX(ceilzvar, ceilz); + Gv_SetVarX(ceilhitvar, ceilhit); + Gv_SetVarX(florzvar, florz); + Gv_SetVarX(florhitvar, florhit); } - getzrange(x, y, z, sectnum, &ceilz, &ceilhit, &florz, &florhit, walldist, clipmask); - Gv_SetVarX(ceilzvar, ceilz); - Gv_SetVarX(ceilhitvar, ceilhit); - Gv_SetVarX(florzvar, florz); - Gv_SetVarX(florhitvar, florhit); break; } case CON_HITSCAN: insptr++; { - int32_t xs=Gv_GetVarX(*insptr++), ys=Gv_GetVarX(*insptr++), zs=Gv_GetVarX(*insptr++); - int32_t sectnum=Gv_GetVarX(*insptr++); - int32_t vx=Gv_GetVarX(*insptr++), vy=Gv_GetVarX(*insptr++), vz=Gv_GetVarX(*insptr++); - int32_t hitsectvar=*insptr++, hitwallvar=*insptr++, hitspritevar=*insptr++; - int32_t hitxvar=*insptr++, hityvar=*insptr++, hitzvar=*insptr++, cliptype=Gv_GetVarX(*insptr++); - int16_t hitsect, hitwall, hitsprite; - int32_t hitx, hity, hitz; + vec3_t vect; + hitdata_t hitinfo; + + vect.x = Gv_GetVarX(*insptr++); + vect.x = Gv_GetVarX(*insptr++); + vect.z = Gv_GetVarX(*insptr++); - if ((sectnum<0 || sectnum>=numsectors) && g_scriptSanityChecks) { - OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sectnum); - break; + int32_t sectnum=Gv_GetVarX(*insptr++); + int32_t vx=Gv_GetVarX(*insptr++), vy=Gv_GetVarX(*insptr++), vz=Gv_GetVarX(*insptr++); + int32_t hitsectvar=*insptr++, hitwallvar=*insptr++, hitspritevar=*insptr++; + int32_t hitxvar=*insptr++, hityvar=*insptr++, hitzvar=*insptr++, cliptype=Gv_GetVarX(*insptr++); + + if ((sectnum<0 || sectnum>=numsectors) && g_scriptSanityChecks) + { + OSD_Printf(CON_ERROR "Invalid sector %d\n",g_errorLineNum,keyw[g_tw],sectnum); + break; + } + hitscan((const vec3_t *)&vect, sectnum, vx, vy, vz, &hitinfo, cliptype); + Gv_SetVarX(hitsectvar, hitinfo.hitsect); + Gv_SetVarX(hitwallvar, hitinfo.hitwall); + Gv_SetVarX(hitspritevar, hitinfo.hitsprite); + Gv_SetVarX(hitxvar, hitinfo.pos.x); + Gv_SetVarX(hityvar, hitinfo.pos.y); + Gv_SetVarX(hitzvar, hitinfo.pos.z); } - hitscan(xs, ys, zs, sectnum, vx, vy, vz, &hitsect, &hitwall, &hitsprite, &hitx, &hity, &hitz, cliptype); - Gv_SetVarX(hitsectvar, hitsect); - Gv_SetVarX(hitwallvar, hitwall); - Gv_SetVarX(hitspritevar, hitsprite); - Gv_SetVarX(hitxvar, hitx); - Gv_SetVarX(hityvar, hity); - Gv_SetVarX(hitzvar, hitz); break; } @@ -2423,7 +2448,7 @@ static int32_t X_DoExecute(void) OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],spritenum); break; } - setsprite(spritenum, davector.x, davector.y, davector.z); + setsprite(spritenum, &davector); break; } @@ -2620,12 +2645,17 @@ static int32_t X_DoExecute(void) } else { + vec3_t tmpvect; + + tmpvect.x = g_player[vm.g_p].ps->posx; + tmpvect.y = g_player[vm.g_p].ps->posy; + tmpvect.z = g_player[vm.g_p].ps->posz+PHEIGHT; P_RandomSpawnPoint(vm.g_p); vm.g_sp->x = ActorExtra[vm.g_i].bposx = g_player[vm.g_p].ps->bobposx = g_player[vm.g_p].ps->oposx = g_player[vm.g_p].ps->posx; vm.g_sp->y = ActorExtra[vm.g_i].bposy = g_player[vm.g_p].ps->bobposy = g_player[vm.g_p].ps->oposy =g_player[vm.g_p].ps->posy; vm.g_sp->z = ActorExtra[vm.g_i].bposy = g_player[vm.g_p].ps->oposz =g_player[vm.g_p].ps->posz; updatesector(g_player[vm.g_p].ps->posx,g_player[vm.g_p].ps->posy,&g_player[vm.g_p].ps->cursectnum); - setsprite(g_player[vm.g_p].ps->i,g_player[vm.g_p].ps->posx,g_player[vm.g_p].ps->posy,g_player[vm.g_p].ps->posz+PHEIGHT); + setsprite(g_player[vm.g_p].ps->i,&tmpvect); vm.g_sp->cstat = 257; vm.g_sp->shade = -12; diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index d07853e89..87795950d 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -1501,15 +1501,15 @@ static void Gv_AddSystemVars(void) Gv_NewVar("cameradist",(intptr_t)&g_cameraDistance, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); Gv_NewVar("cameraclock",(intptr_t)&g_cameraClock, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("myx",(intptr_t)&myx, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("myy",(intptr_t)&myy, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("myz",(intptr_t)&myz, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("omyx",(intptr_t)&omyx, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("omyy",(intptr_t)&omyy, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("omyz",(intptr_t)&omyz, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("myxvel",(intptr_t)&myxvel, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("myyvel",(intptr_t)&myyvel, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); - Gv_NewVar("myzvel",(intptr_t)&myzvel, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("myx",(intptr_t)&my.x, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("myy",(intptr_t)&my.y, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("myz",(intptr_t)&my.z, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("omyx",(intptr_t)&omy.x, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("omyy",(intptr_t)&omy.y, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("omyz",(intptr_t)&omy.z, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("myvelx",(intptr_t)&myvel.x, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("myvely",(intptr_t)&myvel.y, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); + Gv_NewVar("myvelz",(intptr_t)&myvel.z, GAMEVAR_SYSTEM | GAMEVAR_INTPTR | GAMEVAR_SYNCCHECK); Gv_NewVar("myhoriz",(intptr_t)&myhoriz, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); Gv_NewVar("myhorizoff",(intptr_t)&myhorizoff, GAMEVAR_SYSTEM | GAMEVAR_SHORTPTR | GAMEVAR_SYNCCHECK); @@ -1651,15 +1651,15 @@ void Gv_RefreshPointers(void) aGameVars[Gv_GetVarIndex("cameradist")].val.lValue = (intptr_t)&g_cameraDistance; aGameVars[Gv_GetVarIndex("cameraclock")].val.lValue = (intptr_t)&g_cameraClock; - aGameVars[Gv_GetVarIndex("myx")].val.lValue = (intptr_t)&myx; - aGameVars[Gv_GetVarIndex("myy")].val.lValue = (intptr_t)&myy; - aGameVars[Gv_GetVarIndex("myz")].val.lValue = (intptr_t)&myz; - aGameVars[Gv_GetVarIndex("omyx")].val.lValue = (intptr_t)&omyx; - aGameVars[Gv_GetVarIndex("omyy")].val.lValue = (intptr_t)&omyy; - aGameVars[Gv_GetVarIndex("omyz")].val.lValue = (intptr_t)&omyz; - aGameVars[Gv_GetVarIndex("myxvel")].val.lValue = (intptr_t)&myxvel; - aGameVars[Gv_GetVarIndex("myyvel")].val.lValue = (intptr_t)&myyvel; - aGameVars[Gv_GetVarIndex("myzvel")].val.lValue = (intptr_t)&myzvel; + aGameVars[Gv_GetVarIndex("myx")].val.lValue = (intptr_t)&my.x; + aGameVars[Gv_GetVarIndex("myy")].val.lValue = (intptr_t)&my.y; + aGameVars[Gv_GetVarIndex("myz")].val.lValue = (intptr_t)&my.z; + aGameVars[Gv_GetVarIndex("omyx")].val.lValue = (intptr_t)&omy.x; + aGameVars[Gv_GetVarIndex("omyy")].val.lValue = (intptr_t)&omy.y; + aGameVars[Gv_GetVarIndex("omyz")].val.lValue = (intptr_t)&omy.z; + aGameVars[Gv_GetVarIndex("myvelx")].val.lValue = (intptr_t)&myvel.x; + aGameVars[Gv_GetVarIndex("myvely")].val.lValue = (intptr_t)&myvel.y; + aGameVars[Gv_GetVarIndex("myvelz")].val.lValue = (intptr_t)&myvel.z; aGameVars[Gv_GetVarIndex("myhoriz")].val.lValue = (intptr_t)&myhoriz; aGameVars[Gv_GetVarIndex("myhorizoff")].val.lValue = (intptr_t)&myhorizoff; diff --git a/polymer/eduke32/source/global.c b/polymer/eduke32/source/global.c index d25387d27..62314bfd1 100644 --- a/polymer/eduke32/source/global.c +++ b/polymer/eduke32/source/global.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //------------------------------------------------------------------------- #include "duke3d.h" -const char *s_buildDate = "20090105"; +const char *s_buildDate = "20090112"; char *MusicPtr = NULL; int32_t g_musicSize; @@ -147,7 +147,7 @@ int32_t g_impactDamage; int32_t g_scriptDebug; //GLOBAL.C - replace the end "my's" with this -int32_t myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; +vec3_t my, omy, myvel; int16_t myhoriz, omyhoriz, myhorizoff, omyhorizoff; int16_t myang, omyang, mycursectnum, myjumpingcounter; diff --git a/polymer/eduke32/source/mapster32.h b/polymer/eduke32/source/mapster32.h index 4dbcb1898..2cdf862db 100644 --- a/polymer/eduke32/source/mapster32.h +++ b/polymer/eduke32/source/mapster32.h @@ -30,7 +30,8 @@ char *defsfilename = "duke3d.def"; extern char keystatus[]; extern int16_t defaultspritecstat; -extern int32_t posx, posy, posz, horiz, qsetmode; +extern int32_t horiz, qsetmode; +extern vec3_t pos; extern int16_t ang, cursectnum; extern int16_t ceilingheinum, floorheinum; extern char names[MAXTILES][25]; diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 58a5a0cd3..75a8e4bf2 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -515,11 +515,11 @@ static int32_t osdcmd_setweaponscale(const osdfuncparm_t *parm) static int32_t osdcmd_spawn(const osdfuncparm_t *parm) { - int32_t x=0,y=0,z=0; uint16_t cstat=0,picnum=0; char pal=0; int16_t ang=0; int16_t set=0, idx; + vec3_t vect; if (numplayers > 1 || !(g_player[myconnectindex].ps->gm & MODE_GAME)) { @@ -530,9 +530,9 @@ static int32_t osdcmd_spawn(const osdfuncparm_t *parm) switch (parm->numparms) { case 7: // x,y,z - x = Batol(parm->parms[4]); - y = Batol(parm->parms[5]); - z = Batol(parm->parms[6]); + vect.x = Batol(parm->parms[4]); + vect.y = Batol(parm->parms[5]); + vect.z = Batol(parm->parms[6]); set |= 8; case 4: // ang ang = Batol(parm->parms[3]) & 2047; @@ -589,7 +589,7 @@ static int32_t osdcmd_spawn(const osdfuncparm_t *parm) if (set & 4) sprite[idx].ang = ang; if (set & 8) { - if (setsprite(idx, x,y,z) < 0) + if (setsprite(idx, &vect) < 0) { OSD_Printf("spawn: Sprite can't be spawned into null space\n"); deletesprite(idx); diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 5d0a403de..5a1fc6883 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -146,7 +146,7 @@ static void A_HitscanProjTrail(const vec3_t *sv, const vec3_t *dv, int32_t ang, vec3_t srcvect; vec3_t destvect; - Bmemcpy(&destvect,&dv,sizeof(vec3_t)); + Bmemcpy(&destvect, dv, sizeof(vec3_t)); srcvect.x = sv->x + (sintable[(348+ang+512)&2047]/ProjectileData[atwith].offset); srcvect.y = sv->y + (sintable[(ang+348)&2047]/ProjectileData[atwith].offset); @@ -178,18 +178,19 @@ static void A_HitscanProjTrail(const vec3_t *sv, const vec3_t *dv, int32_t ang, int32_t A_GetHitscanRange(int32_t i) { - int32_t sx,sy,sz; - int16_t sect,hw,hs; int32_t zoff = 0; + hitdata_t hitinfo; if (PN == APLAYER) zoff = (40<<8); - hitscan(SX,SY,SZ-zoff,SECT, + SZ -= zoff; + hitscan((const vec3_t *)&sprite[i],SECT, sintable[(SA+512)&2047], sintable[SA&2047], - 0,§,&hw,&hs,&sx,&sy,&sz,CLIPMASK1); + 0,&hitinfo,CLIPMASK1); - return (FindDistance2D(sx-SX,sy-SY)); + SZ += zoff; + return (FindDistance2D(hitinfo.pos.x-SX,hitinfo.pos.y-SY)); } static int32_t A_FindTargetSprite(spritetype *s,int32_t aang,int32_t atwith) @@ -304,9 +305,9 @@ static int32_t A_FindTargetSprite(spritetype *s,int32_t aang,int32_t atwith) int32_t A_Shoot(int32_t i,int32_t atwith) { - int16_t hitsect, hitspr, hitwall, l, sa, p, j, k=-1, wh, scount; + int16_t l, sa, p, j, k=-1, wh, scount; int32_t vel, zvel = 0, x, oldzvel, dal; - vec3_t hitvect; + hitdata_t hitinfo; vec3_t srcvect; char sizx,sizy; spritetype *s = &sprite[i]; @@ -375,30 +376,30 @@ int32_t A_Shoot(int32_t i,int32_t atwith) } if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan(srcvect.x,srcvect.y,srcvect.z,sect, + hitscan((const vec3_t *)&srcvect,sect, sintable[(sa+512)&2047], sintable[sa&2047],zvel<<6, - &hitsect,&hitwall,&hitspr,&hitvect.x,&hitvect.y,&hitvect.z,CLIPMASK1); + &hitinfo,CLIPMASK1); if (ProjectileData[atwith].workslike & PROJECTILE_BLOOD) { if (ProjectileData[atwith].range == 0) ProjectileData[atwith].range = 1024; - if (FindDistance2D(srcvect.x-hitvect.x,srcvect.y-hitvect.y) < ProjectileData[atwith].range) - if (FindDistance2D(wall[hitwall].x-wall[wall[hitwall].point2].x,wall[hitwall].y-wall[wall[hitwall].point2].y) > (mulscale(ProjectileData[atwith].xrepeat+8,tilesizx[ProjectileData[atwith].decal],3))) - if (hitwall >= 0 && wall[hitwall].overpicnum != BIGFORCE) - if ((wall[hitwall].nextsector >= 0 && hitsect >= 0 && - sector[wall[hitwall].nextsector].lotag == 0 && - sector[hitsect].lotag == 0 && - sector[wall[hitwall].nextsector].lotag == 0 && - (sector[hitsect].floorz-sector[wall[hitwall].nextsector].floorz) > (mulscale(ProjectileData[atwith].yrepeat,tilesizy[ProjectileData[atwith].decal],3)<<8)) || - (wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0)) - if ((wall[hitwall].cstat&16) == 0) + if (FindDistance2D(srcvect.x-hitinfo.pos.x,srcvect.y-hitinfo.pos.y) < ProjectileData[atwith].range) + if (FindDistance2D(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x,wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y) > (mulscale(ProjectileData[atwith].xrepeat+8,tilesizx[ProjectileData[atwith].decal],3))) + if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].overpicnum != BIGFORCE) + if ((wall[hitinfo.hitwall].nextsector >= 0 && hitinfo.hitsect >= 0 && + sector[wall[hitinfo.hitwall].nextsector].lotag == 0 && + sector[hitinfo.hitsect].lotag == 0 && + sector[wall[hitinfo.hitwall].nextsector].lotag == 0 && + (sector[hitinfo.hitsect].floorz-sector[wall[hitinfo.hitwall].nextsector].floorz) > (mulscale(ProjectileData[atwith].yrepeat,tilesizy[ProjectileData[atwith].decal],3)<<8)) || + (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag == 0)) + if ((wall[hitinfo.hitwall].cstat&16) == 0) { - if (wall[hitwall].nextsector >= 0) + if (wall[hitinfo.hitwall].nextsector >= 0) { - k = headspritesect[wall[hitwall].nextsector]; + k = headspritesect[wall[hitinfo.hitwall].nextsector]; while (k >= 0) { if (sprite[k].statnum == 3 && sprite[k].lotag == 13) @@ -407,29 +408,29 @@ int32_t A_Shoot(int32_t i,int32_t atwith) } } - if (wall[hitwall].nextwall >= 0 && - wall[wall[hitwall].nextwall].hitag != 0) + if (wall[hitinfo.hitwall].nextwall >= 0 && + wall[wall[hitinfo.hitwall].nextwall].hitag != 0) return -1; - if (wall[hitwall].hitag == 0) + if (wall[hitinfo.hitwall].hitag == 0) { if (ProjectileData[atwith].decal >= 0) { k = A_Spawn(i,ProjectileData[atwith].decal); /* - sprite[k].xvel = -12; - sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, - wall[hitwall].y-wall[wall[hitwall].point2].y)+512; - sprite[k].x = hitvect.x; - sprite[k].y = hitvect.y; - sprite[k].z = hitvect.z; - sprite[k].cstat |= (krand()&4); - sprite[k].xrepeat = ProjectileData[atwith].xrepeat; - sprite[k].yrepeat = ProjectileData[atwith].yrepeat; - sprite[k].cstat = 16+(krand()&12); - A_SetSprite(k,CLIPMASK0); - setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); - A_AddToDeleteQueue(k); + sprite[k].xvel = -12; + sprite[k].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, + wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; + sprite[k].x = hitinfo.pos.x; + sprite[k].y = hitinfo.pos.y; + sprite[k].z = hitinfo.pos.z; + sprite[k].cstat |= (krand()&4); + sprite[k].xrepeat = ProjectileData[atwith].xrepeat; + sprite[k].yrepeat = ProjectileData[atwith].yrepeat; + sprite[k].cstat = 16+(krand()&12); + A_SetSprite(k,CLIPMASK0); + setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); + A_AddToDeleteQueue(k); */ if (!(SpriteFlags[ProjectileData[atwith].decal] & SPRITE_DECAL)) @@ -437,11 +438,11 @@ int32_t A_Shoot(int32_t i,int32_t atwith) k = A_Spawn(i,ProjectileData[atwith].decal); sprite[k].xvel = -1; - sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, - wall[hitwall].y-wall[wall[hitwall].point2].y)+512; - sprite[k].x = hitvect.x; - sprite[k].y = hitvect.y; - sprite[k].z = hitvect.z; + sprite[k].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, + wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; + sprite[k].x = hitinfo.pos.x; + sprite[k].y = hitinfo.pos.y; + sprite[k].z = hitinfo.pos.z; if (ProjectileData[atwith].workslike & PROJECTILE_RANDDECALSIZE) { wh = (krand()&ProjectileData[atwith].xrepeat); @@ -484,18 +485,18 @@ int32_t A_Shoot(int32_t i,int32_t atwith) return -1; } - if (hitsect < 0) return -1; + if (hitinfo.hitsect < 0) return -1; if ((ProjectileData[atwith].range == 0) && (ProjectileData[atwith].workslike & PROJECTILE_KNEE)) ProjectileData[atwith].range = 1024; - if ((ProjectileData[atwith].range > 0) && ((klabs(srcvect.x-hitvect.x)+klabs(srcvect.y-hitvect.y)) > ProjectileData[atwith].range)) + if ((ProjectileData[atwith].range > 0) && ((klabs(srcvect.x-hitinfo.pos.x)+klabs(srcvect.y-hitinfo.pos.y)) > ProjectileData[atwith].range)) return -1; else { - if (hitwall >= 0 || hitspr >= 0) + if (hitinfo.hitwall >= 0 || hitinfo.hitsprite >= 0) { - j = A_InsertSprite(hitsect,hitvect.x,hitvect.y,hitvect.z,atwith,-15,0,0,sa,32,0,i,4); + j = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,atwith,-15,0,0,sa,32,0,i,4); ActorExtra[j].projectile.workslike = ProjectileData[sprite[j].picnum].workslike; sprite[j].extra = ProjectileData[atwith].extra; if (ProjectileData[atwith].extra_rand > 0) @@ -506,9 +507,9 @@ int32_t A_Shoot(int32_t i,int32_t atwith) { k = A_Spawn(j,ProjectileData[atwith].spawns); sprite[k].z -= (8<<8); - ActorExtra[k].temp_data[6] = hitwall; - ActorExtra[k].temp_data[7] = hitsect; - ActorExtra[k].temp_data[8] = hitspr; + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; } if (ProjectileData[atwith].sound >= 0) A_PlaySound(ProjectileData[atwith].sound,j); } @@ -516,31 +517,31 @@ int32_t A_Shoot(int32_t i,int32_t atwith) if (p >= 0 && g_player[p].ps->steroids_amount > 0 && g_player[p].ps->steroids_amount < 400) sprite[j].extra += (g_player[p].ps->max_player_health>>2); - if (hitspr >= 0 && sprite[hitspr].picnum != ACCESSSWITCH && sprite[hitspr].picnum != ACCESSSWITCH2) + if (hitinfo.hitsprite >= 0 && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH2) { - A_DamageObject(hitspr,j); - if (p >= 0) P_ActivateSwitch(p,hitspr,1); + A_DamageObject(hitinfo.hitsprite,j); + if (p >= 0) P_ActivateSwitch(p,hitinfo.hitsprite,1); } - else if (hitwall >= 0) + else if (hitinfo.hitwall >= 0) { - if (wall[hitwall].cstat&2) - if (wall[hitwall].nextsector >= 0) - if (hitvect.z >= (sector[wall[hitwall].nextsector].floorz)) - hitwall = wall[hitwall].nextwall; + if (wall[hitinfo.hitwall].cstat&2) + if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.pos.z >= (sector[wall[hitinfo.hitwall].nextsector].floorz)) + hitinfo.hitwall = wall[hitinfo.hitwall].nextwall; - if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) + if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].picnum != ACCESSSWITCH && wall[hitinfo.hitwall].picnum != ACCESSSWITCH2) { - A_DamageWall(j,hitwall,&hitvect,atwith); - if (p >= 0) P_ActivateSwitch(p,hitwall,0); + A_DamageWall(j,hitinfo.hitwall,&hitinfo.pos,atwith); + if (p >= 0) P_ActivateSwitch(p,hitinfo.hitwall,0); } } } - else if (p >= 0 && zvel > 0 && sector[hitsect].lotag == 1) + else if (p >= 0 && zvel > 0 && sector[hitinfo.hitsect].lotag == 1) { j = A_Spawn(g_player[p].ps->i,WATERSPLASH2); - sprite[j].x = hitvect.x; - sprite[j].y = hitvect.y; + sprite[j].x = hitinfo.pos.x; + sprite[j].y = hitinfo.pos.y; sprite[j].ang = g_player[p].ps->ang; // Total tweek sprite[j].xvel = 32; A_SetSprite(i,CLIPMASK0); @@ -573,11 +574,11 @@ int32_t A_Shoot(int32_t i,int32_t atwith) if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN)) { dal -= (8<<8); -// return -1; + // return -1; } - hitvect.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitvect.x == 0) hitvect.x++; - zvel = ((sprite[j].z-srcvect.z-dal)<<8) / hitvect.x; + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal)<<8) / hitinfo.pos.x; sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); } @@ -593,2586 +594,2585 @@ int32_t A_Shoot(int32_t i,int32_t atwith) { zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan(srcvect.x,srcvect.y,srcvect.z,sect,sintable[(sa+512)&2047],sintable[sa&2047], - zvel<<6,&hitsect,&hitwall,&hitspr,&hitvect.x,&hitvect.y,&hitvect.z,CLIPMASK1); - if (hitspr != -1) + hitscan((const vec3_t *)&srcvect,sect,sintable[(sa+512)&2047],sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + if (hitinfo.hitsprite != -1) { - if (sprite[hitspr].statnum == 1 || sprite[hitspr].statnum == 2 || sprite[hitspr].statnum == 10 || sprite[hitspr].statnum == 13) - j = hitspr; + if (sprite[hitinfo.hitsprite].statnum == 1 || sprite[hitinfo.hitsprite].statnum == 2 || sprite[hitinfo.hitsprite].statnum == 10 || sprite[hitinfo.hitsprite].statnum == 13) + j = hitinfo.hitsprite; } } if (j == -1) { sa += (angRange/2)-(krand()&(angRange-1)); - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - zvel += (zRange/2)-(krand()&(zRange-1)); - } - } - else - { - sa += (angRange/2)-(krand()&(angRange-1)); - if (j == -1) - { - // no target - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - } - zvel += (zRange/2)-(krand()&(zRange-1)); - } - srcvect.z -= (2<<8); - } - else - { - j = A_FindPlayer(s,&x); - srcvect.z -= (4<<8); - hitvect.x = ldist(&sprite[g_player[j].ps->i], s); - if (hitvect.x == 0) - hitvect.x++; - zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitvect.x; - if (s->picnum != BOSS1) - { - zvel += 128-(krand()&255); - sa += 32-(krand()&63); - } - else - { - zvel += 128-(krand()&255); - sa = getangle(g_player[j].ps->posx-srcvect.x,g_player[j].ps->posy-srcvect.y)+64-(krand()&127); - } - } - - if (ProjectileData[atwith].cstat >= 0) s->cstat &= ~ProjectileData[atwith].cstat; - else s->cstat &= ~257; - - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan(srcvect.x,srcvect.y,srcvect.z,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitsect,&hitwall,&hitspr,&hitvect.x,&hitvect.y,&hitvect.z,CLIPMASK1); - - - if (ProjectileData[atwith].cstat >= 0) s->cstat |= ProjectileData[atwith].cstat; - else s->cstat |= 257; - - if (hitsect < 0) return -1; - - if ((ProjectileData[atwith].range > 0) && - ((klabs(srcvect.x-hitvect.x)+klabs(srcvect.y-hitvect.y)) > ProjectileData[atwith].range)) - return -1; - - if (ProjectileData[atwith].trail >= 0) - { - vec3_t tmpvect; - vec3_t tmphvect; - Bmemcpy(&tmpvect,&srcvect,sizeof(vec3_t)); - Bmemcpy(&tmphvect,&hitvect,sizeof(vec3_t)); - A_HitscanProjTrail(&tmpvect,&tmphvect,sa,atwith); - } - - if (ProjectileData[atwith].workslike & PROJECTILE_WATERBUBBLES) - { - if ((krand()&15) == 0 && sector[hitsect].lotag == 2) - A_DoWaterTracers(hitvect.x,hitvect.y,hitvect.z,srcvect.x,srcvect.y,srcvect.z,8-(ud.multimode>>1)); - } - - if (p >= 0) - { - k = A_InsertSprite(hitsect,hitvect.x,hitvect.y,hitvect.z,SHOTSPARK1,-15,10,10,sa,0,0,i,4); - sprite[k].extra = ProjectileData[atwith].extra; - if (ProjectileData[atwith].extra_rand > 0) - sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); - sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - ActorExtra[k].temp_data[6] = hitwall; - ActorExtra[k].temp_data[7] = hitsect; - ActorExtra[k].temp_data[8] = hitspr; - - if (hitwall == -1 && hitspr == -1) - { - if (zvel < 0) - { - if (sector[hitsect].ceilingstat&1) - { - sprite[k].xrepeat = 0; - sprite[k].yrepeat = 0; - return -1; - } - else - Sect_DamageCeiling(hitsect); - } - if (ProjectileData[atwith].spawns >= 0) - { - wh=A_Spawn(k,ProjectileData[atwith].spawns); - if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; - if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; - ActorExtra[wh].temp_data[6] = hitwall; - ActorExtra[wh].temp_data[7] = hitsect; - ActorExtra[wh].temp_data[8] = hitspr; - } - } - - if (hitspr >= 0) - { - A_DamageObject(hitspr,k); - if (sprite[hitspr].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && g_player[sprite[hitspr].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) - { - l = A_Spawn(k,JIBS6); - sprite[k].xrepeat = sprite[k].yrepeat = 0; - sprite[l].z += (4<<8); - sprite[l].xvel = 16; - sprite[l].xrepeat = sprite[l].yrepeat = 24; - sprite[l].ang += 64-(krand()&127); - } - else - { - if (ProjectileData[atwith].spawns >= 0) - { - wh=A_Spawn(k,ProjectileData[atwith].spawns); - if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; - if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; - ActorExtra[wh].temp_data[6] = hitwall; - ActorExtra[wh].temp_data[7] = hitsect; - ActorExtra[wh].temp_data[8] = hitspr; - } - } - if (p >= 0 && ( - sprite[hitspr].picnum == DIPSWITCH || - sprite[hitspr].picnum == DIPSWITCH+1 || - sprite[hitspr].picnum == DIPSWITCH2 || - sprite[hitspr].picnum == DIPSWITCH2+1 || - sprite[hitspr].picnum == DIPSWITCH3 || - sprite[hitspr].picnum == DIPSWITCH3+1 || - sprite[hitspr].picnum == HANDSWITCH || - sprite[hitspr].picnum == HANDSWITCH+1)) - { - P_ActivateSwitch(p,hitspr,1); - return -1; - } - } - else if (hitwall >= 0) - { - if (ProjectileData[atwith].spawns >= 0) - { - wh=A_Spawn(k,ProjectileData[atwith].spawns); - if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; - if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; - ActorExtra[wh].temp_data[6] = hitwall; - ActorExtra[wh].temp_data[7] = hitsect; - ActorExtra[wh].temp_data[8] = hitspr; - } - if (CheckDoorTile(wall[hitwall].picnum) == 1) - goto DOSKIPBULLETHOLE; - if (p >= 0 && ( - wall[hitwall].picnum == DIPSWITCH || - wall[hitwall].picnum == DIPSWITCH+1 || - wall[hitwall].picnum == DIPSWITCH2 || - wall[hitwall].picnum == DIPSWITCH2+1 || - wall[hitwall].picnum == DIPSWITCH3 || - wall[hitwall].picnum == DIPSWITCH3+1 || - wall[hitwall].picnum == HANDSWITCH || - wall[hitwall].picnum == HANDSWITCH+1)) - { - P_ActivateSwitch(p,hitwall,0); - return -1; - } - - if (wall[hitwall].hitag != 0 || (wall[hitwall].nextwall >= 0 && wall[wall[hitwall].nextwall].hitag != 0)) - goto DOSKIPBULLETHOLE; - - if (hitsect >= 0 && sector[hitsect].lotag == 0) - if (wall[hitwall].overpicnum != BIGFORCE) - if ((wall[hitwall].nextsector >= 0 && sector[wall[hitwall].nextsector].lotag == 0) || - (wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0)) - if ((wall[hitwall].cstat&16) == 0) - { - if (wall[hitwall].nextsector >= 0) - { - l = headspritesect[wall[hitwall].nextsector]; - while (l >= 0) - { - if (sprite[l].statnum == 3 && sprite[l].lotag == 13) - goto DOSKIPBULLETHOLE; - l = nextspritesect[l]; - } - } - - l = headspritestat[STAT_MISC]; - while (l >= 0) - { - if (sprite[l].picnum == ProjectileData[atwith].decal) - if (dist(&sprite[l],&sprite[k]) < (12+(krand()&7))) - goto DOSKIPBULLETHOLE; - l = nextspritestat[l]; - } - if (ProjectileData[atwith].decal >= 0) - { - l = A_Spawn(k,ProjectileData[atwith].decal); - sprite[l].xvel = -1; - sprite[l].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, - wall[hitwall].y-wall[wall[hitwall].point2].y)+512; - if (ProjectileData[atwith].workslike & PROJECTILE_RANDDECALSIZE) - { - wh = (krand()&ProjectileData[atwith].xrepeat); - if (wh < ProjectileData[atwith].yrepeat) - wh = ProjectileData[atwith].yrepeat; - sprite[l].xrepeat = wh; - sprite[l].yrepeat = wh; - } - else - { - sprite[l].xrepeat = ProjectileData[atwith].xrepeat; - sprite[l].yrepeat = ProjectileData[atwith].yrepeat; - } - sprite[l].cstat = 16+(krand()&12); - sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); - sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); - - A_SetSprite(l,CLIPMASK0); - A_AddToDeleteQueue(l); - } - } - -DOSKIPBULLETHOLE: - - if (wall[hitwall].cstat&2) - if (wall[hitwall].nextsector >= 0) - if (hitvect.z >= (sector[wall[hitwall].nextsector].floorz)) - hitwall = wall[hitwall].nextwall; - - A_DamageWall(k,hitwall,&hitvect,atwith); - } - } - else - { - k = A_InsertSprite(hitsect,hitvect.x,hitvect.y,hitvect.z,SHOTSPARK1,-15,24,24,sa,0,0,i,4); - sprite[k].extra = ProjectileData[atwith].extra; - if (ProjectileData[atwith].extra_rand > 0) - sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); - sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - ActorExtra[k].temp_data[6] = hitwall; - ActorExtra[k].temp_data[7] = hitsect; - ActorExtra[k].temp_data[8] = hitspr; - - if (hitspr >= 0) - { - A_DamageObject(hitspr,k); - if (sprite[hitspr].picnum != APLAYER) - { - if (ProjectileData[atwith].spawns >= 0) - { - wh=A_Spawn(k,ProjectileData[atwith].spawns); - if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; - if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; - ActorExtra[wh].temp_data[6] = hitwall; - ActorExtra[wh].temp_data[7] = hitsect; - ActorExtra[wh].temp_data[8] = hitspr; - } - } - else sprite[k].xrepeat = sprite[k].yrepeat = 0; - } - else if (hitwall >= 0) - A_DamageWall(k,hitwall,&hitvect,atwith); - } - - if ((krand()&255) < 4) - if (ProjectileData[atwith].isound >= 0) - { - S_PlaySoundXYZ(ProjectileData[atwith].isound,k,&hitvect); - } - - return -1; - } - - if (ProjectileData[atwith].workslike & PROJECTILE_RPG) - { - - /* if(ProjectileData[atwith].workslike & PROJECTILE_FREEZEBLAST) - sz += (3<<8);*/ - - if (s->extra >= 0) s->shade = ProjectileData[atwith].shade; - - scount = 1; - vel = ProjectileData[atwith].vel; - - j = -1; - - if (p >= 0) - { - // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); - hitvect.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - - if (hitvect.x == 0) - hitvect.x++; - - zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitvect.x; - - if (sprite[j].picnum != RECON) - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - // else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*81; - else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*(ProjectileData[atwith].vel/8); - - if (ProjectileData[atwith].sound >= 0) - A_PlaySound(ProjectileData[atwith].sound,i); - } - else - { - if (!(ProjectileData[atwith].workslike & PROJECTILE_NOAIM)) - { - j = A_FindPlayer(s,&x); - sa = getangle(g_player[j].ps->oposx-srcvect.x,g_player[j].ps->oposy-srcvect.y); - - l = ldist(&sprite[g_player[j].ps->i],s); - if (l == 0) - l++; - zvel = ((g_player[j].ps->oposz-srcvect.z)*vel) / l; - - if (A_CheckEnemySprite(s) && (s->hitag&face_player_smart)) - sa = s->ang+(krand()&31)-16; - } - } - - - - if (p >= 0 && j >= 0) - l = j; - else l = -1; - - /* j = A_InsertSprite(sect, - sx+(sintable[(348+sa+512)&2047]/448), - sy+(sintable[(sa+348)&2047]/448), - sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4);*/ - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - j = A_InsertSprite(sect, - srcvect.x+(sintable[(348+sa+512)&2047]/ProjectileData[atwith].offset), - srcvect.y+(sintable[(sa+348)&2047]/ProjectileData[atwith].offset), - srcvect.z-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); - - sprite[j].xrepeat=ProjectileData[atwith].xrepeat; - sprite[j].yrepeat=ProjectileData[atwith].yrepeat; - - - if (ProjectileData[atwith].extra_rand > 0) - sprite[j].extra += (krand()&ProjectileData[atwith].extra_rand); - if (!(ProjectileData[atwith].workslike & PROJECTILE_BOUNCESOFFWALLS)) - sprite[j].yvel = l; - else - { - if (ProjectileData[atwith].bounces >= 1) sprite[j].yvel = ProjectileData[atwith].bounces; - else sprite[j].yvel = g_numFreezeBounces; - // sprite[j].xrepeat >>= 1; - // sprite[j].yrepeat >>= 1; - sprite[j].zvel -= (2<<4); - } - /* - if(p == -1) - { - if(!(ProjectileData[atwith].workslike & PROJECTILE_BOUNCESOFFWALLS)) - { - sprite[j].xrepeat = ProjectileData[atwith].xrepeat; // 30 - sprite[j].yrepeat = ProjectileData[atwith].yrepeat; - sprite[j].extra >>= 2; - } - } - */ - if (ProjectileData[atwith].cstat >= 0) sprite[j].cstat = ProjectileData[atwith].cstat; - else sprite[j].cstat = 128; - if (ProjectileData[atwith].clipdist >= 0) sprite[j].clipdist = ProjectileData[atwith].clipdist; - else sprite[j].clipdist = 40; - - Bmemcpy(&ActorExtra[j].projectile, &ProjectileData[sprite[j].picnum], sizeof(ProjectileData[sprite[j].picnum])); - - // sa = s->ang+32-(krand()&63); - // zvel = oldzvel+512-(krand()&1023); - - return j; - } - - } - else - { - switch (DynamicTileMap[atwith]) - { - case BLOODSPLAT1__STATIC: - case BLOODSPLAT2__STATIC: - case BLOODSPLAT3__STATIC: - case BLOODSPLAT4__STATIC: - - if (p >= 0) - sa += 64 - (krand()&127); - else sa += 1024 + 64 - (krand()&127); - zvel = 1024-(krand()&2047); - case KNEE__STATIC: - if (atwith == KNEE) - { - if (p >= 0) - { - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - srcvect.z += (6<<8); - sa += 15; - } - else - { - j = g_player[A_FindPlayer(s,&x)].ps->i; - zvel = ((sprite[j].z-srcvect.z)<<8) / (x+1); - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - } - - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan(srcvect.x,srcvect.y,srcvect.z,sect, - sintable[(sa+512)&2047], - sintable[sa&2047],zvel<<6, - &hitsect,&hitwall,&hitspr,&hitvect.x,&hitvect.y,&hitvect.z,CLIPMASK1); - - if (atwith == BLOODSPLAT1 || atwith == BLOODSPLAT2 || atwith == BLOODSPLAT3 || atwith == BLOODSPLAT4) - { - if (FindDistance2D(srcvect.x-hitvect.x,srcvect.y-hitvect.y) < 1024) - if (hitwall >= 0 && wall[hitwall].overpicnum != BIGFORCE) - if ((wall[hitwall].nextsector >= 0 && hitsect >= 0 && - sector[wall[hitwall].nextsector].lotag == 0 && - sector[hitsect].lotag == 0 && - sector[wall[hitwall].nextsector].lotag == 0 && - (sector[hitsect].floorz-sector[wall[hitwall].nextsector].floorz) > (16<<8)) || - (wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0)) - if ((wall[hitwall].cstat&16) == 0) - { - if (wall[hitwall].nextsector >= 0) - { - k = headspritesect[wall[hitwall].nextsector]; - while (k >= 0) - { - if (sprite[k].statnum == 3 && sprite[k].lotag == 13) - return -1; - k = nextspritesect[k]; - } - } - - if (wall[hitwall].nextwall >= 0 && - wall[wall[hitwall].nextwall].hitag != 0) - return -1; - - if (wall[hitwall].hitag == 0) - { - k = A_Spawn(i,atwith); - sprite[k].xvel = -12; - sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, - wall[hitwall].y-wall[wall[hitwall].point2].y)+512; - sprite[k].x = hitvect.x; - sprite[k].y = hitvect.y; - sprite[k].z = hitvect.z; - sprite[k].cstat |= (krand()&4); - A_SetSprite(k,CLIPMASK0); - setsprite(k,sprite[k].x,sprite[k].y,sprite[k].z); - if (PN == OOZFILTER || PN == NEWBEAST) - sprite[k].pal = 6; - } - } - return -1; - } - - if (hitsect < 0) break; - - if ((klabs(srcvect.x-hitvect.x)+klabs(srcvect.y-hitvect.y)) < 1024) - { - if (hitwall >= 0 || hitspr >= 0) - { - j = A_InsertSprite(hitsect,hitvect.x,hitvect.y,hitvect.z,KNEE,-15,0,0,sa,32,0,i,4); - sprite[j].extra += (krand()&7); - if (p >= 0) - { - k = A_Spawn(j,SMALLSMOKE); - sprite[k].z -= (8<<8); - A_PlaySound(KICK_HIT,j); - ActorExtra[k].temp_data[6] = hitwall; - ActorExtra[k].temp_data[7] = hitsect; - ActorExtra[k].temp_data[8] = hitspr; - } - - if (p >= 0 && g_player[p].ps->steroids_amount > 0 && g_player[p].ps->steroids_amount < 400) - sprite[j].extra += (g_player[p].ps->max_player_health>>2); - - if (hitspr >= 0 && sprite[hitspr].picnum != ACCESSSWITCH && sprite[hitspr].picnum != ACCESSSWITCH2) - { - A_DamageObject(hitspr,j); - if (p >= 0) P_ActivateSwitch(p,hitspr,1); - } - - else if (hitwall >= 0) - { - if (wall[hitwall].cstat&2) - if (wall[hitwall].nextsector >= 0) - if (hitvect.z >= (sector[wall[hitwall].nextsector].floorz)) - hitwall = wall[hitwall].nextwall; - - if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) - { - A_DamageWall(j,hitwall,&hitvect,atwith); - if (p >= 0) P_ActivateSwitch(p,hitwall,0); - } - } - } - else if (p >= 0 && zvel > 0 && sector[hitsect].lotag == 1) - { - j = A_Spawn(g_player[p].ps->i,WATERSPLASH2); - sprite[j].x = hitvect.x; - sprite[j].y = hitvect.y; - sprite[j].ang = g_player[p].ps->ang; // Total tweek - sprite[j].xvel = 32; - A_SetSprite(i,CLIPMASK0); - sprite[j].xvel = 0; - - } - } - - break; - - case SHOTSPARK1__STATIC: - case SHOTGUN__STATIC: - case CHAINGUN__STATIC: - - if (s->extra >= 0) s->shade = -96; - - if (p >= 0) - { - int32_t angRange=32; - int32_t zRange=256; - - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); - if (((sprite[j].picnum>=GREENSLIME)&&(sprite[j].picnum<=GREENSLIME+7))||(sprite[j].picnum==ROTATEGUN)) - { - - dal -= (8<<8); - - } - hitvect.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitvect.x == 0) hitvect.x++; - zvel = ((sprite[j].z-srcvect.z-dal)<<8) / hitvect.x; - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - - Gv_SetVar(g_iAngRangeVarID,angRange, i,p); - Gv_SetVar(g_iZRangeVarID,zRange,i,p); - - X_OnEvent(EVENT_GETSHOTRANGE, i,p, -1); - - angRange=Gv_GetVar(g_iAngRangeVarID,i,p); - zRange=Gv_GetVar(g_iZRangeVarID,i,p); - - if (atwith == SHOTSPARK1__STATIC && !WW2GI && !NAM) - { - if (!g_player[p].ps->auto_aim) - { - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan(srcvect.x,srcvect.y,srcvect.z,sect,sintable[(sa+512)&2047],sintable[sa&2047], - zvel<<6,&hitsect,&hitwall,&hitspr,&hitvect.x,&hitvect.y,&hitvect.z,CLIPMASK1); - if (hitspr != -1) - { - if (sprite[hitspr].statnum == 1 || sprite[hitspr].statnum == 2 || sprite[hitspr].statnum == 10 || sprite[hitspr].statnum == 13) - j = hitspr; - } - } - - if (j == -1) - { - sa += (angRange/2)-(krand()&(angRange-1)); - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - zvel += (zRange/2)-(krand()&(zRange-1)); - } - } - else - { - sa += (angRange/2)-(krand()&(angRange-1)); - if (j == -1) - { - // no target - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - } - zvel += (zRange/2)-(krand()&(zRange-1)); - } - - srcvect.z -= (2<<8); - } - else - { - j = A_FindPlayer(s,&x); - srcvect.z -= (4<<8); - hitvect.x = ldist(&sprite[g_player[j].ps->i], s); - if (hitvect.x == 0) - hitvect.x++; - zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitvect.x; - if (s->picnum != BOSS1) - { - zvel += 128-(krand()&255); - sa += 32-(krand()&63); - } - else - { - zvel += 128-(krand()&255); - sa = getangle(g_player[j].ps->posx-srcvect.x,g_player[j].ps->posy-srcvect.y)+64-(krand()&127); - } - } - - s->cstat &= ~257; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan(srcvect.x,srcvect.y,srcvect.z,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitsect,&hitwall,&hitspr,&hitvect.x,&hitvect.y,&hitvect.z,CLIPMASK1); - s->cstat |= 257; - - if (hitsect < 0) return -1; - - if ((krand()&15) == 0 && sector[hitsect].lotag == 2) - A_DoWaterTracers(hitvect.x,hitvect.y,hitvect.z, - srcvect.x,srcvect.y,srcvect.z,8-(ud.multimode>>1)); - - if (p >= 0) - { - k = A_InsertSprite(hitsect,hitvect.x,hitvect.y,hitvect.z,SHOTSPARK1,-15,10,10,sa,0,0,i,4); - sprite[k].extra = *actorscrptr[atwith]; - sprite[k].extra += (krand()%6); - sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - ActorExtra[k].temp_data[6] = hitwall; - ActorExtra[k].temp_data[7] = hitsect; - ActorExtra[k].temp_data[8] = hitspr; - - - if (hitwall == -1 && hitspr == -1) - { - if (zvel < 0) - { - if (sector[hitsect].ceilingstat&1) - { - sprite[k].xrepeat = 0; - sprite[k].yrepeat = 0; - return -1; - } - else - Sect_DamageCeiling(hitsect); - } - l = A_Spawn(k,SMALLSMOKE); - ActorExtra[l].temp_data[6] = hitwall; - ActorExtra[l].temp_data[7] = hitsect; - ActorExtra[l].temp_data[8] = hitspr; - } - - if (hitspr >= 0) - { - A_DamageObject(hitspr,k); - if (sprite[hitspr].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && g_player[sprite[hitspr].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) - { - l = A_Spawn(k,JIBS6); - sprite[k].xrepeat = sprite[k].yrepeat = 0; - sprite[l].z += (4<<8); - sprite[l].xvel = 16; - sprite[l].xrepeat = sprite[l].yrepeat = 24; - sprite[l].ang += 64-(krand()&127); - } - else - { - l = A_Spawn(k,SMALLSMOKE); - ActorExtra[l].temp_data[6] = hitwall; - ActorExtra[l].temp_data[7] = hitsect; - ActorExtra[l].temp_data[8] = hitspr; - } - - if (p >= 0 && ( - sprite[hitspr].picnum == DIPSWITCH || - sprite[hitspr].picnum == DIPSWITCH+1 || - sprite[hitspr].picnum == DIPSWITCH2 || - sprite[hitspr].picnum == DIPSWITCH2+1 || - sprite[hitspr].picnum == DIPSWITCH3 || - sprite[hitspr].picnum == DIPSWITCH3+1 || - sprite[hitspr].picnum == HANDSWITCH || - sprite[hitspr].picnum == HANDSWITCH+1)) - { - P_ActivateSwitch(p,hitspr,1); - return -1; - } - } - else if (hitwall >= 0) - { - l = A_Spawn(k,SMALLSMOKE); - ActorExtra[l].temp_data[6] = hitwall; - ActorExtra[l].temp_data[7] = hitsect; - ActorExtra[l].temp_data[8] = hitspr; - - if (CheckDoorTile(wall[hitwall].picnum) == 1) - goto SKIPBULLETHOLE; - if (p >= 0 && ( - wall[hitwall].picnum == DIPSWITCH || - wall[hitwall].picnum == DIPSWITCH+1 || - wall[hitwall].picnum == DIPSWITCH2 || - wall[hitwall].picnum == DIPSWITCH2+1 || - wall[hitwall].picnum == DIPSWITCH3 || - wall[hitwall].picnum == DIPSWITCH3+1 || - wall[hitwall].picnum == HANDSWITCH || - wall[hitwall].picnum == HANDSWITCH+1)) - { - P_ActivateSwitch(p,hitwall,0); - return -1; - } - - if (wall[hitwall].hitag != 0 || (wall[hitwall].nextwall >= 0 && wall[wall[hitwall].nextwall].hitag != 0)) - goto SKIPBULLETHOLE; - - if (hitsect >= 0 && sector[hitsect].lotag == 0) - if (wall[hitwall].overpicnum != BIGFORCE) - if ((wall[hitwall].nextsector >= 0 && sector[wall[hitwall].nextsector].lotag == 0) || - (wall[hitwall].nextsector == -1 && sector[hitsect].lotag == 0)) - if ((wall[hitwall].cstat&16) == 0) - { - if (wall[hitwall].nextsector >= 0) - { - l = headspritesect[wall[hitwall].nextsector]; - while (l >= 0) - { - if (sprite[l].statnum == 3 && sprite[l].lotag == 13) - goto SKIPBULLETHOLE; - l = nextspritesect[l]; - } - } - - l = headspritestat[STAT_MISC]; - while (l >= 0) - { - if (sprite[l].picnum == BULLETHOLE) - if (dist(&sprite[l],&sprite[k]) < (12+(krand()&7))) - goto SKIPBULLETHOLE; - l = nextspritestat[l]; - } - l = A_Spawn(k,BULLETHOLE); - sprite[l].xvel = -1; - sprite[l].x = hitvect.x; - sprite[l].y = hitvect.y; - sprite[l].z = hitvect.z; - - sprite[l].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x, - wall[hitwall].y-wall[wall[hitwall].point2].y)+512; - - sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); - sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); - A_SetSprite(l,CLIPMASK0); - } - -SKIPBULLETHOLE: - - if (wall[hitwall].cstat&2) - if (wall[hitwall].nextsector >= 0) - if (hitvect.z >= (sector[wall[hitwall].nextsector].floorz)) - hitwall = wall[hitwall].nextwall; - - A_DamageWall(k,hitwall,&hitvect,SHOTSPARK1); - } - } - else - { - k = A_InsertSprite(hitsect,hitvect.x,hitvect.y,hitvect.z,SHOTSPARK1,-15,24,24,sa,0,0,i,4); - sprite[k].extra = *actorscrptr[atwith]; - sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 - ActorExtra[k].temp_data[6] = hitwall; - ActorExtra[k].temp_data[7] = hitsect; - ActorExtra[k].temp_data[8] = hitspr; - - if (hitspr >= 0) - { - A_DamageObject(hitspr,k); - if (sprite[hitspr].picnum != APLAYER) - { - l = A_Spawn(k,SMALLSMOKE); - ActorExtra[l].temp_data[6] = hitwall; - ActorExtra[l].temp_data[7] = hitsect; - ActorExtra[l].temp_data[8] = hitspr; - } - else sprite[k].xrepeat = sprite[k].yrepeat = 0; - } - else if (hitwall >= 0) - A_DamageWall(k,hitwall,&hitvect,SHOTSPARK1); - } - - if ((krand()&255) < 4) - S_PlaySoundXYZ(PISTOL_RICOCHET,k, &hitvect); - - return -1; - - case FIRELASER__STATIC: - case SPIT__STATIC: - case COOLEXPLOSION1__STATIC: - - if (s->extra >= 0) s->shade = -96; - - scount = 1; - if (atwith == SPIT) vel = 292; - else - { - if (atwith == COOLEXPLOSION1) - { - if (s->picnum == BOSS2) vel = 644; - else vel = 348; - srcvect.z -= (4<<7); - } - else - { - vel = 840; - srcvect.z -= (4<<7); - } - } - - if (p >= 0) - { - // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)-(12<<8); - hitvect.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitvect.x == 0) hitvect.x++; - zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitvect.x; - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - else - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*98; - } - else - { - j = A_FindPlayer(s,&x); - // sa = getangle(g_player[j].ps->oposx-sx,g_player[j].ps->oposy-sy); - sa += 16-(krand()&31); - hitvect.x = ldist(&sprite[g_player[j].ps->i],s); - if (hitvect.x == 0) hitvect.x++; - zvel = ((g_player[j].ps->oposz - srcvect.z + (3<<8))*vel) / hitvect.x; - } - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - oldzvel = zvel; - - if (atwith == SPIT) - { - sizx = 18; - sizy = 18,srcvect.z -= (10<<8); - } - else - { - if (atwith == FIRELASER) - { - if (p >= 0) - { - - sizx = 34; - sizy = 34; - } - else - { - sizx = 18; - sizy = 18; - } - } - else - { - sizx = 18; - sizy = 18; - } - } - - if (p >= 0) sizx = 7,sizy = 7; - - while (scount > 0) - { - j = A_InsertSprite(sect,srcvect.x,srcvect.y,srcvect.z, - atwith,-127,sizx,sizy,sa,vel,zvel,i,4); - sprite[j].extra += (krand()&7); - - if (atwith == COOLEXPLOSION1) - { - sprite[j].shade = 0; - if (PN == BOSS2) - { - l = sprite[j].xvel; - sprite[j].xvel = 1024; - A_SetSprite(j,CLIPMASK0); - sprite[j].xvel = l; - sprite[j].ang += 128-(krand()&255); - } - } - - sprite[j].cstat = 128; - sprite[j].clipdist = 4; - - sa = s->ang+32-(krand()&63); - zvel = oldzvel+512-(krand()&1023); - - scount--; - } - - return j; - - case FREEZEBLAST__STATIC: - srcvect.z += (3<<8); - case RPG__STATIC: - - if (s->extra >= 0) s->shade = -96; - - scount = 1; - vel = 644; - - j = -1; - - if (p >= 0) - { - // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); - hitvect.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitvect.x == 0) hitvect.x++; - zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitvect.x; - if (sprite[j].picnum != RECON) - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*81; - if (atwith == RPG) - A_PlaySound(RPG_SHOOT,i); - } - else - { - j = A_FindPlayer(s,&x); - sa = getangle(g_player[j].ps->oposx-srcvect.x,g_player[j].ps->oposy-srcvect.y); - if (PN == BOSS3) - srcvect.z -= (32<<8); - else if (PN == BOSS2) - { - vel += 128; - srcvect.z += 24<<8; - } - - l = ldist(&sprite[g_player[j].ps->i],s); - if (l == 0) - l++; - zvel = ((g_player[j].ps->oposz-srcvect.z)*vel) / l; - - if (A_CheckEnemySprite(s) && (s->hitag&face_player_smart)) - sa = s->ang+(krand()&31)-16; - } - - if (p >= 0 && j >= 0) - l = j; - else l = -1; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - j = A_InsertSprite(sect, - srcvect.x+(sintable[(348+sa+512)&2047]/448), - srcvect.y+(sintable[(sa+348)&2047]/448), - srcvect.z-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); - - sprite[j].extra += (krand()&7); - if (atwith != FREEZEBLAST) - sprite[j].yvel = l; - else - { - sprite[j].yvel = g_numFreezeBounces; - sprite[j].xrepeat >>= 1; - sprite[j].yrepeat >>= 1; - sprite[j].zvel -= (2<<4); - } - - if (p == -1) - { - if (PN == BOSS3) - { - if (krand()&1) - { - sprite[j].x -= sintable[sa&2047]>>6; - sprite[j].y -= sintable[(sa+1024+512)&2047]>>6; - sprite[j].ang -= 8; - } - else - { - sprite[j].x += sintable[sa&2047]>>6; - sprite[j].y += sintable[(sa+1024+512)&2047]>>6; - sprite[j].ang += 4; - } - sprite[j].xrepeat = 42; - sprite[j].yrepeat = 42; - } - else if (PN == BOSS2) - { - sprite[j].x -= sintable[sa&2047]/56; - sprite[j].y -= sintable[(sa+1024+512)&2047]/56; - sprite[j].ang -= 8+(krand()&255)-128; - sprite[j].xrepeat = 24; - sprite[j].yrepeat = 24; - } - else if (atwith != FREEZEBLAST) - { - sprite[j].xrepeat = 30; - sprite[j].yrepeat = 30; - sprite[j].extra >>= 2; - } - } - - else if (*aplWeaponWorksLike[g_player[p].ps->curr_weapon] == DEVISTATOR_WEAPON) - { - sprite[j].extra >>= 2; - sprite[j].ang += 16-(krand()&31); - sprite[j].zvel += 256-(krand()&511); - - if (g_player[p].ps->hbomb_hold_delay) - { - sprite[j].x -= sintable[sa&2047]/644; - sprite[j].y -= sintable[(sa+1024+512)&2047]/644; - } - else - { - sprite[j].x += sintable[sa&2047]>>8; - sprite[j].y += sintable[(sa+1024+512)&2047]>>8; - } - sprite[j].xrepeat >>= 1; - sprite[j].yrepeat >>= 1; - } - - sprite[j].cstat = 128; - if (atwith == RPG) - sprite[j].clipdist = 4; - else - sprite[j].clipdist = 40; - - return j; - - case HANDHOLDINGLASER__STATIC: - - if (p >= 0) - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*32; - else zvel = 0; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan(srcvect.x,srcvect.y,srcvect.z-g_player[p].ps->pyoff,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitsect,&hitwall,&hitspr,&hitvect.x,&hitvect.y,&hitvect.z,CLIPMASK1); - - j = 0; - if (hitspr >= 0) break; - - if (hitwall >= 0 && hitsect >= 0) - if (((hitvect.x-srcvect.x)*(hitvect.x-srcvect.x)+(hitvect.y-srcvect.y)*(hitvect.y-srcvect.y)) < (290*290)) - { - if (wall[hitwall].nextsector >= 0) - { - if (sector[wall[hitwall].nextsector].lotag <= 2 && sector[hitsect].lotag <= 2) - j = 1; - } - else if (sector[hitsect].lotag <= 2) - j = 1; - } - - if (j == 1) - { - int32_t lTripBombControl=Gv_GetVarByLabel("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, g_player[p].ps->i, p); - k = A_InsertSprite(hitsect,hitvect.x,hitvect.y,hitvect.z,TRIPBOMB,-16,4,5,sa,0,0,i,6); - if (lTripBombControl & TRIPBOMB_TIMER) - { - int32_t lLifetime=Gv_GetVarByLabel("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, g_player[p].ps->i, p); - int32_t lLifetimeVar=Gv_GetVarByLabel("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, g_player[p].ps->i, p); - // set timer. blows up when at zero.... - ActorExtra[k].temp_data[7]=lLifetime - + mulscale(krand(),lLifetimeVar, 14) - - lLifetimeVar; - ActorExtra[k].temp_data[6]=1; - } - else - - sprite[k].hitag = k; - A_PlaySound(LASERTRIP_ONWALL,k); - sprite[k].xvel = -20; - A_SetSprite(k,CLIPMASK0); - sprite[k].cstat = 16; - ActorExtra[k].temp_data[5] = sprite[k].ang = getangle(wall[hitwall].x-wall[wall[hitwall].point2].x,wall[hitwall].y-wall[wall[hitwall].point2].y)-512; - - - } - return j?k:-1; - - case BOUNCEMINE__STATIC: - case MORTER__STATIC: - - if (s->extra >= 0) s->shade = -96; - - j = g_player[A_FindPlayer(s,&x)].ps->i; - x = ldist(&sprite[j],s); - - zvel = -x>>1; - - if (zvel < -4096) - zvel = -2048; - vel = x>>4; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - A_InsertSprite(sect, - srcvect.x+(sintable[(512+sa+512)&2047]>>8), - srcvect.y+(sintable[(sa+512)&2047]>>8), - srcvect.z+(6<<8),atwith,-64,32,32,sa,vel,zvel,i,1); - break; - - case GROWSPARK__STATIC: - - if (p >= 0) - { - // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); - if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN)) - { - dal -= (8<<8); - - } - hitvect.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitvect.x == 0) - hitvect.x++; - zvel = ((sprite[j].z-srcvect.z-dal)<<8) / hitvect.x; - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - else - { - sa += 16-(krand()&31); - zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; - zvel += 128-(krand()&255); - } - - srcvect.z -= (2<<8); - } - else - { - j = A_FindPlayer(s,&x); - srcvect.z -= (4<<8); - hitvect.x = ldist(&sprite[g_player[j].ps->i], s); - if (hitvect.x == 0) - hitvect.x++; - zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitvect.x; - zvel += 128-(krand()&255); - sa += 32-(krand()&63); - } - - k = 0; - - // RESHOOTGROW: - if (sect < 0) break; - - s->cstat &= ~257; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - hitscan(srcvect.x,srcvect.y,srcvect.z,sect, - sintable[(sa+512)&2047], - sintable[sa&2047], - zvel<<6,&hitsect,&hitwall,&hitspr,&hitvect.x,&hitvect.y,&hitvect.z,CLIPMASK1); - - s->cstat |= 257; - - j = A_InsertSprite(sect,hitvect.x,hitvect.y,hitvect.z,GROWSPARK,-16,28,28,sa,0,0,i,1); - - sprite[j].pal = 2; - sprite[j].cstat |= 130; - sprite[j].xrepeat = sprite[j].yrepeat = 1; - - if (hitwall == -1 && hitspr == -1 && hitsect >= 0) - { - if (zvel < 0 && (sector[hitsect].ceilingstat&1) == 0) - Sect_DamageCeiling(hitsect); - } - else if (hitspr >= 0) A_DamageObject(hitspr,j); - else if (hitwall >= 0 && wall[hitwall].picnum != ACCESSSWITCH && wall[hitwall].picnum != ACCESSSWITCH2) - { - /* if(wall[hitwall].overpicnum == MIRROR && k == 0) - { - l = getangle( - wall[wall[hitwall].point2].x-wall[hitwall].x, - wall[wall[hitwall].point2].y-wall[hitwall].y); - - sx = hitvect.x; - sy = hitvect.y; - srcvect.z = hitvect.z; - sect = hitsect; - sa = ((l<<1) - sa)&2047; - sx += sintable[(sa+512)&2047]>>12; - sy += sintable[sa&2047]>>12; - - k++; - goto RESHOOTGROW; - } - else */ - A_DamageWall(j,hitwall,&hitvect,atwith); - } - - break; - - case SHRINKER__STATIC: - if (s->extra >= 0) s->shade = -96; - if (p >= 0) - { - // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); - Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); - X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); - j=-1; - if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) - { - j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); - } - - if (j >= 0) - { - dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1); - hitvect.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); - if (hitvect.x == 0) - hitvect.x++; - zvel = ((sprite[j].z-srcvect.z-dal-(4<<8))*768) / hitvect.x; - sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); - } - else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*98; - } - else if (s->statnum != 3) - { - j = A_FindPlayer(s,&x); - l = ldist(&sprite[g_player[j].ps->i],s); - if (l == 0) - l++; - zvel = ((g_player[j].ps->oposz-srcvect.z)*512) / l ; - } - else zvel = 0; - if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; - j = A_InsertSprite(sect, - srcvect.x+(sintable[(512+sa+512)&2047]>>12), - srcvect.y+(sintable[(sa+512)&2047]>>12), - srcvect.z+(2<<8),SHRINKSPARK,-16,28,28,sa,768,zvel,i,4); - - sprite[j].cstat = 128; - sprite[j].clipdist = 32; - - - return j; - } - } - return -1; -} - -static void P_DisplaySpitAnim(int32_t snum) -{ - int32_t i, a, x, y, z; - - if (g_player[snum].ps->loogcnt == 0) return; - - y = (g_player[snum].ps->loogcnt<<2); - for (i=0;inumloogs;i++) - { - a = klabs(sintable[((g_player[snum].ps->loogcnt+i)<<5)&2047])>>5; - z = 4096+((g_player[snum].ps->loogcnt+i)<<9); - x = (-g_player[snum].sync->avel)+(sintable[((g_player[snum].ps->loogcnt+i)<<6)&2047]>>10); - - rotatesprite( - (g_player[snum].ps->loogiex[i]+x)<<16,(200+g_player[snum].ps->loogiey[i]-y)<<16,z-(i<<8),256-a, - LOOGIE,0,0,2,0,0,xdim-1,ydim-1); - } -} - -static int32_t P_DisplayFistAnim(int32_t gs,int32_t snum) -{ - int32_t looking_arc,fisti,fistpal; - int32_t fistzoom, fistz; - - fisti = g_player[snum].ps->fist_incs; - if (fisti > 32) fisti = 32; - if (fisti <= 0) return 0; - - looking_arc = klabs(g_player[snum].ps->look_ang)/9; - - fistzoom = 65536L - (sintable[(512+(fisti<<6))&2047]<<2); - if (fistzoom > 90612L) - fistzoom = 90612L; - if (fistzoom < 40920) - fistzoom = 40290; - fistz = 194 + (sintable[((6+fisti)<<7)&2047]>>9); - - if (sprite[g_player[snum].ps->i].pal == 1) - fistpal = 1; - else if (g_player[snum].ps->cursectnum >= 0) - fistpal = sector[g_player[snum].ps->cursectnum].floorpal; - else fistpal = 0; - - rotatesprite( - (-fisti+222+(g_player[snum].sync->avel>>4))<<16, - (looking_arc+fistz)<<16, - fistzoom,0,FIST,gs,fistpal,2,0,0,xdim-1,ydim-1); - - return 1; -} - -#define weapsc(sc) scale(sc,ud.weaponscale,100) - -static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p) -{ - int32_t a = 0; - int32_t xoff = 192; - - switch (g_currentweapon) - { - case DEVISTATOR_WEAPON: - case TRIPBOMB_WEAPON: - xoff = 160; - break; - default: - if (orientation & 262144) - { - xoff = 160; - orientation &= ~262144; - } - break; - } - - if (orientation&4) - a = 1024; - -#if defined(POLYMOST) && defined(USE_OPENGL) - if (getrendermode() >= 3 && usemodels && md_tilehasmodel(tilenum,p) > 0) - y += (224-weapsc(224)); -#endif - rotatesprite(weapsc((orientation&256)?x:(x<<16))+((xoff-weapsc(xoff))<<16), - weapsc((orientation&256)?y:(y<<16))+((200-weapsc(200))<<16), - weapsc(65536L),a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); -} - -static void G_DrawWeaponTile(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p) -{ - if (!ud.drawweapon) - return; - else if (ud.drawweapon == 1) - G_DrawTileScaled(x,y,tilenum,shade,orientation,p); - else if (ud.drawweapon == 2) - { - switch (g_currentweapon) - { - case PISTOL_WEAPON: - case CHAINGUN_WEAPON: - case RPG_WEAPON: - case FREEZE_WEAPON: - case SHRINKER_WEAPON: - case GROW_WEAPON: - case DEVISTATOR_WEAPON: - case TRIPBOMB_WEAPON: - case HANDREMOTE_WEAPON: - case HANDBOMB_WEAPON: - case SHOTGUN_WEAPON: - rotatesprite(160<<16,(180+(g_player[screenpeek].ps->weapon_pos*g_player[screenpeek].ps->weapon_pos))<<16,scale(65536,ud.statusbarscale,100),0,g_currentweapon==GROW_WEAPON?GROWSPRITEICON:WeaponPickupSprites[g_currentweapon],0,0,2,windowx1,windowy1,windowx2,windowy2); - break; - } - } -} - -static int32_t P_DisplayKneeAnim(int32_t gs,int32_t snum) -{ - static int8_t knee_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-72,-32,-8}; - int32_t looking_arc, pal = g_player[snum].ps->palookup; - - if (g_player[snum].ps->knee_incs > 11 || g_player[snum].ps->knee_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; - - looking_arc = knee_y[g_player[snum].ps->knee_incs] + klabs(g_player[snum].ps->look_ang)/9; - - looking_arc -= (g_player[snum].ps->hard_landing<<3); - - if (sprite[g_player[snum].ps->i].pal == 1) - pal = 1; - else if (g_player[snum].ps->cursectnum >= 0) - { - pal = sector[g_player[snum].ps->cursectnum].floorpal; - if (pal == 0) - pal = g_player[snum].ps->palookup; - } - - G_DrawTileScaled(105+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(knee_y[g_player[snum].ps->knee_incs]>>2),looking_arc+280-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),KNEE,gs,4+262144,pal); - - return 1; -} - -static int32_t P_DisplayKnuckleAnim(int32_t gs,int32_t snum) -{ - static char knuckle_frames[] = {0,1,2,2,3,3,3,2,2,1,0}; - int32_t looking_arc, pal = 0; - - if (g_player[snum].ps->knuckle_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; - - looking_arc = klabs(g_player[snum].ps->look_ang)/9; - - looking_arc -= (g_player[snum].ps->hard_landing<<3); - - if (sprite[g_player[snum].ps->i].pal == 1) - pal = 1; - else if (g_player[snum].ps->cursectnum >= 0) - pal = sector[g_player[snum].ps->cursectnum].floorpal; - - G_DrawTileScaled(160+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1),looking_arc+180-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),CRACKKNUCKLES+knuckle_frames[g_player[snum].ps->knuckle_incs>>1],gs,4+262144,pal); - - return 1; -} - -int32_t lastvisinc; - -void P_FireWeapon(DukePlayer_t *p) -{ - int32_t i, snum = sprite[p->i].yvel; - - Gv_SetVar(g_iReturnVarID,0,p->i,snum); - X_OnEvent(EVENT_DOFIRE, p->i, snum, -1); - - if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) - { - if (p->weapon_pos != 0) return; - - if (aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON) - p->ammo_amount[p->curr_weapon]--; - - if (aplWeaponFireSound[p->curr_weapon][snum]) - { - A_PlaySound(aplWeaponFireSound[p->curr_weapon][snum],p->i); - } - - Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); - Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); -// OSD_Printf("doing %d %d %d\n",aplWeaponShoots[p->curr_weapon][snum],p->curr_weapon,snum); - A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); - for (i=1;icurr_weapon][snum];i++) - { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYOTHER) - { - // this makes the projectiles fire on a delay from player code - ActorExtra[p->i].temp_data[7] = (aplWeaponShotsPerBurst[p->curr_weapon][snum])<<1; - } - else - { - if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AMMOPERSHOT) - { - if (p->ammo_amount[p->curr_weapon] > 0) - p->ammo_amount[p->curr_weapon]--; - else break; - } - A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); - } - } - - if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_NOVISIBLE)) - { - lastvisinc = totalclock+32; - p->visibility = 0; - } - - /* if( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_CHECKATRELOAD) && - aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum] - && p->ammo_amount[p->curr_weapon] > 0 - && (aplWeaponClip[p->curr_weapon][snum]) - && ((p->ammo_amount[p->curr_weapon]%(aplWeaponClip[p->curr_weapon][snum]))==0)) - { - p->kickback_pic=aplWeaponTotalTime[p->curr_weapon][snum]; - } */ - } -} - -void P_DoWeaponSpawn(DukePlayer_t *p) -{ - int32_t j, snum = sprite[p->i].yvel; - - if (!aplWeaponSpawn[p->curr_weapon][snum]) - return; - - j = A_Spawn(p->i, aplWeaponSpawn[p->curr_weapon][snum]); - - if ((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_SPAWNTYPE3)) - { - // like chaingun shells - sprite[j].ang += 1024; - sprite[j].ang &= 2047; - sprite[j].xvel += 32; - sprite[j].z += (3<<8); - } - - A_SetSprite(j,CLIPMASK0); - -} - -void P_DisplayScubaMask(int32_t snum) -{ - int32_t p; - - if (sprite[g_player[snum].ps->i].pal == 1) - p = 1; - else if (g_player[snum].ps->cursectnum >= 0) - p = sector[g_player[snum].ps->cursectnum].floorpal; - else p = 0; - - if (g_player[snum].ps->scuba_on) - { - rotatesprite(43<<16,(200-tilesizy[SCUBAMASK])<<16,65536,0,SCUBAMASK,0,p,2+16,windowx1,windowy1,windowx2,windowy2); - rotatesprite((320-43)<<16,(200-tilesizy[SCUBAMASK])<<16,65536,1024,SCUBAMASK,0,p,2+4+16,windowx1,windowy1,windowx2,windowy2); - } -} - -static int32_t P_DisplayTipAnim(int32_t gs,int32_t snum) -{ - int32_t p,looking_arc; - static int16_t tip_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; - - if (g_player[snum].ps->tipincs == 0) return 0; - - looking_arc = klabs(g_player[snum].ps->look_ang)/9; - looking_arc -= (g_player[snum].ps->hard_landing<<3); - - if (sprite[g_player[snum].ps->i].pal == 1) - p = 1; - else - p = sector[g_player[snum].ps->cursectnum].floorpal; - - /* if(g_player[snum].ps->access_spritenum >= 0) - p = sprite[g_player[snum].ps->access_spritenum].pal; - else - p = wall[g_player[snum].ps->access_wallnum].pal; - */ - G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1), - (tip_y[g_player[snum].ps->tipincs]>>1)+looking_arc+240-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),TIP+((26-g_player[snum].ps->tipincs)>>4),gs,262144,p); - - return 1; -} - -static int32_t P_DisplayAccessAnim(int32_t gs,int32_t snum) -{ - static int16_t access_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; - int32_t looking_arc; - int32_t p; - - if (g_player[snum].ps->access_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; - - looking_arc = access_y[g_player[snum].ps->access_incs] + klabs(g_player[snum].ps->look_ang)/9; - looking_arc -= (g_player[snum].ps->hard_landing<<3); - - if (g_player[snum].ps->access_spritenum >= 0) - p = sprite[g_player[snum].ps->access_spritenum].pal; - else p = 0; - // else - // p = wall[g_player[snum].ps->access_wallnum].pal; - - if ((g_player[snum].ps->access_incs-3) > 0 && (g_player[snum].ps->access_incs-3)>>3) - G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(access_y[g_player[snum].ps->access_incs]>>2),looking_arc+266-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),HANDHOLDINGLASER+(g_player[snum].ps->access_incs>>3),gs,262144,p); - else - G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(access_y[g_player[snum].ps->access_incs]>>2),looking_arc+266-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),HANDHOLDINGACCESS,gs,4+262144,p); - - return 1; -} - - -static int32_t fistsign; - -void P_DisplayWeapon(int32_t snum) -{ - int32_t gun_pos, looking_arc, cw; - int32_t weapon_xoffset, i, j; - int32_t o = 0,pal = 0; - DukePlayer_t *p = g_player[snum].ps; - int16_t *kb = &p->kickback_pic; - int32_t gs; - - looking_arc = klabs(p->look_ang)/9; - - gs = sprite[p->i].shade; - if (gs > 24) gs = 24; - - if (p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (sprite[p->i].pal != 1 && sprite[p->i].extra <= 0) || P_DisplayFistAnim(gs,snum) || P_DisplayKnuckleAnim(gs,snum) || P_DisplayTipAnim(gs,snum) || P_DisplayAccessAnim(gs,snum)) - return; - - P_DisplayKneeAnim(gs,snum); - - gun_pos = 80-(p->weapon_pos*p->weapon_pos); - - weapon_xoffset = (160)-90; - - if (ud.weaponsway) - { - weapon_xoffset -= (sintable[((p->weapon_sway>>1)+512)&2047]/(1024+512)); - - if (sprite[p->i].xrepeat < 32) - gun_pos -= klabs(sintable[(p->weapon_sway<<2)&2047]>>9); - else gun_pos -= klabs(sintable[(p->weapon_sway>>1)&2047]>>10); - } - else gun_pos -= 16; - - weapon_xoffset -= 58 + p->weapon_ang; - gun_pos -= (p->hard_landing<<3); - - if (p->last_weapon >= 0) - cw = aplWeaponWorksLike[p->last_weapon][snum]; - else - cw = aplWeaponWorksLike[p->curr_weapon][snum]; - - g_gun_pos=gun_pos; - g_looking_arc=looking_arc; - g_currentweapon=cw; - g_weapon_xoffset=weapon_xoffset; - g_gs=gs; - g_kb=*kb; - g_looking_angSR1=p->look_ang>>1; - - Gv_SetVar(g_iReturnVarID,0,p->i,snum); - X_OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek, -1); - - if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) - { - j = 14-p->quick_kick; - if (j != 14 || p->last_quick_kick) - { - if (sprite[p->i].pal == 1) - pal = 1; - else - { - if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - if (pal == 0) - pal = p->palookup; - } - - guniqhudid = 100; - if (j < 6 || j > 12) - G_DrawTileScaled(weapon_xoffset+80-(p->look_ang>>1), - looking_arc+250-gun_pos,KNEE,gs,o|4|262144,pal); - else G_DrawTileScaled(weapon_xoffset+160-16-(p->look_ang>>1), - looking_arc+214-gun_pos,KNEE+1,gs,o|4|262144,pal); - guniqhudid = 0; - } - - if (sprite[p->i].xrepeat < 40) - { - if (p->jetpack_on == 0) - { - i = sprite[p->i].xvel; - looking_arc += 32-(i>>1); - fistsign += i>>1; - } - cw = weapon_xoffset; - weapon_xoffset += sintable[(fistsign)&2047]>>10; - G_DrawTile(weapon_xoffset+250-(p->look_ang>>1), - looking_arc+258-(klabs(sintable[(fistsign)&2047]>>8)), - FIST,gs,o); - weapon_xoffset = cw; - weapon_xoffset -= sintable[(fistsign)&2047]>>10; - G_DrawTile(weapon_xoffset+40-(p->look_ang>>1), - looking_arc+200+(klabs(sintable[(fistsign)&2047]>>8)), - FIST,gs,o|4); - } - else switch (cw) - - { - - case KNEE_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if ((*kb) > 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else - { - if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - if (pal == 0) - pal = p->palookup; - } - guniqhudid = cw; - if ((*kb) < 5 || (*kb) > 9) - G_DrawTileScaled(weapon_xoffset+220-(p->look_ang>>1), - looking_arc+250-gun_pos,KNEE,gs,o,pal); - else - G_DrawTileScaled(weapon_xoffset+160-(p->look_ang>>1), - looking_arc+214-gun_pos,KNEE+1,gs,o,pal); - guniqhudid = 0; - } - } - break; - - case TRIPBOMB_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - weapon_xoffset += 8; - gun_pos -= 10; - - if ((*kb) > 6) - looking_arc += ((*kb)<<3); - else if ((*kb) < 4) - { - guniqhudid = cw<<2; - G_DrawWeaponTile(weapon_xoffset+142-(p->look_ang>>1), - looking_arc+234-gun_pos,HANDHOLDINGLASER+3,gs,o,pal); - } - - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+130-(p->look_ang>>1), - looking_arc+249-gun_pos, - HANDHOLDINGLASER+((*kb)>>2),gs,o,pal); - - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+152-(p->look_ang>>1), - looking_arc+249-gun_pos, - HANDHOLDINGLASER+((*kb)>>2),gs,o|4,pal); - guniqhudid = 0; - } - break; - - case RPG_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - weapon_xoffset -= sintable[(768+((*kb)<<7))&2047]>>11; - gun_pos += sintable[(768+((*kb)<<7))&2047]>>11; - - if (*kb > 0) - { - if (*kb < 8) - { - G_DrawWeaponTile(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, - RPGGUN+((*kb)>>1),gs,o,pal); - } - } - - G_DrawWeaponTile(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, - RPGGUN,gs,o,pal); - } - break; - - case SHOTGUN_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - - weapon_xoffset -= 8; - - switch (*kb) - { - case 1: - case 2: - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+168-(p->look_ang>>1),looking_arc+201-gun_pos, - SHOTGUN+2,-128,o,pal); - case 0: - case 6: - case 7: - case 8: - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+146-(p->look_ang>>1),looking_arc+202-gun_pos, - SHOTGUN,gs,o,pal); - guniqhudid = 0; - break; - case 3: - case 4: - case 5: - case 9: - case 10: - case 11: - case 12: - if (*kb > 1 && *kb < 5) - { - gun_pos -= 40; - weapon_xoffset += 20; - - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+194-gun_pos, - SHOTGUN+1+((*(kb)-1)>>1),-128,o,pal); - } - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+158-(p->look_ang>>1),looking_arc+220-gun_pos, - SHOTGUN+3,gs,o,pal); - guniqhudid = 0; - break; - case 13: - case 14: - case 15: - guniqhudid = cw; - G_DrawWeaponTile(32+weapon_xoffset+166-(p->look_ang>>1),looking_arc+210-gun_pos, - SHOTGUN+4,gs,o,pal); - guniqhudid = 0; - break; - case 16: - case 17: - case 18: - case 19: - guniqhudid = cw; - G_DrawWeaponTile(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, - SHOTGUN+5,gs,o,pal); - guniqhudid = 0; - break; - case 20: - case 21: - case 22: - case 23: - guniqhudid = cw; - G_DrawWeaponTile(64+weapon_xoffset+176-(p->look_ang>>1),looking_arc+196-gun_pos, - SHOTGUN+6,gs,o,pal); - guniqhudid = 0; - break; - case 24: - case 25: - case 26: - case 27: - guniqhudid = cw; - G_DrawWeaponTile(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, - SHOTGUN+5,gs,o,pal); - guniqhudid = 0; - break; - case 28: - case 29: - case 30: - guniqhudid = cw; - G_DrawWeaponTile(32+weapon_xoffset+156-(p->look_ang>>1),looking_arc+206-gun_pos, - SHOTGUN+4,gs,o,pal); - guniqhudid = 0; - break; - } - } - break; - - - case CHAINGUN_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - if (*kb > 0) - gun_pos -= sintable[(*kb)<<7]>>12; - - if (*kb > 0 && sprite[p->i].pal != 1) weapon_xoffset += 1-(rand()&3); - - G_DrawWeaponTile(weapon_xoffset+168-(p->look_ang>>1),looking_arc+260-gun_pos, - CHAINGUN,gs,o,pal); - switch (*kb) - { - case 0: - G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, - CHAINGUN+1,gs,o,pal); - break; - default: - if (*kb > *aplWeaponFireDelay[CHAINGUN_WEAPON] && *kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]) - { - i = 0; - if (sprite[p->i].pal != 1) i = rand()&7; - G_DrawWeaponTile(i+weapon_xoffset-4+140-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, - CHAINGUN+5+((*kb-4)/5),gs,o,pal); - if (sprite[p->i].pal != 1) i = rand()&7; - G_DrawWeaponTile(i+weapon_xoffset-4+184-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, - CHAINGUN+5+((*kb-4)/5),gs,o,pal); - } - if (*kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]-4) - { - i = rand()&7; - G_DrawWeaponTile(i+weapon_xoffset-4+162-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, - CHAINGUN+5+((*kb-2)/5),gs,o,pal); - G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, - CHAINGUN+1+((*kb)>>1),gs,o,pal); - } - else G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, - CHAINGUN+1,gs,o,pal); - break; - } - } - break; - - case PISTOL_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) - { - static int16_t kb_frames[] = {0,1,2}; - int32_t l = 195-12+weapon_xoffset; - - if ((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) - l -= 3; - - guniqhudid = cw; - G_DrawWeaponTile((l-(p->look_ang>>1)),(looking_arc+244-gun_pos),FIRSTGUN+kb_frames[*kb>2?0:*kb],gs,2,pal); - guniqhudid = 0; - } - else - { - - if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-17) - { - guniqhudid = cw; - G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+230-gun_pos,FIRSTGUN+4,gs,o,pal); - guniqhudid = 0; - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-12) - { - G_DrawWeaponTile(244-((*kb)<<3)-(p->look_ang>>1),looking_arc+130-gun_pos+((*kb)<<4),FIRSTGUN+6,gs,o,pal); - guniqhudid = cw; - G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); - guniqhudid = 0; - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-7) - { - G_DrawWeaponTile(124+((*kb)<<1)-(p->look_ang>>1),looking_arc+430-gun_pos-((*kb)<<3),FIRSTGUN+6,gs,o,pal); - guniqhudid = cw; - G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); - guniqhudid = 0; - } - - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-4) - { - G_DrawWeaponTile(184-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+8,gs,o,pal); - guniqhudid = cw; - G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+210-gun_pos,FIRSTGUN+5,gs,o,pal); - guniqhudid = 0; - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-2) - { - G_DrawWeaponTile(164-(p->look_ang>>1),looking_arc+245-gun_pos,FIRSTGUN+8,gs,o,pal); - guniqhudid = cw; - G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); - guniqhudid = 0; - } - else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]) - { - guniqhudid = cw; - G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+5,gs,o,pal); - guniqhudid = 0; - } - - } - } - - break; - case HANDBOMB_WEAPON: - { - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - guniqhudid = cw; - if ((*kb)) - { - if ((*kb) < (*aplWeaponTotalTime[p->curr_weapon])) - { - - static char throw_frames[] - = {0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2}; - - if ((*kb) < 7) - gun_pos -= 10*(*kb); //D - else if ((*kb) < 12) - gun_pos += 20*((*kb)-10); //U - else if ((*kb) < 20) - gun_pos -= 9*((*kb)-14); //D - - G_DrawWeaponTile(weapon_xoffset+190-(p->look_ang>>1),looking_arc+250-gun_pos,HANDTHROW+throw_frames[(*kb)],gs,o,pal); - } - } - else - G_DrawWeaponTile(weapon_xoffset+190-(p->look_ang>>1),looking_arc+260-gun_pos,HANDTHROW,gs,o,pal); - guniqhudid = 0; - } - } - break; - - case HANDREMOTE_WEAPON: - { - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - static char remote_frames[] = {0,1,1,2,1,1,0,0,0,0,0}; - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - weapon_xoffset = -48; - guniqhudid = cw; - if ((*kb)) - G_DrawWeaponTile(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE+remote_frames[(*kb)],gs,o,pal); - else - G_DrawWeaponTile(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE,gs,o,pal); - guniqhudid = 0; - } - } - break; - - case DEVISTATOR_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - - if ((*kb) < (*aplWeaponTotalTime[DEVISTATOR_WEAPON]+1) && (*kb) > 0) - { - static char cycloidy[] = {0,4,12,24,12,4,0}; - - i = ksgn((*kb)>>2); - - if (p->hbomb_hold_delay) - { - guniqhudid = cw; - G_DrawWeaponTile((cycloidy[*kb]>>1)+weapon_xoffset+268-(p->look_ang>>1),cycloidy[*kb]+looking_arc+238-gun_pos,DEVISTATOR+i,-32,o,pal); - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); - guniqhudid = 0; - } - else - { - guniqhudid = cw<<1; - G_DrawWeaponTile(-(cycloidy[*kb]>>1)+weapon_xoffset+30-(p->look_ang>>1),cycloidy[*kb]+looking_arc+240-gun_pos,DEVISTATOR+i,-32,o|4,pal); - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); - guniqhudid = 0; - } - } - else - { - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); - guniqhudid = 0; - } - } - break; - - case FREEZE_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - if ((*kb) < (aplWeaponTotalTime[p->curr_weapon][snum]+1) && (*kb) > 0) - { - static char cat_frames[] = { 0,0,1,1,2,2 }; - - if (sprite[p->i].pal != 1) - { - weapon_xoffset += rand()&3; - looking_arc += rand()&3; - } - gun_pos -= 16; - guniqhudid = 0; - G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE+2,-32,o,pal); - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+235-gun_pos,FREEZE+3+cat_frames[*kb%6],-32,o,pal); - guniqhudid = 0; - } - else - { - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE,gs,o,pal); - guniqhudid = 0; - } - } - break; - - case GROW_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - weapon_xoffset += 28; - looking_arc += 18; - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - { - if ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum] && (*kb) > 0) - { - if (sprite[p->i].pal != 1) - { - weapon_xoffset += rand()&3; - gun_pos += (rand()&3); - } - - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, - o,2); - - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER-1,gs,o,pal); - guniqhudid = 0; - } - else - { - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+2, - 16-(sintable[p->random_club_frame&2047]>>10), - o,2); - - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER-2,gs,o,pal); - guniqhudid = 0; - } - } - } - break; - - case SHRINKER_WEAPON: - - Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); - X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); - if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) - { - weapon_xoffset += 28; - looking_arc += 18; - if (sprite[p->i].pal == 1) - pal = 1; - else if (p->cursectnum >= 0) - pal = sector[p->cursectnum].floorpal; - else pal = 0; - if (((*kb) > 0) && ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum])) - { - if (sprite[p->i].pal != 1) - { - weapon_xoffset += rand()&3; - gun_pos += (rand()&3); - } - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, - o,0); - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+1,gs,o,pal); - guniqhudid = 0; - - } - else - { - guniqhudid = cw<<1; - G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER+2, - 16-(sintable[p->random_club_frame&2047]>>10), - o,0); - guniqhudid = cw; - G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), - looking_arc+240-gun_pos,SHRINKER,gs,o,pal); - guniqhudid = 0; - } - } - break; - - } - } - P_DisplaySpitAnim(snum); - -} - -#define TURBOTURNTIME (TICRATE/8) // 7 -#define NORMALTURN 15 -#define PREAMBLETURN 5 -#define NORMALKEYMOVE 40 -#define MAXVEL ((NORMALKEYMOVE*2)+10) -#define MAXSVEL ((NORMALKEYMOVE*2)+10) -#define MAXANGVEL 127 -#define MAXHORIZ 127 - -int32_t g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0; -int32 mouseyaxismode = -1; -int32_t jump_input = 0; - -void getinput(int32_t snum) -{ - int32_t j, daang; - static ControlInfo info[2]; - int32 tics; - boolean running; - int32 turnamount; - int32 keymove; - int32 momx = 0,momy = 0; - DukePlayer_t *p = g_player[snum].ps; - - if ((p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause)) || (numplayers > 1 && totalclock < 10)) - // HACK: kill getinput() for the first 10 tics of a new map in multi - { - if (!(p->gm&MODE_MENU)) - CONTROL_GetInput(&info[0]); - memset(&info[1], 0, sizeof(info[1])); - loc.fvel = vel = 0; - loc.svel = svel = 0; - loc.avel = angvel = 0; - loc.horz = horiz = 0; - loc.bits = (((int32_t)g_gameQuit)<team)<<6; - loc.extbits |= (1<<7); - return; - } - - if (ud.mouseaiming) - g_myAimMode = BUTTON(gamefunc_Mouse_Aiming); - else - { - g_oldAimStat = g_myAimStat; - g_myAimStat = BUTTON(gamefunc_Mouse_Aiming); - if (g_myAimStat > g_oldAimStat) - { - g_myAimMode ^= 1; - P_DoQuote(44+g_myAimMode,p); - } - } - - { - int32 i; - if (g_myAimMode) i = analog_lookingupanddown; - else i = ud.config.MouseAnalogueAxes[1]; - - if (i != mouseyaxismode) - { - CONTROL_MapAnalogAxis(1, i, controldevice_mouse); - mouseyaxismode = i; - } - } - - CONTROL_GetInput(&info[0]); - - if (ud.config.MouseDeadZone) - { - if (info[0].dpitch > 0) - { - if (info[0].dpitch > ud.config.MouseDeadZone) - info[0].dpitch -= ud.config.MouseDeadZone; - else info[0].dpitch = 0; - } - else if (info[0].dpitch < 0) - { - if (info[0].dpitch < -ud.config.MouseDeadZone) - info[0].dpitch += ud.config.MouseDeadZone; - else info[0].dpitch = 0; - } - if (info[0].dyaw > 0) - { - if (info[0].dyaw > ud.config.MouseDeadZone) - info[0].dyaw -= ud.config.MouseDeadZone; - else info[0].dyaw = 0; - } - else if (info[0].dyaw < 0) - { - if (info[0].dyaw < -ud.config.MouseDeadZone) - info[0].dyaw += ud.config.MouseDeadZone; - else info[0].dyaw = 0; - } - } - - if (ud.config.MouseBias) - { - if (klabs(info[0].dyaw) > klabs(info[0].dpitch)) - info[0].dpitch /= ud.config.MouseBias; - else info[0].dyaw /= ud.config.MouseBias; - } - - tics = totalclock-lastcontroltime; - lastcontroltime = totalclock; - - if (multiflag == 1) - { - loc.bits = 1<on_ground) - jump_input = 4; - - loc.bits = (jump_input > 0 || BUTTON(gamefunc_Jump))<curr_weapon][snum] & WEAPON_SEMIAUTO && BUTTON(gamefunc_Fire)) - CONTROL_ClearButton(gamefunc_Fire); - - if (jump_input > 0) - jump_input--; - - j=0; - - if (BUTTON(gamefunc_Weapon_1)) - j = 1; - if (BUTTON(gamefunc_Weapon_2)) - j = 2; - if (BUTTON(gamefunc_Weapon_3)) - j = 3; - if (BUTTON(gamefunc_Weapon_4)) - j = 4; - if (BUTTON(gamefunc_Weapon_5)) - j = 5; - if (BUTTON(gamefunc_Weapon_6)) - j = 6; - if (BUTTON(gamefunc_Weapon_7)) - j = 7; - if (BUTTON(gamefunc_Weapon_8)) - j = 8; - if (BUTTON(gamefunc_Weapon_9)) - j = 9; - if (BUTTON(gamefunc_Weapon_10)) - j = 10; - if (BUTTON(gamefunc_Previous_Weapon)) - j = 11; - if (BUTTON(gamefunc_Next_Weapon)) - j = 12; - - loc.bits |= j<>6; - - if (running) - { - turnamount = NORMALTURN<<1; - keymove = NORMALKEYMOVE<<1; - } - else - { - turnamount = NORMALTURN; - keymove = NORMALKEYMOVE; - } - - if (BUTTON(gamefunc_Strafe)) - { - if (BUTTON(gamefunc_Turn_Left) && !(g_player[snum].ps->movement_lock&4)) - svel -= -keymove; - if (BUTTON(gamefunc_Turn_Right) && !(g_player[snum].ps->movement_lock&8)) - svel -= keymove; - } - else - { - if (BUTTON(gamefunc_Turn_Left)) - { - turnheldtime += tics; - if (turnheldtime>=TURBOTURNTIME) - angvel -= turnamount; - else - angvel -= PREAMBLETURN; - } - else if (BUTTON(gamefunc_Turn_Right)) - { - turnheldtime += tics; - if (turnheldtime>=TURBOTURNTIME) - angvel += turnamount; - else - angvel += PREAMBLETURN; - } - else - turnheldtime=0; - } - - if (BUTTON(gamefunc_Strafe_Left) && !(g_player[snum].ps->movement_lock&4)) - svel += keymove; - if (BUTTON(gamefunc_Strafe_Right) && !(g_player[snum].ps->movement_lock&8)) - svel += -keymove; - if (BUTTON(gamefunc_Move_Forward) && !(g_player[snum].ps->movement_lock&1)) - vel += keymove; - if (BUTTON(gamefunc_Move_Backward) && !(g_player[snum].ps->movement_lock&2)) - vel += -keymove; - - if (vel < -MAXVEL) vel = -MAXVEL; - if (vel > MAXVEL) vel = MAXVEL; - if (svel < -MAXSVEL) svel = -MAXSVEL; - if (svel > MAXSVEL) svel = MAXSVEL; - if (angvel < -MAXANGVEL) angvel = -MAXANGVEL; - if (angvel > MAXANGVEL) angvel = MAXANGVEL; - if (horiz < -MAXHORIZ) horiz = -MAXHORIZ; - if (horiz > MAXHORIZ) horiz = MAXHORIZ; - - loc.extbits = 0; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEFORWARD]) - loc.extbits |= BUTTON(gamefunc_Move_Forward) || (vel > 0); - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEBACKWARD]) - loc.extbits |= (BUTTON(gamefunc_Move_Backward) || (vel < 0))<<1; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFELEFT]) - loc.extbits |= (BUTTON(gamefunc_Strafe_Left) || (svel > 0))<<2; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFERIGHT]) - loc.extbits |= (BUTTON(gamefunc_Strafe_Right) || (svel < 0))<<3; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNLEFT]) - loc.extbits |= BUTTON(gamefunc_Turn_Left)<<4; - if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNRIGHT]) - loc.extbits |= BUTTON(gamefunc_Turn_Right)<<5; - // used for changing team - loc.extbits |= (g_player[snum].pteam != g_player[snum].ps->team)<<6; - - if (ud.scrollmode && ud.overhead_on) - { - ud.folfvel = vel; - ud.folavel = angvel; - loc.fvel = 0; - loc.svel = 0; - loc.avel = 0; - loc.horz = 0; - return; - } - - if (numplayers > 1) - daang = myang; - else daang = p->ang; - - momx = mulscale9(vel,sintable[(daang+2560)&2047]); - momy = mulscale9(vel,sintable[(daang+2048)&2047]); - - momx += mulscale9(svel,sintable[(daang+2048)&2047]); - momy += mulscale9(svel,sintable[(daang+1536)&2047]); - - momx += fricxv; - momy += fricyv; + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + zvel += (zRange/2)-(krand()&(zRange-1)); + } + } + else + { + sa += (angRange/2)-(krand()&(angRange-1)); + if (j == -1) + { + // no target + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + } + zvel += (zRange/2)-(krand()&(zRange-1)); + } + srcvect.z -= (2<<8); + } + else + { + j = A_FindPlayer(s,&x); + srcvect.z -= (4<<8); + hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i], s); + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitinfo.pos.x; + if (s->picnum != BOSS1) + { + zvel += 128-(krand()&255); + sa += 32-(krand()&63); + } + else + { + zvel += 128-(krand()&255); + sa = getangle(g_player[j].ps->posx-srcvect.x,g_player[j].ps->posy-srcvect.y)+64-(krand()&127); + } + } + + if (ProjectileData[atwith].cstat >= 0) s->cstat &= ~ProjectileData[atwith].cstat; + else s->cstat &= ~257; + + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + hitscan((const vec3_t *)&srcvect,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + + + if (ProjectileData[atwith].cstat >= 0) s->cstat |= ProjectileData[atwith].cstat; + else s->cstat |= 257; + + if (hitinfo.hitsect < 0) return -1; + + if ((ProjectileData[atwith].range > 0) && + ((klabs(srcvect.x-hitinfo.pos.x)+klabs(srcvect.y-hitinfo.pos.y)) > ProjectileData[atwith].range)) + return -1; + + if (ProjectileData[atwith].trail >= 0) + { + A_HitscanProjTrail(&srcvect,&hitinfo.pos,sa,atwith); + } + + if (ProjectileData[atwith].workslike & PROJECTILE_WATERBUBBLES) + { + if ((krand()&15) == 0 && sector[hitinfo.hitsect].lotag == 2) + A_DoWaterTracers(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,srcvect.x,srcvect.y,srcvect.z,8-(ud.multimode>>1)); + } + + if (p >= 0) + { + k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,10,10,sa,0,0,i,4); + sprite[k].extra = ProjectileData[atwith].extra; + if (ProjectileData[atwith].extra_rand > 0) + sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; + + if (hitinfo.hitwall == -1 && hitinfo.hitsprite == -1) + { + if (zvel < 0) + { + if (sector[hitinfo.hitsect].ceilingstat&1) + { + sprite[k].xrepeat = 0; + sprite[k].yrepeat = 0; + return -1; + } + else + Sect_DamageCeiling(hitinfo.hitsect); + } + if (ProjectileData[atwith].spawns >= 0) + { + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitinfo.hitwall; + ActorExtra[wh].temp_data[7] = hitinfo.hitsect; + ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; + } + } + + if (hitinfo.hitsprite >= 0) + { + A_DamageObject(hitinfo.hitsprite,k); + if (sprite[hitinfo.hitsprite].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && g_player[sprite[hitinfo.hitsprite].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) + { + l = A_Spawn(k,JIBS6); + sprite[k].xrepeat = sprite[k].yrepeat = 0; + sprite[l].z += (4<<8); + sprite[l].xvel = 16; + sprite[l].xrepeat = sprite[l].yrepeat = 24; + sprite[l].ang += 64-(krand()&127); + } + else + { + if (ProjectileData[atwith].spawns >= 0) + { + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitinfo.hitwall; + ActorExtra[wh].temp_data[7] = hitinfo.hitsect; + ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; + } + } + if (p >= 0 && ( + sprite[hitinfo.hitsprite].picnum == DIPSWITCH || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH+1 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH2 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH2+1 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH3 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH3+1 || + sprite[hitinfo.hitsprite].picnum == HANDSWITCH || + sprite[hitinfo.hitsprite].picnum == HANDSWITCH+1)) + { + P_ActivateSwitch(p,hitinfo.hitsprite,1); + return -1; + } + } + else if (hitinfo.hitwall >= 0) + { + if (ProjectileData[atwith].spawns >= 0) + { + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitinfo.hitwall; + ActorExtra[wh].temp_data[7] = hitinfo.hitsect; + ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; + } + if (CheckDoorTile(wall[hitinfo.hitwall].picnum) == 1) + goto DOSKIPBULLETHOLE; + if (p >= 0 && ( + wall[hitinfo.hitwall].picnum == DIPSWITCH || + wall[hitinfo.hitwall].picnum == DIPSWITCH+1 || + wall[hitinfo.hitwall].picnum == DIPSWITCH2 || + wall[hitinfo.hitwall].picnum == DIPSWITCH2+1 || + wall[hitinfo.hitwall].picnum == DIPSWITCH3 || + wall[hitinfo.hitwall].picnum == DIPSWITCH3+1 || + wall[hitinfo.hitwall].picnum == HANDSWITCH || + wall[hitinfo.hitwall].picnum == HANDSWITCH+1)) + { + P_ActivateSwitch(p,hitinfo.hitwall,0); + return -1; + } + + if (wall[hitinfo.hitwall].hitag != 0 || (wall[hitinfo.hitwall].nextwall >= 0 && wall[wall[hitinfo.hitwall].nextwall].hitag != 0)) + goto DOSKIPBULLETHOLE; + + if (hitinfo.hitsect >= 0 && sector[hitinfo.hitsect].lotag == 0) + if (wall[hitinfo.hitwall].overpicnum != BIGFORCE) + if ((wall[hitinfo.hitwall].nextsector >= 0 && sector[wall[hitinfo.hitwall].nextsector].lotag == 0) || + (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag == 0)) + if ((wall[hitinfo.hitwall].cstat&16) == 0) + { + if (wall[hitinfo.hitwall].nextsector >= 0) + { + l = headspritesect[wall[hitinfo.hitwall].nextsector]; + while (l >= 0) + { + if (sprite[l].statnum == 3 && sprite[l].lotag == 13) + goto DOSKIPBULLETHOLE; + l = nextspritesect[l]; + } + } + + l = headspritestat[STAT_MISC]; + while (l >= 0) + { + if (sprite[l].picnum == ProjectileData[atwith].decal) + if (dist(&sprite[l],&sprite[k]) < (12+(krand()&7))) + goto DOSKIPBULLETHOLE; + l = nextspritestat[l]; + } + if (ProjectileData[atwith].decal >= 0) + { + l = A_Spawn(k,ProjectileData[atwith].decal); + sprite[l].xvel = -1; + sprite[l].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, + wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; + if (ProjectileData[atwith].workslike & PROJECTILE_RANDDECALSIZE) + { + wh = (krand()&ProjectileData[atwith].xrepeat); + if (wh < ProjectileData[atwith].yrepeat) + wh = ProjectileData[atwith].yrepeat; + sprite[l].xrepeat = wh; + sprite[l].yrepeat = wh; + } + else + { + sprite[l].xrepeat = ProjectileData[atwith].xrepeat; + sprite[l].yrepeat = ProjectileData[atwith].yrepeat; + } + sprite[l].cstat = 16+(krand()&12); + sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); + sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); + + A_SetSprite(l,CLIPMASK0); + A_AddToDeleteQueue(l); + } + } + +DOSKIPBULLETHOLE: + + if (wall[hitinfo.hitwall].cstat&2) + if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.pos.z >= (sector[wall[hitinfo.hitwall].nextsector].floorz)) + hitinfo.hitwall = wall[hitinfo.hitwall].nextwall; + + A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,atwith); + } + } + else + { + k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,24,24,sa,0,0,i,4); + sprite[k].extra = ProjectileData[atwith].extra; + if (ProjectileData[atwith].extra_rand > 0) + sprite[k].extra += (krand()%ProjectileData[atwith].extra_rand); + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; + + if (hitinfo.hitsprite >= 0) + { + A_DamageObject(hitinfo.hitsprite,k); + if (sprite[hitinfo.hitsprite].picnum != APLAYER) + { + if (ProjectileData[atwith].spawns >= 0) + { + wh=A_Spawn(k,ProjectileData[atwith].spawns); + if (ProjectileData[atwith].sxrepeat > 4) sprite[wh].xrepeat=ProjectileData[atwith].sxrepeat; + if (ProjectileData[atwith].syrepeat > 4) sprite[wh].yrepeat=ProjectileData[atwith].syrepeat; + ActorExtra[wh].temp_data[6] = hitinfo.hitwall; + ActorExtra[wh].temp_data[7] = hitinfo.hitsect; + ActorExtra[wh].temp_data[8] = hitinfo.hitsprite; + } + } + else sprite[k].xrepeat = sprite[k].yrepeat = 0; + } + else if (hitinfo.hitwall >= 0) + A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,atwith); + } + + if ((krand()&255) < 4) + if (ProjectileData[atwith].isound >= 0) + { + S_PlaySoundXYZ(ProjectileData[atwith].isound,k,&hitinfo.pos); + } + + return -1; + } + + if (ProjectileData[atwith].workslike & PROJECTILE_RPG) + { + + /* if(ProjectileData[atwith].workslike & PROJECTILE_FREEZEBLAST) + sz += (3<<8);*/ + + if (s->extra >= 0) s->shade = ProjectileData[atwith].shade; + + scount = 1; + vel = ProjectileData[atwith].vel; + + j = -1; + + if (p >= 0) + { + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + + zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitinfo.pos.x; + + if (sprite[j].picnum != RECON) + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + // else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*81; + else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*(ProjectileData[atwith].vel/8); + + if (ProjectileData[atwith].sound >= 0) + A_PlaySound(ProjectileData[atwith].sound,i); + } + else + { + if (!(ProjectileData[atwith].workslike & PROJECTILE_NOAIM)) + { + j = A_FindPlayer(s,&x); + sa = getangle(g_player[j].ps->oposx-srcvect.x,g_player[j].ps->oposy-srcvect.y); + + l = ldist(&sprite[g_player[j].ps->i],s); + if (l == 0) + l++; + zvel = ((g_player[j].ps->oposz-srcvect.z)*vel) / l; + + if (A_CheckEnemySprite(s) && (s->hitag&face_player_smart)) + sa = s->ang+(krand()&31)-16; + } + } + + + + if (p >= 0 && j >= 0) + l = j; + else l = -1; + + /* j = A_InsertSprite(sect, + sx+(sintable[(348+sa+512)&2047]/448), + sy+(sintable[(sa+348)&2047]/448), + sz-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4);*/ + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + j = A_InsertSprite(sect, + srcvect.x+(sintable[(348+sa+512)&2047]/ProjectileData[atwith].offset), + srcvect.y+(sintable[(sa+348)&2047]/ProjectileData[atwith].offset), + srcvect.z-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); + + sprite[j].xrepeat=ProjectileData[atwith].xrepeat; + sprite[j].yrepeat=ProjectileData[atwith].yrepeat; + + + if (ProjectileData[atwith].extra_rand > 0) + sprite[j].extra += (krand()&ProjectileData[atwith].extra_rand); + if (!(ProjectileData[atwith].workslike & PROJECTILE_BOUNCESOFFWALLS)) + sprite[j].yvel = l; + else + { + if (ProjectileData[atwith].bounces >= 1) sprite[j].yvel = ProjectileData[atwith].bounces; + else sprite[j].yvel = g_numFreezeBounces; + // sprite[j].xrepeat >>= 1; + // sprite[j].yrepeat >>= 1; + sprite[j].zvel -= (2<<4); + } + /* + if(p == -1) + { + if(!(ProjectileData[atwith].workslike & PROJECTILE_BOUNCESOFFWALLS)) + { + sprite[j].xrepeat = ProjectileData[atwith].xrepeat; // 30 + sprite[j].yrepeat = ProjectileData[atwith].yrepeat; + sprite[j].extra >>= 2; + } + } + */ + if (ProjectileData[atwith].cstat >= 0) sprite[j].cstat = ProjectileData[atwith].cstat; + else sprite[j].cstat = 128; + if (ProjectileData[atwith].clipdist >= 0) sprite[j].clipdist = ProjectileData[atwith].clipdist; + else sprite[j].clipdist = 40; + + Bmemcpy(&ActorExtra[j].projectile, &ProjectileData[sprite[j].picnum], sizeof(ProjectileData[sprite[j].picnum])); + + // sa = s->ang+32-(krand()&63); + // zvel = oldzvel+512-(krand()&1023); + + return j; + } + + } + else + { + switch (DynamicTileMap[atwith]) + { + case BLOODSPLAT1__STATIC: + case BLOODSPLAT2__STATIC: + case BLOODSPLAT3__STATIC: + case BLOODSPLAT4__STATIC: + + if (p >= 0) + sa += 64 - (krand()&127); + else sa += 1024 + 64 - (krand()&127); + zvel = 1024-(krand()&2047); + case KNEE__STATIC: + if (atwith == KNEE) + { + if (p >= 0) + { + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + srcvect.z += (6<<8); + sa += 15; + } + else + { + j = g_player[A_FindPlayer(s,&x)].ps->i; + zvel = ((sprite[j].z-srcvect.z)<<8) / (x+1); + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + } + + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + hitscan((const vec3_t *)&srcvect,sect, + sintable[(sa+512)&2047], + sintable[sa&2047],zvel<<6, + &hitinfo,CLIPMASK1); + + if (atwith == BLOODSPLAT1 || atwith == BLOODSPLAT2 || atwith == BLOODSPLAT3 || atwith == BLOODSPLAT4) + { + if (FindDistance2D(srcvect.x-hitinfo.pos.x,srcvect.y-hitinfo.pos.y) < 1024) + if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].overpicnum != BIGFORCE) + if ((wall[hitinfo.hitwall].nextsector >= 0 && hitinfo.hitsect >= 0 && + sector[wall[hitinfo.hitwall].nextsector].lotag == 0 && + sector[hitinfo.hitsect].lotag == 0 && + sector[wall[hitinfo.hitwall].nextsector].lotag == 0 && + (sector[hitinfo.hitsect].floorz-sector[wall[hitinfo.hitwall].nextsector].floorz) > (16<<8)) || + (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag == 0)) + if ((wall[hitinfo.hitwall].cstat&16) == 0) + { + if (wall[hitinfo.hitwall].nextsector >= 0) + { + k = headspritesect[wall[hitinfo.hitwall].nextsector]; + while (k >= 0) + { + if (sprite[k].statnum == 3 && sprite[k].lotag == 13) + return -1; + k = nextspritesect[k]; + } + } + + if (wall[hitinfo.hitwall].nextwall >= 0 && + wall[wall[hitinfo.hitwall].nextwall].hitag != 0) + return -1; + + if (wall[hitinfo.hitwall].hitag == 0) + { + k = A_Spawn(i,atwith); + sprite[k].xvel = -12; + sprite[k].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, + wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; + sprite[k].x = hitinfo.pos.x; + sprite[k].y = hitinfo.pos.y; + sprite[k].z = hitinfo.pos.z; + sprite[k].cstat |= (krand()&4); + A_SetSprite(k,CLIPMASK0); + setsprite(k,(vec3_t *)&sprite[k]); + if (PN == OOZFILTER || PN == NEWBEAST) + sprite[k].pal = 6; + } + } + return -1; + } + + if (hitinfo.hitsect < 0) break; + + if ((klabs(srcvect.x-hitinfo.pos.x)+klabs(srcvect.y-hitinfo.pos.y)) < 1024) + { + if (hitinfo.hitwall >= 0 || hitinfo.hitsprite >= 0) + { + j = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,KNEE,-15,0,0,sa,32,0,i,4); + sprite[j].extra += (krand()&7); + if (p >= 0) + { + k = A_Spawn(j,SMALLSMOKE); + sprite[k].z -= (8<<8); + A_PlaySound(KICK_HIT,j); + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; + } + + if (p >= 0 && g_player[p].ps->steroids_amount > 0 && g_player[p].ps->steroids_amount < 400) + sprite[j].extra += (g_player[p].ps->max_player_health>>2); + + if (hitinfo.hitsprite >= 0 && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH && sprite[hitinfo.hitsprite].picnum != ACCESSSWITCH2) + { + A_DamageObject(hitinfo.hitsprite,j); + if (p >= 0) P_ActivateSwitch(p,hitinfo.hitsprite,1); + } + + else if (hitinfo.hitwall >= 0) + { + if (wall[hitinfo.hitwall].cstat&2) + if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.pos.z >= (sector[wall[hitinfo.hitwall].nextsector].floorz)) + hitinfo.hitwall = wall[hitinfo.hitwall].nextwall; + + if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].picnum != ACCESSSWITCH && wall[hitinfo.hitwall].picnum != ACCESSSWITCH2) + { + A_DamageWall(j,hitinfo.hitwall,&hitinfo.pos,atwith); + if (p >= 0) P_ActivateSwitch(p,hitinfo.hitwall,0); + } + } + } + else if (p >= 0 && zvel > 0 && sector[hitinfo.hitsect].lotag == 1) + { + j = A_Spawn(g_player[p].ps->i,WATERSPLASH2); + sprite[j].x = hitinfo.pos.x; + sprite[j].y = hitinfo.pos.y; + sprite[j].ang = g_player[p].ps->ang; // Total tweek + sprite[j].xvel = 32; + A_SetSprite(i,CLIPMASK0); + sprite[j].xvel = 0; + + } + } + + break; + + case SHOTSPARK1__STATIC: + case SHOTGUN__STATIC: + case CHAINGUN__STATIC: + + if (s->extra >= 0) s->shade = -96; + + if (p >= 0) + { + int32_t angRange=32; + int32_t zRange=256; + + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); + if (((sprite[j].picnum>=GREENSLIME)&&(sprite[j].picnum<=GREENSLIME+7))||(sprite[j].picnum==ROTATEGUN)) + { + + dal -= (8<<8); + + } + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal)<<8) / hitinfo.pos.x; + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + + Gv_SetVar(g_iAngRangeVarID,angRange, i,p); + Gv_SetVar(g_iZRangeVarID,zRange,i,p); + + X_OnEvent(EVENT_GETSHOTRANGE, i,p, -1); + + angRange=Gv_GetVar(g_iAngRangeVarID,i,p); + zRange=Gv_GetVar(g_iZRangeVarID,i,p); + + if (atwith == SHOTSPARK1__STATIC && !WW2GI && !NAM) + { + if (!g_player[p].ps->auto_aim) + { + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + hitscan((const vec3_t *)&srcvect,sect,sintable[(sa+512)&2047],sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + if (hitinfo.hitsprite != -1) + { + if (sprite[hitinfo.hitsprite].statnum == 1 || sprite[hitinfo.hitsprite].statnum == 2 || sprite[hitinfo.hitsprite].statnum == 10 || sprite[hitinfo.hitsprite].statnum == 13) + j = hitinfo.hitsprite; + } + } + + if (j == -1) + { + sa += (angRange/2)-(krand()&(angRange-1)); + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + zvel += (zRange/2)-(krand()&(zRange-1)); + } + } + else + { + sa += (angRange/2)-(krand()&(angRange-1)); + if (j == -1) + { + // no target + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + } + zvel += (zRange/2)-(krand()&(zRange-1)); + } + + srcvect.z -= (2<<8); + } + else + { + j = A_FindPlayer(s,&x); + srcvect.z -= (4<<8); + hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i], s); + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitinfo.pos.x; + if (s->picnum != BOSS1) + { + zvel += 128-(krand()&255); + sa += 32-(krand()&63); + } + else + { + zvel += 128-(krand()&255); + sa = getangle(g_player[j].ps->posx-srcvect.x,g_player[j].ps->posy-srcvect.y)+64-(krand()&127); + } + } + + s->cstat &= ~257; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + hitscan((const vec3_t *)&srcvect,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + s->cstat |= 257; + + if (hitinfo.hitsect < 0) return -1; + + if ((krand()&15) == 0 && sector[hitinfo.hitsect].lotag == 2) + A_DoWaterTracers(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z, + srcvect.x,srcvect.y,srcvect.z,8-(ud.multimode>>1)); + + if (p >= 0) + { + k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,10,10,sa,0,0,i,4); + sprite[k].extra = *actorscrptr[atwith]; + sprite[k].extra += (krand()%6); + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; + + + if (hitinfo.hitwall == -1 && hitinfo.hitsprite == -1) + { + if (zvel < 0) + { + if (sector[hitinfo.hitsect].ceilingstat&1) + { + sprite[k].xrepeat = 0; + sprite[k].yrepeat = 0; + return -1; + } + else + Sect_DamageCeiling(hitinfo.hitsect); + } + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitinfo.hitwall; + ActorExtra[l].temp_data[7] = hitinfo.hitsect; + ActorExtra[l].temp_data[8] = hitinfo.hitsprite; + } + + if (hitinfo.hitsprite >= 0) + { + A_DamageObject(hitinfo.hitsprite,k); + if (sprite[hitinfo.hitsprite].picnum == APLAYER && (ud.ffire == 1 || (!GTFLAGS(GAMETYPE_PLAYERSFRIENDLY) && GTFLAGS(GAMETYPE_TDM) && g_player[sprite[hitinfo.hitsprite].yvel].ps->team != g_player[sprite[i].yvel].ps->team))) + { + l = A_Spawn(k,JIBS6); + sprite[k].xrepeat = sprite[k].yrepeat = 0; + sprite[l].z += (4<<8); + sprite[l].xvel = 16; + sprite[l].xrepeat = sprite[l].yrepeat = 24; + sprite[l].ang += 64-(krand()&127); + } + else + { + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitinfo.hitwall; + ActorExtra[l].temp_data[7] = hitinfo.hitsect; + ActorExtra[l].temp_data[8] = hitinfo.hitsprite; + } + + if (p >= 0 && ( + sprite[hitinfo.hitsprite].picnum == DIPSWITCH || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH+1 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH2 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH2+1 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH3 || + sprite[hitinfo.hitsprite].picnum == DIPSWITCH3+1 || + sprite[hitinfo.hitsprite].picnum == HANDSWITCH || + sprite[hitinfo.hitsprite].picnum == HANDSWITCH+1)) + { + P_ActivateSwitch(p,hitinfo.hitsprite,1); + return -1; + } + } + else if (hitinfo.hitwall >= 0) + { + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitinfo.hitwall; + ActorExtra[l].temp_data[7] = hitinfo.hitsect; + ActorExtra[l].temp_data[8] = hitinfo.hitsprite; + + if (CheckDoorTile(wall[hitinfo.hitwall].picnum) == 1) + goto SKIPBULLETHOLE; + if (p >= 0 && ( + wall[hitinfo.hitwall].picnum == DIPSWITCH || + wall[hitinfo.hitwall].picnum == DIPSWITCH+1 || + wall[hitinfo.hitwall].picnum == DIPSWITCH2 || + wall[hitinfo.hitwall].picnum == DIPSWITCH2+1 || + wall[hitinfo.hitwall].picnum == DIPSWITCH3 || + wall[hitinfo.hitwall].picnum == DIPSWITCH3+1 || + wall[hitinfo.hitwall].picnum == HANDSWITCH || + wall[hitinfo.hitwall].picnum == HANDSWITCH+1)) + { + P_ActivateSwitch(p,hitinfo.hitwall,0); + return -1; + } + + if (wall[hitinfo.hitwall].hitag != 0 || (wall[hitinfo.hitwall].nextwall >= 0 && wall[wall[hitinfo.hitwall].nextwall].hitag != 0)) + goto SKIPBULLETHOLE; + + if (hitinfo.hitsect >= 0 && sector[hitinfo.hitsect].lotag == 0) + if (wall[hitinfo.hitwall].overpicnum != BIGFORCE) + if ((wall[hitinfo.hitwall].nextsector >= 0 && sector[wall[hitinfo.hitwall].nextsector].lotag == 0) || + (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag == 0)) + if ((wall[hitinfo.hitwall].cstat&16) == 0) + { + if (wall[hitinfo.hitwall].nextsector >= 0) + { + l = headspritesect[wall[hitinfo.hitwall].nextsector]; + while (l >= 0) + { + if (sprite[l].statnum == 3 && sprite[l].lotag == 13) + goto SKIPBULLETHOLE; + l = nextspritesect[l]; + } + } + + l = headspritestat[STAT_MISC]; + while (l >= 0) + { + if (sprite[l].picnum == BULLETHOLE) + if (dist(&sprite[l],&sprite[k]) < (12+(krand()&7))) + goto SKIPBULLETHOLE; + l = nextspritestat[l]; + } + l = A_Spawn(k,BULLETHOLE); + sprite[l].xvel = -1; + sprite[l].x = hitinfo.pos.x; + sprite[l].y = hitinfo.pos.y; + sprite[l].z = hitinfo.pos.z; + + sprite[l].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x, + wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)+512; + + sprite[l].x -= mulscale13(1,sintable[(sprite[l].ang+2560)&2047]); + sprite[l].y -= mulscale13(1,sintable[(sprite[l].ang+2048)&2047]); + A_SetSprite(l,CLIPMASK0); + } + +SKIPBULLETHOLE: + + if (wall[hitinfo.hitwall].cstat&2) + if (wall[hitinfo.hitwall].nextsector >= 0) + if (hitinfo.pos.z >= (sector[wall[hitinfo.hitwall].nextsector].floorz)) + hitinfo.hitwall = wall[hitinfo.hitwall].nextwall; + + A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,SHOTSPARK1); + } + } + else + { + k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,SHOTSPARK1,-15,24,24,sa,0,0,i,4); + sprite[k].extra = *actorscrptr[atwith]; + sprite[k].yvel = atwith; // this is a hack to allow you to detect which weapon spawned a SHOTSPARK1 + ActorExtra[k].temp_data[6] = hitinfo.hitwall; + ActorExtra[k].temp_data[7] = hitinfo.hitsect; + ActorExtra[k].temp_data[8] = hitinfo.hitsprite; + + if (hitinfo.hitsprite >= 0) + { + A_DamageObject(hitinfo.hitsprite,k); + if (sprite[hitinfo.hitsprite].picnum != APLAYER) + { + l = A_Spawn(k,SMALLSMOKE); + ActorExtra[l].temp_data[6] = hitinfo.hitwall; + ActorExtra[l].temp_data[7] = hitinfo.hitsect; + ActorExtra[l].temp_data[8] = hitinfo.hitsprite; + } + else sprite[k].xrepeat = sprite[k].yrepeat = 0; + } + else if (hitinfo.hitwall >= 0) + A_DamageWall(k,hitinfo.hitwall,&hitinfo.pos,SHOTSPARK1); + } + + if ((krand()&255) < 4) + S_PlaySoundXYZ(PISTOL_RICOCHET,k, &hitinfo.pos); + + return -1; + + case FIRELASER__STATIC: + case SPIT__STATIC: + case COOLEXPLOSION1__STATIC: + + if (s->extra >= 0) s->shade = -96; + + scount = 1; + if (atwith == SPIT) vel = 292; + else + { + if (atwith == COOLEXPLOSION1) + { + if (s->picnum == BOSS2) vel = 644; + else vel = 348; + srcvect.z -= (4<<7); + } + else + { + vel = 840; + srcvect.z -= (4<<7); + } + } + + if (p >= 0) + { + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)-(12<<8); + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitinfo.pos.x; + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + else + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*98; + } + else + { + j = A_FindPlayer(s,&x); + // sa = getangle(g_player[j].ps->oposx-sx,g_player[j].ps->oposy-sy); + sa += 16-(krand()&31); + hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i],s); + if (hitinfo.pos.x == 0) hitinfo.pos.x++; + zvel = ((g_player[j].ps->oposz - srcvect.z + (3<<8))*vel) / hitinfo.pos.x; + } + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + oldzvel = zvel; + + if (atwith == SPIT) + { + sizx = 18; + sizy = 18,srcvect.z -= (10<<8); + } + else + { + if (atwith == FIRELASER) + { + if (p >= 0) + { + + sizx = 34; + sizy = 34; + } + else + { + sizx = 18; + sizy = 18; + } + } + else + { + sizx = 18; + sizy = 18; + } + } + + if (p >= 0) sizx = 7,sizy = 7; + + while (scount > 0) + { + j = A_InsertSprite(sect,srcvect.x,srcvect.y,srcvect.z, + atwith,-127,sizx,sizy,sa,vel,zvel,i,4); + sprite[j].extra += (krand()&7); + + if (atwith == COOLEXPLOSION1) + { + sprite[j].shade = 0; + if (PN == BOSS2) + { + l = sprite[j].xvel; + sprite[j].xvel = 1024; + A_SetSprite(j,CLIPMASK0); + sprite[j].xvel = l; + sprite[j].ang += 128-(krand()&255); + } + } + + sprite[j].cstat = 128; + sprite[j].clipdist = 4; + + sa = s->ang+32-(krand()&63); + zvel = oldzvel+512-(krand()&1023); + + scount--; + } + + return j; + + case FREEZEBLAST__STATIC: + srcvect.z += (3<<8); + case RPG__STATIC: + + if (s->extra >= 0) s->shade = -96; + + scount = 1; + vel = 644; + + j = -1; + + if (p >= 0) + { + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); // 48 + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(8<<8); + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal)*vel) / hitinfo.pos.x; + if (sprite[j].picnum != RECON) + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*81; + if (atwith == RPG) + A_PlaySound(RPG_SHOOT,i); + } + else + { + j = A_FindPlayer(s,&x); + sa = getangle(g_player[j].ps->oposx-srcvect.x,g_player[j].ps->oposy-srcvect.y); + if (PN == BOSS3) + srcvect.z -= (32<<8); + else if (PN == BOSS2) + { + vel += 128; + srcvect.z += 24<<8; + } + + l = ldist(&sprite[g_player[j].ps->i],s); + if (l == 0) + l++; + zvel = ((g_player[j].ps->oposz-srcvect.z)*vel) / l; + + if (A_CheckEnemySprite(s) && (s->hitag&face_player_smart)) + sa = s->ang+(krand()&31)-16; + } + + if (p >= 0 && j >= 0) + l = j; + else l = -1; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + j = A_InsertSprite(sect, + srcvect.x+(sintable[(348+sa+512)&2047]/448), + srcvect.y+(sintable[(sa+348)&2047]/448), + srcvect.z-(1<<8),atwith,0,14,14,sa,vel,zvel,i,4); + + sprite[j].extra += (krand()&7); + if (atwith != FREEZEBLAST) + sprite[j].yvel = l; + else + { + sprite[j].yvel = g_numFreezeBounces; + sprite[j].xrepeat >>= 1; + sprite[j].yrepeat >>= 1; + sprite[j].zvel -= (2<<4); + } + + if (p == -1) + { + if (PN == BOSS3) + { + if (krand()&1) + { + sprite[j].x -= sintable[sa&2047]>>6; + sprite[j].y -= sintable[(sa+1024+512)&2047]>>6; + sprite[j].ang -= 8; + } + else + { + sprite[j].x += sintable[sa&2047]>>6; + sprite[j].y += sintable[(sa+1024+512)&2047]>>6; + sprite[j].ang += 4; + } + sprite[j].xrepeat = 42; + sprite[j].yrepeat = 42; + } + else if (PN == BOSS2) + { + sprite[j].x -= sintable[sa&2047]/56; + sprite[j].y -= sintable[(sa+1024+512)&2047]/56; + sprite[j].ang -= 8+(krand()&255)-128; + sprite[j].xrepeat = 24; + sprite[j].yrepeat = 24; + } + else if (atwith != FREEZEBLAST) + { + sprite[j].xrepeat = 30; + sprite[j].yrepeat = 30; + sprite[j].extra >>= 2; + } + } + + else if (*aplWeaponWorksLike[g_player[p].ps->curr_weapon] == DEVISTATOR_WEAPON) + { + sprite[j].extra >>= 2; + sprite[j].ang += 16-(krand()&31); + sprite[j].zvel += 256-(krand()&511); + + if (g_player[p].ps->hbomb_hold_delay) + { + sprite[j].x -= sintable[sa&2047]/644; + sprite[j].y -= sintable[(sa+1024+512)&2047]/644; + } + else + { + sprite[j].x += sintable[sa&2047]>>8; + sprite[j].y += sintable[(sa+1024+512)&2047]>>8; + } + sprite[j].xrepeat >>= 1; + sprite[j].yrepeat >>= 1; + } + + sprite[j].cstat = 128; + if (atwith == RPG) + sprite[j].clipdist = 4; + else + sprite[j].clipdist = 40; + + return j; + + case HANDHOLDINGLASER__STATIC: + + if (p >= 0) + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*32; + else zvel = 0; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + + srcvect.z -= g_player[p].ps->pyoff; + hitscan((const vec3_t *)&srcvect,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + + srcvect.z += g_player[p].ps->pyoff; + j = 0; + if (hitinfo.hitsprite >= 0) break; + + if (hitinfo.hitwall >= 0 && hitinfo.hitsect >= 0) + if (((hitinfo.pos.x-srcvect.x)*(hitinfo.pos.x-srcvect.x)+(hitinfo.pos.y-srcvect.y)*(hitinfo.pos.y-srcvect.y)) < (290*290)) + { + if (wall[hitinfo.hitwall].nextsector >= 0) + { + if (sector[wall[hitinfo.hitwall].nextsector].lotag <= 2 && sector[hitinfo.hitsect].lotag <= 2) + j = 1; + } + else if (sector[hitinfo.hitsect].lotag <= 2) + j = 1; + } + + if (j == 1) + { + int32_t lTripBombControl=Gv_GetVarByLabel("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, g_player[p].ps->i, p); + k = A_InsertSprite(hitinfo.hitsect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,TRIPBOMB,-16,4,5,sa,0,0,i,6); + if (lTripBombControl & TRIPBOMB_TIMER) + { + int32_t lLifetime=Gv_GetVarByLabel("STICKYBOMB_LIFETIME", NAM_GRENADE_LIFETIME, g_player[p].ps->i, p); + int32_t lLifetimeVar=Gv_GetVarByLabel("STICKYBOMB_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, g_player[p].ps->i, p); + // set timer. blows up when at zero.... + ActorExtra[k].temp_data[7]=lLifetime + + mulscale(krand(),lLifetimeVar, 14) + - lLifetimeVar; + ActorExtra[k].temp_data[6]=1; + } + else + + sprite[k].hitag = k; + A_PlaySound(LASERTRIP_ONWALL,k); + sprite[k].xvel = -20; + A_SetSprite(k,CLIPMASK0); + sprite[k].cstat = 16; + ActorExtra[k].temp_data[5] = sprite[k].ang = getangle(wall[hitinfo.hitwall].x-wall[wall[hitinfo.hitwall].point2].x,wall[hitinfo.hitwall].y-wall[wall[hitinfo.hitwall].point2].y)-512; + + + } + return j?k:-1; + + case BOUNCEMINE__STATIC: + case MORTER__STATIC: + + if (s->extra >= 0) s->shade = -96; + + j = g_player[A_FindPlayer(s,&x)].ps->i; + x = ldist(&sprite[j],s); + + zvel = -x>>1; + + if (zvel < -4096) + zvel = -2048; + vel = x>>4; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + A_InsertSprite(sect, + srcvect.x+(sintable[(512+sa+512)&2047]>>8), + srcvect.y+(sintable[(sa+512)&2047]>>8), + srcvect.z+(6<<8),atwith,-64,32,32,sa,vel,zvel,i,1); + break; + + case GROWSPARK__STATIC: + + if (p >= 0) + { + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1)+(5<<8); + if (((sprite[j].picnum >= GREENSLIME)&&(sprite[j].picnum <= GREENSLIME+7))||(sprite[j].picnum ==ROTATEGUN)) + { + dal -= (8<<8); + + } + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal)<<8) / hitinfo.pos.x; + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + else + { + sa += 16-(krand()&31); + zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)<<5; + zvel += 128-(krand()&255); + } + + srcvect.z -= (2<<8); + } + else + { + j = A_FindPlayer(s,&x); + srcvect.z -= (4<<8); + hitinfo.pos.x = ldist(&sprite[g_player[j].ps->i], s); + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + zvel = ((g_player[j].ps->posz-srcvect.z) <<8) / hitinfo.pos.x; + zvel += 128-(krand()&255); + sa += 32-(krand()&63); + } + + k = 0; + + // RESHOOTGROW: + if (sect < 0) break; + + s->cstat &= ~257; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + hitscan((const vec3_t *)&srcvect,sect, + sintable[(sa+512)&2047], + sintable[sa&2047], + zvel<<6,&hitinfo,CLIPMASK1); + + s->cstat |= 257; + + j = A_InsertSprite(sect,hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,GROWSPARK,-16,28,28,sa,0,0,i,1); + + sprite[j].pal = 2; + sprite[j].cstat |= 130; + sprite[j].xrepeat = sprite[j].yrepeat = 1; + + if (hitinfo.hitwall == -1 && hitinfo.hitsprite == -1 && hitinfo.hitsect >= 0) + { + if (zvel < 0 && (sector[hitinfo.hitsect].ceilingstat&1) == 0) + Sect_DamageCeiling(hitinfo.hitsect); + } + else if (hitinfo.hitsprite >= 0) A_DamageObject(hitinfo.hitsprite,j); + else if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].picnum != ACCESSSWITCH && wall[hitinfo.hitwall].picnum != ACCESSSWITCH2) + { + /* if(wall[hitinfo.hitwall].overpicnum == MIRROR && k == 0) + { + l = getangle( + wall[wall[hitinfo.hitwall].point2].x-wall[hitinfo.hitwall].x, + wall[wall[hitinfo.hitwall].point2].y-wall[hitinfo.hitwall].y); + + sx = hitinfo.pos.x; + sy = hitinfo.pos.y; + srcvect.z = hitinfo.pos.z; + sect = hitinfo.hitsect; + sa = ((l<<1) - sa)&2047; + sx += sintable[(sa+512)&2047]>>12; + sy += sintable[sa&2047]>>12; + + k++; + goto RESHOOTGROW; + } + else */ + A_DamageWall(j,hitinfo.hitwall,&hitinfo.pos,atwith); + } + + break; + + case SHRINKER__STATIC: + if (s->extra >= 0) s->shade = -96; + if (p >= 0) + { + // j = A_FindTargetSprite( s, AUTO_AIM_ANGLE ); + Gv_SetVar(g_iAimAngleVarID,AUTO_AIM_ANGLE,i,p); + X_OnEvent(EVENT_GETAUTOAIMANGLE, i, p, -1); + j=-1; + if (Gv_GetVar(g_iAimAngleVarID,i,p) > 0) + { + j = A_FindTargetSprite(s, Gv_GetVar(g_iAimAngleVarID,i,p),atwith); + } + + if (j >= 0) + { + dal = ((sprite[j].yrepeat*tilesizy[sprite[j].picnum])<<1); + hitinfo.pos.x = ldist(&sprite[g_player[p].ps->i], &sprite[j]); + if (hitinfo.pos.x == 0) + hitinfo.pos.x++; + zvel = ((sprite[j].z-srcvect.z-dal-(4<<8))*768) / hitinfo.pos.x; + sa = getangle(sprite[j].x-srcvect.x,sprite[j].y-srcvect.y); + } + else zvel = (100-g_player[p].ps->horiz-g_player[p].ps->horizoff)*98; + } + else if (s->statnum != 3) + { + j = A_FindPlayer(s,&x); + l = ldist(&sprite[g_player[j].ps->i],s); + if (l == 0) + l++; + zvel = ((g_player[j].ps->oposz-srcvect.z)*512) / l ; + } + else zvel = 0; + if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; + j = A_InsertSprite(sect, + srcvect.x+(sintable[(512+sa+512)&2047]>>12), + srcvect.y+(sintable[(sa+512)&2047]>>12), + srcvect.z+(2<<8),SHRINKSPARK,-16,28,28,sa,768,zvel,i,4); + + sprite[j].cstat = 128; + sprite[j].clipdist = 32; + + + return j; + } + } + return -1; +} + +static void P_DisplaySpitAnim(int32_t snum) +{ + int32_t i, a, x, y, z; + + if (g_player[snum].ps->loogcnt == 0) return; + + y = (g_player[snum].ps->loogcnt<<2); + for (i=0;inumloogs;i++) + { + a = klabs(sintable[((g_player[snum].ps->loogcnt+i)<<5)&2047])>>5; + z = 4096+((g_player[snum].ps->loogcnt+i)<<9); + x = (-g_player[snum].sync->avel)+(sintable[((g_player[snum].ps->loogcnt+i)<<6)&2047]>>10); + + rotatesprite( + (g_player[snum].ps->loogiex[i]+x)<<16,(200+g_player[snum].ps->loogiey[i]-y)<<16,z-(i<<8),256-a, + LOOGIE,0,0,2,0,0,xdim-1,ydim-1); + } +} + +static int32_t P_DisplayFistAnim(int32_t gs,int32_t snum) +{ + int32_t looking_arc,fisti,fistpal; + int32_t fistzoom, fistz; + + fisti = g_player[snum].ps->fist_incs; + if (fisti > 32) fisti = 32; + if (fisti <= 0) return 0; + + looking_arc = klabs(g_player[snum].ps->look_ang)/9; + + fistzoom = 65536L - (sintable[(512+(fisti<<6))&2047]<<2); + if (fistzoom > 90612L) + fistzoom = 90612L; + if (fistzoom < 40920) + fistzoom = 40290; + fistz = 194 + (sintable[((6+fisti)<<7)&2047]>>9); + + if (sprite[g_player[snum].ps->i].pal == 1) + fistpal = 1; + else if (g_player[snum].ps->cursectnum >= 0) + fistpal = sector[g_player[snum].ps->cursectnum].floorpal; + else fistpal = 0; + + rotatesprite( + (-fisti+222+(g_player[snum].sync->avel>>4))<<16, + (looking_arc+fistz)<<16, + fistzoom,0,FIST,gs,fistpal,2,0,0,xdim-1,ydim-1); + + return 1; +} + +#define weapsc(sc) scale(sc,ud.weaponscale,100) + +static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p) +{ + int32_t a = 0; + int32_t xoff = 192; + + switch (g_currentweapon) + { + case DEVISTATOR_WEAPON: + case TRIPBOMB_WEAPON: + xoff = 160; + break; + default: + if (orientation & 262144) + { + xoff = 160; + orientation &= ~262144; + } + break; + } + + if (orientation&4) + a = 1024; + +#if defined(POLYMOST) && defined(USE_OPENGL) + if (getrendermode() >= 3 && usemodels && md_tilehasmodel(tilenum,p) > 0) + y += (224-weapsc(224)); +#endif + rotatesprite(weapsc((orientation&256)?x:(x<<16))+((xoff-weapsc(xoff))<<16), + weapsc((orientation&256)?y:(y<<16))+((200-weapsc(200))<<16), + weapsc(65536L),a,tilenum,shade,p,2|orientation,windowx1,windowy1,windowx2,windowy2); +} + +static void G_DrawWeaponTile(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p) +{ + if (!ud.drawweapon) + return; + else if (ud.drawweapon == 1) + G_DrawTileScaled(x,y,tilenum,shade,orientation,p); + else if (ud.drawweapon == 2) + { + switch (g_currentweapon) + { + case PISTOL_WEAPON: + case CHAINGUN_WEAPON: + case RPG_WEAPON: + case FREEZE_WEAPON: + case SHRINKER_WEAPON: + case GROW_WEAPON: + case DEVISTATOR_WEAPON: + case TRIPBOMB_WEAPON: + case HANDREMOTE_WEAPON: + case HANDBOMB_WEAPON: + case SHOTGUN_WEAPON: + rotatesprite(160<<16,(180+(g_player[screenpeek].ps->weapon_pos*g_player[screenpeek].ps->weapon_pos))<<16,scale(65536,ud.statusbarscale,100),0,g_currentweapon==GROW_WEAPON?GROWSPRITEICON:WeaponPickupSprites[g_currentweapon],0,0,2,windowx1,windowy1,windowx2,windowy2); + break; + } + } +} + +static int32_t P_DisplayKneeAnim(int32_t gs,int32_t snum) +{ + static int8_t knee_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-72,-32,-8}; + int32_t looking_arc, pal = g_player[snum].ps->palookup; + + if (g_player[snum].ps->knee_incs > 11 || g_player[snum].ps->knee_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; + + looking_arc = knee_y[g_player[snum].ps->knee_incs] + klabs(g_player[snum].ps->look_ang)/9; + + looking_arc -= (g_player[snum].ps->hard_landing<<3); + + if (sprite[g_player[snum].ps->i].pal == 1) + pal = 1; + else if (g_player[snum].ps->cursectnum >= 0) + { + pal = sector[g_player[snum].ps->cursectnum].floorpal; + if (pal == 0) + pal = g_player[snum].ps->palookup; + } + + G_DrawTileScaled(105+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(knee_y[g_player[snum].ps->knee_incs]>>2),looking_arc+280-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),KNEE,gs,4+262144,pal); + + return 1; +} + +static int32_t P_DisplayKnuckleAnim(int32_t gs,int32_t snum) +{ + static char knuckle_frames[] = {0,1,2,2,3,3,3,2,2,1,0}; + int32_t looking_arc, pal = 0; + + if (g_player[snum].ps->knuckle_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; + + looking_arc = klabs(g_player[snum].ps->look_ang)/9; + + looking_arc -= (g_player[snum].ps->hard_landing<<3); + + if (sprite[g_player[snum].ps->i].pal == 1) + pal = 1; + else if (g_player[snum].ps->cursectnum >= 0) + pal = sector[g_player[snum].ps->cursectnum].floorpal; + + G_DrawTileScaled(160+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1),looking_arc+180-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),CRACKKNUCKLES+knuckle_frames[g_player[snum].ps->knuckle_incs>>1],gs,4+262144,pal); + + return 1; +} + +int32_t lastvisinc; + +void P_FireWeapon(DukePlayer_t *p) +{ + int32_t i, snum = sprite[p->i].yvel; + + Gv_SetVar(g_iReturnVarID,0,p->i,snum); + X_OnEvent(EVENT_DOFIRE, p->i, snum, -1); + + if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) + { + if (p->weapon_pos != 0) return; + + if (aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON) + p->ammo_amount[p->curr_weapon]--; + + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + A_PlaySound(aplWeaponFireSound[p->curr_weapon][snum],p->i); + } + + Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); + Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); +// OSD_Printf("doing %d %d %d\n",aplWeaponShoots[p->curr_weapon][snum],p->curr_weapon,snum); + A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + for (i=1;icurr_weapon][snum];i++) + { + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYOTHER) + { + // this makes the projectiles fire on a delay from player code + ActorExtra[p->i].temp_data[7] = (aplWeaponShotsPerBurst[p->curr_weapon][snum])<<1; + } + else + { + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AMMOPERSHOT) + { + if (p->ammo_amount[p->curr_weapon] > 0) + p->ammo_amount[p->curr_weapon]--; + else break; + } + A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + } + } + + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_NOVISIBLE)) + { + lastvisinc = totalclock+32; + p->visibility = 0; + } + + /* if( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_CHECKATRELOAD) && + aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum] + && p->ammo_amount[p->curr_weapon] > 0 + && (aplWeaponClip[p->curr_weapon][snum]) + && ((p->ammo_amount[p->curr_weapon]%(aplWeaponClip[p->curr_weapon][snum]))==0)) + { + p->kickback_pic=aplWeaponTotalTime[p->curr_weapon][snum]; + } */ + } +} + +void P_DoWeaponSpawn(DukePlayer_t *p) +{ + int32_t j, snum = sprite[p->i].yvel; + + if (!aplWeaponSpawn[p->curr_weapon][snum]) + return; + + j = A_Spawn(p->i, aplWeaponSpawn[p->curr_weapon][snum]); + + if ((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_SPAWNTYPE3)) + { + // like chaingun shells + sprite[j].ang += 1024; + sprite[j].ang &= 2047; + sprite[j].xvel += 32; + sprite[j].z += (3<<8); + } + + A_SetSprite(j,CLIPMASK0); + +} + +void P_DisplayScubaMask(int32_t snum) +{ + int32_t p; + + if (sprite[g_player[snum].ps->i].pal == 1) + p = 1; + else if (g_player[snum].ps->cursectnum >= 0) + p = sector[g_player[snum].ps->cursectnum].floorpal; + else p = 0; + + if (g_player[snum].ps->scuba_on) + { + rotatesprite(43<<16,(200-tilesizy[SCUBAMASK])<<16,65536,0,SCUBAMASK,0,p,2+16,windowx1,windowy1,windowx2,windowy2); + rotatesprite((320-43)<<16,(200-tilesizy[SCUBAMASK])<<16,65536,1024,SCUBAMASK,0,p,2+4+16,windowx1,windowy1,windowx2,windowy2); + } +} + +static int32_t P_DisplayTipAnim(int32_t gs,int32_t snum) +{ + int32_t p,looking_arc; + static int16_t tip_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; + + if (g_player[snum].ps->tipincs == 0) return 0; + + looking_arc = klabs(g_player[snum].ps->look_ang)/9; + looking_arc -= (g_player[snum].ps->hard_landing<<3); + + if (sprite[g_player[snum].ps->i].pal == 1) + p = 1; + else + p = sector[g_player[snum].ps->cursectnum].floorpal; + + /* if(g_player[snum].ps->access_spritenum >= 0) + p = sprite[g_player[snum].ps->access_spritenum].pal; + else + p = wall[g_player[snum].ps->access_wallnum].pal; + */ + G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1), + (tip_y[g_player[snum].ps->tipincs]>>1)+looking_arc+240-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),TIP+((26-g_player[snum].ps->tipincs)>>4),gs,262144,p); + + return 1; +} + +static int32_t P_DisplayAccessAnim(int32_t gs,int32_t snum) +{ + static int16_t access_y[] = {0,-8,-16,-32,-64,-84,-108,-108,-108,-108,-108,-108,-108,-108,-108,-108,-96,-72,-64,-32,-16}; + int32_t looking_arc; + int32_t p; + + if (g_player[snum].ps->access_incs == 0 || sprite[g_player[snum].ps->i].extra <= 0) return 0; + + looking_arc = access_y[g_player[snum].ps->access_incs] + klabs(g_player[snum].ps->look_ang)/9; + looking_arc -= (g_player[snum].ps->hard_landing<<3); + + if (g_player[snum].ps->access_spritenum >= 0) + p = sprite[g_player[snum].ps->access_spritenum].pal; + else p = 0; + // else + // p = wall[g_player[snum].ps->access_wallnum].pal; + + if ((g_player[snum].ps->access_incs-3) > 0 && (g_player[snum].ps->access_incs-3)>>3) + G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(access_y[g_player[snum].ps->access_incs]>>2),looking_arc+266-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),HANDHOLDINGLASER+(g_player[snum].ps->access_incs>>3),gs,262144,p); + else + G_DrawTileScaled(170+(g_player[snum].sync->avel>>4)-(g_player[snum].ps->look_ang>>1)+(access_y[g_player[snum].ps->access_incs]>>2),looking_arc+266-((g_player[snum].ps->horiz-g_player[snum].ps->horizoff)>>4),HANDHOLDINGACCESS,gs,4+262144,p); + + return 1; +} + + +static int32_t fistsign; + +void P_DisplayWeapon(int32_t snum) +{ + int32_t gun_pos, looking_arc, cw; + int32_t weapon_xoffset, i, j; + int32_t o = 0,pal = 0; + DukePlayer_t *p = g_player[snum].ps; + int16_t *kb = &p->kickback_pic; + int32_t gs; + + looking_arc = klabs(p->look_ang)/9; + + gs = sprite[p->i].shade; + if (gs > 24) gs = 24; + + if (p->newowner >= 0 || ud.camerasprite >= 0 || p->over_shoulder_on > 0 || (sprite[p->i].pal != 1 && sprite[p->i].extra <= 0) || P_DisplayFistAnim(gs,snum) || P_DisplayKnuckleAnim(gs,snum) || P_DisplayTipAnim(gs,snum) || P_DisplayAccessAnim(gs,snum)) + return; + + P_DisplayKneeAnim(gs,snum); + + gun_pos = 80-(p->weapon_pos*p->weapon_pos); + + weapon_xoffset = (160)-90; + + if (ud.weaponsway) + { + weapon_xoffset -= (sintable[((p->weapon_sway>>1)+512)&2047]/(1024+512)); + + if (sprite[p->i].xrepeat < 32) + gun_pos -= klabs(sintable[(p->weapon_sway<<2)&2047]>>9); + else gun_pos -= klabs(sintable[(p->weapon_sway>>1)&2047]>>10); + } + else gun_pos -= 16; + + weapon_xoffset -= 58 + p->weapon_ang; + gun_pos -= (p->hard_landing<<3); + + if (p->last_weapon >= 0) + cw = aplWeaponWorksLike[p->last_weapon][snum]; + else + cw = aplWeaponWorksLike[p->curr_weapon][snum]; + + g_gun_pos=gun_pos; + g_looking_arc=looking_arc; + g_currentweapon=cw; + g_weapon_xoffset=weapon_xoffset; + g_gs=gs; + g_kb=*kb; + g_looking_angSR1=p->look_ang>>1; + + Gv_SetVar(g_iReturnVarID,0,p->i,snum); + X_OnEvent(EVENT_DISPLAYWEAPON, p->i, screenpeek, -1); + + if (Gv_GetVar(g_iReturnVarID,p->i,snum) == 0) + { + j = 14-p->quick_kick; + if (j != 14 || p->last_quick_kick) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + { + if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + if (pal == 0) + pal = p->palookup; + } + + guniqhudid = 100; + if (j < 6 || j > 12) + G_DrawTileScaled(weapon_xoffset+80-(p->look_ang>>1), + looking_arc+250-gun_pos,KNEE,gs,o|4|262144,pal); + else G_DrawTileScaled(weapon_xoffset+160-16-(p->look_ang>>1), + looking_arc+214-gun_pos,KNEE+1,gs,o|4|262144,pal); + guniqhudid = 0; + } + + if (sprite[p->i].xrepeat < 40) + { + if (p->jetpack_on == 0) + { + i = sprite[p->i].xvel; + looking_arc += 32-(i>>1); + fistsign += i>>1; + } + cw = weapon_xoffset; + weapon_xoffset += sintable[(fistsign)&2047]>>10; + G_DrawTile(weapon_xoffset+250-(p->look_ang>>1), + looking_arc+258-(klabs(sintable[(fistsign)&2047]>>8)), + FIST,gs,o); + weapon_xoffset = cw; + weapon_xoffset -= sintable[(fistsign)&2047]>>10; + G_DrawTile(weapon_xoffset+40-(p->look_ang>>1), + looking_arc+200+(klabs(sintable[(fistsign)&2047]>>8)), + FIST,gs,o|4); + } + else switch (cw) + + { + + case KNEE_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if ((*kb) > 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else + { + if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + if (pal == 0) + pal = p->palookup; + } + guniqhudid = cw; + if ((*kb) < 5 || (*kb) > 9) + G_DrawTileScaled(weapon_xoffset+220-(p->look_ang>>1), + looking_arc+250-gun_pos,KNEE,gs,o,pal); + else + G_DrawTileScaled(weapon_xoffset+160-(p->look_ang>>1), + looking_arc+214-gun_pos,KNEE+1,gs,o,pal); + guniqhudid = 0; + } + } + break; + + case TRIPBOMB_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + weapon_xoffset += 8; + gun_pos -= 10; + + if ((*kb) > 6) + looking_arc += ((*kb)<<3); + else if ((*kb) < 4) + { + guniqhudid = cw<<2; + G_DrawWeaponTile(weapon_xoffset+142-(p->look_ang>>1), + looking_arc+234-gun_pos,HANDHOLDINGLASER+3,gs,o,pal); + } + + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+130-(p->look_ang>>1), + looking_arc+249-gun_pos, + HANDHOLDINGLASER+((*kb)>>2),gs,o,pal); + + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+152-(p->look_ang>>1), + looking_arc+249-gun_pos, + HANDHOLDINGLASER+((*kb)>>2),gs,o|4,pal); + guniqhudid = 0; + } + break; + + case RPG_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + weapon_xoffset -= sintable[(768+((*kb)<<7))&2047]>>11; + gun_pos += sintable[(768+((*kb)<<7))&2047]>>11; + + if (*kb > 0) + { + if (*kb < 8) + { + G_DrawWeaponTile(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, + RPGGUN+((*kb)>>1),gs,o,pal); + } + } + + G_DrawWeaponTile(weapon_xoffset+164,(looking_arc<<1)+176-gun_pos, + RPGGUN,gs,o,pal); + } + break; + + case SHOTGUN_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + + weapon_xoffset -= 8; + + switch (*kb) + { + case 1: + case 2: + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+168-(p->look_ang>>1),looking_arc+201-gun_pos, + SHOTGUN+2,-128,o,pal); + case 0: + case 6: + case 7: + case 8: + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+146-(p->look_ang>>1),looking_arc+202-gun_pos, + SHOTGUN,gs,o,pal); + guniqhudid = 0; + break; + case 3: + case 4: + case 5: + case 9: + case 10: + case 11: + case 12: + if (*kb > 1 && *kb < 5) + { + gun_pos -= 40; + weapon_xoffset += 20; + + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+194-gun_pos, + SHOTGUN+1+((*(kb)-1)>>1),-128,o,pal); + } + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+158-(p->look_ang>>1),looking_arc+220-gun_pos, + SHOTGUN+3,gs,o,pal); + guniqhudid = 0; + break; + case 13: + case 14: + case 15: + guniqhudid = cw; + G_DrawWeaponTile(32+weapon_xoffset+166-(p->look_ang>>1),looking_arc+210-gun_pos, + SHOTGUN+4,gs,o,pal); + guniqhudid = 0; + break; + case 16: + case 17: + case 18: + case 19: + guniqhudid = cw; + G_DrawWeaponTile(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+5,gs,o,pal); + guniqhudid = 0; + break; + case 20: + case 21: + case 22: + case 23: + guniqhudid = cw; + G_DrawWeaponTile(64+weapon_xoffset+176-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+6,gs,o,pal); + guniqhudid = 0; + break; + case 24: + case 25: + case 26: + case 27: + guniqhudid = cw; + G_DrawWeaponTile(64+weapon_xoffset+170-(p->look_ang>>1),looking_arc+196-gun_pos, + SHOTGUN+5,gs,o,pal); + guniqhudid = 0; + break; + case 28: + case 29: + case 30: + guniqhudid = cw; + G_DrawWeaponTile(32+weapon_xoffset+156-(p->look_ang>>1),looking_arc+206-gun_pos, + SHOTGUN+4,gs,o,pal); + guniqhudid = 0; + break; + } + } + break; + + + case CHAINGUN_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + if (*kb > 0) + gun_pos -= sintable[(*kb)<<7]>>12; + + if (*kb > 0 && sprite[p->i].pal != 1) weapon_xoffset += 1-(rand()&3); + + G_DrawWeaponTile(weapon_xoffset+168-(p->look_ang>>1),looking_arc+260-gun_pos, + CHAINGUN,gs,o,pal); + switch (*kb) + { + case 0: + G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1,gs,o,pal); + break; + default: + if (*kb > *aplWeaponFireDelay[CHAINGUN_WEAPON] && *kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]) + { + i = 0; + if (sprite[p->i].pal != 1) i = rand()&7; + G_DrawWeaponTile(i+weapon_xoffset-4+140-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-4)/5),gs,o,pal); + if (sprite[p->i].pal != 1) i = rand()&7; + G_DrawWeaponTile(i+weapon_xoffset-4+184-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-4)/5),gs,o,pal); + } + if (*kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]-4) + { + i = rand()&7; + G_DrawWeaponTile(i+weapon_xoffset-4+162-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, + CHAINGUN+5+((*kb-2)/5),gs,o,pal); + G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1+((*kb)>>1),gs,o,pal); + } + else G_DrawWeaponTile(weapon_xoffset+178-(p->look_ang>>1),looking_arc+233-gun_pos, + CHAINGUN+1,gs,o,pal); + break; + } + } + break; + + case PISTOL_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) + { + static int16_t kb_frames[] = {0,1,2}; + int32_t l = 195-12+weapon_xoffset; + + if ((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) + l -= 3; + + guniqhudid = cw; + G_DrawWeaponTile((l-(p->look_ang>>1)),(looking_arc+244-gun_pos),FIRSTGUN+kb_frames[*kb>2?0:*kb],gs,2,pal); + guniqhudid = 0; + } + else + { + + if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-17) + { + guniqhudid = cw; + G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+230-gun_pos,FIRSTGUN+4,gs,o,pal); + guniqhudid = 0; + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-12) + { + G_DrawWeaponTile(244-((*kb)<<3)-(p->look_ang>>1),looking_arc+130-gun_pos+((*kb)<<4),FIRSTGUN+6,gs,o,pal); + guniqhudid = cw; + G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + guniqhudid = 0; + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-7) + { + G_DrawWeaponTile(124+((*kb)<<1)-(p->look_ang>>1),looking_arc+430-gun_pos-((*kb)<<3),FIRSTGUN+6,gs,o,pal); + guniqhudid = cw; + G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + guniqhudid = 0; + } + + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-4) + { + G_DrawWeaponTile(184-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+8,gs,o,pal); + guniqhudid = cw; + G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+210-gun_pos,FIRSTGUN+5,gs,o,pal); + guniqhudid = 0; + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-2) + { + G_DrawWeaponTile(164-(p->look_ang>>1),looking_arc+245-gun_pos,FIRSTGUN+8,gs,o,pal); + guniqhudid = cw; + G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o,pal); + guniqhudid = 0; + } + else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]) + { + guniqhudid = cw; + G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+5,gs,o,pal); + guniqhudid = 0; + } + + } + } + + break; + case HANDBOMB_WEAPON: + { + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + guniqhudid = cw; + if ((*kb)) + { + if ((*kb) < (*aplWeaponTotalTime[p->curr_weapon])) + { + + static char throw_frames[] + = {0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2}; + + if ((*kb) < 7) + gun_pos -= 10*(*kb); //D + else if ((*kb) < 12) + gun_pos += 20*((*kb)-10); //U + else if ((*kb) < 20) + gun_pos -= 9*((*kb)-14); //D + + G_DrawWeaponTile(weapon_xoffset+190-(p->look_ang>>1),looking_arc+250-gun_pos,HANDTHROW+throw_frames[(*kb)],gs,o,pal); + } + } + else + G_DrawWeaponTile(weapon_xoffset+190-(p->look_ang>>1),looking_arc+260-gun_pos,HANDTHROW,gs,o,pal); + guniqhudid = 0; + } + } + break; + + case HANDREMOTE_WEAPON: + { + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + static char remote_frames[] = {0,1,1,2,1,1,0,0,0,0,0}; + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + weapon_xoffset = -48; + guniqhudid = cw; + if ((*kb)) + G_DrawWeaponTile(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE+remote_frames[(*kb)],gs,o,pal); + else + G_DrawWeaponTile(weapon_xoffset+150-(p->look_ang>>1),looking_arc+258-gun_pos,HANDREMOTE,gs,o,pal); + guniqhudid = 0; + } + } + break; + + case DEVISTATOR_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + + if ((*kb) < (*aplWeaponTotalTime[DEVISTATOR_WEAPON]+1) && (*kb) > 0) + { + static char cycloidy[] = {0,4,12,24,12,4,0}; + + i = ksgn((*kb)>>2); + + if (p->hbomb_hold_delay) + { + guniqhudid = cw; + G_DrawWeaponTile((cycloidy[*kb]>>1)+weapon_xoffset+268-(p->look_ang>>1),cycloidy[*kb]+looking_arc+238-gun_pos,DEVISTATOR+i,-32,o,pal); + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); + guniqhudid = 0; + } + else + { + guniqhudid = cw<<1; + G_DrawWeaponTile(-(cycloidy[*kb]>>1)+weapon_xoffset+30-(p->look_ang>>1),cycloidy[*kb]+looking_arc+240-gun_pos,DEVISTATOR+i,-32,o|4,pal); + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); + guniqhudid = 0; + } + } + else + { + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+268-(p->look_ang>>1),looking_arc+238-gun_pos,DEVISTATOR,gs,o,pal); + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+30-(p->look_ang>>1),looking_arc+240-gun_pos,DEVISTATOR,gs,o|4,pal); + guniqhudid = 0; + } + } + break; + + case FREEZE_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + if ((*kb) < (aplWeaponTotalTime[p->curr_weapon][snum]+1) && (*kb) > 0) + { + static char cat_frames[] = { 0,0,1,1,2,2 }; + + if (sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + looking_arc += rand()&3; + } + gun_pos -= 16; + guniqhudid = 0; + G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE+2,-32,o,pal); + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+235-gun_pos,FREEZE+3+cat_frames[*kb%6],-32,o,pal); + guniqhudid = 0; + } + else + { + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+210-(p->look_ang>>1),looking_arc+261-gun_pos,FREEZE,gs,o,pal); + guniqhudid = 0; + } + } + break; + + case GROW_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + weapon_xoffset += 28; + looking_arc += 18; + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + { + if ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum] && (*kb) > 0) + { + if (sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + gun_pos += (rand()&3); + } + + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, + o,2); + + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER-1,gs,o,pal); + guniqhudid = 0; + } + else + { + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+2, + 16-(sintable[p->random_club_frame&2047]>>10), + o,2); + + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER-2,gs,o,pal); + guniqhudid = 0; + } + } + } + break; + + case SHRINKER_WEAPON: + + Gv_SetVar(g_iReturnVarID,0,g_player[screenpeek].ps->i,screenpeek); + X_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1); + if (Gv_GetVar(g_iReturnVarID,g_player[screenpeek].ps->i,screenpeek) == 0) + { + weapon_xoffset += 28; + looking_arc += 18; + if (sprite[p->i].pal == 1) + pal = 1; + else if (p->cursectnum >= 0) + pal = sector[p->cursectnum].floorpal; + else pal = 0; + if (((*kb) > 0) && ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum])) + { + if (sprite[p->i].pal != 1) + { + weapon_xoffset += rand()&3; + gun_pos += (rand()&3); + } + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+3+((*kb)&3),-32, + o,0); + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+1,gs,o,pal); + guniqhudid = 0; + + } + else + { + guniqhudid = cw<<1; + G_DrawWeaponTile(weapon_xoffset+184-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER+2, + 16-(sintable[p->random_club_frame&2047]>>10), + o,0); + guniqhudid = cw; + G_DrawWeaponTile(weapon_xoffset+188-(p->look_ang>>1), + looking_arc+240-gun_pos,SHRINKER,gs,o,pal); + guniqhudid = 0; + } + } + break; + + } + } + P_DisplaySpitAnim(snum); + +} + +#define TURBOTURNTIME (TICRATE/8) // 7 +#define NORMALTURN 15 +#define PREAMBLETURN 5 +#define NORMALKEYMOVE 40 +#define MAXVEL ((NORMALKEYMOVE*2)+10) +#define MAXSVEL ((NORMALKEYMOVE*2)+10) +#define MAXANGVEL 127 +#define MAXHORIZ 127 + +int32_t g_myAimMode = 0, g_myAimStat = 0, g_oldAimStat = 0; +int32 mouseyaxismode = -1; +int32_t jump_input = 0; + +void getinput(int32_t snum) +{ + int32_t j, daang; + static ControlInfo info[2]; + int32 tics; + boolean running; + int32 turnamount; + int32 keymove; + int32 momx = 0,momy = 0; + DukePlayer_t *p = g_player[snum].ps; + + if ((p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause)) || (numplayers > 1 && totalclock < 10)) + // HACK: kill getinput() for the first 10 tics of a new map in multi + { + if (!(p->gm&MODE_MENU)) + CONTROL_GetInput(&info[0]); + memset(&info[1], 0, sizeof(info[1])); + loc.fvel = vel = 0; + loc.svel = svel = 0; + loc.avel = angvel = 0; + loc.horz = horiz = 0; + loc.bits = (((int32_t)g_gameQuit)<team)<<6; + loc.extbits |= (1<<7); + return; + } + + if (ud.mouseaiming) + g_myAimMode = BUTTON(gamefunc_Mouse_Aiming); + else + { + g_oldAimStat = g_myAimStat; + g_myAimStat = BUTTON(gamefunc_Mouse_Aiming); + if (g_myAimStat > g_oldAimStat) + { + g_myAimMode ^= 1; + P_DoQuote(44+g_myAimMode,p); + } + } + + { + int32 i; + if (g_myAimMode) i = analog_lookingupanddown; + else i = ud.config.MouseAnalogueAxes[1]; + + if (i != mouseyaxismode) + { + CONTROL_MapAnalogAxis(1, i, controldevice_mouse); + mouseyaxismode = i; + } + } + + CONTROL_GetInput(&info[0]); + + if (ud.config.MouseDeadZone) + { + if (info[0].dpitch > 0) + { + if (info[0].dpitch > ud.config.MouseDeadZone) + info[0].dpitch -= ud.config.MouseDeadZone; + else info[0].dpitch = 0; + } + else if (info[0].dpitch < 0) + { + if (info[0].dpitch < -ud.config.MouseDeadZone) + info[0].dpitch += ud.config.MouseDeadZone; + else info[0].dpitch = 0; + } + if (info[0].dyaw > 0) + { + if (info[0].dyaw > ud.config.MouseDeadZone) + info[0].dyaw -= ud.config.MouseDeadZone; + else info[0].dyaw = 0; + } + else if (info[0].dyaw < 0) + { + if (info[0].dyaw < -ud.config.MouseDeadZone) + info[0].dyaw += ud.config.MouseDeadZone; + else info[0].dyaw = 0; + } + } + + if (ud.config.MouseBias) + { + if (klabs(info[0].dyaw) > klabs(info[0].dpitch)) + info[0].dpitch /= ud.config.MouseBias; + else info[0].dyaw /= ud.config.MouseBias; + } + + tics = totalclock-lastcontroltime; + lastcontroltime = totalclock; + + if (multiflag == 1) + { + loc.bits = 1<on_ground) + jump_input = 4; + + loc.bits = (jump_input > 0 || BUTTON(gamefunc_Jump))<curr_weapon][snum] & WEAPON_SEMIAUTO && BUTTON(gamefunc_Fire)) + CONTROL_ClearButton(gamefunc_Fire); + + if (jump_input > 0) + jump_input--; + + j=0; + + if (BUTTON(gamefunc_Weapon_1)) + j = 1; + if (BUTTON(gamefunc_Weapon_2)) + j = 2; + if (BUTTON(gamefunc_Weapon_3)) + j = 3; + if (BUTTON(gamefunc_Weapon_4)) + j = 4; + if (BUTTON(gamefunc_Weapon_5)) + j = 5; + if (BUTTON(gamefunc_Weapon_6)) + j = 6; + if (BUTTON(gamefunc_Weapon_7)) + j = 7; + if (BUTTON(gamefunc_Weapon_8)) + j = 8; + if (BUTTON(gamefunc_Weapon_9)) + j = 9; + if (BUTTON(gamefunc_Weapon_10)) + j = 10; + if (BUTTON(gamefunc_Previous_Weapon)) + j = 11; + if (BUTTON(gamefunc_Next_Weapon)) + j = 12; + + loc.bits |= j<>6; + + if (running) + { + turnamount = NORMALTURN<<1; + keymove = NORMALKEYMOVE<<1; + } + else + { + turnamount = NORMALTURN; + keymove = NORMALKEYMOVE; + } + + if (BUTTON(gamefunc_Strafe)) + { + if (BUTTON(gamefunc_Turn_Left) && !(g_player[snum].ps->movement_lock&4)) + svel -= -keymove; + if (BUTTON(gamefunc_Turn_Right) && !(g_player[snum].ps->movement_lock&8)) + svel -= keymove; + } + else + { + if (BUTTON(gamefunc_Turn_Left)) + { + turnheldtime += tics; + if (turnheldtime>=TURBOTURNTIME) + angvel -= turnamount; + else + angvel -= PREAMBLETURN; + } + else if (BUTTON(gamefunc_Turn_Right)) + { + turnheldtime += tics; + if (turnheldtime>=TURBOTURNTIME) + angvel += turnamount; + else + angvel += PREAMBLETURN; + } + else + turnheldtime=0; + } + + if (BUTTON(gamefunc_Strafe_Left) && !(g_player[snum].ps->movement_lock&4)) + svel += keymove; + if (BUTTON(gamefunc_Strafe_Right) && !(g_player[snum].ps->movement_lock&8)) + svel += -keymove; + if (BUTTON(gamefunc_Move_Forward) && !(g_player[snum].ps->movement_lock&1)) + vel += keymove; + if (BUTTON(gamefunc_Move_Backward) && !(g_player[snum].ps->movement_lock&2)) + vel += -keymove; + + if (vel < -MAXVEL) vel = -MAXVEL; + if (vel > MAXVEL) vel = MAXVEL; + if (svel < -MAXSVEL) svel = -MAXSVEL; + if (svel > MAXSVEL) svel = MAXSVEL; + if (angvel < -MAXANGVEL) angvel = -MAXANGVEL; + if (angvel > MAXANGVEL) angvel = MAXANGVEL; + if (horiz < -MAXHORIZ) horiz = -MAXHORIZ; + if (horiz > MAXHORIZ) horiz = MAXHORIZ; + + loc.extbits = 0; + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEFORWARD]) + loc.extbits |= BUTTON(gamefunc_Move_Forward) || (vel > 0); + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_MOVEBACKWARD]) + loc.extbits |= (BUTTON(gamefunc_Move_Backward) || (vel < 0))<<1; + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFELEFT]) + loc.extbits |= (BUTTON(gamefunc_Strafe_Left) || (svel > 0))<<2; + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_STRAFERIGHT]) + loc.extbits |= (BUTTON(gamefunc_Strafe_Right) || (svel < 0))<<3; + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNLEFT]) + loc.extbits |= BUTTON(gamefunc_Turn_Left)<<4; + if (apScriptGameEvent[EVENT_PROCESSINPUT] || apScriptGameEvent[EVENT_TURNRIGHT]) + loc.extbits |= BUTTON(gamefunc_Turn_Right)<<5; + // used for changing team + loc.extbits |= (g_player[snum].pteam != g_player[snum].ps->team)<<6; + + if (ud.scrollmode && ud.overhead_on) + { + ud.folfvel = vel; + ud.folavel = angvel; + loc.fvel = 0; + loc.svel = 0; + loc.avel = 0; + loc.horz = 0; + return; + } + + if (numplayers > 1) + daang = myang; + else daang = p->ang; + + momx = mulscale9(vel,sintable[(daang+2560)&2047]); + momy = mulscale9(vel,sintable[(daang+2048)&2047]); + + momx += mulscale9(svel,sintable[(daang+2048)&2047]); + momy += mulscale9(svel,sintable[(daang+1536)&2047]); + + momx += fricxv; + momy += fricyv; loc.fvel = momx; loc.svel = momy; @@ -3451,7 +3451,7 @@ void P_ProcessInput(int32_t snum) p->sbs = 0; shrunk = (s->yrepeat < 32); - getzrange(p->posx,p->posy,p->posz,psect,&cz,&hz,&fz,&lz,163L,CLIPMASK0); + getzrange((vec3_t *)p,psect,&cz,&hz,&fz,&lz,163L,CLIPMASK0); getzsofslope(psect,p->posx,p->posy,&p->truecz,&p->truefz); j = p->truefz; @@ -3811,8 +3811,7 @@ void P_ProcessInput(int32_t snum) s->zvel = -348; } - clipmove(&p->posx,&p->posy, - &p->posz,&p->cursectnum, + clipmove((vec3_t *)p,&p->cursectnum, 0,0,164L,(4L<<8),(4L<<8),CLIPMASK0); // p->bobcounter += 32; } @@ -3828,7 +3827,7 @@ void P_ProcessInput(int32_t snum) updatesector(p->posx,p->posy,&p->cursectnum); - pushmove(&p->posx,&p->posy,&p->posz,&p->cursectnum,128L,(4L<<8),(20L<<8),CLIPMASK0); + pushmove((vec3_t *)p,&p->cursectnum,128L,(4L<<8),(20L<<8),CLIPMASK0); if (fz > cz+(16<<8) && s->pal != 1) p->rotscrnang = (p->dead_flag + ((fz+p->posz)>>7))&2047; @@ -4557,8 +4556,7 @@ HORIZONLY: changespritesect(pi,p->cursectnum); } else - j = clipmove(&p->posx,&p->posy, - &p->posz,&p->cursectnum, + j = clipmove((vec3_t *)p,&p->cursectnum, p->posxv,p->posyv,164L,(4L<<8),i,CLIPMASK0); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) @@ -4584,7 +4582,15 @@ HORIZONLY: } // RBG*** - setsprite(pi,p->posx,p->posy,p->posz+PHEIGHT); + + { + vec3_t vect; + + vect.x = p->posx; + vect.y = p->posy; + vect.z = p->posz+PHEIGHT; + setsprite(pi,&vect); + } if (psectlotag < 3) { @@ -4607,7 +4613,7 @@ HORIZONLY: changespritesect(pi,p->cursectnum); if (ud.clipping == 0) - j = (pushmove(&p->posx,&p->posy,&p->posz,&p->cursectnum,164L,(4L<<8),(4L<<8),CLIPMASK0) < 0 && A_GetFurthestAngle(pi,8) < 512); + j = (pushmove((vec3_t *)p,&p->cursectnum,164L,(4L<<8),(4L<<8),CLIPMASK0) < 0 && A_GetFurthestAngle(pi,8) < 512); else j = 0; if (ud.clipping == 0) @@ -4928,36 +4934,39 @@ SHOOTINCODE: case TRIPBOMB_WEAPON: if (p->ammo_amount[p->curr_weapon] > 0) { - int32_t sx,sy,sz; - int16_t sect,hw,hitsp; - - hitscan(p->posx, p->posy, p->posz, + hitdata_t hitinfo; + hitscan((const vec3_t *)p, p->cursectnum, sintable[(p->ang+512)&2047], sintable[p->ang&2047], (100-p->horiz-p->horizoff)*32, - §, &hw, &hitsp, &sx, &sy, &sz,CLIPMASK1); + &hitinfo,CLIPMASK1); - if (sect < 0 || hitsp >= 0) + if (hitinfo.hitsect < 0 || hitinfo.hitsprite >= 0) break; - if (hw >= 0 && sector[sect].lotag > 2) + if (hitinfo.hitwall >= 0 && sector[hitinfo.hitsect].lotag > 2) break; - if (hw >= 0 && wall[hw].overpicnum >= 0) - if (wall[hw].overpicnum == BIGFORCE) + if (hitinfo.hitwall >= 0 && wall[hitinfo.hitwall].overpicnum >= 0) + if (wall[hitinfo.hitwall].overpicnum == BIGFORCE) break; - j = headspritesect[sect]; + j = headspritesect[hitinfo.hitsect]; while (j >= 0) { if (sprite[j].picnum == TRIPBOMB && - klabs(sprite[j].z-sz) < (12<<8) && ((sprite[j].x-sx)*(sprite[j].x-sx)+(sprite[j].y-sy)*(sprite[j].y-sy)) < (290*290)) + klabs(sprite[j].z-hitinfo.pos.z) < (12<<8) && + ((sprite[j].x-hitinfo.pos.x)*(sprite[j].x-hitinfo.pos.x)+ + (sprite[j].y-hitinfo.pos.y)*(sprite[j].y-hitinfo.pos.y)) < (290*290)) break; j = nextspritesect[j]; } - if (j == -1 && hw >= 0 && (wall[hw].cstat&16) == 0) - if ((wall[hw].nextsector >= 0 && sector[wall[hw].nextsector].lotag <= 2) || (wall[hw].nextsector == -1 && sector[sect].lotag <= 2)) - if (((sx-p->posx)*(sx-p->posx) + (sy-p->posy)*(sy-p->posy)) < (290*290)) + if (j == -1 && hitinfo.hitwall >= 0 && (wall[hitinfo.hitwall].cstat&16) == 0) + if ((wall[hitinfo.hitwall].nextsector >= 0 && + sector[wall[hitinfo.hitwall].nextsector].lotag <= 2) || + (wall[hitinfo.hitwall].nextsector == -1 && sector[hitinfo.hitsect].lotag <= 2)) + if (((hitinfo.pos.x-p->posx)*(hitinfo.pos.x-p->posx) + + (hitinfo.pos.y-p->posy)*(hitinfo.pos.y-p->posy)) < (290*290)) { p->posz = p->oposz; p->poszv = 0; @@ -5403,7 +5412,7 @@ void computergetinput(int32_t snum, input_t *syn) int32_t i, j, k, l, x1, y1, z1, x2, y2, z2, x3, y3, z3, dx, dy; int32_t dist, daang, zang, fightdist, damyang, damysect; int32_t startsect, endsect, splc, send, startwall, endwall; - int16_t dasect, dawall, daspr; + hitdata_t hitinfo; DukePlayer_t *p = g_player[snum].ps; walltype *wal; @@ -5421,9 +5430,9 @@ void computergetinput(int32_t snum, input_t *syn) damysect = sprite[p->i].sectnum; if ((numplayers >= 2) && (snum == myconnectindex)) { - x1 = myx; - y1 = myy; - z1 = myz+PHEIGHT; + x1 = my.x; + y1 = my.y; + z1 = my.z+PHEIGHT; damyang = myang; damysect = mycursectnum; } @@ -5513,11 +5522,14 @@ void computergetinput(int32_t snum, input_t *syn) } else { - hitscan(sprite[j].x,sprite[j].y,sprite[j].z,sprite[j].sectnum, + hitscan((const vec3_t *)&sprite[j],sprite[j].sectnum, mulscale14(sprite[j].xvel,sintable[(sprite[j].ang+512)&2047]), mulscale14(sprite[j].xvel,sintable[sprite[j].ang&2047]), (int32_t)sprite[j].zvel, - &dasect,&dawall,&daspr,&x3,&y3,&z3,CLIPMASK1); + &hitinfo,CLIPMASK1); + x3 = hitinfo.pos.x; + y3 = hitinfo.pos.y; + z3 = hitinfo.pos.z; } } } @@ -5538,8 +5550,15 @@ void computergetinput(int32_t snum, input_t *syn) if (p->curr_weapon == RPG_WEAPON) { - hitscan(x1,y1,z1-PHEIGHT,damysect,sintable[(damyang+512)&2047],sintable[damyang&2047], - (100-p->horiz-p->horizoff)*32,&dasect,&dawall,&daspr,&x3,&y3,&z3,CLIPMASK1); + vec3_t vect; + vect.x = x1; + vect.y = y1; + vect.z = z1-PHEIGHT; + hitscan((const vec3_t *)&vect,damysect,sintable[(damyang+512)&2047],sintable[damyang&2047], + (100-p->horiz-p->horizoff)*32,&hitinfo,CLIPMASK1); + x3 = hitinfo.pos.x; + y3 = hitinfo.pos.y; + z3 = hitinfo.pos.z; if ((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1) < 2560*2560) syn->bits &= ~BIT(SK_FIRE); } @@ -5782,18 +5801,19 @@ void computergetinput(int32_t snum, input_t *syn) } } - x3 = p->posx; - y3 = p->posy; - z3 = p->posz; - dasect = p->cursectnum; - i = clipmove(&x3,&y3,&z3,&dasect,p->posxv,p->posyv,164L,4L<<8,4L<<8,CLIPMASK0); - if (!i) { - x3 = p->posx; - y3 = p->posy; - z3 = p->posz+(24<<8); - dasect = p->cursectnum; - i = clipmove(&x3,&y3,&z3,&dasect,p->posxv,p->posyv,164L,4L<<8,4L<<8,CLIPMASK0); + vec3_t vect; + int16_t dasect = p->cursectnum; + Bmemcpy(&vect,p,sizeof(vec3_t)); + + i = clipmove(&vect,&dasect,p->posxv,p->posyv,164L,4L<<8,4L<<8,CLIPMASK0); + if (!i) + { + Bmemcpy(&vect,p,sizeof(vec3_t)); + vect.z += (24<<8); + dasect = p->cursectnum; + i = clipmove(&vect,&dasect,p->posxv,p->posyv,164L,4L<<8,4L<<8,CLIPMASK0); + } } if (i) { diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index b7deda43d..ccf644e07 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1629,10 +1629,10 @@ void clearfifo(void) void Net_ResetPrediction(void) { - myx = omyx = g_player[myconnectindex].ps->posx; - myy = omyy = g_player[myconnectindex].ps->posy; - myz = omyz = g_player[myconnectindex].ps->posz; - myxvel = myyvel = myzvel = 0; + my.x = omy.x = g_player[myconnectindex].ps->posx; + my.y = omy.y = g_player[myconnectindex].ps->posy; + my.z = omy.z = g_player[myconnectindex].ps->posz; + myvel.x = myvel.y = myvel.z = 0; myang = omyang = g_player[myconnectindex].ps->ang; myhoriz = omyhoriz = g_player[myconnectindex].ps->horiz; myhorizoff = omyhorizoff = g_player[myconnectindex].ps->horizoff; diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 619f2028e..5cd79c266 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -188,7 +188,7 @@ int32_t isanearoperator(int32_t lotag) return 0; } -inline int32_t CheckPlayerInSector(int32_t sect) +inline int32_t G_CheckPlayerInSector(int32_t sect) { int32_t i = connecthead; for (;i>=0;i=connectpoint2[i]) @@ -329,8 +329,8 @@ void G_DoSectorAnimations(void) g_player[p].ps->poszv = 0; if (p == myconnectindex) { - myz += v; - myzvel = 0; + my.z += v; + myvel.z = 0; myzbak[((movefifoplc-1)&(MOVEFIFOSIZ-1))] = g_player[p].ps->posz; } } @@ -2456,7 +2456,7 @@ void A_DamageObject(int32_t i,int32_t sn) SA = (sprite[sn].ang+1024)&2047; sprite[i].xvel = -(sprite[sn].extra<<2); j = SECT; - pushmove(&SX,&SY,&SZ,&j,128L,(4L<<8),(4L<<8),CLIPMASK0); + pushmove((vec3_t *)&sprite[i],&j,128L,(4L<<8),(4L<<8),CLIPMASK0); if (j != SECT && j >= 0 && j < MAXSECTORS) changespritesect(i,j); } @@ -3201,38 +3201,41 @@ CHECKINV1: } } -int32_t A_CheckHitSprite(int32_t i,int16_t *hitsp) +int32_t A_CheckHitSprite(int32_t i, int16_t *hitsp) { - int32_t sx,sy,sz,zoff; - int16_t sect,hw; + hitdata_t hitinfo; + int32_t zoff = 0; if (A_CheckEnemySprite(&sprite[i])) zoff = (42<<8); else if (PN == APLAYER) zoff = (39<<8); - else zoff = 0; - hitscan(SX,SY,SZ-zoff,SECT, + SZ -= zoff; + hitscan((const vec3_t *)&sprite[i],SECT, sintable[(SA+512)&2047], sintable[SA&2047], - 0,§,&hw,hitsp,&sx,&sy,&sz,CLIPMASK1); + 0,&hitinfo,CLIPMASK1); - if (hw >= 0 && (wall[hw].cstat&16) && A_CheckEnemySprite(&sprite[i])) + SZ += zoff; + *hitsp = hitinfo.hitsprite; + if (hitinfo.hitwall >= 0 && (wall[hitinfo.hitwall].cstat&16) && A_CheckEnemySprite(&sprite[i])) return((1<<30)); - return (FindDistance2D(sx-SX,sy-SY)); + return (FindDistance2D(hitinfo.pos.x-SX,hitinfo.pos.y-SY)); } static int32_t hitawall(DukePlayer_t *p,int16_t *hitw) { - int32_t sx,sy,sz; - int16_t sect,hs; + hitdata_t hitinfo; - hitscan(p->posx,p->posy,p->posz,p->cursectnum, + hitscan((const vec3_t *)p,p->cursectnum, sintable[(p->ang+512)&2047], sintable[p->ang&2047], - 0,§,hitw,&hs,&sx,&sy,&sz,CLIPMASK0); + 0,&hitinfo,CLIPMASK0); - return (FindDistance2D(sx-p->posx,sy-p->posy)); + *hitw = hitinfo.hitwall; + + return (FindDistance2D(hitinfo.pos.x-p->posx,hitinfo.pos.y-p->posy)); } diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index 970b8ae78..550f710b8 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -513,10 +513,11 @@ int32_t A_PlaySound(uint32_t num, int32_t i) return 0; } { - vec3_t davector; - Bmemcpy(&davector,&sprite[i],sizeof(intptr_t) * 3); + /* + vec3_t davector; + Bmemcpy(&davector,&sprite[i],sizeof(intptr_t) * 3); */ // OSD_Printf("x: %d y: %d z: %d\n",davector.x,davector.y,davector.z); - return S_PlaySoundXYZ(num,i, &davector); + return S_PlaySoundXYZ(num,i, (vec3_t *)&sprite[i]); } }