From f9826241ef4a0ba50c7d26d7590f725fa0c6f617 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 17 Nov 2022 19:30:21 +0100 Subject: [PATCH] - scriptied the cracks. --- source/games/duke/src/actors_d.cpp | 38 --------- source/games/duke/src/actors_r.cpp | 38 --------- source/games/duke/src/animatesprites_d.cpp | 4 - source/games/duke/src/animatesprites_r.cpp | 4 - source/games/duke/src/spawn_d.cpp | 16 +--- source/games/duke/src/spawn_r.cpp | 20 ----- source/games/duke/src/vmexports.cpp | 15 ++++ wadsrc/static/filter/duke/engine/engine.def | 4 + .../static/filter/redneck/engine/engine.def | 4 + wadsrc/static/zscript.txt | 1 + .../static/zscript/games/duke/actors/crack.zs | 83 +++++++++++++++++++ wadsrc/static/zscript/games/duke/dukeactor.zs | 1 + 12 files changed, 110 insertions(+), 118 deletions(-) create mode 100644 wadsrc/static/zscript/games/duke/actors/crack.zs diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 923055ce6..d821c8cde 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -800,39 +800,6 @@ void movefallers_d(void) // //--------------------------------------------------------------------------- -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void movecrack(DDukeActor* actor) -{ - if (actor->spr.hitag > 0) - { - actor->temp_data[0] = actor->spr.cstat; - actor->temp_angle = actor->spr.angle; - int j = fi.ifhitbyweapon(actor); - if (gs.actorinfo[j].flags2 & SFLAG2_EXPLOSIVE) - { - DukeStatIterator it(STAT_STANDABLE); - while (auto a1 = it.Next()) - { - if (actor->spr.hitag == a1->spr.hitag && actorflag(a1, SFLAG2_BRIGHTEXPLODE)) - if (a1->spr.shade != -32) - a1->spr.shade = -32; - } - detonate(actor, EXPLOSION2); - } - else - { - actor->spr.cstat = ESpriteFlags::FromInt(actor->temp_data[0]); - actor->spr.angle = actor->temp_angle; - actor->spr.extra = 0; - } - } -} - //--------------------------------------------------------------------------- // // Duke only @@ -1035,11 +1002,6 @@ void movestandables_d(void) continue; } - else if (picnum >= CRACK1 && picnum <= CRACK1 + 3) - { - movecrack(act); - } - else if (picnum == FIREEXT) { movefireext(act); diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 8a80e90e6..e0c0e67eb 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -713,39 +713,6 @@ void movefallers_r(void) // //--------------------------------------------------------------------------- -static void movecrack(DDukeActor* actor) -{ - if (actor->spr.hitag > 0) - { - actor->temp_data[0] = actor->spr.cstat; - actor->temp_angle = actor->spr.angle; - int j = fi.ifhitbyweapon(actor); - if (gs.actorinfo[j].flags2 & SFLAG2_EXPLOSIVE) - { - DukeStatIterator it(STAT_STANDABLE); - while (auto a1 = it.Next()) - { - if (actor->spr.hitag == a1->spr.hitag && actorflag(a1, SFLAG2_BRIGHTEXPLODE)) - if (a1->spr.shade != -32) - a1->spr.shade = -32; - } - detonate(actor, EXPLOSION2); - } - else - { - actor->spr.cstat = ESpriteFlags::FromInt(actor->temp_data[0]); - actor->spr.angle = actor->temp_angle; - actor->spr.extra = 0; - } - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - static void movebolt(DDukeActor* actor) { double xx; @@ -826,11 +793,6 @@ void movestandables_r(void) continue; } - else if (picnum >= CRACK1 && picnum <= CRACK1 + 3) - { - movecrack(act); - } - else if (picnum == OOZFILTER || picnum == SEENINE || picnum == SEENINEDEAD || picnum == (SEENINEDEAD + 1)) { moveooz(act, SEENINE, SEENINEDEAD, OOZFILTER, EXPLOSION2); diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 5b770af59..039f6d781 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -106,10 +106,6 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi } [[fallthrough]]; case BULLETHOLE: - case CRACK1: - case CRACK2: - case CRACK3: - case CRACK4: t->shade = 16; continue; case NEON1: diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index d29e397a4..cac8b4aeb 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -84,10 +84,6 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi } [[fallthrough]]; case BULLETHOLE: - case CRACK1: - case CRACK2: - case CRACK3: - case CRACK4: t->shade = 16; continue; diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index fba08314f..62c4417ef 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -1060,21 +1060,9 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* ChangeActorStat(act, STAT_STANDABLE); break; - case CRACK1: - case CRACK2: - case CRACK3: - case CRACK4: case FIREEXT: - if (act->spr.picnum == FIREEXT) - { - act->spr.cstat = CSTAT_SPRITE_BLOCK_ALL; - act->spr.extra = gs.impact_damage << 2; - } - else - { - act->spr.cstat |= (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) ? CSTAT_SPRITE_BLOCK : (CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_ALIGNMENT_WALL); - act->spr.extra = 1; - } + act->spr.cstat = CSTAT_SPRITE_BLOCK_ALL; + act->spr.extra = gs.impact_damage << 2; if (ud.multimode < 2 && act->spr.pal != 0) { diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index fb19c284f..bfa77c081 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -1286,26 +1286,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* ChangeActorStat(act, STAT_STANDABLE); break; - case CRACK1: - case CRACK2: - case CRACK3: - case CRACK4: - act->spr.cstat |= CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_ALIGNMENT_WALL; - act->spr.extra = 1; - if (ud.multimode < 2 && act->spr.pal != 0) - { - act->spr.scale = DVector2(0, 0); - ChangeActorStat(act, STAT_MISC); - break; - } - - act->spr.pal = 0; - act->SetOwner(act); - ChangeActorStat(act, STAT_STANDABLE); - act->vel.X = 0.5; - ssp(act, CLIPMASK0); - break; - case EMPTYBIKE: if (!isRRRA()) goto default_case; if (ud.multimode < 2 && act->spr.pal == 1) diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index 227d04615..4bc01e540 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -317,6 +317,21 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, ChangeStat, ChangeActorStat) return 0; } +void DukeActor_detonate(DDukeActor* origin, int intname) +{ + // all callers use "EXPLOSION2", so ignore the parameter for now + int picnum = TileFiles.tileForName("EXPLOSION2"); + detonate(origin, picnum); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, detonate, DukeActor_detonate) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_INT(type); + DukeActor_detonate(self, type); + return 0; +} + // temporary helpers to hide the fact that these flags are not part of the actor yet. DEFINE_ACTION_FUNCTION(DDukeActor, actorflag1) diff --git a/wadsrc/static/filter/duke/engine/engine.def b/wadsrc/static/filter/duke/engine/engine.def index 235fd78c4..8f1ce2aec 100644 --- a/wadsrc/static/filter/duke/engine/engine.def +++ b/wadsrc/static/filter/duke/engine/engine.def @@ -16,4 +16,8 @@ spawnclasses 939 = DukeCactusBroke 2566 = DukeTripbombPlaced 2567 = DukeLaserline + 546 = DukeCrack1 + 547 = DukeCrack2 + 548 = DukeCrack3 + 549 = DukeCrack4 } diff --git a/wadsrc/static/filter/redneck/engine/engine.def b/wadsrc/static/filter/redneck/engine/engine.def index 36badf852..d44976efd 100644 --- a/wadsrc/static/filter/redneck/engine/engine.def +++ b/wadsrc/static/filter/redneck/engine/engine.def @@ -13,5 +13,9 @@ spawnclasses 1230 = DukeTire 1194 = DukeCactus 1203 = DukeCactusBroke + 1075 = DukeCrack1 + 1076 = DukeCrack2 + 1077 = DukeCrack3 + 1078 = DukeCrack4 } diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 32c3d9105..3c05aa51c 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -56,6 +56,7 @@ version "4.10" #include "zscript/games/duke/actors/scrap.zs" #include "zscript/games/duke/actors/cactus.zs" #include "zscript/games/duke/actors/tripbomb.zs" +#include "zscript/games/duke/actors/crack.zs" #include "zscript/games/blood/bloodgame.zs" #include "zscript/games/blood/ui/menu.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/crack.zs b/wadsrc/static/zscript/games/duke/actors/crack.zs new file mode 100644 index 000000000..d0e21d69c --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/crack.zs @@ -0,0 +1,83 @@ + +class DukeCrack1 : DukeActor +{ + default + { + statnum STAT_STANDABLE; + pic "CRACK1"; + } + + override void Initialize() + { + self.cstat |= (self.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) ? CSTAT_SPRITE_BLOCK : (CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_ALIGNMENT_WALL); + self.extra = 1; + + if (ud.multimode < 2 && self.pal != 0) + { + self.scale = (0, 0); + self.ChangeStat(STAT_MISC); + return; + } + + self.pal = 0; + self.ownerActor = self; + self.vel.X = 0.5; + self.DoMove(CLIPMASK0); + } + + override void Tick() + { + if (self.hitag > 0) + { + self.temp_data[0] = self.cstat; + self.temp_angle = self.angle; + if (self.ifhitbyweapon() >= 0 && self.attackerflag2(SFLAG2_EXPLOSIVE)) + { + DukeStatIterator it; + for(let a1 = it.First(STAT_STANDABLE); a1; a1 = it.Next()) + { + if (self.hitag == a1.hitag && a1.actorflag2(SFLAG2_BRIGHTEXPLODE)) + if (a1.shade != -32) + a1.shade = -32; + } + self.detonate('DukeExplosion2'); + } + else + { + self.cstat = self.temp_data[0]; + self.angle = self.temp_angle; + self.extra = 0; + } + } + } + + override bool animate(tspritetype tspr) + { + tspr.shade = 16; + return true; + } +} + +class DukeCrack2 : DukeCrack1 +{ + default + { + pic "CRACK2"; + } +} + +class DukeCrack3 : DukeCrack1 +{ + default + { + pic "CRACK3"; + } +} + +class DukeCrack4 : DukeCrack1 +{ + default + { + pic "CRACK4"; + } +} diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index 56c9dcd98..ecda4494c 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -75,6 +75,7 @@ class DukeActor : CoreActor native native DukeActor spawnweaponorammo(int type); native void lotsofglass(int count); native void makeitfall(); + native void detonate(name type); virtual void BeginPlay() {} virtual void Initialize() {}