From df72651fb70b945a82442d77268710e95ba16a54 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 29 Dec 2022 12:00:19 +0100 Subject: [PATCH] - converted weaponsandammosprites into a class pointer array and fixed RR's bogus content. It's a Duke only feature. RR can use it but would have spawned some non-functional items. --- source/games/duke/src/classnames.h | 17 +++++++++++ source/games/duke/src/flags_d.cpp | 30 +++++++++---------- source/games/duke/src/flags_r.cpp | 30 +++++++++---------- source/games/duke/src/global.h | 2 +- source/games/duke/src/vmexports.cpp | 17 ++--------- .../static/zscript/games/duke/actors/scrap.zs | 6 ++-- wadsrc/static/zscript/games/duke/dukeactor.zs | 1 - wadsrc/static/zscript/games/duke/dukegame.zs | 1 + 8 files changed, 54 insertions(+), 50 deletions(-) diff --git a/source/games/duke/src/classnames.h b/source/games/duke/src/classnames.h index ffb85c17b98..62e480018bd 100644 --- a/source/games/duke/src/classnames.h +++ b/source/games/duke/src/classnames.h @@ -94,3 +94,20 @@ xx(RedneckBoatGrenade) xx(RedneckBowlingBall) xx(RedneckSlingbladeAttack) xx(RedneckChickenArrow) +xx(DukeDevastatorAmmo) +xx(DukeRPGAmmo) +xx(DukeJetpack) +xx(DukeShield) +xx(DukeFirstAid) +xx(DukeSteroids) +xx(DukeFreezeAmmo) +xx(RedneckCrossbow) +xx(RedneckRiflegun) +xx(RedneckBlasterammo) +xx(RedneckDynamiteAmmo) +xx(RedneckCowpie) +xx(RedneckWhiskey) +xx(RedneckPorkRinds) +xx(RedneckMoonshine) +xx(RedneckTitgun) +xx(RedneckTitAmmo) diff --git a/source/games/duke/src/flags_d.cpp b/source/games/duke/src/flags_d.cpp index 7f8cdaf1850..a6783668b1b 100644 --- a/source/games/duke/src/flags_d.cpp +++ b/source/games/duke/src/flags_d.cpp @@ -40,21 +40,21 @@ BEGIN_DUKE_NS void initactorflags_d() { - gs.weaponsandammosprites[0] = DTILE_RPGSPRITE; - gs.weaponsandammosprites[1] = DTILE_CHAINGUNSPRITE; - gs.weaponsandammosprites[2] = DTILE_DEVISTATORAMMO; - gs.weaponsandammosprites[3] = DTILE_RPGAMMO; - gs.weaponsandammosprites[4] = DTILE_RPGAMMO; - gs.weaponsandammosprites[5] = DTILE_JETPACK; - gs.weaponsandammosprites[6] = DTILE_SHIELD; - gs.weaponsandammosprites[7] = DTILE_FIRSTAID; - gs.weaponsandammosprites[8] = DTILE_STEROIDS; - gs.weaponsandammosprites[9] = DTILE_RPGAMMO; - gs.weaponsandammosprites[10] = DTILE_RPGAMMO; - gs.weaponsandammosprites[11] = DTILE_RPGSPRITE; - gs.weaponsandammosprites[12] = DTILE_RPGAMMO; - gs.weaponsandammosprites[13] = DTILE_FREEZESPRITE; - gs.weaponsandammosprites[14] = DTILE_FREEZEAMMO; + gs.weaponsandammosprites[0] = DukeRPGSpriteClass; + gs.weaponsandammosprites[1] = DukeChaingunSpriteClass; + gs.weaponsandammosprites[2] = DukeDevastatorAmmoClass; + gs.weaponsandammosprites[3] = DukeRPGAmmoClass; + gs.weaponsandammosprites[4] = DukeRPGAmmoClass; + gs.weaponsandammosprites[5] = DukeJetpackClass; + gs.weaponsandammosprites[6] = DukeShieldClass; + gs.weaponsandammosprites[7] = DukeFirstAidClass; + gs.weaponsandammosprites[8] = DukeSteroidsClass; + gs.weaponsandammosprites[9] = DukeRPGAmmoClass; + gs.weaponsandammosprites[10] = DukeRPGAmmoClass; + gs.weaponsandammosprites[11] = DukeRPGSpriteClass; + gs.weaponsandammosprites[12] = DukeRPGAmmoClass; + gs.weaponsandammosprites[13] = DukeFreezeSpriteClass; + gs.weaponsandammosprites[14] = DukeFreezeAmmoClass; gs.firstdebris = DTILE_SCRAP6; TILE_APLAYER = DTILE_APLAYER; diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index b992be11537..167eefea018 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -34,21 +34,21 @@ BEGIN_DUKE_NS void initactorflags_r() { - gs.weaponsandammosprites[0] = RTILE_CROSSBOWSPRITE; - gs.weaponsandammosprites[1] = RTILE_RIFLEGUNSPRITE; - gs.weaponsandammosprites[2] = RTILE_DEVISTATORAMMO; - gs.weaponsandammosprites[3] = RTILE_RPGAMMO; - gs.weaponsandammosprites[4] = RTILE_RPGAMMO; - gs.weaponsandammosprites[5] = RTILE_COWPIE; - gs.weaponsandammosprites[6] = RTILE_SHIELD; - gs.weaponsandammosprites[7] = RTILE_FIRSTAID; - gs.weaponsandammosprites[8] = RTILE_STEROIDS; - gs.weaponsandammosprites[9] = RTILE_RPGAMMO; - gs.weaponsandammosprites[10] = RTILE_RPGAMMO; - gs.weaponsandammosprites[11] = RTILE_CROSSBOWSPRITE; - gs.weaponsandammosprites[12] = RTILE_RPGAMMO; - gs.weaponsandammosprites[13] = RTILE_TITSPRITE; - gs.weaponsandammosprites[14] = RTILE_FREEZEAMMO; + gs.weaponsandammosprites[0] = RedneckCrossbowClass; + gs.weaponsandammosprites[1] = RedneckRiflegunClass; + gs.weaponsandammosprites[2] = RedneckBlasterammoClass; + gs.weaponsandammosprites[3] = RedneckDynamiteAmmoClass; + gs.weaponsandammosprites[4] = RedneckDynamiteAmmoClass; + gs.weaponsandammosprites[5] = RedneckCowpieClass; + gs.weaponsandammosprites[6] = RedneckWhiskeyClass; + gs.weaponsandammosprites[7] = RedneckPorkRindsClass; + gs.weaponsandammosprites[8] = RedneckMoonshineClass; + gs.weaponsandammosprites[9] = RedneckDynamiteAmmoClass; + gs.weaponsandammosprites[10] = RedneckDynamiteAmmoClass; + gs.weaponsandammosprites[11] = RedneckCrossbowClass; + gs.weaponsandammosprites[12] = RedneckDynamiteAmmoClass; + gs.weaponsandammosprites[13] = RedneckTitgunClass; + gs.weaponsandammosprites[14] = RedneckTitAmmoClass; TILE_APLAYER = RTILE_APLAYER; TILE_DRONE = RTILE_DRONE; diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 3b7c1a2e6d1..7f0d3024344 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -42,7 +42,7 @@ struct DukeGameInfo ActorInfo actorinfo[MAXTILES]; int16_t max_ammo_amount[MAX_WEAPONS]; - int16_t weaponsandammosprites[15]; + PClassActor* weaponsandammosprites[15]; int displayflags; // global gamevars from WW2GI. Put here so we can modify these values without having to depend on CON. diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index 0e5ae95c2f4..35c09462576 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -507,19 +507,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spawnsprite, DukeActor_Spawnsprite) ACTION_RETURN_POINTER(DukeActor_Spawnsprite(self, type)); } -DDukeActor* DukeActor_spawnweaponorammo(DDukeActor* origin, unsigned intname) -{ - if (intname > 14) return nullptr; - return spawn(origin, gs.weaponsandammosprites[intname]); -} - -DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spawnweaponorammo, DukeActor_spawnweaponorammo) -{ - PARAM_SELF_PROLOGUE(DDukeActor); - PARAM_INT(type); - ACTION_RETURN_POINTER(DukeActor_spawnweaponorammo(self, type)); -} - void DukeActor_Lotsofglass(DDukeActor* origin, int count, walltype* wal) { lotsofglass(origin, wal, count); @@ -1777,6 +1764,7 @@ DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, stickybomb_lifetime); DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, stickybomb_lifetime_var); DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, grenade_lifetime); DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, grenade_lifetime_var); +DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, weaponsandammosprites); DEFINE_GLOBAL_UNSIZED(gs) @@ -1825,12 +1813,11 @@ DEFINE_FIELD_X(ActorAction, ActorAction, increment); DEFINE_FIELD_X(ActorAction, ActorAction, delay); -// this is only a temporary helper until weaponsandammosprites can be migrated to real class types. We absolutely do not want any access to tile numbers in the scripts - even now. void tspritetype_setWeaponOrAmmoSprite(tspritetype* targ, unsigned z) { if (z < 15) { - targ->picnum = gs.weaponsandammosprites[z]; + targ->setspritetexture(GetDefaultByType(gs.weaponsandammosprites[z])->spr.spritetexture()); } } diff --git a/wadsrc/static/zscript/games/duke/actors/scrap.zs b/wadsrc/static/zscript/games/duke/actors/scrap.zs index 474419caeae..a47e9206bd0 100644 --- a/wadsrc/static/zscript/games/duke/actors/scrap.zs +++ b/wadsrc/static/zscript/games/duke/actors/scrap.zs @@ -65,9 +65,9 @@ class DukeScrap : DukeActor } else { - if (self.spriteextra == Scrap1 && self.yint > 0) + if (self.spriteextra == Scrap1 && self.yint > 0 && self.yint <= 15) { - let spawned = self.spawnweaponorammo(self.yint - 1); // fixme later! + let spawned = self.spawn(gs.weaponsandammosprites[self.yint - 1]); if (spawned) { spawned.SetPosition(self.pos); @@ -83,7 +83,7 @@ class DukeScrap : DukeActor { if (self.spriteextra == Scrap1 && self.yint > 0) { - tspr.setWeaponOrAmmoSprite(self.yint - 1); // needed so that we don't have to export tile numbers to scripting. + tspr.setWeaponOrAmmoSprite(self.yint - 1); // needed so that we don't have to export 'picnum' to scripting. } else { diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index 7e31abafda7..5b98731be86 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -295,7 +295,6 @@ class DukeActor : CoreActor native native void StopSound(Sound snd, int flags = 0); native DukeActor spawn(class type); native DukeActor spawnsprite(int type); // for cases where the map has a picnum stored. Avoid when possible. - native DukeActor spawnweaponorammo(int type); native void lotsofglass(int count, walltype wal = null); native void lotsofcolourglass(int count, walltype wal = null); native void makeitfall(); diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index b3043cbad4b..ff2b2e5b04e 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -490,6 +490,7 @@ struct DukeGameInfo native readonly native int stickybomb_lifetime_var; readonly native int grenade_lifetime; readonly native int grenade_lifetime_var; + readonly native class weaponsandammosprites[15]; }