From f9e5f2c1379ebe7833048e3d7ae7abea01f66bc6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 14 Dec 2022 20:27:19 +0100 Subject: [PATCH] - final clenaup on animatesprites_d.cpp. Only the player actor is left, which is also the messiest part... --- source/games/duke/src/animatesprites_d.cpp | 56 +++---------------- source/games/duke/src/animatesprites_r.cpp | 44 +++------------ source/games/duke/src/namelist_d.h | 5 ++ source/games/duke/src/namelist_r.h | 2 + .../filter/dukelike/rmapinfo.spawnclasses | 4 +- .../filter/redneck/rmapinfo.spawnclasses | 3 +- .../games/duke/actors/_placeholders.zs | 20 ++++++- .../zscript/games/duke/actors/dukeitems.zs | 16 ++++++ .../zscript/games/duke/world/dukebreak.zs | 2 +- 9 files changed, 64 insertions(+), 88 deletions(-) diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 6ac400fc5..64b562228 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -47,7 +47,7 @@ BEGIN_DUKE_NS void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle viewang, double interpfrac) { - int k, p; + int p; int t1, t3, t4; tspritetype* t; DDukeActor* h; @@ -59,7 +59,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi if (!actorflag(h, SFLAG2_FORCESECTORSHADE) && ((t->cstat & CSTAT_SPRITE_ALIGNMENT_WALL)) || (badguypic(t->picnum) && t->extra > 0) || t->statnum == STAT_PLAYER) { - if (h->sector()->shadedsector == 1 && h->spr.statnum != 1) + if (h->sector()->shadedsector == 1 && h->spr.statnum != STAT_ACTOR) { t->shade = 16; } @@ -121,13 +121,8 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi t3 = h->temp_data[3]; t4 = h->temp_data[4]; - switch (h->spr.picnum) + if (h->spr.picnum == DTILE_APLAYER) { - case DTILE_GROWSPARK: - t->picnum = DTILE_GROWSPARK + ((PlayClock >> 4) & 3); - break; - case DTILE_APLAYER: - p = h->PlayerIndex(); if (t->pal == 1) t->pos.Z -= 18; @@ -171,7 +166,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi case FREEZE_WEAPON: newtspr->picnum = DTILE_FREEZESPRITE; break; case FLAMETHROWER_WEAPON: //Twentieth Anniversary World Tour if (isWorldTour()) - newtspr->picnum = DTILE_FLAMETHROWERSPRITE; + newtspr->picnum = DTILE_FLAMETHROWERSPRITE; break; case DEVISTATOR_WEAPON: newtspr->picnum = DTILE_DEVISTATORSPRITE; break; } @@ -191,31 +186,14 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi if (!h->GetOwner()) { - if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal)) - { - k = 0; - t->cstat &= ~CSTAT_SPRITE_XFLIP; - } - else - { - k = angletorotation1(t->Angles.Yaw, viewang); - if (k > 4) - { - k = 8 - k; - t->cstat |= CSTAT_SPRITE_XFLIP; - } - else t->cstat &= ~CSTAT_SPRITE_XFLIP; - } + applyRotation1(h, t, viewang); - if (t->sectp->lotag == 2) k += 1795 - 1405; - else if ((h->floorz - h->spr.pos.Z) > 64) k += 60; + if (t->sectp->lotag == ST_2_UNDERWATER) t->picnum += DTILE_APLAYERSWIMMING - DTILE_APLAYER; + else if ((h->floorz - h->spr.pos.Z) > 64) t->picnum += DTILE_APLAYERJUMP - DTILE_APLAYER; - t->picnum += k; t->pal = ps[p].palookup; - - goto PALONLY; + continue; } - if (ps[p].on_crane == nullptr && (h->sector()->lotag & 0x7ff) != 1) { double v = h->spr.pos.Z - ps[p].GetActor()->floorz + 3; @@ -240,23 +218,13 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi continue; } - PALONLY: if (sectp->floorpal) copyfloorpal(t, sectp); - if (!h->GetOwner()) continue; - if (t->pos.Z > h->floorz && t->scale.X < 0.5) t->pos.Z = h->floorz; - break; - - default: - - if (sectp->floorpal && !actorflag(h, SFLAG2_NOFLOORPAL)) - copyfloorpal(t, sectp); - break; } applyanimations(t, h, viewVec, viewang); @@ -271,14 +239,6 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi } } - switch (h->spr.picnum) - { - case DTILE_GROWSPARK: - case DTILE_CHAINGUN: - t->shade = -127; - break; - } - h->dispicnum = t->picnum; if (t->sectp->floortexture == mirrortex) t->scale = DVector2(0, 0); diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index f11ef117e..c49361518 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -121,9 +121,6 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi switch (h->spr.picnum) { - case RTILE_CRYSTALAMMO: - t->shade = int(BobVal(PlayClock << 4) * 16); - break; case RTILE_APLAYER: p = h->PlayerIndex(); @@ -191,30 +188,14 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi if (!h->GetOwner()) { - if (hw_models && modelManager.CheckModel(h->spr.picnum, h->spr.pal)) - { - k = 0; - t->cstat &= ~CSTAT_SPRITE_XFLIP; - } else - { - k = angletorotation1(t->Angles.Yaw, viewang); - if (k > 4) - { - k = 8 - k; - t->cstat |= CSTAT_SPRITE_XFLIP; - } - else t->cstat &= ~CSTAT_SPRITE_XFLIP; - } + applyRotation1(h, t, viewang); - if (t->sectp->lotag == 2) k += 1795 - 1405; - else if ((h->floorz - h->spr.pos.Z) > 64) k += 60; + if (t->sectp->lotag == ST_2_UNDERWATER) t->picnum += RTILE_APLAYERSWIMMING - RTILE_APLAYER; + else if ((h->floorz - h->spr.pos.Z) > 64) t->picnum += RTILE_APLAYERJUMP - RTILE_APLAYER; - t->picnum += k; t->pal = ps[p].palookup; - - goto PALONLY; + continue; } - if (ps[p].on_crane == nullptr && (h->sector()->lotag & 0x7ff) != 1) { double v = h->spr.pos.Z - ps[p].GetActor()->floorz + 3; @@ -239,13 +220,6 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi continue; } - PALONLY: - - if (sectp->floorpal) - copyfloorpal(t, sectp); - - if (!h->GetOwner()) continue; - if (t->pos.Z > h->floorz && t->scale.X < 0.5) t->pos.Z = h->floorz; @@ -300,12 +274,6 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi } break; - - default: - - if (sectp->floorpal) - copyfloorpal(t, sectp); - break; } applyanimations(t, h, viewVec, viewang); @@ -317,6 +285,10 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi switch (h->spr.picnum) { + case RTILE_CRYSTALAMMO: + t->shade = int(BobVal(PlayClock << 4) * 16); + break; + case RTILE_SBMOVE: if (!isRRRA()) t->shade = -127; diff --git a/source/games/duke/src/namelist_d.h b/source/games/duke/src/namelist_d.h index c7fcd63f2..f18b3b89c 100644 --- a/source/games/duke/src/namelist_d.h +++ b/source/games/duke/src/namelist_d.h @@ -445,6 +445,7 @@ x(APLAYERTOP, 1400) x(APLAYER, 1405) x(PLAYERONWATER, 1420) x(PLAYERWALK, 1426) +x(APLAYERJUMP, 1465) x(DUKELYINGDEAD, 1518) x(DUKETORSO, 1520) x(DUKEGUN, 1528) @@ -480,6 +481,7 @@ x(LIZTROOPDUCKING, 1744) x(HEADJIB1, 1768) x(ARMJIB1, 1772) x(LEGJIB1, 1776) +x(APLAYERSWIMMING, 1795) x(CANNONBALL, 1817) x(OCTABRAIN, 1820) x(OCTABRAINSTAYPUT, 1821) @@ -599,6 +601,9 @@ x(F1HELP, 2445) x(NOTCHON, 2446) x(NOTCHOFF, 2447) x(GROWSPARK, 2448) +x(GROWSPARK1, 2440) +x(GROWSPARK2, 2450) +x(GROWSPARK3, 2451) x(DUKEICON, 2452) x(BADGUYICON, 2453) x(FOODICON, 2454) diff --git a/source/games/duke/src/namelist_r.h b/source/games/duke/src/namelist_r.h index 54c8caeed..5f16e4890 100644 --- a/source/games/duke/src/namelist_r.h +++ b/source/games/duke/src/namelist_r.h @@ -1097,6 +1097,8 @@ x(APLAYERTOP, 3840) x(APLAYER, 3845) x(PLAYERWALK, 3846) x(PLAYERONWATER, 3860) +x(APLAYERJUMP, 3905) +x(APLAYERSWIMMING, 3845 + 390) x(DUKELYINGDEAD, 3998) x(DUKEGUN, 4041) x(DUKETORSO, 4046) diff --git a/wadsrc/static/filter/dukelike/rmapinfo.spawnclasses b/wadsrc/static/filter/dukelike/rmapinfo.spawnclasses index 71d6fbc7c..357289030 100644 --- a/wadsrc/static/filter/dukelike/rmapinfo.spawnclasses +++ b/wadsrc/static/filter/dukelike/rmapinfo.spawnclasses @@ -11,7 +11,8 @@ spawnclasses 9 = DukeRespawnController 10 = DukeGPSpeed 4890 = DukeNaturalLightning - 2536 = DukeChaingun + 2613 = DukeShotgunShot + 2536 = DukeChaingunShot 1221 = DukeCranePole 1222 = DukeCrane @@ -254,6 +255,7 @@ spawnclasses 762 = DukeMike 1518 = DukePlayerLyingDead 1420 = DukePlayerOnWater + 2448 = DukeGrowSpark 46 = DukeCrystalAmmo 55 = DukeSteroids diff --git a/wadsrc/static/filter/redneck/rmapinfo.spawnclasses b/wadsrc/static/filter/redneck/rmapinfo.spawnclasses index 81530acfb..26b9788e0 100644 --- a/wadsrc/static/filter/redneck/rmapinfo.spawnclasses +++ b/wadsrc/static/filter/redneck/rmapinfo.spawnclasses @@ -24,7 +24,8 @@ spawnclasses 38 = RedneckJaildoorSound 19 = RedneckGeometryEffect 34 = RedneckKeyinfoSetter - 3380 = DukeChaingun + 3380 = RedneckChaingunShot + 3350 = RedneckShotgunShot 1298 = DukeCranePole 1299 = DukeCrane diff --git a/wadsrc/static/zscript/games/duke/actors/_placeholders.zs b/wadsrc/static/zscript/games/duke/actors/_placeholders.zs index cc3e4f3b3..bf4ac7230 100644 --- a/wadsrc/static/zscript/games/duke/actors/_placeholders.zs +++ b/wadsrc/static/zscript/games/duke/actors/_placeholders.zs @@ -1,6 +1,20 @@ // dummy items representing certain weapons -class DukeChaingun : DukeActor + +class DukeShotgunShot : DukeActor +{ + default + { + pic "SHOTGUN"; + } +} + +class RedneckShotgunShot : DukeShotgunShot +{ +} + + +class DukeChaingunShot : DukeActor { default { @@ -8,6 +22,10 @@ class DukeChaingun : DukeActor } } +class RedneckChaingunShot : DukeChaingunShot +{ +} + class DukeSectorEffector : DukeActor { //This never gets ticked, the handler goes directly to the native implementations. diff --git a/wadsrc/static/zscript/games/duke/actors/dukeitems.zs b/wadsrc/static/zscript/games/duke/actors/dukeitems.zs index 6cb58e83a..9b66e22f8 100644 --- a/wadsrc/static/zscript/games/duke/actors/dukeitems.zs +++ b/wadsrc/static/zscript/games/duke/actors/dukeitems.zs @@ -261,3 +261,19 @@ class DukeAccessCard : DukeItemBase } } + +class DukeGrowSpark : DukeActor +{ + default + { + spriteset "GROWSPARK", "GROWSPARK1", "GROWSPARK2", "GROWSPARK3"; + } + + override bool animate(tspritetype t) + { + t.setSpritePic(self, (PlayClock >> 4) & 3); + t.shade = -127; + return true; + } +} + diff --git a/wadsrc/static/zscript/games/duke/world/dukebreak.zs b/wadsrc/static/zscript/games/duke/world/dukebreak.zs index b681de328..d42e3da97 100644 --- a/wadsrc/static/zscript/games/duke/world/dukebreak.zs +++ b/wadsrc/static/zscript/games/duke/world/dukebreak.zs @@ -13,7 +13,7 @@ class DukeBreakWalls sectortype sptr = Raze.updatesector(pos.XY, spr.sector); if (sptr == nullptr) return; - double scale = spr.isPlayer()? 0.125 : spr is 'DukeChaingun'? 0.25 : 0.5; + double scale = spr.isPlayer()? 0.125 : spr is 'DukeChaingunShot'? 0.25 : 0.5; let spawned = dlevel.SpawnActor(sptr, pos, 'DukeForceRipple', -127, (scale, scale), 0, 0., 0., spr, DukeActor.STAT_MISC); if (spawned) {