diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 7cd856b79..549d14e02 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -579,7 +579,7 @@ void operaterespawns(int low) void detonate(DDukeActor *actor, int explosion) { - earthquaketime = 16; + ud.earthquaketime = 16; DukeStatIterator itj(STAT_EFFECTOR); while (auto effector = itj.Next()) @@ -1523,7 +1523,7 @@ void handle_se02(DDukeActor* actor) { if ((actor->temp_data[0] & 31) == 8) { - earthquaketime = 48; + ud.earthquaketime = 48; S_PlayActorSound(EARTHQUAKE, ps[screenpeek].GetActor()); } diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 858098940..249048bfc 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1797,7 +1797,6 @@ DETONATEB: void moveactors_d(void) { int p; - unsigned int k; DukeStatIterator it(STAT_ACTOR); while (auto act = it.Next()) @@ -1826,28 +1825,6 @@ void moveactors_d(void) if (isWorldTour()) flamethrowerflame(act); continue; - case HELECOPT: - case DUKECAR: - - act->spr.pos.Z += act->vel.Z; - act->temp_data[0]++; - - if (act->temp_data[0] == 4) S_PlayActorSound(WAR_AMBIENCE2, act); - - if (act->temp_data[0] > (26 * 8)) - { - S_PlaySound(RPG_EXPLODE); - for (int j = 0; j < 32; j++) - RANDOMSCRAP(act); - earthquaketime = 16; - act->Destroy(); - continue; - } - else if ((act->temp_data[0] & 3) == 0) - spawn(act, EXPLOSION2); - ssp(act, CLIPMASK0); - break; - case GREENSLIME: case GREENSLIME + 1: case GREENSLIME + 2: @@ -2337,7 +2314,7 @@ void moveeffectors_d(void) //STATNUM 3 break; case SE_33_QUAKE_DEBRIS: - if (earthquaketime > 0 && (krand() & 7) == 0) + if (ud.earthquaketime > 0 && (krand() & 7) == 0) RANDOMSCRAP(act); break; case SE_36_PROJ_SHOOTER: diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 0823b7385..50224929f 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -1148,7 +1148,7 @@ static void rrra_specialstats() { S_PlaySound(215); act->Destroy(); - earthquaketime = 32; + ud.earthquaketime = 32; SetPlayerPal(&ps[myconnectindex], PalEntry(32, 32, 32, 48)); } } @@ -2092,7 +2092,7 @@ void moveeffectors_r(void) //STATNUM 3 break; case SE_33_QUAKE_DEBRIS: - if (earthquaketime > 0 && (krand() & 7) == 0) + if (ud.earthquaketime > 0 && (krand() & 7) == 0) RANDOMSCRAP(act); break; case SE_36_PROJ_SHOOTER: diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index db94c149a..769fa2ef8 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1624,9 +1624,9 @@ int ParseState::parse(void) break; case concmd_mamaquake: if (g_ac->spr.pal == 31) - earthquaketime = 4; + ud.earthquaketime = 4; else if (g_ac->spr.pal == 32) - earthquaketime = 6; + ud.earthquaketime = 6; insptr++; break; case concmd_garybanjo: diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index cd87a7ae4..ca9b1696a 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -64,7 +64,7 @@ void GameInterface::Ticker() if (playrunning()) { - if (earthquaketime > 0) earthquaketime--; + if (ud.earthquaketime > 0) ud.earthquaketime--; ud.cameraactor = nullptr; everyothertime++; diff --git a/source/games/duke/src/global.cpp b/source/games/duke/src/global.cpp index 8c627026f..fd61e656f 100644 --- a/source/games/duke/src/global.cpp +++ b/source/games/duke/src/global.cpp @@ -56,7 +56,6 @@ player_struct ps[MAXPLAYERS]; //------------------------------------------------------------------------- int lastvisinc; // weapon flash -int earthquaketime; int global_random; // readonly - one single global per-frame random value. Ugh... // Redneck Rampage diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 662f7138f..ad61e5fea 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -72,7 +72,6 @@ extern int lastvisinc; extern animwalltype animwall[MAXANIMWALLS]; extern int numanimwalls; extern int numclouds; -extern int earthquaketime; extern int global_random; extern int mirrorcnt; extern int numplayersprites; @@ -111,7 +110,6 @@ extern sectortype* mirrorsector[64]; extern walltype* mirrorwall[64]; extern int wupass; -extern int chickenplant; extern int thunderon; extern int ufospawn; extern int ufocnt; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index c709de48f..40dd8a342 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -426,7 +426,7 @@ void resetprestat(int snum,int g) mspos.Clear(); animates.Clear(); camsprite =nullptr; - earthquaketime = 0; + ud.earthquaketime = 0; WindTime = 0; WindDir = nullAngle; diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index cc7a869b1..4fd5a1677 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -314,10 +314,10 @@ void displayrooms(int snum, double interpfrac, bool sceneonly) double cz = p->GetActor()->ceilingz; double fz = p->GetActor()->floorz; - if (earthquaketime > 0 && p->on_ground == 1) + if (ud.earthquaketime > 0 && p->on_ground == 1) { - cpos.Z += 1 - (((earthquaketime) & 1) * 2.); - cangles.Yaw += DAngle::fromBuild((2 - ((earthquaketime) & 2)) << 2); + cpos.Z += 1 - (((ud.earthquaketime) & 1) * 2.); + cangles.Yaw += DAngle::fromBuild((2 - ((ud.earthquaketime) & 2)) << 2); } if (p->GetActor()->spr.pal == 1) cpos.Z -= 18; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index b3f27092c..3b6caa0c9 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -373,7 +373,7 @@ void GameInterface::SerializeGameState(FSerializer& arc) ("numanimwalls", numanimwalls) .Array("animwall", animwall, numanimwalls) ("camsprite", camsprite) - ("earthquaketime", earthquaketime) + ("earthquaketime", ud.earthquaketime) ("gs.freezerhurtowner", gs.freezerhurtowner) ("global_random", global_random) ("gs.impact_damage", gs.impact_damage) diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index 3c461df3c..127cac809 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -355,9 +355,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* act->spr.shade = actj->spr.shade; act->spr.pal = ps[actj->PlayerIndex()].palookup; } - [[fallthrough]]; - case DUKECAR: - case HELECOPT: act->spr.cstat = 0; act->spr.extra = 1; act->vel.X = 292 / 16.; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 207a270ac..87edf967d 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -162,6 +162,7 @@ struct user_defs int m_ffire, ffire, m_player_skill, multimode; int player_skill, marker; int chickenplant; // readonly - used to trigger some special behavior if a special item is found in a map. + int earthquaketime; TObjPtr cameraactor; diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index 60911cee3..290867ec8 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -1323,6 +1323,7 @@ DEFINE_FIELD_X(DukeUserDefs, user_defs, marker); DEFINE_FIELD_X(DukeUserDefs, user_defs, bomb_tag); DEFINE_FIELD_X(DukeUserDefs, user_defs, cameraactor); DEFINE_FIELD_X(DukeUserDefs, user_defs, chickenplant); +DEFINE_FIELD_X(DukeUserDefs, user_defs, earthquaketime); DEFINE_FIELD_X(DukeUserDefs, user_defs, ufospawnsminion); DEFINE_GLOBAL_UNSIZED(ud) diff --git a/wadsrc/static/filter/dukelike/engine/engine.def b/wadsrc/static/filter/dukelike/engine/engine.def index 1f951ba71..9a8be40b2 100644 --- a/wadsrc/static/filter/dukelike/engine/engine.def +++ b/wadsrc/static/filter/dukelike/engine/engine.def @@ -74,6 +74,8 @@ spawnclasses 4502 = DukeLetter 4361 = DukeDuck 4359 = DukeTarget + 1346 = DukeHelicopter + 2491 = DukeCar 1272 = DukeTrash 634 = DukeBolt1 diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index a362f53b1..c40426222 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -86,6 +86,7 @@ version "4.10" #include "zscript/games/duke/actors/reactor.zs" #include "zscript/games/duke/actors/destructibles.zs" #include "zscript/games/duke/actors/ducktarget.zs" +#include "zscript/games/duke/actors/helicopt.zs" #include "zscript/games/duke/actors/redneckmisc.zs" #include "zscript/games/duke/actors/rabbitspawner.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/helicopt.zs b/wadsrc/static/zscript/games/duke/actors/helicopt.zs new file mode 100644 index 000000000..9394f182d --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/helicopt.zs @@ -0,0 +1,46 @@ +class DukeCar : DukeActor +{ + default + { + extra 1; + clipdist 32; + pic "DUKECAR"; + statnum STAT_ACTOR; + } + + override void Initialize() + { + self.vel.X = 292 / 16.; + self.vel.Z = 360 / 256.; + self.cstat = CSTAT_SPRITE_BLOCK_ALL; + } + + override void Tick() + { + self.pos.Z += self.vel.Z; + self.temp_data[0]++; + + if (self.temp_data[0] == 4) self.PlayActorSound("WAR_AMBIENCE2"); + + if (self.temp_data[0] > (26 * 8)) + { + Duke.PlaySound("RPG_EXPLODE"); + for (int j = 0; j < 32; j++) + self.RANDOMSCRAP(); + ud.earthquaketime = 16; + self.Destroy(); + return; + } + else if ((self.temp_data[0] & 3) == 0) + self.spawn("DukeExplosion2"); + self.DoMove(CLIPMASK0); + } +} + +class DukeHelicopter : DukeCar +{ + default + { + pic "HELECOPT"; + } +} diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index a86beda0b..b41ce4ef5 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -446,7 +446,8 @@ struct DukeUserDefs native native readonly int respawn_monsters, respawn_items, respawn_inventory, recstat, monsters_off, brightness; native readonly int ffire, multimode; native readonly int player_skill, marker, chickenplant; - + + native int earthquaketime; native uint8 ufospawnsminion; native int16 bomb_tag; native DukeActor cameraactor;