From 7f240a0a7a5c3111f8f2a1a65a2700db29c2b484 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 12 Dec 2022 19:39:17 +0100 Subject: [PATCH] - converted all remaining classes used by PicForName. This means all functions using this can now pass class pointers directly to the native code. --- source/core/namedef_custom.h | 7 ++ source/games/duke/src/actors.cpp | 12 +-- source/games/duke/src/actors_d.cpp | 14 ++-- source/games/duke/src/actors_r.cpp | 8 +- source/games/duke/src/dispatch.cpp | 1 - source/games/duke/src/flags_d.cpp | 1 - source/games/duke/src/flags_r.cpp | 1 - source/games/duke/src/funct.h | 6 +- source/games/duke/src/names.h | 1 - source/games/duke/src/player.cpp | 4 +- source/games/duke/src/player_d.cpp | 12 +-- source/games/duke/src/player_r.cpp | 12 +-- source/games/duke/src/spawn_d.cpp | 24 +----- source/games/duke/src/spawn_r.cpp | 35 +-------- source/games/duke/src/vmexports.cpp | 75 +++---------------- .../filter/dukelike/rmapinfo.spawnclasses | 2 + .../filter/redneck/rmapinfo.spawnclasses | 3 + wadsrc/static/zscript.txt | 2 + .../zscript/games/duke/actors/bowling.zs | 12 +++ .../static/zscript/games/duke/actors/recon.zs | 2 +- .../zscript/games/duke/actors/smallsmoke.zs | 25 +++++++ .../static/zscript/games/duke/actors/steam.zs | 22 ++++++ wadsrc/static/zscript/games/duke/dukeactor.zs | 15 ++-- 23 files changed, 135 insertions(+), 161 deletions(-) create mode 100644 wadsrc/static/zscript/games/duke/actors/smallsmoke.zs create mode 100644 wadsrc/static/zscript/games/duke/actors/steam.zs diff --git a/source/core/namedef_custom.h b/source/core/namedef_custom.h index 4c9b2cd10..eca02e547 100644 --- a/source/core/namedef_custom.h +++ b/source/core/namedef_custom.h @@ -38,6 +38,13 @@ xx(DukeSectorEffector) xx(RedneckGoogooCluster) xx(DukeAtomicHealth) xx(RedneckHen) +xx(DukeSmallSmoke) +xx(DukeExplosion2) +xx(DukeWaterBubble) +xx(DukeMoney) +xx(DukeMail) +xx(DukePaper) +xx(RedneckFeather) xx(spawnstate) xx(brokenstate) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 4d7fa105e..cec1f8429 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -301,7 +301,7 @@ void insertspriteq(DDukeActor* const actor) // //--------------------------------------------------------------------------- -void lotsofstuff(DDukeActor* actor, int n, int spawntype) +void lotsofstuff(DDukeActor* actor, int n, PClassActor* spawntype) { for (int i = n; i > 0; i--) { @@ -2633,7 +2633,7 @@ void handle_se32(DDukeActor *actor) // //--------------------------------------------------------------------------- -void handle_se35(DDukeActor *actor, int SMALLSMOKE, int EXPLOSION2) +void handle_se35(DDukeActor *actor) { auto sc = actor->sector(); @@ -2641,14 +2641,14 @@ void handle_se35(DDukeActor *actor, int SMALLSMOKE, int EXPLOSION2) for (int j = 0; j < 8; j++) { actor->spr.Angles.Yaw = randomAngle(90); - auto spawned = spawn(actor, SMALLSMOKE); + auto spawned = spawn(actor, PClass::FindActor(NAME_DukeSmallSmoke)); if (spawned) { spawned->vel.X = 6 + krandf(8); ssp(spawned, CLIPMASK0); SetActor(spawned, spawned->spr.pos); if (rnd(16)) - spawn(actor, EXPLOSION2); + spawn(actor, PClass::FindActor(NAME_DukeExplosion2)); } } @@ -2720,7 +2720,7 @@ void handle_se128(DDukeActor *actor) // //--------------------------------------------------------------------------- -void handle_se130(DDukeActor *actor, int countmax, int EXPLOSION2) +void handle_se130(DDukeActor *actor, int countmax) { auto sc = actor->sector(); @@ -2735,7 +2735,7 @@ void handle_se130(DDukeActor *actor, int countmax, int EXPLOSION2) if (rnd(64)) { - auto k = spawn(actor, EXPLOSION2); + auto k = spawn(actor, PClass::FindActor(NAME_DukeExplosion2)); if (k) { double s = 0.03125 + (krand() & 7) * REPEAT_SCALE; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index b6e9b500a..74f968d61 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -471,17 +471,17 @@ int movesprite_ex_d(DDukeActor* actor, const DVector3& change, unsigned int clip void lotsofmoney_d(DDukeActor *actor, int n) { - lotsofstuff(actor, n, DTILE_MONEY); + lotsofstuff(actor, n, PClass::FindActor(NAME_DukeMoney)); } void lotsofmail_d(DDukeActor *actor, int n) { - lotsofstuff(actor, n, DTILE_MAIL); + lotsofstuff(actor, n, PClass::FindActor(NAME_DukeMail)); } void lotsofpaper_d(DDukeActor *actor, int n) { - lotsofstuff(actor, n, DTILE_PAPER); + lotsofstuff(actor, n, PClass::FindActor(NAME_DukePaper)); } //--------------------------------------------------------------------------- @@ -1095,7 +1095,7 @@ static void handle_se28(DDukeActor* actor) if (rnd(32) && (actor->temp_data[2] & 1)) { act2->spr.cstat &= ~CSTAT_SPRITE_INVISIBLE; - spawn(act2, DTILE_SMALLSMOKE); + spawn(act2, PClass::FindActor(NAME_DukeSmallSmoke)); double x; int p = findplayer(actor, &x); @@ -1235,7 +1235,7 @@ void moveeffectors_d(void) //STATNUM 3 break; } case SE_35: - handle_se35(act, DTILE_SMALLSMOKE, DTILE_EXPLOSION2); + handle_se35(act); break; case SE_25_PISTON: //PISTONS @@ -1287,10 +1287,10 @@ void moveeffectors_d(void) //STATNUM 3 break; case 130: - handle_se130(act, 80, DTILE_EXPLOSION2); + handle_se130(act, 80); break; case 131: - handle_se130(act, 40, DTILE_EXPLOSION2); + handle_se130(act, 40); break; } } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index ede5d8ac9..71899b5d1 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -357,7 +357,7 @@ int movesprite_ex_r(DDukeActor* actor, const DVector3& change, unsigned int clip void lotsoffeathers_r(DDukeActor *actor, int n) { - lotsofstuff(actor, n, RTILE_FEATHER); + lotsofstuff(actor, n, PClass::FindActor(NAME_RedneckFeather)); } @@ -1215,7 +1215,7 @@ void moveeffectors_r(void) //STATNUM 3 } case SE_35: - handle_se35(act, RTILE_SMALLSMOKE, RTILE_EXPLOSION2); + handle_se35(act); break; case SE_25_PISTON: //PISTONS @@ -1264,10 +1264,10 @@ void moveeffectors_r(void) //STATNUM 3 break; case SE_130: - handle_se130(act, 80, RTILE_EXPLOSION2); + handle_se130(act, 80); break; case SE_131: - handle_se130(act, 40, RTILE_EXPLOSION2); + handle_se130(act, 40); break; } } diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 60386fb65..47734fc1e 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -173,7 +173,6 @@ int TILE_THREEDEE; int TILE_INGAMEDUKETHREEDEE; int TILE_FIRE; int TILE_WATERBUBBLE; -int TILE_SMALLSMOKE; int TILE_BLOODPOOL; int TILE_CLOUDYSKIES; int TILE_MIRRORBROKE; diff --git a/source/games/duke/src/flags_d.cpp b/source/games/duke/src/flags_d.cpp index 0ec8c20e3..02162c99a 100644 --- a/source/games/duke/src/flags_d.cpp +++ b/source/games/duke/src/flags_d.cpp @@ -289,7 +289,6 @@ void initactorflags_d() TILE_BOTTOMSTATUSBAR = isWorldTour()? DTILE_WIDESCREENSTATUSBAR : DTILE_BOTTOMSTATUSBAR; TILE_FIRE = DTILE_FIRE; TILE_WATERBUBBLE = DTILE_WATERBUBBLE; - TILE_SMALLSMOKE = DTILE_SMALLSMOKE; TILE_BLOODPOOL = DTILE_BLOODPOOL; TILE_CLOUDYSKIES = DTILE_CLOUDYSKIES; TILE_MIRRORBROKE = DTILE_MIRRORBROKE; diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index 6f6d577b2..b80ad35af 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -284,7 +284,6 @@ void initactorflags_r() TILE_BOTTOMSTATUSBAR = RTILE_BOTTOMSTATUSBAR; TILE_FIRE = RTILE_FIRE; TILE_WATERBUBBLE = RTILE_WATERBUBBLE; - TILE_SMALLSMOKE = RTILE_SMALLSMOKE; TILE_BLOODPOOL = RTILE_BLOODPOOL; TILE_CLOUDYSKIES = RTILE_CLOUDYSKIES; TILE_MIRRORBROKE = RTILE_MIRRORBROKE; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 511b9dc5b..0e241e848 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -39,7 +39,7 @@ void movefta(); void clearcameras(player_struct* p); void RANDOMSCRAP(DDukeActor* i); void detonate(DDukeActor* i, PClassActor* explosion); -void lotsofstuff(DDukeActor* s, int n, int spawntype); +void lotsofstuff(DDukeActor* s, int n, PClassActor* spawntype); void watersplash2(DDukeActor* i); bool money(DDukeActor* i, int BLOODPOOL); bool bloodpool(DDukeActor* i, bool puke); @@ -75,9 +75,9 @@ void handle_se27(DDukeActor* i); void handle_se29(DDukeActor* actor); void handle_se31(DDukeActor* a, bool choosedir); void handle_se32(DDukeActor* i); -void handle_se35(DDukeActor* i, int SMALLSMOKE, int EXPLOSION2); +void handle_se35(DDukeActor* i); void handle_se128(DDukeActor* i); -void handle_se130(DDukeActor* i, int countmax, int EXPLOSION2); +void handle_se130(DDukeActor* i, int countmax); void check_fta_sounds_d(DDukeActor* i); diff --git a/source/games/duke/src/names.h b/source/games/duke/src/names.h index 4167477e4..0cd002905 100644 --- a/source/games/duke/src/names.h +++ b/source/games/duke/src/names.h @@ -14,7 +14,6 @@ extern int TILE_STATIC; extern int TILE_BOTTOMSTATUSBAR; extern int TILE_FIRE; extern int TILE_WATERBUBBLE; -extern int TILE_SMALLSMOKE; extern int TILE_BLOODPOOL; extern int TILE_CLOUDYSKIES; extern int TILE_MIRRORBROKE; diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 90c4d605b..54ad1f37c 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -150,10 +150,10 @@ void tracers(const DVector3& start, const DVector3& dest, int n) if (sect->lotag == 2) { DVector2 scale(0.0625 + (krand() & 3) * REPEAT_SCALE, 0.0625 + (krand() & 3) * REPEAT_SCALE); - CreateActor(sect, pos, TILE_WATERBUBBLE, -32, scale, randomAngle(), 0., 0., ps[0].GetActor(), 5); + CreateActor(sect, pos, PClass::FindActor(NAME_DukeWaterBubble), -32, scale, randomAngle(), 0., 0., ps[0].GetActor(), 5); } else - CreateActor(sect, pos, TILE_SMALLSMOKE, -32, DVector2(0.21875, 0.21875), nullAngle, 0., 0., ps[0].GetActor(), 5); + CreateActor(sect, pos, PClass::FindActor(NAME_DukeSmallSmoke), -32, DVector2(0.21875, 0.21875), nullAngle, 0., 0., ps[0].GetActor(), 5); } } } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index c4357c4bd..29e411601 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -175,7 +175,7 @@ static void shootknee(DDukeActor* actor, int p, DVector3 pos, DAngle ang) knee->spr.extra += (krand() & 7); if (p >= 0) { - auto k = spawn(knee, DTILE_SMALLSMOKE); + auto k = spawn(knee, PClass::FindActor(NAME_DukeSmallSmoke)); if (k) k->spr.pos.Z -= 8; S_PlayActorSound(KICK_HIT, knee); } @@ -336,7 +336,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int else checkhitceiling(hit.hitSector); } - spawn(spark, DTILE_SMALLSMOKE); + spawn(spark, PClass::FindActor(NAME_DukeSmallSmoke)); } if (hit.actor()) @@ -354,7 +354,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int jib->spr.Angles.Yaw += DAngle22_5 / 2 - randomAngle(22.5); } } - else spawn(spark, DTILE_SMALLSMOKE); + else spawn(spark, PClass::FindActor(NAME_DukeSmallSmoke)); if (p >= 0 && isshootableswitch(hit.actor()->spr.spritetexture())) { @@ -364,7 +364,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int } else if (hit.hitWall) { - spawn(spark, DTILE_SMALLSMOKE); + spawn(spark, PClass::FindActor(NAME_DukeSmallSmoke)); if (isadoorwall(hit.hitWall->walltexture) == 1) goto SKIPBULLETHOLE; @@ -433,7 +433,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int { fi.checkhitsprite(hit.actor(), spark); if (!hit.actor()->isPlayer()) - spawn(spark, DTILE_SMALLSMOKE); + spawn(spark, PClass::FindActor(NAME_DukeSmallSmoke)); else spark->spr.scale = DVector2(0, 0); } else if (hit.hitWall) @@ -1534,7 +1534,7 @@ void checkweapons_d(player_struct* p) { case RPG_WEAPON: case HANDBOMB_WEAPON: - spawn(p->GetActor(), DTILE_EXPLOSION2); + spawn(p->GetActor(), PClass::FindActor(NAME_DukeExplosion2)); break; } } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 261121aaa..a94b0c963 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -151,7 +151,7 @@ static void shootmelee(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int a } if (p >= 0) { - auto k = spawn(wpn, RTILE_SMALLSMOKE); + auto k = spawn(wpn, PClass::FindActor(NAME_DukeSmallSmoke)); if (k) k->spr.pos.Z -= 8; if (atwith == RTILE_KNEE) S_PlayActorSound(KICK_HIT, wpn); else if (isRRRA() && atwith == RTILE_SLINGBLADE) S_PlayActorSound(260, wpn); @@ -312,7 +312,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int checkhitceiling(hit.hitSector); } if (hit.hitSector->lotag != 1) - spawn(spark, RTILE_SMALLSMOKE); + spawn(spark, PClass::FindActor(NAME_DukeSmallSmoke)); } if (hit.actor()) @@ -332,7 +332,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int jib->spr.Angles.Yaw += DAngle22_5 / 2 - randomAngle(22.5); } } - else spawn(spark, RTILE_SMALLSMOKE); + else spawn(spark, PClass::FindActor(NAME_DukeSmallSmoke)); if (p >= 0 && isshootableswitch(hit.actor()->spr.spritetexture())) { @@ -342,7 +342,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int } else if (hit.hitWall != nullptr) { - spawn(spark, RTILE_SMALLSMOKE); + spawn(spark, PClass::FindActor(NAME_DukeSmallSmoke)); if (isadoorwall(hit.hitWall->walltexture) == 1) goto SKIPBULLETHOLE; @@ -410,7 +410,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int { fi.checkhitsprite(hit.actor(), spark); if (!hit.actor()->isPlayer()) - spawn(spark, RTILE_SMALLSMOKE); + spawn(spark, PClass::FindActor(NAME_DukeSmallSmoke)); else spark->spr.scale = DVector2(0, 0); } else if (hit.hitWall != nullptr) @@ -1427,7 +1427,7 @@ void checkweapons_r(player_struct* p) [[fallthrough]]; case DYNAMITE_WEAPON: case CROSSBOW_WEAPON: - spawn(p->GetActor(), RTILE_EXPLOSION2); + spawn(p->GetActor(), PClass::FindActor(NAME_DukeExplosion2)); break; } } diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 60e3763bb..cf43710d4 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -207,8 +207,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* // Twentieth Anniversary World Tour if (!isWorldTour()) break; - [[fallthrough]]; - case DTILE_SMALLSMOKE: if (actj) { @@ -225,16 +223,12 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* act->spr.pos.Z = x - 12; } - if (act->spr.picnum == DTILE_ONFIRE) - { - act->spr.pos.X += krandf(32) - 16; - act->spr.pos.Y += krandf(32) - 16; - act->spr.pos.Z -= krandf(40); - act->spr.cstat |= CSTAT_SPRITE_YCENTER; - } + act->spr.pos.X += krandf(32) - 16; + act->spr.pos.Y += krandf(32) - 16; + act->spr.pos.Z -= krandf(40); + act->spr.cstat |= CSTAT_SPRITE_YCENTER; ChangeActorStat(act, STAT_MISC); - break; case DTILE_PLAYERONWATER: @@ -470,16 +464,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* ChangeActorStat(act, STAT_STANDABLE); break; - case DTILE_STEAM: - if (actj) - { - act->spr.Angles.Yaw = actj->spr.Angles.Yaw; - act->spr.cstat = CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_YCENTER | CSTAT_SPRITE_TRANSLUCENT; - act->spr.scale = DVector2(REPEAT_SCALE, REPEAT_SCALE); - act->vel.X = -0.5; - ssp(act, CLIPMASK0); - } - [[fallthrough]]; case DTILE_CEILINGSTEAM: ChangeActorStat(act, STAT_STANDABLE); break; diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 7f6133763..5cc773e14 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -119,7 +119,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* break; case RTILE_EXPLOSION3: - case RTILE_SMALLSMOKE: if (actj) { act->spr.Angles.Yaw = actj->spr.Angles.Yaw; @@ -133,10 +132,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* act->spr.shade = -127; act->spr.cstat |= CSTAT_SPRITE_YCENTER; } - else if (act->spr.picnum == RTILE_SMALLSMOKE) - { - act->spr.scale = DVector2(0.1875, 0.1875); - } if (actj) { @@ -422,19 +417,11 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* case RTILE_FIRSTAID: case RTILE_SAWAMMO: - case RTILE_BOWLINGBALLSPRITE: if (actj) { act->spr.lotag = 0; - if (act->spr.picnum != RTILE_BOWLINGBALLSPRITE) - { - act->spr.pos.Z -= 32; - act->vel.Z = -4; - } - else - { - act->vel.Z = 0; - } + act->spr.pos.Z -= 32; + act->vel.Z = -4; ssp(act, CLIPMASK0); act->spr.cstat = randomXFlip(); } @@ -518,14 +505,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* case RTILE_AIRTANK: act->spr.scale = DVector2(0.296875, 0.25); break; - case RTILE_BOWLINGBALLSPRITE: - act->spr.scale = DVector2(0.171875, 0.171875); - break; - case RTILE_POWDERKEG: - act->spr.scale = DVector2(0.171875, 0.171875); - act->spr.yint = 4; - act->vel.X = 2; - break; case RTILE_CROSSBOWSPRITE: act->spr.scale = DVector2(0.25, 0.21875); break; @@ -557,16 +536,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* } act->spr.shade = act->sector()->floorshade; break; - case RTILE_STEAM: - if (actj) - { - act->spr.Angles.Yaw = actj->spr.Angles.Yaw; - act->spr.cstat = CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_YCENTER | CSTAT_SPRITE_TRANSLUCENT; - act->spr.scale = DVector2(REPEAT_SCALE, REPEAT_SCALE); - act->vel.X = -0.5; - ssp(act, CLIPMASK0); - } - [[fallthrough]]; case RTILE_CEILINGSTEAM: ChangeActorStat(act, STAT_STANDABLE); break; diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index a5b4ab167..68c805c98 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -7,34 +7,6 @@ BEGIN_DUKE_NS void resetswitch(int tag); -static TMap classnameToTile; -// Workaround so that the script code can be written in its final form. This must go away later. -int PicForName(int intname) -{ - if (classnameToTile.CountUsed() == 0) - { - static std::pair classes[] = { - {"DukeSmallSmoke", "SMALLSMOKE"}, - {"RedneckBowlingBallSprite", "BOWLINGBALLSPRITE"}, - {"DukeSteam", "STEAM"}, - {"RedneckHen", "HEN"}, - {"RedneckCow", "COW"}, - {"RedneckPig", "PIG"}, - {"RedneckBillyRay", "BILLYRAY"}, - {"RedneckMinion", "MINION"}, - - }; - - for (auto& p : classes) - { - classnameToTile.Insert(FName(p.first), tileForName(p.second)); - } - } - auto p = classnameToTile.CheckKey(FName(ENamedName(intname))); - if (p) return *p; - return -1; -} - //--------------------------------------------------------------------------- // // global exports @@ -391,42 +363,29 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, StopSound, DukeActor_StopSound) return 0; } -DDukeActor* DukeActor_Spawn(DDukeActor* origin, int intname) +DDukeActor* DukeActor_Spawn(DDukeActor* origin, PClassActor* cls) { - int picnum = PicForName(intname); - - if (picnum == -1) - { - auto cls = PClass::FindActor(FName(ENamedName(intname))); - if (cls) return spawn(origin, cls); - } - else - { - return spawn(origin, picnum); - } - return nullptr; + return spawn(origin, cls); } DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spawn, DukeActor_Spawn) { PARAM_SELF_PROLOGUE(DDukeActor); - PARAM_INT(type); + PARAM_POINTER(type, PClassActor); ACTION_RETURN_POINTER(DukeActor_Spawn(self, type)); } -void DukeActor_Lotsofstuff(DDukeActor* actor, int count, int intname) +void DukeActor_Lotsofstuff(DDukeActor* actor, PClassActor* intname, int count) { - int picnum = PicForName(intname); - // Todo: make this class aware. - lotsofstuff(actor, count, picnum); + lotsofstuff(actor, count, intname); } -DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, lotsofstuff, DukeActor_Lotsofstuff) +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, lotsofstuff, lotsofstuff) { PARAM_SELF_PROLOGUE(DDukeActor); - PARAM_INT(type); + PARAM_POINTER(type, PClassActor); PARAM_INT(count); - DukeActor_Lotsofstuff(self, count, type); + lotsofstuff(self, count, type); return 0; } @@ -664,27 +623,15 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spritewidth, duke_spw) ACTION_RETURN_INT(duke_spw(self)); } -void DukeActor_shoot(DDukeActor* act, int intname) +void DukeActor_shoot(DDukeActor* act, PClassActor* intname) { - int picnum = PicForName(intname); - - if (picnum == -1) - { - auto n = FName(ENamedName(intname)); - auto cls = PClass::FindActor(n); - assert(cls); - fi.shoot(act, -1, cls); - } - else - { - fi.shoot(act, picnum, nullptr); - } + fi.shoot(act, -1, intname); } DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, shoot, DukeActor_shoot) { PARAM_SELF_PROLOGUE(DDukeActor); - PARAM_INT(type); + PARAM_POINTER(type, PClassActor); DukeActor_shoot(self, type); return 0; } diff --git a/wadsrc/static/filter/dukelike/rmapinfo.spawnclasses b/wadsrc/static/filter/dukelike/rmapinfo.spawnclasses index 98eed78e3..6096c96dd 100644 --- a/wadsrc/static/filter/dukelike/rmapinfo.spawnclasses +++ b/wadsrc/static/filter/dukelike/rmapinfo.spawnclasses @@ -249,6 +249,8 @@ spawnclasses 100 = DukeAtomicHealth 1656 = DukeShrinkerExplosion 661 = DukeWaterBubble + 2329 = DukeSmallSmoke + 1250 = DukeSteam 2000 = DukePigCop 2001 = DukePigCopStayPut diff --git a/wadsrc/static/filter/redneck/rmapinfo.spawnclasses b/wadsrc/static/filter/redneck/rmapinfo.spawnclasses index 9d2f2f177..97f336673 100644 --- a/wadsrc/static/filter/redneck/rmapinfo.spawnclasses +++ b/wadsrc/static/filter/redneck/rmapinfo.spawnclasses @@ -283,6 +283,9 @@ spawnclasses 5595 = RedneckGoogooCluster 240 = DukeWaterBubble 3388 = RedneckCircleStuck + 1554 = DukeSmallSmoke + 1327 = DukeSteam + 3437 = RedneckBowlingBallSprite 4861 = RedneckHen 4862 = RedneckHenStayput diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index c9ba3cc76..0f7502c34 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -107,6 +107,8 @@ version "4.10" #include "zscript/games/duke/actors/burning.zs" #include "zscript/games/duke/actors/explosion2.zs" #include "zscript/games/duke/actors/waterbubble.zs" +#include "zscript/games/duke/actors/smallsmoke.zs" +#include "zscript/games/duke/actors/steam.zs" #include "zscript/games/duke/actors/batteryammo.zs" #include "zscript/games/duke/actors/sixpak.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/bowling.zs b/wadsrc/static/zscript/games/duke/actors/bowling.zs index 4131ad167..27409cc3c 100644 --- a/wadsrc/static/zscript/games/duke/actors/bowling.zs +++ b/wadsrc/static/zscript/games/duke/actors/bowling.zs @@ -346,3 +346,15 @@ class RedneckBowlingBallSpot : RedneckBowlingController class RedneckBowlingPinSpot : RedneckBowlingController { } +class RedneckBowlingBallsprite : DukeActor +{ + default + { + pic "BOWLINGBALLSPRITE"; + } + + override void Initialize() + { + commonItemSetup((0.171875, 0.171875), -1, true); + } +} \ No newline at end of file diff --git a/wadsrc/static/zscript/games/duke/actors/recon.zs b/wadsrc/static/zscript/games/duke/actors/recon.zs index a05649205..13379209c 100644 --- a/wadsrc/static/zscript/games/duke/actors/recon.zs +++ b/wadsrc/static/zscript/games/duke/actors/recon.zs @@ -9,7 +9,7 @@ class DukeRecon : DukeActor Sound PainSnd; Sound RoamSnd; int shift; - String spawntype; // should be 'class' but the spawned types have not all been converted yet. + class spawntype; // should be 'class' but the spawned types have not all been converted yet. override void initialize() { diff --git a/wadsrc/static/zscript/games/duke/actors/smallsmoke.zs b/wadsrc/static/zscript/games/duke/actors/smallsmoke.zs new file mode 100644 index 000000000..99d1a59c8 --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/smallsmoke.zs @@ -0,0 +1,25 @@ +class DukeSmallSmoke : DukeActor +{ + default + { + pic "SMALLSMOKE"; + } + + override void Initialize() + { + let owner = self.ownerActor; + + if (owner && owner != self) + { + self.Angle = owner.Angle; + self.cstat = randomXFlip(); + + double c,f; + [c, f] = self.sector.getSlopes(self.pos.XY); + self.pos.Z = min(self.pos.Z, f - 12); + } + self.scale = (0.375, 0.375); + self.ChangeStat(STAT_MISC); + } +} + diff --git a/wadsrc/static/zscript/games/duke/actors/steam.zs b/wadsrc/static/zscript/games/duke/actors/steam.zs new file mode 100644 index 000000000..3ca3fa108 --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/steam.zs @@ -0,0 +1,22 @@ +class DukeSteam : DukeActor +{ + default + { + pic "STEAM"; + } + + override void Initialize() + { + let owner = self.ownerActor; + + if (owner && owner != self) + { + self.Angle = owner.Angle; + self.cstat = CSTAT_SPRITE_ALIGNMENT_WALL | CSTAT_SPRITE_YCENTER | CSTAT_SPRITE_TRANSLUCENT; + self.vel.X = -0.5; + self.doMove(CLIPMASK0); + } + self.scale = (REPEAT_SCALE, REPEAT_SCALE); + self.ChangeStat(STAT_STANDABLE); + } +} diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index ca1f49146..faf2e4ffa 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -191,7 +191,7 @@ class DukeActor : CoreActor native native int PlayActorSound(Sound snd, int chan = CHAN_AUTO, int flags = 0); native int CheckSoundPlaying(Sound snd, int chan = CHAN_AUTO); native void StopSound(Sound snd, int flags = 0); - native DukeActor spawn(Name type); + 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); @@ -235,7 +235,7 @@ class DukeActor : CoreActor native native double gutsoffset(); native int movesprite(Vector3 move, int clipmask); native int movesprite_ex(Vector3 move, int clipmask, CollisionData coll); - native void shoot(Name spawnclass); + native void shoot(class spawnclass); native void setClipDistFromTile(); native void insertspriteq(); native void operateforcefields(int tag); @@ -274,14 +274,19 @@ class DukeActor : CoreActor native } - void commonItemSetup(Vector2 scale = (0.5, 0.5), int usefloorshade = -1) + void commonItemSetup(Vector2 scale = (0.5, 0.5), int usefloorshade = -1, bool noinitialmove = false) { let owner = self.ownerActor; if (owner != self) { self.lotag = 0; - self.pos.Z -= 32; - self.vel.Z = -4; + if (!noinitialmove) + { + self.pos.Z -= 32; + self.vel.Z = -4; + } + else + self.vel.Z = 0; self.DoMove(CLIPMASK0); self.cstat |= randomxflip(); }