diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index b08fe3aa1..4b6a6180d 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -893,50 +893,6 @@ static void shootmortar(DDukeActor* actor, int p, const DVector3& pos, DAngle an // //--------------------------------------------------------------------------- -static void shootshrinker(DDukeActor* actor, int p, const DVector3& pos, DAngle ang, int atwith) -{ - double vel = 48.; - double zvel; - if (actor->spr.extra >= 0) actor->spr.shade = -96; - if (p >= 0) - { - auto aimed = isNamWW2GI() ? nullptr : aim(actor, AUTO_AIM_ANGLE); - if (aimed) - { - auto tex = TexMan.GetGameTexture(aimed->spr.spritetexture()); - double dal = ((aimed->spr.scale.X * tex->GetDisplayHeight()) * 0.5); - double dist = (ps[p].GetActor()->spr.pos.XY() - aimed->spr.pos.XY()).Length(); - zvel = ((aimed->spr.pos.Z - pos.Z - dal - 4) * 48) / dist; - ang = (aimed->spr.pos.XY() - pos.XY()).Angle(); - } - else - setFreeAimVelocity(vel, zvel, ps[p].Angles.getPitchWithView(), 49.); - } - else if (actor->spr.statnum != 3) - { - double x; - int j = findplayer(actor, &x); - double dist = (ps[j].GetActor()->spr.pos.XY() - actor->spr.pos.XY()).Length(); - zvel = ((ps[j].GetActor()->getOffsetZ() - pos.Z) * 32) / dist; - } - else zvel = 0; - - auto spawned = CreateActor(actor->sector(), - pos.plusZ(2) + ang.ToVector() * 0.25, PClass::FindActor("DukeShrinkSpark"), -16, DVector2(0.4375, 0.4375), ang, vel, zvel, actor, 4); - - if (spawned) - { - spawned->spr.cstat = CSTAT_SPRITE_YCENTER; - spawned->clipdist = 8; - } -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - void shoot_d(DDukeActor* actor, int atwith, PClass *cls) { int p; @@ -1024,10 +980,6 @@ void shoot_d(DDukeActor* actor, int atwith, PClass *cls) case DTILE_GROWSPARK: shootgrowspark(actor, p, spos, sang); break; - - case DTILE_SHRINKER: - shootshrinker(actor, p, spos, sang, atwith); - break; } return; } diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index dcedf55bc..feb9cecfb 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -158,6 +158,10 @@ version "4.10" #include "zscript/games/duke/actors/pig.zs" #include "zscript/games/duke/actors/rabbit.zs" + +#include "zscript/games/duke/actors/dukeweapons/shrinker.zs" + + #include "zscript/games/duke/world/dukebreak.zs" #include "zscript/games/duke/world/redneckbreak.zs" diff --git a/wadsrc/static/zscript/games/duke/actors/_placeholders.zs b/wadsrc/static/zscript/games/duke/actors/_placeholders.zs index fb865ba68..dab4536a4 100644 --- a/wadsrc/static/zscript/games/duke/actors/_placeholders.zs +++ b/wadsrc/static/zscript/games/duke/actors/_placeholders.zs @@ -36,14 +36,6 @@ class DukeShotgunShot : DukeActor } } -class DukeShrinker : DukeActor -{ - default - { - pic "SHRINKER"; - } -} - class RedneckShotgunShot : DukeShotgunShot { } diff --git a/wadsrc/static/zscript/games/duke/actors/dukeweapons/shrinker.zs b/wadsrc/static/zscript/games/duke/actors/dukeweapons/shrinker.zs new file mode 100644 index 000000000..0cac56cec --- /dev/null +++ b/wadsrc/static/zscript/games/duke/actors/dukeweapons/shrinker.zs @@ -0,0 +1,120 @@ +class DukeShrinker : DukeActor +{ + default + { + pic "SHRINKER"; + } + + override bool ShootThis(DukeActor shooter, DukePlayer p, Vector3 pos, double ang) const + { + double vel = 48.; + double zvel; + if (shooter.extra >= 0) shooter.shade = -96; + if (p != null) + { + let aimed = Raze.IsNamWW2GI()? null : shooter.aim(self); + if (aimed) + { + double dal = ((aimed.scale.X * aimed.spriteHeight()) * 0.5); // note the incorrect scale this uses! + double dist = (p.actor.pos.XY - aimed.pos.XY).Length(); + zvel = ((aimed.pos.Z - pos.Z - dal - 4) * 48) / dist; + ang = (aimed.pos.XY - pos.XY).Angle(); + } + else + [vel, zvel] = Raze.setFreeAimVelocity(vel, zvel, p.getPitchWithView(), 49.); + } + else if (shooter.statnum != STAT_EFFECTOR) + { + double x; + DukePlayer j; + [j, x] = shooter.findplayer(); + double dist = (j.actor.pos.XY - shooter.pos.XY).Length(); + zvel = ((j.actor.viewzoffset - pos.Z) * 32) / dist; + } + else zvel = 0; + + let spawned = dlevel.SpawnActor(shooter.sector, pos.plusZ(2) + ang.ToVector() * 0.25, "DukeShrinkSpark", -16, (0.4375, 0.4375), ang, vel, zvel, shooter, STAT_PROJECTILE); + + if (spawned) + { + spawned.cstat = CSTAT_SPRITE_YCENTER; + spawned.clipdist = 8; + } + return true; + } +} +/* +class NamShrinker : DukeShrinker +{ + default + { + +NOAUTOAIM; + } +} +*/ + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +class DukeShrinkSpark : DukeProjectile +{ + default + { + spriteset "SHRINKSPARK", "SHRINKSPARK1", "SHRINKSPARK2", "SHRINKSPARK3"; + +FULLBRIGHT; + +MIRRORREFLECT; + +NOFLOORPAL; + } + + override void posthiteffect(CollisionData coll) + { + self.spawn('DukeShrinkerExplosion'); + self.PlayActorSound("SHRINKER_HIT"); + self.hitradius(gs.shrinkerblastradius, 0, 0, 0, 0); + self.Destroy(); + } + + override bool animate(tspritetype tspr) + { + tspr.setSpritePic(self, (PlayClock >> 4) & 3); + return true; + } + + override class GetRadiusDamageType(int targhealth) + { + return 'DukeShrinkSpark'; + } + +} + + +class DukeShrinkerExplosion : DukeActor +{ + default + { + spriteset "SHRINKEREXPLOSION"; + +FULLBRIGHT; + +FORCERUNCON; + } + + override void Initialize() + { + let owner = self.ownerActor; + if (owner != self) + { + self.Angle = owner.Angle; + self.cstat = CSTAT_SPRITE_YCENTER | randomXFlip(); + double c,f; + [c, f] = self.sector.getSlopes(self.pos.XY); + self.pos.Z = min(self.pos.Z, f - 12); + } + self.shade = -64; + self.scale = (0.5, 0.5); + self.ChangeStat(STAT_MISC); + } + +} + diff --git a/wadsrc/static/zscript/games/duke/actors/projectiles.zs b/wadsrc/static/zscript/games/duke/actors/projectiles.zs index f50c50e60..4dce389d5 100644 --- a/wadsrc/static/zscript/games/duke/actors/projectiles.zs +++ b/wadsrc/static/zscript/games/duke/actors/projectiles.zs @@ -266,71 +266,6 @@ class DukeFirelaserTrail : DukeActor // //--------------------------------------------------------------------------- -class DukeShrinkSpark : DukeProjectile -{ - default - { - spriteset "SHRINKSPARK", "SHRINKSPARK1", "SHRINKSPARK2", "SHRINKSPARK3"; - +FULLBRIGHT; - +MIRRORREFLECT; - +NOFLOORPAL; - } - - override void posthiteffect(CollisionData coll) - { - self.spawn('DukeShrinkerExplosion'); - self.PlayActorSound("SHRINKER_HIT"); - self.hitradius(gs.shrinkerblastradius, 0, 0, 0, 0); - self.Destroy(); - } - - override bool animate(tspritetype tspr) - { - tspr.setSpritePic(self, (PlayClock >> 4) & 3); - return true; - } - - override class GetRadiusDamageType(int targhealth) - { - return 'DukeShrinkSpark'; - } - -} - - -class DukeShrinkerExplosion : DukeActor -{ - default - { - spriteset "SHRINKEREXPLOSION"; - +FULLBRIGHT; - +FORCERUNCON; - } - - override void Initialize() - { - let owner = self.ownerActor; - if (owner != self) - { - self.Angle = owner.Angle; - self.cstat = CSTAT_SPRITE_YCENTER | randomXFlip(); - double c,f; - [c, f] = self.sector.getSlopes(self.pos.XY); - self.pos.Z = min(self.pos.Z, f - 12); - } - self.shade = -64; - self.scale = (0.5, 0.5); - self.ChangeStat(STAT_MISC); - } - -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - class DukeRPG : DukeProjectile { default