- added a few exports and properties for weapon shooting and added missing 'const' annotations for ShootThis overrides.

This commit is contained in:
Christoph Oelckers 2022-12-23 08:55:13 +01:00
parent 17cde1e3ca
commit c73830992f
15 changed files with 66 additions and 14 deletions

View file

@ -73,3 +73,4 @@ xx(gutsoffset)
xx(falladjustz)
xx(aimoffset)
xx(strength)
xx(autoaimangle)

View file

@ -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),

View file

@ -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)

View file

@ -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,

View file

@ -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);

View file

@ -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));
}
//---------------------------------------------------------------------------
//
//

View file

@ -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);

View file

@ -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)

View file

@ -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)

View file

@ -8,6 +8,7 @@ class DukeGreenSlime : DukeActor
+DONTDIVEALIVE;
+FORCESECTORSHADE;
+SHRINKAUTOAIM;
sparkoffset -8;
}
override void Initialize()

View file

@ -46,6 +46,7 @@ class DukeRotateGun : DukeActor
+KILLCOUNT;
+NODAMAGEPUSH;
+NORADIUSPUSH;
sparkoffset -8;
aimoffset 32;
}

View file

@ -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)

View file

@ -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<DukeActor> weapon);
virtual native void Tick();

View file

@ -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)));

View file

@ -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;