From 8a921c98bddad02a2dba8248889150ce7c70e87c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Nov 2022 19:55:28 +0100 Subject: [PATCH] - scriptified ooz. --- source/core/gamecvars.cpp | 4 ++ source/core/gamecvars.h | 2 + source/games/duke/src/actors.cpp | 17 ------- source/games/duke/src/actors_d.cpp | 5 -- source/games/duke/src/actors_r.cpp | 4 -- source/games/duke/src/constants.h | 1 + source/games/duke/src/funct.h | 1 - source/games/duke/src/game.cpp | 2 +- source/games/duke/src/premap.cpp | 3 +- source/games/duke/src/spawn_d.cpp | 23 --------- source/games/duke/src/spawn_r.cpp | 18 ------- source/games/duke/src/vmexports.cpp | 6 +++ .../static/filter/dukelike/engine/engine.def | 3 +- .../static/filter/redneck/engine/engine.def | 1 + wadsrc/static/zscript.txt | 1 + .../static/zscript/games/duke/actors/ooz.zs | 47 +++++++++++++++++++ wadsrc/static/zscript/games/duke/dukeactor.zs | 2 + 17 files changed, 68 insertions(+), 72 deletions(-) create mode 100644 wadsrc/static/zscript/games/duke/actors/ooz.zs diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index 358e02ff9..ff5aebe02 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -302,6 +302,10 @@ CUSTOM_CVAR(Int, playergender, 0, CVAR_USERINFO|CVAR_ARCHIVE) if (self < 0 || self > 3) self = 0; } +CUSTOM_CVAR(Int, cl_maxdecalamount, 1024, CVAR_ARCHIVE) +{ + if (self < 0) self = 0; +} diff --git a/source/core/gamecvars.h b/source/core/gamecvars.h index b5a9b93ee..7c3b1de55 100644 --- a/source/core/gamecvars.h +++ b/source/core/gamecvars.h @@ -106,6 +106,8 @@ EXTERN_CVAR(Int, m_ffire) EXTERN_CVAR(Int, m_noexits) EXTERN_CVAR(Int, playercolor) +EXTERN_CVAR(Int, cl_maxdecalamount) + inline const char* PlayerName(size_t pindex) { // Todo: proper implementation of user CVARs. diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index a960936ca..7ad2fcd0d 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -681,23 +681,6 @@ void rpgexplode(DDukeActor *actor, int hit, const DVector3 &pos, int EXPLOSION2, // //--------------------------------------------------------------------------- -void ooz(DDukeActor *actor) -{ - getglobalz(actor); - - double y = min((actor->floorz - actor->ceilingz) / 128, 4.); - double x = clamp(0.390625 - y * 0.5, 0.125, 0.75); - - actor->spr.scale = DVector2(x, y); - actor->spr.pos.Z = actor->floorz; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - void reactor(DDukeActor* const actor, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BURNT, int REACTORSPARK, int REACTOR2SPARK) { auto sectp = actor->sector(); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 31decb5c5..7c2828285 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -2301,11 +2301,6 @@ void moveactors_d(void) ssp(act, CLIPMASK0); break; - case OOZ: - case OOZ2: - ooz(act); - continue; - case GREENSLIME: case GREENSLIME + 1: case GREENSLIME + 2: diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 37445f3f8..410a8ac9a 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -2062,10 +2062,6 @@ void moveactors_r(void) break; } - case OOZ: - ooz(act); - continue; - case EMPTYBIKE: if (!isRRRA()) break; makeitfall(act); diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index ce340301e..aae547119 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -375,6 +375,7 @@ enum sflags2_t SFLAG2_IGNOREHITOWNER = 0x00200000, SFLAG2_DONTDIVE = 0x00400000, SFLAG2_FLOATING = 0x00800000, + SFLAG2_PAL8OOZ = 0x01000000, // dirty hack - only needed because this needs to work from CON. }; using EDukeFlags2 = TFlags; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index c98f30eb2..f1b377ba5 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -43,7 +43,6 @@ void lotsofstuff(DDukeActor* s, int n, int spawntype); bool respawnmarker(DDukeActor* i, int yellow, int green); void forcesphere(DDukeActor* i, int forcesphere); void recon(DDukeActor* i, int explosion, int firelaser, int attacksnd, int painsnd, int roamsnd, int shift, int (*getspawn)(DDukeActor* i)); -void ooz(DDukeActor* i); void reactor(DDukeActor* i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BURNT, int REACTORSPARK, int REACTOR2SPARK); void bloodsplats(DDukeActor* actor); void forcesphereexplode(DDukeActor* i); diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index 17923015c..b043f1e60 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -77,7 +77,7 @@ static void markgcroots() { GC::Mark(camsprite); GC::Mark(BellSprite); - GC::MarkArray(spriteq, countof(spriteq)); + GC::MarkArray(spriteq, 1024); GC::Mark(currentCommentarySprite); GC::Mark(ud.cameraactor); for (auto& pl : ps) diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index be4949c4c..0a684f79d 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -391,12 +391,11 @@ void resetinventory(int snum) void resetprestat(int snum,int g) { player_struct* p; - int i; p = &ps[snum]; spriteqloc = 0; - for(i=0;ihbomb_on = 0; p->pals.a = 0; diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index a5bfa3423..60514c29d 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -681,29 +681,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* break; - case OOZ: - case OOZ2: - { - act->spr.shade = -12; - - if (actj) - { - if (actj->spr.picnum == NUKEBARREL) - act->spr.pal = 8; - insertspriteq(act); - } - - ChangeActorStat(act, STAT_ACTOR); - - getglobalz(act); - - double j = ((act->floorz - act->ceilingz) / 128.); - - act->spr.scale = DVector2(max(0., 0.390625 - j * 0.5), j); - if (krand() & 4) act->spr.cstat |= CSTAT_SPRITE_XFLIP; - - break; - } case HEAVYHBOMB: if (actj) act->SetOwner(actj); else act->SetOwner(act); diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 4bf099bea..b4dc139e9 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -695,24 +695,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* break; - case OOZ: - { - act->spr.shade = -12; - - if (actj) - if (actj->spr.picnum == NUKEBARREL) - act->spr.pal = 8; - - ChangeActorStat(act, STAT_STANDABLE); - - getglobalz(act); - - double j = ((act->floorz - act->ceilingz) / 128.); - - act->spr.scale = DVector2(max(0., 0.390625 - j * 0.5), j); - if(krand() & 4) act->spr.cstat |= CSTAT_SPRITE_XFLIP; - break; - } case DYNAMITE: act->SetOwner(act); act->spr.scale = DVector2(0.140625, 0.140625); diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index 4894b727a..bb2a63658 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -648,6 +648,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, setclipDistFromTile, DukeActor_setclip return 0; } +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, insertspriteq, insertspriteq) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + insertspriteq(self); + return 0; +} // temporary helpers to hide the fact that these flags are not part of the actor yet. diff --git a/wadsrc/static/filter/dukelike/engine/engine.def b/wadsrc/static/filter/dukelike/engine/engine.def index a97a0367a..7daba65d5 100644 --- a/wadsrc/static/filter/dukelike/engine/engine.def +++ b/wadsrc/static/filter/dukelike/engine/engine.def @@ -49,7 +49,8 @@ spawnclasses 903 = DukePoolPocket 2590 = DukeForceSphere 1960 = DukeRecon - + 2300 = DukeOoz + 2309 = DukeOoz2 1272 = DukeTrash 634 = DukeBolt1 diff --git a/wadsrc/static/filter/redneck/engine/engine.def b/wadsrc/static/filter/redneck/engine/engine.def index 48731421d..f52223147 100644 --- a/wadsrc/static/filter/redneck/engine/engine.def +++ b/wadsrc/static/filter/redneck/engine/engine.def @@ -51,6 +51,7 @@ spawnclasses 866 = RedneckRespawnMarker 1344 = DukeRat 1759 = DukeForceSphere + 1529 = DukeOoz 285 = RedneckChickenSpawner1 286 = RedneckChickenSpawner2 diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index fa6eb10bc..a1107b5ef 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -79,6 +79,7 @@ version "4.10" #include "zscript/games/duke/actors/queball.zs" #include "zscript/games/duke/actors/forcesphere.zs" #include "zscript/games/duke/actors/recon.zs" +#include "zscript/games/duke/actors/ooz.zs" #include "zscript/games/duke/actors/genericdestructible.zs" #include "zscript/games/duke/actors/redneckmisc.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/ooz.zs b/wadsrc/static/zscript/games/duke/actors/ooz.zs new file mode 100644 index 000000000..97c15b2bd --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/ooz.zs @@ -0,0 +1,47 @@ +class DukeOoz : DukeActor +{ + default + { + shade -12; + statnum STAT_ACTOR; + pic "OOZ"; + } + + override void Initialize() + { + self.shade = -12; + + if (self.ownerActor && self.OwnerActor != self) + { + if (self.actorflag2(SFLAG2_PAL8OOZ)) + self.pal = 8; + if (!Raze.IsRR()) self.insertspriteq(); + } + + self.getglobalz(); + + double z = ((self.floorz - self.ceilingz) / 128.); + + self.scale = (max(0., 0.390625 - z * 0.5), z); + self.cstat |= randomXFlip(); + } + + override void Tick() + { + self.getglobalz(); + + double y = min((self.floorz - self.ceilingz) / 128, 4.); + double x = clamp(0.390625 - y * 0.5, 0.125, 0.75); + + self.scale = (x, y); + self.pos.Z = self.floorz; + } +} + +class DukeOoz2 : DukeActor +{ + default + { + pic "OOZ2"; + } +} diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index 466f08cc1..5e43f936e 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -204,6 +204,7 @@ class DukeActor : CoreActor native native int monsterCheatCheck(); native void shoot(Name spawnclass); native void setClipDistFromTile(); + native void insertspriteq(); // temporary flag accessors - need to be eliminated once we can have true actor flags @@ -328,4 +329,5 @@ enum sflags2_t SFLAG2_IGNOREHITOWNER = 0x00200000, SFLAG2_DONTDIVE = 0x00400000, SFLAG2_FLOATING = 0x00800000, + SFLAG2_PAL8OOZ = 0x01000000, // dirty hack - only needed because this needs to work from CON. };