- restricted use of gs.firstdebris to the only place where it is really needed.

Also no script export for this, it is only needed for converting CON parameters to propr indices.
This commit is contained in:
Christoph Oelckers 2022-11-15 08:28:05 +01:00
parent d253468b22
commit ad7cf290d2
7 changed files with 20 additions and 9 deletions

View file

@ -1009,7 +1009,7 @@ static void movefireext(DDukeActor* actor)
auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(krandf(-48)), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, actor, STAT_MISC);
if (spawned)
{
if (spawned) spawned->spriteextra = SCRAP3 - gs.firstdebris + krand() & 3;
if (spawned) spawned->spriteextra = Scrap3 + krand() & 3;
spawned->spr.pal = 2;
}
}
@ -2146,7 +2146,7 @@ static void greenslime(DDukeActor *actor)
auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(-8), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, actor, STAT_MISC);
if (spawned)
{
if (spawned) spawned->spriteextra = SCRAP3 - gs.firstdebris + krand() & 3;
if (spawned) spawned->spriteextra = Scrap3 + krand() & 3;
spawned->spr.pal = 6;
}
}
@ -2262,7 +2262,7 @@ static void greenslime(DDukeActor *actor)
auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(-8), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, actor, STAT_MISC);
if (spawned)
{
if (spawned) spawned->spriteextra = SCRAP3 - gs.firstdebris + krand() & 3;
if (spawned) spawned->spriteextra = Scrap3 + krand() & 3;
spawned->spr.pal = 6;
}
}

View file

@ -30,6 +30,18 @@ enum
};
enum EScrap
{
Scrap6 = 0,
Scrap1 = 10,
Scrap2 = 14,
Scrap3 = 18,
Scrap4 = 22,
Scrap5 = 26,
ScrapMax = 30
};
// the available palettes. These are indices into the global table of translations.
enum basepal_t {
BASEPAL = 0,

View file

@ -2154,6 +2154,7 @@ int ParseState::parse(void)
{
insptr++;
int dnum = *insptr - gs.firstdebris;
if (dnum < 0 || dnum >= ScrapMax) break; // this code only works with scrap and nothing else.
insptr++;
int count = *insptr;
bool weap = fi.spawnweapondebris(g_ac->spr.picnum);

View file

@ -1077,7 +1077,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-48), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, targ, STAT_MISC);
if (spawned)
{
if (spawned) spawned->spriteextra = SCRAP3 - gs.firstdebris + krand() & 3;
if (spawned) spawned->spriteextra = Scrap3 + krand() & 3;
spawned->spr.pal = 6;
}
}
@ -1096,7 +1096,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
auto vel = krandf(4) + 4;
auto zvel = -krandf(16) - targ->vel.Z * 0.25;
auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), PClass::FindActor("DukeScrap"), -8, DVector2(0.75, 0.75), a, vel, zvel, targ, STAT_MISC);
if (spawned) spawned->spriteextra = SCRAP1 - gs.firstdebris + krand() & 15;
if (spawned) spawned->spriteextra = Scrap1 + krand() & 15;
}
S_PlayActorSound(GLASS_HEAVYBREAK, targ);
deletesprite(targ);
@ -1126,7 +1126,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
auto zvel = -krandf(2) - 1;
auto spawned = CreateActor(targ->sector(), DVector3(targ->spr.pos.XY(), targ->sector()->floorz - 12 - j * 2), PClass::FindActor("DukeScrap"), -8, DVector2(1, 1), a, vel, zvel, targ, 5);
if (spawned) spawned->spriteextra = SCRAP1 - gs.firstdebris + krand() & 15;
if (spawned) spawned->spriteextra = Scrap1 + krand() & 15;
}
spawn(targ, EXPLOSION2);

View file

@ -2151,7 +2151,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
auto spawned = CreateActor(targ->sector(), DVector3(targ->spr.pos.XY(), targ->sector()->floorz - 12 - j * 2), PClass::FindActor("DukeScrap"), -8, DVector2(1, 1),
a, vel, zvel, targ, 5);
if (spawned) spawned->spriteextra = SCRAP1 - gs.firstdebris + krand() & 15;
if (spawned) spawned->spriteextra = Scrap1 + krand() & 15;
}
spawn(targ, EXPLOSION2);
deletesprite(targ);

View file

@ -631,7 +631,6 @@ DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, freezerhurtowner);
DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, impact_damage);
DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, playerheight);
DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, displayflags);
DEFINE_FIELD_X(DukeGameInfo, DukeGameInfo, firstdebris);
DEFINE_GLOBAL_UNSIZED(gs)

View file

@ -1268,6 +1268,5 @@ struct DukeGameInfo native
readonly native int freezerhurtowner;
readonly native int impact_damage;
readonly native double playerheight;
readonly native int firstdebris;
readonly native int displayflags;
}