- scriptified the force sphere.

Doesn't seem to be used anywhere, though...
This commit is contained in:
Christoph Oelckers 2022-11-28 09:11:18 +01:00
parent bbfb811e1e
commit 7db953e0ea
13 changed files with 154 additions and 197 deletions

View file

@ -681,61 +681,6 @@ void rpgexplode(DDukeActor *actor, int hit, const DVector3 &pos, int EXPLOSION2,
//
//---------------------------------------------------------------------------
void forcesphere(DDukeActor* actor, int forcesphere)
{
auto sectp = actor->sector();
if (actor->spr.yint == 0)
{
actor->spr.yint = 1;
for (DAngle l = DAngle90; l < DAngle270; l += DAngle22_5)
for (DAngle j = nullAngle; j < DAngle360; j += DAngle22_5)
{
auto k = spawn(actor, forcesphere);
if (k)
{
k->spr.cstat = CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_YCENTER;
k->clipdist = 16;
k->spr.Angles.Yaw = j;
k->vel.Z = l.Sin() * 2;
k->vel.X = l.Cos() * 2;
k->SetOwner(actor);
}
}
}
if (actor->temp_data[3] > 0)
{
if (actor->vel.Z < 24)
actor->vel.Z += 0.75;
actor->spr.pos.Z += actor->vel.Z;
if (actor->spr.pos.Z > sectp->floorz)
actor->spr.pos.Z = sectp->floorz;
actor->temp_data[3]--;
if (actor->temp_data[3] == 0)
{
actor->Destroy();
return;
}
else if (actor->temp_data[2] > 10)
{
DukeStatIterator it(STAT_MISC);
while (auto aa = it.Next())
{
if (aa->GetOwner() == actor && aa->spr.picnum == forcesphere)
aa->temp_data[1] = 1 + (krand() & 63);
}
actor->temp_data[3] = 64;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int painsnd, int roamsnd, int shift, int (*getspawn)(DDukeActor* i))
{
auto sectp = actor->sector();
@ -1092,53 +1037,6 @@ void bloodsplats(DDukeActor *actor)
}
}
//---------------------------------------------------------------------------
//
// taken out of moveexplosion
//
//---------------------------------------------------------------------------
void forcesphereexplode(DDukeActor *actor)
{
double size = actor->spr.scale.X;
if (actor->temp_data[1] > 0)
{
actor->temp_data[1]--;
if (actor->temp_data[1] == 0)
{
actor->Destroy();
return;
}
}
auto Owner = actor->GetOwner();
if (!Owner) return;
if (Owner->temp_data[1] == 0)
{
if (actor->temp_data[0] < 64)
{
actor->temp_data[0]++;
size += 0.046875;
}
}
else
if (actor->temp_data[0] > 64)
{
actor->temp_data[0]--;
size -= 0.046875;
}
actor->spr.pos = Owner->spr.pos;;
actor->spr.Angles.Yaw += mapangle(Owner->temp_data[0]);
size = clamp(size, REPEAT_SCALE, 1.);
actor->spr.scale = DVector2(size, size);
actor->spr.shade = int8_t((size * 32) - 48);
for (int j = actor->temp_data[0]; j > 0; j--)
ssp(actor, CLIPMASK0);
}
//---------------------------------------------------------------------------
//
//

View file

@ -2309,9 +2309,6 @@ void moveactors_d(void)
spawn(act, EXPLOSION2);
ssp(act, CLIPMASK0);
break;
case FORCESPHERE:
forcesphere(act, FORCESPHERE);
continue;
case RECON:
recon(act, EXPLOSION2, FIRELASER, RECO_ATTACK, RECO_PAIN, RECO_ROAM, 4, [](DDukeActor* i)->int { return PIGCOP; });
@ -2483,9 +2480,6 @@ void moveexplosions_d(void) // STATNUM 5
}
continue;
case FORCESPHERE:
forcesphereexplode(act);
continue;
case WATERSPLASH2:
watersplash2(act);
continue;

View file

@ -2065,10 +2065,6 @@ void moveactors_r(void)
break;
}
case FORCESPHERE:
forcesphere(act, FORCESPHERE);
continue;
case RECON:
case UFO1_RR:
case UFO2:
@ -2221,11 +2217,6 @@ void moveexplosions_r(void) // STATNUM 5
bloodsplats(act);
continue;
case FORCESPHERE:
forcesphereexplode(act);
continue;
case MUD:
act->temp_data[0]++;

View file

