From a2e3bb57259e4a6475938dc50ac0568c5ce3454e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 7 Sep 2020 21:38:17 +0200 Subject: [PATCH] - fixed WT's incinerator and a few other minor things I found while comparing Raze's WT support code with BuildGDX's. Fixes #357 --- source/games/duke/src/actors_d.cpp | 10 ++++++---- source/games/duke/src/constants.h | 1 + source/games/duke/src/flags_d.cpp | 3 ++- source/games/duke/src/inlines.h | 10 ++++++++++ source/games/duke/src/player_d.cpp | 19 ++++++++++++++++++- source/games/duke/src/sectors_d.cpp | 16 +++++++++++++++- source/games/duke/src/spawn_d.cpp | 8 ++++++++ 7 files changed, 60 insertions(+), 7 deletions(-) diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 5c11e588e..2045325d4 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -491,7 +491,7 @@ SKIPWALLCHECK: hittype[j].extra = hp1 + (krand() % (hp2 - hp1)); } - if (sprite[j].picnum != TANK && sprite[j].picnum != ROTATEGUN && sprite[j].picnum != RECON && sprite[j].picnum != BOSS1 && sprite[j].picnum != BOSS2 && sprite[j].picnum != BOSS3 && sprite[j].picnum != BOSS4) + if (sprite[j].picnum != TANK && sprite[j].picnum != ROTATEGUN && sprite[j].picnum != RECON && !bossguy(&sprite[j])) { if (sj->xvel < 0) sj->xvel = 0; sj->xvel += (s->extra << 2); @@ -2807,6 +2807,8 @@ static void flamethrowerflame(int i) int dax = s->x; int day = s->y; int daz = s->z; + int xvel = s->xvel; + int zvel = s->zvel; getglobalz(i); @@ -2823,8 +2825,8 @@ static void flamethrowerflame(int i) return; } - j = fi.movesprite(i, (s->xvel * (sintable[(s->ang + 512) & 2047])) >> 14, - (s->xvel * (sintable[s->ang & 2047])) >> 14, s->zvel, CLIPMASK1); + j = fi.movesprite(i, (xvel * (sintable[(s->ang + 512) & 2047])) >> 14, + (xvel * (sintable[s->ang & 2047])) >> 14, s->zvel, CLIPMASK1); if (s->sectnum < 0) { @@ -2849,7 +2851,7 @@ static void flamethrowerflame(int i) } if (j != 0) { - s->xvel = s->yvel = 0; + s->xvel = s->yvel = s->zvel = 0; if ((j & kHitTypeMask) == kHitSprite) { j &= (MAXSPRITES - 1); diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index b0c8bc45e..29c436434 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -301,6 +301,7 @@ enum sflags_t SFLAG_BADGUY = 0x00000020, SFLAG_NOPAL = 0x00000040, SFLAG_FORCEAUTOAIM = 0x00000080, + SFLAG_BOSS = 0x00000100, SFLAG_USEACTIVATOR = 0x00000200, SFLAG_NOFLOORSHADOW = 0x00001000, // for temp. internal use, per-tile flag not checked SFLAG_BADGUYSTAYPUT = 0x00008000, diff --git a/source/games/duke/src/flags_d.cpp b/source/games/duke/src/flags_d.cpp index 85682bf7a..3332f1e45 100644 --- a/source/games/duke/src/flags_d.cpp +++ b/source/games/duke/src/flags_d.cpp @@ -81,13 +81,14 @@ void initactorflags_d() // Some flags taken from RedNukem's init code. This is a good start as any to reduce the insane dependency on tile numbers for making decisions in the play code. A lot more will be added here later. setflag(SFLAG_NODAMAGEPUSH, { TANK, BOSS1, BOSS2, BOSS3, BOSS4, RECON, ROTATEGUN }); + setflag(SFLAG_BOSS, { BOSS1, BOSS2, BOSS3, BOSS4 }); setflag(SFLAG_NOWATERDIP, { OCTABRAIN, COMMANDER, DRONE }); setflag(SFLAG_GREENSLIMEFOOD, { LIZTROOP, LIZMAN, PIGCOP, NEWBEAST }); if (isWorldTour()) { setflag(SFLAG_INTERNAL_BADGUY, { FIREFLY }); - setflag(SFLAG_INTERNAL_BADGUY|SFLAG_NODAMAGEPUSH, { BOSS5, BOSS5STAYPUT, BOSS2STAYPUT, BOSS3STAYPUT }); + setflag(SFLAG_INTERNAL_BADGUY|SFLAG_NODAMAGEPUSH|SFLAG_BOSS, { BOSS5 }); } settileflag(TFLAG_WALLSWITCH, { diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 0b7732a28..c6d7e428d 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -27,6 +27,16 @@ inline int badguy(void const * const pSprite) return badguypic(((uspritetype const *) pSprite)->picnum); } +inline int bossguypic(int const tileNum) +{ + return ((actorinfo[tileNum].flags & (SFLAG_BOSS)) != 0); +} + +inline int bossguy(void const* const pSprite) +{ + return badguypic(((uspritetype const*)pSprite)->picnum); +} + inline int actorflag(int spritenum, int mask) { return (((actorinfo[sprite[spritenum].picnum].flags/* ^ hittype[spritenum].flags*/) & mask) != 0); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 4e96eb1cc..71142a5f4 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -158,7 +158,7 @@ void shoot_d(int i, int atwith) } else { - zvel = 98 * (100 + ps[p].gethorizsum()); + zvel = 98 * (100 - ps[p].gethorizsum()); sx += sintable[(sa + 860) & 0x7FF] / 448; sy += sintable[(sa + 348) & 0x7FF] / 448; sz += (3 << 8); @@ -849,11 +849,28 @@ void shoot_d(int i, int atwith) } else if (s->picnum == BOSS2) { + int xoffs = sintable[sa & 2047] / 56; + int yoffs = sintable[(sa + 1024 + 512) & 2047] / 56; + int aoffs = 8 + (krand() & 255) - 128; + + if (isWorldTour()) { // Twentieth Anniversary World Tour + int siz = sprite[i].yrepeat; + xoffs = Scale(xoffs, siz, 80); + yoffs = Scale(yoffs, siz, 80); + aoffs = Scale(aoffs, siz, 80); + } + + sprite[j].x -= xoffs; + sprite[j].y -= yoffs; + sprite[j].ang -= aoffs; + sprite[j].x -= sintable[sa & 2047] / 56; sprite[j].y -= sintable[(sa + 1024 + 512) & 2047] / 56; sprite[j].ang -= 8 + (krand() & 255) - 128; sprite[j].xrepeat = 24; sprite[j].yrepeat = 24; + + } else if (atwith != FREEZEBLAST) { diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index d7cc97477..afad2d096 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1381,6 +1381,9 @@ void checkhitsprite_d(int i, int sn) { if (badguy(&sprite[i]) == 1) { + if (isWorldTour() && sprite[i].picnum == FIREFLY && sprite[i].xrepeat < 48) + break; + if (sprite[sn].picnum == RPG) sprite[sn].extra <<= 1; if ((sprite[i].picnum != DRONE) && (sprite[i].picnum != ROTATEGUN) && (sprite[i].picnum != COMMANDER) && (sprite[i].picnum < GREENSLIME || sprite[i].picnum > GREENSLIME + 7)) @@ -1407,7 +1410,7 @@ void checkhitsprite_d(int i, int sn) fi.shoot(i, BLOODSPLAT4); } - if (sprite[i].picnum != TANK && sprite[i].picnum != BOSS1 && sprite[i].picnum != BOSS4 && sprite[i].picnum != BOSS2 && sprite[i].picnum != BOSS3 && sprite[i].picnum != RECON && sprite[i].picnum != ROTATEGUN) + if (sprite[i].picnum != TANK && !bossguy(&sprite[i]) && sprite[i].picnum != RECON && sprite[i].picnum != ROTATEGUN) { if ((sprite[i].cstat & 48) == 0) sprite[i].ang = (sprite[sn].ang + 1024) & 2047; @@ -1431,6 +1434,17 @@ void checkhitsprite_d(int i, int sn) if (sprite[sn].picnum == FREEZEBLAST && ((sprite[i].picnum == APLAYER && sprite[i].pal == 1) || (freezerhurtowner == 0 && sprite[sn].owner == i))) return; + + int hitpic = sprite[sn].picnum; + if (sprite[sprite[sn].owner].picnum == APLAYER) + { + if (sprite[i].picnum == APLAYER && ud.coop != 0 && ud.ffire == 0) + return; + + if (isWorldTour() && hitpic == FIREBALL && sprite[sprite[i].owner].picnum != FIREBALL) + hitpic = FLAMETHROWERFLAME; + } + hittype[i].picnum = sprite[sn].picnum; hittype[i].extra += sprite[sn].extra; hittype[i].ang = sprite[sn].ang; diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 9316b1724..24a2a1298 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -624,6 +624,14 @@ int spawn_d(int j, int pn) sp->z = x-(12<<8); } + if (sp->picnum == ONFIRE) + { + sp->x += krand() % 256 - 128; + sp->y += krand() % 256 - 128; + sp->z -= krand() % 10240; + sp->cstat |= 0x80; + } + changespritestat(i,5); break;