- scriptified Duke's reactor.

This commit is contained in:
Christoph Oelckers 2022-11-30 11:17:41 +01:00
parent f6fe639233
commit f89ccec829
12 changed files with 184 additions and 165 deletions

View file

@ -608,139 +608,6 @@ void detonate(DDukeActor *actor, int explosion)
//
//---------------------------------------------------------------------------
void reactor(DDukeActor* const actor, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BURNT, int REACTORSPARK, int REACTOR2SPARK)
{
auto sectp = actor->sector();
if (actor->temp_data[4] == 1)
{
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
{
if (a2->spr.picnum == SECTOREFFECTOR)
{
if (a2->spr.lotag == 1)
{
a2->spr.lotag = -1;
a2->spr.hitag = -1;
}
}
else if (a2->spr.picnum == REACTOR)
{
a2->spr.picnum = REACTORBURNT;
}
else if (a2->spr.picnum == REACTOR2)
{
a2->spr.picnum = REACTOR2BURNT;
}
else if (a2->spr.picnum == REACTORSPARK || a2->spr.picnum == REACTOR2SPARK)
{
a2->spr.cstat = CSTAT_SPRITE_INVISIBLE;
}
}
return;
}
if (actor->temp_data[1] >= 20)
{
actor->temp_data[4] = 1;
return;
}
double xx;
int p = findplayer(actor, &xx);
actor->temp_data[2]++;
if (actor->temp_data[2] == 4) actor->temp_data[2] = 0;
if (xx < 256)
{
if ((krand() & 255) < 16)
{
if (!S_CheckSoundPlaying(DUKE_LONGTERM_PAIN))
S_PlayActorSound(DUKE_LONGTERM_PAIN, ps[p].GetActor());
S_PlayActorSound(SHORT_CIRCUIT, actor);
ps[p].GetActor()->spr.extra--;
SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0));
}
actor->temp_data[0] += 128;
if (actor->temp_data[3] == 0)
actor->temp_data[3] = 1;
}
else actor->temp_data[3] = 0;
if (actor->temp_data[1])
{
actor->temp_data[1]++;
actor->temp_data[4] = FloatToFixed<8>(actor->spr.pos.Z);
actor->spr.pos.Z = sectp->floorz - zrand(sectp->floorz - sectp->ceilingz);
switch (actor->temp_data[1])
{
case 3:
{
//Turn on all of those flashing sectoreffector.
fi.hitradius(actor, 4096,
gs.impact_damage << 2,
gs.impact_damage << 2,
gs.impact_damage << 2,
gs.impact_damage << 2);
DukeStatIterator it(STAT_STANDABLE);
while (auto a2 = it.Next())
{
if (ismasterswitch(a2))
if (a2->spr.hitag == actor->spr.hitag)
if (a2->spr.yint == 0)
a2->spr.yint = 1;
}
break;
}
case 4:
case 7:
case 10:
case 15:
{
DukeSectIterator it(actor->sector());
while (auto a2 = it.Next())
{
if (a2 != actor)
{
a2->Destroy();
break;
}
}
break;
}
}
for (int x = 0; x < 16; x++)
RANDOMSCRAP(actor);
actor->spr.pos.Z = FixedToFloat<8>(actor->temp_data[4]);
actor->temp_data[4] = 0;
}
else
{
int j = fi.ifhitbyweapon(actor);
if (j >= 0)
{
for (int x = 0; x < 32; x++)
RANDOMSCRAP(actor);
if (actor->spr.extra < 0)
actor->temp_data[1] = 1;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void watersplash2(DDukeActor* actor)
{
auto sectp = actor->sector();

View file

@ -1913,15 +1913,6 @@ void moveactors_d(void)
case HEAVYHBOMB:
heavyhbomb(act);
continue;
case REACTORBURNT:
case REACTOR2BURNT:
continue;
case REACTOR:
case REACTOR2:
reactor(act, REACTOR, REACTOR2, REACTORBURNT, REACTOR2BURNT, REACTORSPARK, REACTOR2SPARK);
continue;
}
if (monsterCheatCheck(act) && badguy(act))

View file

@ -1664,15 +1664,6 @@ void moveactors_r(void)
case DYNAMITE:
heavyhbomb(act);
continue;
case REACTORBURNT:
case REACTOR2BURNT:
continue;
case REACTOR:
case REACTOR2:
reactor(act, REACTOR, REACTOR2, REACTORBURNT, REACTOR2BURNT, REACTORSPARK, REACTOR2SPARK);
continue;
}

View file

@ -544,9 +544,6 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
case WATERSPLASH2:
t->picnum = WATERSPLASH2 + t1;
break;
case REACTOR2:
t->picnum = h->spr.picnum + h->temp_data[2];
break;
case SHELL:
t->picnum = h->spr.picnum + (h->temp_data[0] & 1);
[[fallthrough]];

View file

@ -698,9 +698,6 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
case WATERSPLASH2:
t->picnum = WATERSPLASH2 + t1;
break;
case REACTOR2:
t->picnum = h->spr.picnum + h->temp_data[2];
break;
case SHELL:
t->picnum = h->spr.picnum + (h->temp_data[0] & 1);
[[fallthrough]];

View file

@ -38,7 +38,6 @@ void clearcameras(player_struct* p);
void RANDOMSCRAP(DDukeActor* i);
void detonate(DDukeActor* i, int explosion);
void lotsofstuff(DDukeActor* s, int n, int spawntype);
void reactor(DDukeActor* i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BURNT, int REACTORSPARK, int REACTOR2SPARK);
void watersplash2(DDukeActor* i);
void frameeffect1(DDukeActor* i);
bool money(DDukeActor* i, int BLOODPOOL);

View file

@ -672,9 +672,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
act->spr.scale = DVector2(0.140625, 0.140625);
act->spr.yint = 4;
[[fallthrough]];
case REACTOR2:
case REACTOR:
if (initreactor(actj, act, false)) return act;
break;

View file

@ -685,9 +685,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
act->SetOwner(act);
act->spr.scale = DVector2(0.140625, 0.140625);
act->spr.yint = 4;
[[fallthrough]];
case REACTOR2:
case REACTOR:
if (initreactor(actj, act, false)) return act;
break;

View file

@ -61,6 +61,11 @@ spawnclasses
1641 = DukeFreezeBlast
1636 = DukeSpit
1360 = DukeCoolExplosion1
578 = DukeReactor2
580 = DukeReactor2Spark
1088 = DukeReactor
1092 = DukeReactorSpark
1272 = DukeTrash
634 = DukeBolt1

View file

@ -63,6 +63,10 @@ spawnclasses
1774 = RedneckDynamiteArrow
3390 = RedneckShitBall
3400 = RedneckSawBlade
1107 = DukeReactor2
1109 = DukeReactor2Spark
2239 = DukeReactor
2243 = DukeReactorSpark
285 = RedneckChickenSpawner1
286 = RedneckChickenSpawner2

View file

@ -57,7 +57,6 @@ version "4.10"
#include "zscript/games/duke/actors/soundcontroller.zs"
#include "zscript/games/duke/actors/respawncontroller.zs"
#include "zscript/games/duke/actors/respawnmarker.zs"
#include "zscript/games/duke/actors/bloodsplats.zs"
#include "zscript/games/duke/actors/projectiles.zs"
#include "zscript/games/duke/actors/rat.zs"
@ -82,6 +81,8 @@ version "4.10"
#include "zscript/games/duke/actors/forcesphere.zs"
#include "zscript/games/duke/actors/recon.zs"
#include "zscript/games/duke/actors/ooz.zs"
#include "zscript/games/duke/actors/bloodsplats.zs"
#include "zscript/games/duke/actors/reactor.zs"
#include "zscript/games/duke/actors/genericdestructible.zs"
#include "zscript/games/duke/actors/redneckmisc.zs"

View file

@ -0,0 +1,173 @@
class DukeReactor : DukeActor
{
default
{
spriteset "REACTOR", "REACTORBURNT";
statnum STAT_ZOMBIEACTOR;
shade -17;
pal 0;
}
override void Initialize()
{
self.extra = gs.impact_damage;
self.cstat |= CSTAT_SPRITE_BLOCK_ALL; // Make it hitable
if (ud.multimode < 2 && self.pal != 0)
{
self.scale = (0, 0);
self.ChangeStat(STAT_MISC);
}
}
override void Tick()
{
if (self.spritesetindex == 1) return; // this one's already dead.
let sectp = self.sector;
if (self.temp_data[4] == 1)
{
DukeSectIterator it;
for (let a2 = it.First(self.sector); a2; a2 = it.Next())
{
if (a2.statnum == STAT_EFFECTOR)
{
if (a2.lotag == SE_1_PIVOT)
{
a2.lotag = -1;
a2.hitag = -1;
}
}
else if (a2 is "DukeReactor")
{
a2.SetSpritesetImage(1);
}
else if (a2 is "DukeReactorSpark")
{
a2.cstat = CSTAT_SPRITE_INVISIBLE;
}
}
return;
}
if (self.temp_data[1] >= 20)
{
self.temp_data[4] = 1;
return;
}
double xx;
DukePlayer p;
[p, xx] = self.FindPlayer();
// This was defined for REACTOR2, which doesn't have any animation frames
//self.temp_data[2]++;
//if (self.temp_data[2] == 4) self.temp_data[2] = 0;
//self.SetSpriteSetImage(self.temp_data[2]);
if (xx < 256)
{
if (random(0, 255) < 16)
{
if (!p.actor.CheckSoundPlaying("PLAYER_LONGTERM_PAIN"))
p.actor.PlayActorSound("PLAYER_LONGTERM_PAIN");
self.PlayActorSound("SHORT_CIRCUIT");
p.actor.extra--;
p.pals = Color(32, 32, 0, 0);
}
self.temp_data[0] += 128;
if (self.temp_data[3] == 0)
self.temp_data[3] = 1;
}
else self.temp_data[3] = 0;
if (self.temp_data[1])
{
self.temp_data[1]++;
double zsave = self.pos.Z;
self.pos.Z = sectp.floorz - frandom(0, sectp.floorz - sectp.ceilingz);
switch (self.temp_data[1])
{
case 3:
{
//Turn on all of those flashing sectoreffector.
self.hitradius(4096,
gs.impact_damage << 2,
gs.impact_damage << 2,
gs.impact_damage << 2,
gs.impact_damage << 2);
DukeStatIterator it;
for (let a2 = it.First(STAT_STANDABLE); a2; a2 = it.Next())
{
if (a2 is 'DukeMasterSwitch' && a2.hitag == self.hitag && a2.yint == 0)
a2.yint = 1;
}
break;
}
case 4:
case 7:
case 10:
case 15:
{
DukeSectIterator it;
for (let a2 = it.First(self.sector); a2; a2 = it.Next())
{
if (a2 != self)
{
a2.Destroy();
break;
}
}
break;
}
}
for (int x = 0; x < 16; x++)
self.RANDOMSCRAP();
self.pos.Z = zsave;
self.temp_data[4] = 0;
}
else
{
int j = self.ifhitbyweapon();
if (j >= 0)
{
for (int x = 0; x < 32; x++)
self.RANDOMSCRAP();
if (self.extra < 0)
self.temp_data[1] = 1;
}
}
}
}
class DukeReactor2 : DukeReactor
{
default
{
spriteset "REACTOR2", "REACTOR2BURNT";
}
}
// These are inert and only needed for checking above.
class DukeReactorSpark : DukeActor
{
default
{
pic "REACTORSPARK";
}
}
class DukeReactor2Spark : DukeActor
{
default
{
pic "REACTOR2SPARK";
}
}