From c73830992f0ba97ef6b305814915ebc39acd3dd4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 23 Dec 2022 08:55:13 +0100 Subject: [PATCH] - added a few exports and properties for weapon shooting and added missing 'const' annotations for ShootThis overrides. --- source/core/namedef_custom.h | 1 + source/core/thingdef_data.cpp | 2 +- source/core/vmexports.cpp | 2 ++ source/games/duke/src/constants.h | 4 +-- source/games/duke/src/funct.h | 3 +- source/games/duke/src/player.cpp | 13 ++++++-- source/games/duke/src/vmexports.cpp | 33 +++++++++++++++++++ .../zscript/games/duke/actors/bowling.zs | 2 +- .../zscript/games/duke/actors/firefly.zs | 2 +- .../zscript/games/duke/actors/greenslime.zs | 1 + .../static/zscript/games/duke/actors/mech.zs | 1 + .../zscript/games/duke/actors/powderkeg.zs | 2 +- wadsrc/static/zscript/games/duke/dukeactor.zs | 7 ++++ wadsrc/static/zscript/games/duke/dukegame.zs | 1 + wadsrc/static/zscript/maptypes.zs | 6 ++-- 15 files changed, 66 insertions(+), 14 deletions(-) diff --git a/source/core/namedef_custom.h b/source/core/namedef_custom.h index 680880566..696f03853 100644 --- a/source/core/namedef_custom.h +++ b/source/core/namedef_custom.h @@ -73,3 +73,4 @@ xx(gutsoffset) xx(falladjustz) xx(aimoffset) xx(strength) +xx(autoaimangle) \ No newline at end of file diff --git a/source/core/thingdef_data.cpp b/source/core/thingdef_data.cpp index 3d3c4361b..bc38e40aa 100644 --- a/source/core/thingdef_data.cpp +++ b/source/core/thingdef_data.cpp @@ -107,7 +107,7 @@ static FFlagDef DukeActorFlagDefs[] = DEFINE_FLAG(SFLAG, BOSS, DDukeActor, flags1), DEFINE_FLAG(SFLAG, BADGUYSTAYPUT, DDukeActor, flags1), DEFINE_FLAG(SFLAG, GREENSLIMEFOOD, DDukeActor, flags1), - //DEFINE_FLAG(SFLAG, SKILLFILTER, DDukeActor, flags1), + DEFINE_FLAG(SFLAG, NOAUTOAIM, DDukeActor, flags1), DEFINE_FLAG(SFLAG, NOWATERDIP, DDukeActor, flags1), DEFINE_FLAG(SFLAG, INTERNAL_BADGUY, DDukeActor, flags1), DEFINE_FLAG(SFLAG, KILLCOUNT, DDukeActor, flags1), diff --git a/source/core/vmexports.cpp b/source/core/vmexports.cpp index 4754510ac..dad43c800 100644 --- a/source/core/vmexports.cpp +++ b/source/core/vmexports.cpp @@ -187,6 +187,8 @@ DEFINE_FIELD_X(sectortype, sectortype, shadedsector) DEFINE_FIELD_NAMED_X(walltype, walltype, xpan_, xpan) DEFINE_FIELD_NAMED_X(walltype, walltype, ypan_, ypan) +DEFINE_FIELD_X(walltype, walltype, walltexture) +DEFINE_FIELD_X(walltype, walltype, overtexture) DEFINE_FIELD_X(walltype, walltype, pos) DEFINE_FIELD_X(walltype, walltype, point2) DEFINE_FIELD_X(walltype, walltype, nextwall) diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index 5772a79cc..d607c5da7 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -327,11 +327,11 @@ enum sflags_t SFLAG_BOSS = 0x00000010, SFLAG_BADGUYSTAYPUT = 0x00000020, SFLAG_GREENSLIMEFOOD = 0x00000040, - SFLAG_SKILLFILTER = 0x00000080, + SFLAG_NOAUTOAIM = 0x00000080, SFLAG_NOWATERDIP = 0x00000100, SFLAG_INTERNAL_BADGUY = 0x00000200, // a separate flag is needed for the internal ones because SFLAG_BADGUY has additional semantics. SFLAG_KILLCOUNT = 0x00000400, - //SFLAG_NOCANSEECHECK = 0x00000800, // not used, was applied to all actors with LOOKALLAROUND. + SFLAG_SKILLFILTER = 0x00000800, // not used, was applied to all actors with LOOKALLAROUND. SFLAG_HITRADIUSCHECK = 0x00001000, SFLAG_LOOKALLAROUND = 0x00002000, SFLAG_MOVEFTA_MAKESTANDABLE = 0x00004000, diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index a6df836af..7f83f3904 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -107,7 +107,8 @@ void playerLookDown(int snum, ESyncBits actions); void playerAimUp(int snum, ESyncBits actions); void playerAimDown(int snum, ESyncBits actions); void tracers(const DVector3& start, const DVector3& dest, int n); -DDukeActor* aim(DDukeActor* s, int aang); +DDukeActor* aim(DDukeActor* s, int aang, bool force = true); +DDukeActor* aim_(DDukeActor* actor, DDukeActor* weapon); void checkweapons(player_struct* const p); int findotherplayer(int p, double* d); void quickkill(player_struct* p); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index f3c44e57c..1c6aee0e1 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -225,9 +225,9 @@ double hitawall(player_struct* p, walltype** hitw) // //--------------------------------------------------------------------------- -DDukeActor* aim(DDukeActor* actor, int abase) +DDukeActor* aim(DDukeActor* actor, int abase, bool force) { - DAngle aang = DAngle90 * (+AUTO_AIM_ANGLE / 512.); + DAngle aang = mapangle(abase); bool gotshrinker, gotfreezer; static const int aimstats[] = { STAT_PLAYER, STAT_DUMMYPLAYER, STAT_ACTOR, STAT_ZOMBIEACTOR }; @@ -238,7 +238,7 @@ DDukeActor* aim(DDukeActor* actor, int abase) if (actor->isPlayer()) { auto* plr = &ps[actor->PlayerIndex()]; - int autoaim = Autoaim(actor->PlayerIndex()); + int autoaim = force? 1 : Autoaim(actor->PlayerIndex()); if (!autoaim) { // Some fudging to avoid aim randomization when autoaim is off. @@ -365,6 +365,13 @@ DDukeActor* aim(DDukeActor* actor, int abase) return aimed; } +// This is what aim should be. +DDukeActor* aim_(DDukeActor* actor, DDukeActor* weapon) +{ + if (!weapon || (weapon->flags1 & SFLAG_NOAUTOAIM)) return nullptr; + return aim(actor, int(weapon->FloatVar(NAME_autoaimangle) * (512 / 90.)), (weapon->flags1 & SFLAG_FORCEAUTOAIM)); +} + //--------------------------------------------------------------------------- // // diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index e6daf53f0..4e9762e89 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -202,6 +202,19 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Duke, setlastvisinc, setlastvisinc) return 0; } +int Duke_isaccessswitch(int texint) +{ + return isaccessswitch(FSetTextureID(texint)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Duke, isaccessswitch, Duke_isaccessswitch) +{ + PARAM_PROLOGUE; + PARAM_INT(v); + ACTION_RETURN_BOOL(Duke_isaccessswitch(v)); + return 0; +} + DEFINE_GLOBAL_UNSIZED(dlevel) DEFINE_GLOBAL(camsprite) @@ -608,6 +621,18 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spritewidth, duke_spw) ACTION_RETURN_INT(duke_spw(self)); } +int duke_sph(DDukeActor* act) +{ + auto tex = TexMan.GetGameTexture(act->spr.spritetexture()); + return (int)tex->GetDisplayHeight(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spriteheight, duke_sph) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + ACTION_RETURN_INT(duke_sph(self)); +} + void DukeActor_shoot(DDukeActor* act, PClassActor* intname) { fi.shoot(act, -1, intname); @@ -661,6 +686,14 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, restoreloc, DukeActor_restoreloc) return 0; } +DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, aim, aim_) +{ + PARAM_SELF_PROLOGUE(DDukeActor); + PARAM_POINTER(weapon, DDukeActor); + ACTION_RETURN_POINTER(aim_(self, weapon)); +} + + DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, addkill, addkill) { PARAM_SELF_PROLOGUE(DDukeActor); diff --git a/wadsrc/static/zscript/games/duke/actors/bowling.zs b/wadsrc/static/zscript/games/duke/actors/bowling.zs index ecdef5766..a24893223 100644 --- a/wadsrc/static/zscript/games/duke/actors/bowling.zs +++ b/wadsrc/static/zscript/games/duke/actors/bowling.zs @@ -232,7 +232,7 @@ class RedneckBowlingBall : RedneckBowlingPin targ.PlayActorSound("BOWLPIN"); } - override bool ShootThis(DukeActor actor, DukePlayer plr, Vector3 spos, double sang) + override bool ShootThis(DukeActor actor, DukePlayer plr, Vector3 spos, double sang) const { let j = actor.spawn(self.GetClassName()); if (j) diff --git a/wadsrc/static/zscript/games/duke/actors/firefly.zs b/wadsrc/static/zscript/games/duke/actors/firefly.zs index abd99f061..b3abbd35b 100644 --- a/wadsrc/static/zscript/games/duke/actors/firefly.zs +++ b/wadsrc/static/zscript/games/duke/actors/firefly.zs @@ -73,7 +73,7 @@ class DukeFirefly : DukeActor +KILLCOUNT; } - override bool ShootThis(DukeActor shooter, DukePlayer p, Vector3 spos, double sang) + override bool ShootThis(DukeActor shooter, DukePlayer p, Vector3 spos, double sang) const { let k = shooter.spawn("DukeFirefly"); if (k) diff --git a/wadsrc/static/zscript/games/duke/actors/greenslime.zs b/wadsrc/static/zscript/games/duke/actors/greenslime.zs index b9d5a1544..256468028 100644 --- a/wadsrc/static/zscript/games/duke/actors/greenslime.zs +++ b/wadsrc/static/zscript/games/duke/actors/greenslime.zs @@ -8,6 +8,7 @@ class DukeGreenSlime : DukeActor +DONTDIVEALIVE; +FORCESECTORSHADE; +SHRINKAUTOAIM; + sparkoffset -8; } override void Initialize() diff --git a/wadsrc/static/zscript/games/duke/actors/mech.zs b/wadsrc/static/zscript/games/duke/actors/mech.zs index cbd00dbba..7e552f11b 100644 --- a/wadsrc/static/zscript/games/duke/actors/mech.zs +++ b/wadsrc/static/zscript/games/duke/actors/mech.zs @@ -46,6 +46,7 @@ class DukeRotateGun : DukeActor +KILLCOUNT; +NODAMAGEPUSH; +NORADIUSPUSH; + sparkoffset -8; aimoffset 32; } diff --git a/wadsrc/static/zscript/games/duke/actors/powderkeg.zs b/wadsrc/static/zscript/games/duke/actors/powderkeg.zs index d65abcea7..4a26b257d 100644 --- a/wadsrc/static/zscript/games/duke/actors/powderkeg.zs +++ b/wadsrc/static/zscript/games/duke/actors/powderkeg.zs @@ -24,7 +24,7 @@ class RedneckPowderKeg : DukeItemBase } - override bool shootthis(DukeActor actor, DukePlayer p, Vector3 spos, double sang) + override bool shootthis(DukeActor actor, DukePlayer p, Vector3 spos, double sang) const { let j = actor.spawn("RedneckPowderKeg"); if (j) diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index d4c4eed51..650cf260f 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -89,6 +89,7 @@ class DukeActor : CoreActor native { lookallarounddefault; falladjustz 24; + autoaimangle 8.4375; } enum EStatnums { @@ -146,12 +147,16 @@ class DukeActor : CoreActor native meta int falladjustz; meta int aimoffset; meta int strength; + meta double autoaimangle; + meta double sparkoffset; property prefix: none; property gutsoffset: gutsoffset; property falladjustz: falladjustz; property aimoffset: aimoffset; property strength: strength; + property autoaimangle: autoaimangle; + property sparkoffset: sparkoffset; native void SetSpritesetImage(int index); @@ -198,6 +203,8 @@ class DukeActor : CoreActor native native void checkhitdefault(DukeActor proj); native void operatesectors(sectortype sec); native int SpriteWidth(); + native int SpriteHeight(); + native DukeActor aim(readonly weapon); virtual native void Tick(); diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index 2215ab5e9..1ad0a1d24 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -173,6 +173,7 @@ struct Duke native native static void StopCommentary(); static native int getPlayerIndex(DukePlayer p); static native void setlastvisinc(int amount); + static native bool isaccessswitch(TextureID tex); static int rnd(int val) { return (random(0, 255) >= (255 - (val))); diff --git a/wadsrc/static/zscript/maptypes.zs b/wadsrc/static/zscript/maptypes.zs index 969f856a8..efeb26cf4 100644 --- a/wadsrc/static/zscript/maptypes.zs +++ b/wadsrc/static/zscript/maptypes.zs @@ -265,16 +265,14 @@ struct walltype native native readonly int nextwall; native readonly int sector; // Build never had this... native readonly int nextsector; + native readonly TextureID walltexture, overtexture; // Again, panning fields extended for interpolation. native readonly float xpan; native readonly float ypan; native int16 cstat; - - // no access to pics! - //int16 picnum; - //int16 overpicnum; + native int16 lotag; native int16 type; // type is an alias of lotag for Blood. native int16 hitag;