//------------------------------------------------------------------------- /* Copyright (C) 1996, 2003 - 3D Realms Entertainment Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) Copyright (C) 2020 - Christoph Oelckers This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition Duke Nukem 3D is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Original Source: 1996 - Todd Replogle Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms EDuke enhancements integrated: 04/13/2003 - Matt Saettler Note: EDuke source was in transition. Changes are in-progress in the source as it is released. This file contains parts of DukeGDX by Alexander Makarov-[M210] (m210-2007@mail.ru) */ //------------------------------------------------------------------------- #include "ns.h" #include "global.h" #include "actors.h" #include "names.h" BEGIN_DUKE_NS struct FireProj { int x, y, z; int xv, yv, zv; }; static TMap fire; //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- bool ceilingspace_d(int sectnum) { if( (sector[sectnum].ceilingstat&1) && sector[sectnum].ceilingpal == 0 ) { switch(sector[sectnum].ceilingpicnum) { case MOONSKY1: case BIGORBIT1: return 1; } } return 0; } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- bool floorspace_d(int sectnum) { if( (sector[sectnum].floorstat&1) && sector[sectnum].ceilingpal == 0 ) { switch(sector[sectnum].floorpicnum) { case MOONSKY1: case BIGORBIT1: return 1; } } return 0; } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void addweapon_d(struct player_struct *p, int weapon) { if ( p->gotweapon[weapon] == 0 ) { p->gotweapon.Set(weapon); if(weapon == SHRINKER_WEAPON) p->gotweapon.Set(GROW_WEAPON); } p->random_club_frame = 0; if (p->holster_weapon == 0) { p->weapon_pos = -1; p->last_weapon = p->curr_weapon; } else { p->weapon_pos = 10; p->holster_weapon = 0; p->last_weapon = -1; } p->kickback_pic = 0; #ifdef EDUKE if(p->curr_weapon != weapon) { short snum; snum = sprite[p->i].yvel; SetGameVarID(g_iWeaponVarID,weapon, p->i, snum); if (p->curr_weapon >= 0) { SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[weapon][snum], p->i, snum); } else { SetGameVarID(g_iWorksLikeVarID, -1, p->i, snum); } SetGameVarID(g_iReturnVarID, 0, -1, snum); OnEvent(EVENT_CHANGEWEAPON, p->i, snum, -1); if (GetGameVarID(g_iReturnVarID, -1, snum) == 0) { p->curr_weapon = weapon; } } #else p->curr_weapon = weapon; #endif switch (weapon) { case KNEE_WEAPON: case TRIPBOMB_WEAPON: case HANDREMOTE_WEAPON: case HANDBOMB_WEAPON: break; case SHOTGUN_WEAPON: spritesound(SHOTGUN_COCK, p->i); break; case PISTOL_WEAPON: spritesound(INSERT_CLIP, p->i); break; default: spritesound(SELECT_WEAPON, p->i); break; } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- bool ifsquished(int i, int p) { if (isRR()) return false; // this function is a no-op in RR's source. bool squishme = false; if (sprite[i].picnum == APLAYER && ud.clipping) return false; auto& sc = sector[sprite[i].sectnum]; int floorceildist = sc.floorz - sc.ceilingz; if (sc.lotag != ST_23_SWINGING_DOOR) { if (sprite[i].pal == 1) squishme = floorceildist < (32 << 8) && (sc.lotag & 32768) == 0; else squishme = floorceildist < (12 << 8); } if (squishme) { FTA(QUOTE_SQUISHED, &ps[p]); if (badguy(&sprite[i])) sprite[i].xvel = 0; if (sprite[i].pal == 1) { hittype[i].picnum = SHOTSPARK1; hittype[i].extra = 1; return false; } return true; } return false; } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4) { spritetype* s, * sj; walltype* wal; int d, q, x1, y1; int sectcnt, sectend, dasect, startwall, endwall, nextsect; short j, p, x, nextj, sect; static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC }; short tempshort[MAXSECTORS]; // originally hijacked a global buffer which is bad. Q: How many do we really need? RedNukem says 64. s = &sprite[i]; if(s->picnum == RPG && s->xrepeat < 11) goto SKIPWALLCHECK; if(s->picnum != SHRINKSPARK) { tempshort[0] = s->sectnum; dasect = s->sectnum; sectcnt = 0; sectend = 1; do { dasect = tempshort[sectcnt++]; if (((sector[dasect].ceilingz - s->z) >> 8) < r) { d = abs(wall[sector[dasect].wallptr].x - s->x) + abs(wall[sector[dasect].wallptr].y - s->y); if (d < r) checkhitceiling(dasect); else { // ouch... d = abs(wall[wall[wall[sector[dasect].wallptr].point2].point2].x - s->x) + abs(wall[wall[wall[sector[dasect].wallptr].point2].point2].y - s->y); if (d < r) checkhitceiling(dasect); } } startwall = sector[dasect].wallptr; endwall = startwall + sector[dasect].wallnum; for (x = startwall, wal = &wall[startwall]; x < endwall; x++, wal++) if ((abs(wal->x - s->x) + abs(wal->y - s->y)) < r) { nextsect = wal->nextsector; if (nextsect >= 0) { for (dasect = sectend - 1; dasect >= 0; dasect--) if (tempshort[dasect] == nextsect) break; if (dasect < 0) tempshort[sectend++] = nextsect; } x1 = (((wal->x + wall[wal->point2].x) >> 1) + s->x) >> 1; y1 = (((wal->y + wall[wal->point2].y) >> 1) + s->y) >> 1; updatesector(x1, y1, §); if (sect >= 0 && cansee(x1, y1, s->z, sect, s->x, s->y, s->z, s->sectnum)) checkhitwall(i, x, wal->x, wal->y, s->z, s->picnum); } } while (sectcnt < sectend); } SKIPWALLCHECK: q = -(16 << 8) + (krand() & ((32 << 8) - 1)); for (x = 0; x < 7; x++) { j = headspritestat[statlist[x]]; while (j >= 0) { nextj = nextspritestat[j]; sj = &sprite[j]; if (isWorldTour()) { if (sprite[s->owner].picnum == APLAYER && sj->picnum == APLAYER && ud.coop != 0 && ud.ffire == 0 && s->owner != j) continue; if (s->picnum == FLAMETHROWERFLAME && ((sprite[s->owner].picnum == FIREFLY && sj->picnum == FIREFLY) || (sprite[s->owner].picnum == BOSS5 && sj->picnum == BOSS5))) continue; } if (x == 0 || x >= 5 || AFLAMABLE(sj->picnum)) { if (s->picnum != SHRINKSPARK || (sj->cstat & 257)) if (dist(s, sj) < r) { if (badguy(sj) && !cansee(sj->x, sj->y, sj->z + q, sj->sectnum, s->x, s->y, s->z + q, s->sectnum)) goto BOLT; checkhitsprite(j, i); } } else if (sj->extra >= 0 && sj != s && (sj->picnum == TRIPBOMB || badguy(sj) || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL || (sj->cstat & 257) || sj->picnum == DUKELYINGDEAD)) { if (s->picnum == SHRINKSPARK && sj->picnum != SHARK && (j == s->owner || sj->xrepeat < 24)) { j = nextj; continue; } if (s->picnum == MORTER && j == s->owner) { j = nextj; continue; } if (sj->picnum == APLAYER) sj->z -= PHEIGHT; d = dist(s, sj); if (sj->picnum == APLAYER) sj->z += PHEIGHT; if (d < r && cansee(sj->x, sj->y, sj->z - (8 << 8), sj->sectnum, s->x, s->y, s->z - (12 << 8), s->sectnum)) { hittype[j].ang = getangle(sj->x - s->x, sj->y - s->y); if (s->picnum == RPG && sj->extra > 0) hittype[j].picnum = RPG; else if (!isWorldTour()) { if (s->picnum == SHRINKSPARK) hittype[j].picnum = SHRINKSPARK; else hittype[j].picnum = RADIUSEXPLOSION; } else { if (s->picnum == SHRINKSPARK || s->picnum == FLAMETHROWERFLAME) hittype[j].picnum = s->picnum; else if (s->picnum != FIREBALL || sprite[s->owner].picnum != APLAYER) { if (s->picnum == LAVAPOOL) hittype[j].picnum = FLAMETHROWERFLAME; else hittype[j].picnum = RADIUSEXPLOSION; } else hittype[j].picnum = FLAMETHROWERFLAME; } if (s->picnum != SHRINKSPARK && (!isWorldTour() && s->picnum != LAVAPOOL)) { if (d < r / 3) { if (hp4 == hp3) hp4++; hittype[j].extra = hp3 + (krand() % (hp4 - hp3)); } else if (d < 2 * r / 3) { if (hp3 == hp2) hp3++; hittype[j].extra = hp2 + (krand() % (hp3 - hp2)); } else if (d < r) { if (hp2 == hp1) hp2++; hittype[j].extra = hp1 + (krand() % (hp2 - hp1)); } if (sprite[j].picnum != TANK && sprite[j].picnum != ROTATEGUN && sprite[j].picnum != RECON && sprite[j].picnum != BOSS1 && sprite[j].picnum != BOSS2 && sprite[j].picnum != BOSS3 && sprite[j].picnum != BOSS4) { if (sj->xvel < 0) sj->xvel = 0; sj->xvel += (s->extra << 2); } if (sj->picnum == PODFEM1 || sj->picnum == FEM1 || sj->picnum == FEM2 || sj->picnum == FEM3 || sj->picnum == FEM4 || sj->picnum == FEM5 || sj->picnum == FEM6 || sj->picnum == FEM7 || sj->picnum == FEM8 || sj->picnum == FEM9 || sj->picnum == FEM10 || sj->picnum == STATUE || sj->picnum == STATUEFLASH || sj->picnum == SPACEMARINE || sj->picnum == QUEBALL || sj->picnum == STRIPEBALL) checkhitsprite(j, i); } else if (s->extra == 0) hittype[j].extra = 0; if (sj->picnum != RADIUSEXPLOSION && s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) { if (sj->picnum == APLAYER) { p = sj->yvel; if (isWorldTour() && hittype[j].picnum == FLAMETHROWERFLAME && sprite[s->owner].picnum == APLAYER) { ps[p].numloogs = -1 - s->yvel; } if (ps[p].newowner >= 0) { clearcamera(&ps[p]); } } hittype[j].owner = s->owner; } } } BOLT: j = nextj; } } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- int movesprite_d(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype) { int daz, h, oldx, oldy; short retval, dasectnum, cd; char bg; bg = badguy(&sprite[spritenum]); if (sprite[spritenum].statnum == 5 || (bg && sprite[spritenum].xrepeat < 4)) { sprite[spritenum].x += (xchange * TICSPERFRAME) >> 2; sprite[spritenum].y += (ychange * TICSPERFRAME) >> 2; sprite[spritenum].z += (zchange * TICSPERFRAME) >> 2; if (bg) setsprite(spritenum, sprite[spritenum].x, sprite[spritenum].y, sprite[spritenum].z); return 0; } dasectnum = sprite[spritenum].sectnum; daz = sprite[spritenum].z; h = ((tilesiz[sprite[spritenum].picnum].y * sprite[spritenum].yrepeat) << 1); daz -= h; if (bg) { oldx = sprite[spritenum].x; oldy = sprite[spritenum].y; if (sprite[spritenum].xrepeat > 60) retval = clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype); else { if (sprite[spritenum].picnum == LIZMAN) cd = 292; #if 0 // TRANSITIONAL the needed infrastructure for this is too different for now else if ((actortype[sprite[spritenum].picnum] & 3)) #else else if (A_CheckSpriteFlags(spritenum, SFLAG_BADGUY)) #endif cd = sprite[spritenum].clipdist << 2; else cd = 192; retval = clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), cd, (4 << 8), (4 << 8), cliptype); } // conditional code from hell... if (dasectnum < 0 || (dasectnum >= 0 && ((hittype[spritenum].actorstayput >= 0 && hittype[spritenum].actorstayput != dasectnum) || ((sprite[spritenum].picnum == BOSS2) && sprite[spritenum].pal == 0 && sector[dasectnum].lotag != 3) || ((sprite[spritenum].picnum == BOSS1 || sprite[spritenum].picnum == BOSS2) && sector[dasectnum].lotag == ST_1_ABOVE_WATER) || (sector[dasectnum].lotag == ST_1_ABOVE_WATER && (sprite[spritenum].picnum == LIZMAN || (sprite[spritenum].picnum == LIZTROOP && sprite[spritenum].zvel == 0))) )) ) { sprite[spritenum].x = oldx; sprite[spritenum].y = oldy; if (sector[dasectnum].lotag == ST_1_ABOVE_WATER && sprite[spritenum].picnum == LIZMAN) sprite[spritenum].ang = (krand()&2047); else if ((hittype[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) dasectnum = 0; return (16384+dasectnum); } if ((retval&49152) >= 32768 && (hittype[spritenum].cgg==0)) sprite[spritenum].ang += 768; } else { if (sprite[spritenum].statnum == 4) retval = clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 8L, (4 << 8), (4 << 8), cliptype); else retval = clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), (int)(sprite[spritenum].clipdist << 2), (4 << 8), (4 << 8), cliptype); } if (dasectnum >= 0) if ((dasectnum != sprite[spritenum].sectnum)) changespritesect(spritenum, dasectnum); daz = sprite[spritenum].z + ((zchange * TICSPERFRAME) >> 3); if ((daz > hittype[spritenum].ceilingz) && (daz <= hittype[spritenum].floorz)) sprite[spritenum].z = daz; else if (retval == 0) return(16384 + dasectnum); return(retval); } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void lotsofmoney_d(spritetype *s, short n) { lotsofstuff(s, n, MONEY); } void lotsofmail_d(spritetype *s, short n) { lotsofstuff(s, n, MAIL); } void lotsofpaper_d(spritetype *s, short n) { lotsofstuff(s, n, PAPER); } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void guts_d(spritetype* s, short gtype, short n, short p) { int gutz, floorz; int i=0, j; int sx, sy; uint8_t pal; if (badguy(s) && s->xrepeat < 16) sx = sy = 8; else sx = sy = 32; gutz = s->z - (8 << 8); floorz = getflorzofslope(s->sectnum, s->x, s->y); if (gutz > (floorz - (8 << 8))) gutz = floorz - (8 << 8); if (s->picnum == COMMANDER) gutz -= (24 << 8); if (badguy(s) && s->pal == 6) pal = 6; else pal = 0; for (j = 0; j < n; j++) { // RANDCORRECT version from RR. int a = krand() & 2047; int r1 = krand(); int r2 = krand(); int r3 = krand(); int r4 = krand(); int r5 = krand(); // TRANSITIONAL: owned by a player??? i = EGS(s->sectnum, s->x + (r5 & 255) - 128, s->y + (r4 & 255) - 128, gutz - (r3 & 8191), gtype, -32, sx, sy, a, 48 + (r2 & 31), -512 - (r1 & 2047), ps[p].i, 5); if (sprite[i].picnum == JIBS2) { sprite[i].xrepeat >>= 2; sprite[i].yrepeat >>= 2; } if (pal != 0) sprite[i].pal = pal; } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void gutsdir_d(spritetype* s, short gtype, short n, short p) { int gutz, floorz; short i, j; char sx, sy; if (badguy(s) && s->xrepeat < 16) sx = sy = 8; else sx = sy = 32; gutz = s->z - (8 << 8); floorz = getflorzofslope(s->sectnum, s->x, s->y); if (gutz > (floorz - (8 << 8))) gutz = floorz - (8 << 8); if (s->picnum == COMMANDER) gutz -= (24 << 8); for (j = 0; j < n; j++) { int a = krand() & 2047; int r1 = krand(); int r2 = krand(); // TRANSITIONAL: owned by a player??? i = EGS(s->sectnum, s->x, s->y, gutz, gtype, -32, sx, sy, a, 256 + (r2 & 127), -512 - (r1 & 2047), ps[p].i, 5); } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void movefta_d(void) { int x, px, py, sx, sy; short i, j, p, psect, ssect, nexti; spritetype* s; i = headspritestat[STAT_ZOMBIEACTOR]; while (i >= 0) { nexti = nextspritestat[i]; s = &sprite[i]; p = findplayer(s, &x); ssect = psect = s->sectnum; if (sprite[ps[p].i].extra > 0) { if (x < 30000) { hittype[i].timetosleep++; if (hittype[i].timetosleep >= (x >> 8)) { if (badguy(s)) { px = ps[p].oposx + 64 - (krand() & 127); py = ps[p].oposy + 64 - (krand() & 127); updatesector(px, py, &psect); if (psect == -1) { i = nexti; continue; } sx = s->x + 64 - (krand() & 127); sy = s->y + 64 - (krand() & 127); updatesector(px, py, &ssect); if (ssect == -1) { i = nexti; continue; } int r1 = krand(); int r2 = krand(); j = cansee(sx, sy, s->z - (r2 % (52 << 8)), s->sectnum, px, py, ps[p].oposz - (r1 % (32 << 8)), ps[p].cursectnum); } else { int r1 = krand(); int r2 = krand(); j = cansee(s->x, s->y, s->z - ((r2 & 31) << 8), s->sectnum, ps[p].oposx, ps[p].oposy, ps[p].oposz - ((r1 & 31) << 8), ps[p].cursectnum); } if (j) switch(s->picnum) { case RUBBERCAN: case EXPLODINGBARREL: case WOODENHORSE: case HORSEONSIDE: case CANWITHSOMETHING: case CANWITHSOMETHING2: case CANWITHSOMETHING3: case CANWITHSOMETHING4: case FIREBARREL: case FIREVASE: case NUKEBARREL: case NUKEBARRELDENTED: case NUKEBARRELLEAKED: case TRIPBOMB: if (sector[s->sectnum].ceilingstat&1) s->shade = sector[s->sectnum].ceilingshade; else s->shade = sector[s->sectnum].floorshade; hittype[i].timetosleep = 0; changespritestat(i, STAT_STANDABLE); break; default: hittype[i].timetosleep = 0; check_fta_sounds(i); changespritestat(i, STAT_ACTOR); break; } else hittype[i].timetosleep = 0; } } if (badguy(s)) { if (sector[s->sectnum].ceilingstat & 1) s->shade = sector[s->sectnum].ceilingshade; else s->shade = sector[s->sectnum].floorshade; } } i = nexti; } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- int ifhitsectors_d(int sectnum) { int i = headspritestat[STAT_MISC]; while(i >= 0) { if (sprite[i].picnum == EXPLOSION2 && sectnum == sprite[i].sectnum) return i; i = nextspritestat[i]; } return -1; } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- int ifhitbyweapon_d(int sn) { short j, p; spritetype* npc; if (hittype[sn].extra >= 0) { if (sprite[sn].extra >= 0) { npc = &sprite[sn]; if (npc->picnum == APLAYER) { if (ud.god && hittype[sn].picnum != SHRINKSPARK) return -1; p = npc->yvel; j = hittype[sn].owner; if (j >= 0 && sprite[j].picnum == APLAYER && ud.coop == 1 && ud.ffire == 0) return -1; npc->extra -= hittype[sn].extra; if (j >= 0) { if (npc->extra <= 0 && hittype[sn].picnum != FREEZEBLAST) { npc->extra = 0; ps[p].wackedbyactor = j; if (sprite[hittype[sn].owner].picnum == APLAYER && p != sprite[hittype[sn].owner].yvel) { // yvel contains player ID ps[p].frag_ps = sprite[j].yvel; } hittype[sn].owner = ps[p].i; } } switch(hittype[sn].picnum) { case RADIUSEXPLOSION: case RPG: case HYDRENT: case HEAVYHBOMB: case SEENINE: case OOZFILTER: case EXPLODINGBARREL: ps[p].posxv += hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047]) << 2; ps[p].posyv += hittype[sn].extra*(sintable[hittype[sn].ang&2047]) << 2; break; default: ps[p].posxv += hittype[sn].extra*(sintable[(hittype[sn].ang+512)&2047]) << 1; ps[p].posyv += hittype[sn].extra*(sintable[hittype[sn].ang&2047]) << 1; break; } } else { if (hittype[sn].extra == 0) if (hittype[sn].picnum == SHRINKSPARK && npc->xrepeat < 24) return -1; if (isWorldTour() && hittype[sn].picnum == FIREFLY && npc->xrepeat < 48) { if (hittype[sn].picnum != RADIUSEXPLOSION && hittype[sn].picnum != RPG) return -1; } npc->extra -= hittype[sn].extra; if (npc->picnum != RECON && npc->owner >= 0 && sprite[npc->owner].statnum < MAXSTATUS) npc->owner = hittype[sn].owner; } hittype[sn].extra = -1; return hittype[sn].picnum; } } if (ud.multimode < 2 || !isWorldTour() || hittype[sn].picnum != FLAMETHROWERFLAME || hittype[sn].extra >= 0 || sprite[sn].extra > 0 || sprite[sn].picnum != APLAYER || ps[sprite[sn].yvel].numloogs > 0 || hittype[sn].owner < 0) { hittype[sn].extra = -1; return -1; } else { p = sprite[sn].yvel; sprite[sn].extra = 0; ps[p].wackedbyactor = (short)hittype[sn].owner; if (sprite[hittype[sn].owner].picnum == APLAYER && p != hittype[sn].owner) ps[p].frag_ps = (short)hittype[sn].owner; hittype[sn].owner = ps[p].i; hittype[sn].extra = -1; return FLAMETHROWERFLAME; } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void movefallers_d(void) { short i, nexti, sect, j; spritetype* s; int x; i = headspritestat[STAT_FALLER]; while (i >= 0) { nexti = nextspritestat[i]; s = &sprite[i]; sect = s->sectnum; if (hittype[i].temp_data[0] == 0) { s->z -= (16 << 8); hittype[i].temp_data[1] = s->ang; x = s->extra; j = ifhitbyweapon(i); if (j >= 0) { if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) { if (s->extra <= 0) { hittype[i].temp_data[0] = 1; j = headspritestat[12]; while (j >= 0) { if (sprite[j].hitag == sprite[i].hitag) { hittype[j].temp_data[0] = 1; sprite[j].cstat &= (65535 - 64); if (sprite[j].picnum == CEILINGSTEAM || sprite[j].picnum == STEAM) sprite[j].cstat |= 32768; } j = nextspritestat[j]; } } } else { hittype[i].extra = 0; s->extra = x; } } s->ang = hittype[i].temp_data[1]; s->z += (16 << 8); } else if (hittype[i].temp_data[0] == 1) { if (s->lotag > 0) { s->lotag-=3; if (s->lotag <= 0) { s->xvel = (32 + (krand() & 63)); s->zvel = -(1024 + (krand() & 1023)); } } else { if (s->xvel > 0) { s->xvel -= 8; ssp(i,CLIPMASK0); } if (floorspace(s->sectnum)) x = 0; else { if (ceilingspace(s->sectnum)) x = gc / 6; else x = gc; } if (s->z < (sector[sect].floorz - FOURSLEIGHT)) { s->zvel += x; if (s->zvel > 6144) s->zvel = 6144; s->z += s->zvel; } if ((sector[sect].floorz - s->z) < (16 << 8)) { j = 1 + (krand() & 7); for (x = 0; x < j; x++) RANDOMSCRAP(s, i); deletesprite(i); } } } i = nexti; } } //--------------------------------------------------------------------------- // // split out of movestandables // //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // // Duke only // //--------------------------------------------------------------------------- static void movetripbomb(int i) { auto s = &sprite[i]; int j, x; int lTripBombControl = GetGameVar("TRIPBOMB_CONTROL", TRIPBOMB_TRIPWIRE, -1, -1); if (lTripBombControl & TRIPBOMB_TIMER) { // we're on a timer.... if (s->extra >= 0) { s->extra--; if (s->extra == 0) { hittype[i].temp_data[2] = 16; spritesound(LASERTRIP_ARMING, i); } } } if (hittype[i].temp_data[2] > 0) { hittype[i].temp_data[2]--; if (hittype[i].temp_data[2] == 8) { spritesound(LASERTRIP_EXPLODE, i); for (j = 0; j < 5; j++) RANDOMSCRAP(s, i); x = s->extra; hitradius(i, tripbombblastradius, x >> 2, x >> 1, x - (x >> 2), x); j = spawn(i, EXPLOSION2); sprite[j].ang = s->ang; sprite[j].xvel = 348; ssp(j, CLIPMASK0); j = headspritestat[5]; while (j >= 0) { if (sprite[j].picnum == LASERLINE && s->hitag == sprite[j].hitag) sprite[j].xrepeat = sprite[j].yrepeat = 0; j = nextspritestat[j]; } deletesprite(i); } return; } else { x = s->extra; s->extra = 1; int16_t l = s->ang; j = ifhitbyweapon(i); if (j >= 0) { hittype[i].temp_data[2] = 16; } s->extra = x; s->ang = l; } if (hittype[i].temp_data[0] < 32) { findplayer(s, &x); if (x > 768) hittype[i].temp_data[0]++; else if (hittype[i].temp_data[0] > 16) hittype[i].temp_data[0]++; } if (hittype[i].temp_data[0] == 32) { int16_t l = s->ang; s->ang = hittype[i].temp_data[5]; hittype[i].temp_data[3] = s->x; hittype[i].temp_data[4] = s->y; s->x += sintable[(hittype[i].temp_data[5] + 512) & 2047] >> 9; s->y += sintable[(hittype[i].temp_data[5]) & 2047] >> 9; s->z -= (3 << 8); setsprite(i, s->x, s->y, s->z); int16_t m; x = hitasprite(i, &m); hittype[i].lastvx = x; s->ang = l; int k = 0; if (lTripBombControl & TRIPBOMB_TRIPWIRE) { // we're on a trip wire while (x > 0) { j = spawn(i, LASERLINE); setsprite(j, sprite[j].x, sprite[j].y, sprite[j].z); sprite[j].hitag = s->hitag; hittype[j].temp_data[1] = sprite[j].z; s->x += sintable[(hittype[i].temp_data[5] + 512) & 2047] >> 4; s->y += sintable[(hittype[i].temp_data[5]) & 2047] >> 4; if (x < 1024) { sprite[j].xrepeat = x >> 5; break; } x -= 1024; } } hittype[i].temp_data[0]++; s->x = hittype[i].temp_data[3]; s->y = hittype[i].temp_data[4]; s->z += (3 << 8); setsprite(i, s->x, s->y, s->z); hittype[i].temp_data[3] = 0; if (m >= 0 && lTripBombControl & TRIPBOMB_TRIPWIRE) { hittype[i].temp_data[2] = 13; spritesound(LASERTRIP_ARMING, i); } else hittype[i].temp_data[2] = 0; } if (hittype[i].temp_data[0] == 33) { hittype[i].temp_data[1]++; hittype[i].temp_data[3] = s->x; hittype[i].temp_data[4] = s->y; s->x += sintable[(hittype[i].temp_data[5] + 512) & 2047] >> 9; s->y += sintable[(hittype[i].temp_data[5]) & 2047] >> 9; s->z -= (3 << 8); setsprite(i, s->x, s->y, s->z); int16_t m; x = hitasprite(i, &m); s->x = hittype[i].temp_data[3]; s->y = hittype[i].temp_data[4]; s->z += (3 << 8); setsprite(i, s->x, s->y, s->z); if (hittype[i].lastvx != x && lTripBombControl & TRIPBOMB_TRIPWIRE) { hittype[i].temp_data[2] = 13; spritesound(LASERTRIP_ARMING, i); } } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- static void movecrack(int i) { auto s = &sprite[i]; auto t = &hittype[i].temp_data[0]; if (s->hitag > 0) { t[0] = s->cstat; t[1] = s->ang; int j = ifhitbyweapon(i); if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) { j = headspritestat[STAT_STANDABLE]; while (j >= 0) { if (s->hitag == sprite[j].hitag && (sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE)) if (sprite[j].shade != -32) sprite[j].shade = -32; j = nextspritestat[j]; } detonate(i, EXPLOSION2); } else { s->cstat = t[0]; s->ang = t[1]; s->extra = 0; } } } //--------------------------------------------------------------------------- // // Duke only // //--------------------------------------------------------------------------- static void movefireext(int i) { int j = ifhitbyweapon(i); if (j == -1) return; auto s = &sprite[i]; auto t = &hittype[i].temp_data[0]; for (int k = 0; k < 16; k++) { j = EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z - (krand() % (48 << 8)), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (sprite[i].zvel >> 2), i, 5); sprite[j].pal = 2; } spawn(i, EXPLOSION2); spritesound(PIPEBOMB_EXPLODE, i); spritesound(GLASS_HEAVYBREAK, i); if (s->hitag > 0) { j = headspritestat[6]; while (j >= 0) { if (s->hitag == sprite[j].hitag && (sprite[j].picnum == OOZFILTER || sprite[j].picnum == SEENINE)) if (sprite[j].shade != -32) sprite[j].shade = -32; j = nextspritestat[j]; } int x = s->extra; spawn(i, EXPLOSION2); hitradius(i, pipebombblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); spritesound(PIPEBOMB_EXPLODE, i); detonate(i, EXPLOSION2); } else { hitradius(i, seenineblastradius, 10, 15, 20, 25); deletesprite(i); } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- static void moveviewscreen(int i) { auto s = &sprite[i]; if (s->xrepeat == 0) deletesprite(i); else { int x; findplayer(s, &x); if (x < 2048) { #if 0 if (SP == 1) camsprite = i; #endif } else if (camsprite != -1 && hittype[i].temp_data[0] == 1) { camsprite = -1; s->yvel = 0; hittype[i].temp_data[0] = 0; } } } //--------------------------------------------------------------------------- // // Duke only // //--------------------------------------------------------------------------- static void movesidebolt(int i) { auto s = &sprite[i]; auto t = &hittype[i].temp_data[0]; int x; int sect = s->sectnum; auto p = findplayer(s, &x); if (x > 20480) return; CLEAR_THE_BOLT2: if (t[2]) { t[2]--; return; } if ((s->xrepeat | s->yrepeat) == 0) { s->xrepeat = t[0]; s->yrepeat = t[1]; } if ((krand() & 8) == 0) { t[0] = s->xrepeat; t[1] = s->yrepeat; t[2] = global_random & 4; s->xrepeat = s->yrepeat = 0; goto CLEAR_THE_BOLT2; } s->picnum++; #if 0 // content of l was undefined. if (l & 1) s->cstat ^= 2; #endif if ((krand() & 1) && sector[sect].floorpicnum == HURTRAIL) spritesound(SHORT_CIRCUIT, i); if (s->picnum == SIDEBOLT1 + 4) s->picnum = SIDEBOLT1; } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- static void movebolt(int i) { auto s = &sprite[i]; auto t = &hittype[i].temp_data[0]; int x; int sect = s->sectnum; auto p = findplayer(s, &x); if (x > 20480) return; if (t[3] == 0) t[3] = sector[sect].floorshade; CLEAR_THE_BOLT: if (t[2]) { t[2]--; sector[sect].floorshade = 20; sector[sect].ceilingshade = 20; return; } if ((s->xrepeat | s->yrepeat) == 0) { s->xrepeat = t[0]; s->yrepeat = t[1]; } else if ((krand() & 8) == 0) { t[0] = s->xrepeat; t[1] = s->yrepeat; t[2] = global_random & 4; s->xrepeat = s->yrepeat = 0; goto CLEAR_THE_BOLT; } s->picnum++; int l = global_random & 7; s->xrepeat = l + 8; if (l & 1) s->cstat ^= 2; if (s->picnum == (BOLT1+1) && (krand()&7) == 0 && sector[sect].floorpicnum == HURTRAIL) spritesound(SHORT_CIRCUIT,i); if (s->picnum==BOLT1+4) s->picnum=BOLT1; if (s->picnum & 1) { sector[sect].floorshade = 0; sector[sect].ceilingshade = 0; } else { sector[sect].floorshade = 20; sector[sect].ceilingshade = 20; } } //--------------------------------------------------------------------------- // // this has been broken up into lots of smaller subfunctions // //--------------------------------------------------------------------------- void movestandables_d(void) { int nexti; for (int i = headspritestat[STAT_STANDABLE]; i >= 0; i = nexti) { nexti = nextspritestat[i]; auto s = &sprite[i]; int picnum = s->picnum; if (s->sectnum < 0) { deletesprite(i); continue; } hittype[i].bposx = s->x; hittype[i].bposy = s->y; hittype[i].bposz = s->z; if (picnum >= CRANE && picnum <= CRANE +3) { movecrane(i, CRANE); } else if (picnum >= WATERFOUNTAIN && picnum <= WATERFOUNTAIN + 3) { movefountain(i, WATERFOUNTAIN); } else if (AFLAMABLE(picnum)) { moveflammable(i, TIRE, BOX, BLOODPOOL); } else if (picnum == TRIPBOMB) { movetripbomb(i); } else if (picnum >= CRACK1 && picnum <= CRACK1 + 3) { movecrack(i); } else if (picnum == FIREEXT) { movefireext(i); } else if (picnum == OOZFILTER || picnum == SEENINE || picnum == SEENINEDEAD || picnum == (SEENINEDEAD + 1)) { moveooz(i, SEENINE, SEENINEDEAD, OOZFILTER, EXPLOSION2); } else if (picnum == MASTERSWITCH) { movemasterswitch(i, SEENINE, OOZFILTER); } else if (picnum == VIEWSCREEN || picnum == VIEWSCREEN2) { moveviewscreen(i); } else if (picnum == TRASH) { movetrash(i); } else if (picnum >= SIDEBOLT1 && picnum <= SIDEBOLT1 + 3) { movesidebolt(i); } else if (picnum >= BOLT1 && picnum <= BOLT1 + 3) { movebolt(i); } else if (picnum == WATERDRIP) { movewaterdrip(i, WATERDRIP); } else if (picnum == DOORSHOCK) { movedoorshock(i); } else if (picnum == TOUCHPLATE) { movetouchplate(i, TOUCHPLATE); } else if (isIn(picnum, CANWITHSOMETHING, CANWITHSOMETHING2, CANWITHSOMETHING3, CANWITHSOMETHING4)) { movecanwithsomething(i); } else if (isIn(picnum, EXPLODINGBARREL, WOODENHORSE, HORSEONSIDE, FLOORFLAME, FIREBARREL, FIREVASE, NUKEBARREL, NUKEBARRELDENTED, NUKEBARRELLEAKED, TOILETWATER, RUBBERCAN, STEAM, CEILINGSTEAM, WATERBUBBLEMAKER)) { int x; int p = findplayer(s, &x); execute(i, p, x); } } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void moveweapons_d(void) { int j, k, nexti, p; int dax, day, daz, x, ll; unsigned int qq; spritetype* s; for (int i = headspritestat[STAT_PROJECTILE]; i >= 0; i = nexti) { nexti = nextspritestat[i]; s = &sprite[i]; if (s->sectnum < 0) { deletesprite(i); continue; } hittype[i].bposx = s->x; hittype[i].bposy = s->y; hittype[i].bposz = s->z; switch(s->picnum) { case RADIUSEXPLOSION: case KNEE: deletesprite(i); continue; case TONGUE: movetongue(i, TONGUE, INNERJAW); continue; case FREEZEBLAST: if (s->yvel < 1 || s->extra < 2 || (s->xvel|s->zvel) == 0) { j = spawn(i,TRANSPORTERSTAR); sprite[j].pal = 1; sprite[j].xrepeat = 32; sprite[j].yrepeat = 32; deletesprite(i); continue; } case SHRINKSPARK: case RPG: case FIRELASER: case SPIT: case COOLEXPLOSION1: if (s->picnum == COOLEXPLOSION1) if (!S_CheckSoundPlaying(i, WIERDSHOT_FLY)) A_PlaySound(WIERDSHOT_FLY, i); p = -1; if (s->picnum == RPG && sector[s->sectnum].lotag == 2) { k = s->xvel>>1; ll = s->zvel>>1; } else { k = s->xvel; ll = s->zvel; } dax = s->x; day = s->y; daz = s->z; getglobalz(i); qq = CLIPMASK1; switch(s->picnum) { case RPG: if (hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) { j = spawn(i,SMALLSMOKE); sprite[j].z += (1 << 8); } break; case FIREBALL: if (isWorldTour()) { if (sector[s->sectnum].lotag == 2) { deletesprite(i); continue; } if (sprite[s->owner].picnum != FIREBALL) { if (hittype[i].temp_data[0] >= 1 && hittype[i].temp_data[0] < 6) { float siz = 1.0f - (hittype[i].temp_data[0] * 0.2f); int trail = hittype[i].temp_data[1]; j = hittype[i].temp_data[1] = spawn(i, FIREBALL); auto spr = &sprite[j]; spr->xvel = sprite[i].xvel; spr->yvel = sprite[i].yvel; spr->zvel = sprite[i].zvel; if (hittype[i].temp_data[0] > 1) { FireProj* proj = fire.CheckKey(trail); if (proj != nullptr) { spr->x = proj->x; spr->y = proj->y; spr->z = proj->z; spr->xvel = proj->xv; spr->yvel = proj->yv; spr->zvel = proj->zv; } } spr->yrepeat = spr->xrepeat = (short)(sprite[i].xrepeat * siz); spr->cstat = sprite[i].cstat; spr->extra = 0; FireProj proj = { spr->x, spr->y, spr->z, spr->xvel, spr->yvel, spr->zvel }; fire.Insert(j, proj); changespritestat((short)j, (short)4); } hittype[i].temp_data[0]++; } if (s->zvel < 15000) s->zvel += 200; } break; } j = movesprite(i, (k*(sintable[(s->ang+512)&2047]))>>14, (k*(sintable[s->ang&2047]))>>14,ll,qq); if (s->picnum == RPG && s->yvel >= 0) if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256) j = 49152|s->yvel; if (s->sectnum < 0) { deletesprite(i); continue; } if ((j&49152) != 49152 && s->picnum != FREEZEBLAST) { if (s->z < hittype[i].ceilingz) { j = 16384|(s->sectnum); s->zvel = -1; } else if ((s->z > hittype[i].floorz && sector[s->sectnum].lotag != 1) || (s->z > hittype[i].floorz+(16 << 8) && sector[s->sectnum].lotag == 1)) { j = 16384|(s->sectnum); if (sector[s->sectnum].lotag != 1) s->zvel = 1; } } if (s->picnum == FIRELASER) { for(k=-3;k<2;k++) { x = EGS(s->sectnum, s->x+((k*sintable[(s->ang+512)&2047])>>9), s->y+((k*sintable[s->ang&2047])>>9), s->z+((k*ksgn(s->zvel))*abs(s->zvel/24)),FIRELASER,-40+(k << 2), s->xrepeat,s->yrepeat,0,0,0,s->owner,5); sprite[x].cstat = 128; sprite[x].pal = s->pal; } } else if (s->picnum == SPIT) if (s->zvel < 6144) s->zvel += gc-112; if (j != 0) { if (s->picnum == COOLEXPLOSION1) { if ((j&49152) == 49152 && sprite[j&(MAXSPRITES-1)].picnum != APLAYER) { continue; } s->xvel = 0; s->zvel = 0; } if ((j&49152) == 49152) { j &= (MAXSPRITES-1); if (s->picnum == FREEZEBLAST && sprite[j].pal == 1) if (badguy(&sprite[j]) || sprite[j].picnum == APLAYER) { j = spawn(i,TRANSPORTERSTAR); sprite[j].pal = 1; sprite[j].xrepeat = 32; sprite[j].yrepeat = 32; deletesprite(i); continue; } checkhitsprite(j,i); if (sprite[j].picnum == APLAYER) { p = sprite[j].yvel; spritesound(PISTOL_BODYHIT,j); if (s->picnum == SPIT) { ps[p].q16horiz += 32 << FRACBITS; ps[p].return_to_center = 8; if (ps[p].loogcnt == 0) { if (!A_CheckSoundPlaying(ps[p].i, DUKE_LONGTERM_PAIN)) A_PlaySound(DUKE_LONGTERM_PAIN, ps[p].i); j = 3+(krand()&3); ps[p].numloogs = j; ps[p].loogcnt = 24*4; for(x=0;x < j;x++) { ps[p].loogiex[x] = krand()%xdim; ps[p].loogiey[x] = krand()%ydim; } } } } } else if ((j&49152) == 32768) { j &= (MAXWALLS-1); if (s->picnum != RPG && s->picnum != FREEZEBLAST && s->picnum != SPIT && (wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR)) { k = getangle( wall[wall[j].point2].x-wall[j].x, wall[wall[j].point2].y-wall[j].y); s->ang = ((k << 1) - s->ang)&2047; s->owner = i; spawn(i,TRANSPORTERSTAR); continue; } else { setsprite(i,dax,day,daz); checkhitwall(i,j,s->x,s->y,s->z,s->picnum); if (s->picnum == FREEZEBLAST) { if (wall[j].overpicnum != MIRROR && wall[j].picnum != MIRROR) { s->extra >>= 1; s->yvel--; } k = getangle( wall[wall[j].point2].x-wall[j].x, wall[wall[j].point2].y-wall[j].y); s->ang = ((k << 1) - s->ang)&2047; continue; } } } else if ((j&49152) == 16384) { setsprite(i,dax,day,daz); if (s->zvel < 0) { if (sector[s->sectnum].ceilingstat&1) if (sector[s->sectnum].ceilingpal == 0) { deletesprite(i); continue; } checkhitceiling(s->sectnum); } if (s->picnum == FREEZEBLAST) { bounce(i); ssp(i,qq); s->extra >>= 1; if (s->xrepeat > 8) s->xrepeat -= 2; if (s->yrepeat > 8) s->yrepeat -= 2; s->yvel--; continue; } } if (s->picnum != SPIT) { if (s->picnum == RPG) { k = spawn(i,EXPLOSION2); sprite[k].x = dax; sprite[k].y = day; sprite[k].z = daz; if (s->xrepeat < 10) { sprite[k].xrepeat = 6; sprite[k].yrepeat = 6; } else if ((j&49152) == 16384) { if (s->zvel > 0) spawn(i,EXPLOSION2BOT); else { sprite[k].cstat |= 8; sprite[k].z += (48 << 8); } } } else if (s->picnum == SHRINKSPARK) { spawn(i,SHRINKEREXPLOSION); spritesound(SHRINKER_HIT,i); hitradius(i,shrinkerblastradius,0,0,0,0); } else if (s->picnum != COOLEXPLOSION1 && s->picnum != FREEZEBLAST && s->picnum != FIRELASER) { k = spawn(i,EXPLOSION2); sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat>>1; if ((j&49152) == 16384) { if (s->zvel < 0) { sprite[k].cstat |= 8; sprite[k].z += (72 << 8); } } } if (s->picnum == RPG) { spritesound(RPG_EXPLODE,i); if (s->xrepeat >= 10) { x = s->extra; hitradius(i,rpgblastradius, x>>2,x>>1,x-(x>>2),x); } else { x = s->extra+(global_random&3); hitradius(i,(rpgblastradius>>1),x>>2,x>>1,x-(x>>2),x); } } } if (s->picnum != COOLEXPLOSION1) { deletesprite(i); continue; } } if (s->picnum == COOLEXPLOSION1) { s->shade++; if (s->shade >= 40) { deletesprite(i); continue; } } else if (s->picnum == RPG && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) spawn(i,WATERBUBBLE); break; case SHOTSPARK1: p = findplayer(s,&x); execute(i,p,x); break; } } } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- void movetransports_d(void) { char warpspriteto; short j, k, l, p, sect, sectlotag, nextj, nextk; int ll, onfloorz, q, nexti; for (int i = headspritestat[STAT_TRANSPORT]; i >= 0; i = nexti) { sect = sprite[i].sectnum; sectlotag = sector[sect].lotag; nexti = nextspritestat[i]; if (sprite[i].owner == i) { i = nexti; continue; } onfloorz = hittype[i].temp_data[4]; if (hittype[i].temp_data[0] > 0) hittype[i].temp_data[0]--; j = headspritesect[sect]; while (j >= 0) { nextj = nextspritesect[j]; switch (sprite[j].statnum) { case STAT_PLAYER: // Player if (sprite[j].owner != -1) { p = sprite[j].yvel; ps[p].on_warping_sector = 1; if (ps[p].transporter_hold == 0 && ps[p].jumping_counter == 0) { if (ps[p].on_ground && sectlotag == 0 && onfloorz && ps[p].jetpack_on == 0) { if (sprite[i].pal == 0) { spawn(i, TRANSPORTERBEAM); spritesound(TELEPORTER, i); } for (k = connecthead; k >= 0; k = connectpoint2[k]) if (ps[k].cursectnum == sprite[sprite[i].owner].sectnum) { ps[k].frag_ps = p; sprite[ps[k].i].extra = 0; } ps[p].q16ang = sprite[sprite[i].owner].ang << FRACBITS; if (sprite[sprite[i].owner].owner != sprite[i].owner) { hittype[i].temp_data[0] = 13; hittype[sprite[i].owner].temp_data[0] = 13; ps[p].transporter_hold = 13; } ps[p].bobposx = ps[p].oposx = ps[p].posx = sprite[sprite[i].owner].x; ps[p].bobposy = ps[p].oposy = ps[p].posy = sprite[sprite[i].owner].y; ps[p].oposz = ps[p].posz = sprite[sprite[i].owner].z - PHEIGHT; changespritesect(j, sprite[sprite[i].owner].sectnum); ps[p].cursectnum = sprite[j].sectnum; if (sprite[i].pal == 0) { k = spawn(sprite[i].owner, TRANSPORTERBEAM); spritesound(TELEPORTER, k); } break; } } else if (!(sectlotag == 1 && ps[p].on_ground == 1)) break; if (onfloorz == 0 && abs(sprite[i].z - ps[p].posz) < 6144) if ((ps[p].jetpack_on == 0) || (ps[p].jetpack_on && (PlayerInput(p, SK_JUMP))) || (ps[p].jetpack_on && (PlayerInput(p, SK_CROUCH) ^ !!ps[p].crouch_toggle))) { ps[p].oposx = ps[p].posx += sprite[sprite[i].owner].x - sprite[i].x; ps[p].oposy = ps[p].posy += sprite[sprite[i].owner].y - sprite[i].y; if (ps[p].jetpack_on && (PlayerInput(p, SK_JUMP) || ps[p].jetpack_on < 11)) ps[p].posz = sprite[sprite[i].owner].z - 6144; else ps[p].posz = sprite[sprite[i].owner].z + 6144; ps[p].oposz = ps[p].posz; hittype[ps[p].i].bposx = ps[p].posx; hittype[ps[p].i].bposy = ps[p].posy; hittype[ps[p].i].bposz = ps[p].posz; changespritesect(j, sprite[sprite[i].owner].sectnum); ps[p].cursectnum = sprite[sprite[i].owner].sectnum; break; } k = 0; if (onfloorz && sectlotag == ST_1_ABOVE_WATER && ps[p].on_ground && ps[p].posz > (sector[sect].floorz - (16 << 8)) && (PlayerInput(p, SK_CROUCH) || ps[p].poszv > 2048)) // if( onfloorz && sectlotag == 1 && ps[p].posz > (sector[sect].floorz-(6<<8)) ) { k = 1; if (screenpeek == p) { FX_StopAllSounds(); } if (sprite[ps[p].i].extra > 0) spritesound(DUKE_UNDERWATER, j); ps[p].oposz = ps[p].posz = sector[sprite[sprite[i].owner].sectnum].ceilingz + (7 << 8); ps[p].posxv = 4096 - (krand() & 8192); ps[p].posyv = 4096 - (krand() & 8192); } if (onfloorz && sectlotag == ST_2_UNDERWATER && ps[p].posz < (sector[sect].ceilingz + (6 << 8))) { k = 1; // if( sprite[j].extra <= 0) break; if (screenpeek == p) { FX_StopAllSounds(); } spritesound(DUKE_GASP, j); ps[p].oposz = ps[p].posz = sector[sprite[sprite[i].owner].sectnum].floorz - (7 << 8); ps[p].jumping_toggle = 1; ps[p].jumping_counter = 0; } if (k == 1) { ps[p].oposx = ps[p].posx += sprite[sprite[i].owner].x - sprite[i].x; ps[p].oposy = ps[p].posy += sprite[sprite[i].owner].y - sprite[i].y; if (sprite[sprite[i].owner].owner != sprite[i].owner) ps[p].transporter_hold = -2; ps[p].cursectnum = sprite[sprite[i].owner].sectnum; changespritesect(j, sprite[sprite[i].owner].sectnum); setsprite(ps[p].i, ps[p].posx, ps[p].posy, ps[p].posz + PHEIGHT); setpal(&ps[p]); if ((krand() & 255) < 32) spawn(j, WATERSPLASH2); if (sectlotag == 1) for (l = 0; l < 9; l++) { q = spawn(ps[p].i, WATERBUBBLE); sprite[q].z += krand() & 16383; } } } break; case STAT_ACTOR: switch (sprite[j].picnum) { case SHARK: case COMMANDER: case OCTABRAIN: case GREENSLIME: case GREENSLIME + 1: case GREENSLIME + 2: case GREENSLIME + 3: case GREENSLIME + 4: case GREENSLIME + 5: case GREENSLIME + 6: case GREENSLIME + 7: if (sprite[j].extra > 0) goto JBOLT; } case STAT_PROJECTILE: case STAT_MISC: case STAT_FALLER: case STAT_DUMMYPLAYER: ll = abs(sprite[j].zvel); { warpspriteto = 0; if (ll && sectlotag == 2 && sprite[j].z < (sector[sect].ceilingz + ll)) warpspriteto = 1; if (ll && sectlotag == 1 && sprite[j].z > (sector[sect].floorz - ll)) warpspriteto = 1; if (sectlotag == 0 && (onfloorz || abs(sprite[j].z - sprite[i].z) < 4096)) { if (sprite[sprite[i].owner].owner != sprite[i].owner && onfloorz && hittype[i].temp_data[0] > 0 && sprite[j].statnum != 5) { hittype[i].temp_data[0]++; goto BOLT; } warpspriteto = 1; } if (warpspriteto) switch (sprite[j].picnum) { case TRANSPORTERSTAR: case TRANSPORTERBEAM: case TRIPBOMB: case BULLETHOLE: case WATERSPLASH2: case BURNING: case BURNING2: case FIRE: case FIRE2: case TOILETWATER: case LASERLINE: goto JBOLT; case PLAYERONWATER: if (sectlotag == 2) { sprite[j].cstat &= 32767; break; } default: if (sprite[j].statnum == 5 && !(sectlotag == 1 || sectlotag == 2)) break; case WATERBUBBLE: // if( rnd(192) && sprite[j].picnum == WATERBUBBLE) // break; if (sectlotag > 0) { k = spawn(j, WATERSPLASH2); if (sectlotag == 1 && sprite[j].statnum == 4) { sprite[k].xvel = sprite[j].xvel >> 1; sprite[k].ang = sprite[j].ang; ssp(k, CLIPMASK0); } } switch (sectlotag) { case 0: if (onfloorz) { if (sprite[j].statnum == 4 || (checkcursectnums(sect) == -1 && checkcursectnums(sprite[sprite[i].owner].sectnum) == -1)) { sprite[j].x += (sprite[sprite[i].owner].x - sprite[i].x); sprite[j].y += (sprite[sprite[i].owner].y - sprite[i].y); sprite[j].z -= sprite[i].z - sector[sprite[sprite[i].owner].sectnum].floorz; sprite[j].ang = sprite[sprite[i].owner].ang; hittype[j].bposx = sprite[j].x; hittype[j].bposy = sprite[j].y; hittype[j].bposz = sprite[j].z; if (sprite[i].pal == 0) { k = spawn(i, TRANSPORTERBEAM); spritesound(TELEPORTER, k); k = spawn(sprite[i].owner, TRANSPORTERBEAM); spritesound(TELEPORTER, k); } if (sprite[sprite[i].owner].owner != sprite[i].owner) { hittype[i].temp_data[0] = 13; hittype[sprite[i].owner].temp_data[0] = 13; } changespritesect(j, sprite[sprite[i].owner].sectnum); } } else { sprite[j].x += (sprite[sprite[i].owner].x - sprite[i].x); sprite[j].y += (sprite[sprite[i].owner].y - sprite[i].y); sprite[j].z = sprite[sprite[i].owner].z + 4096; hittype[j].bposx = sprite[j].x; hittype[j].bposy = sprite[j].y; hittype[j].bposz = sprite[j].z; changespritesect(j, sprite[sprite[i].owner].sectnum); } break; case 1: sprite[j].x += (sprite[sprite[i].owner].x - sprite[i].x); sprite[j].y += (sprite[sprite[i].owner].y - sprite[i].y); sprite[j].z = sector[sprite[sprite[i].owner].sectnum].ceilingz + ll; hittype[j].bposx = sprite[j].x; hittype[j].bposy = sprite[j].y; hittype[j].bposz = sprite[j].z; changespritesect(j, sprite[sprite[i].owner].sectnum); break; case 2: sprite[j].x += (sprite[sprite[i].owner].x - sprite[i].x); sprite[j].y += (sprite[sprite[i].owner].y - sprite[i].y); sprite[j].z = sector[sprite[sprite[i].owner].sectnum].floorz - ll; hittype[j].bposx = sprite[j].x; hittype[j].bposy = sprite[j].y; hittype[j].bposz = sprite[j].z; changespritesect(j, sprite[sprite[i].owner].sectnum); break; } break; } } break; } JBOLT: j = nextj; } BOLT:; } } END_DUKE_NS