@ -208,21 +208,6 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
case PAPER:
case PAPER + 1:
break;
case FORCESPHERE:
if (t->statnum == STAT_MISC && OwnerAc)
{
auto sqa = ( OwnerAc->spr.pos.XY() - ps[screenpeek].GetActor()->spr.pos.XY()).Angle();
auto sqb = (OwnerAc->spr.pos.XY() - t->pos.XY()).Angle();
if (absangle(sqa, sqb) > DAngle90)
{
double dist1 = (OwnerAc->spr.pos.XY() - t->pos.XY()).LengthSquared();
double dist2 = (OwnerAc->spr.pos.XY() - ps[screenpeek].GetActor()->spr.pos.XY()).LengthSquared();
if (dist1 < dist2)
t->scale = DVector2(0, 0);
}
}
continue;
case BURNING:
case BURNING2:
if (OwnerAc && OwnerAc->spr.statnum == STAT_PLAYER)

View file

@ -193,21 +193,6 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi
break;
case POWDERKEG:
continue;
case FORCESPHERE:
if (t->statnum == STAT_MISC && OwnerAc)
{
auto sqa = (OwnerAc->spr.pos.XY() - ps[screenpeek].GetActor()->spr.pos.XY()).Angle();
auto sqb = (OwnerAc->spr.pos.XY() - t->pos.XY()).Angle();
if (absangle(sqa, sqb) > DAngle90)
{
double dist1 = (OwnerAc->spr.pos.XY() - t->pos.XY()).LengthSquared();
double dist2 = (OwnerAc->spr.pos.XY() - ps[screenpeek].GetActor()->spr.pos.XY()).LengthSquared();
if (dist1 < dist2)
t->scale = DVector2(0, 0);
}
}
continue;
case BURNING:
if (OwnerAc && OwnerAc->spr.statnum == STAT_PLAYER)
{

View file

@ -1189,17 +1189,6 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
lotsofglass(targ, nullptr, 10);
break;
case FORCESPHERE:
targ->spr.scale.X = (0);
if (targ->GetOwner())
{
targ->GetOwner()->temp_data[0] = 32;
targ->GetOwner()->temp_data[1] = !targ->GetOwner()->temp_data[1];
targ->GetOwner()->temp_data[2] ++;
}
spawn(targ, EXPLOSION2);
break;
case BROKEHYDROPLANT:
if (targ->spr.cstat & CSTAT_SPRITE_BLOCK)
{

View file

@ -1564,19 +1564,6 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
lotsofglass(targ, nullptr, 10);
targ->Destroy();
break;
case FORCESPHERE:
{
targ->spr.scale.X = (0);
auto Owner = targ->GetOwner();
if (Owner)
{
Owner->temp_data[0] = 32;
Owner->temp_data[1] = !Owner->temp_data[1];
Owner->temp_data[2] ++;
}
spawn(targ, EXPLOSION2);
break;
}
case TOILET:
targ->spr.picnum = TOILETBROKE;
if(krand() & 1) targ->spr.cstat |= CSTAT_SPRITE_XFLIP;

View file

@ -210,19 +210,6 @@ DDukeActor* spawninit_d(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
break;
case FORCESPHERE:
if (!actj)
{
act->spr.cstat = CSTAT_SPRITE_INVISIBLE;
ChangeActorStat(act, STAT_ZOMBIEACTOR);
}
else
{
act->spr.scale = DVector2(REPEAT_SCALE, REPEAT_SCALE);
ChangeActorStat(act, STAT_MISC);
}
break;
case BLOOD:
act->spr.scale = DVector2(0.25, 0.25);
act->spr.pos.Z -= 26;

View file

@ -178,19 +178,6 @@ DDukeActor* spawninit_r(DDukeActor* actj, DDukeActor* act, TArray<DDukeActor*>*
ChangeActorStat(act, STAT_MISC);
break;
case FORCESPHERE:
if (!actj)
{
act->spr.cstat = CSTAT_SPRITE_INVISIBLE;
ChangeActorStat(act, STAT_ZOMBIEACTOR);
}
else
{
act->spr.scale = DVector2(REPEAT_SCALE, REPEAT_SCALE);
ChangeActorStat(act, STAT_MISC);
}
break;
case BLOOD:
act->spr.scale = DVector2(0.0625, 0.0625);
act->spr.pos.Z -= 26;

View file

@ -47,6 +47,7 @@ spawnclasses
902 = DukeQueball
901 = DukeStripeBall
903 = DukePoolPocket
2590 = DukeForceSphere
1272 = DukeTrash

View file

@ -50,6 +50,7 @@ spawnclasses
1440 = DukeInnerJaw1
866 = RedneckRespawnMarker
1344 = DukeRat
1759 = DukeForceSphere
285 = RedneckChickenSpawner1
286 = RedneckChickenSpawner2

View file

@ -77,6 +77,7 @@ version "4.10"
#include "zscript/games/duke/actors/canwithsomething.zs"
#include "zscript/games/duke/actors/tongue.zs"
#include "zscript/games/duke/actors/queball.zs"
#include "zscript/games/duke/actors/forcesphere.zs"
#include "zscript/games/duke/actors/genericdestructible.zs"
#include "zscript/games/duke/actors/redneckmisc.zs"

View file

@ -0,0 +1,151 @@
class DukeForceSphere : DukeActor
{
default
{
pic "FORCESPHERE";
}
override void Initialize()
{
if (ownerActor == self)
{
self.cstat = CSTAT_SPRITE_INVISIBLE;
self.ChangeStat(STAT_ZOMBIEACTOR);
}
else
{
self.scale = (1 / 64., 1 / 64.);
self.ChangeStat(STAT_MISC);
}
}
void TickParent()
{
let sectp = self.sector;
if (self.yint == 0)
{
self.yint = 1;
for (double l = 90; l < 270; l += 22.5)
for (double j = 0; j < 360; j += 22.5)
{
let k = self.spawn("DukeForceSphere");
if (k)
{
k.cstat = CSTAT_SPRITE_BLOCK_ALL | CSTAT_SPRITE_YCENTER;
k.clipdist = 16;
k.angle = j;
k.vel.Z = sin(l) * 2;
k.vel.X = cos(l) * 2;
k.ownerActor = self;
}
}
}
if (self.temp_data[3] > 0)
{
if (self.vel.Z < 24)
self.vel.Z += 0.75;
self.pos.Z += self.vel.Z;
if (self.pos.Z > sectp.floorz)
self.pos.Z = sectp.floorz;
self.temp_data[3]--;
if (self.temp_data[3] == 0)
{
self.Destroy();
return;
}
else if (self.temp_data[2] > 10)
{
DukeStatIterator it;
for (let aa = it.First(STAT_MISC); aa; aa = it.Next())
{
if (aa.ownerActor == self && aa is 'DukeForceSphere')
aa.temp_data[1] = random(1, 64);
}
self.temp_data[3] = 64;
}
}
}
void TickChild()
{
double size = self.scale.X;
if (self.temp_data[1] > 0)
{
self.temp_data[1]--;
if (self.temp_data[1] == 0)
{
self.Destroy();
return;
}
}
let Owner = self.ownerActor;
if (!Owner) return;
if (Owner.temp_data[1] == 0)
{
if (self.temp_data[0] < 64)
{
self.temp_data[0]++;
size += 0.046875;
}
}
else
if (self.temp_data[0] > 64)
{
self.temp_data[0]--;
size -= 0.046875;
}
self.pos = Owner.pos;;
self.angle += Raze.BAngToDegree * Owner.temp_data[0];
size = clamp(size, 1 / 64., 1.);
self.scale = (size, size);
self.shade = ((size * 32) - 48);
for (int j = self.temp_data[0]; j > 0; j--)
self.DoMove(CLIPMASK0);
}
override void Tick()
{
if (self.statnum == STAT_MISC) TickChild();
else TickParent();
}
override bool Animate(tspritetype t)
{
let OwnerAc = self.ownerActor;
if (self.statnum == STAT_MISC && OwnerAc)
{
let plr = Duke.GetViewPlayer().actor;
let sqa = (OwnerAc.pos.XY - plr.pos.XY).Angle();
let sqb = (OwnerAc.pos.XY - t.pos.XY).Angle();
if (absangle(sqa, sqb) > 90)
{
double dist1 = (OwnerAc.pos.XY - t.pos.XY).LengthSquared();
double dist2 = (OwnerAc.pos.XY - plr.pos.XY).LengthSquared();
if (dist1 < dist2)
t.scale = (0, 0);
}
}
return true;
}
override void onHit(DukeActor hitter)
{
self.scale.X = (0);
let Owner = self.ownerActor;
if (Owner)
{
Owner.temp_data[0] = 32;
Owner.temp_data[1] = !Owner.temp_data[1];
Owner.temp_data[2] ++;
}
self.spawn("DukeExplosion2");
}
}