From 63f45f57d8ff73a508eed2cf6934104e4187b545 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 7 May 2020 22:30:19 +0200 Subject: [PATCH] - separated Duke and RR implementations because the more complex functions would become too messy otherwise. --- source/games/duke/src/actors.cpp | 2574 ++----------------------- source/games/duke/src/actors.h | 37 + source/games/duke/src/actors_d.cpp | 2594 ++++--------------------- source/games/duke/src/actors_r.cpp | 2830 ++++------------------------ source/games/duke/src/e_actors.cpp | 69 +- source/games/duke/src/macros.h | 6 +- source/games/duke/src/names.h | 11 - source/games/duke/src/names_rr.h | 37 +- source/games/duke/src/namesdyn.cpp | 5 +- source/games/duke/src/namesdyn.h | 1 + 10 files changed, 1100 insertions(+), 7064 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 2d0f547d0..acfaa7bf8 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -41,64 +41,99 @@ This file is a combination of code from the following sources: #include "ns.h" #include "global.h" -#include "names.h" +#include "namesdyn.h" BEGIN_DUKE_NS -struct FireProj -{ - int x, y, z; - int xv, yv, zv; -}; - -static TMap fire; - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- +bool ceilingspace_d(int sectnum); +bool ceilingspace_r(int sectnum); +bool floorspace_d(int sectnum); +bool floorspace_r(int sectnum); +void addweapon_d(struct player_struct *p, int weapon); +void addweapon_r(struct player_struct *p, int weapon); +void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4); +void hitradius_r(short i, int r, int hp1, int hp2, int hp3, int hp4); +int movesprite_d(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); +int movesprite_r(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); +void lotsofmoney_d(spritetype *s, short n); +void lotsofmail_d(spritetype *s, short n); +void lotsofpaper_d(spritetype *s, short n); +void lotsoffeathers_r(spritetype *s, short n); +void guts_d(spritetype* s, short gtype, short n, short p); +void guts_r(spritetype* s, short gtype, short n, short p); +void gutsdir_d(spritetype* s, short gtype, short n, short p); +void gutsdir_r(spritetype* s, short gtype, short n, short p); +int ifhitsectors_d(int sectnum); +int ifhitsectors_r(int sectnum); +int ifhitbyweapon_r(int sn); +int ifhitbyweapon_d(int sn); bool ceilingspace(int sectnum) { - if ((sector[sectnum].ceilingstat & 1) && sector[sectnum].ceilingpal == 0) - { - switch (sector[sectnum].ceilingpicnum) - { - case MOONSKY1: - case BIGORBIT1: - return !isRR(); - - case RR_MOONSKY1: - case RR_BIGORBIT1: - return isRR(); - } - } - return 0; + return isRR()? ceilingspace_r(sectnum) : ceilingspace_d(sectnum); } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - bool floorspace(int sectnum) { - if ((sector[sectnum].floorstat & 1) && sector[sectnum].ceilingpal == 0) - { - switch (sector[sectnum].floorpicnum) - { - case MOONSKY1: - case BIGORBIT1: - return !isRR(); + return isRR()? floorspace_r(sectnum) : floorspace_d(sectnum); +} - case RR_MOONSKY1: - case RR_BIGORBIT1: - return !!isRR(); - } - } - return 0; +void addweapon(struct player_struct *p, int weapon) +{ + if (isRR()) addweapon_r(p, weapon); + else addweapon_d(p, weapon); +} + +void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4) +{ + if (isRR()) hitradius_r(i, r, hp1, hp2, hp3, hp4); + else hitradius_d(i, r, hp1, hp2, hp3, hp4); +} + +int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype) +{ + if (isRR()) return movesprite_r(spritenum, xchange, ychange, zchange, cliptype); + else return movesprite_d(spritenum, xchange, ychange, zchange, cliptype); +} + +void lotsofmoney(spritetype *s, short n) +{ + if (isRR()) lotsoffeathers_r(s, n); + else lotsofmoney_d(s, n); +} + +void lotsofmail(spritetype *s, short n) +{ + if (isRR()) lotsoffeathers_r(s, n); + else lotsofmail_d(s, n); +} + +void lotsofpaper(spritetype *s, short n) +{ + if (isRR()) lotsoffeathers_r(s, n); + else lotsofpaper_d(s, n); +} + +void guts(spritetype* s, short gtype, short n, short p) +{ + if (isRR()) guts_r(s, gtype, n, p); + else guts_d(s, gtype, n, p); +} + +void gutsdir(spritetype* s, short gtype, short n, short p) +{ + if (isRR()) gutsdir_r(s, gtype, n, p); + else gutsdir_d(s, gtype, n, p); +} + +int ifhitsectors(int sectnum) +{ + return isRR()? ifhitsectors_r(sectnum) : ifhitsectors_d(sectnum); +} + +int ifhitbyweapon(int sectnum) +{ + return isRR()? ifhitbyweapon_r(sectnum) : ifhitbyweapon_d(sectnum); } //--------------------------------------------------------------------------- @@ -121,124 +156,6 @@ void addammo(short weapon, struct player_struct* p, short amount) // //--------------------------------------------------------------------------- -void addweapon(struct player_struct* p, int weapon) -{ - short cw = p->curr_weapon; - if (p->OnMotorcycle || p->OnBoat) - { - p->gotweapon.Set(weapon); - if (weapon == SHRINKER_WEAPON) - { - p->gotweapon.Set(GROW_WEAPON); - p->ammo_amount[GROW_WEAPON] = 1; - } - else if (weapon == RPG_WEAPON) - { - p->gotweapon.Set(RA16_WEAPON); - } - else if (weapon == RA15_WEAPON) - { - p->ammo_amount[RA15_WEAPON] = 1; - } - return; - } - - if (p->gotweapon[weapon] == 0) - { - p->gotweapon.Set(weapon); - if (weapon == SHRINKER_WEAPON) - { - p->gotweapon.Set(GROW_WEAPON); - if (isRRRA()) p->ammo_amount[GROW_WEAPON] = 1; - } - if (isRRRA()) - { - if (weapon == RPG_WEAPON) - { - p->gotweapon.Set(RA16_WEAPON); - } - if (weapon == RA15_WEAPON) - { - p->ammo_amount[RA15_WEAPON] = 50; - } - } - - if (!isRR() || weapon != HANDBOMB_WEAPON) - cw = weapon; - } - else - cw = weapon; - - if (isRR() && weapon == HANDBOMB_WEAPON) - p->last_weapon = -1; - - 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 != cw) - { - short snum; - snum = sprite[p->i].yvel; - - SetGameVarID(g_iWeaponVarID, cw, 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 = cw; - } - } -#else - p->curr_weapon = cw; -#endif - - switch (weapon) - { - case RA15_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; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - void checkavailinven(struct player_struct* p) { @@ -343,50 +260,6 @@ void checkavailweapon(struct player_struct* p) // //--------------------------------------------------------------------------- -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 == TILE_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 clearcamera(player_struct* ps) { ps->newowner = -1; @@ -412,405 +285,6 @@ void clearcamera(player_struct* ps) // //--------------------------------------------------------------------------- -void hitradius(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->xrepeat < 11) - { - if (!isRR()) - { - if (s->picnum == RPG) goto SKIPWALLCHECK; - } - else - { - if (s->picnum == RR_CROSSBOW || ((isRRRA()) && s->picnum == RR_CHIKENCROSSBOW)) goto SKIPWALLCHECK; - } - } - - if ((isRR()) || 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: - - int val = (isRR()) ? 24 : 16; - q = -(val << 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 ((!isRR() && 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 (!isRR()) - { - 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; - } - } - } - } - else - { - if (sj->extra >= 0 && sj != s && (badguy(sj) || sj->picnum == RR_QUEBALL || sj->picnum == RR_3440 || sj->picnum == RR_STRIPEBALL || (sj->cstat & 257) || sj->picnum == RR_LNRDLYINGDEAD)) - { - if (s->picnum == RR_MORTER && j == s->owner) - { - j = nextj; - continue; - } - if ((isRRRA()) && s->picnum == RR_CHEERBOMB && 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)) - { - if ((isRRRA()) && sprite[j].picnum == RR_MINION && sprite[j].pal == 19) - { - j = nextj; - continue; - } - - hittype[j].ang = getangle(sj->x - s->x, sj->y - s->y); - - if (s->picnum == RR_CROSSBOW && sj->extra > 0) - hittype[j].picnum = RR_CROSSBOW; - else if ((isRRRA()) && s->picnum == RR_CHIKENCROSSBOW && sj->extra > 0) - hittype[j].picnum = RR_CROSSBOW; - else - hittype[j].picnum = RR_RADIUSEXPLOSION; - - 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)); - } - - int pic = sprite[j].picnum; - if ((isRRRA())? - (pic != RR_HULK && pic != RR_MAMAJACKOLOPE && pic != RR_GUITARBILLY && pic != RR_BANJOCOOTER && pic != RR_MAMACLOUD) : - (pic != RR_HULK && pic != RR_SBMOVE)) - { - if (sprite[j].xvel < 0) sprite[j].xvel = 0; - sprite[j].xvel += (sprite[j].extra << 2); - } - - if (sj->picnum == RR_STATUEFLASH || sj->picnum == RR_QUEBALL || - sj->picnum == RR_STRIPEBALL || sj->picnum == RR_3440) - checkhitsprite(j, i); - - if (sprite[j].picnum != RR_RADIUSEXPLOSION && - s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) - { - if (sprite[j].picnum == APLAYER) - { - p = sprite[j].yvel; - if (ps[p].newowner >= 0) - { - clearcamera(&ps[p]); - } - } - hittype[j].owner = s->owner; - } - } - } - } - BOLT: - j = nextj; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -int movesprite(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 (isRR()) - cd = 192; - 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); - } - - bool rr = (isRR()); - // conditional code from hell... - if (dasectnum < 0 || (dasectnum >= 0 && - ((hittype[spritenum].actorstayput >= 0 && hittype[spritenum].actorstayput != dasectnum) || - (!rr && - ( - ((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 && (rr || sprite[spritenum].picnum == LIZMAN)) - sprite[spritenum].ang = (krand() & 2047); - else if ((hittype[spritenum].temp_data[0] & 3) == 1 && (rr || 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); -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - int ssp(short i, unsigned int cliptype) //The set sprite function { spritetype* s; @@ -847,9 +321,6 @@ void insertspriteq(int i) //--------------------------------------------------------------------------- // // consolidation of several nearly identical functions -// lotsofmoney -> MONEY / RR_FEATHERS -// lotsofmail -> MAIL -// lotsofpaper -> PAPER // //--------------------------------------------------------------------------- @@ -865,105 +336,6 @@ void lotsofstuff(spritetype* s, short n, int spawntype) } } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void guts(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 (!isRR() && s->picnum == COMMANDER) - gutz -= (24 << 8); - - if (badguy(s) && s->pal == 6) - pal = 6; - else - { - pal = 0; - if (isRRRA()) - { - if (s->picnum == RR_MINION && (s->pal == 8 || s->pal == 19)) pal = s->pal; - } - } - - if (isRR()) - { - sx >>= 1; - sy >>= 1; - } - - 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 (!isRR() && sprite[i].picnum == JIBS2) - { - sprite[i].xrepeat >>= 2; - sprite[i].yrepeat >>= 2; - } - if (pal != 0) - sprite[i].pal = pal; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void gutsdir(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 (!isRR() && 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); - } -} - //--------------------------------------------------------------------------- // // movesector - why is this in actors.cpp? @@ -1007,292 +379,6 @@ void ms(short i) // //--------------------------------------------------------------------------- -void movefta(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; - } - - if (!isRR() || s->pal == 33 || s->type == RR_VIXEN || - ((isRRRA()) && isIn(s->type, RR_COOT, RR_COOTSTAYPUT, RR_BIKERSTAND, RR_BIKERRIDE, - RR_BIKERRIDEDAISY, RR_MINIONAIRBOAT, RR_HULKAIRBOAT, - RR_DAISYAIRBOAT, RR_JACKOLOPE, RR_BANJOCOOTER, - RR_GUITARBILLY, RR_MAMAJACKOLOPE, RR_BIKERBV, - RR_MAKEOUT, RR_CHEER, RR_CHEERSTAYPUT)) || - (sintable[(s->ang + 512) & 2047] * (px - sx) + sintable[s->ang & 2047] * (py - sy) >= 0)) - { - 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) - { - bool res = (!isRR()) ? - isIn(s->picnum, - RUBBERCAN, - EXPLODINGBARREL, - WOODENHORSE, - HORSEONSIDE, - CANWITHSOMETHING, - CANWITHSOMETHING2, - CANWITHSOMETHING3, - CANWITHSOMETHING4, - FIREBARREL, - FIREVASE, - NUKEBARREL, - NUKEBARRELDENTED, - NUKEBARRELLEAKED, - TRIPBOMB) : - isIn(s->picnum, - RR_1251, - RR_1268, - RR_1187, - RR_1304, - RR_1305, - RR_1306, - RR_1309, - RR_1315, - RR_1317, - RR_1388); - - - if (res) - { - 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); - } - else - { -#if 0 - // TRANSITIONAL: RedNukem has this here. Needed? - if (A_CheckSpriteFlags(spriteNum, SFLAG_USEACTIVATOR) && sector[sprite[spriteNum].sectnum].lotag & 16384) break; -#endif - hittype[i].timetosleep = 0; - check_fta_sounds(i); - changespritestat(i, STAT_ACTOR); - } - } - else hittype[i].timetosleep = 0; - } - } - if ((!isRR() || !j) && badguy(s)) - { - if (sector[s->sectnum].ceilingstat & 1) - s->shade = sector[s->sectnum].ceilingshade; - else s->shade = sector[s->sectnum].floorshade; - - if (isRR() && (s->picnum != RR_HEN || s->picnum != RR_COW || s->picnum != RR_PIG || s->picnum != RR_DOGRUN || ((isRRRA()) && s->picnum != RR_JACKOLOPE))) - if (wakeup(i, p)) - { - hittype[i].timetosleep = 0; - check_fta_sounds(i); - changespritestat(i, STAT_ACTOR); - } - - } - } - i = nexti; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -int ifhitsectors(int sectnum) -{ - int i = headspritestat[STAT_MISC]; - if (!isRR()) - { - while (i >= 0) - { - if (sprite[i].picnum == EXPLOSION2 && sectnum == sprite[i].sectnum) - return i; - i = nextspritestat[i]; - } - } - else - { - while (i >= 0) - { - if (sprite[i].picnum == RR_EXPLOSION2 || (sprite[i].picnum == RR_EXPLOSION3 && sectnum == sprite[i].sectnum)) - return i; - i = nextspritestat[i]; - } - } - - return -1; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -int ifhitbyweapon(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 && (isRR() || 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 != pPick2(FREEZEBLAST, RR_ALIENBLAST)) - { - 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; - } - } - - bool res = !isRR() ? - isIn(hittype[sn].picnum, RADIUSEXPLOSION, RPG, HYDRENT, HEAVYHBOMB, SEENINE, OOZFILTER, EXPLODINGBARREL) : - (isIn(hittype[sn].picnum, RR_DYNAMITE, RR_POWDERKEGSPRITE, RR_1228, RR_1273, RR_1315, RR_SEENINE, RR_RADIUSEXPLOSION, RR_CROSSBOW) || - (isRRRA() && hittype[sn].picnum == RR_CHIKENCROSSBOW)); - - int shift = res ? 2 : 1; - ps[p].posxv += hittype[sn].extra * (sintable[(hittype[sn].ang + 512) & 2047]) << shift; - ps[p].posyv += hittype[sn].extra * (sintable[hittype[sn].ang & 2047]) << shift; - } - else - { - if (hittype[sn].extra == 0) - if ((isRR() || 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 != pPick2(RECON, RR_4989) && 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; - } - - - hittype[sn].extra = -1; - return -1; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - void movecyclers(void) { short q, j, x, t, s, * c; @@ -1559,56 +645,13 @@ void movefx(void) if (sprite[i].extra == 66) { j = spawn(i, sprite[i].hitag); - if (isRRRA()) + if (isRRRA()) { - sprite[j].pal = sprite[i].pal; - if (sprite[j].picnum == RR_MAMAJACKOLOPE) - { - if (sprite[j].pal == 30) - { - sprite[j].xrepeat = 26; - sprite[j].yrepeat = 26; - sprite[j].clipdist = 75; - } - else if (sprite[j].pal == 31) - { - sprite[j].xrepeat = 36; - sprite[j].yrepeat = 36; - sprite[j].clipdist = 100; - } - else if (sprite[j].pal == 32) - { - sprite[j].xrepeat = 50; - sprite[j].yrepeat = 50; - sprite[j].clipdist = 100; - } - else - { - sprite[j].xrepeat = 50; - sprite[j].yrepeat = 50; - sprite[j].clipdist = 100; - } - } - - if (sprite[j].pal == 8) - { - sprite[j].cstat |= 2; - } - - if (sprite[j].pal != 6) - { - deletesprite(i); - i = nexti; - continue; - } - sprite[i].extra = (66 - 13); - sprite[j].pal = 0; + respawn_rrra(i, j); } else { deletesprite(i); - i = nexti; - continue; } } else if (sprite[i].extra > (66 - 13)) @@ -1677,132 +720,18 @@ void movefx(void) } } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void movefallers(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) - { - bool res = !isRR() ? - isIn(j, FIREEXT, RPG, RADIUSEXPLOSION, SEENINE, OOZFILTER) : - (isIn(j, RR_CROSSBOW, RR_RADIUSEXPLOSION, RR_SEENINE, RR_OOZFILTER) || (isRRRA() && j == RR_CHIKENCROSSBOW)); - - if (res) - { - 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 (!isRR() ? isIn(j, CEILINGSTEAM, STEAM) : isIn(j, RR_CEILINGSTEAM, RR_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 (isRR()) - { - s->xvel = (64 + krand()) & 127; - s->zvel = -(1024 + (krand() & 1023)); - } - else if (s->lotag <= 0) - { - s->xvel = (32 + (krand() & 63)); - s->zvel = -(1024 + (krand() & 1023)); - } - } - else - { - if (s->xvel > 0) - { - s->xvel -= isRR()? 2 : 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 // //--------------------------------------------------------------------------- -static void movecrane(int i) +void movecrane(int i, int crane) { auto t = &hittype[i].temp_data[0]; auto s = &sprite[i]; int sect = s->sectnum; int x; - int crane = pPick(CRANE); //t[0] = state //t[1] = checking sector number @@ -1988,7 +917,7 @@ static void movecrane(int i) // //--------------------------------------------------------------------------- -static void movefountain(int i) +void movefountain(int i, int fountain) { auto t = &hittype[i].temp_data[0]; auto s = &sprite[i]; @@ -2001,8 +930,8 @@ static void movefountain(int i) s->picnum++; - if (s->picnum == (pPick(WATERFOUNTAIN) + 3)) - s->picnum = pPick(WATERFOUNTAIN) + 1; + if (s->picnum == fountain + 3) + s->picnum = fountain + 1; } else { @@ -2011,7 +940,7 @@ static void movefountain(int i) if (x > 512) { t[0] = 0; - s->picnum = pPick(WATERFOUNTAIN); + s->picnum = fountain; } else t[0] = 1; } @@ -2023,7 +952,7 @@ static void movefountain(int i) // //--------------------------------------------------------------------------- -static void moveflammable(int i) +void moveflammable(int i, int tire, int box, int pool) { auto s = &sprite[i]; int j; @@ -2032,10 +961,10 @@ static void moveflammable(int i) hittype[i].temp_data[1]++; if ((hittype[i].temp_data[1] & 3) > 0) return; - if (!isRR() && s->picnum == TIRE && hittype[i].temp_data[1] == 32) + if (!isRR() && s->picnum == tire && hittype[i].temp_data[1] == 32) { s->cstat = 0; - j = spawn(i, BLOODPOOL); + j = spawn(i, pool); sprite[j].shade = 127; } else @@ -2065,170 +994,20 @@ static void moveflammable(int i) } s->yrepeat = j; } - if (!isRR() && s->picnum == BOX) + if (box >= 0 && s->picnum == box) { makeitfall(i); hittype[i].ceilingz = sector[s->sectnum].ceilingz; } } -//--------------------------------------------------------------------------- -// -// 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 detonate(int i) +void detonate(int i, int explosion) { auto s = &sprite[i]; auto t = &hittype[i].temp_data[0]; @@ -2262,7 +1041,7 @@ static void detonate(int i) if ((t[3] == 1 && s->xrepeat) || s->lotag == -99) { int x = s->extra; - spawn(i, EXPLOSION2); + spawn(i, explosion); hitradius(i, seenineblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); spritesound(PIPEBOMB_EXPLODE, i); } @@ -2280,176 +1059,7 @@ static void detonate(int 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); - - bool res = !isRR() ? - isIn(j, FIREEXT, RPG, RADIUSEXPLOSION, SEENINE, OOZFILTER) : - (isIn(j, RR_CROSSBOW, RR_RADIUSEXPLOSION, RR_SEENINE, RR_OOZFILTER) || (isRRRA() && j == RR_CHIKENCROSSBOW)); - - if (res) - { - j = headspritestat[STAT_STANDABLE]; - while (j >= 0) - { - if (s->hitag == sprite[j].hitag && (isRR() ? isIn(sprite[j].picnum, RR_OOZFILTER, RR_SEENINE) : isIn(sprite[j].picnum, OOZFILTER, SEENINE))) - if (sprite[j].shade != -32) - sprite[j].shade = -32; - j = nextspritestat[j]; - } - detonate(i); - } - 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); - } - else - { - hitradius(i, seenineblastradius, 10, 15, 20, 25); - deletesprite(i); - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void moveooz(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - int j; - if (s->shade != -32 && s->shade != -33) - { - if (s->xrepeat) - j = (ifhitbyweapon(i) >= 0); - else - j = 0; - - if (j || s->shade == -31) - { - if (j) s->lotag = 0; - - t[3] = 1; - - j = headspritestat[STAT_STANDABLE]; - while (j >= 0) - { - if (s->hitag == sprite[j].hitag && (sprite[j].picnum == pPick(SEENINE) || sprite[j].picnum == pPick(OOZFILTER))) - sprite[j].shade = -32; - j = nextspritestat[j]; - } - } - } - else - { - if (s->shade == -32) - { - if (s->lotag > 0) - { - s->lotag -= 3; - if (s->lotag <= 0) s->lotag = -99; - } - else - s->shade = -33; - } - else - { - if (s->xrepeat > 0) - { - hittype[i].temp_data[2]++; - if (hittype[i].temp_data[2] == 3) - { - if (s->picnum == pPick(OOZFILTER)) - { - hittype[i].temp_data[2] = 0; - detonate(i); - return; - } - if (s->picnum != (pPick(SEENINEDEAD) + 1)) - { - hittype[i].temp_data[2] = 0; - - if (s->picnum == pPick(SEENINEDEAD)) s->picnum++; - else if (s->picnum == pPick(SEENINE)) - s->picnum = pPick(SEENINEDEAD); - } - else - { - detonate(i); - return; - } - } - return; - } - detonate(i); - return; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void movemasterswitch(int i) +void movemasterswitch(int i, int spectype1, int spectype2) { auto s = &sprite[i]; auto t = &hittype[i].temp_data[0]; @@ -2481,7 +1091,7 @@ void movemasterswitch(int i) } else if (sprite[j].statnum == 6) { - if (sprite[j].picnum == pPick(SEENINE) || sprite[j].picnum == pPick(OOZFILTER)) + if (sprite[j].picnum == spectype1 || sprite[j].picnum == spectype2) // SEENINE and OOZFILTER { sprite[j].shade = -31; } @@ -2499,38 +1109,7 @@ void movemasterswitch(int 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; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movetrash(int i) +void movetrash(int i) { auto s = &sprite[i]; if (s->xvel == 0) s->xvel = 1; @@ -2544,126 +1123,13 @@ static void movetrash(int i) else deletesprite(i); } -//--------------------------------------------------------------------------- -// -// 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; - - auto bolt1 = pPick(BOLT1); - if (s->picnum == (bolt1 + 1) && (isRR() ? (krand() & 1) != 0 : (krand() & 7) == 0) && sector[sect].floorpicnum == pPick(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; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movewaterdrip(int i) +void movewaterdrip(int i, int drip) { auto s = &sprite[i]; auto t = &hittype[i].temp_data[0]; @@ -2688,7 +1154,7 @@ static void movewaterdrip(int i) if (s->pal != 2 && (isRR() || s->hitag == 0)) spritesound(SOMETHING_DRIPPING, i); - if (sprite[s->owner].picnum != pPick(WATERDRIP)) + if (sprite[s->owner].picnum != drip) { deletesprite(i); } @@ -2707,7 +1173,7 @@ static void movewaterdrip(int i) // //--------------------------------------------------------------------------- -static void movedoorshock(int i) +void movedoorshock(int i) { auto s = &sprite[i]; int sect = s->sectnum; @@ -2723,7 +1189,7 @@ static void movedoorshock(int i) // //--------------------------------------------------------------------------- -static void movetouchplate(int i) +void movetouchplate(int i, int plate) { auto s = &sprite[i]; auto t = &hittype[i].temp_data[0]; @@ -2793,7 +1259,7 @@ static void movetouchplate(int i) int j = headspritestat[STAT_STANDABLE]; while (j >= 0) { - if (j != i && sprite[j].picnum == TOUCHPLATE && sprite[j].lotag == s->lotag) + if (j != i && sprite[j].picnum == plate && sprite[j].lotag == s->lotag) { hittype[j].temp_data[1] = 1; hittype[j].temp_data[3] = t[3]; @@ -2809,7 +1275,87 @@ static void movetouchplate(int i) // //--------------------------------------------------------------------------- -static void movecanwithsomething(int i) +void moveooz(int i, int seenine, int seeninedead, int ooz, int explosion) +{ + auto s = &sprite[i]; + auto t = &hittype[i].temp_data[0]; + int j; + if (s->shade != -32 && s->shade != -33) + { + if (s->xrepeat) + j = (ifhitbyweapon(i) >= 0); + else + j = 0; + + if (j || s->shade == -31) + { + if (j) s->lotag = 0; + + t[3] = 1; + + j = headspritestat[STAT_STANDABLE]; + while (j >= 0) + { + if (s->hitag == sprite[j].hitag && (sprite[j].picnum == seenine || sprite[j].picnum == ooz)) + sprite[j].shade = -32; + j = nextspritestat[j]; + } + } + } + else + { + if (s->shade == -32) + { + if (s->lotag > 0) + { + s->lotag -= 3; + if (s->lotag <= 0) s->lotag = -99; + } + else + s->shade = -33; + } + else + { + if (s->xrepeat > 0) + { + hittype[i].temp_data[2]++; + if (hittype[i].temp_data[2] == 3) + { + if (s->picnum == ooz) + { + hittype[i].temp_data[2] = 0; + detonate(i, explosion); + return; + } + if (s->picnum != (seeninedead + 1)) + { + hittype[i].temp_data[2] = 0; + + if (s->picnum == seeninedead) s->picnum++; + else if (s->picnum == seenine) + s->picnum = seeninedead; + } + else + { + detonate(i, explosion); + return; + } + } + return; + } + detonate(i, explosion); + return; + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void movecanwithsomething(int i) { auto s = &sprite[i]; makeitfall(i); @@ -2826,160 +1372,13 @@ static void movecanwithsomething(int i) } } -//--------------------------------------------------------------------------- -// -// this has been broken up into lots of smaller subfunctions -// -//--------------------------------------------------------------------------- - -void movestandables(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 >= pPick(CRANE) && picnum <= pPick(CRANE) +3) - { - movecrane(i); - } - - else if (picnum >= pPick(WATERFOUNTAIN) && picnum <= pPick(WATERFOUNTAIN) + 3) - { - movefountain(i); - } - - else if (AFLAMABLE(picnum)) - { - moveflammable(i); - } - - else if (!isRR() && picnum == TRIPBOMB) - { - movetripbomb(i); - } - - else if (picnum >= pPick(CRACK1) && picnum <= pPick(CRACK1)+3) - { - movecrack(i); - } - - else if (!isRR() && picnum == FIREEXT) - { - movefireext(i); - } - - else if (picnum == pPick(OOZFILTER) || picnum == pPick(SEENINE) || picnum == pPick(SEENINEDEAD) || picnum == (pPick(SEENINEDEAD) + 1)) - { - moveooz(i); - } - - else if (picnum == MASTERSWITCH) - { - movemasterswitch(i); - } - - else if (!isRR() && (picnum == VIEWSCREEN || picnum == VIEWSCREEN2)) - { - moveviewscreen(i); - } - - else if (picnum == pPick(TRASH)) - { - movetrash(i); - } - - else if (!isRR() && picnum >= SIDEBOLT1 && picnum <= SIDEBOLT1 + 3) - { - movesidebolt(i); - } - - else if (picnum >= pPick(BOLT1) && picnum <= pPick(BOLT1) + 3) - { - movebolt(i); - } - - else if (picnum == pPick(WATERDRIP)) - { - movewaterdrip(i); - } - - else if (picnum == pPick(DOORSHOCK)) - { - movedoorshock(i); - } - - else if (picnum == TOUCHPLATE) - { - movetouchplate(i); - } - - else if (isRR() ? picnum == RR_CANWITHSOMETHING : isIn(picnum, CANWITHSOMETHING, CANWITHSOMETHING2, CANWITHSOMETHING3, CANWITHSOMETHING4)) - { - movecanwithsomething(i); - } - - else if (!isRR() ? - isIn(picnum, - EXPLODINGBARREL, - WOODENHORSE, - HORSEONSIDE, - FLOORFLAME, - FIREBARREL, - FIREVASE, - NUKEBARREL, - NUKEBARRELDENTED, - NUKEBARRELLEAKED, - TOILETWATER, - RUBBERCAN, - STEAM, - CEILINGSTEAM, - WATERBUBBLEMAKER) : - isIn(picnum, - RR_1187, - RR_1196, - RR_1251, - RR_1268, - RR_1304, - RR_1305, - RR_1306, - RR_1315, - RR_1317, - RR_1388, - RR_STEAM, - RR_CEILINGSTEAM, - RR_WATERBUBBLEMAKER) - ) - { - int x; - int p = findplayer(s, &x); - execute(i, p, x); - } - } -} - //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- -static void bounce(int i) +void bounce(int i) { int k, l, daang, dax, day, daz, xvect, yvect, zvect; short hitsect; @@ -3020,11 +1419,11 @@ static void bounce(int i) //--------------------------------------------------------------------------- // -// +// taken out of moveweapon // //--------------------------------------------------------------------------- -static void movetongue(int i) +void movetongue(int i, int tongue, int jaw) { spritetype* s = &sprite[i]; @@ -3053,7 +1452,7 @@ static void movetongue(int i) int q = 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 / 12)), pPick(TONGUE), -40 + (k << 1), + s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 12)), tongue, -40 + (k << 1), 8, 8, 0, 0, 0, i, 5); sprite[q].cstat = 128; sprite[q].pal = 8; @@ -3062,604 +1461,11 @@ static void movetongue(int i) int q = 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 / 12)), pPick(INNERJAW), -40, + s->z + ((k * ksgn(s->zvel)) * abs(s->zvel / 12)), jaw, -40, 32, 32, 0, 0, 0, i, 5); sprite[q].cstat = 128; if (hittype[i].temp_data[1] > 512 && hittype[i].temp_data[1] < (1024)) - sprite[q].picnum = pPick(INNERJAW) + 1; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void moveweapons(void) -{ - int j, k, nexti, p, q, tempsect; - int dax, day, daz, x, l, ll, x1, y1; - unsigned int qq; - spritetype* s; - - for (int i = headspritestat[STAT_PROJECTILE]; i >= 0; i = nexti) - { - nexti = nextspritestat[i]; - s = &sprite[i]; - int picnum = 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 == pPick(RADIUSEXPLOSION) || (!isRR() && picnum == KNEE)) - { - deletesprite(i); - } - - else if (picnum == pPick(TONGUE)) - { - movetongue(i); - } - - else if (picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST) && (s->yvel < 1 || s->extra < 2 || (s->xvel | s->zvel) == 0)) - { - j = spawn(i, pPick(TRANSPORTERSTAR)); - sprite[j].pal = 1; - sprite[j].xrepeat = 32; - sprite[j].yrepeat = 32; - deletesprite(i); - continue; - } - - else if (!isRR() ? - (isIn(picnum, FREEZEBLAST, SHRINKSPARK, RPG, FIRELASER, SPIT, COOLEXPLOSION1) || (isWorldTour() && picnum == FIREBALL)) : - (isIn(picnum, RR_ALIENBLAST, RR_CROSSBOW, RR_FIRELASER, RR_SHITBALL, RR_CIRCLESAW, RR_UWHIP, RR_OWHIP, RR_DILDO) || (isRRRA() && isIn(picnum, RR_CHIKENCROSSBOW, RR_1790))) - ) - { - if (!isRR() && picnum == COOLEXPLOSION1) - if (!S_CheckSoundPlaying(i, WIERDSHOT_FLY)) - A_PlaySound(WIERDSHOT_FLY, i); - - p = -1; - - if ((picnum == pPick2(RPG, RR_CROSSBOW) || (isRRRA() && picnum == RR_CHIKENCROSSBOW)) && 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; - - if (picnum == pPick2(RPG, RR_CROSSBOW)) - { - if (hittype[i].picnum != pPick(BOSS2) && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) - { - j = spawn(i, pPick(SMALLSMOKE)); - sprite[j].z += (1 << 8); - } - } - else if (isRRRA() && picnum == RR_CHIKENCROSSBOW) - { - s->hitag++; - if (hittype[i].picnum != RR_BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) - { - j = spawn(i, RR_SMALLSMOKE); - sprite[j].z += (1 << 8); - if ((krand() & 15) == 2) - { - j = spawn(i, RR_1310); - } - } - if (sprite[s->lotag].extra <= 0) - s->lotag = 0; - if (s->lotag != 0 && s->hitag > 5) - { - spritetype* ts; - int ang, ang2, ang3; - ts = &sprite[s->lotag]; - ang = getangle(ts->x - s->x, ts->y - s->y); - ang2 = ang - s->ang; - ang3 = abs(ang2); - if (ang2 < 100) - { - if (ang3 > 1023) - s->ang += 51; - else - s->ang -= 51; - } - else if (ang2 > 100) - { - if (ang3 > 1023) - s->ang -= 51; - else - s->ang += 51; - } - else - s->ang = ang; - - if (s->hitag > 180) - if (s->zvel <= 0) - s->zvel += 200; - } - } - else if (isRRRA() && picnum == RR_1790) - { - if (s->extra) - { - s->zvel = -(s->extra * 250); - s->extra--; - } - else - makeitfall(i); - if (s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) - { - j = spawn(i, RR_SMALLSMOKE); - sprite[j].z += (1 << 8); - } - } - else if (isWorldTour() && picnum == FIREBALL) - { - 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; - } - - j = movesprite(i, - (k * (sintable[(s->ang + 512) & 2047])) >> 14, - (k * (sintable[s->ang & 2047])) >> 14, ll, qq); - - if ((picnum == pPick2(RPG, RR_CROSSBOW) || (isRRRA() && isIn(picnum, RR_CHIKENCROSSBOW, RR_1790))) && 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) // || (isRR() && sector[s->sectnum].filler == 800)) - { - deletesprite(i); - continue; - } - - if ((j & 49152) != 49152) - if (picnum != pPick2(FREEZEBLAST, RR_ALIENBLAST)) - { - 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 (picnum == pPick(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)) * klabs(s->zvel / 24)), pPick(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 (picnum == pPick2(SPIT, RR_SHITBALL)) if (s->zvel < 6144) - s->zvel += gc - 112; - - if (j != 0) - { - if (!isRR() && picnum == COOLEXPLOSION1) - { - if ((j & 49152) == 49152 && sprite[j & (MAXSPRITES - 1)].picnum != APLAYER) - { - continue; - } - s->xvel = 0; - s->zvel = 0; - } - - //if ((j & kHitTypeMask) == kHitSprite) j &= kHitIndexMask; reminder for later. - if ((j & 49152) == 49152) - { - j &= (MAXSPRITES - 1); - - if (isRRRA()) - { - if (sprite[j].picnum == RR_MINION - && (picnum == RR_CROSSBOW || picnum == RR_CHIKENCROSSBOW) - && sprite[j].pal == 19) - { - spritesound(RPG_EXPLODE, i); - j = spawn(i, RR_EXPLOSION2); - sprite[j].x = s->x; - sprite[j].y = s->y; - sprite[j].z = s->z; - continue; - } - } - else if (picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST) && sprite[j].pal == 1) - if (badguy(&sprite[j]) || sprite[j].picnum == APLAYER) - { - j = spawn(i, pPick(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 (picnum == pPick2(SPIT, RR_SHITBALL)) - { - if (sprite[s->owner].picnum == RR_MAMAJACKOLOPE) - { - guts(s, RR_RABBITJIBA, 2, myconnectindex); - guts(s, RR_RABBITJIBB, 2, myconnectindex); - guts(s, RR_RABBITJIBC, 2, myconnectindex); - } - - 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 (isRRRA() && sprite[s->owner].picnum == RR_MAMAJACKOLOPE) - { - guts(s, RR_RABBITJIBA, 2, myconnectindex); - guts(s, RR_RABBITJIBB, 2, myconnectindex); - guts(s, RR_RABBITJIBC, 2, myconnectindex); - } - - bool ismirror = (wall[j].overpicnum == pPick(MIRROR) || wall[j].picnum == pPick(MIRROR)); - if (ismirror && !isRR() ? - isIn(picnum, RPG, FREEZEBLAST, SPIT) : - (isIn(picnum, RR_CROSSBOW, RR_ALIENBLAST, RR_SHITBALL, RR_CIRCLESAW) || (isRRRA() && picnum == RR_CHIKENCROSSBOW)) - ) - { - 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, pPick(TRANSPORTERSTAR)); - continue; - } - else - { - setsprite(i, dax, day, daz); - checkhitwall(i, j, s->x, s->y, s->z, picnum); - - if (!isRRRA() && picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST)) - { - if (!ismirror) - { - 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; - } - - if (isRR() && s->picnum == RR_CIRCLESAW) - { - if (wall[j].picnum >= RR_3643 && wall[j].picnum < RR_3643 + 3) - { - deletesprite(i); - } - if (s->extra <= 0) - { - s->x += sintable[(s->ang + 512) & 2047] >> 7; - s->y += sintable[s->ang & 2047] >> 7; - if (!isRRRA() || (sprite[s->owner].picnum != RR_DAISYMAE && sprite[s->owner].picnum != RR_DAISYMAESTAYPUT)) - { - j = spawn(i, RR_CIRCLESTUCK); - sprite[j].xrepeat = 8; - sprite[j].yrepeat = 8; - sprite[j].cstat = 16; - sprite[j].ang = (sprite[j].ang + 512) & 2047; - sprite[j].clipdist = mulscale7(s->xrepeat, tilesiz[s->picnum].x); - } - deletesprite(i); - continue; - } - if (!ismirror) - { - s->extra -= 20; - 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 (isRRRA() && sprite[s->owner].picnum == RR_MAMAJACKOLOPE) - { - guts(s, RR_RABBITJIBA, 2, myconnectindex); - guts(s, RR_RABBITJIBB, 2, myconnectindex); - guts(s, RR_RABBITJIBC, 2, myconnectindex); - } - - if (s->zvel < 0) - { - if (sector[s->sectnum].ceilingstat & 1) - if (sector[s->sectnum].ceilingpal == 0) - { - deletesprite(i); - continue; - } - - checkhitceiling(s->sectnum); - } - - if (!isRRRA() && picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST)) - { - 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 (picnum != pPick2(SPIT, RR_SHITBALL)) - { - if (picnum == pPick2(RPG, RR_CROSSBOW)) - { - k = spawn(i, pPick(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 (!isRR() && s->zvel > 0) - spawn(i, EXPLOSION2BOT); - else { sprite[k].cstat |= 8; sprite[k].z += (48 << 8); } - } - } - else if (isRRRA() && s->picnum == RR_CHIKENCROSSBOW) - { - k = spawn(i, RR_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) - { - sprite[k].cstat |= 8; - sprite[k].z += (48 << 8); - } - } - else if (isRRRA() && s->picnum == RR_1790) - { - s->extra = 160; - k = spawn(i, RR_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) - { - sprite[k].cstat |= 8; - sprite[k].z += (48 << 8); - } - } - - else if (!isRR() && picnum == SHRINKSPARK) - { - spawn(i, SHRINKEREXPLOSION); - spritesound(SHRINKER_HIT, i); - hitradius(i, shrinkerblastradius, 0, 0, 0, 0); - } - else if (!isRR() ? - !isIn(picnum, COOLEXPLOSION1, FREEZEBLAST, FIRELASER) : - !isIn(picnum, RR_ALIENBLAST, RR_FIRELASER, RR_CIRCLESAW)) - { - k = spawn(i, pPick(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 (picnum == pPick2(RPG, RR_CROSSBOW)) - { - 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); - } - } - else if (isRRRA() && s->picnum == RR_CHIKENCROSSBOW) - { - s->extra = 150; - spritesound(247, 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); - } - } - else if (s->picnum == RR_1790) - { - s->extra = 160; - 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 (isRR() || picnum != COOLEXPLOSION1) - { - deletesprite(i); - continue; - } - } - if (!isRR() && picnum == COOLEXPLOSION1) - { - s->shade++; - if (s->shade >= 40) - { - deletesprite(i); - continue; - } - } - else if ((picnum == pPick2(RPG, RR_CROSSBOW) || (isRRRA() && picnum == RR_CHIKENCROSSBOW)) && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) - spawn(i, pPick(WATERBUBBLE)); - - continue; - } - else if (picnum == pPick(SHOTSPARK1)) - { - p = findplayer(s, &x); - execute(i, p, x); - } - } + sprite[q].picnum = jaw + 1; } diff --git a/source/games/duke/src/actors.h b/source/games/duke/src/actors.h index c2f0adf2b..0c6e09614 100644 --- a/source/games/duke/src/actors.h +++ b/source/games/duke/src/actors.h @@ -367,6 +367,43 @@ inline int wakeup(int sn, int pn) return G_WakeUp(&sprite[sn], pn); } +// shared functions +void movecrane(int i, int crane); +void movefountain(int i, int fountain); +void moveflammable(int i, int tire, int box, int pool); +void detonate(int i, int explosion); +void movemasterswitch(int i, int spectype1, int spectype2); +void movetrash(int i); +void movewaterdrip(int i, int drip); +void movedoorshock(int i); +void movetouchplate(int i, int plate); +void movecanwithsomething(int i); +void bounce(int i); +void movetongue(int i, int tongue, int jaw); +void moveooz(int i, int seenine, int seeninedead, int ooz, int explosion); +void lotsofstuff(spritetype* s, short n, int spawntype); +void respawn_rrra(int i, int j); + +void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4); +int ifhitbyweapon(int sn); +int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype); + +// tile names which are identical for all games. +enum +{ + SECTOREFFECTOR = 1, + ACTIVATOR = 2, + TOUCHPLATE = 3, + ACTIVATORLOCKED = 4, + MUSICANDSFX = 5, + LOCATORS = 6, + CYCLER = 7, + MASTERSWITCH = 8, + RESPAWN = 9, + GPSPEED = 10, + FOF = 13, +}; + #endif END_DUKE_NS diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 2d0f547d0..42ad9dd00 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -2,7 +2,6 @@ /* Copyright (C) 1996, 2003 - 3D Realms Entertainment Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) -Copyright (C) 2017-2019 - Nuke.YKT Copyright (C) 2020 - Christoph Oelckers This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition @@ -30,17 +29,14 @@ 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 is a combination of code from the following sources: -- EDuke 2 by Matt Saettler -- JFDuke by Jonathon Fowler (jf@jonof.id.au), -- DukeGDX and RedneckGDX by Alexander Makarov-[M210] (m210-2007@mail.ru) -- Redneck Rampage reconstructed source by Nuke.YKT +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 @@ -59,19 +55,15 @@ static TMap fire; // //--------------------------------------------------------------------------- -bool ceilingspace(int sectnum) +bool ceilingspace_d(int sectnum) { - if ((sector[sectnum].ceilingstat & 1) && sector[sectnum].ceilingpal == 0) + if( (sector[sectnum].ceilingstat&1) && sector[sectnum].ceilingpal == 0 ) { - switch (sector[sectnum].ceilingpicnum) + switch(sector[sectnum].ceilingpicnum) { - case MOONSKY1: - case BIGORBIT1: - return !isRR(); - - case RR_MOONSKY1: - case RR_BIGORBIT1: - return isRR(); + case MOONSKY1: + case BIGORBIT1: + return 1; } } return 0; @@ -83,19 +75,15 @@ bool ceilingspace(int sectnum) // //--------------------------------------------------------------------------- -bool floorspace(int sectnum) +bool floorspace_d(int sectnum) { - if ((sector[sectnum].floorstat & 1) && sector[sectnum].ceilingpal == 0) + if( (sector[sectnum].floorstat&1) && sector[sectnum].ceilingpal == 0 ) { - switch (sector[sectnum].floorpicnum) + switch(sector[sectnum].floorpicnum) { - case MOONSKY1: - case BIGORBIT1: - return !isRR(); - - case RR_MOONSKY1: - case RR_BIGORBIT1: - return !!isRR(); + case MOONSKY1: + case BIGORBIT1: + return 1; } } return 0; @@ -107,71 +95,15 @@ bool floorspace(int sectnum) // //--------------------------------------------------------------------------- -void addammo(short weapon, struct player_struct* p, short amount) +void addweapon_d(struct player_struct *p, int weapon) { - p->ammo_amount[weapon] += amount; - - if (p->ammo_amount[weapon] > max_ammo_amount[weapon]) - p->ammo_amount[weapon] = max_ammo_amount[weapon]; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void addweapon(struct player_struct* p, int weapon) -{ - short cw = p->curr_weapon; - if (p->OnMotorcycle || p->OnBoat) + if ( p->gotweapon[weapon] == 0 ) { p->gotweapon.Set(weapon); - if (weapon == SHRINKER_WEAPON) - { + if(weapon == SHRINKER_WEAPON) p->gotweapon.Set(GROW_WEAPON); - p->ammo_amount[GROW_WEAPON] = 1; - } - else if (weapon == RPG_WEAPON) - { - p->gotweapon.Set(RA16_WEAPON); - } - else if (weapon == RA15_WEAPON) - { - p->ammo_amount[RA15_WEAPON] = 1; - } - return; } - if (p->gotweapon[weapon] == 0) - { - p->gotweapon.Set(weapon); - if (weapon == SHRINKER_WEAPON) - { - p->gotweapon.Set(GROW_WEAPON); - if (isRRRA()) p->ammo_amount[GROW_WEAPON] = 1; - } - if (isRRRA()) - { - if (weapon == RPG_WEAPON) - { - p->gotweapon.Set(RA16_WEAPON); - } - if (weapon == RA15_WEAPON) - { - p->ammo_amount[RA15_WEAPON] = 50; - } - } - - if (!isRR() || weapon != HANDBOMB_WEAPON) - cw = weapon; - } - else - cw = weapon; - - if (isRR() && weapon == HANDBOMB_WEAPON) - p->last_weapon = -1; - p->random_club_frame = 0; if (p->holster_weapon == 0) @@ -188,12 +120,12 @@ void addweapon(struct player_struct* p, int weapon) p->kickback_pic = 0; #ifdef EDUKE - if (p->curr_weapon != cw) + if(p->curr_weapon != weapon) { short snum; snum = sprite[p->i].yvel; - SetGameVarID(g_iWeaponVarID, cw, p->i, snum); + SetGameVarID(g_iWeaponVarID,weapon, p->i, snum); if (p->curr_weapon >= 0) { SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[weapon][snum], p->i, snum); @@ -206,28 +138,27 @@ void addweapon(struct player_struct* p, int weapon) OnEvent(EVENT_CHANGEWEAPON, p->i, snum, -1); if (GetGameVarID(g_iReturnVarID, -1, snum) == 0) { - p->curr_weapon = cw; + p->curr_weapon = weapon; } } #else - p->curr_weapon = cw; + p->curr_weapon = weapon; #endif switch (weapon) { - case RA15_WEAPON: case KNEE_WEAPON: case TRIPBOMB_WEAPON: case HANDREMOTE_WEAPON: - case HANDBOMB_WEAPON: + case HANDBOMB_WEAPON: break; - case SHOTGUN_WEAPON: + case SHOTGUN_WEAPON: spritesound(SHOTGUN_COCK, p->i); break; - case PISTOL_WEAPON: + case PISTOL_WEAPON: spritesound(INSERT_CLIP, p->i); break; - default: + default: spritesound(SELECT_WEAPON, p->i); break; } @@ -239,116 +170,12 @@ void addweapon(struct player_struct* p, int weapon) // //--------------------------------------------------------------------------- -void checkavailinven(struct player_struct* p) -{ - - if (p->firstaid_amount > 0) - p->inven_icon = ICON_FIRSTAID; - else if (p->steroids_amount > 0) - p->inven_icon = ICON_STEROIDS; - else if (p->holoduke_amount > 0) - p->inven_icon = ICON_HOLODUKE; - else if (p->jetpack_amount > 0) - p->inven_icon = ICON_JETPACK; - else if (p->heat_amount > 0) - p->inven_icon = ICON_HEATS; - else if (p->scuba_amount > 0) - p->inven_icon = ICON_SCUBA; - else if (p->boot_amount > 0) - p->inven_icon = ICON_BOOTS; - else p->inven_icon = ICON_NONE; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void checkavailweapon(struct player_struct* p) -{ - short i, snum; - int weap; - - if (p->wantweaponfire >= 0) - { - weap = p->wantweaponfire; - p->wantweaponfire = -1; - - if (weap == p->curr_weapon) return; - else if (p->gotweapon[weap] && p->ammo_amount[weap] > 0) - { - addweapon(p, weap); - return; - } - } - - weap = p->curr_weapon; - if (p->gotweapon[weap] && p->ammo_amount[weap] > 0) - return; - - snum = sprite[p->i].yvel; - - // Note: RedNukem has this restriction, but the original source and RedneckGDX do not. -#if 1 // TRANSITIONAL - int max = ((isRR()) ? DEVISTATOR_WEAPON : FREEZE_WEAPON); -#else - int max = FREEZE_WEAPON; -#endif - for (i = 0; i < 10; i++) - { - weap = ud.wchoice[snum][i]; - if ((g_gameType & GAMEFLAG_SHAREWARE) && weap > 6) continue; - - if (weap == 0) weap = max; - else weap--; - - if (weap == KNEE_WEAPON || (p->gotweapon[weap] && p->ammo_amount[weap] > 0)) - break; - } - - if (i == HANDREMOTE_WEAPON) weap = KNEE_WEAPON; - - // Found the weapon - - p->last_weapon = p->curr_weapon; - p->random_club_frame = 0; - p->curr_weapon = weap; - if (isWW2GI()) - { - SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); - if (p->curr_weapon >= 0) - { - SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); - } - else - { - SetGameVarID(g_iWorksLikeVarID, -1, p->i, snum); - } - OnEvent(EVENT_CHANGEWEAPON, p->i, snum, -1); - } - - p->kickback_pic = 0; - if (p->holster_weapon == 1) - { - p->holster_weapon = 0; - p->weapon_pos = 10; - } - else p->weapon_pos = -1; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - 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 == TILE_APLAYER && ud.clipping) + if (sprite[i].picnum == APLAYER && ud.clipping) return false; auto& sc = sector[sprite[i].sectnum]; @@ -387,32 +214,7 @@ bool ifsquished(int i, int p) // //--------------------------------------------------------------------------- -void clearcamera(player_struct* ps) -{ - ps->newowner = -1; - ps->posx = ps->oposx; - ps->posy = ps->oposy; - ps->posz = ps->oposz; - ps->q16ang = ps->oq16ang; - updatesector(ps->posx, ps->posy, &ps->cursectnum); - setpal(ps); - - int k = headspritestat[1]; - while (k >= 0) - { - if (sprite[k].picnum == CAMERA1) - sprite[k].yvel = 0; - k = nextspritestat[k]; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4) +void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4) { spritetype* s, * sj; walltype* wal; @@ -424,19 +226,9 @@ void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4) s = &sprite[i]; - if (s->xrepeat < 11) - { - if (!isRR()) - { - if (s->picnum == RPG) goto SKIPWALLCHECK; - } - else - { - if (s->picnum == RR_CROSSBOW || ((isRRRA()) && s->picnum == RR_CHIKENCROSSBOW)) goto SKIPWALLCHECK; - } - } + if(s->picnum == RPG && s->xrepeat < 11) goto SKIPWALLCHECK; - if ((isRR()) || s->picnum != SHRINKSPARK) + if(s->picnum != SHRINKSPARK) { tempshort[0] = s->sectnum; dasect = s->sectnum; @@ -482,8 +274,7 @@ void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4) SKIPWALLCHECK: - int val = (isRR()) ? 24 : 16; - q = -(val << 8) + (krand() & ((32 << 8) - 1)); + q = -(16 << 8) + (krand() & ((32 << 8) - 1)); for (x = 0; x < 7; x++) { @@ -504,7 +295,7 @@ SKIPWALLCHECK: if (x == 0 || x >= 5 || AFLAMABLE(sj->picnum)) { - if ((!isRR() && s->picnum != SHRINKSPARK) || (sj->cstat & 257)) + 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)) @@ -512,145 +303,52 @@ SKIPWALLCHECK: checkhitsprite(j, i); } } - else if (!isRR()) + 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 (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)) { - 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; - } - } + j = nextj; + continue; } - } - else - { - if (sj->extra >= 0 && sj != s && (badguy(sj) || sj->picnum == RR_QUEBALL || sj->picnum == RR_3440 || sj->picnum == RR_STRIPEBALL || (sj->cstat & 257) || sj->picnum == RR_LNRDLYINGDEAD)) + if (s->picnum == MORTER && j == s->owner) { - if (s->picnum == RR_MORTER && j == s->owner) - { - j = nextj; - continue; - } - if ((isRRRA()) && s->picnum == RR_CHEERBOMB && j == s->owner) - { - j = nextj; - continue; - } + j = nextj; + continue; + } - if (sj->picnum == APLAYER) sj->z -= PHEIGHT; - d = dist(s, sj); - if (sj->picnum == APLAYER) sj->z += PHEIGHT; + 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)) + 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 ((isRRRA()) && sprite[j].picnum == RR_MINION && sprite[j].pal == 19) + 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) { - j = nextj; - continue; + if (s->picnum == LAVAPOOL) + hittype[j].picnum = FLAMETHROWERFLAME; + else + hittype[j].picnum = RADIUSEXPLOSION; } - - hittype[j].ang = getangle(sj->x - s->x, sj->y - s->y); - - if (s->picnum == RR_CROSSBOW && sj->extra > 0) - hittype[j].picnum = RR_CROSSBOW; - else if ((isRRRA()) && s->picnum == RR_CHIKENCROSSBOW && sj->extra > 0) - hittype[j].picnum = RR_CROSSBOW; else - hittype[j].picnum = RR_RADIUSEXPLOSION; + hittype[j].picnum = FLAMETHROWERFLAME; + } + if (s->picnum != SHRINKSPARK && (!isWorldTour() && s->picnum != LAVAPOOL)) + { if (d < r / 3) { if (hp4 == hp3) hp4++; @@ -667,32 +365,41 @@ SKIPWALLCHECK: hittype[j].extra = hp1 + (krand() % (hp2 - hp1)); } - int pic = sprite[j].picnum; - if ((isRRRA())? - (pic != RR_HULK && pic != RR_MAMAJACKOLOPE && pic != RR_GUITARBILLY && pic != RR_BANJOCOOTER && pic != RR_MAMACLOUD) : - (pic != RR_HULK && pic != RR_SBMOVE)) + 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 (sprite[j].xvel < 0) sprite[j].xvel = 0; - sprite[j].xvel += (sprite[j].extra << 2); + if (sj->xvel < 0) sj->xvel = 0; + sj->xvel += (s->extra << 2); } - if (sj->picnum == RR_STATUEFLASH || sj->picnum == RR_QUEBALL || - sj->picnum == RR_STRIPEBALL || sj->picnum == RR_3440) + 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 (sprite[j].picnum != RR_RADIUSEXPLOSION && - s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) + if (sj->picnum != RADIUSEXPLOSION && + s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) + { + if (sj->picnum == APLAYER) { - if (sprite[j].picnum == APLAYER) + p = sj->yvel; + + if (isWorldTour() && hittype[j].picnum == FLAMETHROWERFLAME && sprite[s->owner].picnum == APLAYER) { - p = sprite[j].yvel; - if (ps[p].newowner >= 0) - { - clearcamera(&ps[p]); - } + ps[p].numloogs = -1 - s->yvel; + } + + if (ps[p].newowner >= 0) + { + clearcamera(&ps[p]); } - hittype[j].owner = s->owner; } + hittype[j].owner = s->owner; } } } @@ -708,7 +415,7 @@ SKIPWALLCHECK: // //--------------------------------------------------------------------------- -int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype) +int movesprite_d(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype) { int daz, h, oldx, oldy; short retval, dasectnum, cd; @@ -741,9 +448,7 @@ int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned retval = clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype); else { - if (isRR()) - cd = 192; - else if (sprite[spritenum].picnum == LIZMAN) + 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)) @@ -757,30 +462,26 @@ int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned retval = clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), cd, (4 << 8), (4 << 8), cliptype); } - bool rr = (isRR()); // conditional code from hell... if (dasectnum < 0 || (dasectnum >= 0 && ((hittype[spritenum].actorstayput >= 0 && hittype[spritenum].actorstayput != dasectnum) || - (!rr && - ( - ((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].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 && (rr || sprite[spritenum].picnum == LIZMAN)) - sprite[spritenum].ang = (krand() & 2047); - else if ((hittype[spritenum].temp_data[0] & 3) == 1 && (rr || sprite[spritenum].picnum != COMMANDER)) - sprite[spritenum].ang = (krand() & 2047); - setsprite(spritenum, oldx, oldy, sprite[spritenum].z); + 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); + return (16384+dasectnum); } - if ((retval & 49152) >= 32768 && (hittype[spritenum].cgg == 0)) sprite[spritenum].ang += 768; + if ((retval&49152) >= 32768 && (hittype[spritenum].cgg==0)) sprite[spritenum].ang += 768; } else { @@ -807,23 +508,23 @@ int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned //--------------------------------------------------------------------------- // -// +// // //--------------------------------------------------------------------------- -int ssp(short i, unsigned int cliptype) //The set sprite function +void lotsofmoney_d(spritetype *s, short n) { - spritetype* s; - int movetype; + lotsofstuff(s, n, MONEY); +} - s = &sprite[i]; +void lotsofmail_d(spritetype *s, short n) +{ + lotsofstuff(s, n, MAIL); +} - movetype = movesprite(i, - (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, - (s->xvel * (sintable[s->ang & 2047])) >> 14, s->zvel, - cliptype); - - return (movetype == 0); +void lotsofpaper_d(spritetype *s, short n) +{ + lotsofstuff(s, n, PAPER); } //--------------------------------------------------------------------------- @@ -832,46 +533,7 @@ int ssp(short i, unsigned int cliptype) //The set sprite function // //--------------------------------------------------------------------------- -void insertspriteq(int i) -{ - if (spriteqamount > 0) - { - if (spriteq[spriteqloc] >= 0) - sprite[spriteq[spriteqloc]].xrepeat = 0; - spriteq[spriteqloc] = i; - spriteqloc = (spriteqloc + 1) % spriteqamount; - } - else sprite[i].xrepeat = sprite[i].yrepeat = 0; -} - -//--------------------------------------------------------------------------- -// -// consolidation of several nearly identical functions -// lotsofmoney -> MONEY / RR_FEATHERS -// lotsofmail -> MAIL -// lotsofpaper -> PAPER -// -//--------------------------------------------------------------------------- - -void lotsofstuff(spritetype* s, short n, int spawntype) -{ - short i, j; - for (i = n; i > 0; i--) - { - short r1 = krand(), r2 = krand(); // using the RANDCORRECT version from RR. - // TRANSITIONAL RedNukem sets the spawner as owner. - j = EGS(s->sectnum, s->x, s->y, s->z - (r2 % (47 << 8)), spawntype, -32, 8, 8, r1 & 2047, 0, 0, 0, 5); - sprite[j].cstat = krand() & 12; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void guts(spritetype* s, short gtype, short n, short p) +void guts_d(spritetype* s, short gtype, short n, short p) { int gutz, floorz; int i=0, j; @@ -888,25 +550,12 @@ void guts(spritetype* s, short gtype, short n, short p) if (gutz > (floorz - (8 << 8))) gutz = floorz - (8 << 8); - if (!isRR() && s->picnum == COMMANDER) + if (s->picnum == COMMANDER) gutz -= (24 << 8); if (badguy(s) && s->pal == 6) pal = 6; - else - { - pal = 0; - if (isRRRA()) - { - if (s->picnum == RR_MINION && (s->pal == 8 || s->pal == 19)) pal = s->pal; - } - } - - if (isRR()) - { - sx >>= 1; - sy >>= 1; - } + else pal = 0; for (j = 0; j < n; j++) { @@ -919,7 +568,7 @@ void guts(spritetype* s, short gtype, short n, short p) 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 (!isRR() && sprite[i].picnum == JIBS2) + if (sprite[i].picnum == JIBS2) { sprite[i].xrepeat >>= 2; sprite[i].yrepeat >>= 2; @@ -935,7 +584,7 @@ void guts(spritetype* s, short gtype, short n, short p) // //--------------------------------------------------------------------------- -void gutsdir(spritetype* s, short gtype, short n, short p) +void gutsdir_d(spritetype* s, short gtype, short n, short p) { int gutz, floorz; short i, j; @@ -951,7 +600,7 @@ void gutsdir(spritetype* s, short gtype, short n, short p) if (gutz > (floorz - (8 << 8))) gutz = floorz - (8 << 8); - if (!isRR() && s->picnum == COMMANDER) + if (s->picnum == COMMANDER) gutz -= (24 << 8); for (j = 0; j < n; j++) @@ -964,50 +613,13 @@ void gutsdir(spritetype* s, short gtype, short n, short p) } } -//--------------------------------------------------------------------------- -// -// movesector - why is this in actors.cpp? -// -//--------------------------------------------------------------------------- - -void ms(short i) -{ - //T1,T2 and T3 are used for all the sector moving stuff!!! - - short startwall, endwall, x; - int tx, ty; - spritetype* s; - - s = &sprite[i]; - - s->x += (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14; - s->y += (s->xvel * (sintable[s->ang & 2047])) >> 14; - - int j = hittype[i].temp_data[1]; - int k = hittype[i].temp_data[2]; - - startwall = sector[s->sectnum].wallptr; - endwall = startwall + sector[s->sectnum].wallnum; - for (x = startwall; x < endwall; x++) - { - rotatepoint( - 0, 0, - msx[j], msy[j], - k & 2047, &tx, &ty); - - dragpoint(x, s->x + tx, s->y + ty); - - j++; - } -} - //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- -void movefta(void) +void movefta_d(void) { int x, px, py, sx, sy; short i, j, p, psect, ssect, nexti; @@ -1049,18 +661,9 @@ void movefta(void) continue; } - if (!isRR() || s->pal == 33 || s->type == RR_VIXEN || - ((isRRRA()) && isIn(s->type, RR_COOT, RR_COOTSTAYPUT, RR_BIKERSTAND, RR_BIKERRIDE, - RR_BIKERRIDEDAISY, RR_MINIONAIRBOAT, RR_HULKAIRBOAT, - RR_DAISYAIRBOAT, RR_JACKOLOPE, RR_BANJOCOOTER, - RR_GUITARBILLY, RR_MAMAJACKOLOPE, RR_BIKERBV, - RR_MAKEOUT, RR_CHEER, RR_CHEERSTAYPUT)) || - (sintable[(s->ang + 512) & 2047] * (px - sx) + sintable[s->ang & 2047] * (py - sy) >= 0)) - { - 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); - } + 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 { @@ -1069,74 +672,45 @@ void movefta(void) 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) + + if (j) switch(s->picnum) { - bool res = (!isRR()) ? - isIn(s->picnum, - RUBBERCAN, - EXPLODINGBARREL, - WOODENHORSE, - HORSEONSIDE, - CANWITHSOMETHING, - CANWITHSOMETHING2, - CANWITHSOMETHING3, - CANWITHSOMETHING4, - FIREBARREL, - FIREVASE, - NUKEBARREL, - NUKEBARRELDENTED, - NUKEBARRELLEAKED, - TRIPBOMB) : - isIn(s->picnum, - RR_1251, - RR_1268, - RR_1187, - RR_1304, - RR_1305, - RR_1306, - RR_1309, - RR_1315, - RR_1317, - RR_1388); - - - if (res) - { - if (sector[s->sectnum].ceilingstat & 1) + 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); - } - else - { -#if 0 - // TRANSITIONAL: RedNukem has this here. Needed? - if (A_CheckSpriteFlags(spriteNum, SFLAG_USEACTIVATOR) && sector[sprite[spriteNum].sectnum].lotag & 16384) break; -#endif + break; + + default: hittype[i].timetosleep = 0; check_fta_sounds(i); changespritestat(i, STAT_ACTOR); - } + break; } else hittype[i].timetosleep = 0; } } - if ((!isRR() || !j) && badguy(s)) + if (badguy(s)) { if (sector[s->sectnum].ceilingstat & 1) s->shade = sector[s->sectnum].ceilingshade; else s->shade = sector[s->sectnum].floorshade; - - if (isRR() && (s->picnum != RR_HEN || s->picnum != RR_COW || s->picnum != RR_PIG || s->picnum != RR_DOGRUN || ((isRRRA()) && s->picnum != RR_JACKOLOPE))) - if (wakeup(i, p)) - { - hittype[i].timetosleep = 0; - check_fta_sounds(i); - changespritestat(i, STAT_ACTOR); - } - } } i = nexti; @@ -1149,28 +723,15 @@ void movefta(void) // //--------------------------------------------------------------------------- -int ifhitsectors(int sectnum) +int ifhitsectors_d(int sectnum) { int i = headspritestat[STAT_MISC]; - if (!isRR()) + while(i >= 0) { - while (i >= 0) - { - if (sprite[i].picnum == EXPLOSION2 && sectnum == sprite[i].sectnum) - return i; - i = nextspritestat[i]; - } + if (sprite[i].picnum == EXPLOSION2 && sectnum == sprite[i].sectnum) + return i; + i = nextspritestat[i]; } - else - { - while (i >= 0) - { - if (sprite[i].picnum == RR_EXPLOSION2 || (sprite[i].picnum == RR_EXPLOSION3 && sectnum == sprite[i].sectnum)) - return i; - i = nextspritestat[i]; - } - } - return -1; } @@ -1180,7 +741,7 @@ int ifhitsectors(int sectnum) // //--------------------------------------------------------------------------- -int ifhitbyweapon(int sn) +int ifhitbyweapon_d(int sn) { short j, p; spritetype* npc; @@ -1193,7 +754,7 @@ int ifhitbyweapon(int sn) if (npc->picnum == APLAYER) { - if (ud.god && (isRR() || hittype[sn].picnum != SHRINKSPARK)) return -1; + if (ud.god && hittype[sn].picnum != SHRINKSPARK) return -1; p = npc->yvel; j = hittype[sn].owner; @@ -1208,7 +769,7 @@ int ifhitbyweapon(int sn) if (j >= 0) { - if (npc->extra <= 0 && hittype[sn].picnum != pPick2(FREEZEBLAST, RR_ALIENBLAST)) + if (npc->extra <= 0 && hittype[sn].picnum != FREEZEBLAST) { npc->extra = 0; @@ -1224,19 +785,32 @@ int ifhitbyweapon(int sn) } } - bool res = !isRR() ? - isIn(hittype[sn].picnum, RADIUSEXPLOSION, RPG, HYDRENT, HEAVYHBOMB, SEENINE, OOZFILTER, EXPLODINGBARREL) : - (isIn(hittype[sn].picnum, RR_DYNAMITE, RR_POWDERKEGSPRITE, RR_1228, RR_1273, RR_1315, RR_SEENINE, RR_RADIUSEXPLOSION, RR_CROSSBOW) || - (isRRRA() && hittype[sn].picnum == RR_CHIKENCROSSBOW)); - - int shift = res ? 2 : 1; - ps[p].posxv += hittype[sn].extra * (sintable[(hittype[sn].ang + 512) & 2047]) << shift; - ps[p].posyv += hittype[sn].extra * (sintable[hittype[sn].ang & 2047]) << shift; + 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 ((isRR() || hittype[sn].picnum == SHRINKSPARK) && npc->xrepeat < 24) + if (hittype[sn].picnum == SHRINKSPARK && npc->xrepeat < 24) return -1; if (isWorldTour() && hittype[sn].picnum == FIREFLY && npc->xrepeat < 48) @@ -1246,7 +820,7 @@ int ifhitbyweapon(int sn) } npc->extra -= hittype[sn].extra; - if (npc->picnum != pPick2(RECON, RR_4989) && npc->owner >= 0 && sprite[npc->owner].statnum < MAXSTATUS) + if (npc->picnum != RECON && npc->owner >= 0 && sprite[npc->owner].statnum < MAXSTATUS) npc->owner = hittype[sn].owner; } @@ -1281,409 +855,17 @@ int ifhitbyweapon(int sn) return FLAMETHROWERFLAME; } - - - hittype[sn].extra = -1; - return -1; } + + //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- -void movecyclers(void) -{ - short q, j, x, t, s, * c; - walltype* wal; - char cshade; - - for (q = numcyclers - 1; q >= 0; q--) - { - - c = &cyclers[q][0]; - s = c[0]; - - t = c[3]; - j = t + (sintable[c[1] & 2047] >> 10); - cshade = c[2]; - - if (j < cshade) j = cshade; - else if (j > t) j = t; - - c[1] += sector[s].extra; - if (c[5]) - { - wal = &wall[sector[s].wallptr]; - for (x = sector[s].wallnum; x > 0; x--, wal++) - if (wal->hitag != 1) - { - wal->shade = j; - - if ((wal->cstat & 2) && wal->nextwall >= 0) - wall[wal->nextwall].shade = j; - - } - sector[s].floorshade = sector[s].ceilingshade = j; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void movedummyplayers(void) -{ - short i, p, nexti; - - i = headspritestat[STAT_DUMMYPLAYER]; - while (i >= 0) - { - nexti = nextspritestat[i]; - - p = sprite[sprite[i].owner].yvel; - - if ((!isRR() && ps[p].on_crane >= 0) || sector[ps[p].cursectnum].lotag != 1 || sprite[ps[p].i].extra <= 0) - { - ps[p].dummyplayersprite = -1; - deletesprite(i); - i = nexti; - continue; - } - else - { - if (ps[p].on_ground && ps[p].on_warping_sector == 1 && sector[ps[p].cursectnum].lotag == 1) - { - sprite[i].cstat = 257; - sprite[i].z = sector[sprite[i].sectnum].ceilingz + (27 << 8); - sprite[i].ang = ps[p].q16ang >> FRACBITS; - if (hittype[i].temp_data[0] == 8) - hittype[i].temp_data[0] = 0; - else hittype[i].temp_data[0]++; - } - else - { - if (sector[sprite[i].sectnum].lotag != 2) sprite[i].z = sector[sprite[i].sectnum].floorz; - sprite[i].cstat = (short)32768; - } - } - - sprite[i].x += (ps[p].posx - ps[p].oposx); - sprite[i].y += (ps[p].posy - ps[p].oposy); - setsprite(i, sprite[i].x, sprite[i].y, sprite[i].z); - i = nexti; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -int otherp; -void moveplayers(void) //Players -{ - short i, nexti; - int otherx; - spritetype* s; - struct player_struct* p; - - i = headspritestat[STAT_PLAYER]; - while (i >= 0) - { - nexti = nextspritestat[i]; - - s = &sprite[i]; - p = &ps[s->yvel]; - if (s->owner >= 0) - { - if (p->newowner >= 0) //Looking thru the camera - { - s->x = p->oposx; - s->y = p->oposy; - hittype[i].bposz = s->z = p->oposz + PHEIGHT; - s->ang = p->oq16ang >> FRACBITS; - setsprite(i, s->x, s->y, s->z); - } - else - { - if (ud.multimode > 1) - otherp = findotherplayer(s->yvel, &otherx); - else - { - otherp = s->yvel; - otherx = 0; - } - - execute(i, s->yvel, otherx); - - p->oq16ang = p->q16ang; - - if (ud.multimode > 1) - if (sprite[ps[otherp].i].extra > 0) - { - if (s->yrepeat > 32 && sprite[ps[otherp].i].yrepeat < 32) - { - if (otherx < 1400 && p->knee_incs == 0) - { - p->knee_incs = 1; - p->weapon_pos = -1; - p->actorsqu = ps[otherp].i; - } - } - } - if (ud.god) - { - s->extra = p->max_player_health; - s->cstat = 257; - if (!isWW2GI() && !isRR()) - p->jetpack_amount = 1599; - } - - - if (s->extra > 0) - { - // currently alive... - - hittype[i].owner = i; - - if (ud.god == 0) - if (ceilingspace(s->sectnum) || floorspace(s->sectnum)) - quickkill(p); - } - else - { - - p->posx = s->x; - p->posy = s->y; - p->posz = s->z - (20 << 8); - - p->newowner = -1; - - if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS) - { - int ang = p->q16ang >> FRACBITS; - ang += getincangle(ang, getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1; - ang &= 2047; - p->q16ang = ang << FRACBITS; - } - - } - s->ang = p->q16ang >> FRACBITS; - } - } - else - { - if (p->holoduke_on == -1) - { - deletesprite(i); - i = nexti; - continue; - } - - hittype[i].bposx = s->x; - hittype[i].bposy = s->y; - hittype[i].bposz = s->z; - - s->cstat = 0; - - if (s->xrepeat < 42) - { - s->xrepeat += 4; - s->cstat |= 2; - } - else s->xrepeat = 42; - if (s->yrepeat < 36) - s->yrepeat += 4; - else - { - s->yrepeat = 36; - if (sector[s->sectnum].lotag != ST_2_UNDERWATER) - makeitfall(i); - if (s->zvel == 0 && sector[s->sectnum].lotag == ST_1_ABOVE_WATER) - s->z += (32 << 8); - } - - if (s->extra < 8) - { - s->xvel = 128; - s->ang = p->q16ang >> FRACBITS; - s->extra++; - //IFMOVING; // JBF 20040825: is really "if (ssp(i,CLIPMASK0)) ;" which is probably - ssp(i, CLIPMASK0); // not the safest of ideas because a zealous optimiser probably sees - // it as redundant, so I'll call the "ssp(i,CLIPMASK0)" explicitly. - } - else - { - s->ang = 2047 - (p->q16ang >> FRACBITS); - setsprite(i, s->x, s->y, s->z); - } - } - - if (sector[s->sectnum].ceilingstat & 1) - s->shade += (sector[s->sectnum].ceilingshade - s->shade) >> 1; - else - s->shade += (sector[s->sectnum].floorshade - s->shade) >> 1; - - i = nexti; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void movefx(void) -{ - short i, j, nexti, p; - int x, ht; - spritetype* s; - - i = headspritestat[STAT_FX]; - while (i >= 0) - { - s = &sprite[i]; - - nexti = nextspritestat[i]; - - switch (s->picnum) - { - case RESPAWN: - if (sprite[i].extra == 66) - { - j = spawn(i, sprite[i].hitag); - if (isRRRA()) - { - sprite[j].pal = sprite[i].pal; - if (sprite[j].picnum == RR_MAMAJACKOLOPE) - { - if (sprite[j].pal == 30) - { - sprite[j].xrepeat = 26; - sprite[j].yrepeat = 26; - sprite[j].clipdist = 75; - } - else if (sprite[j].pal == 31) - { - sprite[j].xrepeat = 36; - sprite[j].yrepeat = 36; - sprite[j].clipdist = 100; - } - else if (sprite[j].pal == 32) - { - sprite[j].xrepeat = 50; - sprite[j].yrepeat = 50; - sprite[j].clipdist = 100; - } - else - { - sprite[j].xrepeat = 50; - sprite[j].yrepeat = 50; - sprite[j].clipdist = 100; - } - } - - if (sprite[j].pal == 8) - { - sprite[j].cstat |= 2; - } - - if (sprite[j].pal != 6) - { - deletesprite(i); - i = nexti; - continue; - } - sprite[i].extra = (66 - 13); - sprite[j].pal = 0; - } - else - { - deletesprite(i); - i = nexti; - continue; - } - } - else if (sprite[i].extra > (66 - 13)) - sprite[i].extra++; - break; - - case MUSICANDSFX: - - ht = s->hitag; - - if (hittype[i].temp_data[1] != (int)SoundEnabled()) - { - hittype[i].temp_data[1] = SoundEnabled(); - hittype[i].temp_data[0] = 0; - } - - if (s->lotag >= 1000 && s->lotag < 2000) - { - x = ldist(&sprite[ps[screenpeek].i], s); - if (x < ht && hittype[i].temp_data[0] == 0) - { - FX_SetReverb(s->lotag - 1000); - hittype[i].temp_data[0] = 1; - } - if (x >= ht && hittype[i].temp_data[0] == 1) - { - FX_SetReverb(0); - FX_SetReverbDelay(0); - hittype[i].temp_data[0] = 0; - } - } - else if (s->lotag < 999 && (unsigned)sector[s->sectnum].lotag < ST_9_SLIDING_ST_DOOR && snd_ambience && sector[sprite[i].sectnum].floorz != sector[sprite[i].sectnum].ceilingz) - { - auto flags = S_GetUserFlags(s->lotag); - if (flags & SF_MSFX) - { - int x = dist(&sprite[ps[screenpeek].i], s); - - if (x < ht && hittype[i].temp_data[0] == 0) - { - // Start playing an ambience sound. - A_PlaySound(s->lotag, i, CHAN_AUTO, CHANF_LOOP); - hittype[i].temp_data[0] = 1; // AMBIENT_SFX_PLAYING - } - else if (x >= ht && hittype[i].temp_data[0] == 1) - { - // Stop playing ambience sound because we're out of its range. - S_StopEnvSound(s->lotag, i); - } - } - - if ((flags & (SF_GLOBAL | SF_DTAG)) == SF_GLOBAL) - { - if (hittype[i].temp_data[4] > 0) hittype[i].temp_data[4]--; - else for (p = connecthead; p >= 0; p = connectpoint2[p]) - if (p == myconnectindex && ps[p].cursectnum == s->sectnum) - { - S_PlaySound(s->lotag + (unsigned)global_random % (s->hitag + 1)); - hittype[i].temp_data[4] = 26 * 40 + (global_random % (26 * 40)); - } - } - } - break; - } - i = nexti; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void movefallers(void) +void movefallers_d(void) { short i, nexti, sect, j; spritetype* s; @@ -1705,11 +887,7 @@ void movefallers(void) j = ifhitbyweapon(i); if (j >= 0) { - bool res = !isRR() ? - isIn(j, FIREEXT, RPG, RADIUSEXPLOSION, SEENINE, OOZFILTER) : - (isIn(j, RR_CROSSBOW, RR_RADIUSEXPLOSION, RR_SEENINE, RR_OOZFILTER) || (isRRRA() && j == RR_CHIKENCROSSBOW)); - - if (res) + if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) { if (s->extra <= 0) { @@ -1721,7 +899,7 @@ void movefallers(void) { hittype[j].temp_data[0] = 1; sprite[j].cstat &= (65535 - 64); - if (!isRR() ? isIn(j, CEILINGSTEAM, STEAM) : isIn(j, RR_CEILINGSTEAM, RR_STEAM)) + if (sprite[j].picnum == CEILINGSTEAM || sprite[j].picnum == STEAM) sprite[j].cstat |= 32768; } j = nextspritestat[j]; @@ -1741,13 +919,8 @@ void movefallers(void) { if (s->lotag > 0) { - s->lotag -= 3; - if (isRR()) - { - s->xvel = (64 + krand()) & 127; - s->zvel = -(1024 + (krand() & 1023)); - } - else if (s->lotag <= 0) + s->lotag-=3; + if (s->lotag <= 0) { s->xvel = (32 + (krand() & 63)); s->zvel = -(1024 + (krand() & 1023)); @@ -1757,8 +930,8 @@ void movefallers(void) { if (s->xvel > 0) { - s->xvel -= isRR()? 2 : 8; - ssp(i, CLIPMASK0); + s->xvel -= 8; + ssp(i,CLIPMASK0); } if (floorspace(s->sectnum)) x = 0; @@ -1796,282 +969,6 @@ void movefallers(void) // //--------------------------------------------------------------------------- -static void movecrane(int i) -{ - auto t = &hittype[i].temp_data[0]; - auto s = &sprite[i]; - int sect = s->sectnum; - int x; - int crane = pPick(CRANE); - - //t[0] = state - //t[1] = checking sector number - - if (s->xvel) getglobalz(i); - - if (t[0] == 0) //Waiting to check the sector - { - int j = headspritesect[t[1]]; - while (j >= 0) - { - int nextj = nextspritesect[j]; - switch (sprite[j].statnum) - { - case STAT_ACTOR: - case STAT_ZOMBIEACTOR: - case STAT_STANDABLE: - case STAT_PLAYER: - 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); - t[0]++; - deletesprite(i); - return; - } - j = nextj; - } - } - - else if (t[0] == 1) - { - if (s->xvel < 184) - { - s->picnum = crane + 1; - s->xvel += 8; - } - //IFMOVING; // JBF 20040825: see my rant above about this - ssp(i, CLIPMASK0); - if (sect == t[1]) - t[0]++; - } - else if (t[0] == 2 || t[0] == 7) - { - s->z += (1024 + 512); - - if (t[0] == 2) - { - if ((sector[sect].floorz - s->z) < (64 << 8)) - if (s->picnum > crane) s->picnum--; - - if ((sector[sect].floorz - s->z) < (4096 + 1024)) - t[0]++; - } - if (t[0] == 7) - { - if ((sector[sect].floorz - s->z) < (64 << 8)) - { - if (s->picnum > crane) s->picnum--; - else - { - if (s->owner == -2) - { - auto p = findplayer(s, &x); - spritesound(isRR() ? 390 : DUKE_GRUNT, ps[p].i); - if (ps[p].on_crane == i) - ps[p].on_crane = -1; - } - t[0]++; - s->owner = -1; - } - } - } - } - else if (t[0] == 3) - { - s->picnum++; - if (s->picnum == (crane + 2)) - { - auto p = checkcursectnums(t[1]); - if (p >= 0 && ps[p].on_ground) - { - s->owner = -2; - ps[p].on_crane = i; - spritesound(isRR() ? 390 : DUKE_GRUNT, ps[p].i); - ps[p].q16ang = (s->ang + 1024) << FRACBITS; - } - else - { - int j = headspritesect[t[1]]; - while (j >= 0) - { - switch (sprite[j].statnum) - { - case 1: - case 6: - s->owner = j; - break; - } - j = nextspritesect[j]; - } - } - - t[0]++;//Grabbed the sprite - t[2] = 0; - return; - } - } - else if (t[0] == 4) //Delay before going up - { - t[2]++; - if (t[2] > 10) - t[0]++; - } - else if (t[0] == 5 || t[0] == 8) - { - if (t[0] == 8 && s->picnum < (crane + 2)) - if ((sector[sect].floorz - s->z) > 8192) - s->picnum++; - - if (s->z < msx[t[4] + 2]) - { - t[0]++; - s->xvel = 0; - } - else - s->z -= (1024 + 512); - } - else if (t[0] == 6) - { - if (s->xvel < 192) - s->xvel += 8; - s->ang = getangle(msx[t[4]] - s->x, msy[t[4]] - s->y); - //IFMOVING; // JBF 20040825: see my rant above about this - ssp(i, CLIPMASK0); - if (((s->x - msx[t[4]]) * (s->x - msx[t[4]]) + (s->y - msy[t[4]]) * (s->y - msy[t[4]])) < (128 * 128)) - t[0]++; - } - - else if (t[0] == 9) - t[0] = 0; - - setsprite(msy[t[4] + 2], s->x, s->y, s->z - (34 << 8)); - - if (s->owner != -1) - { - auto p = findplayer(s, &x); - - int j = ifhitbyweapon(i); - if (j >= 0) - { - if (s->owner == -2) - if (ps[p].on_crane == i) - ps[p].on_crane = -1; - s->owner = -1; - s->picnum = crane; - return; - } - - if (s->owner >= 0) - { - setsprite(s->owner, s->x, s->y, s->z); - - hittype[s->owner].bposx = s->x; - hittype[s->owner].bposy = s->y; - hittype[s->owner].bposz = s->z; - - s->zvel = 0; - } - else if (s->owner == -2) - { - auto ang = ps[p].q16ang >> FRACBITS; - ps[p].oposx = ps[p].posx = s->x - (sintable[(ang + 512) & 2047] >> 6); - ps[p].oposy = ps[p].posy = s->y - (sintable[ang & 2047] >> 6); - ps[p].oposz = ps[p].posz = s->z + (2 << 8); - setsprite(ps[p].i, ps[p].posx, ps[p].posy, ps[p].posz); - ps[p].cursectnum = sprite[ps[p].i].sectnum; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movefountain(int i) -{ - auto t = &hittype[i].temp_data[0]; - auto s = &sprite[i]; - int x; - if (t[0] > 0) - { - if (t[0] < 20) - { - t[0]++; - - s->picnum++; - - if (s->picnum == (pPick(WATERFOUNTAIN) + 3)) - s->picnum = pPick(WATERFOUNTAIN) + 1; - } - else - { - findplayer(s, &x); - - if (x > 512) - { - t[0] = 0; - s->picnum = pPick(WATERFOUNTAIN); - } - else t[0] = 1; - } - } -} -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void moveflammable(int i) -{ - auto s = &sprite[i]; - int j; - if (hittype[i].temp_data[0] == 1) - { - hittype[i].temp_data[1]++; - if ((hittype[i].temp_data[1] & 3) > 0) return; - - if (!isRR() && s->picnum == TIRE && hittype[i].temp_data[1] == 32) - { - s->cstat = 0; - j = spawn(i, BLOODPOOL); - sprite[j].shade = 127; - } - else - { - if (s->shade < 64) s->shade++; - else - { - deletesprite(i); - return; - } - } - - j = s->xrepeat - (krand() & 7); - if (j < 10) - { - deletesprite(i); - return; - } - - s->xrepeat = j; - - j = s->yrepeat - (krand() & 7); - if (j < 4) - { - deletesprite(i); - return; - } - s->yrepeat = j; - } - if (!isRR() && s->picnum == BOX) - { - makeitfall(i); - hittype[i].ceilingz = sector[s->sectnum].ceilingz; - } -} - //--------------------------------------------------------------------------- // // Duke only @@ -2228,58 +1125,6 @@ static void movetripbomb(int i) // //--------------------------------------------------------------------------- -static void detonate(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - earthquaketime = 16; - - int j = headspritestat[STAT_EFFECTOR]; - while (j >= 0) - { - if (s->hitag == sprite[j].hitag) - { - if (sprite[j].lotag == SE_13_EXPLOSIVE) - { - if (hittype[j].temp_data[2] == 0) - hittype[j].temp_data[2] = 1; - } - else if (sprite[j].lotag == SE_8_UP_OPEN_DOOR_LIGHTS) - hittype[j].temp_data[4] = 1; - else if (sprite[j].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL) - { - if (hittype[j].temp_data[0] == 0) - hittype[j].temp_data[0] = 1; - } - else if (sprite[j].lotag == SE_21_DROP_FLOOR) - hittype[j].temp_data[0] = 1; - } - j = nextspritestat[j]; - } - - s->z -= (32 << 8); - - if ((t[3] == 1 && s->xrepeat) || s->lotag == -99) - { - int x = s->extra; - spawn(i, EXPLOSION2); - hitradius(i, seenineblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); - spritesound(PIPEBOMB_EXPLODE, i); - } - - if (s->xrepeat) - for (int x = 0; x < 8; x++) RANDOMSCRAP(s, i); - - deletesprite(i); - -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - static void movecrack(int i) { auto s = &sprite[i]; @@ -2289,22 +1134,17 @@ static void movecrack(int i) t[0] = s->cstat; t[1] = s->ang; int j = ifhitbyweapon(i); - - bool res = !isRR() ? - isIn(j, FIREEXT, RPG, RADIUSEXPLOSION, SEENINE, OOZFILTER) : - (isIn(j, RR_CROSSBOW, RR_RADIUSEXPLOSION, RR_SEENINE, RR_OOZFILTER) || (isRRRA() && j == RR_CHIKENCROSSBOW)); - - if (res) + if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) { j = headspritestat[STAT_STANDABLE]; while (j >= 0) { - if (s->hitag == sprite[j].hitag && (isRR() ? isIn(sprite[j].picnum, RR_OOZFILTER, RR_SEENINE) : isIn(sprite[j].picnum, OOZFILTER, SEENINE))) + 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); + detonate(i, EXPLOSION2); } else { @@ -2354,7 +1194,7 @@ static void movefireext(int i) spawn(i, EXPLOSION2); hitradius(i, pipebombblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); spritesound(PIPEBOMB_EXPLODE, i); - detonate(i); + detonate(i, EXPLOSION2); } else { @@ -2369,136 +1209,6 @@ static void movefireext(int i) // //--------------------------------------------------------------------------- -static void moveooz(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - int j; - if (s->shade != -32 && s->shade != -33) - { - if (s->xrepeat) - j = (ifhitbyweapon(i) >= 0); - else - j = 0; - - if (j || s->shade == -31) - { - if (j) s->lotag = 0; - - t[3] = 1; - - j = headspritestat[STAT_STANDABLE]; - while (j >= 0) - { - if (s->hitag == sprite[j].hitag && (sprite[j].picnum == pPick(SEENINE) || sprite[j].picnum == pPick(OOZFILTER))) - sprite[j].shade = -32; - j = nextspritestat[j]; - } - } - } - else - { - if (s->shade == -32) - { - if (s->lotag > 0) - { - s->lotag -= 3; - if (s->lotag <= 0) s->lotag = -99; - } - else - s->shade = -33; - } - else - { - if (s->xrepeat > 0) - { - hittype[i].temp_data[2]++; - if (hittype[i].temp_data[2] == 3) - { - if (s->picnum == pPick(OOZFILTER)) - { - hittype[i].temp_data[2] = 0; - detonate(i); - return; - } - if (s->picnum != (pPick(SEENINEDEAD) + 1)) - { - hittype[i].temp_data[2] = 0; - - if (s->picnum == pPick(SEENINEDEAD)) s->picnum++; - else if (s->picnum == pPick(SEENINE)) - s->picnum = pPick(SEENINEDEAD); - } - else - { - detonate(i); - return; - } - } - return; - } - detonate(i); - return; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void movemasterswitch(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - if (s->yvel == 1) - { - s->hitag--; - if (s->hitag <= 0) - { - operatesectors(s->sectnum, i); - - int j = headspritesect[s->sectnum]; - while (j >= 0) - { - if (sprite[j].statnum == 3) - { - switch (sprite[j].lotag) - { - case SE_2_EARTHQUAKE: - case SE_21_DROP_FLOOR: - case SE_31_FLOOR_RISE_FALL: - case SE_32_CEILING_RISE_FALL: - case SE_36_PROJ_SHOOTER: - hittype[j].temp_data[0] = 1; - break; - case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT: - hittype[j].temp_data[4] = 1; - break; - } - } - else if (sprite[j].statnum == 6) - { - if (sprite[j].picnum == pPick(SEENINE) || sprite[j].picnum == pPick(OOZFILTER)) - { - sprite[j].shade = -31; - } - } - j = nextspritesect[j]; - } - deletesprite(i); - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - static void moveviewscreen(int i) { auto s = &sprite[i]; @@ -2524,26 +1234,6 @@ static void moveviewscreen(int i) } } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movetrash(int i) -{ - auto s = &sprite[i]; - if (s->xvel == 0) s->xvel = 1; - if (ssp(i, CLIPMASK0)) - { - makeitfall(i); - if (krand() & 1) s->zvel -= 256; - if (klabs(s->xvel) < 48) - s->xvel += (krand() & 3); - } - else deletesprite(i); -} - //--------------------------------------------------------------------------- // // Duke only @@ -2639,11 +1329,10 @@ CLEAR_THE_BOLT: if (l & 1) s->cstat ^= 2; - auto bolt1 = pPick(BOLT1); - if (s->picnum == (bolt1 + 1) && (isRR() ? (krand() & 1) != 0 : (krand() & 7) == 0) && sector[sect].floorpicnum == pPick(HURTRAIL) ) - spritesound(SHORT_CIRCUIT, i); + 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==BOLT1+4) s->picnum=BOLT1; if (s->picnum & 1) { @@ -2657,182 +1346,13 @@ CLEAR_THE_BOLT: } } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movewaterdrip(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - int sect = s->sectnum; - - if (t[1]) - { - t[1]--; - if (t[1] == 0) - s->cstat &= 32767; - } - else - { - makeitfall(i); - ssp(i, CLIPMASK0); - if (s->xvel > 0) s->xvel -= 2; - - if (s->zvel == 0) - { - s->cstat |= 32768; - - if (s->pal != 2 && (isRR() || s->hitag == 0)) - spritesound(SOMETHING_DRIPPING, i); - - if (sprite[s->owner].picnum != pPick(WATERDRIP)) - { - deletesprite(i); - } - else - { - hittype[i].bposz = s->z = t[0]; - t[1] = 48 + (krand() & 31); - } - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movedoorshock(int i) -{ - auto s = &sprite[i]; - int sect = s->sectnum; - int j = abs(sector[sect].ceilingz - sector[sect].floorz) >> 9; - s->yrepeat = j + 4; - s->xrepeat = 16; - s->z = sector[sect].floorz; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movetouchplate(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - int sect = s->sectnum; - int x; - int p; - - if (t[1] == 1 && s->hitag >= 0) //Move the sector floor - { - x = sector[sect].floorz; - - if (t[3] == 1) - { - if (x >= t[2]) - { - sector[sect].floorz = x; - t[1] = 0; - } - else - { - sector[sect].floorz += sector[sect].extra; - p = checkcursectnums(sect); - if (p >= 0) ps[p].posz += sector[sect].extra; - } - } - else - { - if (x <= s->z) - { - sector[sect].floorz = s->z; - t[1] = 0; - } - else - { - sector[sect].floorz -= sector[sect].extra; - p = checkcursectnums(sect); - if (p >= 0) - ps[p].posz -= sector[sect].extra; - } - } - return; - } - - if (t[5] == 1) return; - - p = checkcursectnums(sect); - if (p >= 0 && (ps[p].on_ground || s->ang == 512)) - { - if (t[0] == 0 && !check_activator_motion(s->lotag)) - { - t[0] = 1; - t[1] = 1; - t[3] = !t[3]; - operatemasterswitches(s->lotag); - operateactivators(s->lotag, p); - if (s->hitag > 0) - { - s->hitag--; - if (s->hitag == 0) t[5] = 1; - } - } - } - else t[0] = 0; - - if (t[1] == 1) - { - int j = headspritestat[STAT_STANDABLE]; - while (j >= 0) - { - if (j != i && sprite[j].picnum == TOUCHPLATE && sprite[j].lotag == s->lotag) - { - hittype[j].temp_data[1] = 1; - hittype[j].temp_data[3] = t[3]; - } - j = nextspritestat[j]; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movecanwithsomething(int i) -{ - auto s = &sprite[i]; - makeitfall(i); - int j = ifhitbyweapon(i); - if (j >= 0) - { - spritesound(VENT_BUST, i); - for (j = 0; j < 10; j++) - RANDOMSCRAP(s, i); - - if (s->lotag) spawn(i, s->lotag); - - deletesprite(i); - } -} - //--------------------------------------------------------------------------- // // this has been broken up into lots of smaller subfunctions // //--------------------------------------------------------------------------- -void movestandables(void) +void movestandables_d(void) { int nexti; @@ -2854,88 +1374,87 @@ void movestandables(void) hittype[i].bposz = s->z; - if (picnum >= pPick(CRANE) && picnum <= pPick(CRANE) +3) + if (picnum >= CRANE && picnum <= CRANE +3) { - movecrane(i); + movecrane(i, CRANE); } - else if (picnum >= pPick(WATERFOUNTAIN) && picnum <= pPick(WATERFOUNTAIN) + 3) + else if (picnum >= WATERFOUNTAIN && picnum <= WATERFOUNTAIN + 3) { - movefountain(i); + movefountain(i, WATERFOUNTAIN); } else if (AFLAMABLE(picnum)) { - moveflammable(i); + moveflammable(i, TIRE, BOX, BLOODPOOL); } - else if (!isRR() && picnum == TRIPBOMB) + else if (picnum == TRIPBOMB) { movetripbomb(i); } - else if (picnum >= pPick(CRACK1) && picnum <= pPick(CRACK1)+3) + else if (picnum >= CRACK1 && picnum <= CRACK1 + 3) { movecrack(i); } - else if (!isRR() && picnum == FIREEXT) + else if (picnum == FIREEXT) { movefireext(i); } - else if (picnum == pPick(OOZFILTER) || picnum == pPick(SEENINE) || picnum == pPick(SEENINEDEAD) || picnum == (pPick(SEENINEDEAD) + 1)) + else if (picnum == OOZFILTER || picnum == SEENINE || picnum == SEENINEDEAD || picnum == (SEENINEDEAD + 1)) { - moveooz(i); + moveooz(i, SEENINE, SEENINEDEAD, OOZFILTER, EXPLOSION2); } else if (picnum == MASTERSWITCH) { - movemasterswitch(i); + movemasterswitch(i, SEENINE, OOZFILTER); } - else if (!isRR() && (picnum == VIEWSCREEN || picnum == VIEWSCREEN2)) + else if (picnum == VIEWSCREEN || picnum == VIEWSCREEN2) { moveviewscreen(i); } - else if (picnum == pPick(TRASH)) + else if (picnum == TRASH) { movetrash(i); } - else if (!isRR() && picnum >= SIDEBOLT1 && picnum <= SIDEBOLT1 + 3) + else if (picnum >= SIDEBOLT1 && picnum <= SIDEBOLT1 + 3) { movesidebolt(i); } - else if (picnum >= pPick(BOLT1) && picnum <= pPick(BOLT1) + 3) + else if (picnum >= BOLT1 && picnum <= BOLT1 + 3) { movebolt(i); } - else if (picnum == pPick(WATERDRIP)) + else if (picnum == WATERDRIP) { - movewaterdrip(i); + movewaterdrip(i, WATERDRIP); } - else if (picnum == pPick(DOORSHOCK)) + else if (picnum == DOORSHOCK) { movedoorshock(i); } else if (picnum == TOUCHPLATE) { - movetouchplate(i); + movetouchplate(i, TOUCHPLATE); } - else if (isRR() ? picnum == RR_CANWITHSOMETHING : isIn(picnum, CANWITHSOMETHING, CANWITHSOMETHING2, CANWITHSOMETHING3, CANWITHSOMETHING4)) + else if (isIn(picnum, CANWITHSOMETHING, CANWITHSOMETHING2, CANWITHSOMETHING3, CANWITHSOMETHING4)) { movecanwithsomething(i); } - else if (!isRR() ? - isIn(picnum, + else if (isIn(picnum, EXPLODINGBARREL, WOODENHORSE, HORSEONSIDE, @@ -2949,22 +1468,7 @@ void movestandables(void) RUBBERCAN, STEAM, CEILINGSTEAM, - WATERBUBBLEMAKER) : - isIn(picnum, - RR_1187, - RR_1196, - RR_1251, - RR_1268, - RR_1304, - RR_1305, - RR_1306, - RR_1315, - RR_1317, - RR_1388, - RR_STEAM, - RR_CEILINGSTEAM, - RR_WATERBUBBLEMAKER) - ) + WATERBUBBLEMAKER)) { int x; int p = findplayer(s, &x); @@ -2979,106 +1483,10 @@ void movestandables(void) // //--------------------------------------------------------------------------- -static void bounce(int i) +void moveweapons_d(void) { - int k, l, daang, dax, day, daz, xvect, yvect, zvect; - short hitsect; - spritetype* s = &sprite[i]; - - xvect = mulscale10(s->xvel, sintable[(s->ang + 512) & 2047]); - yvect = mulscale10(s->xvel, sintable[s->ang & 2047]); - zvect = s->zvel; - - hitsect = s->sectnum; - - k = sector[hitsect].wallptr; l = wall[k].point2; - daang = getangle(wall[l].x - wall[k].x, wall[l].y - wall[k].y); - - if (s->z < (hittype[i].floorz + hittype[i].ceilingz) >> 1) - k = sector[hitsect].ceilingheinum; - else - k = sector[hitsect].floorheinum; - - dax = mulscale14(k, sintable[(daang) & 2047]); - day = mulscale14(k, sintable[(daang + 1536) & 2047]); - daz = 4096; - - k = xvect * dax + yvect * day + zvect * daz; - l = dax * dax + day * day + daz * daz; - if ((abs(k) >> 14) < l) - { - k = divscale17(k, l); - xvect -= mulscale16(dax, k); - yvect -= mulscale16(day, k); - zvect -= mulscale16(daz, k); - } - - s->zvel = zvect; - s->xvel = ksqrt(dmulscale8(xvect, xvect, yvect, yvect)); - s->ang = getangle(xvect, yvect); -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movetongue(int i) -{ - spritetype* s = &sprite[i]; - - hittype[i].temp_data[0] = sintable[(hittype[i].temp_data[1]) & 2047] >> 9; - hittype[i].temp_data[1] += 32; - if (hittype[i].temp_data[1] > 2047) - { - deletesprite(i); - return; - } - - if (sprite[s->owner].statnum == MAXSTATUS) - if (badguy(&sprite[s->owner]) == 0) - { - deletesprite(i); - return; - } - - s->ang = sprite[s->owner].ang; - s->x = sprite[s->owner].x; - s->y = sprite[s->owner].y; - if (sprite[s->owner].picnum == APLAYER) - s->z = sprite[s->owner].z - (34 << 8); - for (int k = 0; k < hittype[i].temp_data[0]; k++) - { - int q = 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 / 12)), pPick(TONGUE), -40 + (k << 1), - 8, 8, 0, 0, 0, i, 5); - sprite[q].cstat = 128; - sprite[q].pal = 8; - } - int k = hittype[i].temp_data[0]; // do not depend on the above loop counter. - int q = 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 / 12)), pPick(INNERJAW), -40, - 32, 32, 0, 0, 0, i, 5); - sprite[q].cstat = 128; - if (hittype[i].temp_data[1] > 512 && hittype[i].temp_data[1] < (1024)) - sprite[q].picnum = pPick(INNERJAW) + 1; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void moveweapons(void) -{ - int j, k, nexti, p, q, tempsect; - int dax, day, daz, x, l, ll, x1, y1; + int j, k, nexti, p; + int dax, day, daz, x, ll; unsigned int qq; spritetype* s; @@ -3086,7 +1494,6 @@ void moveweapons(void) { nexti = nextspritestat[i]; s = &sprite[i]; - int picnum = picnum; if (s->sectnum < 0) { @@ -3098,41 +1505,42 @@ void moveweapons(void) hittype[i].bposy = s->y; hittype[i].bposz = s->z; - if (picnum == pPick(RADIUSEXPLOSION) || (!isRR() && picnum == KNEE)) + switch(s->picnum) { - deletesprite(i); - } - - else if (picnum == pPick(TONGUE)) - { - movetongue(i); - } - - else if (picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST) && (s->yvel < 1 || s->extra < 2 || (s->xvel | s->zvel) == 0)) - { - j = spawn(i, pPick(TRANSPORTERSTAR)); - sprite[j].pal = 1; - sprite[j].xrepeat = 32; - sprite[j].yrepeat = 32; + case RADIUSEXPLOSION: + case KNEE: deletesprite(i); continue; - } + case TONGUE: + movetongue(i, TONGUE, INNERJAW); + continue; - else if (!isRR() ? - (isIn(picnum, FREEZEBLAST, SHRINKSPARK, RPG, FIRELASER, SPIT, COOLEXPLOSION1) || (isWorldTour() && picnum == FIREBALL)) : - (isIn(picnum, RR_ALIENBLAST, RR_CROSSBOW, RR_FIRELASER, RR_SHITBALL, RR_CIRCLESAW, RR_UWHIP, RR_OWHIP, RR_DILDO) || (isRRRA() && isIn(picnum, RR_CHIKENCROSSBOW, RR_1790))) - ) - { - if (!isRR() && picnum == COOLEXPLOSION1) + 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 ((picnum == pPick2(RPG, RR_CROSSBOW) || (isRRRA() && picnum == RR_CHIKENCROSSBOW)) && sector[s->sectnum].lotag == 2) + if (s->picnum == RPG && sector[s->sectnum].lotag == 2) { - k = s->xvel >> 1; - ll = s->zvel >> 1; + k = s->xvel>>1; + ll = s->zvel>>1; } else { @@ -3145,175 +1553,119 @@ void moveweapons(void) getglobalz(i); qq = CLIPMASK1; - if (picnum == pPick2(RPG, RR_CROSSBOW)) + switch(s->picnum) { - if (hittype[i].picnum != pPick(BOSS2) && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) - { - j = spawn(i, pPick(SMALLSMOKE)); - sprite[j].z += (1 << 8); - } - } - else if (isRRRA() && picnum == RR_CHIKENCROSSBOW) - { - s->hitag++; - if (hittype[i].picnum != RR_BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) - { - j = spawn(i, RR_SMALLSMOKE); - sprite[j].z += (1 << 8); - if ((krand() & 15) == 2) + case RPG: + if (hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) { - j = spawn(i, RR_1310); + j = spawn(i,SMALLSMOKE); + sprite[j].z += (1 << 8); } - } - if (sprite[s->lotag].extra <= 0) - s->lotag = 0; - if (s->lotag != 0 && s->hitag > 5) - { - spritetype* ts; - int ang, ang2, ang3; - ts = &sprite[s->lotag]; - ang = getangle(ts->x - s->x, ts->y - s->y); - ang2 = ang - s->ang; - ang3 = abs(ang2); - if (ang2 < 100) + break; + + case FIREBALL: + if (isWorldTour()) { - if (ang3 > 1023) - s->ang += 51; - else - s->ang -= 51; - } - else if (ang2 > 100) - { - if (ang3 > 1023) - s->ang -= 51; - else - s->ang += 51; - } - else - s->ang = ang; - - if (s->hitag > 180) - if (s->zvel <= 0) - s->zvel += 200; - } - } - else if (isRRRA() && picnum == RR_1790) - { - if (s->extra) - { - s->zvel = -(s->extra * 250); - s->extra--; - } - else - makeitfall(i); - if (s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) - { - j = spawn(i, RR_SMALLSMOKE); - sprite[j].z += (1 << 8); - } - } - else if (isWorldTour() && picnum == FIREBALL) - { - 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) + if (sector[s->sectnum].lotag == 2) { - 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; - } + deletesprite(i); + continue; } - 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); + 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; } - 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); + (k*(sintable[(s->ang+512)&2047]))>>14, + (k*(sintable[s->ang&2047]))>>14,ll,qq); - if ((picnum == pPick2(RPG, RR_CROSSBOW) || (isRRRA() && isIn(picnum, RR_CHIKENCROSSBOW, RR_1790))) && s->yvel >= 0) - if (FindDistance2D(s->x - sprite[s->yvel].x, s->y - sprite[s->yvel].y) < 256) - j = 49152 | s->yvel; + 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) // || (isRR() && sector[s->sectnum].filler == 800)) + if (s->sectnum < 0) { deletesprite(i); continue; } - if ((j & 49152) != 49152) - if (picnum != pPick2(FREEZEBLAST, RR_ALIENBLAST)) - { - 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 (picnum == pPick(FIRELASER)) + if ((j&49152) != 49152 && s->picnum != FREEZEBLAST) { - for (k = -3; k < 2; k++) + 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)) * klabs(s->zvel / 24)), pPick(FIRELASER), -40 + (k << 2), - s->xrepeat, s->yrepeat, 0, 0, 0, s->owner, 5); + 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 (picnum == pPick2(SPIT, RR_SHITBALL)) if (s->zvel < 6144) - s->zvel += gc - 112; + else if (s->picnum == SPIT) if (s->zvel < 6144) + s->zvel += gc-112; if (j != 0) { - if (!isRR() && picnum == COOLEXPLOSION1) + if (s->picnum == COOLEXPLOSION1) { - if ((j & 49152) == 49152 && sprite[j & (MAXSPRITES - 1)].picnum != APLAYER) + if ((j&49152) == 49152 && sprite[j&(MAXSPRITES-1)].picnum != APLAYER) { continue; } @@ -3321,53 +1673,31 @@ void moveweapons(void) s->zvel = 0; } - //if ((j & kHitTypeMask) == kHitSprite) j &= kHitIndexMask; reminder for later. - if ((j & 49152) == 49152) + if ((j&49152) == 49152) { - j &= (MAXSPRITES - 1); + j &= (MAXSPRITES-1); - if (isRRRA()) - { - if (sprite[j].picnum == RR_MINION - && (picnum == RR_CROSSBOW || picnum == RR_CHIKENCROSSBOW) - && sprite[j].pal == 19) - { - spritesound(RPG_EXPLODE, i); - j = spawn(i, RR_EXPLOSION2); - sprite[j].x = s->x; - sprite[j].y = s->y; - sprite[j].z = s->z; - continue; - } - } - else if (picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST) && sprite[j].pal == 1) + if (s->picnum == FREEZEBLAST && sprite[j].pal == 1) if (badguy(&sprite[j]) || sprite[j].picnum == APLAYER) - { - j = spawn(i, pPick(TRANSPORTERSTAR)); - sprite[j].pal = 1; - sprite[j].xrepeat = 32; - sprite[j].yrepeat = 32; + { + j = spawn(i,TRANSPORTERSTAR); + sprite[j].pal = 1; + sprite[j].xrepeat = 32; + sprite[j].yrepeat = 32; - deletesprite(i); - continue; - } + deletesprite(i); + continue; + } - checkhitsprite(j, i); + checkhitsprite(j,i); if (sprite[j].picnum == APLAYER) { p = sprite[j].yvel; - spritesound(PISTOL_BODYHIT, j); + spritesound(PISTOL_BODYHIT,j); - if (picnum == pPick2(SPIT, RR_SHITBALL)) + if (s->picnum == SPIT) { - if (sprite[s->owner].picnum == RR_MAMAJACKOLOPE) - { - guts(s, RR_RABBITJIBA, 2, myconnectindex); - guts(s, RR_RABBITJIBB, 2, myconnectindex); - guts(s, RR_RABBITJIBC, 2, myconnectindex); - } - ps[p].q16horiz += 32 << FRACBITS; ps[p].return_to_center = 8; @@ -3376,113 +1706,60 @@ void moveweapons(void) if (!A_CheckSoundPlaying(ps[p].i, DUKE_LONGTERM_PAIN)) A_PlaySound(DUKE_LONGTERM_PAIN, ps[p].i); - j = 3 + (krand() & 3); + j = 3+(krand()&3); ps[p].numloogs = j; - ps[p].loogcnt = 24 * 4; - for (x = 0; x < j; x++) + ps[p].loogcnt = 24*4; + for(x=0;x < j;x++) { - ps[p].loogiex[x] = krand() % xdim; - ps[p].loogiey[x] = krand() % ydim; + ps[p].loogiex[x] = krand()%xdim; + ps[p].loogiey[x] = krand()%ydim; } } } } } - else if ((j & 49152) == 32768) + else if ((j&49152) == 32768) { - j &= (MAXWALLS - 1); + j &= (MAXWALLS-1); - if (isRRRA() && sprite[s->owner].picnum == RR_MAMAJACKOLOPE) - { - guts(s, RR_RABBITJIBA, 2, myconnectindex); - guts(s, RR_RABBITJIBB, 2, myconnectindex); - guts(s, RR_RABBITJIBC, 2, myconnectindex); - } - - bool ismirror = (wall[j].overpicnum == pPick(MIRROR) || wall[j].picnum == pPick(MIRROR)); - if (ismirror && !isRR() ? - isIn(picnum, RPG, FREEZEBLAST, SPIT) : - (isIn(picnum, RR_CROSSBOW, RR_ALIENBLAST, RR_SHITBALL, RR_CIRCLESAW) || (isRRRA() && picnum == RR_CHIKENCROSSBOW)) - ) + 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; + 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, pPick(TRANSPORTERSTAR)); + spawn(i,TRANSPORTERSTAR); continue; } else { - setsprite(i, dax, day, daz); - checkhitwall(i, j, s->x, s->y, s->z, picnum); + setsprite(i,dax,day,daz); + checkhitwall(i,j,s->x,s->y,s->z,s->picnum); - if (!isRRRA() && picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST)) + if (s->picnum == FREEZEBLAST) { - if (!ismirror) + 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; - } - - if (isRR() && s->picnum == RR_CIRCLESAW) - { - if (wall[j].picnum >= RR_3643 && wall[j].picnum < RR_3643 + 3) - { - deletesprite(i); - } - if (s->extra <= 0) - { - s->x += sintable[(s->ang + 512) & 2047] >> 7; - s->y += sintable[s->ang & 2047] >> 7; - if (!isRRRA() || (sprite[s->owner].picnum != RR_DAISYMAE && sprite[s->owner].picnum != RR_DAISYMAESTAYPUT)) - { - j = spawn(i, RR_CIRCLESTUCK); - sprite[j].xrepeat = 8; - sprite[j].yrepeat = 8; - sprite[j].cstat = 16; - sprite[j].ang = (sprite[j].ang + 512) & 2047; - sprite[j].clipdist = mulscale7(s->xrepeat, tilesiz[s->picnum].x); - } - deletesprite(i); - continue; - } - if (!ismirror) - { - s->extra -= 20; - 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; + 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) + else if ((j&49152) == 16384) { - setsprite(i, dax, day, daz); - - if (isRRRA() && sprite[s->owner].picnum == RR_MAMAJACKOLOPE) - { - guts(s, RR_RABBITJIBA, 2, myconnectindex); - guts(s, RR_RABBITJIBB, 2, myconnectindex); - guts(s, RR_RABBITJIBC, 2, myconnectindex); - } + setsprite(i,dax,day,daz); if (s->zvel < 0) { - if (sector[s->sectnum].ceilingstat & 1) + if (sector[s->sectnum].ceilingstat&1) if (sector[s->sectnum].ceilingpal == 0) { deletesprite(i); @@ -3492,10 +1769,10 @@ void moveweapons(void) checkhitceiling(s->sectnum); } - if (!isRRRA() && picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST)) + if (s->picnum == FREEZEBLAST) { bounce(i); - ssp(i, qq); + ssp(i,qq); s->extra >>= 1; if (s->xrepeat > 8) s->xrepeat -= 2; @@ -3506,11 +1783,11 @@ void moveweapons(void) } } - if (picnum != pPick2(SPIT, RR_SHITBALL)) + if (s->picnum != SPIT) { - if (picnum == pPick2(RPG, RR_CROSSBOW)) + if (s->picnum == RPG) { - k = spawn(i, pPick(EXPLOSION2)); + k = spawn(i,EXPLOSION2); sprite[k].x = dax; sprite[k].y = day; sprite[k].z = daz; @@ -3520,64 +1797,24 @@ void moveweapons(void) sprite[k].xrepeat = 6; sprite[k].yrepeat = 6; } - else if ((j & 49152) == 16384) + else if ((j&49152) == 16384) { - if (!isRR() && s->zvel > 0) - spawn(i, EXPLOSION2BOT); + if (s->zvel > 0) + spawn(i,EXPLOSION2BOT); else { sprite[k].cstat |= 8; sprite[k].z += (48 << 8); } } } - else if (isRRRA() && s->picnum == RR_CHIKENCROSSBOW) + else if (s->picnum == SHRINKSPARK) { - k = spawn(i, RR_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) - { - sprite[k].cstat |= 8; - sprite[k].z += (48 << 8); - } + spawn(i,SHRINKEREXPLOSION); + spritesound(SHRINKER_HIT,i); + hitradius(i,shrinkerblastradius,0,0,0,0); } - else if (isRRRA() && s->picnum == RR_1790) + else if (s->picnum != COOLEXPLOSION1 && s->picnum != FREEZEBLAST && s->picnum != FIRELASER) { - s->extra = 160; - k = spawn(i, RR_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) - { - sprite[k].cstat |= 8; - sprite[k].z += (48 << 8); - } - } - - else if (!isRR() && picnum == SHRINKSPARK) - { - spawn(i, SHRINKEREXPLOSION); - spritesound(SHRINKER_HIT, i); - hitradius(i, shrinkerblastradius, 0, 0, 0, 0); - } - else if (!isRR() ? - !isIn(picnum, COOLEXPLOSION1, FREEZEBLAST, FIRELASER) : - !isIn(picnum, RR_ALIENBLAST, RR_FIRELASER, RR_CIRCLESAW)) - { - k = spawn(i, pPick(EXPLOSION2)); - sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat >> 1; - if ((j & 49152) == 16384) + k = spawn(i,EXPLOSION2); + sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat>>1; + if ((j&49152) == 16384) { if (s->zvel < 0) { @@ -3585,83 +1822,48 @@ void moveweapons(void) } } } - if (picnum == pPick2(RPG, RR_CROSSBOW)) + if (s->picnum == RPG) { - spritesound(RPG_EXPLODE, i); + spritesound(RPG_EXPLODE,i); if (s->xrepeat >= 10) { x = s->extra; - hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x); + 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); + x = s->extra+(global_random&3); + hitradius(i,(rpgblastradius>>1),x>>2,x>>1,x-(x>>2),x); } } - else if (isRRRA() && s->picnum == RR_CHIKENCROSSBOW) - { - s->extra = 150; - spritesound(247, 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); - } - } - else if (s->picnum == RR_1790) - { - s->extra = 160; - 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 (isRR() || picnum != COOLEXPLOSION1) + if (s->picnum != COOLEXPLOSION1) { deletesprite(i); continue; } } - if (!isRR() && picnum == COOLEXPLOSION1) + if (s->picnum == COOLEXPLOSION1) { s->shade++; - if (s->shade >= 40) + if (s->shade >= 40) { deletesprite(i); continue; } } - else if ((picnum == pPick2(RPG, RR_CROSSBOW) || (isRRRA() && picnum == RR_CHIKENCROSSBOW)) && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) - spawn(i, pPick(WATERBUBBLE)); + else if (s->picnum == RPG && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) + spawn(i,WATERBUBBLE); + break; - continue; - } - else if (picnum == pPick(SHOTSPARK1)) - { - p = findplayer(s, &x); - execute(i, p, x); + case SHOTSPARK1: + p = findplayer(s,&x); + execute(i,p,x); + break; } } } - END_DUKE_NS diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 2d0f547d0..242e512a1 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1,11 +1,9 @@ //------------------------------------------------------------------------- /* Copyright (C) 1996, 2003 - 3D Realms Entertainment -Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) -Copyright (C) 2017-2019 - Nuke.YKT -Copyright (C) 2020 - Christoph Oelckers +Copyright (C) 2017-2019 Nuke.YKT -This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition +This file is part of 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 @@ -24,24 +22,13 @@ 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 is a combination of code from the following sources: -- EDuke 2 by Matt Saettler -- JFDuke by Jonathon Fowler (jf@jonof.id.au), -- DukeGDX and RedneckGDX by Alexander Makarov-[M210] (m210-2007@mail.ru) -- Redneck Rampage reconstructed source by Nuke.YKT - */ //------------------------------------------------------------------------- #include "ns.h" #include "global.h" -#include "names.h" +#include "actors.h" +#include "names_rr.h" BEGIN_DUKE_NS @@ -59,19 +46,15 @@ static TMap fire; // //--------------------------------------------------------------------------- -bool ceilingspace(int sectnum) +bool ceilingspace_r(int sectnum) { - if ((sector[sectnum].ceilingstat & 1) && sector[sectnum].ceilingpal == 0) + if( (sector[sectnum].ceilingstat&1) && sector[sectnum].ceilingpal == 0 ) { - switch (sector[sectnum].ceilingpicnum) + switch(sector[sectnum].ceilingpicnum) { - case MOONSKY1: - case BIGORBIT1: - return !isRR(); - - case RR_MOONSKY1: - case RR_BIGORBIT1: - return isRR(); + case MOONSKY1: + case BIGORBIT1: + return 1; } } return 0; @@ -83,19 +66,15 @@ bool ceilingspace(int sectnum) // //--------------------------------------------------------------------------- -bool floorspace(int sectnum) +bool floorspace_r(int sectnum) { - if ((sector[sectnum].floorstat & 1) && sector[sectnum].ceilingpal == 0) + if( (sector[sectnum].floorstat&1) && sector[sectnum].ceilingpal == 0 ) { - switch (sector[sectnum].floorpicnum) + switch(sector[sectnum].floorpicnum) { - case MOONSKY1: - case BIGORBIT1: - return !isRR(); - - case RR_MOONSKY1: - case RR_BIGORBIT1: - return !!isRR(); + case MOONSKY1: + case BIGORBIT1: + return 1; } } return 0; @@ -107,21 +86,7 @@ bool floorspace(int sectnum) // //--------------------------------------------------------------------------- -void addammo(short weapon, struct player_struct* p, short amount) -{ - p->ammo_amount[weapon] += amount; - - if (p->ammo_amount[weapon] > max_ammo_amount[weapon]) - p->ammo_amount[weapon] = max_ammo_amount[weapon]; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void addweapon(struct player_struct* p, int weapon) +void addweapon_r(struct player_struct* p, int weapon) { short cw = p->curr_weapon; if (p->OnMotorcycle || p->OnBoat) @@ -163,13 +128,13 @@ void addweapon(struct player_struct* p, int weapon) } } - if (!isRR() || weapon != HANDBOMB_WEAPON) + if (weapon != HANDBOMB_WEAPON) cw = weapon; } else cw = weapon; - if (isRR() && weapon == HANDBOMB_WEAPON) + if (weapon == HANDBOMB_WEAPON) p->last_weapon = -1; p->random_club_frame = 0; @@ -187,39 +152,16 @@ void addweapon(struct player_struct* p, int weapon) } p->kickback_pic = 0; -#ifdef EDUKE - if (p->curr_weapon != cw) - { - short snum; - snum = sprite[p->i].yvel; - - SetGameVarID(g_iWeaponVarID, cw, 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 = cw; - } - } -#else p->curr_weapon = cw; -#endif switch (weapon) { case RA15_WEAPON: + if (!isRRRA()) break; case KNEE_WEAPON: + case HANDBOMB_WEAPON: case TRIPBOMB_WEAPON: case HANDREMOTE_WEAPON: - case HANDBOMB_WEAPON: break; case SHOTGUN_WEAPON: spritesound(SHOTGUN_COCK, p->i); @@ -228,7 +170,7 @@ void addweapon(struct player_struct* p, int weapon) spritesound(INSERT_CLIP, p->i); break; default: - spritesound(SELECT_WEAPON, p->i); + spritesound(EJECT_CLIP, p->i); break; } } @@ -239,180 +181,7 @@ void addweapon(struct player_struct* p, int weapon) // //--------------------------------------------------------------------------- -void checkavailinven(struct player_struct* p) -{ - - if (p->firstaid_amount > 0) - p->inven_icon = ICON_FIRSTAID; - else if (p->steroids_amount > 0) - p->inven_icon = ICON_STEROIDS; - else if (p->holoduke_amount > 0) - p->inven_icon = ICON_HOLODUKE; - else if (p->jetpack_amount > 0) - p->inven_icon = ICON_JETPACK; - else if (p->heat_amount > 0) - p->inven_icon = ICON_HEATS; - else if (p->scuba_amount > 0) - p->inven_icon = ICON_SCUBA; - else if (p->boot_amount > 0) - p->inven_icon = ICON_BOOTS; - else p->inven_icon = ICON_NONE; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void checkavailweapon(struct player_struct* p) -{ - short i, snum; - int weap; - - if (p->wantweaponfire >= 0) - { - weap = p->wantweaponfire; - p->wantweaponfire = -1; - - if (weap == p->curr_weapon) return; - else if (p->gotweapon[weap] && p->ammo_amount[weap] > 0) - { - addweapon(p, weap); - return; - } - } - - weap = p->curr_weapon; - if (p->gotweapon[weap] && p->ammo_amount[weap] > 0) - return; - - snum = sprite[p->i].yvel; - - // Note: RedNukem has this restriction, but the original source and RedneckGDX do not. -#if 1 // TRANSITIONAL - int max = ((isRR()) ? DEVISTATOR_WEAPON : FREEZE_WEAPON); -#else - int max = FREEZE_WEAPON; -#endif - for (i = 0; i < 10; i++) - { - weap = ud.wchoice[snum][i]; - if ((g_gameType & GAMEFLAG_SHAREWARE) && weap > 6) continue; - - if (weap == 0) weap = max; - else weap--; - - if (weap == KNEE_WEAPON || (p->gotweapon[weap] && p->ammo_amount[weap] > 0)) - break; - } - - if (i == HANDREMOTE_WEAPON) weap = KNEE_WEAPON; - - // Found the weapon - - p->last_weapon = p->curr_weapon; - p->random_club_frame = 0; - p->curr_weapon = weap; - if (isWW2GI()) - { - SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); - if (p->curr_weapon >= 0) - { - SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); - } - else - { - SetGameVarID(g_iWorksLikeVarID, -1, p->i, snum); - } - OnEvent(EVENT_CHANGEWEAPON, p->i, snum, -1); - } - - p->kickback_pic = 0; - if (p->holster_weapon == 1) - { - p->holster_weapon = 0; - p->weapon_pos = 10; - } - else p->weapon_pos = -1; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -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 == TILE_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 clearcamera(player_struct* ps) -{ - ps->newowner = -1; - ps->posx = ps->oposx; - ps->posy = ps->oposy; - ps->posz = ps->oposz; - ps->q16ang = ps->oq16ang; - updatesector(ps->posx, ps->posy, &ps->cursectnum); - setpal(ps); - - int k = headspritestat[1]; - while (k >= 0) - { - if (sprite[k].picnum == CAMERA1) - sprite[k].yvel = 0; - k = nextspritestat[k]; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4) +void hitradius_r(short i, int r, int hp1, int hp2, int hp3, int hp4) { spritetype* s, * sj; walltype* wal; @@ -426,64 +195,53 @@ void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4) if (s->xrepeat < 11) { - if (!isRR()) - { - if (s->picnum == RPG) goto SKIPWALLCHECK; - } - else - { - if (s->picnum == RR_CROSSBOW || ((isRRRA()) && s->picnum == RR_CHIKENCROSSBOW)) goto SKIPWALLCHECK; - } + if (s->picnum == RPG || ((isRRRA()) && s->picnum == RPG2)) goto SKIPWALLCHECK; } - if ((isRR()) || s->picnum != SHRINKSPARK) - { - tempshort[0] = s->sectnum; - dasect = s->sectnum; - sectcnt = 0; sectend = 1; + tempshort[0] = s->sectnum; + dasect = s->sectnum; + sectcnt = 0; sectend = 1; - do + do + { + dasect = tempshort[sectcnt++]; + if (((sector[dasect].ceilingz - s->z) >> 8) < r) { - 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 { - d = abs(wall[sector[dasect].wallptr].x - s->x) + abs(wall[sector[dasect].wallptr].y - s->y); + // 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); - 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) + 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) { - 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); + for (dasect = sectend - 1; dasect >= 0; dasect--) + if (tempshort[dasect] == nextsect) break; + if (dasect < 0) tempshort[sectend++] = nextsect; } - } while (sectcnt < sectend); - } + 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: - int val = (isRR()) ? 24 : 16; - q = -(val << 8) + (krand() & ((32 << 8) - 1)); + q = -(24 << 8) + (krand() & ((32 << 8) - 1)); for (x = 0; x < 7; x++) { @@ -493,18 +251,9 @@ SKIPWALLCHECK: 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 ((!isRR() && s->picnum != SHRINKSPARK) || (sj->cstat & 257)) + if (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)) @@ -512,187 +261,81 @@ SKIPWALLCHECK: checkhitsprite(j, i); } } - else if (!isRR()) + else if (sj->extra >= 0 && sj != s && (badguy(sj) || sj->picnum == QUEBALL || sj->picnum == RRTILE3440 || sj->picnum == STRIPEBALL || (sj->cstat & 257) || sj->picnum == DUKELYINGDEAD)) { - 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 == MORTER && j == s->owner) { - 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; - } - } + j = nextj; + continue; } - } - else - { - if (sj->extra >= 0 && sj != s && (badguy(sj) || sj->picnum == RR_QUEBALL || sj->picnum == RR_3440 || sj->picnum == RR_STRIPEBALL || (sj->cstat & 257) || sj->picnum == RR_LNRDLYINGDEAD)) + if ((isRRRA()) && s->picnum == CHEERBOMB && j == s->owner) { - if (s->picnum == RR_MORTER && j == s->owner) - { - j = nextj; - continue; - } - if ((isRRRA()) && s->picnum == RR_CHEERBOMB && 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)) + { + if ((isRRRA()) && sprite[j].picnum == MINION && sprite[j].pal == 19) { j = nextj; continue; } - if (sj->picnum == APLAYER) sj->z -= PHEIGHT; - d = dist(s, sj); - if (sj->picnum == APLAYER) sj->z += PHEIGHT; + hittype[j].ang = getangle(sj->x - s->x, sj->y - s->y); - if (d < r && cansee(sj->x, sj->y, sj->z - (8 << 8), sj->sectnum, s->x, s->y, s->z - (12 << 8), s->sectnum)) + if (s->picnum == RPG && sj->extra > 0) + hittype[j].picnum = RPG; + else if ((isRRRA()) && s->picnum == RPG2 && sj->extra > 0) + hittype[j].picnum = RPG; + else + hittype[j].picnum = RADIUSEXPLOSION; + + if (d < r / 3) { - if ((isRRRA()) && sprite[j].picnum == RR_MINION && sprite[j].pal == 19) - { - j = nextj; - continue; - } + 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)); + } - hittype[j].ang = getangle(sj->x - s->x, sj->y - s->y); + int pic = sprite[j].picnum; + if ((isRRRA())? + (pic != HULK && pic != MAMA && pic != BILLYPLAY && pic != COOTPLAY && pic != MAMACLOUD) : + (pic != HULK && pic != SBMOVE)) + { + if (sprite[j].xvel < 0) sprite[j].xvel = 0; + sprite[j].xvel += (sprite[j].extra << 2); + } - if (s->picnum == RR_CROSSBOW && sj->extra > 0) - hittype[j].picnum = RR_CROSSBOW; - else if ((isRRRA()) && s->picnum == RR_CHIKENCROSSBOW && sj->extra > 0) - hittype[j].picnum = RR_CROSSBOW; - else - hittype[j].picnum = RR_RADIUSEXPLOSION; + if (sj->picnum == STATUEFLASH || sj->picnum == QUEBALL || + sj->picnum == STRIPEBALL || sj->picnum == RRTILE3440) + checkhitsprite(j, i); - if (d < r / 3) + if (sprite[j].picnum != RADIUSEXPLOSION && + s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) + { + if (sprite[j].picnum == APLAYER) { - 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)); - } - - int pic = sprite[j].picnum; - if ((isRRRA())? - (pic != RR_HULK && pic != RR_MAMAJACKOLOPE && pic != RR_GUITARBILLY && pic != RR_BANJOCOOTER && pic != RR_MAMACLOUD) : - (pic != RR_HULK && pic != RR_SBMOVE)) - { - if (sprite[j].xvel < 0) sprite[j].xvel = 0; - sprite[j].xvel += (sprite[j].extra << 2); - } - - if (sj->picnum == RR_STATUEFLASH || sj->picnum == RR_QUEBALL || - sj->picnum == RR_STRIPEBALL || sj->picnum == RR_3440) - checkhitsprite(j, i); - - if (sprite[j].picnum != RR_RADIUSEXPLOSION && - s->owner >= 0 && sprite[s->owner].statnum < MAXSTATUS) - { - if (sprite[j].picnum == APLAYER) + p = sprite[j].yvel; + if (ps[p].newowner >= 0) { - p = sprite[j].yvel; - if (ps[p].newowner >= 0) - { - clearcamera(&ps[p]); - } + clearcamera(&ps[p]); } - hittype[j].owner = s->owner; } + hittype[j].owner = s->owner; } } } @@ -708,7 +351,7 @@ SKIPWALLCHECK: // //--------------------------------------------------------------------------- -int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype) +int movesprite_r(short spritenum, int xchange, int ychange, int zchange, unsigned int cliptype) { int daz, h, oldx, oldy; short retval, dasectnum, cd; @@ -741,40 +384,18 @@ int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned retval = clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 1024L, (4 << 8), (4 << 8), cliptype); else { - if (isRR()) - cd = 192; - 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; - + cd = 192; retval = clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), cd, (4 << 8), (4 << 8), cliptype); } - bool rr = (isRR()); - // conditional code from hell... if (dasectnum < 0 || (dasectnum >= 0 && - ((hittype[spritenum].actorstayput >= 0 && hittype[spritenum].actorstayput != dasectnum) || - (!rr && - ( - ((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))) - ) - ) - ))) + hittype[spritenum].actorstayput >= 0 && hittype[spritenum].actorstayput != dasectnum)) { sprite[spritenum].x = oldx; sprite[spritenum].y = oldy; - if (sector[dasectnum].lotag == ST_1_ABOVE_WATER && (rr || sprite[spritenum].picnum == LIZMAN)) + if (sector[dasectnum].lotag == ST_1_ABOVE_WATER) sprite[spritenum].ang = (krand() & 2047); - else if ((hittype[spritenum].temp_data[0] & 3) == 1 && (rr || sprite[spritenum].picnum != COMMANDER)) + else if ((hittype[spritenum].temp_data[0] & 3) == 1) sprite[spritenum].ang = (krand() & 2047); setsprite(spritenum, oldx, oldy, sprite[spritenum].z); if (dasectnum < 0) dasectnum = 0; @@ -789,7 +410,7 @@ int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned 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); + clipmove(&sprite[spritenum].x, &sprite[spritenum].y, &daz, &dasectnum, ((xchange * TICSPERFRAME) << 11), ((ychange * TICSPERFRAME) << 11), 128L, (4 << 8), (4 << 8), cliptype); } if (dasectnum >= 0) @@ -807,71 +428,23 @@ int movesprite(short spritenum, int xchange, int ychange, int zchange, unsigned //--------------------------------------------------------------------------- // -// +// // //--------------------------------------------------------------------------- -int ssp(short i, unsigned int cliptype) //The set sprite function +void lotsoffeathers_r(spritetype *s, short n) { - spritetype* s; - int movetype; - - s = &sprite[i]; - - movetype = movesprite(i, - (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, - (s->xvel * (sintable[s->ang & 2047])) >> 14, s->zvel, - cliptype); - - return (movetype == 0); + lotsofstuff(s, n, MONEY); } + //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- -void insertspriteq(int i) -{ - if (spriteqamount > 0) - { - if (spriteq[spriteqloc] >= 0) - sprite[spriteq[spriteqloc]].xrepeat = 0; - spriteq[spriteqloc] = i; - spriteqloc = (spriteqloc + 1) % spriteqamount; - } - else sprite[i].xrepeat = sprite[i].yrepeat = 0; -} - -//--------------------------------------------------------------------------- -// -// consolidation of several nearly identical functions -// lotsofmoney -> MONEY / RR_FEATHERS -// lotsofmail -> MAIL -// lotsofpaper -> PAPER -// -//--------------------------------------------------------------------------- - -void lotsofstuff(spritetype* s, short n, int spawntype) -{ - short i, j; - for (i = n; i > 0; i--) - { - short r1 = krand(), r2 = krand(); // using the RANDCORRECT version from RR. - // TRANSITIONAL RedNukem sets the spawner as owner. - j = EGS(s->sectnum, s->x, s->y, s->z - (r2 % (47 << 8)), spawntype, -32, 8, 8, r1 & 2047, 0, 0, 0, 5); - sprite[j].cstat = krand() & 12; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void guts(spritetype* s, short gtype, short n, short p) +void guts_r(spritetype* s, short gtype, short n, short p) { int gutz, floorz; int i=0, j; @@ -888,9 +461,6 @@ void guts(spritetype* s, short gtype, short n, short p) if (gutz > (floorz - (8 << 8))) gutz = floorz - (8 << 8); - if (!isRR() && s->picnum == COMMANDER) - gutz -= (24 << 8); - if (badguy(s) && s->pal == 6) pal = 6; else @@ -898,16 +468,10 @@ void guts(spritetype* s, short gtype, short n, short p) pal = 0; if (isRRRA()) { - if (s->picnum == RR_MINION && (s->pal == 8 || s->pal == 19)) pal = s->pal; + if (s->picnum == MINION && (s->pal == 8 || s->pal == 19)) pal = s->pal; } } - if (isRR()) - { - sx >>= 1; - sy >>= 1; - } - for (j = 0; j < n; j++) { // RANDCORRECT version from RR. @@ -918,12 +482,7 @@ void guts(spritetype* s, short gtype, short n, short p) 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 (!isRR() && sprite[i].picnum == JIBS2) - { - sprite[i].xrepeat >>= 2; - sprite[i].yrepeat >>= 2; - } + i = EGS(s->sectnum, s->x + (r5 & 255) - 128, s->y + (r4 & 255) - 128, gutz - (r3 & 8191), gtype, -32, sx >> 1, sy >> 1, a, 48 + (r2 & 31), -512 - (r1 & 2047), ps[p].i, 5); if (pal != 0) sprite[i].pal = pal; } @@ -935,7 +494,7 @@ void guts(spritetype* s, short gtype, short n, short p) // //--------------------------------------------------------------------------- -void gutsdir(spritetype* s, short gtype, short n, short p) +void gutsdir_r(spritetype* s, short gtype, short n, short p) { int gutz, floorz; short i, j; @@ -951,9 +510,6 @@ void gutsdir(spritetype* s, short gtype, short n, short p) if (gutz > (floorz - (8 << 8))) gutz = floorz - (8 << 8); - if (!isRR() && s->picnum == COMMANDER) - gutz -= (24 << 8); - for (j = 0; j < n; j++) { int a = krand() & 2047; @@ -964,50 +520,13 @@ void gutsdir(spritetype* s, short gtype, short n, short p) } } -//--------------------------------------------------------------------------- -// -// movesector - why is this in actors.cpp? -// -//--------------------------------------------------------------------------- - -void ms(short i) -{ - //T1,T2 and T3 are used for all the sector moving stuff!!! - - short startwall, endwall, x; - int tx, ty; - spritetype* s; - - s = &sprite[i]; - - s->x += (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14; - s->y += (s->xvel * (sintable[s->ang & 2047])) >> 14; - - int j = hittype[i].temp_data[1]; - int k = hittype[i].temp_data[2]; - - startwall = sector[s->sectnum].wallptr; - endwall = startwall + sector[s->sectnum].wallnum; - for (x = startwall; x < endwall; x++) - { - rotatepoint( - 0, 0, - msx[j], msy[j], - k & 2047, &tx, &ty); - - dragpoint(x, s->x + tx, s->y + ty); - - j++; - } -} - //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- -void movefta(void) +void movefta_r(void) { int x, px, py, sx, sy; short i, j, p, psect, ssect, nexti; @@ -1049,13 +568,11 @@ void movefta(void) continue; } - if (!isRR() || s->pal == 33 || s->type == RR_VIXEN || - ((isRRRA()) && isIn(s->type, RR_COOT, RR_COOTSTAYPUT, RR_BIKERSTAND, RR_BIKERRIDE, - RR_BIKERRIDEDAISY, RR_MINIONAIRBOAT, RR_HULKAIRBOAT, - RR_DAISYAIRBOAT, RR_JACKOLOPE, RR_BANJOCOOTER, - RR_GUITARBILLY, RR_MAMAJACKOLOPE, RR_BIKERBV, - RR_MAKEOUT, RR_CHEER, RR_CHEERSTAYPUT)) || - (sintable[(s->ang + 512) & 2047] * (px - sx) + sintable[s->ang & 2047] * (py - sy) >= 0)) + if (s->pal == 33 || s->picnum == VIXEN || + (isRRRA() && (isIn(s->picnum, COOT, COOTSTAYPUT, BIKER, BIKERB, BIKERBV2, CHEER, CHEERB, + CHEERSTAYPUT, MINIONBOAT, HULKBOAT, CHEERBOAT, RABBIT, COOTPLAY, BILLYPLAY, MAKEOUT, MAMA) + || (s->picnum == MINION && s->pal == 8))) + || (sintable[(s->ang + 512) & 2047] * (px - sx) + sintable[s->ang & 2047] * (py - sy) >= 0)) { int r1 = krand(); int r2 = krand(); @@ -1069,74 +586,54 @@ void movefta(void) 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) + + if (j) switch (s->picnum) { - bool res = (!isRR()) ? - isIn(s->picnum, - RUBBERCAN, - EXPLODINGBARREL, - WOODENHORSE, - HORSEONSIDE, - CANWITHSOMETHING, - CANWITHSOMETHING2, - CANWITHSOMETHING3, - CANWITHSOMETHING4, - FIREBARREL, - FIREVASE, - NUKEBARREL, - NUKEBARRELDENTED, - NUKEBARRELLEAKED, - TRIPBOMB) : - isIn(s->picnum, - RR_1251, - RR_1268, - RR_1187, - RR_1304, - RR_1305, - RR_1306, - RR_1309, - RR_1315, - RR_1317, - RR_1388); + case RUBBERCAN: + case EXPLODINGBARREL: + case WOODENHORSE: + case HORSEONSIDE: + case CANWITHSOMETHING: + case FIREBARREL: + case FIREVASE: + case NUKEBARREL: + case NUKEBARRELDENTED: + case NUKEBARRELLEAKED: + if (sector[s->sectnum].ceilingstat & 1) + s->shade = sector[s->sectnum].ceilingshade; + else s->shade = sector[s->sectnum].floorshade; - - if (res) - { - 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); - } - else - { + hittype[i].timetosleep = 0; + changespritestat(i, STAT_STANDABLE); + break; + default: #if 0 - // TRANSITIONAL: RedNukem has this here. Needed? - if (A_CheckSpriteFlags(spriteNum, SFLAG_USEACTIVATOR) && sector[sprite[spriteNum].sectnum].lotag & 16384) break; + // TRANSITIONAL: RedNukem has this here. Needed? + if (A_CheckSpriteFlags(spriteNum, SFLAG_USEACTIVATOR) && sector[sprite[spriteNum].sectnum].lotag & 16384) break; #endif - hittype[i].timetosleep = 0; - check_fta_sounds(i); - changespritestat(i, STAT_ACTOR); - } + hittype[i].timetosleep = 0; + check_fta_sounds(i); + changespritestat(i, STAT_ACTOR); + break; } else hittype[i].timetosleep = 0; } } - if ((!isRR() || !j) && badguy(s)) + if (!j && badguy(s)) { if (sector[s->sectnum].ceilingstat & 1) s->shade = sector[s->sectnum].ceilingshade; else s->shade = sector[s->sectnum].floorshade; - if (isRR() && (s->picnum != RR_HEN || s->picnum != RR_COW || s->picnum != RR_PIG || s->picnum != RR_DOGRUN || ((isRRRA()) && s->picnum != RR_JACKOLOPE))) + if (s->picnum != HEN || s->picnum != COW || s->picnum != PIG || s->picnum != DOGRUN || ((isRRRA()) && s->picnum != RABBIT)) + { if (wakeup(i, p)) { hittype[i].timetosleep = 0; check_fta_sounds(i); changespritestat(i, STAT_ACTOR); } - + } } } i = nexti; @@ -1149,28 +646,15 @@ void movefta(void) // //--------------------------------------------------------------------------- -int ifhitsectors(int sectnum) +int ifhitsectors_r(int sectnum) { int i = headspritestat[STAT_MISC]; - if (!isRR()) + while (i >= 0) { - while (i >= 0) - { - if (sprite[i].picnum == EXPLOSION2 && sectnum == sprite[i].sectnum) - return i; - i = nextspritestat[i]; - } + if (sprite[i].picnum == EXPLOSION2 || (sprite[i].picnum == EXPLOSION3 && sectnum == sprite[i].sectnum)) + return i; + i = nextspritestat[i]; } - else - { - while (i >= 0) - { - if (sprite[i].picnum == RR_EXPLOSION2 || (sprite[i].picnum == RR_EXPLOSION3 && sectnum == sprite[i].sectnum)) - return i; - i = nextspritestat[i]; - } - } - return -1; } @@ -1180,7 +664,7 @@ int ifhitsectors(int sectnum) // //--------------------------------------------------------------------------- -int ifhitbyweapon(int sn) +int ifhitbyweapon_r(int sn) { short j, p; spritetype* npc; @@ -1193,7 +677,7 @@ int ifhitbyweapon(int sn) if (npc->picnum == APLAYER) { - if (ud.god && (isRR() || hittype[sn].picnum != SHRINKSPARK)) return -1; + if (ud.god) return -1; p = npc->yvel; j = hittype[sn].owner; @@ -1208,7 +692,7 @@ int ifhitbyweapon(int sn) if (j >= 0) { - if (npc->extra <= 0 && hittype[sn].picnum != pPick2(FREEZEBLAST, RR_ALIENBLAST)) + if (npc->extra <= 0 && hittype[sn].picnum != FREEZEBLAST) { npc->extra = 0; @@ -1224,29 +708,40 @@ int ifhitbyweapon(int sn) } } - bool res = !isRR() ? - isIn(hittype[sn].picnum, RADIUSEXPLOSION, RPG, HYDRENT, HEAVYHBOMB, SEENINE, OOZFILTER, EXPLODINGBARREL) : - (isIn(hittype[sn].picnum, RR_DYNAMITE, RR_POWDERKEGSPRITE, RR_1228, RR_1273, RR_1315, RR_SEENINE, RR_RADIUSEXPLOSION, RR_CROSSBOW) || - (isRRRA() && hittype[sn].picnum == RR_CHIKENCROSSBOW)); - - int shift = res ? 2 : 1; - ps[p].posxv += hittype[sn].extra * (sintable[(hittype[sn].ang + 512) & 2047]) << shift; - ps[p].posyv += hittype[sn].extra * (sintable[hittype[sn].ang & 2047]) << shift; + int pn = hittype[sn].picnum; + if (pn == RPG2 && isRRRA()) pn = 0; // avoid messing around with gotos. + switch (pn) + { + case RADIUSEXPLOSION: + case RPG: + case HYDRENT: + case HEAVYHBOMB: + case SEENINE: + case OOZFILTER: + case EXPLODINGBARREL: + case TRIPBOMBSPRITE: + case RPG2: + 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 ((isRR() || hittype[sn].picnum == SHRINKSPARK) && npc->xrepeat < 24) + if (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 != pPick2(RECON, RR_4989) && npc->owner >= 0 && sprite[npc->owner].statnum < MAXSTATUS) + if (npc->picnum != RECON && npc->owner >= 0 && sprite[npc->owner].statnum < MAXSTATUS) npc->owner = hittype[sn].owner; } @@ -1255,34 +750,6 @@ int ifhitbyweapon(int sn) } } - - 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; - } - - hittype[sn].extra = -1; return -1; } @@ -1293,388 +760,49 @@ int ifhitbyweapon(int sn) // //--------------------------------------------------------------------------- -void movecyclers(void) +void respawn_rrra(int i, int j) { - short q, j, x, t, s, * c; - walltype* wal; - char cshade; - - for (q = numcyclers - 1; q >= 0; q--) + sprite[j].pal = sprite[i].pal; + if (sprite[j].picnum == MAMA) { - - c = &cyclers[q][0]; - s = c[0]; - - t = c[3]; - j = t + (sintable[c[1] & 2047] >> 10); - cshade = c[2]; - - if (j < cshade) j = cshade; - else if (j > t) j = t; - - c[1] += sector[s].extra; - if (c[5]) + if (sprite[j].pal == 30) { - wal = &wall[sector[s].wallptr]; - for (x = sector[s].wallnum; x > 0; x--, wal++) - if (wal->hitag != 1) - { - wal->shade = j; - - if ((wal->cstat & 2) && wal->nextwall >= 0) - wall[wal->nextwall].shade = j; - - } - sector[s].floorshade = sector[s].ceilingshade = j; + sprite[j].xrepeat = 26; + sprite[j].yrepeat = 26; + sprite[j].clipdist = 75; } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void movedummyplayers(void) -{ - short i, p, nexti; - - i = headspritestat[STAT_DUMMYPLAYER]; - while (i >= 0) - { - nexti = nextspritestat[i]; - - p = sprite[sprite[i].owner].yvel; - - if ((!isRR() && ps[p].on_crane >= 0) || sector[ps[p].cursectnum].lotag != 1 || sprite[ps[p].i].extra <= 0) + else if (sprite[j].pal == 31) { - ps[p].dummyplayersprite = -1; - deletesprite(i); - i = nexti; - continue; + sprite[j].xrepeat = 36; + sprite[j].yrepeat = 36; + sprite[j].clipdist = 100; + } + else if (sprite[j].pal == 32) + { + sprite[j].xrepeat = 50; + sprite[j].yrepeat = 50; + sprite[j].clipdist = 100; } else { - if (ps[p].on_ground && ps[p].on_warping_sector == 1 && sector[ps[p].cursectnum].lotag == 1) - { - sprite[i].cstat = 257; - sprite[i].z = sector[sprite[i].sectnum].ceilingz + (27 << 8); - sprite[i].ang = ps[p].q16ang >> FRACBITS; - if (hittype[i].temp_data[0] == 8) - hittype[i].temp_data[0] = 0; - else hittype[i].temp_data[0]++; - } - else - { - if (sector[sprite[i].sectnum].lotag != 2) sprite[i].z = sector[sprite[i].sectnum].floorz; - sprite[i].cstat = (short)32768; - } + sprite[j].xrepeat = 50; + sprite[j].yrepeat = 50; + sprite[j].clipdist = 100; } - - sprite[i].x += (ps[p].posx - ps[p].oposx); - sprite[i].y += (ps[p].posy - ps[p].oposy); - setsprite(i, sprite[i].x, sprite[i].y, sprite[i].z); - i = nexti; } -} -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -int otherp; -void moveplayers(void) //Players -{ - short i, nexti; - int otherx; - spritetype* s; - struct player_struct* p; - - i = headspritestat[STAT_PLAYER]; - while (i >= 0) + if (sprite[j].pal == 8) { - nexti = nextspritestat[i]; - - s = &sprite[i]; - p = &ps[s->yvel]; - if (s->owner >= 0) - { - if (p->newowner >= 0) //Looking thru the camera - { - s->x = p->oposx; - s->y = p->oposy; - hittype[i].bposz = s->z = p->oposz + PHEIGHT; - s->ang = p->oq16ang >> FRACBITS; - setsprite(i, s->x, s->y, s->z); - } - else - { - if (ud.multimode > 1) - otherp = findotherplayer(s->yvel, &otherx); - else - { - otherp = s->yvel; - otherx = 0; - } - - execute(i, s->yvel, otherx); - - p->oq16ang = p->q16ang; - - if (ud.multimode > 1) - if (sprite[ps[otherp].i].extra > 0) - { - if (s->yrepeat > 32 && sprite[ps[otherp].i].yrepeat < 32) - { - if (otherx < 1400 && p->knee_incs == 0) - { - p->knee_incs = 1; - p->weapon_pos = -1; - p->actorsqu = ps[otherp].i; - } - } - } - if (ud.god) - { - s->extra = p->max_player_health; - s->cstat = 257; - if (!isWW2GI() && !isRR()) - p->jetpack_amount = 1599; - } - - - if (s->extra > 0) - { - // currently alive... - - hittype[i].owner = i; - - if (ud.god == 0) - if (ceilingspace(s->sectnum) || floorspace(s->sectnum)) - quickkill(p); - } - else - { - - p->posx = s->x; - p->posy = s->y; - p->posz = s->z - (20 << 8); - - p->newowner = -1; - - if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS) - { - int ang = p->q16ang >> FRACBITS; - ang += getincangle(ang, getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1; - ang &= 2047; - p->q16ang = ang << FRACBITS; - } - - } - s->ang = p->q16ang >> FRACBITS; - } - } - else - { - if (p->holoduke_on == -1) - { - deletesprite(i); - i = nexti; - continue; - } - - hittype[i].bposx = s->x; - hittype[i].bposy = s->y; - hittype[i].bposz = s->z; - - s->cstat = 0; - - if (s->xrepeat < 42) - { - s->xrepeat += 4; - s->cstat |= 2; - } - else s->xrepeat = 42; - if (s->yrepeat < 36) - s->yrepeat += 4; - else - { - s->yrepeat = 36; - if (sector[s->sectnum].lotag != ST_2_UNDERWATER) - makeitfall(i); - if (s->zvel == 0 && sector[s->sectnum].lotag == ST_1_ABOVE_WATER) - s->z += (32 << 8); - } - - if (s->extra < 8) - { - s->xvel = 128; - s->ang = p->q16ang >> FRACBITS; - s->extra++; - //IFMOVING; // JBF 20040825: is really "if (ssp(i,CLIPMASK0)) ;" which is probably - ssp(i, CLIPMASK0); // not the safest of ideas because a zealous optimiser probably sees - // it as redundant, so I'll call the "ssp(i,CLIPMASK0)" explicitly. - } - else - { - s->ang = 2047 - (p->q16ang >> FRACBITS); - setsprite(i, s->x, s->y, s->z); - } - } - - if (sector[s->sectnum].ceilingstat & 1) - s->shade += (sector[s->sectnum].ceilingshade - s->shade) >> 1; - else - s->shade += (sector[s->sectnum].floorshade - s->shade) >> 1; - - i = nexti; + sprite[j].cstat |= 2; } -} -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void movefx(void) -{ - short i, j, nexti, p; - int x, ht; - spritetype* s; - - i = headspritestat[STAT_FX]; - while (i >= 0) + if (sprite[j].pal != 6) { - s = &sprite[i]; - - nexti = nextspritestat[i]; - - switch (s->picnum) - { - case RESPAWN: - if (sprite[i].extra == 66) - { - j = spawn(i, sprite[i].hitag); - if (isRRRA()) - { - sprite[j].pal = sprite[i].pal; - if (sprite[j].picnum == RR_MAMAJACKOLOPE) - { - if (sprite[j].pal == 30) - { - sprite[j].xrepeat = 26; - sprite[j].yrepeat = 26; - sprite[j].clipdist = 75; - } - else if (sprite[j].pal == 31) - { - sprite[j].xrepeat = 36; - sprite[j].yrepeat = 36; - sprite[j].clipdist = 100; - } - else if (sprite[j].pal == 32) - { - sprite[j].xrepeat = 50; - sprite[j].yrepeat = 50; - sprite[j].clipdist = 100; - } - else - { - sprite[j].xrepeat = 50; - sprite[j].yrepeat = 50; - sprite[j].clipdist = 100; - } - } - - if (sprite[j].pal == 8) - { - sprite[j].cstat |= 2; - } - - if (sprite[j].pal != 6) - { - deletesprite(i); - i = nexti; - continue; - } - sprite[i].extra = (66 - 13); - sprite[j].pal = 0; - } - else - { - deletesprite(i); - i = nexti; - continue; - } - } - else if (sprite[i].extra > (66 - 13)) - sprite[i].extra++; - break; - - case MUSICANDSFX: - - ht = s->hitag; - - if (hittype[i].temp_data[1] != (int)SoundEnabled()) - { - hittype[i].temp_data[1] = SoundEnabled(); - hittype[i].temp_data[0] = 0; - } - - if (s->lotag >= 1000 && s->lotag < 2000) - { - x = ldist(&sprite[ps[screenpeek].i], s); - if (x < ht && hittype[i].temp_data[0] == 0) - { - FX_SetReverb(s->lotag - 1000); - hittype[i].temp_data[0] = 1; - } - if (x >= ht && hittype[i].temp_data[0] == 1) - { - FX_SetReverb(0); - FX_SetReverbDelay(0); - hittype[i].temp_data[0] = 0; - } - } - else if (s->lotag < 999 && (unsigned)sector[s->sectnum].lotag < ST_9_SLIDING_ST_DOOR && snd_ambience && sector[sprite[i].sectnum].floorz != sector[sprite[i].sectnum].ceilingz) - { - auto flags = S_GetUserFlags(s->lotag); - if (flags & SF_MSFX) - { - int x = dist(&sprite[ps[screenpeek].i], s); - - if (x < ht && hittype[i].temp_data[0] == 0) - { - // Start playing an ambience sound. - A_PlaySound(s->lotag, i, CHAN_AUTO, CHANF_LOOP); - hittype[i].temp_data[0] = 1; // AMBIENT_SFX_PLAYING - } - else if (x >= ht && hittype[i].temp_data[0] == 1) - { - // Stop playing ambience sound because we're out of its range. - S_StopEnvSound(s->lotag, i); - } - } - - if ((flags & (SF_GLOBAL | SF_DTAG)) == SF_GLOBAL) - { - if (hittype[i].temp_data[4] > 0) hittype[i].temp_data[4]--; - else for (p = connecthead; p >= 0; p = connectpoint2[p]) - if (p == myconnectindex && ps[p].cursectnum == s->sectnum) - { - S_PlaySound(s->lotag + (unsigned)global_random % (s->hitag + 1)); - hittype[i].temp_data[4] = 26 * 40 + (global_random % (26 * 40)); - } - } - } - break; - } - i = nexti; + deletesprite(i); + return; } + sprite[i].extra = (66 - 13); + sprite[j].pal = 0; } //--------------------------------------------------------------------------- @@ -1683,7 +811,7 @@ void movefx(void) // //--------------------------------------------------------------------------- -void movefallers(void) +void movefallers_r(void) { short i, nexti, sect, j; spritetype* s; @@ -1702,14 +830,10 @@ void movefallers(void) s->z -= (16 << 8); hittype[i].temp_data[1] = s->ang; x = s->extra; - j = ifhitbyweapon(i); + j = ifhitbyweapon_r(i); if (j >= 0) { - bool res = !isRR() ? - isIn(j, FIREEXT, RPG, RADIUSEXPLOSION, SEENINE, OOZFILTER) : - (isIn(j, RR_CROSSBOW, RR_RADIUSEXPLOSION, RR_SEENINE, RR_OOZFILTER) || (isRRRA() && j == RR_CHIKENCROSSBOW)); - - if (res) + if (j == RPG || (isRRRA() && j == RPG2) || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) { if (s->extra <= 0) { @@ -1721,7 +845,7 @@ void movefallers(void) { hittype[j].temp_data[0] = 1; sprite[j].cstat &= (65535 - 64); - if (!isRR() ? isIn(j, CEILINGSTEAM, STEAM) : isIn(j, RR_CEILINGSTEAM, RR_STEAM)) + if (sprite[j].picnum == CEILINGSTEAM || sprite[j].picnum == STEAM) sprite[j].cstat |= 32768; } j = nextspritestat[j]; @@ -1742,22 +866,14 @@ void movefallers(void) if (s->lotag > 0) { s->lotag -= 3; - if (isRR()) - { - s->xvel = (64 + krand()) & 127; - s->zvel = -(1024 + (krand() & 1023)); - } - else if (s->lotag <= 0) - { - s->xvel = (32 + (krand() & 63)); - s->zvel = -(1024 + (krand() & 1023)); - } + s->xvel = ((64 + krand()) & 127); + s->zvel = -(1024 + (krand() & 1023)); } else { if (s->xvel > 0) { - s->xvel -= isRR()? 2 : 8; + s->xvel -= 2; ssp(i, CLIPMASK0); } @@ -1796,484 +912,6 @@ void movefallers(void) // //--------------------------------------------------------------------------- -static void movecrane(int i) -{ - auto t = &hittype[i].temp_data[0]; - auto s = &sprite[i]; - int sect = s->sectnum; - int x; - int crane = pPick(CRANE); - - //t[0] = state - //t[1] = checking sector number - - if (s->xvel) getglobalz(i); - - if (t[0] == 0) //Waiting to check the sector - { - int j = headspritesect[t[1]]; - while (j >= 0) - { - int nextj = nextspritesect[j]; - switch (sprite[j].statnum) - { - case STAT_ACTOR: - case STAT_ZOMBIEACTOR: - case STAT_STANDABLE: - case STAT_PLAYER: - 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); - t[0]++; - deletesprite(i); - return; - } - j = nextj; - } - } - - else if (t[0] == 1) - { - if (s->xvel < 184) - { - s->picnum = crane + 1; - s->xvel += 8; - } - //IFMOVING; // JBF 20040825: see my rant above about this - ssp(i, CLIPMASK0); - if (sect == t[1]) - t[0]++; - } - else if (t[0] == 2 || t[0] == 7) - { - s->z += (1024 + 512); - - if (t[0] == 2) - { - if ((sector[sect].floorz - s->z) < (64 << 8)) - if (s->picnum > crane) s->picnum--; - - if ((sector[sect].floorz - s->z) < (4096 + 1024)) - t[0]++; - } - if (t[0] == 7) - { - if ((sector[sect].floorz - s->z) < (64 << 8)) - { - if (s->picnum > crane) s->picnum--; - else - { - if (s->owner == -2) - { - auto p = findplayer(s, &x); - spritesound(isRR() ? 390 : DUKE_GRUNT, ps[p].i); - if (ps[p].on_crane == i) - ps[p].on_crane = -1; - } - t[0]++; - s->owner = -1; - } - } - } - } - else if (t[0] == 3) - { - s->picnum++; - if (s->picnum == (crane + 2)) - { - auto p = checkcursectnums(t[1]); - if (p >= 0 && ps[p].on_ground) - { - s->owner = -2; - ps[p].on_crane = i; - spritesound(isRR() ? 390 : DUKE_GRUNT, ps[p].i); - ps[p].q16ang = (s->ang + 1024) << FRACBITS; - } - else - { - int j = headspritesect[t[1]]; - while (j >= 0) - { - switch (sprite[j].statnum) - { - case 1: - case 6: - s->owner = j; - break; - } - j = nextspritesect[j]; - } - } - - t[0]++;//Grabbed the sprite - t[2] = 0; - return; - } - } - else if (t[0] == 4) //Delay before going up - { - t[2]++; - if (t[2] > 10) - t[0]++; - } - else if (t[0] == 5 || t[0] == 8) - { - if (t[0] == 8 && s->picnum < (crane + 2)) - if ((sector[sect].floorz - s->z) > 8192) - s->picnum++; - - if (s->z < msx[t[4] + 2]) - { - t[0]++; - s->xvel = 0; - } - else - s->z -= (1024 + 512); - } - else if (t[0] == 6) - { - if (s->xvel < 192) - s->xvel += 8; - s->ang = getangle(msx[t[4]] - s->x, msy[t[4]] - s->y); - //IFMOVING; // JBF 20040825: see my rant above about this - ssp(i, CLIPMASK0); - if (((s->x - msx[t[4]]) * (s->x - msx[t[4]]) + (s->y - msy[t[4]]) * (s->y - msy[t[4]])) < (128 * 128)) - t[0]++; - } - - else if (t[0] == 9) - t[0] = 0; - - setsprite(msy[t[4] + 2], s->x, s->y, s->z - (34 << 8)); - - if (s->owner != -1) - { - auto p = findplayer(s, &x); - - int j = ifhitbyweapon(i); - if (j >= 0) - { - if (s->owner == -2) - if (ps[p].on_crane == i) - ps[p].on_crane = -1; - s->owner = -1; - s->picnum = crane; - return; - } - - if (s->owner >= 0) - { - setsprite(s->owner, s->x, s->y, s->z); - - hittype[s->owner].bposx = s->x; - hittype[s->owner].bposy = s->y; - hittype[s->owner].bposz = s->z; - - s->zvel = 0; - } - else if (s->owner == -2) - { - auto ang = ps[p].q16ang >> FRACBITS; - ps[p].oposx = ps[p].posx = s->x - (sintable[(ang + 512) & 2047] >> 6); - ps[p].oposy = ps[p].posy = s->y - (sintable[ang & 2047] >> 6); - ps[p].oposz = ps[p].posz = s->z + (2 << 8); - setsprite(ps[p].i, ps[p].posx, ps[p].posy, ps[p].posz); - ps[p].cursectnum = sprite[ps[p].i].sectnum; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movefountain(int i) -{ - auto t = &hittype[i].temp_data[0]; - auto s = &sprite[i]; - int x; - if (t[0] > 0) - { - if (t[0] < 20) - { - t[0]++; - - s->picnum++; - - if (s->picnum == (pPick(WATERFOUNTAIN) + 3)) - s->picnum = pPick(WATERFOUNTAIN) + 1; - } - else - { - findplayer(s, &x); - - if (x > 512) - { - t[0] = 0; - s->picnum = pPick(WATERFOUNTAIN); - } - else t[0] = 1; - } - } -} -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void moveflammable(int i) -{ - auto s = &sprite[i]; - int j; - if (hittype[i].temp_data[0] == 1) - { - hittype[i].temp_data[1]++; - if ((hittype[i].temp_data[1] & 3) > 0) return; - - if (!isRR() && s->picnum == TIRE && hittype[i].temp_data[1] == 32) - { - s->cstat = 0; - j = spawn(i, BLOODPOOL); - sprite[j].shade = 127; - } - else - { - if (s->shade < 64) s->shade++; - else - { - deletesprite(i); - return; - } - } - - j = s->xrepeat - (krand() & 7); - if (j < 10) - { - deletesprite(i); - return; - } - - s->xrepeat = j; - - j = s->yrepeat - (krand() & 7); - if (j < 4) - { - deletesprite(i); - return; - } - s->yrepeat = j; - } - if (!isRR() && s->picnum == BOX) - { - makeitfall(i); - hittype[i].ceilingz = sector[s->sectnum].ceilingz; - } -} - -//--------------------------------------------------------------------------- -// -// 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 detonate(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - earthquaketime = 16; - - int j = headspritestat[STAT_EFFECTOR]; - while (j >= 0) - { - if (s->hitag == sprite[j].hitag) - { - if (sprite[j].lotag == SE_13_EXPLOSIVE) - { - if (hittype[j].temp_data[2] == 0) - hittype[j].temp_data[2] = 1; - } - else if (sprite[j].lotag == SE_8_UP_OPEN_DOOR_LIGHTS) - hittype[j].temp_data[4] = 1; - else if (sprite[j].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL) - { - if (hittype[j].temp_data[0] == 0) - hittype[j].temp_data[0] = 1; - } - else if (sprite[j].lotag == SE_21_DROP_FLOOR) - hittype[j].temp_data[0] = 1; - } - j = nextspritestat[j]; - } - - s->z -= (32 << 8); - - if ((t[3] == 1 && s->xrepeat) || s->lotag == -99) - { - int x = s->extra; - spawn(i, EXPLOSION2); - hitradius(i, seenineblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x); - spritesound(PIPEBOMB_EXPLODE, i); - } - - if (s->xrepeat) - for (int x = 0; x < 8; x++) RANDOMSCRAP(s, i); - - deletesprite(i); - -} - //--------------------------------------------------------------------------- // // @@ -2288,23 +926,18 @@ static void movecrack(int i) { t[0] = s->cstat; t[1] = s->ang; - int j = ifhitbyweapon(i); - - bool res = !isRR() ? - isIn(j, FIREEXT, RPG, RADIUSEXPLOSION, SEENINE, OOZFILTER) : - (isIn(j, RR_CROSSBOW, RR_RADIUSEXPLOSION, RR_SEENINE, RR_OOZFILTER) || (isRRRA() && j == RR_CHIKENCROSSBOW)); - - if (res) + int j = ifhitbyweapon_r(i); + if (j == RPG || (isRRRA() && j == RPG2) || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER) { j = headspritestat[STAT_STANDABLE]; while (j >= 0) { - if (s->hitag == sprite[j].hitag && (isRR() ? isIn(sprite[j].picnum, RR_OOZFILTER, RR_SEENINE) : isIn(sprite[j].picnum, OOZFILTER, SEENINE))) + 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); + detonate(i, EXPLOSION2); } else { @@ -2315,283 +948,6 @@ static void movecrack(int i) } } -//--------------------------------------------------------------------------- -// -// 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); - } - else - { - hitradius(i, seenineblastradius, 10, 15, 20, 25); - deletesprite(i); - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void moveooz(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - int j; - if (s->shade != -32 && s->shade != -33) - { - if (s->xrepeat) - j = (ifhitbyweapon(i) >= 0); - else - j = 0; - - if (j || s->shade == -31) - { - if (j) s->lotag = 0; - - t[3] = 1; - - j = headspritestat[STAT_STANDABLE]; - while (j >= 0) - { - if (s->hitag == sprite[j].hitag && (sprite[j].picnum == pPick(SEENINE) || sprite[j].picnum == pPick(OOZFILTER))) - sprite[j].shade = -32; - j = nextspritestat[j]; - } - } - } - else - { - if (s->shade == -32) - { - if (s->lotag > 0) - { - s->lotag -= 3; - if (s->lotag <= 0) s->lotag = -99; - } - else - s->shade = -33; - } - else - { - if (s->xrepeat > 0) - { - hittype[i].temp_data[2]++; - if (hittype[i].temp_data[2] == 3) - { - if (s->picnum == pPick(OOZFILTER)) - { - hittype[i].temp_data[2] = 0; - detonate(i); - return; - } - if (s->picnum != (pPick(SEENINEDEAD) + 1)) - { - hittype[i].temp_data[2] = 0; - - if (s->picnum == pPick(SEENINEDEAD)) s->picnum++; - else if (s->picnum == pPick(SEENINE)) - s->picnum = pPick(SEENINEDEAD); - } - else - { - detonate(i); - return; - } - } - return; - } - detonate(i); - return; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void movemasterswitch(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - if (s->yvel == 1) - { - s->hitag--; - if (s->hitag <= 0) - { - operatesectors(s->sectnum, i); - - int j = headspritesect[s->sectnum]; - while (j >= 0) - { - if (sprite[j].statnum == 3) - { - switch (sprite[j].lotag) - { - case SE_2_EARTHQUAKE: - case SE_21_DROP_FLOOR: - case SE_31_FLOOR_RISE_FALL: - case SE_32_CEILING_RISE_FALL: - case SE_36_PROJ_SHOOTER: - hittype[j].temp_data[0] = 1; - break; - case SE_3_RANDOM_LIGHTS_AFTER_SHOT_OUT: - hittype[j].temp_data[4] = 1; - break; - } - } - else if (sprite[j].statnum == 6) - { - if (sprite[j].picnum == pPick(SEENINE) || sprite[j].picnum == pPick(OOZFILTER)) - { - sprite[j].shade = -31; - } - } - j = nextspritesect[j]; - } - 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; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movetrash(int i) -{ - auto s = &sprite[i]; - if (s->xvel == 0) s->xvel = 1; - if (ssp(i, CLIPMASK0)) - { - makeitfall(i); - if (krand() & 1) s->zvel -= 256; - if (klabs(s->xvel) < 48) - s->xvel += (krand() & 3); - } - else deletesprite(i); -} - -//--------------------------------------------------------------------------- -// -// 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; -} - //--------------------------------------------------------------------------- // // @@ -2639,11 +995,10 @@ CLEAR_THE_BOLT: if (l & 1) s->cstat ^= 2; - auto bolt1 = pPick(BOLT1); - if (s->picnum == (bolt1 + 1) && (isRR() ? (krand() & 1) != 0 : (krand() & 7) == 0) && sector[sect].floorpicnum == pPick(HURTRAIL) ) + if (s->picnum == (BOLT1 + 1) && (krand() & 1) && sector[sect].floorpicnum == HURTRAIL) spritesound(SHORT_CIRCUIT, i); - if (s->picnum == bolt1 + 4) s->picnum = bolt1; + if (s->picnum == BOLT1 + 4) s->picnum = BOLT1; if (s->picnum & 1) { @@ -2657,182 +1012,13 @@ CLEAR_THE_BOLT: } } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movewaterdrip(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - int sect = s->sectnum; - - if (t[1]) - { - t[1]--; - if (t[1] == 0) - s->cstat &= 32767; - } - else - { - makeitfall(i); - ssp(i, CLIPMASK0); - if (s->xvel > 0) s->xvel -= 2; - - if (s->zvel == 0) - { - s->cstat |= 32768; - - if (s->pal != 2 && (isRR() || s->hitag == 0)) - spritesound(SOMETHING_DRIPPING, i); - - if (sprite[s->owner].picnum != pPick(WATERDRIP)) - { - deletesprite(i); - } - else - { - hittype[i].bposz = s->z = t[0]; - t[1] = 48 + (krand() & 31); - } - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movedoorshock(int i) -{ - auto s = &sprite[i]; - int sect = s->sectnum; - int j = abs(sector[sect].ceilingz - sector[sect].floorz) >> 9; - s->yrepeat = j + 4; - s->xrepeat = 16; - s->z = sector[sect].floorz; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movetouchplate(int i) -{ - auto s = &sprite[i]; - auto t = &hittype[i].temp_data[0]; - int sect = s->sectnum; - int x; - int p; - - if (t[1] == 1 && s->hitag >= 0) //Move the sector floor - { - x = sector[sect].floorz; - - if (t[3] == 1) - { - if (x >= t[2]) - { - sector[sect].floorz = x; - t[1] = 0; - } - else - { - sector[sect].floorz += sector[sect].extra; - p = checkcursectnums(sect); - if (p >= 0) ps[p].posz += sector[sect].extra; - } - } - else - { - if (x <= s->z) - { - sector[sect].floorz = s->z; - t[1] = 0; - } - else - { - sector[sect].floorz -= sector[sect].extra; - p = checkcursectnums(sect); - if (p >= 0) - ps[p].posz -= sector[sect].extra; - } - } - return; - } - - if (t[5] == 1) return; - - p = checkcursectnums(sect); - if (p >= 0 && (ps[p].on_ground || s->ang == 512)) - { - if (t[0] == 0 && !check_activator_motion(s->lotag)) - { - t[0] = 1; - t[1] = 1; - t[3] = !t[3]; - operatemasterswitches(s->lotag); - operateactivators(s->lotag, p); - if (s->hitag > 0) - { - s->hitag--; - if (s->hitag == 0) t[5] = 1; - } - } - } - else t[0] = 0; - - if (t[1] == 1) - { - int j = headspritestat[STAT_STANDABLE]; - while (j >= 0) - { - if (j != i && sprite[j].picnum == TOUCHPLATE && sprite[j].lotag == s->lotag) - { - hittype[j].temp_data[1] = 1; - hittype[j].temp_data[3] = t[3]; - } - j = nextspritestat[j]; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movecanwithsomething(int i) -{ - auto s = &sprite[i]; - makeitfall(i); - int j = ifhitbyweapon(i); - if (j >= 0) - { - spritesound(VENT_BUST, i); - for (j = 0; j < 10; j++) - RANDOMSCRAP(s, i); - - if (s->lotag) spawn(i, s->lotag); - - deletesprite(i); - } -} - //--------------------------------------------------------------------------- // // this has been broken up into lots of smaller subfunctions // //--------------------------------------------------------------------------- -void movestandables(void) +void movestandables_r(void) { int nexti; @@ -2854,92 +1040,71 @@ void movestandables(void) hittype[i].bposz = s->z; - if (picnum >= pPick(CRANE) && picnum <= pPick(CRANE) +3) + if (picnum >= CRANE && picnum <= CRANE +3) { - movecrane(i); + movecrane(i, CRANE); } - else if (picnum >= pPick(WATERFOUNTAIN) && picnum <= pPick(WATERFOUNTAIN) + 3) + else if (picnum >= WATERFOUNTAIN && picnum <= WATERFOUNTAIN + 3) { - movefountain(i); + movefountain(i, WATERFOUNTAIN); } else if (AFLAMABLE(picnum)) { - moveflammable(i); + moveflammable(i, TIRE, BOX, BLOODPOOL); } - else if (!isRR() && picnum == TRIPBOMB) - { - movetripbomb(i); - } - else if (picnum >= pPick(CRACK1) && picnum <= pPick(CRACK1)+3) + else if (picnum >= CRACK1 && picnum <= CRACK1 + 3) { movecrack(i); } - else if (!isRR() && picnum == FIREEXT) + else if (picnum == OOZFILTER || picnum == SEENINE || picnum == SEENINEDEAD || picnum == (SEENINEDEAD + 1)) { - movefireext(i); - } - - else if (picnum == pPick(OOZFILTER) || picnum == pPick(SEENINE) || picnum == pPick(SEENINEDEAD) || picnum == (pPick(SEENINEDEAD) + 1)) - { - moveooz(i); + moveooz(i, SEENINE, SEENINEDEAD, OOZFILTER, EXPLOSION2); } else if (picnum == MASTERSWITCH) { - movemasterswitch(i); + movemasterswitch(i, SEENINE, OOZFILTER); } - else if (!isRR() && (picnum == VIEWSCREEN || picnum == VIEWSCREEN2)) - { - moveviewscreen(i); - } - - else if (picnum == pPick(TRASH)) + else if (picnum == TRASH) { movetrash(i); } - else if (!isRR() && picnum >= SIDEBOLT1 && picnum <= SIDEBOLT1 + 3) - { - movesidebolt(i); - } - - else if (picnum >= pPick(BOLT1) && picnum <= pPick(BOLT1) + 3) + else if (picnum >= BOLT1 && picnum <= BOLT1 + 3) { movebolt(i); } - else if (picnum == pPick(WATERDRIP)) + else if (picnum == WATERDRIP) { - movewaterdrip(i); + movewaterdrip(i, WATERDRIP); } - else if (picnum == pPick(DOORSHOCK)) + else if (picnum == DOORSHOCK) { movedoorshock(i); } else if (picnum == TOUCHPLATE) { - movetouchplate(i); + movetouchplate(i, TOUCHPLATE); } - else if (isRR() ? picnum == RR_CANWITHSOMETHING : isIn(picnum, CANWITHSOMETHING, CANWITHSOMETHING2, CANWITHSOMETHING3, CANWITHSOMETHING4)) + else if (picnum == CANWITHSOMETHING) { movecanwithsomething(i); } - else if (!isRR() ? - isIn(picnum, + else if (isIn(picnum, EXPLODINGBARREL, WOODENHORSE, HORSEONSIDE, - FLOORFLAME, FIREBARREL, FIREVASE, NUKEBARREL, @@ -2948,23 +1113,7 @@ void movestandables(void) TOILETWATER, RUBBERCAN, STEAM, - CEILINGSTEAM, - WATERBUBBLEMAKER) : - isIn(picnum, - RR_1187, - RR_1196, - RR_1251, - RR_1268, - RR_1304, - RR_1305, - RR_1306, - RR_1315, - RR_1317, - RR_1388, - RR_STEAM, - RR_CEILINGSTEAM, - RR_WATERBUBBLEMAKER) - ) + CEILINGSTEAM)) { int x; int p = findplayer(s, &x); @@ -2979,106 +1128,10 @@ void movestandables(void) // //--------------------------------------------------------------------------- -static void bounce(int i) +void moveweapons_r(void) { - int k, l, daang, dax, day, daz, xvect, yvect, zvect; - short hitsect; - spritetype* s = &sprite[i]; - - xvect = mulscale10(s->xvel, sintable[(s->ang + 512) & 2047]); - yvect = mulscale10(s->xvel, sintable[s->ang & 2047]); - zvect = s->zvel; - - hitsect = s->sectnum; - - k = sector[hitsect].wallptr; l = wall[k].point2; - daang = getangle(wall[l].x - wall[k].x, wall[l].y - wall[k].y); - - if (s->z < (hittype[i].floorz + hittype[i].ceilingz) >> 1) - k = sector[hitsect].ceilingheinum; - else - k = sector[hitsect].floorheinum; - - dax = mulscale14(k, sintable[(daang) & 2047]); - day = mulscale14(k, sintable[(daang + 1536) & 2047]); - daz = 4096; - - k = xvect * dax + yvect * day + zvect * daz; - l = dax * dax + day * day + daz * daz; - if ((abs(k) >> 14) < l) - { - k = divscale17(k, l); - xvect -= mulscale16(dax, k); - yvect -= mulscale16(day, k); - zvect -= mulscale16(daz, k); - } - - s->zvel = zvect; - s->xvel = ksqrt(dmulscale8(xvect, xvect, yvect, yvect)); - s->ang = getangle(xvect, yvect); -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movetongue(int i) -{ - spritetype* s = &sprite[i]; - - hittype[i].temp_data[0] = sintable[(hittype[i].temp_data[1]) & 2047] >> 9; - hittype[i].temp_data[1] += 32; - if (hittype[i].temp_data[1] > 2047) - { - deletesprite(i); - return; - } - - if (sprite[s->owner].statnum == MAXSTATUS) - if (badguy(&sprite[s->owner]) == 0) - { - deletesprite(i); - return; - } - - s->ang = sprite[s->owner].ang; - s->x = sprite[s->owner].x; - s->y = sprite[s->owner].y; - if (sprite[s->owner].picnum == APLAYER) - s->z = sprite[s->owner].z - (34 << 8); - for (int k = 0; k < hittype[i].temp_data[0]; k++) - { - int q = 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 / 12)), pPick(TONGUE), -40 + (k << 1), - 8, 8, 0, 0, 0, i, 5); - sprite[q].cstat = 128; - sprite[q].pal = 8; - } - int k = hittype[i].temp_data[0]; // do not depend on the above loop counter. - int q = 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 / 12)), pPick(INNERJAW), -40, - 32, 32, 0, 0, 0, i, 5); - sprite[q].cstat = 128; - if (hittype[i].temp_data[1] > 512 && hittype[i].temp_data[1] < (1024)) - sprite[q].picnum = pPick(INNERJAW) + 1; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void moveweapons(void) -{ - int j, k, nexti, p, q, tempsect; - int dax, day, daz, x, l, ll, x1, y1; + int j, k, nexti, p; + int dax, day, daz, x, ll; unsigned int qq; spritetype* s; @@ -3086,7 +1139,6 @@ void moveweapons(void) { nexti = nextspritestat[i]; s = &sprite[i]; - int picnum = picnum; if (s->sectnum < 0) { @@ -3098,38 +1150,43 @@ void moveweapons(void) hittype[i].bposy = s->y; hittype[i].bposz = s->z; - if (picnum == pPick(RADIUSEXPLOSION) || (!isRR() && picnum == KNEE)) + switch (s->picnum) { - deletesprite(i); - } - - else if (picnum == pPick(TONGUE)) - { - movetongue(i); - } - - else if (picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST) && (s->yvel < 1 || s->extra < 2 || (s->xvel | s->zvel) == 0)) - { - j = spawn(i, pPick(TRANSPORTERSTAR)); - sprite[j].pal = 1; - sprite[j].xrepeat = 32; - sprite[j].yrepeat = 32; + case RADIUSEXPLOSION: deletesprite(i); continue; - } - - else if (!isRR() ? - (isIn(picnum, FREEZEBLAST, SHRINKSPARK, RPG, FIRELASER, SPIT, COOLEXPLOSION1) || (isWorldTour() && picnum == FIREBALL)) : - (isIn(picnum, RR_ALIENBLAST, RR_CROSSBOW, RR_FIRELASER, RR_SHITBALL, RR_CIRCLESAW, RR_UWHIP, RR_OWHIP, RR_DILDO) || (isRRRA() && isIn(picnum, RR_CHIKENCROSSBOW, RR_1790))) - ) - { - if (!isRR() && picnum == COOLEXPLOSION1) - if (!S_CheckSoundPlaying(i, WIERDSHOT_FLY)) - A_PlaySound(WIERDSHOT_FLY, i); + 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 RPG2: + case RRTILE1790: + if (!isRRRA()) continue; + case SHRINKSPARK: + case RPG: + case FIRELASER: + case SPIT: + case COOLEXPLOSION1: + case OWHIP: + case UWHIP: p = -1; - if ((picnum == pPick2(RPG, RR_CROSSBOW) || (isRRRA() && picnum == RR_CHIKENCROSSBOW)) && sector[s->sectnum].lotag == 2) + if (s->picnum == RPG && sector[s->sectnum].lotag == 2) + { + k = s->xvel >> 1; + ll = s->zvel >> 1; + } + else if (isRRRA() && s->picnum == RPG2 && sector[s->sectnum].lotag == 2) { k = s->xvel >> 1; ll = s->zvel >> 1; @@ -3145,24 +1202,25 @@ void moveweapons(void) getglobalz(i); qq = CLIPMASK1; - if (picnum == pPick2(RPG, RR_CROSSBOW)) + switch (s->picnum) { - if (hittype[i].picnum != pPick(BOSS2) && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) + case RPG: + if (hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) { - j = spawn(i, pPick(SMALLSMOKE)); + j = spawn(i, SMALLSMOKE); sprite[j].z += (1 << 8); } - } - else if (isRRRA() && picnum == RR_CHIKENCROSSBOW) - { + break; + case RPG2: + if (!isRRRA()) break; s->hitag++; - if (hittype[i].picnum != RR_BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) + if (hittype[i].picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) { - j = spawn(i, RR_SMALLSMOKE); + j = spawn(i, SMALLSMOKE); sprite[j].z += (1 << 8); if ((krand() & 15) == 2) { - j = spawn(i, RR_1310); + j = spawn(i, 1310); } } if (sprite[s->lotag].extra <= 0) @@ -3196,9 +1254,9 @@ void moveweapons(void) if (s->zvel <= 0) s->zvel += 200; } - } - else if (isRRRA() && picnum == RR_1790) - { + break; + case RRTILE1790: + if (!isRRRA()) break; if (s->extra) { s->zvel = -(s->extra * 250); @@ -3208,63 +1266,17 @@ void moveweapons(void) makeitfall(i); if (s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) { - j = spawn(i, RR_SMALLSMOKE); + j = spawn(i, SMALLSMOKE); sprite[j].z += (1 << 8); } - } - else if (isWorldTour() && picnum == FIREBALL) - { - 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, + j = movesprite_r(i, (k * (sintable[(s->ang + 512) & 2047])) >> 14, (k * (sintable[s->ang & 2047])) >> 14, ll, qq); - if ((picnum == pPick2(RPG, RR_CROSSBOW) || (isRRRA() && isIn(picnum, RR_CHIKENCROSSBOW, RR_1790))) && s->yvel >= 0) + if ((s->picnum == RPG || (isRRRA() && isIn(s->picnum, RPG2, RRTILE1790))) && s->yvel >= 0) if (FindDistance2D(s->x - sprite[s->yvel].x, s->y - sprite[s->yvel].y) < 256) j = 49152 | s->yvel; @@ -3274,52 +1286,41 @@ void moveweapons(void) continue; } - if ((j & 49152) != 49152) - if (picnum != pPick2(FREEZEBLAST, RR_ALIENBLAST)) + if ((j&49152) != 49152 && s->picnum != FREEZEBLAST) + { + if (s->z < hittype[i].ceilingz) { - if (s->z < hittype[i].ceilingz) + j = 16384|(s->sectnum); + s->zvel = -1; + } + else + if (s->z > hittype[i].floorz) { j = 16384 | (s->sectnum); - s->zvel = -1; + if (sector[s->sectnum].lotag != 1) + 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 (picnum == pPick(FIRELASER)) + 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)) * klabs(s->zvel / 24)), pPick(FIRELASER), -40 + (k << 2), + 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 (picnum == pPick2(SPIT, RR_SHITBALL)) if (s->zvel < 6144) + else if (s->picnum == SPIT) if (s->zvel < 6144) s->zvel += gc - 112; if (j != 0) { - if (!isRR() && picnum == COOLEXPLOSION1) - { - if ((j & 49152) == 49152 && sprite[j & (MAXSPRITES - 1)].picnum != APLAYER) - { - continue; - } - s->xvel = 0; - s->zvel = 0; - } //if ((j & kHitTypeMask) == kHitSprite) j &= kHitIndexMask; reminder for later. if ((j & 49152) == 49152) @@ -3328,46 +1329,45 @@ void moveweapons(void) if (isRRRA()) { - if (sprite[j].picnum == RR_MINION - && (picnum == RR_CROSSBOW || picnum == RR_CHIKENCROSSBOW) + if (sprite[j].picnum == MINION + && (s->picnum == RPG || s->picnum == RPG2) && sprite[j].pal == 19) { spritesound(RPG_EXPLODE, i); - j = spawn(i, RR_EXPLOSION2); - sprite[j].x = s->x; - sprite[j].y = s->y; - sprite[j].z = s->z; + k = spawn(i, EXPLOSION2); + sprite[k].x = dax; + sprite[k].y = day; + sprite[k].z = daz; continue; } } - else if (picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST) && sprite[j].pal == 1) + else if (s->picnum == FREEZEBLAST && sprite[j].pal == 1) if (badguy(&sprite[j]) || sprite[j].picnum == APLAYER) - { - j = spawn(i, pPick(TRANSPORTERSTAR)); - sprite[j].pal = 1; - sprite[j].xrepeat = 32; - sprite[j].yrepeat = 32; + { + j = spawn(i,TRANSPORTERSTAR); + sprite[j].pal = 1; + sprite[j].xrepeat = 32; + sprite[j].yrepeat = 32; - deletesprite(i); - continue; - } + deletesprite(i); + continue; + } - checkhitsprite(j, i); + checkhitsprite(j,i); if (sprite[j].picnum == APLAYER) { p = sprite[j].yvel; - spritesound(PISTOL_BODYHIT, j); + spritesound(PISTOL_BODYHIT,j); - if (picnum == pPick2(SPIT, RR_SHITBALL)) + if (s->picnum == SPIT) { - if (sprite[s->owner].picnum == RR_MAMAJACKOLOPE) + if (isRRRA() && sprite[s->owner].picnum == MAMA) { - guts(s, RR_RABBITJIBA, 2, myconnectindex); - guts(s, RR_RABBITJIBB, 2, myconnectindex); - guts(s, RR_RABBITJIBC, 2, myconnectindex); + guts_r(s, RABBITJIBA, 2, myconnectindex); + guts_r(s, RABBITJIBB, 2, myconnectindex); + guts_r(s, RABBITJIBC, 2, myconnectindex); } - ps[p].q16horiz += 32 << FRACBITS; ps[p].return_to_center = 8; @@ -3392,37 +1392,37 @@ void moveweapons(void) { j &= (MAXWALLS - 1); - if (isRRRA() && sprite[s->owner].picnum == RR_MAMAJACKOLOPE) + if (isRRRA() && sprite[s->owner].picnum == MAMA) { - guts(s, RR_RABBITJIBA, 2, myconnectindex); - guts(s, RR_RABBITJIBB, 2, myconnectindex); - guts(s, RR_RABBITJIBC, 2, myconnectindex); + guts_r(s, RABBITJIBA, 2, myconnectindex); + guts_r(s, RABBITJIBB, 2, myconnectindex); + guts_r(s, RABBITJIBC, 2, myconnectindex); } - bool ismirror = (wall[j].overpicnum == pPick(MIRROR) || wall[j].picnum == pPick(MIRROR)); - if (ismirror && !isRR() ? - isIn(picnum, RPG, FREEZEBLAST, SPIT) : - (isIn(picnum, RR_CROSSBOW, RR_ALIENBLAST, RR_SHITBALL, RR_CIRCLESAW) || (isRRRA() && picnum == RR_CHIKENCROSSBOW)) - ) + if (s->picnum != RPG && (!isRRRA() || s->picnum != RPG2) && s->picnum != FREEZEBLAST && s->picnum != SPIT && s->picnum != SHRINKSPARK && (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, pPick(TRANSPORTERSTAR)); + spawn(i, TRANSPORTERSTAR); continue; } else { setsprite(i, dax, day, daz); - checkhitwall(i, j, s->x, s->y, s->z, picnum); + checkhitwall(i, j, s->x, s->y, s->z, s->picnum); - if (!isRRRA() && picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST)) + if (!isRRRA() && s->picnum == FREEZEBLAST) { - if (!ismirror) + if (wall[j].overpicnum != MIRROR && wall[j].picnum != MIRROR) { s->extra >>= 1; + if (s->xrepeat > 8) + s->xrepeat -= 2; + if (s->yrepeat > 8) + s->yrepeat -= 2; s->yvel--; } @@ -3432,10 +1432,9 @@ void moveweapons(void) s->ang = ((k << 1) - s->ang) & 2047; continue; } - - if (isRR() && s->picnum == RR_CIRCLESAW) + if (s->picnum == SHRINKSPARK) { - if (wall[j].picnum >= RR_3643 && wall[j].picnum < RR_3643 + 3) + if (wall[j].picnum >= RRTILE3643 && wall[j].picnum < RRTILE3643 + 3) { deletesprite(i); } @@ -3443,9 +1442,9 @@ void moveweapons(void) { s->x += sintable[(s->ang + 512) & 2047] >> 7; s->y += sintable[s->ang & 2047] >> 7; - if (!isRRRA() || (sprite[s->owner].picnum != RR_DAISYMAE && sprite[s->owner].picnum != RR_DAISYMAESTAYPUT)) + if (!isRRRA() || (sprite[s->owner].picnum != CHEER && sprite[s->owner].picnum != CHEERSTAYPUT)) { - j = spawn(i, RR_CIRCLESTUCK); + j = spawn(i, CIRCLESTUCK); sprite[j].xrepeat = 8; sprite[j].yrepeat = 8; sprite[j].cstat = 16; @@ -3455,7 +1454,7 @@ void moveweapons(void) deletesprite(i); continue; } - if (!ismirror) + if (wall[j].overpicnum != MIRROR && wall[j].picnum != MIRROR) { s->extra -= 20; s->yvel--; @@ -3473,11 +1472,11 @@ void moveweapons(void) { setsprite(i, dax, day, daz); - if (isRRRA() && sprite[s->owner].picnum == RR_MAMAJACKOLOPE) + if (isRRRA() && sprite[s->owner].picnum == MAMA) { - guts(s, RR_RABBITJIBA, 2, myconnectindex); - guts(s, RR_RABBITJIBB, 2, myconnectindex); - guts(s, RR_RABBITJIBC, 2, myconnectindex); + guts_r(s, RABBITJIBA, 2, myconnectindex); + guts_r(s, RABBITJIBB, 2, myconnectindex); + guts_r(s, RABBITJIBC, 2, myconnectindex); } if (s->zvel < 0) @@ -3492,7 +1491,7 @@ void moveweapons(void) checkhitceiling(s->sectnum); } - if (!isRRRA() && picnum == pPick2(FREEZEBLAST, RR_ALIENBLAST)) + if (!isRRRA() && s->picnum == FREEZEBLAST) { bounce(i); ssp(i, qq); @@ -3506,30 +1505,11 @@ void moveweapons(void) } } - if (picnum != pPick2(SPIT, RR_SHITBALL)) + if (s->picnum != SPIT) { - if (picnum == pPick2(RPG, RR_CROSSBOW)) + if (s->picnum == RPG) { - k = spawn(i, pPick(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 (!isRR() && s->zvel > 0) - spawn(i, EXPLOSION2BOT); - else { sprite[k].cstat |= 8; sprite[k].z += (48 << 8); } - } - } - else if (isRRRA() && s->picnum == RR_CHIKENCROSSBOW) - { - k = spawn(i, RR_EXPLOSION2); + k = spawn(i, EXPLOSION2); sprite[k].x = dax; sprite[k].y = day; sprite[k].z = daz; @@ -3545,10 +1525,28 @@ void moveweapons(void) sprite[k].z += (48 << 8); } } - else if (isRRRA() && s->picnum == RR_1790) + else if (isRRRA() && s->picnum == RPG2) + { + 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) + { + sprite[k].cstat |= 8; + sprite[k].z += (48 << 8); + } + } + else if (isRRRA() && s->picnum == RRTILE1790) { s->extra = 160; - k = spawn(i, RR_EXPLOSION2); + k = spawn(i, EXPLOSION2); sprite[k].x = dax; sprite[k].y = day; sprite[k].z = daz; @@ -3564,18 +1562,9 @@ void moveweapons(void) sprite[k].z += (48 << 8); } } - - else if (!isRR() && picnum == SHRINKSPARK) + else if (s->picnum != FREEZEBLAST && s->picnum != FIRELASER && s->picnum != SHRINKSPARK) { - spawn(i, SHRINKEREXPLOSION); - spritesound(SHRINKER_HIT, i); - hitradius(i, shrinkerblastradius, 0, 0, 0, 0); - } - else if (!isRR() ? - !isIn(picnum, COOLEXPLOSION1, FREEZEBLAST, FIRELASER) : - !isIn(picnum, RR_ALIENBLAST, RR_FIRELASER, RR_CIRCLESAW)) - { - k = spawn(i, pPick(EXPLOSION2)); + k = spawn(i, 1441); sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat >> 1; if ((j & 49152) == 16384) { @@ -3585,7 +1574,7 @@ void moveweapons(void) } } } - if (picnum == pPick2(RPG, RR_CROSSBOW)) + if (s->picnum == RPG) { spritesound(RPG_EXPLODE, i); @@ -3600,7 +1589,7 @@ void moveweapons(void) hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); } } - else if (isRRRA() && s->picnum == RR_CHIKENCROSSBOW) + else if (isRRRA() && s->picnum == RPG2) { s->extra = 150; spritesound(247, i); @@ -3616,7 +1605,7 @@ void moveweapons(void) hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); } } - else if (s->picnum == RR_1790) + else if (isRRRA() && s->picnum == RRTILE1790) { s->extra = 160; spritesound(RPG_EXPLODE, i); @@ -3632,36 +1621,23 @@ void moveweapons(void) hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); } } - - } - if (isRR() || picnum != COOLEXPLOSION1) - { - deletesprite(i); - continue; } + deletesprite(i); + continue; } - if (!isRR() && picnum == COOLEXPLOSION1) - { - s->shade++; - if (s->shade >= 40) - { - deletesprite(i); - continue; - } - } - else if ((picnum == pPick2(RPG, RR_CROSSBOW) || (isRRRA() && picnum == RR_CHIKENCROSSBOW)) && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) - spawn(i, pPick(WATERBUBBLE)); + if ((s->picnum == RPG || (isRRRA() && s->picnum == RPG2)) && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(184)) + spawn(i, WATERBUBBLE); continue; - } - else if (picnum == pPick(SHOTSPARK1)) - { + + + case SHOTSPARK1: p = findplayer(s, &x); execute(i, p, x); + continue; } } } - END_DUKE_NS diff --git a/source/games/duke/src/e_actors.cpp b/source/games/duke/src/e_actors.cpp index d8bf83d5e..a7377c019 100644 --- a/source/games/duke/src/e_actors.cpp +++ b/source/games/duke/src/e_actors.cpp @@ -353,7 +353,6 @@ int G_WakeUp(spritetype *const pSprite, int const playerNum) // sleeping monsters, etc -void movefta(void); // stupid name, but it's what the function does. int ifhitsectors(int sectnum); @@ -375,12 +374,6 @@ static int P_Submerge(int, int, DukePlayer_t *, int, int); static int P_Emerge(int, int, DukePlayer_t *, int, int); static void P_FinishWaterChange(int, DukePlayer_t *, int, int, int); -void moveplayers(); -void movefx(); -void movefallers(); -void movestandables(); -void moveweapons(); - ACTOR_STATIC void A_DoProjectileBounce(int const spriteNum) { spritetype * const pSprite = &sprite[spriteNum]; @@ -7534,20 +7527,64 @@ void G_RefreshLights(void) #endif } -void G_MoveWorld(void) +void movefta_d(void); +void movefallers_d(); +void movestandables_d(); +void moveweapons_d(); + +void movefta_r(void); +void moveplayers(); +void movefx(); +void movefallers_r(); +void movestandables_r(); +void moveweapons_r(); + +void G_MoveWorld_d(void) +{ + extern double g_moveActorsTime, g_moveWorldTime; + const double worldTime = timerGetHiTicks(); + + movefta_d(); //ST 2 + moveweapons_d(); //ST 4 + G_MoveTransports(); //ST 9 + + moveplayers(); //ST 10 + movefallers_d(); //ST 12 + G_MoveMisc(); //ST 5 + + const double actorsTime = timerGetHiTicks(); + + G_MoveActors(); //ST 1 + + g_moveActorsTime = (1-0.033)*g_moveActorsTime + 0.033*(timerGetHiTicks()-actorsTime); + + // XXX: Has to be before effectors, in particular movers? + // TODO: lights in moving sectors ought to be interpolated + G_DoEffectorLights(); + G_MoveEffectors(); //ST 3 + movestandables_d(); //ST 6 + + G_RefreshLights(); + G_DoSectorAnimations(); + movefx(); //ST 11 + + g_moveWorldTime = (1-0.033)*g_moveWorldTime + 0.033*(timerGetHiTicks()-worldTime); +} + +void G_MoveWorld_r(void) { extern double g_moveActorsTime, g_moveWorldTime; const double worldTime = timerGetHiTicks(); if (!DEER) { - movefta(); //ST 2 + movefta_r(); //ST 2 G_MoveWeapons(); //ST 4 G_MoveTransports(); //ST 9 } moveplayers(); //ST 10 - movefallers(); //ST 12 + movefallers_r(); //ST 12 if (!DEER) G_MoveMisc(); //ST 5 @@ -7555,7 +7592,7 @@ void G_MoveWorld(void) G_MoveActors(); //ST 1 - g_moveActorsTime = (1-0.033)*g_moveActorsTime + 0.033*(timerGetHiTicks()-actorsTime); + g_moveActorsTime = (1 - 0.033) * g_moveActorsTime + 0.033 * (timerGetHiTicks() - actorsTime); if (DEER) { @@ -7573,7 +7610,7 @@ void G_MoveWorld(void) if (!DEER) { G_MoveEffectors(); //ST 3 - movestandables(); //ST 6 + movestandables_r(); //ST 6 } G_RefreshLights(); @@ -7584,8 +7621,14 @@ void G_MoveWorld(void) if (RR && numplayers < 2 && g_thunderOn) G_Thunder(); - g_moveWorldTime = (1-0.033)*g_moveWorldTime + 0.033*(timerGetHiTicks()-worldTime); + g_moveWorldTime = (1 - 0.033) * g_moveWorldTime + 0.033 * (timerGetHiTicks() - worldTime); } +void G_MoveWorld(void) +{ + if (!isRR()) G_MoveWorld_d(); + else G_MoveWorld_r(); +} END_DUKE_NS + diff --git a/source/games/duke/src/macros.h b/source/games/duke/src/macros.h index 3b2f3c594..7be9786fd 100644 --- a/source/games/duke/src/macros.h +++ b/source/games/duke/src/macros.h @@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define EDUKE32_MACROS_H_ #include "mmulti.h" -#include "names.h" BEGIN_DUKE_NS @@ -64,10 +63,7 @@ static FORCE_INLINE int32_t krand2(void) inline bool AFLAMABLE(int X) { - if (!(g_gameType & GAMEFLAG_RRALL)) - return (X == BOX || X == TREE1 || X == TREE2 || X == TIRE || X == CONE); - else - return (X == RR_AFLAM1191 || X == RR_AFLAM1193 || X == RR_TIRE || X == RR_AFLAM3062); + return (X == TILE_BOX || X == TILE_TREE1 || X == TILE_TREE2 || X == TILE_TIRE || X == TILE_CONE); } #define rnd(X) ((krand2()>>8)>=(255-(X))) diff --git a/source/games/duke/src/names.h b/source/games/duke/src/names.h index ef35e973e..ef98867f2 100644 --- a/source/games/duke/src/names.h +++ b/source/games/duke/src/names.h @@ -29,17 +29,6 @@ BEGIN_DUKE_NS enum { - SECTOREFFECTOR = 1, - ACTIVATOR = 2, - TOUCHPLATE = 3, - ACTIVATORLOCKED = 4, - MUSICANDSFX = 5, - LOCATORS = 6, - CYCLER = 7, - MASTERSWITCH = 8, - RESPAWN = 9, - GPSPEED = 10, - FOF = 13, ARROW = 20, FIRSTGUNSPRITE = 21, CHAINGUNSPRITE = 22, diff --git a/source/games/duke/src/names_rr.h b/source/games/duke/src/names_rr.h index 778687e9c..11ffddaad 100644 --- a/source/games/duke/src/names_rr.h +++ b/source/games/duke/src/names_rr.h @@ -32,19 +32,8 @@ BEGIN_DUKE_NS enum { - SECTOREFFECTOR = 1, - ACTIVATOR = 2, - TOUCHPLATE = 3, - ACTIVATORLOCKED = 4, - MUSICANDSFX = 5, - LOCATORS = 6, - CYCLER = 7, - MASTERSWITCH = 8, - RESPAWN = 9, - GPSPEED = 10, RRTILE11 = 11, PLEASEWAIT = 12, - FOF = 13, //WEATHERWARN = 14, RPG2SPRITE = 14, DUKETAG = 15, @@ -306,7 +295,7 @@ enum PIPE2B = 1126, BOLT1 = 1127, PIPE3B = 1132, - CAMERA1 = 1134, + RR_CAMERA1 = 1134, BRICK = 1139, VACUUM = 1141, JURYGUY = 1142, @@ -980,7 +969,7 @@ enum RRTILE3827 = 3827, RRTILE3837 = 3837, APLAYERTOP = 3840, - APLAYER = 3845, + RR_APLAYER = 3845, PLAYERONWATER = 3860, DUKELYINGDEAD = 3998, DUKEGUN = 4041, @@ -1246,7 +1235,7 @@ enum RRTILE8594 = 8594, RRTILE8595 = 8595, RRTILE8596 = 8596, - RRTILE8598 = 8598 = , + RRTILE8598 = 8598, RRTILE8605 = 8605, RRTILE8608 = 8608, RRTILE8609 = 8609, @@ -1267,15 +1256,12 @@ enum RRTILE8682 = 8682, RRTILE8683 = 8683, RRTILE8704 = 8704, - , - , // = RR = bad = guys, BOSS1 = 4477, BOSS2 = 4557, BOSS3 = 4607, BOSS4 = 4221, - , - , + BOULDER = 256, BOULDER1 = 264, TORNADO = 1930, @@ -1335,13 +1321,8 @@ enum SBDIP = 5085, MINION = 5120, MINIONSTAYPUT = 5121, - , - #ifdef = RRRA, - # = define = UFO1 = 5260, - #else, - # = define = UFO1 = 5270, - #endif, - , + UFO1_RR = 5260, + UFO1_RRRA = 5270, UFO2 = 5274, UFO3 = 5278, UFO4 = 5282, @@ -1406,4 +1387,8 @@ enum MAMA = 8705, MAMAJIBA = 8890, MAMAJIBB = 8895, -}; \ No newline at end of file +}; + +extern int APLAYER; +extern int CAMERA1; +END_DUKE_NS diff --git a/source/games/duke/src/namesdyn.cpp b/source/games/duke/src/namesdyn.cpp index 0a06dc0ec..db1cbc6af 100644 --- a/source/games/duke/src/namesdyn.cpp +++ b/source/games/duke/src/namesdyn.cpp @@ -2928,8 +2928,9 @@ void G_InitDynamicTiles(void) { int32_t i; - APLAYER = (g_gameType & GAMEFLAG_RRALL) ? RR_APLAYER : DUKE_APLAYER; - CAMERA1 = (g_gameType & GAMEFLAG_RRALL) ? RR_CAMERA1 : DUKE_CAMERA1; + // this cannot include the constant headers so it has to use literal numbers + APLAYER = (g_gameType & GAMEFLAG_RRALL) ? 3845 : 1405; + CAMERA1 = (g_gameType & GAMEFLAG_RRALL) ? 1134 : 621; Bmemset(DynamicTileMap, 0, sizeof(DynamicTileMap)); diff --git a/source/games/duke/src/namesdyn.h b/source/games/duke/src/namesdyn.h index 360194430..51cef6296 100644 --- a/source/games/duke/src/namesdyn.h +++ b/source/games/duke/src/namesdyn.h @@ -3612,6 +3612,7 @@ enum redneck_weapon_t RATE_WEAPON = 15, CHICKENBOW_WEAPON = 16 }; +extern int APLAYER, CAMERA1; #define DYNAMICWEAPONMAP(Weaponnum) Weaponnum