From 7b75a0683a5aa048d2b0af59a80ee3580b1bbabf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 9 May 2020 00:34:48 +0200 Subject: [PATCH] moveactors plus backing code. --- source/build/include/pragmas.h | 2 + source/core/gamecontrol.h | 5 + source/games/duke/CMakeLists.txt | 2 + source/games/duke/src/actors.cpp | 624 +++++- source/games/duke/src/actors.h | 17 +- source/games/duke/src/actors_d.cpp | 949 +++++++++- source/games/duke/src/actors_lava.cpp | 663 +++++++ source/games/duke/src/actors_r.cpp | 1193 +++++++++++- source/games/duke/src/bowling.cpp | 341 ++++ source/games/duke/src/cheats.cpp | 4 +- source/games/duke/src/e_actors.cpp | 2500 +------------------------ source/games/duke/src/game.cpp | 8 +- source/games/duke/src/global.h | 46 +- source/games/duke/src/player.h | 26 + source/games/duke/src/premap.cpp | 65 +- source/games/duke/src/savegame.cpp | 34 +- source/games/duke/src/sector.cpp | 435 +---- source/games/duke/src/sector.h | 17 +- source/games/duke/src/soundefs.h | 5 + source/games/duke/src/sounds.h | 4 + 20 files changed, 3875 insertions(+), 3065 deletions(-) create mode 100644 source/games/duke/src/actors_lava.cpp create mode 100644 source/games/duke/src/bowling.cpp diff --git a/source/build/include/pragmas.h b/source/build/include/pragmas.h index 0a32a13dd..cc89dad71 100644 --- a/source/build/include/pragmas.h +++ b/source/build/include/pragmas.h @@ -174,6 +174,8 @@ static FORCE_INLINE void swapchar2(void *a, void *b, int32_t s) static FORCE_INLINE CONSTEXPR int ksgn(int32_t a) { return (a > 0) - (a < 0); } #endif +inline int sgn(int32_t a) { return (a > 0) - (a < 0); } + #ifndef pragmas_have_mulscale static FORCE_INLINE CONSTEXPR int32_t mulscale(int32_t eax, int32_t edx, int32_t ecx) { return dw((qw(eax) * edx) >> by(ecx)); } static FORCE_INLINE CONSTEXPR int32_t dmulscale(int32_t eax, int32_t edx, int32_t esi, int32_t edi, int32_t ecx) diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 8c5f49a40..b2afefcf2 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -155,6 +155,11 @@ inline bool isNam() return g_gameType & (GAMEFLAG_NAM | GAMEFLAG_NAPALM); } +inline bool isNamWW2GI() +{ + return g_gameType & (GAMEFLAG_NAM | GAMEFLAG_NAPALM |GAMEFLAG_WW2GI); +} + inline bool isWW2GI() { return g_gameType & (GAMEFLAG_WW2GI); diff --git a/source/games/duke/CMakeLists.txt b/source/games/duke/CMakeLists.txt index 1234aa669..44e4e8c98 100644 --- a/source/games/duke/CMakeLists.txt +++ b/source/games/duke/CMakeLists.txt @@ -3,6 +3,8 @@ set( PCH_SOURCES src/actors.cpp src/actors_r.cpp src/actors_d.cpp + src/actors_lava.cpp + src/bowling.cpp src/e_actors.cpp src/anim.cpp src/cheats.cpp diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index acfaa7bf8..d87183af8 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -446,7 +446,7 @@ void movedummyplayers(void) { sprite[i].cstat = 257; sprite[i].z = sector[sprite[i].sectnum].ceilingz + (27 << 8); - sprite[i].ang = ps[p].q16ang >> FRACBITS; + sprite[i].ang = ps[p].getang(); if (hittype[i].temp_data[0] == 8) hittype[i].temp_data[0] = 0; else hittype[i].temp_data[0]++; @@ -493,7 +493,7 @@ void moveplayers(void) //Players s->x = p->oposx; s->y = p->oposy; hittype[i].bposz = s->z = p->oposz + PHEIGHT; - s->ang = p->oq16ang >> FRACBITS; + s->ang = p->getoang(); setsprite(i, s->x, s->y, s->z); } else @@ -553,14 +553,13 @@ void moveplayers(void) //Players if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS) { - int ang = p->q16ang >> FRACBITS; + int ang = p->getang(); ang += getincangle(ang, getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1; - ang &= 2047; - p->q16ang = ang << FRACBITS; + p->setang(ang & 2047); } } - s->ang = p->q16ang >> FRACBITS; + s->ang = p->getang(); } } else @@ -598,7 +597,7 @@ void moveplayers(void) //Players if (s->extra < 8) { s->xvel = 128; - s->ang = p->q16ang >> FRACBITS; + s->ang = p->getang(); 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 @@ -606,7 +605,7 @@ void moveplayers(void) //Players } else { - s->ang = 2047 - (p->q16ang >> FRACBITS); + s->ang = 2047 - (p->getang()); setsprite(i, s->x, s->y, s->z); } } @@ -815,7 +814,7 @@ void movecrane(int i, int crane) s->owner = -2; ps[p].on_crane = i; spritesound(isRR() ? 390 : DUKE_GRUNT, ps[p].i); - ps[p].q16ang = (s->ang + 1024) << FRACBITS; + ps[p].setang(s->ang + 1024); } else { @@ -901,7 +900,7 @@ void movecrane(int i, int crane) } else if (s->owner == -2) { - auto ang = ps[p].q16ang >> FRACBITS; + auto ang = ps[p].getang(); 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); @@ -1468,6 +1467,611 @@ void movetongue(int i, int tongue, int jaw) sprite[q].picnum = jaw + 1; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- +bool respawnmarker(int i, int yellow, int green) +{ + hittype[i].temp_data[0]++; + if (hittype[i].temp_data[0] > respawnitemtime) + { + deletesprite(i); + return false; + } + if (hittype[i].temp_data[0] >= (respawnitemtime >> 1) && hittype[i].temp_data[0] < ((respawnitemtime >> 1) + (respawnitemtime >> 2))) + sprite[i].picnum = yellow; + else if (hittype[i].temp_data[0] > ((respawnitemtime >> 1) + (respawnitemtime >> 2))) + sprite[i].picnum = green; + makeitfall(i); + return true; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +bool rat(int i, bool makesound) +{ + spritetype* s = &sprite[i]; + makeitfall(i); + if (ssp(i, CLIPMASK0)) + { + if (makesound && (krand() & 255) == 0) spritesound(RATTY, i); + s->ang += (krand() & 31) - 15 + (sintable[(hittype[i].temp_data[0] << 8) & 2047] >> 11); + } + else + { + hittype[i].temp_data[0]++; + if (hittype[i].temp_data[0] > 1) + { + deletesprite(i); + return false; + } + else s->ang = (krand() & 2047); + } + if (s->xvel < 128) + s->xvel += 2; + s->ang += (krand() & 3) - 6; + return true; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +bool queball(int i, int pocket, int queball, int stripeball) +{ + spritetype* s = &sprite[i]; + int j, nextj; + if (s->xvel) + { + j = headspritestat[0]; + while (j >= 0) + { + nextj = nextspritestat[j]; + if (sprite[j].picnum == pocket && ldist(&sprite[j], s) < 52) + { + deletesprite(i); + return false; + } + j = nextj; + } + + j = clipmove(&s->x, &s->y, &s->z, &s->sectnum, + (((s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14) * TICSPERFRAME) << 11, + (((s->xvel * (sintable[s->ang & 2047])) >> 14) * TICSPERFRAME) << 11, + 24L, (4 << 8), (4 << 8), CLIPMASK1); + + if (j & 49152) + { + if ((j & 49152) == 32768) + { + j &= (MAXWALLS - 1); + int 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; + } + else if ((j & 49152) == 49152) + { + j &= (MAXSPRITES - 1); + checkhitsprite(i, j); + } + } + s->xvel--; + if (s->xvel < 0) s->xvel = 0; + if (s->picnum == stripeball) + { + s->cstat = 257; + s->cstat |= 4 & s->xvel; + s->cstat |= 8 & s->xvel; + } + } + else + { + int x; + int p = findplayer(s, &x); + + if (x < 1596) + { + + // if(s->pal == 12) + { + j = getincangle(ps[p].getang(), getangle(s->x - ps[p].posx, s->y - ps[p].posy)); + if (j > -64 && j < 64 && PlayerInput(p, SK_OPEN)) + if (ps[p].toggle_key_flag == 1) + { + int a = headspritestat[1]; + while (a >= 0) + { + if (sprite[a].picnum == queball || sprite[a].picnum == stripeball) + { + j = getincangle(ps[p].getang(), getangle(sprite[a].x - ps[p].posx, sprite[a].y - ps[p].posy)); + if (j > -64 && j < 64) + { + int l; + findplayer(&sprite[a], &l); + if (x > l) break; + } + } + a = nextspritestat[a]; + } + if (a == -1) + { + if (s->pal == 12) + s->xvel = 164; + else s->xvel = 140; + s->ang = ps[p].getang(); + ps[p].toggle_key_flag = 2; + } + } + } + } + if (x < 512 && s->sectnum == ps[p].cursectnum) + { + s->ang = getangle(s->x - ps[p].posx, s->y - ps[p].posy); + s->xvel = 48; + } + } + return true; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void forcesphere(int i, int forcesphere) +{ + spritetype* s = &sprite[i]; + auto t = &hittype[i].temp_data[0]; + int sect = s->sectnum; + if (s->yvel == 0) + { + s->yvel = 1; + + for (int l = 512; l < (2048 - 512); l += 128) + for (int j = 0; j < 2048; j += 128) + { + int k = spawn(i, forcesphere); + sprite[k].cstat = 257 + 128; + sprite[k].clipdist = 64; + sprite[k].ang = j; + sprite[k].zvel = sintable[l & 2047] >> 5; + sprite[k].xvel = sintable[(l + 512) & 2047] >> 9; + sprite[k].owner = i; + } + } + + if (t[3] > 0) + { + if (s->zvel < 6144) + s->zvel += 192; + s->z += s->zvel; + if (s->z > sector[sect].floorz) + s->z = sector[sect].floorz; + t[3]--; + if (t[3] == 0) + { + deletesprite(i); + return; + } + else if (t[2] > 10) + { + int j = headspritestat[5]; + while (j >= 0) + { + if (sprite[j].owner == i && sprite[j].picnum == forcesphere) + hittype[j].temp_data[1] = 1 + (krand() & 63); + j = nextspritestat[j]; + } + t[3] = 64; + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void recon(int i, int explosion, int firelaser, int attacksnd, int painsnd, int roamsnd, int shift, int (*getspawn)(int i)) +{ + spritetype* s = &sprite[i]; + auto t = &hittype[i].temp_data[0]; + int sect = s->sectnum; + int j, a; + + getglobalz(i); + + 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; + + if (s->z < sector[sect].ceilingz + (32 << 8)) + s->z = sector[sect].ceilingz + (32 << 8); + + if (ud.multimode < 2) + { + if (actor_tog == 1) + { + s->cstat = (short)32768; + return; + } + else if (actor_tog == 2) s->cstat = 257; + } + j = ifhitbyweapon(i); if (j >= 0) + { + if (s->extra < 0 && t[0] != -1) + { + t[0] = -1; + s->extra = 0; + } + if (painsnd >= 0) spritesound(painsnd, i); + RANDOMSCRAP(s, i); + } + + if (t[0] == -1) + { + s->z += 1024; + t[2]++; + if ((t[2] & 3) == 0) spawn(i, explosion); + getglobalz(i); + s->ang += 96; + s->xvel = 128; + j = ssp(i, CLIPMASK0); + if (j != 1 || s->z > hittype[i].floorz) + { + for (int l = 0; l < 16; l++) + RANDOMSCRAP(s, i); + spritesound(LASERTRIP_EXPLODE, i); + spawn(i, getspawn(i)); + ps[myconnectindex].actors_killed++; + deletesprite(i); + } + return; + } + else + { + if (s->z > hittype[i].floorz - (48 << 8)) + s->z = hittype[i].floorz - (48 << 8); + } + + int x; + int p = findplayer(s, &x); + j = s->owner; + + // 3 = findplayerz, 4 = shoot + + if (t[0] >= 4) + { + t[2]++; + if ((t[2] & 15) == 0) + { + a = s->ang; + s->ang = hittype[i].tempang; + if (attacksnd >= 0) spritesound(attacksnd, i); + shoot(i, firelaser); + s->ang = a; + } + if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum)) + { + t[0] = 0; + t[2] = 0; + } + else hittype[i].tempang += + getincangle(hittype[i].tempang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) / 3; + } + else if (t[0] == 2 || t[0] == 3) + { + t[3] = 0; + if (s->xvel > 0) s->xvel -= 16; + else s->xvel = 0; + + if (t[0] == 2) + { + int l = ps[p].posz - s->z; + if (abs(l) < (48 << 8)) t[0] = 3; + else s->z += sgn(ps[p].posz - s->z) << shift; // The shift here differs between Duke and RR. + } + else + { + t[2]++; + if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum)) + { + t[0] = 1; + t[2] = 0; + } + else if ((t[2] & 15) == 0 && attacksnd >= 0) + { + spritesound(attacksnd, i); + shoot(i, firelaser); + } + } + s->ang += getincangle(s->ang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 2; + } + + if (t[0] != 2 && t[0] != 3) + { + int l = ldist(&sprite[j], s); + if (l <= 1524) + { + a = s->ang; + s->xvel >>= 1; + } + else a = getangle(sprite[j].x - s->x, sprite[j].y - s->y); + + if (t[0] == 1 || t[0] == 4) // Found a locator and going with it + { + l = dist(&sprite[j], s); + + if (l <= 1524) { if (t[0] == 1) t[0] = 0; else t[0] = 5; } + else + { + // Control speed here + if (l > 1524) { if (s->xvel < 256) s->xvel += 32; } + else + { + if (s->xvel > 0) s->xvel -= 16; + else s->xvel = 0; + } + } + + if (t[0] < 2) t[2]++; + + if (x < 6144 && t[0] < 2 && t[2] > (26 * 4)) + { + t[0] = 2 + (krand() & 2); + t[2] = 0; + hittype[i].tempang = s->ang; + } + } + + if (t[0] == 0 || t[0] == 5) + { + if (t[0] == 0) + t[0] = 1; + else t[0] = 4; + j = s->owner = LocateTheLocator(s->hitag, -1); + if (j == -1) + { + s->hitag = j = hittype[i].temp_data[5]; + s->owner = LocateTheLocator(j, -1); + j = s->owner; + if (j == -1) + { + deletesprite(i); + return; + } + } + else s->hitag++; + } + + t[3] = getincangle(s->ang, a); + s->ang += t[3] >> 3; + + if (s->z < sprite[j].z) + s->z += 1024; + else s->z -= 1024; + } + + if (roamsnd >= 0 && S_CheckSoundPlaying(roamsnd) < 2) + A_PlaySound(roamsnd, i); + + ssp(i, CLIPMASK0); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void ooz(int i) +{ + getglobalz(i); + + int j = (hittype[i].floorz - hittype[i].ceilingz) >> 9; + if (j > 255) j = 255; + + int x = 25 - (j >> 1); + if (x < 8) x = 8; + else if (x > 48) x = 48; + + spritetype* s = &sprite[i]; + s->yrepeat = j; + s->xrepeat = x; + s->z = hittype[i].floorz; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void reactor(int i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BURNT) +{ + spritetype* s = &sprite[i]; + auto t = &hittype[i].temp_data[0]; + int sect = s->sectnum; + + if (t[4] == 1) + { + int j = headspritesect[sect]; + while (j >= 0) + { + if (sprite[j].picnum == SECTOREFFECTOR) + { + if (sprite[j].lotag == 1) + { + sprite[j].lotag = (short)65535; + sprite[j].hitag = (short)65535; + } + } + else if (sprite[j].picnum == REACTOR) + { + sprite[j].picnum = REACTORBURNT; + } + else if (sprite[j].picnum == REACTOR2) + { + sprite[j].picnum = REACTOR2BURNT; + } + else if (sprite[j].picnum == REACTORBURNT || sprite[j].picnum == REACTOR2BURNT) + { + sprite[j].cstat = (short)32768; + } + j = nextspritesect[j]; + } + return; + } + + if (t[1] >= 20) + { + t[4] = 1; + return; + } + + int x; + int p = findplayer(s, &x); + + t[2]++; + if (t[2] == 4) t[2] = 0; + + if (x < 4096) + { + if ((krand() & 255) < 16) + { + if (!S_CheckSoundPlaying(DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN, ps[p].i); + + spritesound(SHORT_CIRCUIT, i); + + sprite[ps[p].i].extra--; + SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0)); + } + t[0] += 128; + if (t[3] == 0) + t[3] = 1; + } + else t[3] = 0; + + if (t[1]) + { + int j; + t[1]++; + + t[4] = s->z; + s->z = sector[sect].floorz - (krand() % (sector[sect].floorz - sector[sect].ceilingz)); + + switch (t[1]) + { + case 3: + //Turn on all of those flashing sectoreffector. + hitradius(i, 4096, + impact_damage << 2, + impact_damage << 2, + impact_damage << 2, + impact_damage << 2); + j = headspritestat[6]; + while (j >= 0) + { + if (sprite[j].picnum == MASTERSWITCH) + if (sprite[j].hitag == s->hitag) + if (sprite[j].yvel == 0) + sprite[j].yvel = 1; + j = nextspritestat[j]; + } + break; + + case 4: + case 7: + case 10: + case 15: + j = headspritesect[sect]; + while (j >= 0) + { + int l = nextspritesect[j]; + + if (j != i) + { + deletesprite(j); + return; + } + j = l; + } + break; + } + for (x = 0; x < 16; x++) + RANDOMSCRAP(s, i); + + s->z = t[4]; + t[4] = 0; + + } + else + { + int j = ifhitbyweapon(i); + if (j >= 0) + { + for (x = 0; x < 32; x++) + RANDOMSCRAP(s, i); + if (s->extra < 0) + t[1] = 1; + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void camera(int i) +{ + spritetype* s = &sprite[i]; + auto t = &hittype[i].temp_data[0]; + if (t[0] == 0) + { + t[1] += 8; + if (camerashitable) + { + int j = ifhitbyweapon(i); + if (j >= 0) + { + t[0] = 1; // static + s->cstat = (short)32768; + for (int x = 0; x < 5; x++) + RANDOMSCRAP(s, i); + return; + } + } + + if (s->hitag > 0) + { + if (t[1] < s->hitag) + s->ang += 8; + else if (t[1] < (s->hitag * 3)) + s->ang -= 8; + else if (t[1] < (s->hitag << 2)) + s->ang += 8; + else + { + t[1] = 8; + s->ang += 16; + } + } + } +} END_DUKE_NS diff --git a/source/games/duke/src/actors.h b/source/games/duke/src/actors.h index 0c6e09614..d423575e7 100644 --- a/source/games/duke/src/actors.h +++ b/source/games/duke/src/actors.h @@ -262,10 +262,16 @@ extern actor_t actor[MAXSPRITES]; extern actor_t* hittype; extern int32_t block_deletesprite; extern int32_t g_noEnemies; +#define actor_tog g_noEnemies extern int32_t otherp; extern int32_t ticrandomseed; extern int g_canSeePlayer; +int A_FindLocator(int const tag, int const sectNum); +inline int LocateTheLocator(int const tag, int const sectNum) +{ + return A_FindLocator(tag, sectNum); +} int A_CheckNoSE7Water(uspritetype const *pSprite, int sectNum, int sectLotag, int32_t *pOther); int A_CheckSwitchTile(int spriteNum); @@ -284,7 +290,7 @@ inline void check_fta_sounds(int s) } void A_RadiusDamage(int spriteNum, int blastRadius, int dmg1, int dmg2, int dmg3, int dmg4); void A_SpawnMultiple(int spriteNum, int tileNum, int spawnCnt); -void A_ResetLanePics(void); +void resetlanepics(void); int G_SetInterpolation(int32_t *posptr); void G_AddGameLight(int lightRadius, int spriteNum, int zOffset, int lightRange, int lightColor, int lightPrio); @@ -382,6 +388,15 @@ 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); +bool respawnmarker(int i, int yellow, int green); +bool rat(int i, bool makesound); +bool queball(int i, int pocket, int queball, int stripeball); +void forcesphere(int i, int forcesphere); +void recon(int i, int explosion, int firelaser, int attacksnd, int painsnd, int roamsnd, int shift, int (*getspawn)(int i)); +void ooz(int i); +void reactor(int i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BURNT); +void camera(int i); + void respawn_rrra(int i, int j); void hitradius(short i, int r, int hp1, int hp2, int hp3, int hp4); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index f10b759d0..2cda48e1a 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1530,6 +1530,10 @@ void moveweapons_d(void) case FIRELASER: case SPIT: case COOLEXPLOSION1: + case FIREBALL: + // Twentieth Anniversary World Tour + if (s->picnum == FIREBALL && !isWorldTour()) + break; if (s->picnum == COOLEXPLOSION1) if (!S_CheckSoundPlaying(i, WIERDSHOT_FLY)) @@ -1673,6 +1677,8 @@ void moveweapons_d(void) s->zvel = 0; } + bool fireball = (isWorldTour() && s->picnum == FIREBALL && sprite[s->owner].picnum != FIREBALL); + if ((j&49152) == 49152) { j &= (MAXSPRITES-1); @@ -1689,16 +1695,23 @@ void moveweapons_d(void) continue; } - checkhitsprite(j,i); + if (!isWorldTour() || s->picnum != FIREBALL || fireball) + checkhitsprite(j,i); if (sprite[j].picnum == APLAYER) { p = sprite[j].yvel; + + if (ud.multimode >= 2 && fireball && sprite[s->owner].picnum == APLAYER) + { + ps[p].numloogs = -1 - sprite[i].yvel; + } + spritesound(PISTOL_BODYHIT,j); if (s->picnum == SPIT) { - ps[p].q16horiz += 32 << FRACBITS; + ps[p].addhoriz(32); ps[p].return_to_center = 8; if (ps[p].loogcnt == 0) @@ -1722,7 +1735,9 @@ void moveweapons_d(void) { j &= (MAXWALLS-1); - if (s->picnum != RPG && s->picnum != FREEZEBLAST && s->picnum != SPIT && (wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR)) + if (s->picnum != RPG && s->picnum != FREEZEBLAST && s->picnum != SPIT && + (!isWorldTour() || s->picnum != FIREBALL) && + (wall[j].overpicnum == MIRROR || wall[j].picnum == MIRROR)) { k = getangle( wall[wall[j].point2].x-wall[j].x, @@ -1768,6 +1783,15 @@ void moveweapons_d(void) checkhitceiling(s->sectnum); } + else if (fireball) + { + j = spawn(i, LAVAPOOL); + sprite[j].owner = sprite[i].owner; + sprite[j].yvel = sprite[i].yvel; + actor[j].owner = sprite[i].owner; + deletesprite(i); + continue; + } if (s->picnum == FREEZEBLAST) { @@ -1781,6 +1805,8 @@ void moveweapons_d(void) s->yvel--; continue; } + + } if (s->picnum != SPIT) @@ -1810,7 +1836,7 @@ void moveweapons_d(void) spritesound(SHRINKER_HIT,i); hitradius(i,shrinkerblastradius,0,0,0,0); } - else if (s->picnum != COOLEXPLOSION1 && s->picnum != FREEZEBLAST && s->picnum != FIRELASER) + else if (s->picnum != COOLEXPLOSION1 && s->picnum != FREEZEBLAST && s->picnum != FIRELASER && (!isWorldTour() || s->picnum != FIREBALL)) { k = spawn(i,EXPLOSION2); sprite[k].xrepeat = sprite[k].yrepeat = s->xrepeat>>1; @@ -1829,14 +1855,19 @@ void moveweapons_d(void) 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); + hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x); } } + if (fireball) + { + j = spawn(i, EXPLOSION2); + sprite[j].xrepeat = sprite[j].yrepeat = (short)(s->xrepeat >> 1); + } } if (s->picnum != COOLEXPLOSION1) { @@ -1874,7 +1905,7 @@ void moveweapons_d(void) void movetransports_d(void) { char warpspriteto; - short j, k, l, p, sect, sectlotag, nextj, nextk; + short j, k, l, p, sect, sectlotag, nextj; int ll, onfloorz, q, nexti; for (int i = headspritestat[STAT_TRANSPORT]; i >= 0; i = nexti) @@ -1926,7 +1957,7 @@ void movetransports_d(void) sprite[ps[k].i].extra = 0; } - ps[p].q16ang = sprite[sprite[i].owner].ang << FRACBITS; + ps[p].setang(sprite[sprite[i].owner].ang); if (sprite[sprite[i].owner].owner != sprite[i].owner) { @@ -2206,4 +2237,906 @@ void movetransports_d(void) } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void greenslime(int i) +{ + spritetype* s = &sprite[i]; + auto t = &hittype[i].temp_data[0]; + int sect = s->sectnum; + int j; + + // #ifndef VOLUMEONE + if (ud.multimode < 2) + { + if (actor_tog == 1) + { + s->cstat = (short)32768; + return; + } + else if (actor_tog == 2) s->cstat = 257; + } + // #endif + + t[1] += 128; + + if (sector[sect].floorstat & 1) + { + deletesprite(i); + return; + } + + int x; + int p = findplayer(s, &x); + + if (x > 20480) + { + hittype[i].timetosleep++; + if (hittype[i].timetosleep > SLEEPTIME) + { + hittype[i].timetosleep = 0; + changespritestat(i, 2); + return; + } + } + + if (t[0] == -5) // FROZEN + { + t[3]++; + if (t[3] > 280) + { + s->pal = 0; + t[0] = 0; + return; + } + makeitfall(i); + s->cstat = 257; + s->picnum = GREENSLIME + 2; + s->extra = 1; + s->pal = 1; + j = ifhitbyweapon(i); if (j >= 0) + { + if (j == FREEZEBLAST) + return; + for (j = 16; j >= 0; j--) + { + int k = EGS(sprite[i].sectnum, sprite[i].x, sprite[i].y, sprite[i].z, GLASSPIECES + (j % 3), -32, 36, 36, krand() & 2047, 32 + (krand() & 63), 1024 - (krand() & 1023), i, 5); + sprite[k].pal = 1; + } + spritesound(GLASS_BREAKING, i); + deletesprite(i); + } + else if (x < 1024 && ps[p].quick_kick == 0) + { + j = getincangle(ps[p].getang(), getangle(sprite[i].x - ps[p].posx, sprite[i].y - ps[p].posy)); + if (j > -128 && j < 128) + ps[p].quick_kick = 14; + } + + return; + } + + if (x < 1596) + s->cstat = 0; + else s->cstat = 257; + + if (t[0] == -4) //On the player + { + if (sprite[ps[p].i].extra < 1) + { + t[0] = 0; + return; + } + + setsprite(i, s->x, s->y, s->z); + + s->ang = ps[p].getang(); + + if ((PlayerInput(p, SK_FIRE) || (ps[p].quick_kick > 0)) && sprite[ps[p].i].extra > 0) + if (ps[p].quick_kick > 0 || (ps[p].curr_weapon != HANDREMOTE_WEAPON && ps[p].curr_weapon != HANDBOMB_WEAPON && ps[p].curr_weapon != TRIPBOMB_WEAPON && ps[p].ammo_amount[ps[p].curr_weapon] >= 0)) + { + for (x = 0; x < 8; x++) + { + j = EGS(sect, s->x, s->y, s->z - (8 << 8), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), i, 5); + sprite[j].pal = 6; + } + + spritesound(SLIM_DYING, i); + spritesound(SQUISHED, i); + if ((krand() & 255) < 32) + { + j = spawn(i, BLOODPOOL); + sprite[j].pal = 0; + } + ps[p].actors_killed++; + t[0] = -3; + if (ps[p].somethingonplayer == i) + ps[p].somethingonplayer = -1; + deletesprite(i); + return; + } + + s->z = ps[p].posz + ps[p].pyoff - t[2] + (8 << 8); + + s->z += (100 - ps[p].gethoriz()) << 4; + + if (t[2] > 512) + t[2] -= 128; + + if (t[2] < 348) + t[2] += 128; + + if (ps[p].newowner >= 0) + { + ps[p].newowner = -1; + ps[p].posx = ps[p].oposx; + ps[p].posy = ps[p].oposy; + ps[p].posz = ps[p].oposz; + ps[p].q16ang = ps[p].oq16ang; + + updatesector(ps[p].posx, ps[p].posy, &ps[p].cursectnum); + setpal(&ps[p]); + + j = headspritestat[1]; + while (j >= 0) + { + if (sprite[j].picnum == CAMERA1) sprite[j].yvel = 0; + j = nextspritestat[j]; + } + } + + if (t[3] > 0) + { + short frames[] = { 5,5,6,6,7,7,6,5 }; + + s->picnum = GREENSLIME + frames[t[3]]; + + if (t[3] == 5) + { + sprite[ps[p].i].extra += -(5 + (krand() & 3)); + spritesound(SLIM_ATTACK, i); + } + + if (t[3] < 7) t[3]++; + else t[3] = 0; + + } + else + { + s->picnum = GREENSLIME + 5; + if (rnd(32)) + t[3] = 1; + } + + s->xrepeat = 20 + (sintable[t[1] & 2047] >> 13); + s->yrepeat = 15 + (sintable[t[1] & 2047] >> 13); + + s->x = ps[p].posx + (sintable[(ps[p].getang() + 512) & 2047] >> 7); + s->y = ps[p].posy + (sintable[ps[p].getang() & 2047] >> 7); + + return; + } + + else if (s->xvel < 64 && x < 768) + { + if (ps[p].somethingonplayer == -1) + { + ps[p].somethingonplayer = i; + if (t[0] == 3 || t[0] == 2) //Falling downward + t[2] = (12 << 8); + else t[2] = -(13 << 8); //Climbing up duke + t[0] = -4; + } + } + + j = ifhitbyweapon(i); if (j >= 0) + { + spritesound(SLIM_DYING, i); + + ps[p].actors_killed++; + if (ps[p].somethingonplayer == i) + ps[p].somethingonplayer = -1; + + if (j == FREEZEBLAST) + { + spritesound(SOMETHINGFROZE, i); t[0] = -5; t[3] = 0; + return; + } + + if ((krand() & 255) < 32) + { + j = spawn(i, BLOODPOOL); + sprite[j].pal = 0; + } + + for (x = 0; x < 8; x++) + { + j = EGS(sect, s->x, s->y, s->z - (8 << 8), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (s->zvel >> 2), i, 5); + sprite[j].pal = 6; + } + t[0] = -3; + deletesprite(i); + return; + } + // All weap + if (t[0] == -1) //Shrinking down + { + makeitfall(i); + + s->cstat &= 65535 - 8; + s->picnum = GREENSLIME + 4; + + // if(s->yrepeat > 62) + // guts(s,JIBS6,5,myconnectindex); + + if (s->xrepeat > 32) s->xrepeat -= krand() & 7; + if (s->yrepeat > 16) s->yrepeat -= krand() & 7; + else + { + s->xrepeat = 40; + s->yrepeat = 16; + t[5] = -1; + t[0] = 0; + } + + return; + } + else if (t[0] != -2) getglobalz(i); + + if (t[0] == -2) //On top of somebody (an enemy) + { + makeitfall(i); + sprite[t[5]].xvel = 0; + + int l = sprite[t[5]].ang; + + s->z = sprite[t[5]].z; + s->x = sprite[t[5]].x + (sintable[(l + 512) & 2047] >> 11); + s->y = sprite[t[5]].y + (sintable[l & 2047] >> 11); + + s->picnum = GREENSLIME + 2 + (global_random & 1); + + if (s->yrepeat < 64) s->yrepeat += 2; + else + { + if (s->xrepeat < 32) s->xrepeat += 4; + else + { + t[0] = -1; + x = ldist(s, &sprite[t[5]]); + if (x < 768) { + sprite[t[5]].xrepeat = 0; + + // JBF 20041129: a slimer eating another enemy really ought + // to decrease the maximum kill count by one. + if (ps[myconnectindex].max_actors_killed > 0) ps[myconnectindex].max_actors_killed--; + } + } + } + return; + } + + //Check randomly to see of there is an actor near + if (rnd(32)) + { + j = headspritesect[sect]; + while (j >= 0) + { + switch (sprite[j].picnum) + { + case LIZTROOP: + case LIZMAN: + case PIGCOP: + case NEWBEAST: + if (ldist(s, &sprite[j]) < 768 && (klabs(s->z - sprite[j].z) < 8192)) //Gulp them + { + t[5] = j; + t[0] = -2; + t[1] = 0; + return; + } + } + + j = nextspritesect[j]; + } + } + + //Moving on the ground or ceiling + + if (t[0] == 0 || t[0] == 2) + { + s->picnum = GREENSLIME; + + if ((krand() & 511) == 0) + spritesound(SLIM_ROAM, i); + + if (t[0] == 2) + { + s->zvel = 0; + s->cstat &= (65535 - 8); + + if ((sector[sect].ceilingstat & 1) || (hittype[i].ceilingz + 6144) < s->z) + { + s->z += 2048; + t[0] = 3; + return; + } + } + else + { + s->cstat |= 8; + makeitfall(i); + } + + if (everyothertime & 1) ssp(i, CLIPMASK0); + + if (s->xvel > 96) + { + s->xvel -= 2; + return; + } + else + { + if (s->xvel < 32) s->xvel += 4; + s->xvel = 64 - (sintable[(t[1] + 512) & 2047] >> 9); + + s->ang += getincangle(s->ang, + getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 3; + // TJR + } + + s->xrepeat = 36 + (sintable[(t[1] + 512) & 2047] >> 11); + s->yrepeat = 16 + (sintable[t[1] & 2047] >> 13); + + if (rnd(4) && (sector[sect].ceilingstat & 1) == 0 && + klabs(hittype[i].floorz - hittype[i].ceilingz) + < (192 << 8)) + { + s->zvel = 0; + t[0]++; + } + + } + + if (t[0] == 1) + { + s->picnum = GREENSLIME; + if (s->yrepeat < 40) s->yrepeat += 8; + if (s->xrepeat > 8) s->xrepeat -= 4; + if (s->zvel > -(2048 + 1024)) + s->zvel -= 348; + s->z += s->zvel; + if (s->z < hittype[i].ceilingz + 4096) + { + s->z = hittype[i].ceilingz + 4096; + s->xvel = 0; + t[0] = 2; + } + } + + if (t[0] == 3) + { + s->picnum = GREENSLIME + 1; + + makeitfall(i); + + if (s->z > hittype[i].floorz - (8 << 8)) + { + s->yrepeat -= 4; + s->xrepeat += 2; + } + else + { + if (s->yrepeat < (40 - 4)) s->yrepeat += 8; + if (s->xrepeat > 8) s->xrepeat -= 4; + } + + if (s->z > hittype[i].floorz - 2048) + { + s->z = hittype[i].floorz - 2048; + t[0] = 0; + s->xvel = 0; + } + } +} + +void flamethrowerflame(int i) +{ + spritetype* s = &sprite[i]; + auto t = &hittype[i].temp_data[0]; + int sect = s->sectnum; + int x, j; + int p = findplayer(s, &x); + execute(i, p, x); + t[0]++; + if (sector[sect].lotag == 2) + { + sprite[spawn(i, EXPLOSION2)].shade = 127; + deletesprite(i); + return; + } + + int dax = s->x; + int day = s->y; + int daz = s->z; + + getglobalz(i); + + int ds = t[0] / 6; + if (s->xrepeat < 80) + s->yrepeat = s->xrepeat += ds; + s->clipdist += ds; + if (t[0] <= 2) + t[3] = krand() % 10; + if (t[0] > 30) + { + sprite[spawn(i, EXPLOSION2)].shade = 127; + deletesprite(i); + return; + } + + j = movesprite(i, (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, + (s->xvel * (sintable[s->ang & 2047])) >> 14, s->zvel, CLIPMASK1); + + if (s->sectnum < 0) + { + deletesprite(i); + return; + } + + if ((j & kHitTypeMask) != kHitSprite) + { + if (s->z < hittype[i].ceilingz) + { + j = kHitSector | (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 = kHitSector | (s->sectnum); + if (sector[s->sectnum].lotag != 1) + s->zvel = 1; + } + } + + if (j != 0) { + s->xvel = s->yvel = 0; + if ((j & kHitTypeMask) == kHitSprite) + { + j &= (MAXSPRITES - 1); + checkhitsprite((short)j, i); + if (sprite[j].picnum == APLAYER) + spritesound(j, PISTOL_BODYHIT); + } + else if ((j & kHitTypeMask) == kHitWall) + { + j &= (MAXWALLS - 1); + setsprite(i, dax, day, daz); + checkhitwall(i, j, s->x, s->y, s->z, s->picnum); + } + else if ((j & kHitTypeMask) == kHitSector) + { + setsprite(i, dax, day, daz); + if (s->zvel < 0) + checkhitceiling(s->sectnum); + } + + 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); + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void moveactors_d(void) +{ + int x, m, l, * t; + short j, sect, p; + spritetype* s; + unsigned short k; + int nexti; + bool bBoom; + + + for (int i = headspritestat[1]; i >= 0; i = nexti) + { + nexti = nextspritestat[i]; + + s = &sprite[i]; + + sect = s->sectnum; + + if (s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS) + { + deletesprite(i); + continue; + } + + t = &hittype[i].temp_data[0]; + + hittype[i].bposx = s->x; + hittype[i].bposy = s->y; + hittype[i].bposz = s->z; + + + switch (s->picnum) + { + case FLAMETHROWERFLAME: + if (isWorldTour()) flamethrowerflame(i); + continue; + + case DUCK: + case TARGET: + if (s->cstat & 32) + { + t[0]++; + if (t[0] > 60) + { + t[0] = 0; + s->cstat = 128 + 257 + 16; + s->extra = 1; + } + } + else + { + j = ifhitbyweapon(i); + if (j >= 0) + { + s->cstat = 32 + 128; + k = 1; + + j = headspritestat[1]; + while (j >= 0) + { + if (sprite[j].lotag == s->lotag && + sprite[j].picnum == s->picnum) + { + if ((sprite[j].hitag && !(sprite[j].cstat & 32)) || + (!sprite[j].hitag && (sprite[j].cstat & 32)) + ) + { + k = 0; + break; + } + } + + j = nextspritestat[j]; + } + + if (k == 1) + { + operateactivators(s->lotag, -1); + operateforcefields(i, s->lotag); + operatemasterswitches(s->lotag); + } + } + } + continue; + + case RESPAWNMARKERRED: + case RESPAWNMARKERYELLOW: + case RESPAWNMARKERGREEN: + if (!respawnmarker(i, RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue; + break; + + case HELECOPT: + case DUKECAR: + + s->z += s->zvel; + t[0]++; + + if (t[0] == 4) spritesound(WAR_AMBIENCE2, i); + + if (t[0] > (26 * 8)) + { + sound(RPG_EXPLODE); + for (j = 0; j < 32; j++) + RANDOMSCRAP(s, i); + earthquaketime = 16; + deletesprite(i); + continue; + } + else if ((t[0] & 3) == 0) + spawn(i, EXPLOSION2); + ssp(i, CLIPMASK0); + break; + case RAT: + if (!rat(i, true)) continue; + break; + case QUEBALL: + case STRIPEBALL: + if (!queball(i, POCKET, QUEBALL, STRIPEBALL)) continue; + break; + case FORCESPHERE: + forcesphere(i, FORCESPHERE); + continue; + + case RECON: + recon(i, EXPLOSION2, FIRELASER, RECO_ATTACK, RECO_PAIN, RECO_ROAM, 10, [](int i)->int { return PIGCOP; }); + continue; + + case OOZ: + case OOZ2: + ooz(i); + continue; + + case GREENSLIME: + case GREENSLIME + 1: + case GREENSLIME + 2: + case GREENSLIME + 3: + case GREENSLIME + 4: + case GREENSLIME + 5: + case GREENSLIME + 6: + case GREENSLIME + 7: + greenslime(i); + continue; + + case BOUNCEMINE: + case MORTER: + j = spawn(i, FRAMEEFFECT1); + hittype[j].temp_data[0] = 3; + + case HEAVYHBOMB: + + if ((s->cstat & 32768)) + { + t[2]--; + if (t[2] <= 0) + { + spritesound(TELEPORTER, i); + spawn(i, TRANSPORTERSTAR); + s->cstat = 257; + } + continue; + } + + p = findplayer(s, &x); + + if (x < 1220) s->cstat &= ~257; + else s->cstat |= 257; + + if (t[3] == 0) + { + j = ifhitbyweapon(i); + if (j >= 0) + { + t[3] = 1; + t[4] = 0; + l = 0; + s->xvel = 0; + goto DETONATEB; + } + } + + if (s->picnum != BOUNCEMINE) + { + makeitfall(i); + + if (sector[sect].lotag != 1 && s->z >= hittype[i].floorz - (FOURSLEIGHT) && s->yvel < 3) + { + if (s->yvel > 0 || (s->yvel == 0 && hittype[i].floorz == sector[sect].floorz)) + spritesound(PIPEBOMB_BOUNCE, i); + s->zvel = -((4 - s->yvel) << 8); + if (sector[s->sectnum].lotag == 2) + s->zvel >>= 2; + s->yvel++; + } + if (s->z < hittype[i].ceilingz) // && sector[sect].lotag != 2 ) + { + s->z = hittype[i].ceilingz + (3 << 8); + s->zvel = 0; + } + } + + j = movesprite(i, + (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, + (s->xvel * (sintable[s->ang & 2047])) >> 14, + s->zvel, CLIPMASK0); + + if (sector[sprite[i].sectnum].lotag == 1 && s->zvel == 0) + { + s->z += (32 << 8); + if (t[5] == 0) + { + t[5] = 1; + spawn(i, WATERSPLASH2); + } + } + else t[5] = 0; + + if (t[3] == 0 && (s->picnum == BOUNCEMINE || s->picnum == MORTER) && (j || x < 844)) + { + t[3] = 1; + t[4] = 0; + l = 0; + s->xvel = 0; + goto DETONATEB; + } + + if (sprite[s->owner].picnum == APLAYER) + l = sprite[s->owner].yvel; + else l = -1; + + if (s->xvel > 0) + { + s->xvel -= 5; + if (sector[sect].lotag == 2) + s->xvel -= 10; + + if (s->xvel < 0) + s->xvel = 0; + if (s->xvel & 8) s->cstat ^= 4; + } + + if ((j & 49152) == 32768) + { + j &= (MAXWALLS - 1); + + checkhitwall(i, j, s->x, s->y, s->z, s->picnum); + + 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->xvel >>= 1; + } + + DETONATEB: + + bBoom = false; + if ((l >= 0 && ps[l].hbomb_on == 0) || t[3] == 1) + bBoom = true; + if (isNamWW2GI() && s->picnum == HEAVYHBOMB) + { + s->extra--; + if (s->extra <= 0) + bBoom = true; + } + if (bBoom) + { + t[4]++; + + if (t[4] == 2) + { + x = s->extra; + m = 0; + switch (s->picnum) + { + case HEAVYHBOMB: m = pipebombblastradius; break; + case MORTER: m = morterblastradius; break; + case BOUNCEMINE: m = bouncemineblastradius; break; + } + + hitradius(i, m, x >> 2, x >> 1, x - (x >> 2), x); + spawn(i, EXPLOSION2); + if (s->zvel == 0) + spawn(i, EXPLOSION2BOT); + spritesound(PIPEBOMB_EXPLODE, i); + for (x = 0; x < 8; x++) + RANDOMSCRAP(s, i); + } + + if (s->yrepeat) + { + s->yrepeat = 0; + continue; + } + + if (t[4] > 20) + { + if (s->owner != i || ud.respawn_items == 0) + { + deletesprite(i); + continue; + } + else + { + t[2] = respawnitemtime; + spawn(i, RESPAWNMARKERRED); + s->cstat = (short)32768; + s->yrepeat = 9; + continue; + } + } + } + else if (s->picnum == HEAVYHBOMB && x < 788 && t[0] > 7 && s->xvel == 0) + if (cansee(s->x, s->y, s->z - (8 << 8), s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum)) + if (ps[p].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) + { + if (ud.coop >= 1 && s->owner == i) + { + for (j = 0; j < ps[p].weapreccnt; j++) + if (ps[p].weaprecs[j] == s->picnum) + goto BOLT; + + if (ps[p].weapreccnt < 255) // DukeGDX has 16 here. + ps[p].weaprecs[ps[p].weapreccnt++] = s->picnum; + } + + addammo(HANDBOMB_WEAPON, &ps[p], 1); + spritesound(DUKE_GET, ps[p].i); + + if (ps[p].gotweapon[HANDBOMB_WEAPON] == 0 || s->owner == ps[p].i) + addweapon(&ps[p], HANDBOMB_WEAPON); + + if (sprite[s->owner].picnum != APLAYER) + { + SetPlayerPal(&ps[p], PalEntry(32, 0, 32, 0)); + } + + if (s->owner != i || ud.respawn_items == 0) + { + if (s->owner == i && ud.coop >= 1) + continue; + + deletesprite(i); + continue; + } + else + { + t[2] = respawnitemtime; + spawn(i, RESPAWNMARKERRED); + s->cstat = (short)32768; + } + } + + if (t[0] < 8) t[0]++; + continue; + + case REACTORBURNT: + case REACTOR2BURNT: + continue; + + case REACTOR: + case REACTOR2: + reactor(i, REACTOR, REACTOR2, REACTOR2BURNT, REACTOR2BURNT); + continue; + + case DUKE_CAMERA1: + camera(i); + continue; + } + + + // #ifndef VOLOMEONE + if (ud.multimode < 2 && badguy(s)) + { + if (actor_tog == 1) + { + s->cstat = (short)32768; + continue; + } + else if (actor_tog == 2) s->cstat = 257; + } + // #endif + + p = findplayer(s, &x); + + execute(i, p, x); + + BOLT:; + + } + +} + + END_DUKE_NS diff --git a/source/games/duke/src/actors_lava.cpp b/source/games/duke/src/actors_lava.cpp new file mode 100644 index 000000000..e18172b81 --- /dev/null +++ b/source/games/duke/src/actors_lava.cpp @@ -0,0 +1,663 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2017-2019 Nuke.YKT + +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 +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +aint with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms +*/ +//------------------------------------------------------------------------- +#include "ns.h" +#include "global.h" +#include "actors.h" +#include "names_rr.h" +#include "serializer.h" + +BEGIN_DUKE_NS + +static int torchcnt; +static int jaildoorcnt; +static int minecartcnt; +static int lightnincnt; + +static short torchsector[64]; +static short torchsectorshade[64]; +static short torchtype[64]; + +static short jaildoorsound[32]; +static int jaildoordrag[32]; +static int jaildoorspeed[32]; +static short jaildoorsecthtag[32]; +static int jaildoordist[32]; +static short jaildoordir[32]; +static short jaildooropen[32]; +static short jaildoorsect[32]; + +static short minecartdir[16]; +static int minecartspeed[16]; +static short minecartchildsect[16]; +static short minecartsound[16]; +static int minecartdist[16]; +static int minecartdrag[16]; +static short minecartopen[16]; +static short minecartsect[16]; + +static short lightninsector[64]; +static short lightninsectorshade[64]; + +static uint8_t brightness; + +static int thunderflash; +static int thundertime; +static int winderflash; +static int windertime; + + +void lava_cleararrays() +{ + jaildoorcnt = 0; + minecartcnt = 0; + torchcnt = 0; + lightnincnt = 0; +} + +void lava_serialize(FSerializer& arc) +{ + arc("torchcnt", torchcnt) + ("jaildoorcnt", jaildoorcnt) + ("minecartcnt", minecartcnt) + ("lightnincnt", lightnincnt); + + if (torchcnt) + arc.Array("torchsector", torchsector, torchcnt) + .Array("torchsectorshade", torchsectorshade, torchcnt) + .Array("torchtype", torchtype, torchcnt); + + if (jaildoorcnt) + arc.Array("jaildoorsound", jaildoorsound, jaildoorcnt) + .Array("jaildoordrag", jaildoordrag, jaildoorcnt) + .Array("jaildoorspeed", jaildoorspeed, jaildoorcnt) + .Array("jaildoorsecthtag", jaildoorsecthtag, jaildoorcnt) + .Array("jaildoordist", jaildoordist, jaildoorcnt) + .Array("jaildoordir", jaildoordir, jaildoorcnt) + .Array("jaildooropen", jaildooropen, jaildoorcnt) + .Array("jaildoorsect", jaildoorsect, jaildoorcnt); + + if (minecartcnt) + arc.Array("minecartdir", minecartdir, minecartcnt) + .Array("minecartspeed", minecartspeed, minecartcnt) + .Array("minecartchildsect", minecartchildsect, minecartcnt) + .Array("minecartsound", minecartsound, minecartcnt) + .Array("minecartdist", minecartdist, minecartcnt) + .Array("minecartdrag", minecartdrag, minecartcnt) + .Array("minecartopen", minecartopen, minecartcnt) + .Array("minecartsect", minecartsect, minecartcnt); + + if (lightnincnt) + arc.Array("lightninsector", lightninsector, lightnincnt) + .Array("lightninsectorshade", lightninsectorshade, lightnincnt); + + arc("brightness", brightness) + ("thunderflash", thunderflash) + ("thundertime", thundertime) + ("winderflash", winderflash) + ("windertime", windertime); +} + +void addtorch(int i) +{ + if (torchcnt >= 64) + I_Error("Too many torch effects"); + + torchsector[torchcnt] = sprite[i].sectnum; + torchsectorshade[torchcnt] = sector[sprite[i].sectnum].floorshade; + torchtype[torchcnt] = sprite[i].lotag; + torchcnt++; +} + +void addlightning(int i) +{ + if (lightnincnt >= 64) + I_Error("Too many lightnin effects"); + + lightninsector[lightnincnt] = sprite[i].sectnum; + lightninsectorshade[lightnincnt] = sector[sprite[i].sectnum].floorshade; + lightnincnt++; +} + +void addjaildoor(int p1, int p2, int iht, int jlt, int p3, int j) +{ + if (jaildoorcnt >= 32) + I_Error("Too many jaildoor sectors"); + + jaildoordist[jaildoorcnt] = p1; + jaildoorspeed[jaildoorcnt] = p2; + jaildoorsecthtag[jaildoorcnt] = iht; + jaildoorsect[jaildoorcnt] = j; + jaildoordrag[jaildoorcnt] = 0; + jaildooropen[jaildoorcnt] = 0; + jaildoordir[jaildoorcnt] = jlt; + jaildoorsound[jaildoorcnt] = p3; + jaildoorcnt++; +} + +void addminecart(int p1, int p2, int i, int iht, int p3, int childsectnum) +{ + if (minecartcnt >= 16) + G_GameExit("\nToo many minecart sectors"); + minecartdist[minecartcnt] = p1; + minecartspeed[minecartcnt] = p2; + minecartsect[minecartcnt] = i; + minecartdir[minecartcnt] = sector[i].hitag; + minecartdrag[minecartcnt] = p1; + minecartopen[minecartcnt] = 1; + minecartsound[minecartcnt] = p3; + minecartchildsect[minecartcnt] = childsectnum; + minecartcnt++; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void dotorch(void) +{ + int ds; + short j; + short startwall, endwall; + char shade; + ds = krand()&8; + for (int i = 0; i < torchcnt; i++) + { + shade = torchsectorshade[i] - ds; + switch (torchtype[i]) + { + case 0: + sector[torchsector[i]].floorshade = shade; + sector[torchsector[i]].ceilingshade = shade; + break; + case 1: + sector[torchsector[i]].ceilingshade = shade; + break; + case 2: + sector[torchsector[i]].floorshade = shade; + break; + case 4: + sector[torchsector[i]].ceilingshade = shade; + break; + case 5: + sector[torchsector[i]].floorshade = shade; + break; + } + startwall = sector[torchsector[i]].wallptr; + endwall = startwall + sector[torchsector[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + if (wall[j].lotag != 1) + { + switch (torchtype[i]) + { + case 0: + wall[j].shade = shade; + break; + case 1: + wall[j].shade = shade; + break; + case 2: + wall[j].shade = shade; + break; + case 3: + wall[j].shade = shade; + break; + } + } + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void dojaildoor(void) +{ + int j; + int startwall, endwall; + int x, y; + int speed; + for (int i = 0; i < jaildoorcnt; i++) + { + if (numplayers > 2) + speed = jaildoorspeed[i]; + else + speed = jaildoorspeed[i]; + if (speed < 2) + speed = 2; + if (jaildooropen[i] == 1) + { + jaildoordrag[i] -= speed; + if (jaildoordrag[i] <= 0) + { + jaildoordrag[i] = 0; + jaildooropen[i] = 2; + switch (jaildoordir[i]) + { + case 10: + jaildoordir[i] = 30; + break; + case 20: + jaildoordir[i] = 40; + break; + case 30: + jaildoordir[i] = 10; + break; + case 40: + jaildoordir[i] = 20; + break; + } + } + else + { + startwall = sector[jaildoorsect[i]].wallptr; + endwall = startwall + sector[jaildoorsect[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + switch (jaildoordir[i]) + { + case 10: + x = wall[j].x; + y = wall[j].y + speed; + break; + case 20: + x = wall[j].x - speed; + y = wall[j].y; + break; + case 30: + x = wall[j].x; + y = wall[j].y - speed; + break; + case 40: + x = wall[j].x + speed; + y = wall[j].y; + break; + } + dragpoint(j,x,y); + } + } + } + if (jaildooropen[i] == 3) + { + jaildoordrag[i] -= speed; + if (jaildoordrag[i] <= 0) + { + jaildoordrag[i] = 0; + jaildooropen[i] = 0; + switch (jaildoordir[i]) + { + case 10: + jaildoordir[i] = 30; + break; + case 20: + jaildoordir[i] = 40; + break; + case 30: + jaildoordir[i] = 10; + break; + case 40: + jaildoordir[i] = 20; + break; + } + } + else + { + startwall = sector[jaildoorsect[i]].wallptr; + endwall = startwall + sector[jaildoorsect[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + switch (jaildoordir[i]) + { + case 10: + x = wall[j].x; + y = wall[j].y + speed; + break; + case 20: + x = wall[j].x - speed; + y = wall[j].y; + break; + case 30: + x = wall[j].x; + y = wall[j].y - speed; + break; + case 40: + x = wall[j].x + speed; + y = wall[j].y; + break; + } + dragpoint(j,x,y); + } + } + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void moveminecart(void) +{ + short i; + short j; + short csect; + short startwall; + short endwall; + int speed; + int y; + int x; + short nextj; + int cx; + int cy; + int max_x; + int min_y; + int max_y; + int min_x; + for (i = 0; i < minecartcnt; i++) + { + speed = minecartspeed[i]; + if (speed < 2) + speed = 2; + + if (minecartopen[i] == 1) + { + minecartdrag[i] -= speed; + if (minecartdrag[i] <= 0) + { + minecartdrag[i] = minecartdist[i]; + minecartopen[i] = 2; + switch (minecartdir[i]) + { + case 10: + minecartdir[i] = 30; + break; + case 20: + minecartdir[i] = 40; + break; + case 30: + minecartdir[i] = 10; + break; + case 40: + minecartdir[i] = 20; + break; + } + } + else + { + startwall = sector[minecartsect[i]].wallptr; + endwall = startwall + sector[minecartsect[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + switch (minecartdir[i]) + { + case 10: + x = wall[j].x; + y = wall[j].y + speed; + break; + case 20: + x = wall[j].x - speed; + y = wall[j].y; + break; + case 30: + x = wall[j].x; + y = wall[j].y - speed; + break; + case 40: + x = wall[j].x + speed; + y = wall[j].y; + break; + } + dragpoint(j,x,y); + } + } + } + if (minecartopen[i] == 2) + { + minecartdrag[i] -= speed; + if (minecartdrag[i] <= 0) + { + minecartdrag[i] = minecartdist[i]; + minecartopen[i] = 1; + switch (minecartdir[i]) + { + case 10: + minecartdir[i] = 30; + break; + case 20: + minecartdir[i] = 40; + break; + case 30: + minecartdir[i] = 10; + break; + case 40: + minecartdir[i] = 20; + break; + } + } + else + { + startwall = sector[minecartsect[i]].wallptr; + endwall = startwall + sector[minecartsect[i]].wallnum; + for (j = startwall; j < endwall; j++) + { + switch (minecartdir[i]) + { + case 10: + x = wall[j].x; + y = wall[j].y + speed; + break; + case 20: + x = wall[j].x - speed; + y = wall[j].y; + break; + case 30: + x = wall[j].x; + y = wall[j].y - speed; + break; + case 40: + x = wall[j].x + speed; + y = wall[j].y; + break; + } + dragpoint(j,x,y); + } + } + } + csect = minecartchildsect[i]; + startwall = sector[csect].wallptr; + endwall = startwall + sector[csect].wallnum; + max_x = max_y = -0x20000; + min_x = min_y = 0x20000; + for (j = startwall; j < endwall; j++) + { + x = wall[j].x; + y = wall[j].y; + if (x > max_x) + max_x = x; + if (y > max_y) + max_y = y; + if (x < min_x) + min_x = x; + if (y < min_y) + min_y = y; + } + cx = (max_x + min_x) >> 1; + cy = (max_y + min_y) >> 1; + j = headspritesect[csect]; + while (j != -1) + { + nextj = nextspritesect[j]; + if (badguy(&sprite[j])) + setsprite(j,cx,cy,sprite[j].z); + j = nextj; + } + } +} + +void operatejaildoors(int hitag) +{ + for (int i = 0; i < jaildoorcnt; i++) + { + if (jaildoorsecthtag[i] == hitag) + { + if (jaildooropen[i] == 0) + { + jaildooropen[i] = 1; + jaildoordrag[i] = jaildoordist[i]; + if (!isRRRA() || jaildoorsound[i] != 0) + spritesound(jaildoorsound[i], ps[screenpeek].i); + } + if (jaildooropen[i] == 2) + { + jaildooropen[i] = 3; + jaildoordrag[i] = jaildoordist[i]; + if (!isRRRA() || jaildoorsound[i] != 0) + spritesound(jaildoorsound[i], ps[screenpeek].i); + } + } + } +} + +void thunder(void) +{ + struct player_struct* p; + int r1, r2; + short startwall, endwall, i, j; + unsigned char shade; + + p = &ps[screenpeek]; + + if (!thunderflash) + { + if ((gotpic[RRTILE2577 >> 3] & (1 << (RRTILE2577 & 7))) > 0) + { + gotpic[RRTILE2577 >> 3] &= ~(1 << (RRTILE2577 & 7)); + g_visibility = 256; // this is an engine variable + if (krand() > 65000) + { + thunderflash = 1; + thundertime = 256; + sound(351 + (rand() % 3)); + } + } + else + { + g_visibility = p->visibility; + brightness = ud.brightness >> 2; + } + } + else + { + thundertime -= 4; + if (thundertime < 0) + { + thunderflash = 0; + brightness = ud.brightness >> 2; + videoSetBrightness(brightness); + g_visibility = p->visibility; + } + } + if (!winderflash) + { + if ((gotpic[RRTILE2562 >> 3] & (1 << (RRTILE2562 & 7))) > 0) + { + gotpic[RRTILE2562 >> 3] &= ~(1 << (RRTILE2562 & 7)); + if (krand() > 65000) + { + winderflash = 1; + windertime = 128; + sound(351 + (rand() % 3)); + } + } + } + else + { + windertime -= 4; + if (windertime < 0) + { + winderflash = 0; + for (i = 0; i < lightnincnt; i++) + { + startwall = sector[lightninsector[i]].wallptr; + endwall = startwall + sector[lightninsector[i]].wallnum; + sector[lightninsector[i]].floorshade = lightninsectorshade[i]; + sector[lightninsector[i]].ceilingshade = lightninsectorshade[i]; + for (j = startwall; j < endwall; j++) + wall[j].shade = lightninsectorshade[i]; + } + } + } + if (thunderflash == 1) + { + r1 = krand() & 4; + brightness += r1; + switch (r1) + { + case 0: + g_visibility = 2048; + break; + case 1: + g_visibility = 1024; + break; + case 2: + g_visibility = 512; + break; + case 3: + g_visibility = 256; + break; + default: + g_visibility = 4096; + break; + } + if (brightness > 8) + brightness = 0; + videoSetBrightness(brightness); + } + if (winderflash == 1) + { + r2 = krand() & 8; + shade = torchsectorshade[i] + r2; + for (i = 0; i < lightnincnt; i++) + { + startwall = sector[lightninsector[i]].wallptr; + endwall = startwall + sector[lightninsector[i]].wallnum; + sector[lightninsector[i]].floorshade = lightninsectorshade[i] - shade; + sector[lightninsector[i]].ceilingshade = lightninsectorshade[i] - shade; + for (j = startwall; j < endwall; j++) + wall[j].shade = lightninsectorshade[i] - shade; + } + } +} + +END_DUKE_NS diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index aff5b3f12..42f0c16ea 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -29,9 +29,21 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "global.h" #include "actors.h" #include "names_rr.h" +#include "mmulti.h" BEGIN_DUKE_NS +void dojaildoor(); +void moveminecart(); + +void ballreturn(short spr); +short pinsectorresetdown(short sect); +short pinsectorresetup(short sect); +short checkpins(short sect); +void resetpins(short sect); +void resetlanepics(void); + + struct FireProj { int x, y, z; @@ -257,7 +269,7 @@ SKIPWALLCHECK: 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; + continue; checkhitsprite(j, i); } } @@ -339,7 +351,6 @@ SKIPWALLCHECK: } } } - BOLT: j = nextj; } } @@ -1368,7 +1379,7 @@ void moveweapons_r(void) guts_r(s, RABBITJIBB, 2, myconnectindex); guts_r(s, RABBITJIBC, 2, myconnectindex); } - ps[p].q16horiz += 32 << FRACBITS; + ps[p].addhoriz(32); ps[p].return_to_center = 8; if (ps[p].loogcnt == 0) @@ -1701,7 +1712,7 @@ void movetransports_r(void) sprite[ps[k].i].extra = 0; } - ps[p].q16ang = sprite[OW].ang << FRACBITS; + ps[p].setang(sprite[OW].ang); if (sprite[OW].owner != OW) { @@ -1878,7 +1889,7 @@ void movetransports_r(void) if (sprite[OW].owner != OW && onfloorz && hittype[i].temp_data[0] > 0 && sprite[j].statnum != 5) { hittype[i].temp_data[0]++; - goto BOLT; + continue; } warpspriteto = 1; } @@ -2030,10 +2041,1180 @@ void movetransports_r(void) JBOLT: j = nextj; } - BOLT: i = nexti; } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void rrra_specialstats() +{ + int i, j, nexti; + + i = headspritestat[117]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].hitag > 2) + sprite[i].hitag = 0; + if ((sprite[i].picnum == RRTILE8488 || sprite[i].picnum == RRTILE8490) && sprite[i].hitag != 2) + { + sprite[i].hitag = 2; + sprite[i].extra = -100; + } + if (sprite[i].hitag == 0) + { + sprite[i].extra++; + if (sprite[i].extra >= 30) + sprite[i].hitag = 1; + } + else if (sprite[i].hitag == 1) + { + sprite[i].extra--; + if (sprite[i].extra <= -30) + sprite[i].hitag = 0; + } + else if (sprite[i].hitag == 2) + { + sprite[i].extra--; + if (sprite[i].extra <= -104) + { + spawn(i, sprite[i].lotag); + deletesprite(i); + } + } + j = movesprite(i, 0, 0, sprite[i].extra * 2, CLIPMASK0); + i = nexti; + } + + i = headspritestat[118]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].hitag > 1) + sprite[i].hitag = 0; + if (sprite[i].hitag == 0) + { + sprite[i].extra++; + if (sprite[i].extra >= 20) + sprite[i].hitag = 1; + } + else if (sprite[i].hitag == 1) + { + sprite[i].extra--; + if (sprite[i].extra <= -20) + sprite[i].hitag = 0; + } + j = movesprite(i, 0, 0, sprite[i].extra, CLIPMASK0); + i = nexti; + } + + if (ps[screenpeek].raat609 > 0) + { + ps[screenpeek].raat609--; + if (ps[screenpeek].raat609 == 0) + { + ps[screenpeek].gm = MODE_EOL; + ud.eog = 1; + ud.level_number++; + if (ud.level_number > 6) + ud.level_number = 0; + ud.m_level_number = ud.level_number; + } + } + + if (enemysizecheat > 0) + { + short ti; + for (ti = 0; ti < MAXSPRITES; ti++) + { + switch (sprite[ti].picnum) + { + //case 4049: + //case 4050: + case BILLYCOCK: + case BILLYRAY: + case BILLYRAYSTAYPUT: + case BRAYSNIPER: + case DOGRUN: + case LTH: + case HULKJUMP: + case HULK: + case HULKSTAYPUT: + case HEN: + case DRONE: + case PIG: + case MINION: + case MINIONSTAYPUT: + case UFO1_RRRA: + case UFO2: + case UFO3: + case UFO4: + case UFO5: + case COOT: + case COOTSTAYPUT: + case VIXEN: + case BIKERB: + case BIKERBV2: + case BIKER: + case MAKEOUT: + case CHEERB: + case CHEER: + case CHEERSTAYPUT: + case COOTPLAY: + case BILLYPLAY: + case MINIONBOAT: + case HULKBOAT: + case CHEERBOAT: + case RABBIT: + case MAMA: + if (enemysizecheat == 3) + { + sprite[ti].xrepeat = sprite[ti].xrepeat << 1; + sprite[ti].yrepeat = sprite[ti].yrepeat << 1; + sprite[ti].clipdist = mulscale7(sprite[ti].xrepeat, tilesiz[sprite[ti].picnum].x); + } + else if (enemysizecheat == 2) + { + sprite[ti].xrepeat = sprite[ti].xrepeat >> 1; + sprite[ti].yrepeat = sprite[ti].yrepeat >> 1; + sprite[ti].clipdist = mulscale7(sprite[ti].xrepeat, tilesiz[sprite[ti].picnum].y); + } + break; + } + } + enemysizecheat = 0; + } + + i = headspritestat[121]; + while (i >= 0) + { + nexti = nextspritestat[i]; + sprite[i].extra++; + if (sprite[i].extra < 100) + { + if (sprite[i].extra == 90) + { + sprite[i].picnum--; + if (sprite[i].picnum < PIG + 7) + sprite[i].picnum = PIG + 7; + sprite[i].extra = 1; + } + movesprite(i, 0, 0, -300, CLIPMASK0); + if (sector[sprite[i].sectnum].ceilingz + (4 << 8) > sprite[i].z) + { + sprite[i].picnum = 0; + sprite[i].extra = 100; + } + } + else if (sprite[i].extra == 200) + { + setsprite(i, sprite[i].x, sprite[i].y, sector[sprite[i].sectnum].floorz - 10); + sprite[i].extra = 1; + sprite[i].picnum = PIG + 11; + spawn(i, TRANSPORTERSTAR); + } + i = nexti; + } + + i = headspritestat[119]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].hitag > 0) + { + if (sprite[i].extra == 0) + { + sprite[i].hitag--; + sprite[i].extra = 150; + spawn(i, RABBIT); + } + else + sprite[i].extra--; + } + i = nexti; + } + i = headspritestat[116]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].extra) + { + if (sprite[i].extra == sprite[i].lotag) + sound(183); + sprite[i].extra--; + j = movesprite(i, + (sprite[i].hitag * sintable[(sprite[i].ang + 512) & 2047]) >> 14, + (sprite[i].hitag * sintable[sprite[i].ang & 2047]) >> 14, + sprite[i].hitag << 1, CLIPMASK0); + if (j > 0) + { + spritesound(PIPEBOMB_EXPLODE, i); + deletesprite(i); + } + if (sprite[i].extra == 0) + { + sound(215); + deletesprite(i); + earthquaketime = 32; + SetPlayerPal(&ps[myconnectindex], PalEntry(32, 32, 32, 48)); + } + } + i = nexti; + } + + i = headspritestat[115]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].extra) + { + if (sprite[i].picnum != RRTILE8162) + sprite[i].picnum = RRTILE8162; + sprite[i].extra--; + if (sprite[i].extra == 0) + { + int rvar; + rvar = krand() & 127; + if (rvar < 96) + { + sprite[i].picnum = RRTILE8162 + 3; + } + else if (rvar < 112) + { + if (ps[screenpeek].SlotWin & 1) + { + sprite[i].picnum = RRTILE8162 + 3; + } + else + { + sprite[i].picnum = RRTILE8162 + 2; + spawn(i, BATTERYAMMO); + ps[screenpeek].SlotWin |= 1; + spritesound(52, i); + } + } + else if (rvar < 120) + { + if (ps[screenpeek].SlotWin & 2) + { + sprite[i].picnum = RRTILE8162 + 3; + } + else + { + sprite[i].picnum = RRTILE8162 + 6; + spawn(i, HEAVYHBOMB); + ps[screenpeek].SlotWin |= 2; + spritesound(52, i); + } + } + else if (rvar < 126) + { + if (ps[screenpeek].SlotWin & 4) + { + sprite[i].picnum = RRTILE8162 + 3; + } + else + { + sprite[i].picnum = RRTILE8162 + 5; + spawn(i, SIXPAK); + ps[screenpeek].SlotWin |= 4; + spritesound(52, i); + } + } + else + { + if (ps[screenpeek].SlotWin & 8) + { + sprite[i].picnum = RRTILE8162 + 3; + } + else + { + sprite[i].picnum = RRTILE8162 + 4; + spawn(i, ATOMICHEALTH); + ps[screenpeek].SlotWin |= 8; + spritesound(52, i); + } + } + } + } + i = nexti; + } + + i = headspritestat[122]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].extra) + { + if (sprite[i].picnum != RRTILE8589) + sprite[i].picnum = RRTILE8589; + sprite[i].extra--; + if (sprite[i].extra == 0) + { + int rvar; + rvar = krand() & 127; + if (rvar < 96) + { + sprite[i].picnum = RRTILE8589 + 4; + } + else if (rvar < 112) + { + if (ps[screenpeek].SlotWin & 1) + { + sprite[i].picnum = RRTILE8589 + 4; + } + else + { + sprite[i].picnum = RRTILE8589 + 5; + spawn(i, BATTERYAMMO); + ps[screenpeek].SlotWin |= 1; + spritesound(342, i); + } + } + else if (rvar < 120) + { + if (ps[screenpeek].SlotWin & 2) + { + sprite[i].picnum = RRTILE8589 + 4; + } + else + { + sprite[i].picnum = RRTILE8589 + 6; + spawn(i, HEAVYHBOMB); + ps[screenpeek].SlotWin |= 2; + spritesound(342, i); + } + } + else if (rvar < 126) + { + if (ps[screenpeek].SlotWin & 4) + { + sprite[i].picnum = RRTILE8589 + 4; + } + else + { + sprite[i].picnum = RRTILE8589 + 2; + spawn(i, SIXPAK); + ps[screenpeek].SlotWin |= 4; + spritesound(342, i); + } + } + else + { + if (ps[screenpeek].SlotWin & 8) + { + sprite[i].picnum = RRTILE8589 + 4; + } + else + { + sprite[i].picnum = RRTILE8589 + 3; + spawn(i, ATOMICHEALTH); + ps[screenpeek].SlotWin |= 8; + spritesound(342, i); + } + } + } + } + i = nexti; + } + + i = headspritestat[123]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].lotag == 5) + if (!S_CheckSoundPlaying(330)) + spritesound(330, i); + i = nexti; + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void rr_specialstats() +{ + int x; + int i, j, nexti, nextj, p, pi; + spritetype* s; + unsigned short pst; + + i = headspritestat[107]; + while (i >= 0) + { + nexti = nextspritestat[i]; + + if (sprite[i].hitag == 100) + { + sprite[i].z += (4 << 8); + if (sprite[i].z >= sector[sprite[i].sectnum].floorz + 15168) + sprite[i].z = sector[sprite[i].sectnum].floorz + 15168; + } + + if (sprite[i].picnum == LUMBERBLADE) + { + sprite[i].extra++; + if (sprite[i].extra == 192) + { + sprite[i].hitag = 0; + sprite[i].z = sector[sprite[i].sectnum].floorz - 15168; + sprite[i].extra = 0; + sprite[i].picnum = RRTILE3410; + j = headspritestat[0]; + while (j >= 0) + { + nextj = nextspritestat[j]; + if (sprite[j].picnum == 128) + if (sprite[j].hitag == 999) + sprite[j].picnum = 127; + j = nextj; + } + } + } + i = nexti; + } + + if (chickenplant) + { + i = headspritestat[106]; + while (i >= 0) + { + nexti = nextspritestat[i]; + switch (sprite[i].picnum) + { + case RRTILE285: + sprite[i].lotag--; + if (sprite[i].lotag < 0) + { + j = spawn(i, RRTILE3190); + sprite[j].ang = sprite[i].ang; + sprite[i].lotag = 128; + } + break; + case RRTILE286: + sprite[i].lotag--; + if (sprite[i].lotag < 0) + { + j = spawn(i, RRTILE3192); + sprite[j].ang = sprite[i].ang; + sprite[i].lotag = 256; + } + break; + case RRTILE287: + sprite[i].lotag--; + if (sprite[i].lotag < 0) + { + lotsoffeathers_r(&sprite[i], (krand() & 3) + 4); + sprite[i].lotag = 84; + } + break; + case RRTILE288: + sprite[i].lotag--; + if (sprite[i].lotag < 0) + { + j = spawn(i, RRTILE3132); + sprite[i].lotag = 96; + if (!isRRRA()) spritesound(472, j); + } + break; + case RRTILE289: + sprite[i].lotag--; + if (sprite[i].lotag < 0) + { + j = spawn(i, RRTILE3120); + sprite[j].ang = sprite[i].ang; + sprite[i].lotag = 448; + } + break; + case RRTILE290: + sprite[i].lotag--; + if (sprite[i].lotag < 0) + { + j = spawn(i, RRTILE3122); + sprite[j].ang = sprite[i].ang; + sprite[i].lotag = 64; + } + break; + case RRTILE291: + sprite[i].lotag--; + if (sprite[i].lotag < 0) + { + j = spawn(i, RRTILE3123); + sprite[j].ang = sprite[i].ang; + sprite[i].lotag = 512; + } + break; + case RRTILE292: + sprite[i].lotag--; + if (sprite[i].lotag < 0) + { + j = spawn(i, RRTILE3124); + sprite[j].ang = sprite[i].ang; + sprite[i].lotag = 224; + } + break; + case RRTILE293: + sprite[i].lotag--; + if (sprite[i].lotag < 0) + { + guts_r(&sprite[i], JIBS1, 1, myconnectindex); + guts_r(&sprite[i], JIBS2, 1, myconnectindex); + guts_r(&sprite[i], JIBS3, 1, myconnectindex); + guts_r(&sprite[i], JIBS4, 1, myconnectindex); + sprite[i].lotag = 256; + } + break; + } + i = nexti; + } + } + + i = headspritestat[105]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].picnum == RRTILE280) + if (sprite[i].lotag == 100) + { + pst = pinsectorresetup(sprite[i].sectnum); + if (pst) + { + sprite[i].lotag = 0; + if (sprite[i].extra == 1) + { + pst = checkpins(sprite[i].sectnum); + if (!pst) + { + sprite[i].extra = 2; + } + } + if (sprite[i].extra == 2) + { + sprite[i].extra = 0; + resetpins(sprite[i].sectnum); + } + } + } + i = nexti; + } + + i = headspritestat[108]; + while (i >= 0) + { + nexti = nextspritestat[i]; + + s = &sprite[i]; + if (s->picnum == RRTILE296) + { + p = findplayer(s, &x); + if (x < 2047) + { + j = headspritestat[108]; + while (j >= 0) + { + nextj = nextspritestat[j]; + if (sprite[j].picnum == RRTILE297) + { + ps[p].setang(sprite[j].ang); + ps[p].bobposx = ps[p].oposx = ps[p].posx = sprite[j].x; + ps[p].bobposy = ps[p].oposy = ps[p].posy = sprite[j].y; + ps[p].oposz = ps[p].posz = sprite[j].z - (36 << 8); + pi = ps[p].i; + changespritesect(pi, sprite[j].sectnum); + ps[p].cursectnum = sprite[pi].sectnum; + spritesound(70, j); + deletesprite(j); + } + j = nextj; + } + } + } + i = nexti; + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void moveactors_r(void) +{ + int x, m, l, nexti; + short j, ns, sect, p; + spritetype *s; + unsigned short k; + + dojaildoor(); + moveminecart(); + + if (isRRRA()) + { + rrra_specialstats(); + } + rr_specialstats(); + + for (int i = headspritestat[1]; i >= 0; i = nexti) + { + nexti = nextspritestat[i]; + + s = &sprite[i]; + + sect = s->sectnum; + + if( s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS) + { + deletesprite(i); + continue; + } + + auto t = &hittype[i].temp_data[0]; + + hittype[i].bposx = s->x; + hittype[i].bposy = s->y; + hittype[i].bposz = s->z; + + + switch(s->picnum) + { + case RESPAWNMARKERRED: + case RESPAWNMARKERYELLOW: + case RESPAWNMARKERGREEN: + if (!respawnmarker(i, RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue; + break; + case RAT: + if (!rat(i, !isRRRA())) continue; + break; + case RRTILE3190: + case RRTILE3191: + case RRTILE3192: + if (!chickenplant) + { + deletesprite(i); + continue; + } + if (sector[sprite[i].sectnum].lotag == 903) + makeitfall(i); + j = movesprite(i, + (s->xvel*sintable[(s->ang+512)&2047])>>14, + (s->xvel*sintable[s->ang&2047])>>14, + s->zvel,CLIPMASK0); + switch (sector[sprite[i].sectnum].lotag) + { + case 901: + sprite[i].picnum = RRTILE3191; + break; + case 902: + sprite[i].picnum = RRTILE3192; + break; + case 903: + if (sprite[i].z >= sector[sprite[i].sectnum].floorz - (8<<8)) + { + deletesprite(i); + continue; + } + break; + case 904: + deletesprite(i); + continue; + break; + } + if ((j & 32768) == 32768) + { + deletesprite(i); + continue; + } + break; + + case RRTILE3120: + case RRTILE3122: + case RRTILE3123: + case RRTILE3124: + if (!chickenplant) + { + deletesprite(i); + continue; + } + makeitfall(i); + j = movesprite(i, + (s->xvel*(sintable[(s->ang+512)&2047]))>>14, + (s->xvel*(sintable[s->ang&2047]))>>14, + s->zvel,CLIPMASK0); + if ((j & 32768) == 32768) + { + deletesprite(i); + continue; + } + if (sector[s->sectnum].lotag == 903) + { + if (sprite[i].z >= sector[sprite[i].sectnum].floorz - (4<<8)) + { + deletesprite(i); + continue; + } + } + else if (sector[s->sectnum].lotag == 904) + { + deletesprite(i); + continue; + } + break; + + case RRTILE3132: + if (!chickenplant) + { + deletesprite(i); + continue; + } + makeitfall(i); + j = movesprite(i, + (s->xvel*sintable[(s->ang+512)&2047])>>14, + (s->xvel*sintable[s->ang&2047])>>14, + s->zvel,CLIPMASK0); + if (s->z >= sector[s->sectnum].floorz - (8<<8)) + { + if (sector[s->sectnum].lotag == 1) + { + j = spawn(i,WATERSPLASH2); + sprite[j].z = sector[sprite[j].sectnum].floorz; + } + deletesprite(i); + continue; + } + break; + case BOWLINGBALL: + if (s->xvel) + { + if(!S_CheckSoundPlaying(356)) + spritesound(356,i); + } + else + { + spawn(i,BOWLINGBALLSPRITE); + deletesprite(i); + continue; + } + if (sector[s->sectnum].lotag == 900) + { + S_StopEnvSound(356, -1); + } + case RRTILE3440: + case RRTILE3440+1: + case HENSTAND: + case HENSTAND+1: + if (s->picnum == HENSTAND || s->picnum == HENSTAND+1) + { + s->lotag--; + if (s->lotag == 0) + { + spawn(i,HEN); + deletesprite(i); + continue; + } + } + if (sector[s->sectnum].lotag == 900) + s->xvel = 0; + if (s->xvel) + { + makeitfall(i); + j = movesprite(i, + (sintable[(s->ang+512)&2047]*s->xvel)>>14, + (sintable[s->ang&2047]*s->xvel)>>14, + s->zvel,CLIPMASK0); + if (j & 49152) + { + if ((j & 49152) == 32768) + { + j &= (MAXWALLS-1); + 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; + } + else if ((j & 49152) == 49152) + { + j &= (MAXSPRITES-1); + checkhitsprite(i,j); + if (sprite[j].picnum == HEN) + { + ns = spawn(j,HENSTAND); + deletesprite(j); + sprite[ns].xvel = 32; + sprite[ns].lotag = 40; + sprite[ns].ang = s->ang; + } + } + } + s->xvel --; + if(s->xvel < 0) s->xvel = 0; + s->cstat = 257; + if( s->picnum == RRTILE3440 ) + { + s->cstat |= 4&s->xvel; + s->cstat |= 8&s->xvel; + if (krand() & 1) + s->picnum = RRTILE3440+1; + } + else if (s->picnum == HENSTAND) + { + s->cstat |= 4&s->xvel; + s->cstat |= 8&s->xvel; + if (krand() & 1) + s->picnum = HENSTAND+1; + if (!s->xvel) + deletesprite(i); + } + if (s->picnum == RRTILE3440 || (s->picnum == RRTILE3440 + 1 && !s->xvel)) + { + deletesprite(i); + continue; + } + } + else if (sector[s->sectnum].lotag == 900) + { + if (s->picnum == BOWLINGBALL) + ballreturn(i); + deletesprite(i); + continue; + } + break; + + case QUEBALL: + case STRIPEBALL: + if (!queball(i, POCKET, QUEBALL, STRIPEBALL)) continue; + break; + case FORCESPHERE: + forcesphere(i, FORCESPHERE); + continue; + + case RECON: + case UFO1_RR: + case UFO2: + case UFO3: + case UFO4: + case UFO5: + recon(i, EXPLOSION2, FIRELASER, -1, -1, 457, 8, [](int i) ->int + { + auto s = &sprite[i]; + if (isRRRA() && ufospawnsminion) + return MINION; + else if (s->picnum == UFO1_RR) + return HEN; + else if (s->picnum == UFO2) + return COOT; + else if (s->picnum == UFO3) + return COW; + else if (s->picnum == UFO4) + return PIG; + else //if (s->picnum == UFO5) + return BILLYRAY; + }); + continue; + + case OOZ: + ooz(i); + continue; + + case EMPTYBIKE: + if (!isRRRA()) break; + makeitfall(i); + getglobalz(i); + if (sector[sect].lotag == 1) + { + setsprite(i,s->x,s->y,hittype[i].floorz+(16<<8)); + } + break; + + case EMPTYBOAT: + if (!isRRRA()) break; + makeitfall(i); + getglobalz(i); + break; + + case TRIPBOMBSPRITE: + if (!isRRRA() || (sector[sect].lotag != 1 && sector[sect].lotag != 160)) + if (s->xvel) + { + j = movesprite(i, + (s->xvel*sintable[(s->ang+512)&2047])>>14, + (s->xvel*sintable[s->ang&2047])>>14, + s->zvel,CLIPMASK0); + s->xvel--; + } + break; + + case CHEERBOMB: + if (!isRRRA()) break; + case MORTER: + case HEAVYHBOMB: + if( (s->cstat&32768) ) + { + t[2]--; + if(t[2] <= 0) + { + spritesound(TELEPORTER,i); + spawn(i,TRANSPORTERSTAR); + s->cstat = 257; + } + continue; + } + + p = findplayer(s,&x); + + if( x < 1220 ) s->cstat &= ~257; + else s->cstat |= 257; + + if(t[3] == 0 ) + { + j = ifhitbyweapon(i); + if(j >= 0) + { + t[3] = 1; + t[4] = 0; + l = 0; + s->xvel = 0; + goto DETONATEB; + } + } + + makeitfall(i); + + if( sector[sect].lotag != 1 && (!isRRRA() || sector[sect].lotag != 160) && s->z >= hittype[i].floorz-(FOURSLEIGHT) && s->yvel < 3 ) + { + if( s->yvel > 0 || (s->yvel == 0 && hittype[i].floorz == sector[sect].floorz )) + { + if (s->picnum != CHEERBOMB) + spritesound(PIPEBOMB_BOUNCE,i); + else + { + t[3] = 1; + t[4] = 1; + l = 0; + goto DETONATEB; + } + } + s->zvel = -((4-s->yvel)<<8); + if(sector[s->sectnum].lotag== 2) + s->zvel >>= 2; + s->yvel++; + } + if(s->picnum != CHEERBOMB && s->z < hittype[i].ceilingz+(16<<8) && sector[sect].lotag != 2 ) + { + s->z = hittype[i].ceilingz+(16<<8); + s->zvel = 0; + } + + j = movesprite(i, + (s->xvel*(sintable[(s->ang+512)&2047]))>>14, + (s->xvel*(sintable[s->ang&2047]))>>14, + s->zvel,CLIPMASK0); + + if(sector[sprite[i].sectnum].lotag == 1 && s->zvel == 0) + { + s->z += (32<<8); + if(t[5] == 0) + { + t[5] = 1; + spawn(i,WATERSPLASH2); + if (isRRRA() && s->picnum == MORTER) + s->xvel = 0; + } + } + else t[5] = 0; + + if(t[3] == 0 && s->picnum == MORTER && (j || x < 844) ) + { + t[3] = 1; + t[4] = 0; + l = 0; + s->xvel = 0; + goto DETONATEB; + } + + if(t[3] == 0 && s->picnum == CHEERBOMB && (j || x < 844) ) + { + t[3] = 1; + t[4] = 0; + l = 0; + s->xvel = 0; + goto DETONATEB; + } + + if(sprite[s->owner].picnum == APLAYER) + l = sprite[s->owner].yvel; + else l = -1; + + if(s->xvel > 0) + { + s->xvel -= 5; + if(sector[sect].lotag == 2) + s->xvel -= 10; + + if(s->xvel < 0) + s->xvel = 0; + if(s->xvel&8) s->cstat ^= 4; + } + + if( (j&49152) == 32768 ) + { + j &= (MAXWALLS-1); + + checkhitwall(i,j,s->x,s->y,s->z,s->picnum); + + k = getangle( + wall[wall[j].point2].x-wall[j].x, + wall[wall[j].point2].y-wall[j].y); + + if (s->picnum == CHEERBOMB) + { + t[3] = 1; + t[4] = 0; + l = 0; + s->xvel = 0; + goto DETONATEB; + } + s->ang = ((k<<1) - s->ang)&2047; + s->xvel >>= 1; + } + + DETONATEB: + + if( ( l >= 0 && ps[l].hbomb_on == 0 ) || t[3] == 1) + { + t[4]++; + + if(t[4] == 2) + { + x = s->extra; + m = 0; + switch(s->picnum) + { + case TRIPBOMBSPRITE: m = powderkegblastradius;break; + case HEAVYHBOMB: m = pipebombblastradius;break; + case HBOMBAMMO: m = pipebombblastradius;break; + case MORTER: m = morterblastradius;break; + case CHEERBOMB: m = morterblastradius;break; + } + + if(sector[s->sectnum].lotag != 800) + { + hitradius( i, m,x>>2,x>>1,x-(x>>2),x); + spawn(i,EXPLOSION2); + if (s->picnum == CHEERBOMB) + spawn(i,BURNING); + spritesound(PIPEBOMB_EXPLODE,i); + for(x=0;x<8;x++) + RANDOMSCRAP(s, i); + } + } + + if(s->yrepeat) + { + s->yrepeat = 0; + continue; + } + + if(t[4] > 20) + { + deletesprite(i); + continue; + } + if (s->picnum == CHEERBOMB) + { + spawn(i,BURNING); + deletesprite(i); + continue; + } + } + else if(s->picnum == HEAVYHBOMB && x < 788 && t[0] > 7 && s->xvel == 0) + if( cansee(s->x,s->y,s->z-(8<<8),s->sectnum,ps[p].posx,ps[p].posy,ps[p].posz,ps[p].cursectnum) ) + if(ps[p].ammo_amount[HANDBOMB_WEAPON] < max_ammo_amount[HANDBOMB_WEAPON]) + if(s->pal == 0) + { + if(ud.coop >= 1) + { + for(j=0;jowner == ps[p].i ) + addweapon(&ps[p],HANDBOMB_WEAPON); + + if( sprite[s->owner].picnum != APLAYER ) + { + SetPlayerPal(&ps[p], PalEntry(32, 0, 32, 0)); + } + + if( hittype[s->owner].picnum != HEAVYHBOMB || ud.respawn_items == 0 || sprite[s->owner].picnum == APLAYER ) + { + if(s->picnum == HEAVYHBOMB && + sprite[s->owner].picnum != APLAYER && ud.coop ) + continue; + deletesprite(i); + continue; + } + else + { + t[2] = respawnitemtime; + spawn(i,RESPAWNMARKERRED); + s->cstat = (short) 32768; + } + } + + if(t[0] < 8) t[0]++; + continue; + + case REACTORBURNT: + case REACTOR2BURNT: + continue; + + case REACTOR: + case REACTOR2: + reactor(i, REACTOR, REACTOR2, REACTOR2BURNT, REACTOR2BURNT); + continue; + + case RR_CAMERA1: + camera(i); + continue; + } + + +// #ifndef VOLOMEONE + if( ud.multimode < 2 && badguy(s) ) + { + if( actor_tog == 1) + { + s->cstat = (short)32768; + continue; + } + else if(actor_tog == 2) s->cstat = 257; + } +// #endif + + p = findplayer(s,&x); + + execute(i,p,x); + i = nexti; + } + +} + END_DUKE_NS diff --git a/source/games/duke/src/bowling.cpp b/source/games/duke/src/bowling.cpp new file mode 100644 index 000000000..38ea2915e --- /dev/null +++ b/source/games/duke/src/bowling.cpp @@ -0,0 +1,341 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2017-2019 Nuke.YKT + +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 +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms +*/ +//------------------------------------------------------------------------- + +#include "ns.h" +#include "global.h" +#include "actors.h" +#include "names_rr.h" + +BEGIN_DUKE_NS + +short pinsectorresetdown(short sect); + + +void ballreturn(short spr) +{ + short j, i, nexti, nextj; + i = headspritestat[105]; + while (i >= 0) + { + nexti = nextspritestat[i]; + if (sprite[i].picnum == RRTILE281) + if (sprite[spr].sectnum == sprite[i].sectnum) + { + j = headspritestat[105]; + while (j >= 0) + { + nextj = nextspritestat[j]; + if (sprite[j].picnum == RRTILE282) + if (sprite[i].hitag == sprite[j].hitag) + spawn(j, BOWLINGBALLSPRITE); + if (sprite[j].picnum == RRTILE280) + if (sprite[i].hitag == sprite[j].hitag) + if (sprite[j].lotag == 0) + { + sprite[j].lotag = 100; + sprite[j].extra++; + pinsectorresetdown(sprite[j].sectnum); + } + j = nextj; + } + } + + i = nexti; + } +} + +short pinsectorresetdown(short sect) +{ + int vel, j; + + j = getanimationgoal(§or[sect].ceilingz); + + if (j == -1) + { + j = sector[sect].floorz; + vel = 64; + setanimation(sect,§or[sect].ceilingz,j,vel); + return 1; + } + return 0; +} + +short pinsectorresetup(short sect) +{ + int vel, j; + + j = getanimationgoal(§or[sect].ceilingz); + + if (j == -1) + { + j = sector[nextsectorneighborz(sect,sector[sect].ceilingz,-1,-1)].ceilingz; + vel = 64; + setanimation(sect,§or[sect].ceilingz,j,vel); + return 1; + } + return 0; +} + +short checkpins(short sect) +{ + short i, pin; + int x, y; + short pins[10]; + short nexti, tag; + + pin = 0; + for(i=0;i<10;i++) pins[i] = 0; + + i = headspritesect[sect]; + + while (i >= 0) + { + nexti = nextspritesect[i]; + + if (sprite[i].picnum == RRTILE3440) + { + pin++; + pins[sprite[i].lotag] = 1; + } + if (sprite[i].picnum == RRTILE280) + { + tag = sprite[i].hitag; + } + + i = nexti; + } + + if (tag) + { + tag += 2024; + tileCopySection(2024,0,0,128,64,tag,0,0); + for(i=0;i<10;i++) + { + if (pins[i] == 1) + { + switch (i) + { + case 0: + x = 64; + y = 48; + break; + case 1: + x = 56; + y = 40; + break; + case 2: + x = 72; + y = 40; + break; + case 3: + x = 48; + y = 32; + break; + case 4: + x = 64; + y = 32; + break; + case 5: + x = 80; + y = 32; + break; + case 6: + x = 40; + y = 24; + break; + case 7: + x = 56; + y = 24; + break; + case 8: + x = 72; + y = 24; + break; + case 9: + x = 88; + y = 24; + break; + } + tileCopySection(2023,0,0,8,8,tag,x-4,y-10); + } + } + } + + return pin; +} + +void resetpins(short sect) +{ + short i, j, nexti, tag; + int x, y; + i = headspritesect[sect]; + while (i >= 0) + { + nexti = headspritesect[i]; + if (sprite[i].picnum == 3440) + deletesprite(i); + i = nexti; + } + i = headspritesect[sect]; + while (i >= 0) + { + nexti = nextspritesect[i]; + if (sprite[i].picnum == 283) + { + j = spawn(i,3440); + sprite[j].lotag = sprite[i].lotag; + if (sprite[j].lotag == 3 || sprite[j].lotag == 5) + { + sprite[j].clipdist = (1+(krand()%1))*16+32; + } + else + { + sprite[j].clipdist = (1+(krand()%1))*16+32; + } + sprite[j].ang -= ((krand()&32)-(krand()&64))&2047; + } + if (sprite[i].picnum == 280) + tag = sprite[i].hitag; + i = nexti; + } + if (tag) + { + tag += LANEPICS+1; + tileCopySection(LANEPICS+1,0,0,128,64,tag,0,0); + for(i=0;i<10;i++) + { + switch (i) + { + case 0: + x = 64; + y = 48; + break; + case 1: + x = 56; + y = 40; + break; + case 2: + x = 72; + y = 40; + break; + case 3: + x = 48; + y = 32; + break; + case 4: + x = 64; + y = 32; + break; + case 5: + x = 80; + y = 32; + break; + case 6: + x = 40; + y = 24; + break; + case 7: + x = 56; + y = 24; + break; + case 8: + x = 72; + y = 24; + break; + case 9: + x = 88; + y = 24; + break; + } + tileCopySection(LANEPICS,0,0,8,8,tag,x-4,y-10); + } + } +} + +void resetlanepics(void) +{ + int x, y; + short i; + short tag, pic; + for(tag=0;tag<4;tag++) + { + pic = tag + 1; + if (pic == 0) continue; + pic += LANEPICS+1; + tileCopySection(LANEPICS+1,0,0,128,64, pic,0,0); + for(i=0;i<10;i++) + { + switch (i) + { + case 0: + x = 64; + y = 48; + break; + case 1: + x = 56; + y = 40; + break; + case 2: + x = 72; + y = 40; + break; + case 3: + x = 48; + y = 32; + break; + case 4: + x = 64; + y = 32; + break; + case 5: + x = 80; + y = 32; + break; + case 6: + x = 40; + y = 24; + break; + case 7: + x = 56; + y = 24; + break; + case 8: + x = 72; + y = 24; + break; + case 9: + x = 88; + y = 24; + break; + } + tileCopySection(LANEPICS,0,0,8,8,pic,x-4,y-10); + } + } +} + +END_DUKE_NS + diff --git a/source/games/duke/src/cheats.cpp b/source/games/duke/src/cheats.cpp index 8937f8da8..666c08694 100644 --- a/source/games/duke/src/cheats.cpp +++ b/source/games/duke/src/cheats.cpp @@ -810,13 +810,13 @@ void G_DoCheats(void) return; case CHEAT_RATONY: - g_changeEnemySize = 2; + enemysizecheat = 2; end_cheat(pPlayer); inputState.keyFlushChars(); return; case CHEAT_RAVAN: - g_changeEnemySize = 3; + enemysizecheat = 3; end_cheat(pPlayer); inputState.keyFlushChars(); return; diff --git a/source/games/duke/src/e_actors.cpp b/source/games/duke/src/e_actors.cpp index 8525a620a..f80d7cf18 100644 --- a/source/games/duke/src/e_actors.cpp +++ b/source/games/duke/src/e_actors.cpp @@ -377,7 +377,7 @@ static void Proj_BounceOffWall(spritetype *s, int j) s->ang = ((k<<1) - s->ang)&2047; } -static int A_FindLocator(int const tag, int const sectNum) + int A_FindLocator(int const tag, int const sectNum) { for (bssize_t SPRITES_OF(STAT_LOCATOR, spriteNum)) { @@ -388,2493 +388,6 @@ static int A_FindLocator(int const tag, int const sectNum) return -1; } -ACTOR_STATIC int A_PinSectorResetDown(int16_t const sectNum) -{ - if (GetAnimationGoal(§or[sectNum].ceilingz) == -1) - { - int const newZ = sector[sectNum].floorz; - SetAnimation(sectNum,§or[sectNum].ceilingz,newZ,64); - return 1; - } - return 0; -} - -ACTOR_STATIC int A_PinSectorResetUp(int16_t const sectNum) -{ - if (GetAnimationGoal(§or[sectNum].ceilingz) == -1) - { - int const newZ = sector[nextsectorneighborz(sectNum, sector[sectNum].ceilingz,-1,-1)].ceilingz; - SetAnimation(sectNum,§or[sectNum].ceilingz,newZ,64); - return 1; - } - return 0; -} - -ACTOR_STATIC void A_BallReturn(int16_t const pinSprite) -{ - int spriteNum = headspritestat[105]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - if (sprite[spriteNum].picnum == TILE_RRTILE281) - if (sprite[pinSprite].sectnum == sprite[spriteNum].sectnum) - { - int otherSprite = headspritestat[105]; - while (otherSprite >= 0) - { - int const otherSpriteNext = nextspritestat[otherSprite]; - if (sprite[otherSprite].picnum == TILE_RRTILE282) - if (sprite[spriteNum].hitag == sprite[otherSprite].hitag) - A_Spawn(otherSprite, TILE_BOWLINGBALLSPRITE); - if (sprite[otherSprite].picnum == TILE_RRTILE280) - if (sprite[spriteNum].hitag == sprite[otherSprite].hitag) - if (sprite[otherSprite].lotag == 0) - { - sprite[otherSprite].lotag = 100; - sprite[otherSprite].extra++; - A_PinSectorResetDown(sprite[otherSprite].sectnum); - } - otherSprite = otherSpriteNext; - } - } - - spriteNum = nextSprite; - } -} - -ACTOR_STATIC int A_CheckPins(int16_t const sectNum) -{ - uint8_t pins[10]; - int pinCount = 0; - int tag; - - Bmemset(pins, 0, sizeof(pins)); - - int spriteNum = headspritesect[sectNum]; - - while (spriteNum >= 0) - { - if (sprite[spriteNum].picnum == TILE_RRTILE3440) - { - pinCount++; - pins[sprite[spriteNum].lotag] = 1; - } - if (sprite[spriteNum].picnum == TILE_RRTILE280) - { - tag = sprite[spriteNum].hitag; - } - spriteNum = nextspritesect[spriteNum]; - } - - if (tag != 0) - { - int const tileNumber = TILE_LANEPICS + tag + 1; - TileFiles.tileMakeWritable(tileNumber); - tileCopySection(TILE_LANEPICS+1, 0, 0, 128, 64, tileNumber, 0, 0); - - for (int pin = 0; pin < 10; pin++) - { - if (pins[pin] == 1) - { - int x, y; - switch (pin) - { - case 0: - x = 64; - y = 48; - break; - case 1: - x = 56; - y = 40; - break; - case 2: - x = 72; - y = 40; - break; - case 3: - x = 48; - y = 32; - break; - case 4: - x = 64; - y = 32; - break; - case 5: - x = 80; - y = 32; - break; - case 6: - x = 40; - y = 24; - break; - case 7: - x = 56; - y = 24; - break; - case 8: - x = 72; - y = 24; - break; - case 9: - x = 88; - y = 24; - break; - } - tileCopySection(TILE_LANEPICS, 0, 0, 8, 8, tileNumber, x - 4, y - 10); - } - } - } - - return pinCount; -} - -ACTOR_STATIC void A_ResetPins(int16_t sect) -{ - int step = 0; - int tag = 0; - int spriteNum = headspritesect[sect]; - while (spriteNum >= 0) - { - if (spriteNum > MAXSECTORSV7 || step > 1000) - break; - int const nextSprite = headspritesect[spriteNum]; - if (sprite[spriteNum].picnum == TILE_RRTILE3440) - deletesprite(spriteNum); - spriteNum = nextSprite; - step++; - } - spriteNum = headspritesect[sect]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritesect[spriteNum]; - if (sprite[spriteNum].picnum == TILE_RRTILE283) - { - int const newSprite = A_Spawn(spriteNum, TILE_RRTILE3440); - sprite[newSprite].lotag = sprite[spriteNum].lotag; - krand2(); - sprite[newSprite].clipdist = 48; - sprite[newSprite].ang -= ((krand2()&32)-(krand2()&64))&2047; - } - if (sprite[spriteNum].picnum == TILE_RRTILE280) - tag = sprite[spriteNum].hitag; - spriteNum = nextSprite; - } - if (tag != 0) - { - int const tileNumber = TILE_LANEPICS + tag + 1; - TileFiles.tileMakeWritable(tileNumber); - tileCopySection(TILE_LANEPICS+1, 0, 0, 128, 64, tileNumber, 0, 0); - - for (int pin = 0; pin < 10; pin++) - { - int x, y; - switch (pin) - { - case 0: - x = 64; - y = 48; - break; - case 1: - x = 56; - y = 40; - break; - case 2: - x = 72; - y = 40; - break; - case 3: - x = 48; - y = 32; - break; - case 4: - x = 64; - y = 32; - break; - case 5: - x = 80; - y = 32; - break; - case 6: - x = 40; - y = 24; - break; - case 7: - x = 56; - y = 24; - break; - case 8: - x = 72; - y = 24; - break; - case 9: - x = 88; - y = 24; - break; - } - tileCopySection(TILE_LANEPICS, 0, 0, 8, 8, tileNumber, x - 4, y - 10); - } - } -} - -void A_ResetLanePics(void) -{ - for (int tag = 1; tag <= 4; tag++) - { - int const tileNumber = TILE_LANEPICS + tag + 1; - TileFiles.tileMakeWritable(tileNumber); - tileCopySection(TILE_LANEPICS + 1, 0, 0, 128, 64, tileNumber, 0, 0); - - for (int pin = 0; pin < 10; pin++) - { - int x, y; - switch (pin) - { - case 0: - x = 64; - y = 48; - break; - case 1: - x = 56; - y = 40; - break; - case 2: - x = 72; - y = 40; - break; - case 3: - x = 48; - y = 32; - break; - case 4: - x = 64; - y = 32; - break; - case 5: - x = 80; - y = 32; - break; - case 6: - x = 40; - y = 24; - break; - case 7: - x = 56; - y = 24; - break; - case 8: - x = 72; - y = 24; - break; - case 9: - x = 88; - y = 24; - break; - } - tileCopySection(TILE_LANEPICS, 0, 0, 8, 8, tileNumber, x - 4, y - 10); - } - } -} - -ACTOR_STATIC void G_MoveActors(void) -{ - int spriteNum; - - if (!DEER && g_jailDoorCnt) - G_DoJailDoor(); - - if (!DEER && g_mineCartCnt) - G_MoveMineCart(); - - int bBoom = 0; - - if (!DEER && RRRA) - { - int spriteNum = headspritestat[117]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - if (sprite[spriteNum].hitag > 2) - sprite[spriteNum].hitag = 0; - if ((sprite[spriteNum].picnum == TILE_RRTILE8488 || sprite[spriteNum].picnum == TILE_RRTILE8490) && sprite[spriteNum].hitag != 2) - { - sprite[spriteNum].hitag = 2; - sprite[spriteNum].extra = -100; - } - if (sprite[spriteNum].hitag == 0) - { - sprite[spriteNum].extra++; - if (sprite[spriteNum].extra >= 30) - sprite[spriteNum].hitag = 1; - } - else if (sprite[spriteNum].hitag == 1) - { - sprite[spriteNum].extra--; - if (sprite[spriteNum].extra <= -30) - sprite[spriteNum].hitag = 0; - } - else if (sprite[spriteNum].hitag == 2) - { - sprite[spriteNum].extra--; - if (sprite[spriteNum].extra <= -104) - { - A_Spawn(spriteNum, sprite[spriteNum].lotag); - deletesprite(spriteNum); - } - } - - vec3_t const vect = { 0, 0, sprite[spriteNum].extra * 2}; - - A_MoveSprite(spriteNum, &vect, CLIPMASK0); - spriteNum = nextSprite; - } - - spriteNum = headspritestat[118]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - if (sprite[spriteNum].hitag > 1) - sprite[spriteNum].hitag = 0; - if (sprite[spriteNum].hitag == 0) - { - sprite[spriteNum].extra++; - if (sprite[spriteNum].extra >= 20) - sprite[spriteNum].hitag = 1; - } - else if (sprite[spriteNum].hitag == 1) - { - sprite[spriteNum].extra--; - if (sprite[spriteNum].extra <= -20) - sprite[spriteNum].hitag = 0; - } - - vec3_t const vect = { 0, 0, sprite[spriteNum].extra }; - - A_MoveSprite(spriteNum, &vect, CLIPMASK0); - spriteNum = nextSprite; - } - - if (g_player[myconnectindex].ps->level_end_timer > 0) - { - if (--g_player[myconnectindex].ps->level_end_timer == 0) - { - for (bssize_t TRAVERSE_CONNECT(playerNum)) - g_player[playerNum].ps->gm = MODE_EOL; - ud.eog = 1; - ud.level_number++; - if (ud.level_number > 6) - ud.level_number = 0; - m_level_number = ud.level_number; - } - } - - if (g_changeEnemySize > 0) - { - for (bssize_t enemySprite = 0; enemySprite < MAXSPRITES; enemySprite++) - { - switch (DYNAMICTILEMAP(sprite[enemySprite].picnum)) - { - case BILLYCOCK__STATICRR: - case BILLYRAY__STATICRR: - case BILLYRAYSTAYPUT__STATICRR: - case BRAYSNIPER__STATICRR: - case DOGRUN__STATICRR: - case LTH__STATICRR: - case HULKJUMP__STATICRR: - case HULK__STATICRR: - case HULKSTAYPUT__STATICRR: - case HEN__STATICRR: - case DRONE__STATIC: - case PIG__STATICRR: - case MINION__STATICRR: - case MINIONSTAYPUT__STATICRR: - case UFO1__STATICRR: - case UFO2__STATICRR: - case UFO3__STATICRR: - case UFO4__STATICRR: - case UFO5__STATICRR: - case COOT__STATICRR: - case COOTSTAYPUT__STATICRR: - case VIXEN__STATICRR: - case BIKERB__STATICRR: - case BIKERBV2__STATICRR: - case BIKER__STATICRR: - case MAKEOUT__STATICRR: - case CHEERB__STATICRR: - case CHEER__STATICRR: - case CHEERSTAYPUT__STATICRR: - case COOTPLAY__STATICRR: - case BILLYPLAY__STATICRR: - case MINIONBOAT__STATICRR: - case HULKBOAT__STATICRR: - case CHEERBOAT__STATICRR: - case RABBIT__STATICRR: - case MAMA__STATICRR: - if (g_changeEnemySize == 3) - { - sprite[enemySprite].xrepeat = sprite[enemySprite].xrepeat << 1; - sprite[enemySprite].yrepeat = sprite[enemySprite].yrepeat << 1; - sprite[enemySprite].clipdist = mulscale7(sprite[enemySprite].xrepeat, tilesiz[sprite[enemySprite].picnum].x); - } - else if (g_changeEnemySize == 2) - { - sprite[enemySprite].xrepeat = sprite[enemySprite].xrepeat >> 1; - sprite[enemySprite].yrepeat = sprite[enemySprite].yrepeat >> 1; - sprite[enemySprite].clipdist = mulscale7(sprite[enemySprite].xrepeat, tilesiz[sprite[enemySprite].picnum].x); - } - break; - } - } - g_changeEnemySize = 0; - } - - spriteNum = headspritestat[121]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - sprite[spriteNum].extra++; - if (sprite[spriteNum].extra < 100) - { - if (sprite[spriteNum].extra == 90) - { - sprite[spriteNum].picnum--; - if (sprite[spriteNum].picnum < TILE_PIG + 7) - sprite[spriteNum].picnum = TILE_PIG + 7; - sprite[spriteNum].extra = 1; - } - - vec3_t const vect = { 0, 0, -300 }; - A_MoveSprite(spriteNum, &vect, CLIPMASK0); - if (sector[sprite[spriteNum].sectnum].ceilingz + (4 << 8) > sprite[spriteNum].z) - { - sprite[spriteNum].picnum = 0; - sprite[spriteNum].extra = 100; - } - } - else if (sprite[spriteNum].extra == 200) - { - vec3_t const pos = { sprite[spriteNum].x, sprite[spriteNum].y, sector[sprite[spriteNum].sectnum].floorz - 10 }; - setsprite(spriteNum, &pos); - sprite[spriteNum].extra = 1; - sprite[spriteNum].picnum = TILE_PIG + 11; - A_Spawn(spriteNum, TILE_TRANSPORTERSTAR); - } - spriteNum = nextSprite; - } - - spriteNum = headspritestat[119]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - if (sprite[spriteNum].hitag > 0) - { - if (sprite[spriteNum].extra == 0) - { - sprite[spriteNum].hitag--; - sprite[spriteNum].extra = 150; - A_Spawn(spriteNum, TILE_RABBIT); - } - else - sprite[spriteNum].extra--; - } - spriteNum = nextSprite; - } - spriteNum = headspritestat[116]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - if (sprite[spriteNum].extra) - { - if (sprite[spriteNum].extra == sprite[spriteNum].lotag) - S_PlaySound(183); - sprite[spriteNum].extra--; - vec3_t const vect = { - (sprite[spriteNum].hitag*sintable[(sprite[spriteNum].ang + 512) & 2047]) >> 14, - (sprite[spriteNum].hitag*sintable[sprite[spriteNum].ang & 2047]) >> 14, - sprite[spriteNum].hitag << 1 - }; - if (A_MoveSprite(spriteNum, &vect, CLIPMASK0) > 0) - { - A_PlaySound(PIPEBOMB_EXPLODE, spriteNum); - deletesprite(spriteNum); - } - if (sprite[spriteNum].extra == 0) - { - S_PlaySound(215); - deletesprite(spriteNum); - g_earthquakeTime = 32; - P_PalFrom(g_player[myconnectindex].ps, 48, 32, 32, 32); - } - } - spriteNum = nextSprite; - } - - spriteNum = headspritestat[115]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - if (sprite[spriteNum].extra) - { - if (sprite[spriteNum].picnum != TILE_RRTILE8162) - sprite[spriteNum].picnum = TILE_RRTILE8162; - sprite[spriteNum].extra--; - if (sprite[spriteNum].extra == 0) - { - int const fortune = krand2()&127; - if (fortune < 96) - { - sprite[spriteNum].picnum = TILE_RRTILE8162 + 3; - } - else if (fortune < 112) - { - if (g_slotWin & 1) - { - sprite[spriteNum].picnum = TILE_RRTILE8162 + 3; - } - else - { - sprite[spriteNum].picnum = TILE_RRTILE8162 + 2; - A_Spawn(spriteNum, TILE_BATTERYAMMO); - g_slotWin |= 1; - A_PlaySound(52, spriteNum); - } - } - else if (fortune < 120) - { - if (g_slotWin & 2) - { - sprite[spriteNum].picnum = TILE_RRTILE8162 + 3; - } - else - { - sprite[spriteNum].picnum = TILE_RRTILE8162 + 6; - A_Spawn(spriteNum, TILE_HEAVYHBOMB); - g_slotWin |= 2; - A_PlaySound(52, spriteNum); - } - } - else if (fortune < 126) - { - if (g_slotWin & 4) - { - sprite[spriteNum].picnum = TILE_RRTILE8162 + 3; - } - else - { - sprite[spriteNum].picnum = TILE_RRTILE8162 + 5; - A_Spawn(spriteNum, TILE_SIXPAK); - g_slotWin |= 4; - A_PlaySound(52, spriteNum); - } - } - else - { - if (g_slotWin & 8) - { - sprite[spriteNum].picnum = TILE_RRTILE8162 + 3; - } - else - { - sprite[spriteNum].picnum = TILE_RRTILE8162 + 4; - A_Spawn(spriteNum, TILE_ATOMICHEALTH); - g_slotWin |= 8; - A_PlaySound(52, spriteNum); - } - } - } - } - spriteNum = nextSprite; - } - - spriteNum = headspritestat[122]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - if (sprite[spriteNum].extra) - { - if (sprite[spriteNum].picnum != TILE_RRTILE8589) - sprite[spriteNum].picnum = TILE_RRTILE8589; - sprite[spriteNum].extra--; - if (sprite[spriteNum].extra == 0) - { - int const fortune = krand2()&127; - if (fortune < 96) - { - sprite[spriteNum].picnum = TILE_RRTILE8589 + 4; - } - else if (fortune < 112) - { - if (g_slotWin & 1) - { - sprite[spriteNum].picnum = TILE_RRTILE8589 + 4; - } - else - { - sprite[spriteNum].picnum = TILE_RRTILE8589 + 5; - A_Spawn(spriteNum, TILE_BATTERYAMMO); - g_slotWin |= 1; - A_PlaySound(342, spriteNum); - } - } - else if (fortune < 120) - { - if (g_slotWin & 2) - { - sprite[spriteNum].picnum = TILE_RRTILE8589 + 4; - } - else - { - sprite[spriteNum].picnum = TILE_RRTILE8589 + 6; - A_Spawn(spriteNum, TILE_HEAVYHBOMB); - g_slotWin |= 2; - A_PlaySound(342, spriteNum); - } - } - else if (fortune < 126) - { - if (g_slotWin & 4) - { - sprite[spriteNum].picnum = TILE_RRTILE8589 + 4; - } - else - { - sprite[spriteNum].picnum = TILE_RRTILE8589 + 2; - A_Spawn(spriteNum, TILE_SIXPAK); - g_slotWin |= 4; - A_PlaySound(342, spriteNum); - } - } - else - { - if (g_slotWin & 8) - { - sprite[spriteNum].picnum = TILE_RRTILE8589 + 4; - } - else - { - sprite[spriteNum].picnum = TILE_RRTILE8589 + 3; - A_Spawn(spriteNum, TILE_ATOMICHEALTH); - g_slotWin |= 8; - A_PlaySound(342, spriteNum); - } - } - } - } - spriteNum = nextSprite; - } - - spriteNum = headspritestat[123]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - if (sprite[spriteNum].lotag == 5) - if (!S_CheckSoundPlaying(spriteNum, 330)) - A_PlaySound(330, spriteNum); - spriteNum = nextSprite; - } - } - - if (!DEER && RR) - { - spriteNum = headspritestat[107]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - - if (sprite[spriteNum].hitag == 100) - { - sprite[spriteNum].z += (4 << 8); - if (sprite[spriteNum].z >= sector[sprite[spriteNum].sectnum].floorz + 15168) - sprite[spriteNum].z = sector[sprite[spriteNum].sectnum].floorz + 15168; - } - - if (sprite[spriteNum].picnum == TILE_LUMBERBLADE) - { - sprite[spriteNum].extra++; - if (sprite[spriteNum].extra == 192) - { - sprite[spriteNum].hitag = 0; - sprite[spriteNum].z = sector[sprite[spriteNum].sectnum].floorz - 15168; - sprite[spriteNum].extra = 0; - sprite[spriteNum].picnum = TILE_RRTILE3410; - int otherSprite = headspritestat[0]; - while (otherSprite >= 0) - { - int const nextOtherSprite = nextspritestat[otherSprite]; - if (sprite[otherSprite].picnum == TILE_DIPSWITCH3 + 1) - if (sprite[otherSprite].hitag == 999) - sprite[otherSprite].picnum = TILE_DIPSWITCH3; - otherSprite = nextOtherSprite; - } - } - } - spriteNum = nextSprite; - } - - if (g_chickenPlant) - { - spriteNum = headspritestat[106]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - switch (DYNAMICTILEMAP(sprite[spriteNum].picnum)) - { - case RRTILE285__STATICRR: - sprite[spriteNum].lotag--; - if (sprite[spriteNum].lotag < 0) - { - int const newSprite = A_Spawn(spriteNum, TILE_RRTILE3190); - sprite[newSprite].ang = sprite[spriteNum].ang; - sprite[spriteNum].lotag = 128; - } - break; - case RRTILE286__STATICRR: - sprite[spriteNum].lotag--; - if (sprite[spriteNum].lotag < 0) - { - int const newSprite = A_Spawn(spriteNum, TILE_RRTILE3192); - sprite[newSprite].ang = sprite[spriteNum].ang; - sprite[spriteNum].lotag = 256; - } - break; - case RRTILE287__STATICRR: - sprite[spriteNum].lotag--; - if (sprite[spriteNum].lotag < 0) - { - A_SpawnMultiple(spriteNum, TILE_MONEY, (krand2()&3)+4); - sprite[spriteNum].lotag = 84; - } - break; - case RRTILE288__STATICRR: - sprite[spriteNum].lotag--; - if (sprite[spriteNum].lotag < 0) - { - int const newSprite = A_Spawn(spriteNum, TILE_RRTILE3132); - sprite[spriteNum].lotag = 96; - if (!RRRA) - A_PlaySound(472, newSprite); - } - break; - case RRTILE289__STATICRR: - sprite[spriteNum].lotag--; - if (sprite[spriteNum].lotag < 0) - { - int const newSprite = A_Spawn(spriteNum, TILE_RRTILE3120); - sprite[newSprite].ang = sprite[spriteNum].ang; - sprite[spriteNum].lotag = 448; - } - break; - case RRTILE290__STATICRR: - sprite[spriteNum].lotag--; - if (sprite[spriteNum].lotag < 0) - { - int const newSprite = A_Spawn(spriteNum, TILE_RRTILE3122); - sprite[newSprite].ang = sprite[spriteNum].ang; - sprite[spriteNum].lotag = 64; - } - break; - case RRTILE291__STATICRR: - sprite[spriteNum].lotag--; - if (sprite[spriteNum].lotag < 0) - { - int const newSprite = A_Spawn(spriteNum, TILE_RRTILE3123); - sprite[newSprite].ang = sprite[spriteNum].ang; - sprite[spriteNum].lotag = 512; - } - break; - case RRTILE292__STATICRR: - sprite[spriteNum].lotag--; - if (sprite[spriteNum].lotag < 0) - { - int const newSprite = A_Spawn(spriteNum, TILE_RRTILE3124); - sprite[newSprite].ang = sprite[spriteNum].ang; - sprite[spriteNum].lotag = 224; - } - break; - case RRTILE293__STATICRR: - sprite[spriteNum].lotag--; - if (sprite[spriteNum].lotag < 0) - { - A_DoGuts(spriteNum, TILE_JIBS1, 1); - A_DoGuts(spriteNum, TILE_JIBS2, 1); - A_DoGuts(spriteNum, TILE_JIBS3, 1); - A_DoGuts(spriteNum, TILE_JIBS4, 1); - sprite[spriteNum].lotag = 256; - } - break; - } - spriteNum = nextSprite; - } - } - - spriteNum = headspritestat[105]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - if (sprite[spriteNum].picnum == TILE_RRTILE280) - if (sprite[spriteNum].lotag == 100) - { - if (A_PinSectorResetUp(SECT(spriteNum))) - { - sprite[spriteNum].lotag = 0; - if (sprite[spriteNum].extra == 1) - { - if (!A_CheckPins(SECT(spriteNum))) - { - sprite[spriteNum].extra = 2; - } - } - if (sprite[spriteNum].extra == 2) - { - sprite[spriteNum].extra = 0; - A_ResetPins(SECT(spriteNum)); - } - } - } - spriteNum = nextSprite; - } - - spriteNum = headspritestat[108]; - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - - spritetype *const pSprite= &sprite[spriteNum]; - if (pSprite->picnum == TILE_RRTILE296) - { - int playerDist; - DukePlayer_t *const pPlayer = g_player[A_FindPlayer(pSprite, &playerDist)].ps; - - if (playerDist < 2047) - { - int otherSprite = headspritestat[108]; - while (otherSprite >= 0) - { - int const nextOtherSprite = nextspritestat[otherSprite]; - if (sprite[otherSprite].picnum == TILE_RRTILE297) - { - pPlayer->q16ang = F16(sprite[otherSprite].ang); - pPlayer->pos = *(vec3_t*)&sprite[otherSprite]; - pPlayer->pos.z -= (36<<8); - - pPlayer->opos = pPlayer->pos; - pPlayer->bobpos = *(vec2_t*)&pPlayer->pos; - - changespritesect(pPlayer->i, sprite[otherSprite].sectnum); - pPlayer->cursectnum = sprite[otherSprite].sectnum; - - A_PlaySound(TELEPORTER, otherSprite); - - A_DeleteSprite(otherSprite); - } - otherSprite = nextOtherSprite; - } - } - } - spriteNum = nextSprite; - } - } - - spriteNum = headspritestat[STAT_ACTOR]; - - while (spriteNum >= 0) - { - int const nextSprite = nextspritestat[spriteNum]; - spritetype *const pSprite = &sprite[spriteNum]; - int const sectNum = pSprite->sectnum; - int32_t *const pData = actor[spriteNum].t_data; - int deleteAfterExecute = 0; - - int switchPic; - - if (pSprite->xrepeat == 0 || sectNum < 0 || sectNum >= MAXSECTORS) - DELETE_SPRITE_AND_CONTINUE(spriteNum); - - Bmemcpy(&actor[spriteNum].bpos, pSprite, sizeof(vec3_t)); - - switchPic = pSprite->picnum; - - if (!RR && pSprite->picnum > TILE_GREENSLIME && pSprite->picnum <= TILE_GREENSLIME+7) - switchPic = TILE_GREENSLIME; - - if (RR && (switchPic == TILE_RRTILE3440 + 1 || switchPic == TILE_HENSTAND + 1)) - switchPic--; - - - if (!DEER) - switch (DYNAMICTILEMAP(switchPic)) - { - case DUCK__STATIC: - case TARGET__STATIC: - if (RR) break; - if (pSprite->cstat&32) - { - pData[0]++; - if (pData[0] > 60) - { - pData[0] = 0; - pSprite->cstat = 128+257+16; - pSprite->extra = 1; - } - } - else - { - if (A_IncurDamage(spriteNum) >= 0) - { - int doEffects = 1; - - pSprite->cstat = 32+128; - - for (bssize_t SPRITES_OF(STAT_ACTOR, actorNum)) - { - if ((sprite[actorNum].lotag == pSprite->lotag && sprite[actorNum].picnum == pSprite->picnum) - && ((sprite[actorNum].hitag != 0) ^ ((sprite[actorNum].cstat & 32) != 0))) - { - doEffects = 0; - break; - } - } - - if (doEffects == 1) - { - G_OperateActivators(pSprite->lotag, -1); - G_OperateForceFields(spriteNum, pSprite->lotag); - G_OperateMasterSwitches(pSprite->lotag); - } - } - } - goto next_sprite; - - case RESPAWNMARKERRED__STATIC: - case RESPAWNMARKERYELLOW__STATIC: - case RESPAWNMARKERGREEN__STATIC: - if (++T1(spriteNum) > g_itemRespawnTime) - DELETE_SPRITE_AND_CONTINUE(spriteNum); - - if (T1(spriteNum) >= (g_itemRespawnTime>>1) && T1(spriteNum) < ((g_itemRespawnTime>>1)+(g_itemRespawnTime>>2))) - PN(spriteNum) = TILE_RESPAWNMARKERYELLOW; - else if (T1(spriteNum) > ((g_itemRespawnTime>>1)+(g_itemRespawnTime>>2))) - PN(spriteNum) = TILE_RESPAWNMARKERGREEN; - - A_Fall(spriteNum); - break; - - case HELECOPT__STATIC: - case DUKECAR__STATIC: - if (RR) break; - pSprite->z += pSprite->zvel; - pData[0]++; - - if (pData[0] == 4) - A_PlaySound(WAR_AMBIENCE2,spriteNum); - - if (pData[0] > (GAMETICSPERSEC*8)) - { - g_earthquakeTime = 16; - S_PlaySound(RPG_EXPLODE); - - for (bssize_t j = 0; j < 32; j++) - RANDOMSCRAP(pSprite, spriteNum); - - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - else if ((pData[0]&3) == 0) - A_Spawn(spriteNum,TILE_EXPLOSION2); - - A_SetSprite(spriteNum,CLIPMASK0); - break; - - case RAT__STATIC: - A_Fall(spriteNum); - if (A_SetSprite(spriteNum, CLIPMASK0)) - { - if (!RRRA && (krand2()&255) < 3) A_PlaySound(RATTY,spriteNum); - pSprite->ang += (krand2()&31)-15+(sintable[(pData[0]<<8)&2047]>>11); - } - else - { - T1(spriteNum)++; - if (T1(spriteNum) > 1) - { - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - else pSprite->ang = (krand2()&2047); - } - if (pSprite->xvel < 128) - pSprite->xvel+=2; - pSprite->ang += (krand2()&3)-6; - break; - - case RRTILE3190__STATICRR: - case RRTILE3191__STATICRR: - case RRTILE3192__STATICRR: - { - if (!g_chickenPlant) DELETE_SPRITE_AND_CONTINUE(spriteNum); - if (sector[SECT(spriteNum)].lotag == 903) - A_Fall(spriteNum); - - vec3_t const vect = { - (pSprite->xvel*(sintable[(pSprite->ang + 512) & 2047])) >> 14, - (pSprite->xvel*(sintable[pSprite->ang & 2047])) >> 14, - pSprite->zvel - }; - int const moveSprite = A_MoveSprite(spriteNum, &vect, CLIPMASK0); - switch (sector[SECT(spriteNum)].lotag) - { - case 901: - sprite[spriteNum].picnum = TILE_RRTILE3191; - break; - case 902: - sprite[spriteNum].picnum = TILE_RRTILE3192; - break; - case 903: - if (SZ(spriteNum) >= sector[SECT(spriteNum)].floorz - ZOFFSET3) { DELETE_SPRITE_AND_CONTINUE(spriteNum); } - break; - case 904: - DELETE_SPRITE_AND_CONTINUE(spriteNum); - break; - } - if (moveSprite & 49152) - { - if ((moveSprite & 49152) == 32768) { DELETE_SPRITE_AND_CONTINUE(spriteNum); } - else if ((moveSprite & 49152) == 49152) { DELETE_SPRITE_AND_CONTINUE(spriteNum); } - } - break; - } - - case RRTILE3120__STATICRR: - case RRTILE3122__STATICRR: - case RRTILE3123__STATICRR: - case RRTILE3124__STATICRR: - { - if (!g_chickenPlant) DELETE_SPRITE_AND_CONTINUE(spriteNum); - A_Fall(spriteNum); - - vec3_t const vect = { - (pSprite->xvel*(sintable[(pSprite->ang + 512) & 2047])) >> 14, - (pSprite->xvel*(sintable[pSprite->ang & 2047])) >> 14, - pSprite->zvel - }; - int const moveSprite = A_MoveSprite(spriteNum, &vect, CLIPMASK0); - if (moveSprite & 49152) - { - if ((moveSprite & 49152) == 32768) { DELETE_SPRITE_AND_CONTINUE(spriteNum); } - else if ((moveSprite & 49152) == 49152) { DELETE_SPRITE_AND_CONTINUE(spriteNum); } - } - if (sector[pSprite->sectnum].lotag == 903) - { - if (SZ(spriteNum) >= sector[SECT(spriteNum)].floorz - (4 << 8)) - { - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - } - else if (sector[pSprite->sectnum].lotag == 904) - { - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - break; - } - - case RRTILE3132__STATICRR: - { - if (!g_chickenPlant) DELETE_SPRITE_AND_CONTINUE(spriteNum); - A_Fall(spriteNum); - - vec3_t const vect = { - (pSprite->xvel*(sintable[(pSprite->ang + 512) & 2047])) >> 14, - (pSprite->xvel*(sintable[pSprite->ang & 2047])) >> 14, - pSprite->zvel - }; - A_MoveSprite(spriteNum, &vect, CLIPMASK0); - if (pSprite->z >= sector[pSprite->sectnum].floorz - (8 << 8)) - { - if (sector[pSprite->sectnum].lotag == 1) - { - int const newSprite = A_Spawn(spriteNum, TILE_WATERSPLASH2); - sprite[newSprite].z = sector[sprite[newSprite].sectnum].floorz; - } - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - break; - } - - case BOWLINGBALL__STATICRR: - if (pSprite->xvel) - { - if (!A_CheckSoundPlaying(spriteNum, 356)) - A_PlaySound(356, spriteNum); - } - else - { - A_Spawn(spriteNum, TILE_BOWLINGBALLSPRITE); - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - if (sector[pSprite->sectnum].lotag == 900) - { - S_StopEnvSound(356, spriteNum); - } - fallthrough__; - case RRTILE3440__STATICRR: - case HENSTAND__STATICRR: - if (pSprite->picnum == TILE_HENSTAND || pSprite->picnum == TILE_HENSTAND + 1) - { - if (--pSprite->lotag == 0) - { - A_Spawn(spriteNum, TILE_HEN); - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - } - if (sector[pSprite->sectnum].lotag == 900) - pSprite->xvel = 0; - if (pSprite->xvel) - { - A_Fall(spriteNum); - - vec3_t const vect = { - (pSprite->xvel*(sintable[(pSprite->ang + 512) & 2047])) >> 14, - (pSprite->xvel*(sintable[pSprite->ang & 2047])) >> 14, - pSprite->zvel - }; - int moveSprite = A_MoveSprite(spriteNum, &vect, CLIPMASK0); - if (moveSprite & 49152) - { - if ((moveSprite & 49152) == 32768) - { - moveSprite &= (MAXWALLS - 1); - Proj_BounceOffWall(pSprite, moveSprite); - } - else if ((moveSprite & 49152) == 49152) - { - moveSprite &= (MAXSPRITES - 1); - A_DamageObject(spriteNum, moveSprite); - if (sprite[moveSprite].picnum == TILE_HEN) - { - int const newSprite = A_Spawn(moveSprite, TILE_HENSTAND); - A_DeleteSprite(moveSprite); - sprite[newSprite].xvel = 32; - sprite[newSprite].lotag = 40; - sprite[newSprite].ang = pSprite->ang; - } - } - } - if (--pSprite->xvel < 0) pSprite->xvel = 0; - pSprite->cstat = 257; - if (pSprite->picnum == TILE_RRTILE3440) - { - pSprite->cstat |= 4 & pSprite->xvel; - pSprite->cstat |= 8 & pSprite->xvel; - if (krand2() & 1) - pSprite->picnum = TILE_RRTILE3440 + 1; - } - else if (pSprite->picnum == TILE_HENSTAND) - { - pSprite->cstat |= 4 & pSprite->xvel; - pSprite->cstat |= 8 & pSprite->xvel; - if (krand2() & 1) - pSprite->picnum = TILE_HENSTAND + 1; - if (!pSprite->xvel) - deleteAfterExecute = 1; - } - if (pSprite->picnum == TILE_RRTILE3440 || (pSprite->picnum == TILE_RRTILE3440 + 1 && !pSprite->xvel)) - deleteAfterExecute = 1; - } - else if (sector[pSprite->sectnum].lotag == 900) - { - if (pSprite->picnum == TILE_BOWLINGBALL) - A_BallReturn(spriteNum); - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - break; - - case QUEBALL__STATIC: - case STRIPEBALL__STATIC: - if (pSprite->xvel) - { - for (bssize_t SPRITES_OF(STAT_DEFAULT, hitObject)) - if (sprite[hitObject].picnum == TILE_POCKET && ldist(&sprite[hitObject],pSprite) < 52) - DELETE_SPRITE_AND_CONTINUE(spriteNum); - - int hitObject = clipmove((vec3_t *)pSprite, &pSprite->sectnum, - (((pSprite->xvel * (sintable[(pSprite->ang + 512) & 2047])) >> 14) * TICSPERFRAME) << 11, - (((pSprite->xvel * (sintable[pSprite->ang & 2047])) >> 14) * TICSPERFRAME) << 11, 24L, ZOFFSET6, - ZOFFSET6, CLIPMASK1); - - if (hitObject & 49152) - { - if ((hitObject & 49152) == 32768) - { - hitObject &= (MAXWALLS - 1); - Proj_BounceOffWall(pSprite, hitObject); - } - else if ((hitObject & 49152) == 49152) - { - hitObject &= (MAXSPRITES - 1); - A_DamageObject(spriteNum, hitObject); - } - } - - if (--pSprite->xvel < 0) - pSprite->xvel = 0; - - if (pSprite->picnum == TILE_STRIPEBALL) - { - pSprite->cstat = 257; - pSprite->cstat |= (4 & pSprite->xvel) | (8 & pSprite->xvel); - } - } - else - { - int32_t playerDist; - int const playerNum = A_FindPlayer(pSprite,&playerDist); - DukePlayer_t *const pPlayer = g_player[playerNum].ps; - - // I'm 50/50 on this being either a typo or a stupid hack - if (playerDist < 1596) - { - int const angDiff = G_GetAngleDelta(fix16_to_int(pPlayer->q16ang),getangle(pSprite->x-pPlayer->pos.x,pSprite->y-pPlayer->pos.y)); - - if (angDiff > -64 && angDiff < 64 && TEST_SYNC_KEY(g_player[playerNum].input->bits, SK_OPEN) - && pPlayer->toggle_key_flag == 1) - { - int ballSprite; - - for (SPRITES_OF(STAT_ACTOR, ballSprite)) - { - if (sprite[ballSprite].picnum == TILE_QUEBALL || sprite[ballSprite].picnum == TILE_STRIPEBALL) - { - int const angDiff2 = G_GetAngleDelta( - fix16_to_int(pPlayer->q16ang), getangle(sprite[ballSprite].x - pPlayer->pos.x, sprite[ballSprite].y - pPlayer->pos.y)); - - if (angDiff2 > -64 && angDiff2 < 64) - { - int32_t ballDist; - A_FindPlayer(&sprite[ballSprite], &ballDist); - - if (playerDist > ballDist) - break; - } - } - } - - if (ballSprite == -1) - { - pSprite->xvel = (pSprite->pal == 12) ? 164 : 140; - pSprite->ang = fix16_to_int(pPlayer->q16ang); - - pPlayer->toggle_key_flag = 2; - } - } - } - - if (playerDist < 512 && pSprite->sectnum == pPlayer->cursectnum) - { - pSprite->ang = getangle(pSprite->x-pPlayer->pos.x,pSprite->y-pPlayer->pos.y); - pSprite->xvel = 48; - } - } - - break; - - case FORCESPHERE__STATIC: - if (pSprite->yvel == 0) - { - pSprite->yvel = 1; - - for (bssize_t l = 512; l < (2048 - 512); l += 128) - { - for (bssize_t j = 0; j < 2048; j += 128) - { - int const newSprite = A_Spawn(spriteNum, TILE_FORCESPHERE); - sprite[newSprite].cstat = 257 + 128; - sprite[newSprite].clipdist = 64; - sprite[newSprite].ang = j; - sprite[newSprite].zvel = sintable[l & 2047] >> 5; - sprite[newSprite].xvel = sintable[(l + 512) & 2047] >> 9; - sprite[newSprite].owner = spriteNum; - } - } - } - - if (pData[3] > 0) - { - if (pSprite->zvel < 6144) - pSprite->zvel += 192; - - pSprite->z += pSprite->zvel; - - if (pSprite->z > sector[sectNum].floorz) - pSprite->z = sector[sectNum].floorz; - - if (--pData[3] == 0) - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - else if (pData[2] > 10) - { - for (bssize_t SPRITES_OF(STAT_MISC, miscSprite)) - { - if (sprite[miscSprite].owner == spriteNum && sprite[miscSprite].picnum == TILE_FORCESPHERE) - actor[miscSprite].t_data[1] = 1 + (krand2() & 63); - } - - pData[3] = 64; - } - - goto next_sprite; - - case RECON__STATIC: - case UFO1__STATICRR: - case UFO2__STATICRR: - case UFO3__STATICRR: - case UFO4__STATICRR: - case UFO5__STATICRR: - { - int playerNum; - DukePlayer_t *pPlayer; - - A_GetZLimits(spriteNum); - - pSprite->shade += (sector[pSprite->sectnum].ceilingstat & 1) ? (sector[pSprite->sectnum].ceilingshade - pSprite->shade) >> 1 - : (sector[pSprite->sectnum].floorshade - pSprite->shade) >> 1; - - if (pSprite->z < sector[sectNum].ceilingz + ZOFFSET5) - pSprite->z = sector[sectNum].ceilingz + ZOFFSET5; - -#if 0 //def POLYMER - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].sector = s->sectnum; - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].x = s->x; - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].y = s->y; - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].z = s->z + 10248; - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].range = 8192; - - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].angle = s->ang; - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].horiz = 100; - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].radius = 256; - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].faderadius = 200; - - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[0] = 255; - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[1] = 255; - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].color[2] = 255; - - gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = PR_LIGHT_PRIO_MAX_GAME; - - if (gamelightcount < PR_MAXLIGHTS) - gamelightcount++; -#endif - - if (!g_netServer && ud.multimode < 2) - { - if (g_noEnemies == 1) - { - pSprite->cstat = 32768; - goto next_sprite; - } - else if (g_noEnemies == 2) pSprite->cstat = 257; - } - if (A_IncurDamage(spriteNum) >= 0) - { - if (pSprite->extra < 0 && pData[0] != -1) - { - pData[0] = -1; - pSprite->extra = 0; - } - - if (!RR) - A_PlaySound(RECO_PAIN,spriteNum); - RANDOMSCRAP(pSprite, spriteNum); - } - - if (pData[0] == -1) - { - pSprite->z += 1024; - pData[2]++; - - if ((pData[2]&3) == 0) - A_Spawn(spriteNum,TILE_EXPLOSION2); - - A_GetZLimits(spriteNum); - pSprite->ang += 96; - pSprite->xvel = 128; - - if (A_SetSprite(spriteNum, CLIPMASK0) != 1 || pSprite->z > actor[spriteNum].floorz) - { - for (bssize_t l = 0; l < 16; l++) - RANDOMSCRAP(pSprite, spriteNum); - - //int const newSprite = A_Spawn(spriteNum, TILE_EXPLOSION2); - A_PlaySound(LASERTRIP_EXPLODE, spriteNum); - if (RR) - { - if (RRRA && g_ufoSpawnMinion) - A_Spawn(spriteNum, TILE_MINION); - else if (pSprite->picnum == TILE_UFO1) - A_Spawn(spriteNum, TILE_HEN); - else if (pSprite->picnum == TILE_UFO2) - A_Spawn(spriteNum, TILE_COOT); - else if (pSprite->picnum == TILE_UFO3) - A_Spawn(spriteNum, TILE_COW); - else if (pSprite->picnum == TILE_UFO4) - A_Spawn(spriteNum, TILE_PIG); - else if (pSprite->picnum == TILE_UFO5) - A_Spawn(spriteNum, TILE_BILLYRAY); - } - else - A_Spawn(spriteNum, TILE_PIGCOP); - P_AddKills(g_player[myconnectindex].ps, 1); - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - - goto next_sprite; - } - else - { - if (pSprite->z > actor[spriteNum].floorz-(48<<8)) - pSprite->z = actor[spriteNum].floorz-(48<<8); - } - - int32_t playerDist; - playerNum = A_FindPlayer(pSprite, &playerDist); - pPlayer = g_player[playerNum].ps; - - int const spriteOwner = pSprite->owner; - - // 3 = findplayerz, 4 = shoot - - if (pData[0] >= 4) - { - if ((++pData[2] & 15) == 0) - { - int const saveAng = pSprite->ang; - pSprite->ang = actor[spriteNum].tempang; - if (!RR) - A_PlaySound(RECO_ATTACK, spriteNum); - A_Shoot(spriteNum, TILE_FIRELASER); - pSprite->ang = saveAng; - } - if (pData[2] > (GAMETICSPERSEC * 3) - || !cansee(pSprite->x, pSprite->y, pSprite->z - ZOFFSET2, pSprite->sectnum, pPlayer->pos.x, pPlayer->pos.y, - pPlayer->pos.z, pPlayer->cursectnum)) - { - pData[0] = 0; - pData[2] = 0; - } - else actor[spriteNum].tempang += G_GetAngleDelta(actor[spriteNum].tempang, - getangle(pPlayer->pos.x - pSprite->x, - pPlayer->pos.y - pSprite->y)) / 3; - } - else if (pData[0] == 2 || pData[0] == 3) - { - pData[3] = 0; - pSprite->xvel = (pSprite->xvel > 0) ? pSprite->xvel - 16 : 0; - - if (pData[0] == 2) - { - int const zDiff = pPlayer->pos.z - pSprite->z; - - if (klabs(zDiff) < (48 << 8)) - pData[0] = 3; - else - pSprite->z += ksgn(pPlayer->pos.z - pSprite->z) << (RR ? 8 : 10); - } - else - { - pData[2]++; - if (pData[2] > (GAMETICSPERSEC*3) || - !cansee(pSprite->x,pSprite->y,pSprite->z-ZOFFSET2,pSprite->sectnum, pPlayer->pos.x,pPlayer->pos.y,pPlayer->pos.z,pPlayer->cursectnum)) - { - pData[0] = 1; - pData[2] = 0; - } - else if ((pData[2]&15) == 0) - { - if (!RR) - A_PlaySound(RECO_ATTACK,spriteNum); - A_Shoot(spriteNum,TILE_FIRELASER); - } - } - pSprite->ang += G_GetAngleDelta(pSprite->ang, getangle(pPlayer->pos.x - pSprite->x, pPlayer->pos.y - pSprite->y)) >> 2; - } - - if (pData[0] != 2 && pData[0] != 3) - { - int newAngle; - int locatorDist = ldist(&sprite[spriteOwner], pSprite); - if (locatorDist <= 1524) - { - newAngle = pSprite->ang; - pSprite->xvel >>= 1; - } - else newAngle = getangle(sprite[spriteOwner].x - pSprite->x, sprite[spriteOwner].y - pSprite->y); - - if (pData[0] == 1 || pData[0] == 4) // Found a locator and going with it - { - locatorDist = dist(&sprite[spriteOwner], pSprite); - - if (locatorDist <= 1524) - { - pData[0] = (pData[0] == 1) ? 0 : 5; - } - else - { - // Control speed here - if (pSprite->xvel < 256) pSprite->xvel += 32; - } - - if (pData[0] < 2) pData[2]++; - - if (playerDist < 6144 && pData[0] < 2 && pData[2] > (GAMETICSPERSEC*4)) - { - pData[0] = 2+(krand2()&2); - pData[2] = 0; - actor[spriteNum].tempang = pSprite->ang; - } - } - - int locatorSprite = pSprite->owner; - - if (pData[0] == 0 || pData[0] == 5) - { - pData[0] = (pData[0] == 0) ? 1 : 4; - pSprite->owner = A_FindLocator(pSprite->hitag, -1); - locatorSprite = pSprite->owner; - - if (locatorSprite == -1) - { - locatorSprite = actor[spriteNum].t_data[5]; - pSprite->hitag = locatorSprite; - pSprite->owner = A_FindLocator(locatorSprite, -1); - locatorSprite = pSprite->owner; - - if (locatorSprite == -1) - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - else pSprite->hitag++; - } - - // RECON_T4 - pData[3] = G_GetAngleDelta(pSprite->ang,newAngle); - pSprite->ang += pData[3]>>3; - - if (pSprite->z < sprite[locatorSprite].z) - pSprite->z += 1024; - else - pSprite->z -= 1024; - } - - int sndNum = RR ? 457 : RECO_ROAM; - - if (!A_CheckSoundPlaying(spriteNum,sndNum)) - A_PlaySound(sndNum,spriteNum); - - A_SetSprite(spriteNum,CLIPMASK0); - - goto next_sprite; - } - - case OOZ2__STATIC: - if (RR) break; - fallthrough__; - case OOZ__STATIC: - { - A_GetZLimits(spriteNum); - - int const yrepeat = min((actor[spriteNum].floorz - actor[spriteNum].ceilingz) >> 9, 255); - int const xrepeat = clamp(25 - (yrepeat >> 1), 8, 48); - - pSprite->yrepeat = yrepeat; - pSprite->xrepeat = xrepeat; - pSprite->z = actor[spriteNum].floorz; - - goto next_sprite; - } - - case GREENSLIME__STATIC: - { - if (RR) break; - // #ifndef VOLUMEONE - if (!g_netServer && ud.multimode < 2) - { - if (g_noEnemies == 1) - { - pSprite->cstat = 32768; - goto next_sprite; - } - else if (g_noEnemies == 2) pSprite->cstat = 257; - } - // #endif - - pData[1]+=128; - - if (sector[sectNum].floorstat&1) - DELETE_SPRITE_AND_CONTINUE(spriteNum); - - int32_t playerDist; - int const playerNum = A_FindPlayer(pSprite, &playerDist); - DukePlayer_t *const pPlayer = g_player[playerNum].ps; - - if (playerDist > 20480) - { - if (++actor[spriteNum].timetosleep > SLEEPTIME) - { - actor[spriteNum].timetosleep = 0; - changespritestat(spriteNum, STAT_ZOMBIEACTOR); - goto next_sprite; - } - } - - if (pData[0] == -5) // FROZEN - { - pData[3]++; - if (pData[3] > 280) - { - pSprite->pal = 0; - pData[0] = 0; - goto next_sprite; - } - A_Fall(spriteNum); - - pSprite->cstat = 257; - pSprite->picnum = TILE_GREENSLIME + 2; - pSprite->extra = 1; - pSprite->pal = 1; - - int const damageTile = A_IncurDamage(spriteNum); - if (damageTile >= 0) - { - if (damageTile == TILE_FREEZEBLAST) - goto next_sprite; - - P_AddKills(pPlayer, 1); - - for (bssize_t j = 16; j >= 0; --j) - { - int32_t const r1 = krand2(), r2 = krand2(), r3 = krand2(); - int32_t newSprite = A_InsertSprite(SECT(spriteNum), SX(spriteNum), SY(spriteNum), SZ(spriteNum), - TILE_GLASSPIECES + (j % 3), -32, 36, 36, r3 & 2047, 32 + (r2 & 63), - 1024 - (r1 & 1023), spriteNum, 5); - sprite[newSprite].pal = 1; - } - - A_PlaySound(GLASS_BREAKING, spriteNum); - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - else if (playerDist < 1024 && pPlayer->quick_kick == 0) - { - int const angDiff = G_GetAngleDelta(fix16_to_int(pPlayer->q16ang), getangle(SX(spriteNum) - pPlayer->pos.x, - SY(spriteNum) - pPlayer->pos.y)); - - if (angDiff > -128 && angDiff < 128) - pPlayer->quick_kick = 14; - } - - goto next_sprite; - } - - pSprite->cstat = (playerDist < 1596) ? 0 : 257; - - if (pData[0] == -4) //On the player - { - if (sprite[pPlayer->i].extra < 1) - { - pData[0] = 0; - goto next_sprite; - } - - setsprite(spriteNum,(vec3_t *)pSprite); - - pSprite->ang = fix16_to_int(pPlayer->q16ang); - - if ((TEST_SYNC_KEY(g_player[playerNum].input->bits, SK_FIRE) || (pPlayer->quick_kick > 0)) && sprite[pPlayer->i].extra > 0) - if (pPlayer->quick_kick > 0 || - (pPlayer->curr_weapon != HANDREMOTE_WEAPON && pPlayer->curr_weapon != HANDBOMB_WEAPON && - pPlayer->curr_weapon != TRIPBOMB_WEAPON && pPlayer->ammo_amount[pPlayer->curr_weapon] >= 0)) - { - for (bssize_t x = 0; x < 8; ++x) - { - int32_t const r1 = krand2(), r2 = krand2(), r3 = krand2(), r4 = krand2(); - int const j - = A_InsertSprite(sectNum, pSprite->x, pSprite->y, pSprite->z - ZOFFSET3, TILE_SCRAP3 + (r4 & 3), -8, 48, 48, - r3 & 2047, (r2 & 63) + 64, -(r1 & 4095) - (pSprite->zvel >> 2), spriteNum, 5); - sprite[j].pal = 6; - } - - A_PlaySound(SLIM_DYING,spriteNum); - A_PlaySound(SQUISHED,spriteNum); - - if ((krand2()&255) < 32) - { - int const j = A_Spawn(spriteNum,TILE_BLOODPOOL); - sprite[j].pal = 0; - } - - P_AddKills(pPlayer, 1); - pData[0] = -3; - - if (pPlayer->somethingonplayer == spriteNum) - pPlayer->somethingonplayer = -1; - - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - - pSprite->z = pPlayer->pos.z + pPlayer->pyoff - pData[2] + ZOFFSET3 + (fix16_to_int(F16(100) - pPlayer->q16horiz) << 4); - - if (pData[2] > 512) - pData[2] -= 128; - - if (pData[2] < 348) - pData[2] += 128; - - if (pPlayer->newowner >= 0) - G_ClearCameraView(pPlayer); - - if (pData[3] > 0) - { - static const char slimeFrames[] = { 5, 5, 6, 6, 7, 7, 6, 5 }; - - pSprite->picnum = TILE_GREENSLIME + slimeFrames[pData[3]]; - - if (pData[3] == 5) - { - sprite[pPlayer->i].extra += -(5 + (krand2() & 3)); - A_PlaySound(SLIM_ATTACK, spriteNum); - } - - if (pData[3] < 7) - pData[3]++; - else - pData[3] = 0; - } - else - { - pSprite->picnum = TILE_GREENSLIME + 5; - if (rnd(32)) - pData[3] = 1; - } - - pSprite->xrepeat = 20 + (sintable[pData[1] & 2047] >> 13); - pSprite->yrepeat = 15 + (sintable[pData[1] & 2047] >> 13); - pSprite->x = pPlayer->pos.x + (sintable[(fix16_to_int(pPlayer->q16ang) + 512) & 2047] >> 7); - pSprite->y = pPlayer->pos.y + (sintable[fix16_to_int(pPlayer->q16ang) & 2047] >> 7); - - goto next_sprite; - } - - else if (pSprite->xvel < 64 && playerDist < 768) - { - if (pPlayer->somethingonplayer == -1) - { - pPlayer->somethingonplayer = spriteNum; - if (pData[0] == 3 || pData[0] == 2) // Falling downward - pData[2] = (12 << 8); - else - pData[2] = -(13 << 8); // Climbing up player - pData[0] = -4; - } - } - - int const damageTile = A_IncurDamage(spriteNum); - if (damageTile >= 0) - { - A_PlaySound(SLIM_DYING,spriteNum); - - P_AddKills(pPlayer, 1); - - if (pPlayer->somethingonplayer == spriteNum) - pPlayer->somethingonplayer = -1; - - if (damageTile == TILE_FREEZEBLAST) - { - A_PlaySound(SOMETHINGFROZE, spriteNum); - pData[0] = -5; - pData[3] = 0; - goto next_sprite; - } - - if ((krand2()&255) < 32) - { - int const j = A_Spawn(spriteNum,TILE_BLOODPOOL); - sprite[j].pal = 0; - } - - for (bssize_t x=0; x<8; x++) - { - int32_t const r1 = krand2(), r2 = krand2(), r3 = krand2(), r4 = krand2(); - int const j = A_InsertSprite(sectNum, pSprite->x, pSprite->y, pSprite->z - ZOFFSET3, TILE_SCRAP3 + (r4 & 3), -8, - 48, 48, r3 & 2047, (r2 & 63) + 64, -(r1 & 4095) - (pSprite->zvel >> 2), - spriteNum, 5); - sprite[j].pal = 6; - } - pData[0] = -3; - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - // All weap - if (pData[0] == -1) //Shrinking down - { - A_Fall(spriteNum); - - pSprite->cstat &= 65535-8; - pSprite->picnum = TILE_GREENSLIME+4; - - // if(s->yrepeat > 62) - // A_DoGuts(s,TILE_JIBS6,5,myconnectindex); - - if (pSprite->xrepeat > 32) pSprite->xrepeat -= krand2()&7; - if (pSprite->yrepeat > 16) pSprite->yrepeat -= krand2()&7; - else - { - pSprite->xrepeat = 40; - pSprite->yrepeat = 16; - pData[5] = -1; - pData[0] = 0; - } - - goto next_sprite; - } - else if (pData[0] != -2) A_GetZLimits(spriteNum); - - if (pData[0] == -2) //On top of somebody - { - A_Fall(spriteNum); - sprite[pData[5]].xvel = 0; - - int const ang = sprite[pData[5]].ang; - pSprite->x = sprite[pData[5]].x + (sintable[(ang + 512) & 2047] >> 11); - pSprite->y = sprite[pData[5]].y + (sintable[ang & 2047] >> 11); - pSprite->z = sprite[pData[5]].z; - - pSprite->picnum = TILE_GREENSLIME + 2 + (g_globalRandom & 1); - - if (pSprite->yrepeat < 64) - pSprite->yrepeat += 2; - else - { - if (pSprite->xrepeat < 32) - pSprite->xrepeat += 4; - else - { - pData[0] = -1; - playerDist = ldist(pSprite, &sprite[pData[5]]); - - if (playerDist < 768) - sprite[pData[5]].xrepeat = 0; - } - } - - goto next_sprite; - } - - //Check randomly to see of there is an actor near - if (rnd(32)) - { - for (bssize_t SPRITES_OF_SECT(sectNum, j)) - { - if (A_CheckSpriteFlags(j, SFLAG_GREENSLIMEFOOD)) - { - if (ldist(pSprite, &sprite[j]) < 768 && (klabs(pSprite->z - sprite[j].z) < 8192)) // Gulp them - { - pData[5] = j; - pData[0] = -2; - pData[1] = 0; - goto next_sprite; - } - } - } - } - - //Moving on the ground or ceiling - - if (pData[0] == 0 || pData[0] == 2) - { - pSprite->picnum = TILE_GREENSLIME; - - if ((krand2()&511) == 0) - A_PlaySound(SLIM_ROAM,spriteNum); - - if (pData[0]==2) - { - pSprite->zvel = 0; - pSprite->cstat &= (65535-8); - - if ((sector[sectNum].ceilingstat&1) || (actor[spriteNum].ceilingz+6144) < pSprite->z) - { - pSprite->z += 2048; - pData[0] = 3; - goto next_sprite; - } - } - else - { - pSprite->cstat |= 8; - A_Fall(spriteNum); - } - - if (everyothertime&1) A_SetSprite(spriteNum,CLIPMASK0); - - if (pSprite->xvel > 96) - { - pSprite->xvel -= 2; - goto next_sprite; - } - else - { - if (pSprite->xvel < 32) pSprite->xvel += 4; - pSprite->xvel = 64 - (sintable[(pData[1]+512)&2047]>>9); - - pSprite->ang += G_GetAngleDelta(pSprite->ang, - getangle(pPlayer->pos.x-pSprite->x,pPlayer->pos.y-pSprite->y))>>3; - // TJR - } - - pSprite->xrepeat = 36 + (sintable[(pData[1]+512)&2047]>>11); - pSprite->yrepeat = 16 + (sintable[pData[1]&2047]>>13); - - if (rnd(4) && (sector[sectNum].ceilingstat&1) == 0 && - klabs(actor[spriteNum].floorz-actor[spriteNum].ceilingz) - < (192<<8)) - { - pSprite->zvel = 0; - pData[0]++; - } - - } - - if (pData[0]==1) - { - pSprite->picnum = TILE_GREENSLIME; - if (pSprite->yrepeat < 40) pSprite->yrepeat+=8; - if (pSprite->xrepeat > 8) pSprite->xrepeat-=4; - if (pSprite->zvel > -(2048+1024)) - pSprite->zvel -= 348; - pSprite->z += pSprite->zvel; - if (pSprite->z < actor[spriteNum].ceilingz+4096) - { - pSprite->z = actor[spriteNum].ceilingz+4096; - pSprite->xvel = 0; - pData[0] = 2; - } - } - - if (pData[0]==3) - { - pSprite->picnum = TILE_GREENSLIME+1; - - A_Fall(spriteNum); - - if (pSprite->z > actor[spriteNum].floorz-ZOFFSET3) - { - pSprite->yrepeat-=4; - pSprite->xrepeat+=2; - } - else - { - if (pSprite->yrepeat < (40-4)) pSprite->yrepeat+=8; - if (pSprite->xrepeat > 8) pSprite->xrepeat-=4; - } - - if (pSprite->z > actor[spriteNum].floorz-2048) - { - pSprite->z = actor[spriteNum].floorz-2048; - pData[0] = 0; - pSprite->xvel = 0; - } - } - goto next_sprite; - } - - case EMPTYBIKE__STATICRR: - if(!RRRA) break; - A_Fall(spriteNum); - A_GetZLimits(spriteNum); - if (sector[sectNum].lotag == ST_1_ABOVE_WATER) - { - vec3_t const pos = { pSprite->x, pSprite->y, actor[spriteNum].floorz + ZOFFSET2 }; - setsprite(spriteNum, &pos); - } - break; - - case EMPTYBOAT__STATICRR: - if (!RRRA) break; - A_Fall(spriteNum); - A_GetZLimits(spriteNum); - break; - - case TRIPBOMBSPRITE__STATIC: - if (!RR) break; - if (!RRRA || (sector[sectNum].lotag != ST_1_ABOVE_WATER && sector[sectNum].lotag != 160)) - if (pSprite->xvel) - { - vec3_t const vect = { - (pSprite->xvel*(sintable[(pSprite->ang + 512) & 2047])) >> 14, - (pSprite->xvel*(sintable[pSprite->ang & 2047])) >> 14, - pSprite->zvel - }; - - A_MoveSprite(spriteNum, &vect, CLIPMASK0); - pSprite->xvel--; - } - break; - - case BOUNCEMINE__STATIC: - if (RR) break; - fallthrough__; - case MORTER__STATIC: - if (!RR) - { - int const j = A_Spawn(spriteNum, TILE_FRAMEEFFECT1); - actor[j].t_data[0] = 3; - } - fallthrough__; - case HEAVYHBOMB__STATIC: - case CHEERBOMB__STATICRR: - { - int playerNum; - DukePlayer_t *pPlayer; - int detonatePlayer; - - if ((pSprite->cstat&32768)) - { - if (--pData[2] <= 0) - { - A_PlaySound(TELEPORTER, spriteNum); - A_Spawn(spriteNum, TILE_TRANSPORTERSTAR); - pSprite->cstat = 257; - } - goto next_sprite; - } - - int32_t playerDist; - playerNum = A_FindPlayer(pSprite, &playerDist); - pPlayer = g_player[playerNum].ps; - - if (playerDist < 1220) - pSprite->cstat &= ~257; - else - pSprite->cstat |= 257; - - if (pData[3] == 0) - { - if (A_IncurDamage(spriteNum) >= 0) - { - pData[3] = 1; - pData[4] = 0; - detonatePlayer = 0; - pSprite->xvel = 0; - goto DETONATEB; - } - } - - if (RR || pSprite->picnum != TILE_BOUNCEMINE) - { - A_Fall(spriteNum); - - if (sector[sectNum].lotag != ST_1_ABOVE_WATER && (!RRRA || sector[sectNum].lotag != 160) && pSprite->z >= actor[spriteNum].floorz-(ZOFFSET) && pSprite->yvel < 3) - { - if (pSprite->yvel > 0 || (pSprite->yvel == 0 && actor[spriteNum].floorz == sector[sectNum].floorz)) - { - if (RRRA && pSprite->picnum == TILE_CHEERBOMB) - { - pData[3] = 1; - pData[4] = 1; - detonatePlayer = 0; - goto DETONATEB; - } - else - A_PlaySound(PIPEBOMB_BOUNCE,spriteNum); - } - pSprite->zvel = -((4-pSprite->yvel)<<8); - if (sector[pSprite->sectnum].lotag == ST_2_UNDERWATER) - pSprite->zvel >>= 2; - pSprite->yvel++; - } - if (RR) - { - if ((!RRRA || pSprite->picnum != TILE_CHEERBOMB) && pSprite->z < actor[spriteNum].ceilingz+(16<<8) && sector[sectNum].lotag != ST_2_UNDERWATER ) - { - pSprite->z = actor[spriteNum].ceilingz+(16<<8); - pSprite->zvel = 0; - } - } - else - { - if (pSprite->z < actor[spriteNum].ceilingz) // && sector[sect].lotag != ST_2_UNDERWATER ) - { - pSprite->z = actor[spriteNum].ceilingz+(3<<8); - pSprite->zvel = 0; - } - } - } - - // can't initialize this because of the goto above - vec3_t tmpvect; - tmpvect.x = (pSprite->xvel * (sintable[(pSprite->ang + 512) & 2047])) >> 14; - tmpvect.y = (pSprite->xvel * (sintable[pSprite->ang & 2047])) >> 14; - tmpvect.z = pSprite->zvel; - - int moveSprite; - moveSprite = A_MoveSprite(spriteNum, &tmpvect, CLIPMASK0); - - //actor[spriteNum].movflag = moveSprite; - - if (sector[SECT(spriteNum)].lotag == ST_1_ABOVE_WATER && pSprite->zvel == 0) - { - pSprite->z += ZOFFSET5; - if (pData[5] == 0) - { - pData[5] = 1; - A_Spawn(spriteNum,TILE_WATERSPLASH2); - if (RRRA && pSprite->picnum == TILE_MORTER) - pSprite->xvel = 0; - } - } - else pData[5] = 0; - - if (pData[3] == 0 && ((!RR && pSprite->picnum == TILE_BOUNCEMINE) || pSprite->picnum == TILE_MORTER || (RRRA && pSprite->picnum == TILE_CHEERBOMB)) - && (moveSprite || playerDist < 844)) - { - pData[3] = 1; - pData[4] = 0; - detonatePlayer = 0; - pSprite->xvel = 0; - goto DETONATEB; - } - - if (sprite[pSprite->owner].picnum == TILE_APLAYER) - detonatePlayer = P_Get(pSprite->owner); - else detonatePlayer = -1; - - if (pSprite->xvel > 0) - { - pSprite->xvel -= 5; - if (sector[sectNum].lotag == ST_2_UNDERWATER) - pSprite->xvel -= 10; - - if (pSprite->xvel < 0) - pSprite->xvel = 0; - if (pSprite->xvel&8) pSprite->cstat ^= 4; - } - - if ((moveSprite&49152) == 32768) - { - vec3_t davect = *(vec3_t *)pSprite; - moveSprite &= (MAXWALLS - 1); - A_DamageWall(spriteNum, moveSprite, &davect, pSprite->picnum); - if (RRRA && pSprite->picnum == TILE_CHEERBOMB) - { - pData[3] = 1; - pData[4] = 0; - detonatePlayer = 0; - pSprite->xvel = 0; - goto DETONATEB; - } - Proj_BounceOffWall(pSprite, moveSprite); - pSprite->xvel >>= 1; - } - -DETONATEB: - if (!NAM_WW2GI) - bBoom = 0; - if ((detonatePlayer >= 0 && g_player[detonatePlayer].ps->hbomb_on == 0) || pData[3] == 1) - bBoom = 1; - if (NAM_WW2GI && pSprite->picnum == TILE_HEAVYHBOMB) - { - pSprite->extra--; - if (pSprite->extra <= 0) - bBoom = 1; - } - - if (bBoom) - { - pData[4]++; - - if (pData[4] == 2) - { - int const x = pSprite->extra; - int radius = 0; - - switch (DYNAMICTILEMAP(pSprite->picnum)) - { - case TRIPBOMBSPRITE__STATIC: if(RR) radius = g_tripbombRadius; break; - case HEAVYHBOMB__STATIC: radius = g_pipebombRadius; break; - case HBOMBAMMO__STATIC: if (RR) radius = g_pipebombRadius; break; - case MORTER__STATIC: radius = g_morterRadius; break; - case BOUNCEMINE__STATIC: if (!RR) radius = g_bouncemineRadius; break; - case CHEERBOMB__STATICRR: if (RRRA) radius = g_morterRadius; break; - } - - if (!RR || sector[pSprite->sectnum].lotag != 800) - { - A_RadiusDamage(spriteNum, radius, x >> 2, x >> 1, x - (x >> 2), x); - - int const j = A_Spawn(spriteNum, TILE_EXPLOSION2); - A_PlaySound(PIPEBOMB_EXPLODE, j); - - if (RRRA && pSprite->picnum == TILE_CHEERBOMB) - A_Spawn(spriteNum, TILE_BURNING); - - if (!RR && pSprite->zvel == 0) - A_Spawn(spriteNum,TILE_EXPLOSION2BOT); - - for (bssize_t x = 0; x < 8; ++x) - RANDOMSCRAP(pSprite, spriteNum); - } - } - - if (pSprite->yrepeat) - { - pSprite->yrepeat = 0; - goto next_sprite; - } - - if (pData[4] > 20) - { - if (RR || pSprite->owner != spriteNum || ud.respawn_items == 0) - { - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - else - { - pData[4] = g_itemRespawnTime; - A_Spawn(spriteNum,TILE_RESPAWNMARKERRED); - pSprite->cstat = 32768; - pSprite->yrepeat = 9; - goto next_sprite; - } - } - if (RRRA && pSprite->picnum == TILE_CHEERBOMB) - { - A_Spawn(spriteNum, TILE_BURNING); - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - } - else if (pSprite->picnum == TILE_HEAVYHBOMB && playerDist < 788 && pData[0] > 7 && pSprite->xvel == 0) - { - if (cansee(pSprite->x, pSprite->y, pSprite->z - ZOFFSET3, pSprite->sectnum, - pPlayer->pos.x, pPlayer->pos.y, pPlayer->pos.z, pPlayer->cursectnum)) - { - if (pPlayer->ammo_amount[HANDBOMB_WEAPON] < pPlayer->max_ammo_amount[HANDBOMB_WEAPON] && (!RR || pSprite->pal == 0)) - { - if ((g_gametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY) && (RR || pSprite->owner == spriteNum)) - { - for (bssize_t j = 0; j < pPlayer->weapreccnt; j++) - { - if (pPlayer->weaprecs[j] == (RR ? spriteNum : pSprite->picnum)) - goto next_sprite; - } - - if (pPlayer->weapreccnt < MAX_WEAPON_RECS-1) - pPlayer->weaprecs[pPlayer->weapreccnt++] = (RR ? spriteNum : pSprite->picnum); - } - - P_AddAmmo(pPlayer, HANDBOMB_WEAPON, 1); - if (RR) - P_AddAmmo(pPlayer, RPG_WEAPON, 1); - A_PlaySound(DUKE_GET, pPlayer->i); - - if (!pPlayer->gotweapon[HANDBOMB_WEAPON] || pSprite->owner == pPlayer->i) - P_AddWeapon(pPlayer, HANDBOMB_WEAPON); - - if (sprite[pSprite->owner].picnum != TILE_APLAYER) - P_PalFrom(pPlayer, 32, 0, 32, 0); - - if ((RR && actor[pSprite->owner].picnum != TILE_HEAVYHBOMB) || (!RR && pSprite->owner != spriteNum) - || ud.respawn_items == 0) - { - if ((!RR || (pSprite->picnum == TILE_HEAVYHBOMB && sprite[pSprite->owner].picnum != TILE_APLAYER)) && (RR || pSprite->owner == spriteNum) && (g_gametypeFlags[ud.coop] & GAMETYPE_WEAPSTAY)) - goto next_sprite; - DELETE_SPRITE_AND_CONTINUE(spriteNum); - } - else - { - pData[2] = g_itemRespawnTime; - A_Spawn(spriteNum, TILE_RESPAWNMARKERRED); - pSprite->cstat = 32768; - } - } - } - } - - if (pData[0] < 8) - pData[0]++; - - goto next_sprite; - } - - case REACTORBURNT__STATIC: - case REACTOR2BURNT__STATIC: - goto next_sprite; - - case REACTOR__STATIC: - case REACTOR2__STATIC: - { - if (pData[4] == 1) - { - for (bssize_t SPRITES_OF_SECT(sectNum, j)) - { - switch (DYNAMICTILEMAP(sprite[j].picnum)) - { - case SECTOREFFECTOR__STATIC: - if (sprite[j].lotag == 1) - { - sprite[j].lotag = 65535u; - sprite[j].hitag = 65535u; - } - break; - case REACTOR__STATIC: - sprite[j].picnum = TILE_REACTORBURNT; - break; - case REACTOR2__STATIC: - sprite[j].picnum = TILE_REACTOR2BURNT; - break; - case REACTORSPARK__STATIC: - case REACTOR2SPARK__STATIC: - sprite[j].cstat = 32768; - break; - } - } - - goto next_sprite; - } - - if (pData[1] >= 20) - { - pData[4] = 1; - goto next_sprite; - } - - int32_t playerDist; - int playerNum = A_FindPlayer(pSprite, &playerDist); - DukePlayer_t *const pPlayer = g_player[playerNum].ps; - - if (++pData[2] == 4) - pData[2] = 0; - - if (playerDist < 4096) - { - if ((krand2() & 255) < 16) - { - if (!A_CheckSoundPlaying(pPlayer->i, DUKE_LONGTERM_PAIN)) - A_PlaySound(DUKE_LONGTERM_PAIN, pPlayer->i); - - A_PlaySound(SHORT_CIRCUIT, spriteNum); - sprite[pPlayer->i].extra--; - P_PalFrom(pPlayer, 32, 32, 0, 0); - } - - pData[0] += 128; - - if (pData[3] == 0) - pData[3] = 1; - } - else pData[3] = 0; - - if (pData[1]) - { - pData[1]++; - pData[4] = pSprite->z; - pSprite->z = sector[sectNum].floorz - (krand2() % (sector[sectNum].floorz - sector[sectNum].ceilingz)); - - switch (pData[1]) - { - case 3: - // Turn on all of those flashing sectoreffector. - A_RadiusDamage(spriteNum, 4096, g_impactDamage << 2, g_impactDamage << 2, g_impactDamage << 2, g_impactDamage << 2); - - for (bssize_t SPRITES_OF(STAT_STANDABLE, j)) - { - if (sprite[j].picnum == TILE_MASTERSWITCH && sprite[j].hitag == pSprite->hitag && sprite[j].yvel == 0) - sprite[j].yvel = 1; - } - break; - - case 4: - case 7: - case 10: - case 15: - for (bssize_t SPRITES_OF_SECT(sectNum, j)) - { - if (j != spriteNum) - { - A_DeleteSprite(j); - break; - } - } - - break; - } - - for (bssize_t x = 0; x < 16; x++) - RANDOMSCRAP(pSprite, spriteNum); - - pSprite->z = pData[4]; - pData[4] = 0; - } - else if (A_IncurDamage(spriteNum) >= 0) - { - for (bssize_t x = 0; x < 32; x++) - RANDOMSCRAP(pSprite, spriteNum); - - if (pSprite->extra < 0) - pData[1] = 1; - } - goto next_sprite; - } - - case CAMERA1__STATIC: - if (pData[0] == 0) - { - pData[1]+=8; - if (g_damageCameras) - { - if (A_IncurDamage(spriteNum) >= 0) - { - pData[0] = 1; // static - pSprite->cstat = 32768; - - for (bssize_t x = 0; x < 5; x++) - RANDOMSCRAP(pSprite, spriteNum); - - goto next_sprite; - } - } - - if (pSprite->hitag > 0) - { - if (pData[1] < pSprite->hitag) pSprite->ang += 8; - else if (pData[1] < pSprite->hitag * 3) pSprite->ang -= 8; - else if (pData[1] < (pSprite->hitag << 2)) pSprite->ang += 8; - else - { - pData[1] = 8; - pSprite->ang += 16; - } - } - } - goto next_sprite; - } - - if (!g_netServer && ud.multimode < 2 && A_CheckEnemySprite(pSprite)) - { - if (g_noEnemies == 1) - { - pSprite->cstat = 32768; - goto next_sprite; - } - else if (g_noEnemies == 2) - { - pSprite->cstat = 257; - } - } - - if (G_HaveActor(sprite[spriteNum].picnum)) - { - int32_t playerDist; - int playerNum = A_FindPlayer(pSprite, &playerDist); - A_Execute(spriteNum, playerNum, playerDist); - } - if (deleteAfterExecute) - A_DeleteSprite(spriteNum); -next_sprite: - spriteNum = nextSprite; - } -} ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 { @@ -6455,6 +3968,7 @@ void movefallers_d(); void movestandables_d(); void moveweapons_d(); void movetransports_d(void); +void moveactors_d(); void movefta_r(void); void moveplayers(); @@ -6463,6 +3977,8 @@ void movefallers_r(); void movestandables_r(); void moveweapons_r(); void movetransports_r(void); +void moveactors_r(); +void thunder(); void G_MoveWorld_d(void) { @@ -6479,7 +3995,7 @@ void G_MoveWorld_d(void) const double actorsTime = timerGetHiTicks(); - G_MoveActors(); //ST 1 + moveactors_d(); //ST 1 g_moveActorsTime = (1-0.033)*g_moveActorsTime + 0.033*(timerGetHiTicks()-actorsTime); @@ -6515,7 +4031,7 @@ void G_MoveWorld_r(void) const double actorsTime = timerGetHiTicks(); - G_MoveActors(); //ST 1 + moveactors_r(); //ST 1 g_moveActorsTime = (1 - 0.033) * g_moveActorsTime + 0.033 * (timerGetHiTicks() - actorsTime); @@ -6543,8 +4059,8 @@ void G_MoveWorld_r(void) if (!DEER) movefx(); //ST 11 - if (RR && numplayers < 2 && g_thunderOn) - G_Thunder(); + if (numplayers < 2 && g_thunderOn) + thunder(); g_moveWorldTime = (1 - 0.033) * g_moveWorldTime + 0.033 * (timerGetHiTicks() - worldTime); } diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index 72fdc71cc..be04944e1 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -1682,7 +1682,7 @@ default_case: if (!RRRA) goto default_case; pSprite->xrepeat = 0; pSprite->yrepeat = 0; - g_ufoSpawnMinion = 1; + ufospawnsminion = 1; break; case RRTILE8193__STATICRR: if (!RRRA) goto default_case; @@ -2988,7 +2988,7 @@ rr_badguy: pSprite->xrepeat = 16; pSprite->yrepeat = 16; pSprite->clipdist = mulscale7(pSprite->xrepeat, tilesiz[pSprite->picnum].x); - if (RRRA && g_ufoSpawnMinion) + if (RRRA && ufospawnsminion) pSprite->pal = 8; break; case DOGRUN__STATICRR: @@ -7572,8 +7572,8 @@ int G_DoMoveThings(void) //if (g_netClient) //Slave // Net_SendClientUpdate(); - if (RR && ud.recstat == 0 && ud.multimode < 2 && g_torchCnt) - G_DoTorch(); + if (RR && ud.recstat == 0 && ud.multimode < 2) + dotorch(); return 0; } diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 731e22296..2e91f9131 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -113,6 +113,7 @@ G_EXTERN int32_t g_frameRate; G_EXTERN int32_t g_cyclerCnt; #define numcyclers g_cyclerCnt G_EXTERN int32_t g_damageCameras; +#define camerashitable g_damageCameras G_EXTERN int32_t g_defaultLabelCnt; G_EXTERN int32_t g_doQuickSave; G_EXTERN int32_t g_earthquakeTime; @@ -122,6 +123,7 @@ G_EXTERN int32_t g_gameQuit; G_EXTERN int32_t g_globalRandom; #define global_random g_globalRandom G_EXTERN int32_t g_impactDamage; +#define impact_damage g_impactDamage G_EXTERN int32_t g_labelCnt; G_EXTERN int32_t g_maxPlayerHealth; G_EXTERN int32_t g_mirrorCount; @@ -157,6 +159,7 @@ G_EXTERN ClockTicks ototalclock; G_EXTERN int32_t g_wupass; G_EXTERN int32_t g_chickenPlant; +#define chickenplant g_chickenPlant G_EXTERN int32_t g_thunderOn; G_EXTERN int32_t g_ufoSpawn; G_EXTERN int32_t g_ufoCnt; @@ -165,34 +168,6 @@ G_EXTERN int32_t g_vixenLevel; G_EXTERN int32_t g_lastLevel; G_EXTERN int32_t g_turdLevel; -G_EXTERN int32_t g_mineCartDir[MAXMINECARTS]; -G_EXTERN int32_t g_mineCartSpeed[MAXMINECARTS]; -G_EXTERN int32_t g_mineCartChildSect[MAXMINECARTS]; -G_EXTERN int32_t g_mineCartSound[MAXMINECARTS]; -G_EXTERN int32_t g_mineCartDist[MAXMINECARTS]; -G_EXTERN int32_t g_mineCartDrag[MAXMINECARTS]; -G_EXTERN int32_t g_mineCartOpen[MAXMINECARTS]; -G_EXTERN int32_t g_mineCartSect[MAXMINECARTS]; -G_EXTERN uint32_t g_mineCartCnt; - -G_EXTERN int32_t g_jailDoorSound[MAXJAILDOORS]; -G_EXTERN int32_t g_jailDoorDrag[MAXJAILDOORS]; -G_EXTERN int32_t g_jailDoorSpeed[MAXJAILDOORS]; -G_EXTERN int32_t g_jailDoorSecHitag[MAXJAILDOORS]; -G_EXTERN int32_t g_jailDoorDist[MAXJAILDOORS]; -G_EXTERN int32_t g_jailDoorDir[MAXJAILDOORS]; -G_EXTERN int32_t g_jailDoorOpen[MAXJAILDOORS]; -G_EXTERN int32_t g_jailDoorSect[MAXJAILDOORS]; -G_EXTERN uint32_t g_jailDoorCnt; - -G_EXTERN int32_t g_lightninSector[MAXLIGHTNINSECTORS]; -G_EXTERN int32_t g_lightninSectorShade[MAXLIGHTNINSECTORS]; -G_EXTERN uint32_t g_lightninCnt; - -G_EXTERN int32_t g_torchSector[MAXTORCHSECTORS]; -G_EXTERN int32_t g_torchSectorShade[MAXTORCHSECTORS]; -G_EXTERN int32_t g_torchType[MAXTORCHSECTORS]; -G_EXTERN uint32_t g_torchCnt; G_EXTERN int32_t g_geoSectorWarp[MAXGEOSECTORS]; G_EXTERN int32_t g_geoSectorWarp2[MAXGEOSECTORS]; @@ -232,8 +207,9 @@ G_EXTERN msy_ msy; G_EXTERN int32_t g_windTime, g_windDir; G_EXTERN int16_t g_fakeBubbaCnt, g_mamaSpawnCnt, g_banjoSong, g_bellTime, g_bellSprite; G_EXTERN uint8_t g_spriteExtra[MAXSPRITES], g_sectorExtra[MAXSECTORS]; -G_EXTERN uint8_t g_changeEnemySize, g_slotWin, g_ufoSpawnMinion, g_pistonSound, g_chickenWeaponTimer, g_RAendLevel, g_RAendEpisode, g_fogType; +G_EXTERN uint8_t enemysizecheat, ufospawnsminion, g_pistonSound, g_chickenWeaponTimer, g_RAendLevel, g_RAendEpisode, g_fogType; G_EXTERN int32_t g_cdTrack; +#define raat607 enemysizecheat // only as a reminder // XXX: I think this pragma pack is meaningless here. // MSDN (https://msdn.microsoft.com/en-us/library/2e70t5y1%28VS.80%29.aspx) says: @@ -265,10 +241,13 @@ extern char g_gametypeNames[MAXGAMETYPES][33]; extern int32_t g_actorRespawnTime; extern int32_t g_bouncemineRadius; +#define bouncemineblastradius g_bouncemineRadius extern int32_t g_deleteQueueSize; extern int32_t g_gametypeCnt; extern int32_t g_itemRespawnTime; +#define respawnitemtime g_itemRespawnTime extern int32_t g_morterRadius; +#define morterblastradius g_morterRadius extern int32_t g_numFreezeBounces; extern int32_t g_pipebombRadius; #define pipebombblastradius g_pipebombRadius @@ -284,6 +263,7 @@ extern int32_t g_spriteGravity; extern int32_t g_timerTicsPerSecond; extern int32_t g_tripbombRadius; #define tripbombblastradius g_tripbombRadius +#define powderkegblastradius g_tripbombRadius extern int32_t g_volumeCnt; #define gc g_spriteGravity @@ -369,6 +349,14 @@ inline bool PlayerInput(int pl, int bit) return TEST_SYNC_KEY(g_player[pl].input->bits, bit); } +enum +{ + kHitTypeMask = 0xC000, + //kHitIndexMask = 0x3FFF, + kHitSector = 0x4000, + kHitWall = 0x8000, + kHitSprite = 0xC000, +}; END_DUKE_NS diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index 0596e7a16..40db7a0b9 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -163,6 +163,13 @@ typedef struct player_struct { fix16_t q16horiz, q16horizoff; fix16_t q16ang, oq16ang; + int getang() { return q16ang >> FRACBITS; } + int getoang() { return oq16ang >> FRACBITS; } + void setang(int v) { q16ang = v << FRACBITS; } + void setoang(int v) { oq16ang = v << FRACBITS; } + void addhoriz(int v) { q16horiz += (v << FRACBITS); } + int gethoriz() { return q16horiz >> FRACBITS; } + int32_t truefz, truecz, player_par; int32_t randomflamex, exitx, exity; int32_t runspeed, max_player_health, max_shield_amount; @@ -247,6 +254,7 @@ typedef struct player_struct { int32_t dhat60f, dhat613, dhat617, dhat61b, dhat61f; int8_t crouch_toggle; + int SlotWin; int8_t padding_[3]; } DukePlayer_t; @@ -258,6 +266,7 @@ typedef struct player_struct { #define heat_amount inv_amount[GET_HEATS] #define scuba_amount inv_amount[GET_SCUBA] #define boot_amount inv_amount[GET_BOOTS] +#define raat609 level_end_timer // name in RRGDX is 'MamaEnd' // KEEPINSYNC lunatic/_defs_game.lua @@ -350,6 +359,10 @@ extern int32_t ticrandomseed; #define SHOOT_HARDCODED_ZVEL INT32_MIN int A_Shoot(int spriteNum, int projecTile); +inline int shoot(int s, int p) +{ + return A_Shoot(s, p); +} static inline void P_PalFrom(DukePlayer_t *pPlayer, uint8_t f, uint8_t r, uint8_t g, uint8_t b) { @@ -359,6 +372,14 @@ static inline void P_PalFrom(DukePlayer_t *pPlayer, uint8_t f, uint8_t r, uint8_ pPlayer->pals.b = b; } +inline void SetPlayerPal(DukePlayer_t* pPlayer, PalEntry pe) +{ + pPlayer->pals.f = pe.a; + pPlayer->pals.r = pe.r; + pPlayer->pals.g = pe.g; + pPlayer->pals.b = pe.b; +} + void P_AddKills(DukePlayer_t * pPlayer, uint16_t kills); int32_t A_GetHitscanRange(int spriteNum); void P_GetInput(int playerNum); @@ -367,7 +388,12 @@ void P_GetInputBoat(int playerNum); void sub_299C0(void); void P_DHGetInput(int const playerNum); void P_AddAmmo(DukePlayer_t * pPlayer, int weaponNum, int addAmount); +inline void addammo(int weaponNum, DukePlayer_t* pPlayer, int addAmount) +{ + P_AddAmmo(pPlayer, weaponNum, addAmount); +} void P_AddWeapon(DukePlayer_t *pPlayer, int weaponNum); +void addweapon(DukePlayer_t* pPlayer, int weaponNum); void P_CheckWeapon(DukePlayer_t *pPlayer); void P_DisplayScuba(void); void P_DisplayWeapon(void); diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 23c655e7c..29dab7e28 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -37,6 +37,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS +void lava_cleararrays(); +void addjaildoor(int p1, int p2, int iht, int jlt, int p3, int h); +void addminecart(int p1, int p2, int i, int iht, int p3, int childsectnum); +void addtorch(int i); +void addlightning(int i); + + static int32_t g_whichPalForPlayer = 9; static uint8_t precachehightile[2][MAXTILES>>3]; @@ -1001,7 +1008,7 @@ void P_ResetStatus(int playerNum) pPlayer->drug_stat[2] = 0; pPlayer->drug_aspect = 0; } - A_ResetLanePics(); + resetlanepics(); if (!g_netServer && numplayers < 2) { g_ufoSpawn = min(RRRA ? 3 : (ud.m_player_skill*4+1), 32); @@ -1092,7 +1099,7 @@ void P_ResetInventory(int playerNum) pPlayer->hbomb_offset = 0; pPlayer->recoil = 0; pPlayer->yehaa_timer = 0; - A_ResetLanePics(); + resetlanepics(); if (!g_netServer && numplayers < 2) { g_ufoSpawn = min(ud.m_player_skill*4+1, 32); @@ -1211,7 +1218,7 @@ static void resetprestat(int playerNum, int gameMode) pPlayer->hbomb_offset = 0; pPlayer->recoil = 0; pPlayer->yehaa_timer = 0; - A_ResetLanePics(); + resetlanepics(); if (!g_netServer && numplayers < 2) { g_ufoSpawn = min(ud.m_player_skill*4+1, 32); @@ -1268,10 +1275,9 @@ static void prelevel(char g) { G_SetFog(0); g_fogType = 0; - g_ufoSpawnMinion = 0; + ufospawnsminion = 0; g_pistonSound = 0; - g_slotWin = 0; - g_changeEnemySize = 0; + enemysizecheat = 0; g_player[myconnectindex].ps->level_end_timer = 0; g_mamaSpawnCnt = 15; g_banjoSong = 0; @@ -1282,6 +1288,7 @@ static void prelevel(char g) { DukePlayer_t *ps = g_player[playerNum].ps; ps->sea_sick_stat = 0; + ps->SlotWin = 0; if (ud.level_number == 4 && ud.volume_number == 1) ps->inv_amount[GET_STEROIDS] = 0; } @@ -1308,11 +1315,8 @@ static void prelevel(char g) resetprestat(0,g); if (RR) { - g_lightninCnt = 0; - g_torchCnt = 0; + lava_cleararrays(); g_geoSectorCnt = 0; - g_jailDoorCnt = 0; - g_mineCartCnt = 0; g_ambientCnt = 0; g_thunderOn = 0; g_chickenPlant = 0; @@ -1382,24 +1386,15 @@ static void prelevel(char g) { if (sector[i].hitag == sector[j].hitag && i != j) { - if (g_jailDoorCnt >= 32) - G_GameExit("\nToo many jaildoor sectors"); - g_jailDoorDist[g_jailDoorCnt] = p1; - g_jailDoorSpeed[g_jailDoorCnt] = p2; - g_jailDoorSecHitag[g_jailDoorCnt] = sector[i].hitag; - g_jailDoorSect[g_jailDoorCnt] = j; - g_jailDoorDrag[g_jailDoorCnt] = 0; - g_jailDoorOpen[g_jailDoorCnt] = 0; - g_jailDoorDir[g_jailDoorCnt] = sector[j].lotag; - g_jailDoorSound[g_jailDoorCnt] = p3; - g_jailDoorCnt++; - } + addjaildoor(p1, p2, sector[i].hitag, sector[j].lotag, p3, j); + } } break; } case 42: { if (!RR) break; + int childsectnum = -1; int k = headspritesect[i]; while (k != -1) { @@ -1413,7 +1408,7 @@ static void prelevel(char g) if (sprite[kk].picnum == TILE_RRTILE66) if (sprite[kk].lotag == sprite[k].sectnum) { - g_mineCartChildSect[g_mineCartCnt] = sprite[kk].sectnum; + childsectnum = sprite[kk].sectnum; A_DeleteSprite(kk); } } @@ -1426,16 +1421,7 @@ static void prelevel(char g) } k = nexti; } - if (g_mineCartCnt >= 16) - G_GameExit("\nToo many minecart sectors"); - g_mineCartDist[g_mineCartCnt] = p1; - g_mineCartSpeed[g_mineCartCnt] = p2; - g_mineCartSect[g_mineCartCnt] = i; - g_mineCartDir[g_mineCartCnt] = sector[i].hitag; - g_mineCartDrag[g_mineCartCnt] = p1; - g_mineCartOpen[g_mineCartCnt] = 1; - g_mineCartSound[g_mineCartCnt] = p3; - g_mineCartCnt++; + addminecart(p1, p2, i, sector[i].hitag, p3, childsectnum); break; } case ST_20_CEILING_DOOR: @@ -1523,21 +1509,12 @@ static void prelevel(char g) case RRTILE18__STATICRR: if (!RR) break; - if (g_torchCnt >= 64) - G_GameExit("\nToo many torch effects"); - g_torchSector[g_torchCnt] = SECT(i); - g_torchSectorShade[g_torchCnt] = sector[SECT(i)].floorshade; - g_torchType[g_torchCnt] = SLT(i); - g_torchCnt++; + addtorch(i); A_DeleteSprite(i); break; case RRTILE35__STATICRR: - if (g_lightninCnt >= 64) - G_GameExit("\nToo many lightnin effects"); - g_lightninSector[g_lightninCnt] = SECT(i); - g_lightninSectorShade[g_lightninCnt] = sector[SECT(i)].floorshade; - g_lightninCnt++; + addlightning(i); A_DeleteSprite(i); break; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index e4d6c70bc..7d0777648 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -901,28 +901,8 @@ static const dataspec_t svgm_anmisc[] = { 0, &g_spriteExtra[0], sizeof(g_spriteExtra[0]), MAXSPRITES }, { 0, &g_sectorExtra[0], sizeof(g_sectorExtra[0]), MAXSECTORS }, - { 0, &g_jailDoorSecHitag[0], sizeof(g_jailDoorSecHitag[0]), ARRAY_SIZE(g_jailDoorSecHitag) }, - { 0, &g_jailDoorSect[0], sizeof(g_jailDoorSect[0]), ARRAY_SIZE(g_jailDoorSect) }, - { 0, &g_jailDoorOpen[0], sizeof(g_jailDoorOpen[0]), ARRAY_SIZE(g_jailDoorOpen) }, - { 0, &g_jailDoorDir[0], sizeof(g_jailDoorDir[0]), ARRAY_SIZE(g_jailDoorDir) }, - { 0, &g_jailDoorDrag[0], sizeof(g_jailDoorDrag[0]), ARRAY_SIZE(g_jailDoorDrag) }, - { 0, &g_jailDoorDist[0], sizeof(g_jailDoorDist[0]), ARRAY_SIZE(g_jailDoorDist) }, - { 0, &g_jailDoorSpeed[0], sizeof(g_jailDoorSpeed[0]), ARRAY_SIZE(g_jailDoorSpeed) }, - { 0, &g_jailDoorSound[0], sizeof(g_jailDoorSound[0]), ARRAY_SIZE(g_jailDoorSound) }, - { 0, &g_jailDoorCnt, sizeof(g_jailDoorCnt), 1 }, - { 0, &g_shadedSector[0], sizeof(g_shadedSector[0]), MAXSECTORS }, - { 0, &g_mineCartSect[0], sizeof(g_mineCartSect[0]), ARRAY_SIZE(g_mineCartSect) }, - { 0, &g_mineCartChildSect[0], sizeof(g_mineCartChildSect[0]), ARRAY_SIZE(g_mineCartChildSect) }, - { 0, &g_mineCartOpen[0], sizeof(g_mineCartOpen[0]), ARRAY_SIZE(g_mineCartOpen) }, - { 0, &g_mineCartDir[0], sizeof(g_mineCartDir[0]), ARRAY_SIZE(g_mineCartDir) }, - { 0, &g_mineCartDrag[0], sizeof(g_mineCartDrag[0]), ARRAY_SIZE(g_mineCartDrag) }, - { 0, &g_mineCartDist[0], sizeof(g_mineCartDist[0]), ARRAY_SIZE(g_mineCartDist) }, - { 0, &g_mineCartSpeed[0], sizeof(g_mineCartSpeed[0]), ARRAY_SIZE(g_mineCartSpeed) }, - { 0, &g_mineCartSound[0], sizeof(g_mineCartSound[0]), ARRAY_SIZE(g_mineCartSound) }, - { 0, &g_mineCartCnt, sizeof(g_mineCartCnt), 1 }, - { 0, &g_ambientCnt, sizeof(g_ambientCnt), 1 }, { 0, &g_ambientHitag[0], sizeof(g_ambientHitag[0]), ARRAY_SIZE(g_ambientHitag) }, { 0, &g_ambientLotag[0], sizeof(g_ambientLotag[0]), ARRAY_SIZE(g_ambientLotag) }, @@ -932,15 +912,6 @@ static const dataspec_t svgm_anmisc[] = { 0, &g_hulkSpawn, sizeof(g_hulkSpawn), 1 }, { 0, &g_lastLevel, sizeof(g_lastLevel), 1 }, - { 0, &g_torchSector[0], sizeof(g_torchSector[0]), ARRAY_SIZE(g_torchSector) }, - { 0, &g_torchSectorShade[0], sizeof(g_torchSectorShade[0]), ARRAY_SIZE(g_torchSectorShade) }, - { 0, &g_torchType[0], sizeof(g_torchType[0]), ARRAY_SIZE(g_torchType) }, - { 0, &g_torchCnt, sizeof(g_torchCnt), 1 }, - - { 0, &g_lightninSector[0], sizeof(g_lightninSector[0]), ARRAY_SIZE(g_lightninSector) }, - { 0, &g_lightninSectorShade[0], sizeof(g_lightninSectorShade[0]), ARRAY_SIZE(g_lightninSectorShade) }, - { 0, &g_lightninCnt, sizeof(g_lightninCnt), 1 }, - { 0, &g_geoSector[0], sizeof(g_geoSector[0]), ARRAY_SIZE(g_geoSector) }, { 0, &g_geoSectorWarp[0], sizeof(g_geoSectorWarp[0]), ARRAY_SIZE(g_geoSectorWarp) }, { 0, &g_geoSectorX[0], sizeof(g_geoSectorX[0]), ARRAY_SIZE(g_geoSectorX) }, @@ -958,9 +929,8 @@ static const dataspec_t svgm_anmisc[] = { 0, &g_bellTime, sizeof(g_bellTime), 1 }, { 0, &g_bellSprite, sizeof(g_bellSprite), 1 }, - { 0, &g_changeEnemySize, sizeof(g_changeEnemySize), 1 }, - { 0, &g_slotWin, sizeof(g_slotWin), 1 }, - { 0, &g_ufoSpawnMinion, sizeof(g_ufoSpawnMinion), 1 }, + { 0, &enemysizecheat, sizeof(enemysizecheat), 1 }, + { 0, &ufospawnsminion, sizeof(ufospawnsminion), 1 }, { 0, &g_pistonSound, sizeof(g_pistonSound), 1 }, { 0, &g_chickenWeaponTimer, sizeof(g_chickenWeaponTimer), 1 }, { 0, &g_RAendLevel, sizeof(g_RAendLevel), 1 }, diff --git a/source/games/duke/src/sector.cpp b/source/games/duke/src/sector.cpp index 8e0bf7001..0db867268 100644 --- a/source/games/duke/src/sector.cpp +++ b/source/games/duke/src/sector.cpp @@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS // PRIMITIVE +void operatejaildoors(int hitag); static int g_haltSoundHack = 0; @@ -682,26 +683,7 @@ void G_OperateSectors(int sectNum, int spriteNum) { case 41: if (!RR) break; - for (bsize_t i = 0; i < g_jailDoorCnt; i++) - { - if (g_jailDoorSecHitag[i] == pSector->hitag) - { - if (g_jailDoorOpen[i] == 0) - { - g_jailDoorOpen[i] = 1; - g_jailDoorDrag[i] = g_jailDoorDist[i]; - if (!RRRA || g_jailDoorSound[i] != 0) - A_CallSound2(g_jailDoorSound[i], screenpeek); - } - if (g_jailDoorOpen[i] == 2) - { - g_jailDoorOpen[i] = 3; - g_jailDoorDrag[i] = g_jailDoorDist[i]; - if (!RRRA || g_jailDoorSound[i] != 0) - A_CallSound2(g_jailDoorSound[i], screenpeek); - } - } - } + operatejaildoors(pSector->hitag); break; case 7: { @@ -4919,418 +4901,5 @@ void G_DoFurniture(int wallNum, int sectNum, int playerNum) } } -void G_DoTorch(void) -{ - int j; - int startWall, endWall; - int randNum = rand()&8; - for (bsize_t i = 0; i < g_torchCnt; i++) - { - int shade = g_torchSectorShade[i] - randNum; - switch (g_torchType[i]) - { - case 0: - sector[g_torchSector[i]].floorshade = shade; - sector[g_torchSector[i]].ceilingshade = shade; - break; - case 1: - sector[g_torchSector[i]].ceilingshade = shade; - break; - case 2: - sector[g_torchSector[i]].floorshade = shade; - break; - case 4: - sector[g_torchSector[i]].ceilingshade = shade; - break; - case 5: - sector[g_torchSector[i]].floorshade = shade; - break; - } - startWall = sector[g_torchSector[i]].wallptr; - endWall = startWall + sector[g_torchSector[i]].wallnum - 1; - for (j = startWall; j <= endWall; j++) - { - if (wall[j].lotag != 1) - { - switch (g_torchType[i]) - { - case 0: - wall[j].shade = shade; - break; - case 1: - wall[j].shade = shade; - break; - case 2: - wall[j].shade = shade; - break; - case 3: - wall[j].shade = shade; - break; - } - } - } - } -} - -void G_DoJailDoor(void) -{ - int j; - int32_t speed; - int startWall, endWall; - for (bsize_t i = 0; i < g_jailDoorCnt; i++) - { - speed = g_jailDoorSpeed[i]; - if (speed < 2) - speed = 2; - - if (g_jailDoorOpen[i] == 1) - { - g_jailDoorDrag[i] -= speed; - if (g_jailDoorDrag[i] <= 0) - { - g_jailDoorDrag[i] = 0; - g_jailDoorOpen[i] = 2; - switch (g_jailDoorDir[i]) - { - case 10: - g_jailDoorDir[i] = 30; - break; - case 20: - g_jailDoorDir[i] = 40; - break; - case 30: - g_jailDoorDir[i] = 10; - break; - case 40: - g_jailDoorDir[i] = 20; - break; - } - } - else - { - startWall = sector[g_jailDoorSect[i]].wallptr; - endWall = startWall + sector[g_jailDoorSect[i]].wallnum - 1; - for (j = startWall; j <= endWall; j++) - { - int32_t x, y; - x = wall[j].x; - y = wall[j].y; - switch (g_jailDoorDir[i]) - { - case 10: - y += speed; - break; - case 20: - x -= speed; - break; - case 30: - y -= speed; - break; - case 40: - x += speed; - break; - } - dragpoint(j, x, y, 0); - } - } - } - if (g_jailDoorOpen[i] == 3) - { - g_jailDoorDrag[i] -= speed; - if (g_jailDoorDrag[i] <= 0) - { - g_jailDoorDrag[i] = 0; - g_jailDoorOpen[i] = 0; - switch (g_jailDoorDir[i]) - { - case 10: - g_jailDoorDir[i] = 30; - break; - case 20: - g_jailDoorDir[i] = 40; - break; - case 30: - g_jailDoorDir[i] = 10; - break; - case 40: - g_jailDoorDir[i] = 20; - break; - } - } - else - { - startWall = sector[g_jailDoorSect[i]].wallptr; - endWall = startWall + sector[g_jailDoorSect[i]].wallnum - 1; - for (j = startWall; j <= endWall; j++) - { - int32_t x, y; - x = wall[j].x; - y = wall[j].y; - switch (g_jailDoorDir[i]) - { - case 10: - y += speed; - break; - case 20: - x -= speed; - break; - case 30: - y -= speed; - break; - case 40: - x += speed; - break; - } - dragpoint(j, x, y, 0); - } - } - } - } -} - -void G_MoveMineCart(void) -{ - int j, nextj; - int startWall, endWall; - int32_t speed; - int32_t max_x, min_x, max_y, min_y, cx, cy; - for (bsize_t i = 0; i < g_mineCartCnt; i++) - { - speed = g_mineCartSpeed[i]; - if (speed < 2) - speed = 2; - - if (g_mineCartOpen[i] == 1) - { - g_mineCartDrag[i] -= speed; - if (g_mineCartDrag[i] <= 0) - { - g_mineCartDrag[i] = g_mineCartDist[i]; - g_mineCartOpen[i] = 2; - switch (g_mineCartDir[i]) - { - case 10: - g_mineCartDir[i] = 30; - break; - case 20: - g_mineCartDir[i] = 40; - break; - case 30: - g_mineCartDir[i] = 10; - break; - case 40: - g_mineCartDir[i] = 20; - break; - } - } - else - { - startWall = sector[g_mineCartSect[i]].wallptr; - endWall = startWall + sector[g_mineCartSect[i]].wallnum - 1; - for (j = startWall; j <= endWall; j++) - { - int32_t x, y; - x = wall[j].x; - y = wall[j].y; - switch (g_mineCartDir[i]) - { - case 10: - y += speed; - break; - case 20: - x -= speed; - break; - case 30: - y -= speed; - break; - case 40: - x += speed; - break; - } - dragpoint(j, x, y, 0); - } - } - } - if (g_mineCartOpen[i] == 2) - { - g_mineCartDrag[i] -= speed; - if (g_mineCartDrag[i] <= 0) - { - g_mineCartDrag[i] = g_mineCartDist[i]; - g_mineCartOpen[i] = 1; - switch (g_mineCartDir[i]) - { - case 10: - g_mineCartDir[i] = 30; - break; - case 20: - g_mineCartDir[i] = 40; - break; - case 30: - g_mineCartDir[i] = 10; - break; - case 40: - g_mineCartDir[i] = 20; - break; - } - } - else - { - startWall = sector[g_mineCartSect[i]].wallptr; - endWall = startWall + sector[g_mineCartSect[i]].wallnum - 1; - for (j = startWall; j <= endWall; j++) - { - int32_t x, y; - x = wall[j].x; - y = wall[j].y; - switch (g_mineCartDir[i]) - { - case 10: - y += speed; - break; - case 20: - x -= speed; - break; - case 30: - y -= speed; - break; - case 40: - x += speed; - break; - } - dragpoint(j, x, y, 0); - } - } - } - startWall = sector[g_mineCartChildSect[i]].wallptr; - endWall = startWall + sector[g_mineCartChildSect[i]].wallnum - 1; - max_x = max_y = -(2<<16); - min_x = min_y = 2<<16; - for (j = startWall; j <= endWall; j++) - { - if (max_x < wall[j].x) - max_x = wall[j].x; - if (max_y < wall[j].y) - max_y = wall[j].y; - if (min_x > wall[j].x) - min_x = wall[j].x; - if (min_y > wall[j].y) - min_y = wall[j].y; - } - cx = (max_x + min_x) >> 1; - cy = (max_y + min_y) >> 1; - j = headspritesect[g_mineCartChildSect[i]]; - vec3_t pos; - pos.x = cx; - pos.y = cy; - while (j != -1) - { - nextj = nextspritesect[j]; - pos.z = sprite[j].z; - if (A_CheckEnemySprite(&sprite[j])) - setsprite(j,&pos); - j = nextj; - } - } -} - - -void G_Thunder(void) -{ - static int32_t brightness; - int j; - int startWall, endWall; - uint8_t shade; - bsize_t i = 0; - if (!g_thunderFlash) - { - if ((gotpic[TILE_RRTILE2577>>3]&(1<<(TILE_RRTILE2577&7)))) - { - gotpic[TILE_RRTILE2577>>3] &= ~(1<<(TILE_RRTILE2577&7)); - if (tilePtr(TILE_RRTILE2577) != nullptr) // why does this on texture load state??? - { - g_visibility = 256; - if (krand2() > 65000) - { - g_thunderTime = 256; - g_thunderFlash = 1; - S_PlaySound(351+(rand()%3)); - } - } - } - else - { - brightness = 0; - g_visibility = g_player[screenpeek].ps->visibility; - } - } - else - { - g_thunderTime -= 4; - if (g_thunderTime < 0) - { - brightness = 0; - g_thunderFlash = 0; - videoSetBrightness(0); - g_visibility = g_player[screenpeek].ps->visibility; - } - } - if (!g_winderFlash) - { - if ((gotpic[TILE_RRTILE2562>>3]&(1<<(TILE_RRTILE2562&7)))) - { - gotpic[TILE_RRTILE2562>>3] &= ~(1<<(TILE_RRTILE2562&7)); - if (tilePtr(TILE_RRTILE2562) != nullptr) // why does this on texture load state??? - { - if (krand2() > 65000) - { - g_winderTime = 128; - g_winderFlash = 1; - S_PlaySound(351+(rand()%3)); - } - } - } - } - else - { - g_winderFlash -= 4; - if (g_winderTime < 0) - { - g_winderFlash = 0; - for (i = 0; i < g_lightninCnt; i++) - { - sector[g_lightninSector[i]].floorshade = g_lightninSectorShade[i]; - sector[g_lightninSector[i]].ceilingshade = g_lightninSectorShade[i]; - startWall = sector[g_lightninSector[i]].wallptr; - endWall = startWall + sector[g_lightninSector[i]].wallnum - 1; - for (j = startWall; j <= endWall; j++) - wall[j].shade = g_lightninSectorShade[i]; - } - } - } - if (g_thunderFlash == 1) - { - brightness += krand2()&4; - g_visibility = 2048; - if (brightness > 8) - brightness = 0; - videoSetBrightness(brightness); - } - if (g_winderFlash == 1) - { - if (i >= MAXTORCHSECTORS) - i = MAXTORCHSECTORS - 1; - shade = g_torchSectorShade[i]+(krand2()&8); - for (i = 0; i < g_lightninCnt; i++) - { - sector[g_lightninSector[i]].floorshade = g_lightninSectorShade[i] - shade; - sector[g_lightninSector[i]].ceilingshade = g_lightninSectorShade[i] - shade; - startWall = sector[g_lightninSector[i]].wallptr; - endWall = startWall + sector[g_lightninSector[i]].wallnum - 1; - for (j = startWall; j <= endWall; j++) - wall[j].shade = g_lightninSectorShade[i] - shade; - } - } -} END_DUKE_NS diff --git a/source/games/duke/src/sector.h b/source/games/duke/src/sector.h index 113d8972d..1ec4a0063 100644 --- a/source/games/duke/src/sector.h +++ b/source/games/duke/src/sector.h @@ -146,6 +146,10 @@ inline void operateactivators(int l, int w) G_OperateActivators(l, w); } void G_OperateForceFields(int spriteNum,int wallTag); +inline void operateforcefields(int s, int w) +{ + G_OperateForceFields(s, w); +} void G_OperateMasterSwitches(int lotag); inline void operatemasterswitches(int l) { @@ -159,6 +163,10 @@ inline void operatesectors(int s, int i) } void P_HandleSharedKeys(int playerNum); int GetAnimationGoal(const int32_t *animPtr); +inline int getanimationgoal(const int32_t* animPtr) +{ + return GetAnimationGoal(animPtr); +} int isanearoperator(int lotag); int isanunderoperator(int lotag); int P_ActivateSwitch(int playerNum, int wallOrSprite, int nSwitchType); @@ -166,11 +174,12 @@ void P_CheckSectors(int playerNum); void Sect_DamageCeiling(int sectNum); inline void checkhitceiling(int sec) { Sect_DamageCeiling(sec); } int SetAnimation(int sectNum,int32_t *animPtr,int goalVal,int animVel); +inline int setanimation(int sectNum, int32_t* animPtr, int goalVal, int animVel) +{ + return SetAnimation(sectNum, animPtr, goalVal, animVel); +} void G_DoFurniture(int wallNum, int sectNum, int playerNum); -void G_DoTorch(void); -void G_DoJailDoor(void); -void G_MoveMineCart(void); -void G_Thunder(void); +void dotorch(); #define FORCEFIELD_CSTAT (64+16+4+1) diff --git a/source/games/duke/src/soundefs.h b/source/games/duke/src/soundefs.h index f72481312..a151c73aa 100644 --- a/source/games/duke/src/soundefs.h +++ b/source/games/duke/src/soundefs.h @@ -416,3 +416,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define BELLSND 395 #define GOAWAY 396 #define JOKE 397 +#define FLAMETHROWER_INTRO 398 +#define FLAMETHROWER_LOOP 399 +#define FLAMETHROWER_END= 400 +#define E5L7_DUKE_QUIT_YOU 401 + \ No newline at end of file diff --git a/source/games/duke/src/sounds.h b/source/games/duke/src/sounds.h index a8dcb18fc..5aed76d65 100644 --- a/source/games/duke/src/sounds.h +++ b/source/games/duke/src/sounds.h @@ -68,6 +68,10 @@ int S_TryPlaySpecialMusic(unsigned int); void S_PlaySpecialMusicOrNothing(unsigned int); void S_ContinueLevelMusic(void); int S_PlaySound(int num, int channel = CHAN_AUTO, EChanFlags flags = 0); +inline int sound(int num) +{ + return S_PlaySound(num); +} int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos, int channel = CHAN_AUTO, EChanFlags flags = 0); void S_StopEnvSound(int sndNum,int sprNum, int flags = -1); void S_Update(void);