- scriptified the guts spawning function.

This commit is contained in:
Christoph Oelckers 2022-11-22 23:21:45 +01:00
parent f39eaba109
commit 93ef4b34d7
19 changed files with 123 additions and 166 deletions

View file

@ -4179,12 +4179,12 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO
goto SKIPJIBS;
if (sphit)
{
fi.guts(actor, JIBS6, 5, playernum);
spawnguts(actor, PClass::FindActor("DukeJibs6"), 5);
S_PlayActorSound(squished, actor);
}
else
{
fi.guts(actor, JIBS6, 15, playernum);
spawnguts(actor, PClass::FindActor("DukeJibs6"), 15);
S_PlayActorSound(squished, actor);
spawn(actor, BLOODPOOL);
}

View file

@ -494,60 +494,6 @@ void lotsofpaper_d(DDukeActor *actor, int n)
//
//---------------------------------------------------------------------------
void guts_d(DDukeActor* actor, int gtype, int n, int p)
{
double scale;
uint8_t pal;
if (badguy(actor) && actor->spr.scale.X < 0.25)
scale = 0.125;
else scale = 0.5;
double gutz = actor->spr.pos.Z - 8;
double floorz = getflorzofslopeptr(actor->sector(), actor->spr.pos);
if (gutz > floorz - 8)
gutz = floorz - 8;
gutz += gs.actorinfo[actor->spr.picnum].gutsoffset;
if (badguy(actor) && actor->spr.pal == 6)
pal = 6;
else if (actor->spr.picnum != LIZTROOP) // EDuke32 transfers the palette unconditionally, I'm not sure that's such a good idea.
pal = 0;
else
pal = actor->spr.pal;
for (int j = 0; j < n; j++)
{
// RANDCORRECT version from RR.
DAngle a = randomAngle();
double zvel = -2 -krandf(8);
double vel = 3 + krandf(2);
DVector3 offs;
offs.Z = gutz - krandf(16);
offs.Y = krandf(16) - 8;
offs.X = krandf(16) - 8;
// TRANSITIONAL: owned by a player???
auto spawned = CreateActor(actor->sector(), offs + actor->spr.pos.XY(), gtype, -32, DVector2(scale, scale), a, vel, zvel, ps[p].GetActor(), 5);
if (spawned)
{
if (spawned->spr.picnum == JIBS2)
{
spawned->spr.scale *= 0.25;
}
if (pal != 0)
spawned->spr.pal = pal;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int ifhitbyweapon_d(DDukeActor *actor)
{
int p;

View file

@ -393,58 +393,6 @@ void lotsoffeathers_r(DDukeActor *actor, int n)
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void guts_r(DDukeActor* actor, int gtype, int n, int p)
{
int j;
double scale;
uint8_t pal;
if (badguy(actor) && actor->spr.scale.X < 0.25)
scale = 0.0625;
else scale = 0.25;
double gutz = actor->spr.pos.Z - 8;
double floorz = getflorzofslopeptr(actor->sector(), actor->spr.pos);
if (gutz > floorz - 8)
gutz = floorz - 8;
gutz += gs.actorinfo[actor->spr.picnum].gutsoffset;
if (badguy(actor) && actor->spr.pal == 6)
pal = 6;
else
{
pal = 0;
if (isRRRA())
{
if (actor->spr.picnum == MINION && (actor->spr.pal == 8 || actor->spr.pal == 19)) pal = actor->spr.pal;
}
}
for (j = 0; j < n; j++)
{
// RANDCORRECT version from RR.
DAngle a = randomAngle();
double zvel = -2 - krandf(8);
double vel = 3 + krandf(2);
DVector3 offs;
offs.Z = gutz - krandf(16);
offs.Y = krandf(16) - 8;
offs.X = krandf(16) - 8;
// TRANSITIONAL: owned by a player???
auto spawned = CreateActor(actor->sector(), offs + actor->spr.pos.XY(), gtype, -32, DVector2(scale, scale), a, vel, zvel, ps[p].GetActor(), 5);
if (spawned && pal != 0)
spawned->spr.pal = pal;
}
}
//---------------------------------------------------------------------------
//
//
@ -704,6 +652,13 @@ static void chickenarrow(DDukeActor* actor)
}
}
static void rabbitguts(DDukeActor* proj)
{
spawnguts(proj, PClass::FindActor("RedneckRabbitGibA"), 2);
spawnguts(proj, PClass::FindActor("RedneckRabbitGibB"), 2);
spawnguts(proj, PClass::FindActor("RedneckRabbitGibC"), 2);
}
//---------------------------------------------------------------------------
//
//
@ -750,9 +705,7 @@ static bool weaponhitsprite(DDukeActor *proj, DDukeActor *targ, const DVector3 &
{
if (isRRRA() && proj->GetOwner() && proj->GetOwner()->spr.picnum == MAMA)
{
guts_r(proj, RABBITJIBA, 2, myconnectindex);
guts_r(proj, RABBITJIBB, 2, myconnectindex);
guts_r(proj, RABBITJIBC, 2, myconnectindex);
rabbitguts(proj);
}
ps[p].Angles.addPitch(DAngle::fromDeg(-14.04));
@ -787,9 +740,7 @@ static bool weaponhitwall(DDukeActor *proj, walltype* wal, const DVector3& oldpo
{
if (isRRRA() && proj->GetOwner() && proj->GetOwner()->spr.picnum == MAMA)
{
guts_r(proj, RABBITJIBA, 2, myconnectindex);
guts_r(proj, RABBITJIBB, 2, myconnectindex);
guts_r(proj, RABBITJIBC, 2, myconnectindex);
rabbitguts(proj);
}
if (proj->spr.picnum != RPG && (!isRRRA() || proj->spr.picnum != RPG2) && proj->spr.picnum != FREEZEBLAST && proj->spr.picnum != SPIT && proj->spr.picnum != SHRINKSPARK && (wal->overpicnum == MIRROR || wal->picnum == MIRROR))
@ -872,9 +823,7 @@ bool weaponhitsector(DDukeActor *proj, const DVector3& oldpos)
if (isRRRA() && proj->GetOwner() && proj->GetOwner()->spr.picnum == MAMA)
{
guts_r(proj, RABBITJIBA, 2, myconnectindex);
guts_r(proj, RABBITJIBB, 2, myconnectindex);
guts_r(proj, RABBITJIBC, 2, myconnectindex);
rabbitguts(proj);
}
if (proj->vel.Z < 0)
@ -3235,7 +3184,7 @@ static int fallspecial(DDukeActor *actor, int playernum)
{
if (actor->spr.picnum != APLAYER && badguy(actor) && actor->spr.pos.Z == actor->floorz - FOURSLEIGHT_F)
{
fi.guts(actor, JIBS6, 5, playernum);
spawnguts(actor, PClass::FindActor("DukeJibs6"), 5);
S_PlayActorSound(SQUISHED, actor);
addspritetodelete();
}

View file

@ -365,6 +365,7 @@ enum sflags2_t
SFLAG2_GREENBLOOD = 0x00000800,
SFLAG2_ALWAYSROTATE1 = 0x00001000,
SFLAG2_DIENOW = 0x00002000,
SFLAG2_TRANFERPALTOJIBS = 0x00004000,
};
using EDukeFlags2 = TFlags<sflags2_t, uint32_t>;

View file

@ -62,8 +62,6 @@ void lotsofmoney_d(DDukeActor* s, int n);
void lotsofmail_d(DDukeActor* s, int n);
void lotsofpaper_d(DDukeActor* s, int n);
void lotsoffeathers_r(DDukeActor* s, int n);
void guts_d(DDukeActor* s, int gtype, int n, int p);
void guts_r(DDukeActor* s, int gtype, int n, int p);
int ifhitbyweapon_r(DDukeActor* sn);
int ifhitbyweapon_d(DDukeActor* sn);
void fall_d(DDukeActor* i, int g_p);
@ -123,7 +121,6 @@ void SetDispatcher()
lotsofmoney_d,
lotsofmail_d,
lotsofpaper_d,
guts_d,
ifhitbyweapon_d,
fall_d,
spawnweapondebris_d,
@ -163,7 +160,6 @@ void SetDispatcher()
lotsoffeathers_r,
lotsoffeathers_r,
lotsoffeathers_r,
guts_r,
ifhitbyweapon_r,
fall_r,
spawnweapondebris_r,

View file

@ -91,7 +91,6 @@ struct Dispatcher
void (*lotsofmoney)(DDukeActor *s, int n);
void (*lotsofmail)(DDukeActor *s, int n);
void (*lotsofpaper)(DDukeActor *s, int n);
void (*guts)(DDukeActor* s, int gtype, int n, int p);
int (*ifhitbyweapon)(DDukeActor* sectnum);
void (*fall)(DDukeActor* actor, int g_p);
bool (*spawnweapondebris)(int picnum);

View file

@ -120,6 +120,7 @@ void initactorflags_d()
setflag(SFLAG2_GREENBLOOD, { OOZFILTER, NEWBEAST });
setflag(SFLAG2_ALWAYSROTATE1, { RAT, CAMERA1 });
setflag(SFLAG2_DIENOW, { RADIUSEXPLOSION, KNEE });
setflag(SFLAG2_TRANFERPALTOJIBS, { LIZTROOP });
if (isWorldTour())
{

View file

@ -189,6 +189,7 @@ void initactorflags_r()
if (isRRRA())
{
setflag(SFLAG_MOVEFTA_CHECKSEEWITHPAL8, { MINION });
setflag(SFLAG2_TRANFERPALTOJIBS, { MINION });
}
gs.actorinfo[RPG2].flags |= SFLAG_FORCEAUTOAIM;
@ -246,6 +247,7 @@ void initactorflags_r()
TILE_EGG = EGG;
gs.firstdebris = SCRAP6;
gs.gutsscale = 0.25;
}
END_DUKE_NS

View file

@ -55,6 +55,7 @@ bool money(DDukeActor* i, int BLOODPOOL);
bool bloodpool(DDukeActor* i, bool puke);
void shell(DDukeActor* i, bool morecheck);
void glasspieces(DDukeActor* i);
void spawnguts(DDukeActor* origin, PClass* type, int count);
void handle_se00(DDukeActor* i);
void handle_se01(DDukeActor* i);

View file

@ -3187,6 +3187,7 @@ void loadcons()
gs.shrinkerblastradius = 650;
gs.gravity = 0.6875;
gs.tripbombblastradius = 3880;
gs.gutsscale = 0.125;
gs.playerheight = 40;
gs.displayflags = DUKE3D_NO_WIDESCREEN_PINNING;

View file

@ -2447,10 +2447,17 @@ int ParseState::parse(void)
parseifelse(g_ac->spr.extra <= *insptr);
break;
case concmd_guts:
{
insptr += 2;
fi.guts(g_ac,*(insptr-1),*insptr,g_p);
auto info = spawnMap.CheckKey(*(insptr - 1));
if (info)
{
auto clstype = static_cast<PClassActor*>(info->Class(*(insptr - 1)));
if (clstype) spawnguts(g_ac, clstype, *insptr);
}
insptr++;
break;
}
case concmd_slapplayer:
insptr++;
forceplayerangle(g_p);

View file

@ -18,6 +18,8 @@ struct DukeGameInfo
// Static constant global state
double playerfriction;
double gravity;
double playerheight;
double gutsscale;
int respawnactortime;
int bouncemineblastradius;
@ -41,7 +43,6 @@ struct DukeGameInfo
ActorInfo actorinfo[MAXTILES];
int16_t max_ammo_amount[MAX_WEAPONS];
int16_t weaponsandammosprites[15];
double playerheight;
int displayflags;
};

View file

@ -103,7 +103,7 @@ void quickkill(player_struct* p)
auto pa = p->GetActor();
pa->spr.extra = 0;
pa->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
if (ud.god == 0) fi.guts(pa, TILE_JIBS6, 8, myconnectindex);
if (ud.god == 0) spawnguts(pa, PClass::FindActor("DukeJibs6"), 8);
return;
}
@ -390,7 +390,7 @@ void dokneeattack(int snum, const std::initializer_list<int> & respawnlist)
p->weapon_pos = -p->weapon_pos;
if (p->actorsqu != nullptr && (p->GetActor()->spr.pos - p->actorsqu->spr.pos).Length() < 1400/16.)
{
fi.guts(p->actorsqu, TILE_JIBS6, 7, myconnectindex);
spawnguts(p->actorsqu, PClass::FindActor("DukeJibs6"), 7);
spawn(p->actorsqu, TILE_BLOODPOOL);
S_PlayActorSound(SQUISHED, p->actorsqu);
if (isIn(p->actorsqu->spr.picnum, respawnlist))

View file

@ -1326,12 +1326,12 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
fi.shoot(targ, BLOODSPLAT3);
targ->spr.Angles.Yaw = randomAngle();
fi.shoot(targ, BLOODSPLAT4);
fi.guts(targ, JIBS1, 1, myconnectindex);
fi.guts(targ, JIBS2, 2, myconnectindex);
fi.guts(targ, JIBS3, 3, myconnectindex);
fi.guts(targ, JIBS4, 4, myconnectindex);
fi.guts(targ, JIBS5, 1, myconnectindex);
fi.guts(targ, JIBS3, 6, myconnectindex);
spawnguts(targ, PClass::FindActor("DukeJibs1"), 1);
spawnguts(targ, PClass::FindActor("DukeJibs2"), 2);
spawnguts(targ, PClass::FindActor("DukeJibs3"), 3);
spawnguts(targ, PClass::FindActor("DukeJibs4"), 4);
spawnguts(targ, PClass::FindActor("DukeJibs5"), 1);
spawnguts(targ, PClass::FindActor("DukeJibs3"), 6);
S_PlaySound(SQUISHED);
targ->Destroy();
break;

View file

@ -1,3 +1,8 @@
#include "vm.h"
#include "ns.h"
#include "buildtiles.h"
#include "global.h"
#include "funct.h"
BEGIN_DUKE_NS
void resetswitch(int tag);
@ -31,34 +36,10 @@ int PicForName(int intname)
{
picnum = TileFiles.tileForName("RABBIT");
}
else if (FName(ENamedName(intname)) == FName("DukeJibs1"))
{
picnum = TileFiles.tileForName("JIBS1");
}
else if (FName(ENamedName(intname)) == FName("DukeJibs2"))
{
picnum = TileFiles.tileForName("JIBS2");
}
else if (FName(ENamedName(intname)) == FName("DukeJibs3"))
{
picnum = TileFiles.tileForName("JIBS3");
}
else if (FName(ENamedName(intname)) == FName("DukeJibs4"))
{
picnum = TileFiles.tileForName("JIBS4");
}
else if (FName(ENamedName(intname)) == FName("RedneckFeather"))
{
picnum = TileFiles.tileForName("FEATHER");
}
else if (FName(ENamedName(intname)) == FName("RedneckCactusDebris1"))
{
picnum = TileFiles.tileForName("CACTUSDEBRIS1");
}
else if (FName(ENamedName(intname)) == FName("RedneckCactusDebris2"))
{
picnum = TileFiles.tileForName("CACTUSDEBRIS2");
}
return picnum;
}
@ -364,18 +345,15 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, lotsofstuff, DukeActor_Lotsofstuff)
return 0;
}
void DukeActor_spawnguts(DDukeActor* actor, int intname, int count)
double DukeActor_gutsoffset(DDukeActor* self)
{
int picnum = PicForName(intname);
fi.guts(actor, picnum, count, myconnectindex);
return gs.actorinfo[self->spr.picnum].gutsoffset;
}
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spawnguts, DukeActor_spawnguts)
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, gutsoffset, DukeActor_gutsoffset)
{
PARAM_SELF_PROLOGUE(DDukeActor);
PARAM_INT(type);
PARAM_INT(count);
DukeActor_spawnguts(self, type, count);
ACTION_RETURN_FLOAT(DukeActor_gutsoffset(self));
return 0;
}
@ -1068,6 +1046,7 @@ DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, lasermode);
DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, freezerhurtowner);
DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, impact_damage);
DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, playerheight);
DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, gutsscale);
DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, displayflags);
DEFINE_GLOBAL_UNSIZED(gs)
@ -1115,4 +1094,14 @@ DEFINE_ACTION_FUNCTION_NATIVE(_tspritetype, setWeaponOrAmmoSprite, tspritetype_s
}
void spawnguts(DDukeActor* origin, PClass* type, int count)
{
IFVM(DukeActor, spawnguts)
{
VMValue params[] = { (DObject*)origin, type, count };
VMCall(func, params, 3, nullptr, 0);
}
}
END_DUKE_NS

