diff --git a/source/core/actorlist.cpp b/source/core/actorlist.cpp index 257337b89..8a2cb5dbb 100644 --- a/source/core/actorlist.cpp +++ b/source/core/actorlist.cpp @@ -372,6 +372,7 @@ void DCoreActor::initFromSprite(spritetype* mspr) spr.cstat = (mspr->cstat & ~ESpriteFlags::FromInt(actorinfo->DefaultCstat)) | (spr.cstat & ESpriteFlags::FromInt(actorinfo->DefaultCstat)); spr.pos = mspr->pos; spr.sectp = mspr->sectp; + spr.clipdist = mspr->clipdist; // this has no associated property because it is needed for initialization of the real clipdist. // only copy those values which have not been defaulted by the class definition. #define setter(flag, var) if (!(actorinfo->DefaultFlags & flag)) spr.var = mspr->var; @@ -388,7 +389,6 @@ void DCoreActor::initFromSprite(spritetype* mspr) setter(DEFF_DETAIL, detail); setter(DEFF_SHADE, shade); setter(DEFF_PAL, pal); - setter(DEFF_CLIPDIST, clipdist); setter(DEFF_BLEND, blend); setter(DEFF_XREPEAT, scale.X); setter(DEFF_YREPEAT, scale.Y); @@ -398,7 +398,7 @@ void DCoreActor::initFromSprite(spritetype* mspr) #undef setter - clipdist = spr.clipdist * 0.25; + if (!(actorinfo->DefaultFlags & DEFF_CLIPDIST)) clipdist = spr.clipdist * 0.25; if (mspr->statnum != 0 && !(actorinfo->DefaultFlags & DEFF_STATNUM)) ChangeActorStat(this, mspr->statnum); } diff --git a/source/core/thingdef_properties.cpp b/source/core/thingdef_properties.cpp index 79e47e174..569cd8d99 100644 --- a/source/core/thingdef_properties.cpp +++ b/source/core/thingdef_properties.cpp @@ -440,10 +440,10 @@ DEFINE_PROPERTY(pal, I, CoreActor) //========================================================================== // //========================================================================== -DEFINE_PROPERTY(clipdist, I, CoreActor) +DEFINE_PROPERTY(clipdist, F, CoreActor) { - PROP_INT_PARM(i, 0); - defaults->spr.clipdist = i; + PROP_FLOAT_PARM(i, 0); + defaults->clipdist = i; bag.Info->ActorInfo()->DefaultFlags |= DEFF_CLIPDIST; } diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index bb9bcd49f..a8174b91e 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1925,7 +1925,7 @@ void handle_se00(DDukeActor* actor) actor->tempval += 4; if (actor->tempval >= 256) callsound(actor->sector(), actor, true); - if (actor->spr.clipdist) direction = 1; // notreallyclipdist + if (actor->spr.detail) direction = 1; else direction = -1; } else actor->tempval = 256; @@ -1953,7 +1953,7 @@ void handle_se00(DDukeActor* actor) actor->tempval -= 4; if (actor->tempval <= 0) callsound(actor->sector(), actor, true); - if (actor->spr.clipdist) direction = -1; // notreallyclipdist + if (actor->spr.detail) direction = -1; else direction = 1; } else actor->tempval = 0; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 074bc31bb..0c0a070a3 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -813,11 +813,6 @@ void movestandables_d(void) continue; } - else if (isIn(picnum, CANWITHSOMETHING, CANWITHSOMETHING2, CANWITHSOMETHING3, CANWITHSOMETHING4)) - { - movecanwithsomething(act); - } - else if (isIn(picnum, EXPLODINGBARREL, WOODENHORSE, diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index a79d4d550..53fd875df 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -732,11 +732,6 @@ void movestandables_r(void) continue; } - else if (picnum == CANWITHSOMETHING) - { - movecanwithsomething(act); - } - else if (isIn(picnum, EXPLODINGBARREL, WOODENHORSE, diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index 5e1503758..018c7f369 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -818,8 +818,8 @@ void spawneffector(DDukeActor* actor, TArray* actors) { if (sectp->lotag == 30) { - if (actor->spr.pal) actor->spr.clipdist = 1; // notreallyclipdist - else actor->spr.clipdist = 0; + if (actor->spr.pal) actor->spr.detail = 1; + else actor->spr.detail = 0; actor->temp_pos.Z = sectp->floorz; sectp->hitagactor = actor; } diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index e01e096e6..9f5e0c8b1 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -999,10 +999,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray* act->clipdist = 2; act->SetOwner(act); break; - case CANWITHSOMETHING: - case CANWITHSOMETHING2: - case CANWITHSOMETHING3: - case CANWITHSOMETHING4: case RUBBERCAN: act->spr.extra = 0; [[fallthrough]]; diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 7f822affa..daaaec894 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -1272,7 +1272,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray* act->clipdist = 2; act->SetOwner(act); break; - case CANWITHSOMETHING: case RUBBERCAN: act->spr.extra = 0; [[fallthrough]]; diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index baab9ec1f..3e04867d1 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -268,6 +268,22 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spawn, DukeActor_Spawn) ACTION_RETURN_POINTER(DukeActor_Spawn(self, type)); } +DDukeActor* DukeActor_Spawnsprite(DDukeActor* origin, int picnum) +{ + if (picnum >= 0 && picnum < MAXTILES) + { + return spawn(origin, picnum); + } + return nullptr; +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spawnsprite, DukeActor_Spawnsprite) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_INT(type); + ACTION_RETURN_POINTER(DukeActor_Spawnsprite(self, type)); +} + DDukeActor* DukeActor_spawnweaponorammo(DDukeActor* origin, unsigned intname) { if (intname > 14) return nullptr; diff --git a/wadsrc/static/filter/duke/engine/engine.def b/wadsrc/static/filter/duke/engine/engine.def index 8bc7060a1..574f04db3 100644 --- a/wadsrc/static/filter/duke/engine/engine.def +++ b/wadsrc/static/filter/duke/engine/engine.def @@ -45,4 +45,9 @@ spawnclasses 4528 = DukeSideBolt4 660 = DukeWaterdrip 160 = DukeDoorshock + 1232 = DukeCanWithSomething + 2807 = DukeCanWithSomething2 + 2808 = DukeCanWithSomething3 + 2809 = DukeCanWithSomething4 + } diff --git a/wadsrc/static/filter/redneck/engine/engine.def b/wadsrc/static/filter/redneck/engine/engine.def index 2993c749f..a97d41568 100644 --- a/wadsrc/static/filter/redneck/engine/engine.def +++ b/wadsrc/static/filter/redneck/engine/engine.def @@ -29,5 +29,6 @@ spawnclasses 1130 = DukeBolt4 239 = DukeWaterdrip 120 = DukeDoorshock + 1309 = DukeCanWithSomething } diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index a8d215398..8040abcfd 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -66,6 +66,7 @@ version "4.10" #include "zscript/games/duke/actors/waterdrip.zs" #include "zscript/games/duke/actors/doorshock.zs" #include "zscript/games/duke/actors/viewscreen.zs" +#include "zscript/games/duke/actors/canwithsomething.zs" #include "zscript/games/blood/bloodgame.zs" #include "zscript/games/blood/ui/menu.zs" diff --git a/wadsrc/static/zscript/coreactor.zs b/wadsrc/static/zscript/coreactor.zs index 141d6f5e5..6c3216b79 100644 --- a/wadsrc/static/zscript/coreactor.zs +++ b/wadsrc/static/zscript/coreactor.zs @@ -66,5 +66,12 @@ class CoreActor native return CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP; } + int randomXFlip() + { + int r = random(0, 1); + if (r == 0) return 0; + return CSTAT_SPRITE_XFLIP; + } + } diff --git a/wadsrc/static/zscript/games/duke/actors/canwithsomething.zs b/wadsrc/static/zscript/games/duke/actors/canwithsomething.zs new file mode 100644 index 000000000..9742a09ba --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/canwithsomething.zs @@ -0,0 +1,60 @@ + +class DukeCanWithSomething : DukeActor +{ + Default + { + extra 0; + clipdist 18; + statnum STAT_ZOMBIEACTOR; + pic "CANWITHSOMETHING"; + } + + override void Initialize() + { + if (self.ownerActor != self) + self.scale = (0.5, 0.5); + self.makeitfall(); + self.cstat = CSTAT_SPRITE_BLOCK_ALL | randomXFlip(); + } + + + override void Tick() + { + self.makeitfall(); + int j = self.ifhitbyweapon(); + if (j >= 0) + { + self.PlayActorSound(DukeSnd.VENT_BUST); + for (j = 0; j < 10; j++) + self.RANDOMSCRAP(); + + if (self.lotag) self.spawnsprite(self.lotag); + self.Destroy(); + } + } +} + +class DukeCanWithSomething2 : DukeCanWithSomething +{ + Default + { + pic "CANWITHSOMETHING2"; + } +} + +class DukeCanWithSomething3 : DukeCanWithSomething +{ + Default + { + pic "CANWITHSOMETHING3"; + } +} + +class DukeCanWithSomething4 : DukeCanWithSomething +{ + Default + { + pic "CANWITHSOMETHING4"; + } +} + diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index 6c276e215..40fcc6a1d 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -128,6 +128,7 @@ class DukeActor : CoreActor native native int domove(int clipmask); native void PlayActorSound(int snd); native DukeActor spawn(Name 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); native void makeitfall();