- SE 0 and 1 handlers.

This commit is contained in:
Christoph Oelckers 2020-10-21 23:39:12 +02:00
parent a37cfe2913
commit 1ce2600a43
5 changed files with 47 additions and 53 deletions

View file

@ -1825,7 +1825,7 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p
else s->z -= 1024; else s->z -= 1024;
} }
if (roamsnd >= 0 && S_CheckSoundPlaying(actor->GetIndex(), roamsnd) < 1) if (roamsnd >= 0 && S_CheckActorSoundPlaying(actor, roamsnd) < 1)
S_PlayActorSound(roamsnd, actor); S_PlayActorSound(roamsnd, actor);
ssp(actor, CLIPMASK0); ssp(actor, CLIPMASK0);
@ -2602,24 +2602,21 @@ void scrap(DDukeActor* actor, int SCRAP1, int SCRAP6)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se00(int i, int LASERLINE) void handle_se00(DDukeActor* actor, int LASERLINE)
{ {
auto s = &sprite[i]; auto s = &actor->s;
auto actor = &hittype[i]; int* t = &actor->temp_data[0];
int sectno = s->sectnum;
auto t = &actor->temp_data[0];
sectortype *sect = &sector[s->sectnum]; sectortype *sect = &sector[s->sectnum];
int st = s->lotag; int st = s->lotag;
int sh = s->hitag; int sh = s->hitag;
int zchange = 0; int zchange = 0;
int j = s->owner; auto Owner = actor->GetOwner();
auto sprowner = &sprite[j];
if (sprowner->lotag == (short)65535) if (!Owner || Owner->s.lotag == (short)65535)
{ {
deletesprite(i); deletesprite(actor);
return; return;
} }
@ -2630,13 +2627,13 @@ void handle_se00(int i, int LASERLINE)
{ {
q >>= 2; q >>= 2;
if (sprite[i].extra == 1) if (s->extra == 1)
{ {
if (actor->tempang < 256) if (actor->tempang < 256)
{ {
actor->tempang += 4; actor->tempang += 4;
if (actor->tempang >= 256) if (actor->tempang >= 256)
callsound(s->sectnum, i); callsound(s->sectnum, actor);
if (s->clipdist) l = 1; if (s->clipdist) l = 1;
else l = -1; else l = -1;
} }
@ -2658,13 +2655,13 @@ void handle_se00(int i, int LASERLINE)
sect->floorz = s->z; sect->floorz = s->z;
} }
} }
else if (sprite[i].extra == 3) else if (s->extra == 3)
{ {
if (actor->tempang > 0) if (actor->tempang > 0)
{ {
actor->tempang -= 4; actor->tempang -= 4;
if (actor->tempang <= 0) if (actor->tempang <= 0)
callsound(s->sectnum, i); callsound(s->sectnum, actor);
if (s->clipdist) l = -1; if (s->clipdist) l = -1;
else l = 1; else l = 1;
} }
@ -2692,21 +2689,21 @@ void handle_se00(int i, int LASERLINE)
} }
else else
{ {
if (hittype[j].temp_data[0] == 0) return; if (Owner->temp_data[0] == 0) return;
if (hittype[j].temp_data[0] == 2) if (Owner->temp_data[0] == 2)
{ {
deletesprite(i); deletesprite(actor);
return; return;
} }
if (sprowner->ang > 1024) if (Owner->s.ang > 1024)
l = -1; l = -1;
else l = 1; else l = 1;
if (t[3] == 0) if (t[3] == 0)
t[3] = ldist(s, &sprite[j]); t[3] = ldist(actor, Owner);
s->xvel = t[3]; s->xvel = t[3];
s->x = sprowner->x; s->x = Owner->s.x;
s->y = sprowner->y; s->y = Owner->s.y;
s->ang += (l * q); s->ang += (l * q);
t[2] += (l * q); t[2] += (l * q);
} }
@ -2723,9 +2720,7 @@ void handle_se00(int i, int LASERLINE)
ps[p].posz += zchange; ps[p].posz += zchange;
int m, x; int m, x;
rotatepoint(sprowner->x, sprowner->y, rotatepoint(Owner->s.x, Owner->s.y, ps[p].posx, ps[p].posy, (q * l), &m, &x);
ps[p].posx, ps[p].posy, (q * l),
&m, &x);
ps[p].bobposx += m - ps[p].posx; ps[p].bobposx += m - ps[p].posx;
ps[p].bobposy += x - ps[p].posy; ps[p].bobposy += x - ps[p].posy;
@ -2733,21 +2728,22 @@ void handle_se00(int i, int LASERLINE)
ps[p].posx = m; ps[p].posx = m;
ps[p].posy = x; ps[p].posy = x;
if (sprite[ps[p].i].extra <= 0) auto psp = ps[p].GetActor();
if (psp->s.extra <= 0)
{ {
sprite[ps[p].i].x = m; psp->s.x = m;
sprite[ps[p].i].y = x; psp->s.y = x;
} }
} }
} }
SectIterator itp(s->sectnum); DukeSectIterator itp(s->sectnum);
while ((p = itp.NextIndex()) >= 0) while (auto ap = itp.Next())
{ {
auto sprp = &sprite[p]; auto sprp = &sprite[p];
if (sprp->statnum != 3 && sprp->statnum != 4) if (sprp->statnum != 3 && sprp->statnum != 4)
if (LASERLINE < 0 || sprp->picnum != LASERLINE) if (LASERLINE < 0 || sprp->picnum != LASERLINE)
{ {
if (sprp->picnum == TILE_APLAYER && sprp->owner >= 0) if (sprp->picnum == TILE_APLAYER && ap->GetOwner())
{ {
continue; continue;
} }
@ -2756,16 +2752,12 @@ void handle_se00(int i, int LASERLINE)
sprp->ang &= 2047; sprp->ang &= 2047;
sprp->z += zchange; sprp->z += zchange;
rotatepoint(Owner->s.x, Owner->s.y, ap->s.x, ap->s.y, (q* l), &ap->s.x, &ap->s.y);
rotatepoint(sprowner->x, sprowner->y,
sprp->x, sprp->y, (q * l),
&sprp->x, &sprp->y);
} }
} }
} }
ms(i); ms(actor);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -2774,21 +2766,18 @@ void handle_se00(int i, int LASERLINE)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se01(int i) void handle_se01(DDukeActor *actor)
{ {
spritetype* s = &sprite[i]; int* t = &actor->temp_data[0];
auto t = &hittype[i].temp_data[0]; int sh = actor->s.hitag;
int sh = s->hitag; if (actor->GetOwner() == nullptr) //Init
if (s->owner == -1) //Init
{ {
s->owner = i; actor->SetOwner(actor);
StatIterator it(STAT_EFFECTOR); DukeStatIterator it(STAT_EFFECTOR);
int j; while (auto ac = it.Next())
while ((j = it.NextIndex()) >= 0)
{ {
auto ss = &sprite[j]; if (ac->s.lotag == 19 && ac->s.hitag == sh)
if (ss->lotag == 19 && ss->hitag == sh)
{ {
t[0] = 0; t[0] = 0;
break; break;

View file

@ -3573,11 +3573,11 @@ void moveeffectors_d(void) //STATNUM 3
switch (st) switch (st)
{ {
case SE_0_ROTATING_SECTOR: case SE_0_ROTATING_SECTOR:
handle_se00(i, LASERLINE); handle_se00(&hittype[i], LASERLINE);
break; break;
case SE_1_PIVOT: //Nothing for now used as the pivot case SE_1_PIVOT: //Nothing for now used as the pivot
handle_se01(i); handle_se01(&hittype[i]);
break; break;
case SE_6_SUBWAY: case SE_6_SUBWAY:

View file

@ -3476,11 +3476,11 @@ void moveeffectors_r(void) //STATNUM 3
switch (st) switch (st)
{ {
case SE_0_ROTATING_SECTOR: case SE_0_ROTATING_SECTOR:
handle_se00(i, -1); handle_se00(&hittype[i], -1);
break; break;
case SE_1_PIVOT: //Nothing for now used as the pivot case SE_1_PIVOT: //Nothing for now used as the pivot
handle_se01(i); handle_se01(&hittype[i]);
break; break;
case SE_6_SUBWAY: case SE_6_SUBWAY:

View file

@ -276,4 +276,9 @@ inline void detonate(int i, int explosion)
detonate(&hittype[i], explosion); detonate(&hittype[i], explosion);
} }
inline void callsound(int sect, DDukeActor* a)
{
callsound(sect, a->GetIndex());
}
END_DUKE_NS END_DUKE_NS

View file

@ -63,8 +63,8 @@ void shell(DDukeActor* i, bool morecheck);
void glasspieces(DDukeActor* i); void glasspieces(DDukeActor* i);
void scrap(DDukeActor* i, int SCRAP1, int SCRAP6); void scrap(DDukeActor* i, int SCRAP1, int SCRAP6);
void handle_se00(int i, int LASERLINE); void handle_se00(DDukeActor* i, int LASERLINE);
void handle_se01(int i); void handle_se01(DDukeActor* i);
void handle_se14(int i, bool checkstat, int RPG, int JIBS6); void handle_se14(int i, bool checkstat, int RPG, int JIBS6);
void handle_se30(int i, int JIBS6); void handle_se30(int i, int JIBS6);
void handle_se02(int i); void handle_se02(int i);