View file

@ -70,7 +70,7 @@ spawnclasses
3410 = RedneckLumberBlade
295 = RedneckKegHolder
1463 = DukeJibs1
1468 = DukeJibs2
1468 = RedneckJibs2
1473 = DukeJibs3
1478 = DukeJibs4
1483 = DukeJibs5

View file

@ -1,3 +1,49 @@
extend class DukeActor
{
void spawnguts(class<DukeJibs1> gtype, int n)
{
double scale = gs.gutsscale;
int pal;
if (self.badguy() && self.scale.X < 0.25)
scale *= 0.25;
double gutz = self.pos.Z - 8;
double c;
double floorz;
[c, floorz] = self.sector.getslopes(self.pos.XY);
if (gutz > floorz - 8)
gutz = floorz - 8;
gutz += self.gutsoffset();
if (self.badguy() && self.pal == 6)
pal = 6;
else if (!self.actorflag2(SFLAG2_TRANFERPALTOJIBS))
pal = 0;
else
pal = self.pal;
for (int j = 0; j < n; j++)
{
// RANDCORRECT version from RR.
double a = frandom(0, 360);
double zvel = -2 - frandom(0, 8);
double vel = frandom(3, 5);
Vector3 offs;
offs.Z = gutz - frandom(0, 16);
offs.Y = frandom(0, 16) - 8;
offs.X = frandom(0, 16) - 8;
let spawned = dlevel.SpawnActor(self.sector, offs + self.pos.XY, gtype, -32, (scale, scale), a, vel, zvel, self, STAT_MISC);
if (spawned && pal != 0)
spawned.pal = pal;
}
}
}
class DukeJibs1 : DukeActor
{
@ -156,6 +202,19 @@ class DukeJibs1 : DukeActor
//---------------------------------------------------------------------------
class DukeJibs2 : DukeJibs1
{
default
{
pic "JIBS2";
}
override void Initialize()
{
self.scale *= 0.25; // only Duke needs this.
}
}
class RedneckJibs2 : DukeJibs1
{
default
{

View file

@ -191,7 +191,7 @@ class DukeActor : CoreActor native
native int badguy();
native int isplayer();
native void lotsofstuff(Name type, int count);
native void spawnguts(Name type, int count);
native double gutsoffset();
native int movesprite(Vector3 move, int clipmask);
@ -301,4 +301,8 @@ enum sflags2_t
SFLAG2_CAMERA = 0x00000100,
SFLAG2_DONTANIMATE = 0x00000200,
SFLAG2_INTERPOLATEANGLE = 0x00000400,
SFLAG2_GREENBLOOD = 0x00000800,
SFLAG2_ALWAYSROTATE1 = 0x00001000,
SFLAG2_DIENOW = 0x00002000,
SFLAG2_TRANFERPALTOJIBS = 0x00004000,
};

View file

@ -373,6 +373,7 @@ struct DukeGameInfo native
readonly native int freezerhurtowner;
readonly native int impact_damage;
readonly native double playerheight;
readonly native double gutsscale;
readonly native int displayflags;
}