- the 5 remaining shared SE handlers.

This commit is contained in:
Christoph Oelckers 2020-10-22 00:40:57 +02:00
parent 769bc3bd22
commit 02813802d4
4 changed files with 64 additions and 73 deletions

View file

@ -4467,10 +4467,10 @@ void handle_se26(DDukeActor* actor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se27(int i) void handle_se27(DDukeActor* actor)
{ {
spritetype* s = &sprite[i]; auto s = &actor->s;
auto t = &hittype[i].temp_data[0]; int* t = &actor->temp_data[0];
auto sc = &sector[s->sectnum]; auto sc = &sector[s->sectnum];
int st = s->lotag; int st = s->lotag;
int sh = s->hitag; int sh = s->hitag;
@ -4478,34 +4478,34 @@ void handle_se27(int i)
if (ud.recstat == 0) return; if (ud.recstat == 0) return;
hittype[i].tempang = s->ang; actor->tempang = s->ang;
p = findplayer(s, &x); p = findplayer(&actor->s, &x);
if (sprite[ps[p].i].extra > 0 && myconnectindex == screenpeek) if (ps[p].GetActor()->s.extra > 0 && myconnectindex == screenpeek)
{ {
if (t[0] < 0) if (t[0] < 0)
{ {
ud.camerasprite = i; ud.camerasprite = actor->GetIndex();
t[0]++; t[0]++;
} }
else if (ud.recstat == 2 && ps[p].newowner == -1) else if (ud.recstat == 2 && ps[p].newowner == -1)
{ {
if (cansee(s->x, s->y, s->z, sprite[i].sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum)) if (cansee(s->x, s->y, s->z, s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum))
{ {
if (x < (unsigned)sh) if (x < (unsigned)sh)
{ {
ud.camerasprite = i; ud.camerasprite = actor->GetIndex();
t[0] = 999; t[0] = 999;
s->ang += getincangle(s->ang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 3; s->ang += getincangle(s->ang, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 3;
sprite[i].yvel = 100 + ((s->z - ps[p].posz) / 257); s->yvel = 100 + ((s->z - ps[p].posz) / 257);
} }
else if (t[0] == 999) else if (t[0] == 999)
{ {
if (ud.camerasprite == i) if (ud.camerasprite == actor->GetIndex())
t[0] = 0; t[0] = 0;
else t[0] = -10; else t[0] = -10;
ud.camerasprite = i; ud.camerasprite = actor->GetIndex();
} }
} }
@ -4515,10 +4515,10 @@ void handle_se27(int i)
if (t[0] == 999) if (t[0] == 999)
{ {
if (ud.camerasprite == i) if (ud.camerasprite == actor->GetIndex())
t[0] = 0; t[0] = 0;
else t[0] = -20; else t[0] = -20;
ud.camerasprite = i; ud.camerasprite = actor->GetIndex();
} }
} }
} }
@ -4531,10 +4531,10 @@ void handle_se27(int i)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se32(int i) void handle_se32(DDukeActor *actor)
{ {
spritetype* s = &sprite[i]; auto s = &actor->s;
auto t = &hittype[i].temp_data[0]; int* t = &actor->temp_data[0];
auto sc = &sector[s->sectnum]; auto sc = &sector[s->sectnum];
if (t[0] == 1) if (t[0] == 1)
@ -4543,57 +4543,51 @@ void handle_se32(int i)
if (t[2] == 1) // Retract if (t[2] == 1) // Retract
{ {
if (sprite[i].ang != 1536) if (s->ang != 1536)
{ {
if (abs(sc->ceilingz - s->z) < if (abs(sc->ceilingz - s->z) < (s->yvel << 1))
(sprite[i].yvel << 1))
{ {
sc->ceilingz = s->z; sc->ceilingz = s->z;
callsound(s->sectnum, i); callsound(s->sectnum, actor->GetIndex());
t[2] = 0; t[2] = 0;
t[0] = 0; t[0] = 0;
} }
else sc->ceilingz += else sc->ceilingz += sgn(s->z - sc->ceilingz) * s->yvel;
sgn(s->z - sc->ceilingz) * sprite[i].yvel;
} }
else else
{ {
if (abs(sc->ceilingz - t[1]) < if (abs(sc->ceilingz - t[1]) < (s->yvel << 1))
(sprite[i].yvel << 1))
{ {
sc->ceilingz = t[1]; sc->ceilingz = t[1];
callsound(s->sectnum, i); callsound(s->sectnum, actor->GetIndex());
t[2] = 0; t[2] = 0;
t[0] = 0; t[0] = 0;
} }
else sc->ceilingz += else sc->ceilingz += sgn(t[1] - sc->ceilingz) * s->yvel;
sgn(t[1] - sc->ceilingz) * sprite[i].yvel;
} }
return; return;
} }
if ((s->ang & 2047) == 1536) if ((s->ang & 2047) == 1536)
{ {
if (abs(sc->ceilingz - s->z) < if (abs(sc->ceilingz - s->z) < (s->yvel << 1))
(sprite[i].yvel << 1))
{ {
t[0] = 0; t[0] = 0;
t[2] = !t[2]; t[2] = !t[2];
callsound(s->sectnum, i); callsound(s->sectnum, actor->GetIndex());
sc->ceilingz = s->z; sc->ceilingz = s->z;
} }
else sc->ceilingz += else sc->ceilingz += sgn(s->z - sc->ceilingz) * s->yvel;
sgn(s->z - sc->ceilingz) * sprite[i].yvel;
} }
else else
{ {
if (abs(sc->ceilingz - t[1]) < (sprite[i].yvel << 1)) if (abs(sc->ceilingz - t[1]) < (s->yvel << 1))
{ {
t[0] = 0; t[0] = 0;
t[2] = !t[2]; t[2] = !t[2];
callsound(s->sectnum, i); callsound(s->sectnum, actor->GetIndex());
} }
else sc->ceilingz -= sgn(s->z - t[1]) * sprite[i].yvel; else sc->ceilingz -= sgn(s->z - t[1]) * s->yvel;
} }
} }
@ -4605,22 +4599,22 @@ void handle_se32(int i)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se35(int i, int SMALLSMOKE, int EXPLOSION2) void handle_se35(DDukeActor *actor, int SMALLSMOKE, int EXPLOSION2)
{ {
spritetype* s = &sprite[i]; auto s = &actor->s;
auto t = &hittype[i].temp_data[0]; int* t = &actor->temp_data[0];
auto sc = &sector[s->sectnum]; auto sc = &sector[s->sectnum];
if (sc->ceilingz > s->z) if (sc->ceilingz > s->z)
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
{ {
s->ang += krand() & 511; s->ang += krand() & 511;
int k = fi.spawn(i, SMALLSMOKE); auto spawned = spawn(actor, SMALLSMOKE);
sprite[k].xvel = 96 + (krand() & 127); spawned->s.xvel = 96 + (krand() & 127);
ssp(k, CLIPMASK0); ssp(spawned, CLIPMASK0);
setsprite(k, sprite[k].x, sprite[k].y, sprite[k].z); setsprite(spawned, spawned->s.pos);
if (rnd(16)) if (rnd(16))
fi.spawn(i, EXPLOSION2); spawn(actor, EXPLOSION2);
} }
switch (t[0]) switch (t[0])
@ -4649,11 +4643,10 @@ void handle_se35(int i, int SMALLSMOKE, int EXPLOSION2)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se128(int i) void handle_se128(DDukeActor *actor)
{ {
spritetype* s = &sprite[i]; int* t = &actor->temp_data[0];
auto t = &hittype[i].temp_data[0]; auto sc = &sector[actor->s.sectnum];
auto sc = &sector[s->sectnum];
auto wal = &wall[t[2]]; auto wal = &wall[t[2]];
@ -4679,7 +4672,7 @@ void handle_se128(int i)
wal->cstat &= (128 + 32 + 8 + 4 + 2); wal->cstat &= (128 + 32 + 8 + 4 + 2);
if (wal->nextwall >= 0) if (wal->nextwall >= 0)
wall[wal->nextwall].cstat &= (128 + 32 + 8 + 4 + 2); wall[wal->nextwall].cstat &= (128 + 32 + 8 + 4 + 2);
deletesprite(i); deletesprite(actor);
} }
} }
@ -4689,16 +4682,14 @@ void handle_se128(int i)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se130(int i, int countmax, int EXPLOSION2) void handle_se130(DDukeActor *actor, int countmax, int EXPLOSION2)
{ {
auto act = &hittype[i]; int* t = &actor->temp_data[0];
spritetype* s = &act->s; auto sc = &sector[actor->s.sectnum];
auto t = &act->temp_data[0];
auto sc = &sector[s->sectnum];
if (t[0] > countmax) if (t[0] > countmax)
{ {
deletesprite(i); deletesprite(actor);
return; return;
} }
else t[0]++; else t[0]++;
@ -4707,7 +4698,7 @@ void handle_se130(int i, int countmax, int EXPLOSION2)
if (rnd(64)) if (rnd(64))
{ {
auto k = spawn(act, EXPLOSION2); auto k = spawn(actor, EXPLOSION2);
k->s.xrepeat = k->s.yrepeat = 2 + (krand() & 7); k->s.xrepeat = k->s.yrepeat = 2 + (krand() & 7);
k->s.z = sc->floorz - (krand() % x); k->s.z = sc->floorz - (krand() % x);
k->s.ang += 256 - (krand() % 511); k->s.ang += 256 - (krand() % 511);

View file

@ -3763,7 +3763,7 @@ void moveeffectors_d(void) //STATNUM 3
break; break;
} }
case 35: case 35:
handle_se35(i, SMALLSMOKE, EXPLOSION2); handle_se35(&hittype[i], SMALLSMOKE, EXPLOSION2);
break; break;
case 25: //PISTONS case 25: //PISTONS
@ -3795,7 +3795,7 @@ void moveeffectors_d(void) //STATNUM 3
break; break;
case SE_27_DEMO_CAM: case SE_27_DEMO_CAM:
handle_se27(i); handle_se27(&hittype[i]);
break; break;
case 28: case 28:
if (t[5] > 0) if (t[5] > 0)
@ -4021,7 +4021,7 @@ void moveeffectors_d(void) //STATNUM 3
break; break;
case 32: // True Drop Ceiling case 32: // True Drop Ceiling
handle_se32(i); handle_se32(&hittype[i]);
break; break;
case 33: case 33:
@ -4041,14 +4041,14 @@ void moveeffectors_d(void) //STATNUM 3
break; break;
case 128: //SE to control glass breakage case 128: //SE to control glass breakage
handle_se128(i); handle_se128(&hittype[i]);
break; break;
case 130: case 130:
handle_se130(i, 80, EXPLOSION2); handle_se130(&hittype[i], 80, EXPLOSION2);
break; break;
case 131: case 131:
handle_se130(i, 40, EXPLOSION2); handle_se130(&hittype[i], 40, EXPLOSION2);
break; break;
} }
} }

View file

@ -3725,7 +3725,7 @@ void moveeffectors_r(void) //STATNUM 3
break; break;
} }
case 35: case 35:
handle_se35(i, SMALLSMOKE, EXPLOSION2); handle_se35(&hittype[i], SMALLSMOKE, EXPLOSION2);
break; break;
case 25: //PISTONS case 25: //PISTONS
@ -3765,7 +3765,7 @@ void moveeffectors_r(void) //STATNUM 3
break; break;
case SE_27_DEMO_CAM: case SE_27_DEMO_CAM:
handle_se27(i); handle_se27(&hittype[i]);
break; break;
case 29: case 29:
@ -3900,7 +3900,7 @@ void moveeffectors_r(void) //STATNUM 3
break; break;
case 32: // True Drop Ceiling case 32: // True Drop Ceiling
handle_se32(i); handle_se32(&hittype[i]);
break; break;
case 33: case 33:
@ -3920,14 +3920,14 @@ void moveeffectors_r(void) //STATNUM 3
break; break;
case 128: //SE to control glass breakage case 128: //SE to control glass breakage
handle_se128(i); handle_se128(&hittype[i]);
break; break;
case 130: case 130:
handle_se130(i, 80, EXPLOSION2); handle_se130(&hittype[i], 80, EXPLOSION2);
break; break;
case 131: case 131:
handle_se130(i, 40, EXPLOSION2); handle_se130(&hittype[i], 40, EXPLOSION2);
break; break;
} }
} }

View file

@ -85,11 +85,11 @@ void handle_se20(DDukeActor* i);
void handle_se21(DDukeActor* i); void handle_se21(DDukeActor* i);
void handle_se22(DDukeActor* i); void handle_se22(DDukeActor* i);
void handle_se26(DDukeActor* i); void handle_se26(DDukeActor* i);
void handle_se27(int i); void handle_se27(DDukeActor* i);
void handle_se32(int i); void handle_se32(DDukeActor* i);
void handle_se35(int i, int SMALLSMOKE, int EXPLOSION2); void handle_se35(DDukeActor* i, int SMALLSMOKE, int EXPLOSION2);
void handle_se128(int i); void handle_se128(DDukeActor* i);
void handle_se130(int i, int countmax, int EXPLOSION2); void handle_se130(DDukeActor* i, int countmax, int EXPLOSION2);
void respawn_rrra(DDukeActor* oldact, DDukeActor* newact); void respawn_rrra(DDukeActor* oldact, DDukeActor* newact);