From a6a4e628df9d40c8bfe7294877374e3497e15e56 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Nov 2022 00:19:37 +0100 Subject: [PATCH] - scriptified RRRA's gambling machines. These were fallout from the generic destructibles because the code to destroy them was removed along with that. --- source/games/duke/src/actors_r.cpp | 151 ------------------ source/games/duke/src/namelist_r.h | 34 ++-- source/games/duke/src/premap.cpp | 3 + source/games/duke/src/sectors_r.cpp | 14 -- source/games/duke/src/spawn_r.cpp | 16 -- source/games/duke/src/vmexports.cpp | 18 ++- .../redneck.ridesagain/engine/engine.def | 3 + wadsrc/static/zscript.txt | 2 + .../games/duke/actors/gamblingmachine.zs | 132 +++++++++++++++ .../zscript/games/duke/actors/redneckmisc.zs | 13 ++ 10 files changed, 186 insertions(+), 200 deletions(-) create mode 100644 wadsrc/static/zscript/games/duke/actors/gamblingmachine.zs create mode 100644 wadsrc/static/zscript/games/duke/actors/redneckmisc.zs diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 6f0a1e104..517f3ed16 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1587,157 +1587,6 @@ static void rrra_specialstats() } } - it.Reset(115); - while (auto act = it.Next()) - { - if (act->spr.extra) - { - if (act->spr.picnum != RRTILE8162) - act->spr.picnum = RRTILE8162; - act->spr.extra--; - if (act->spr.extra == 0) - { - int rvar; - rvar = krand() & 127; - if (rvar < 96) - { - act->spr.picnum = RRTILE8162 + 3; - } - else if (rvar < 112) - { - if (ps[screenpeek].SlotWin & 1) - { - act->spr.picnum = RRTILE8162 + 3; - } - else - { - act->spr.picnum = RRTILE8162 + 2; - spawn(act, BATTERYAMMO); - ps[screenpeek].SlotWin |= 1; - S_PlayActorSound(52, act); - } - } - else if (rvar < 120) - { - if (ps[screenpeek].SlotWin & 2) - { - act->spr.picnum = RRTILE8162 + 3; - } - else - { - act->spr.picnum = RRTILE8162 + 6; - spawn(act, DYNAMITE); - ps[screenpeek].SlotWin |= 2; - S_PlayActorSound(52, act); - } - } - else if (rvar < 126) - { - if (ps[screenpeek].SlotWin & 4) - { - act->spr.picnum = RRTILE8162 + 3; - } - else - { - act->spr.picnum = RRTILE8162 + 5; - spawn(act, SIXPAK); - ps[screenpeek].SlotWin |= 4; - S_PlayActorSound(52, act); - } - } - else - { - if (ps[screenpeek].SlotWin & 8) - { - act->spr.picnum = RRTILE8162 + 3; - } - else - { - act->spr.picnum = RRTILE8162 + 4; - spawn(act, ATOMICHEALTH); - ps[screenpeek].SlotWin |= 8; - S_PlayActorSound(52, act); - } - } - } - } - } - - it.Reset(122); - while (auto act = it.Next()) - { - if (act->spr.extra) - { - if (act->spr.picnum != RRTILE8589) - act->spr.picnum = RRTILE8589; - act->spr.extra--; - if (act->spr.extra == 0) - { - int rvar; - rvar = krand() & 127; - if (rvar < 96) - { - act->spr.picnum = RRTILE8589 + 4; - } - else if (rvar < 112) - { - if (ps[screenpeek].SlotWin & 1) - { - act->spr.picnum = RRTILE8589 + 4; - } - else - { - act->spr.picnum = RRTILE8589 + 5; - spawn(act, BATTERYAMMO); - ps[screenpeek].SlotWin |= 1; - S_PlayActorSound(342, act); - } - } - else if (rvar < 120) - { - if (ps[screenpeek].SlotWin & 2) - { - act->spr.picnum = RRTILE8589 + 4; - } - else - { - act->spr.picnum = RRTILE8589 + 6; - spawn(act, DYNAMITE); - ps[screenpeek].SlotWin |= 2; - S_PlayActorSound(342, act); - } - } - else if (rvar < 126) - { - if (ps[screenpeek].SlotWin & 4) - { - act->spr.picnum = RRTILE8589 + 4; - } - else - { - act->spr.picnum = RRTILE8589 + 2; - spawn(act, SIXPAK); - ps[screenpeek].SlotWin |= 4; - S_PlayActorSound(342, act); - } - } - else - { - if (ps[screenpeek].SlotWin & 8) - { - act->spr.picnum = RRTILE8589 + 4; - } - else - { - act->spr.picnum = RRTILE8589 + 3; - spawn(act, ATOMICHEALTH); - ps[screenpeek].SlotWin |= 8; - S_PlayActorSound(342, act); - } - } - } - } - } it.Reset(123); while (auto act = it.Next()) diff --git a/source/games/duke/src/namelist_r.h b/source/games/duke/src/namelist_r.h index 0514fe236..92c45df18 100644 --- a/source/games/duke/src/namelist_r.h +++ b/source/games/duke/src/namelist_r.h @@ -715,7 +715,7 @@ y(RRTILE2382, 2382) x(CACTUSLARGEYELLOW, 2430) x(CACTUSLARGEGREEN, 2431) x(CACTUSLARGEBROWN, 2432) -y(RRTILE2437, 2437) +x(BIGBELL, 2437) x(CACTUSDRUG, 2443) y(RRTILE2445, 2445) x(CACTUSLARGEGREEN2, 2446) @@ -1083,7 +1083,7 @@ y(RRTILE5058, 5058) y(RRTILE5059, 5059) y(RRTILE5061, 5061) y(RRTILE5062, 5062) -y(RRTILE5063, 5063) +y(GAMBLINGMACHINEBROKE, 5063) y(RRTILE5064, 5064) y(RRTILE5065, 5065) y(RRTILE5066, 5066) @@ -1242,13 +1242,13 @@ y(RRTILE8094, 8094) y(RRTILE8096, 8096) y(RRTILE8099, 8099) y(RRTILE8106, 8106) -y(RRTILE8162, 8162) -y(RRTILE8163, 8163) -y(RRTILE8164, 8164) -y(RRTILE8165, 8165) -y(RRTILE8166, 8166) -y(RRTILE8167, 8167) -y(RRTILE8168, 8168) +y(GAMBLINGMACHINE2, 8162) +y(GAMBLINGMACHINE3, 8163) +y(GAMBLINGMACHINE4, 8164) +y(GAMBLINGMACHINE5, 8165) +y(GAMBLINGMACHINE6, 8166) +y(GAMBLINGMACHINE7, 8167) +y(GAMBLINGMACHINE8, 8168) y(RRTILE8192, 8192) y(RRTILE8193, 8193) y(RRTILE8215, 8215) @@ -1309,14 +1309,14 @@ y(RRTILE8569, 8569) y(RRTILE8570, 8570) y(RRTILE8571, 8571) y(RRTILE8579, 8579) -y(RRTILE8588, 8588) -y(RRTILE8589, 8589) -y(RRTILE8590, 8590) -y(RRTILE8591, 8591) -y(RRTILE8592, 8592) -y(RRTILE8593, 8593) -y(RRTILE8594, 8594) -y(RRTILE8595, 8595) +y(GAMBLINGMACHINE2_BROKE, 8588) +y(GAMBLINGMACHINE2_2, 8589) +y(GAMBLINGMACHINE2_3, 8590) +y(GAMBLINGMACHINE2_4, 8591) +y(GAMBLINGMACHINE2_5, 8592) +y(GAMBLINGMACHINE2_6, 8593) +y(GAMBLINGMACHINE2_7, 8594) +y(GAMBLINGMACHINE2_8, 8595) y(RRTILE8596, 8596) y(RRTILE8598, 8598) y(RRTILE8605, 8605) diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index b35adc63f..0c66f56a9 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -941,6 +941,9 @@ static TArray spawnactors(SpawnSpriteDef& sprites) auto sprt = &sprites.sprites[i]; + if (sprt->picnum == 7220) + sprt->picnum = 8165; + auto info = spawnMap.CheckKey(sprt->picnum); auto cls = info ? info->Class(sprt->picnum) : nullptr;; auto actor = static_cast(InsertActor(cls? cls : RUNTIME_CLASS(DDukeActor), sprt->sectp, sprt->statnum)); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index b9f2df3c8..e5c67eafa 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -1874,20 +1874,6 @@ void checksectors_r(int snum) if (!isRRRA()) return; OnBoat(p, neartagsprite); return; - case RRTILE8164: - case RRTILE8165: - case RRTILE8166: - case RRTILE8167: - case RRTILE8168: - case RRTILE8591: - case RRTILE8592: - case RRTILE8593: - case RRTILE8594: - case RRTILE8595: - if (!isRRRA()) return; - neartagsprite->spr.extra = 60; - S_PlayActorSound(235, neartagsprite); - return; case TOILET: case STALL: diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index d4f4851c8..011840aa7 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -116,22 +116,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* act->spr.scale = DVector2(0, 0); pistonsound = 1; break; - case RRTILE8165: - if (!isRRRA()) goto default_case; - act->spr.lotag = 1; - act->clipdist = 0; - act->SetOwner(act); - act->spr.extra = 0; - ChangeActorStat(act, 115); - break; - case RRTILE8593: - if (!isRRRA()) goto default_case; - act->spr.lotag = 1; - act->clipdist = 0; - act->SetOwner(act); - act->spr.extra = 0; - ChangeActorStat(act, 122); - break; case WATERSPLASH2: case MUD: diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index 85c67e325..18f1b2dc6 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -40,11 +40,25 @@ int PicForName(int intname) { picnum = TileFiles.tileForName("FEATHER"); } - + else if (FName(ENamedName(intname)) == FName("DukeBatteryAmmo")) + { + picnum = TileFiles.tileForName("BATTERYAMMO"); + } + else if (FName(ENamedName(intname)) == FName("RedneckDynamite")) + { + picnum = TileFiles.tileForName("DYNAMITE"); + } + else if (FName(ENamedName(intname)) == FName("DukeSixpak")) + { + picnum = TileFiles.tileForName("SIXPAK"); + } + else if (FName(ENamedName(intname)) == FName("DukeAtomicHealth")) + { + picnum = TileFiles.tileForName("ATOMICHEALTH"); + } return picnum; } - //--------------------------------------------------------------------------- // // global exports diff --git a/wadsrc/static/filter/redneck.ridesagain/engine/engine.def b/wadsrc/static/filter/redneck.ridesagain/engine/engine.def index f6935b7ba..91710cc99 100644 --- a/wadsrc/static/filter/redneck.ridesagain/engine/engine.def +++ b/wadsrc/static/filter/redneck.ridesagain/engine/engine.def @@ -32,6 +32,9 @@ spawnclasses 8895 = RedneckMamaJibB 8487 = RedneckBalloons1 8489 = RedneckBalloons2 + 8165 = RedneckGamblingMachine + 8593 = RedneckGamblingMachine2 + 2437 = RedneckBell 7636 = DukeGenericDestructible, "OLDPHOTO0", "OLDPHOTO0BROKE", "VENT_BUST" 7638 = DukeGenericDestructible, "OLDPHOTO1", "OLDPHOTO1BROKE", "VENT_BUST" diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index c81d7b4fe..a0a419822 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -76,11 +76,13 @@ version "4.10" #include "zscript/games/duke/actors/tongue.zs" #include "zscript/games/duke/actors/genericdestructible.zs" +#include "zscript/games/duke/actors/redneckmisc.zs" #include "zscript/games/duke/actors/rabbitspawner.zs" #include "zscript/games/duke/actors/chickenplant.zs" #include "zscript/games/duke/actors/lumberblade.zs" #include "zscript/games/duke/actors/rrcactus.zs" #include "zscript/games/duke/actors/balloons.zs" +#include "zscript/games/duke/actors/gamblingmachine.zs" #include "zscript/games/blood/bloodgame.zs" #include "zscript/games/blood/ui/menu.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/gamblingmachine.zs b/wadsrc/static/zscript/games/duke/actors/gamblingmachine.zs new file mode 100644 index 000000000..050c993da --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/gamblingmachine.zs @@ -0,0 +1,132 @@ + +class RedneckGamblingMachine : DukeActor +{ + default + { + statnum STAT_ACTOR; + lotag 1; + clipdist 0; + extra 0; + spriteset "GAMBLINGMACHINE2", "GAMBLINGMACHINE3", "GAMBLINGMACHINE4", "GAMBLINGMACHINE5", "GAMBLINGMACHINE6", "GAMBLINGMACHINE7", "GAMBLINGMACHINE8", "GAMBLINGMACHINEBROKE"; + spritesetindex 3; + } + + Sound winsound; + + override void Initialize() + { + winsound = "COW3"; + } + + override void Tick() + { + int spriteindex; + if (self.extra && self.spritesetindex < 7) + { + let pl = Duke.GetViewPlayer(); + + if (self.spritesetindex != 0) + spriteindex = 0; + self.extra--; + if (self.extra == 0) + { + int rvar = random(0, 127); + if (rvar < 96) + { + spriteindex = 3; + } + else if (rvar < 112) + { + if (pl.SlotWin & 1) + { + spriteindex = 3; + } + else + { + spriteindex = 2; + self.spawn("DukeBatteryAmmo"); + pl.SlotWin |= 1; + self.PlayActorSound(winsound); + } + } + else if (rvar < 120) + { + if (pl.SlotWin & 2) + { + spriteindex = 3; + } + else + { + spriteindex = 6; + self.spawn("RedneckDynamite"); + pl.SlotWin |= 2; + self.PlayActorSound(winsound); + } + } + else if (rvar < 126) + { + if (pl.SlotWin & 4) + { + spriteindex = 3; + } + else + { + spriteindex = 5; + self.spawn("DukeSixpak"); + pl.SlotWin |= 4; + self.PlayActorSound(winsound); + } + } + else + { + if (pl.SlotWin & 8) + { + spriteindex = 3; + } + else + { + spriteindex = 4; + spawn("DukeAtomicHealth"); + pl.SlotWin |= 8; + self.PlayActorSound(winsound); + } + } + } + self.setSpriteSetImage(spriteindex); + } + } + + override void OnHit(DukeActor proj) + { + if (self.spritesetindex < 7) + { + self.SetSpriteSetImage(7); + self.PlayActorSound("GLASS_HEAVYBREAK"); + } + } + + override bool OnUse(DukePlayer p) + { + if (self.spritesetindex > 1 && self.spritesetindex < 7) + { + self.extra = 60; + self.PlayActorSound("SLOTS"); + return true; + } + return false; + } + +} + +class RedneckGamblingMachine2 : RedneckGamblingMachine +{ + default + { + spriteset "GAMBLINGMACHINE2_2", "GAMBLINGMACHINE2_3", "GAMBLINGMACHINE2_4", "GAMBLINGMACHINE2_5", "GAMBLINGMACHINE2_6", "GAMBLINGMACHINE2_7", "GAMBLINGMACHINE2_8", "GAMBLINGMACHINE2_BROKE"; + } + + override void Initialize() + { + winsound = "VX_TPIN2"; + } +} diff --git a/wadsrc/static/zscript/games/duke/actors/redneckmisc.zs b/wadsrc/static/zscript/games/duke/actors/redneckmisc.zs new file mode 100644 index 000000000..dfa8cf27b --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/redneckmisc.zs @@ -0,0 +1,13 @@ + +class RedneckBell : DukeActor +{ + default + { + pic "BIGBELL"; + } + + override void OnHit(DukeActor proj) + { + self.PlayActorSound("BELL"); + } +} \ No newline at end of file