- shared SE31 code.

This commit is contained in:
Christoph Oelckers 2020-10-22 01:04:13 +02:00
parent 21fb3fb7bb
commit 8f75a58343
4 changed files with 147 additions and 256 deletions

View file

@ -4833,6 +4833,150 @@ void handle_se130(DDukeActor *actor, int countmax, int EXPLOSION2)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se31(DDukeActor* actor, bool choosedir)
{
auto s = &actor->s;
int* t = &actor->temp_data[0];
auto sec = &sector[s->sectnum];
if (t[0] == 1)
{
// Choose dir
if (choosedir && t[3] > 0)
{
t[3]--;
return;
}
if (t[2] == 1) // Retract
{
if (s->ang != 1536)
{
if (abs(sec->floorz - s->z) < s->yvel)
{
sec->floorz = s->z;
t[2] = 0;
t[0] = 0;
if (choosedir) t[3] = s->hitag;
callsound(s->sectnum, actor->GetIndex());
}
else
{
int l = sgn(s->z - sec->floorz) * s->yvel;
sec->floorz += l;
DukeSectIterator it(s->sectnum);
while (auto a2 = it.Next())
{
if (a2->s.picnum == TILE_APLAYER && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].posz += l;
if (a2->s.zvel == 0 && a2->s.statnum != STAT_EFFECTOR && (!choosedir || a2->s.statnum != STAT_PROJECTILE))
{
a2->bposz = a2->s.z += l;
a2->floorz = sec->floorz;
}
}
}
}
else
{
if (abs(sec->floorz - t[1]) < s->yvel)
{
sec->floorz = t[1];
callsound(s->sectnum, actor->GetIndex());
t[2] = 0;
t[0] = 0;
if (choosedir) t[3] = s->hitag;
}
else
{
int l = sgn(t[1] - sec->floorz) * s->yvel;
sec->floorz += l;
DukeSectIterator it(s->sectnum);
while (auto a2 = it.Next())
{
if (a2->s.picnum == TILE_APLAYER && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].posz += l;
if (a2->s.zvel == 0 && a2->s.statnum != STAT_EFFECTOR && (!choosedir || a2->s.statnum != STAT_PROJECTILE))
{
a2->bposz = a2->s.z += l;
a2->floorz = sec->floorz;
}
}
}
}
return;
}
if ((s->ang & 2047) == 1536)
{
if (abs(s->z - sec->floorz) < s->yvel)
{
callsound(s->sectnum, actor->GetIndex());
t[0] = 0;
t[2] = 1;
if (choosedir) t[3] = s->hitag;
}
else
{
int l = sgn(s->z - sec->floorz) * s->yvel;
sec->floorz += l;
DukeSectIterator it(s->sectnum);
while (auto a2 = it.Next())
{
if (a2->s.picnum == TILE_APLAYER && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].posz += l;
if (a2->s.zvel == 0 && a2->s.statnum != STAT_EFFECTOR && (!choosedir || a2->s.statnum != STAT_PROJECTILE))
{
a2->bposz = a2->s.z += l;
a2->floorz = sec->floorz;
}
}
}
}
else
{
if (abs(sec->floorz - t[1]) < s->yvel)
{
t[0] = 0;
callsound(s->sectnum, actor->GetIndex());
t[2] = 1;
t[3] = s->hitag;
}
else
{
int l = sgn(s->z - t[1]) * s->yvel;
sec->floorz -= l;
DukeSectIterator it(s->sectnum);
while (auto a2 = it.Next())
{
if (a2->s.picnum ==TILE_APLAYER && a2->GetOwner())
if (ps[a2->PlayerIndex()].on_ground == 1)
ps[a2->PlayerIndex()].posz -= l;
if (a2->s.zvel == 0 && a2->s.statnum != STAT_EFFECTOR && (!choosedir || a2->s.statnum != STAT_PROJECTILE))
{
a2->bposz = a2->s.z -= l;
a2->floorz = sec->floorz;
}
}
}
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void getglobalz(int i) void getglobalz(int i)
{ {
int hz,lz,zr; int hz,lz,zr;

View file

@ -3783,140 +3783,7 @@ void moveeffectors_d(void) //STATNUM 3
sc->floorz = s->z + l; sc->floorz = s->z + l;
break; break;
case 31: // True Drop Floor case 31: // True Drop Floor
if (t[0] == 1) handle_se31(&hittype[i], true);
{
// Choose dir
if (t[3] > 0)
{
t[3]--;
break;
}
if (t[2] == 1) // Retract
{
if (sprite[i].ang != 1536)
{
if (abs(sc->floorz - s->z) < sprite[i].yvel )
{
sc->floorz = s->z;
t[2] = 0;
t[0] = 0;
t[3] = s->hitag;
callsound(s->sectnum, i);
}
else
{
l = sgn(s->z - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
SectIterator it(s->sectnum);
while ((j = it.NextIndex()) >= 0)
{
auto sj = &sprite[j];
if (sj->picnum == APLAYER && sj->owner >= 0)
if (ps[sj->yvel].on_ground == 1)
ps[sj->yvel].posz += l;
if (sj->zvel == 0 && sj->statnum != 3 && sj->statnum != 4)
{
hittype[j].bposz = sj->z += l;
hittype[j].floorz = sc->floorz;
}
}
}
}
else
{
if (abs(sc->floorz - t[1]) < sprite[i].yvel )
{
sc->floorz = t[1];
callsound(s->sectnum, i);
t[2] = 0;
t[0] = 0;
t[3] = s->hitag;
}
else
{
l = sgn(t[1] - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
SectIterator it(s->sectnum);
while ((j = it.NextIndex()) >= 0)
{
auto sj = &sprite[j];
if (sj->picnum == APLAYER && sj->owner >= 0)
if (ps[sj->yvel].on_ground == 1)
ps[sj->yvel].posz += l;
if (sj->zvel == 0 && sj->statnum != 3 && sj->statnum != 4)
{
hittype[j].bposz = sj->z += l;
hittype[j].floorz = sc->floorz;
}
}
}
}
break;
}
if ((s->ang & 2047) == 1536)
{
if (abs(s->z - sc->floorz) < sprite[i].yvel )
{
callsound(s->sectnum, i);
t[0] = 0;
t[2] = 1;
t[3] = s->hitag;
}
else
{
l = sgn(s->z - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
SectIterator it(s->sectnum);
while ((j = it.NextIndex()) >= 0)
{
auto sj = &sprite[j];
if (sj->picnum == APLAYER && sj->owner >= 0)
if (ps[sj->yvel].on_ground == 1)
ps[sj->yvel].posz += l;
if (sj->zvel == 0 && sj->statnum != 3 && sj->statnum != 4)
{
hittype[j].bposz = sj->z += l;
hittype[j].floorz = sc->floorz;
}
}
}
}
else
{
if (abs(sc->floorz - t[1]) < sprite[i].yvel )
{
t[0] = 0;
callsound(s->sectnum, i);
t[2] = 1;
t[3] = s->hitag;
}
else
{
l = sgn(s->z - t[1]) * sprite[i].yvel ;
sc->floorz -= l;
SectIterator it(s->sectnum);
while ((j = it.NextIndex()) >= 0)
{
auto sj = &sprite[j];
if (sj->picnum == APLAYER && sj->owner >= 0)
if (ps[sj->yvel].on_ground == 1)
ps[sj->yvel].posz -= l;
if (sj->zvel == 0 && sj->statnum != 3 && sj->statnum != 4)
{
hittype[j].bposz = sj->z -= l;
hittype[j].floorz = sc->floorz;
}
}
}
}
}
break; break;
case 32: // True Drop Ceiling case 32: // True Drop Ceiling

View file

@ -3678,128 +3678,7 @@ void moveeffectors_r(void) //STATNUM 3
break; break;
case 31: // True Drop Floor case 31: // True Drop Floor
if (t[0] == 1) handle_se31(&hittype[i], false);
{
if (t[2] == 1) // Retract
{
if (sprite[i].ang != 1536)
{
if (abs(sc->floorz - s->z) < sprite[i].yvel )
{
sc->floorz = s->z;
t[2] = 0;
t[0] = 0;
callsound(s->sectnum, i);
}
else
{
l = sgn(s->z - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
SectIterator it(s->sectnum);
while ((j = it.NextIndex()) >= 0)
{
auto sj = &sprite[j];
if (sj->picnum == APLAYER && sj->owner >= 0)
if (ps[sj->yvel].on_ground == 1)
ps[sj->yvel].posz += l;
if (sj->zvel == 0 && sj->statnum != 3)
{
hittype[j].bposz = sj->z += l;
hittype[j].floorz = sc->floorz;
}
}
}
}
else
{
if (abs(sc->floorz - t[1]) < sprite[i].yvel )
{
sc->floorz = t[1];
callsound(s->sectnum, i);
t[2] = 0;
t[0] = 0;
}
else
{
l = sgn(t[1] - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
SectIterator it(s->sectnum);
while ((j = it.NextIndex()) >= 0)
{
auto sj = &sprite[j];
if (sj->picnum == APLAYER && sj->owner >= 0)
if (ps[sj->yvel].on_ground == 1)
ps[sj->yvel].posz += l;
if (sj->zvel == 0 && sj->statnum != 3)
{
hittype[j].bposz = sj->z += l;
hittype[j].floorz = sc->floorz;
}
}
}
}
break;
}
if ((s->ang & 2047) == 1536)
{
if (abs(s->z - sc->floorz) < sprite[i].yvel )
{
callsound(s->sectnum, i);
t[0] = 0;
t[2] = 1;
}
else
{
l = sgn(s->z - sc->floorz) * sprite[i].yvel ;
sc->floorz += l;
SectIterator it(s->sectnum);
while ((j = it.NextIndex()) >= 0)
{
auto sj = &sprite[j];
if (sj->picnum == APLAYER && sj->owner >= 0)
if (ps[sj->yvel].on_ground == 1)
ps[sj->yvel].posz += l;
if (sj->zvel == 0 && sj->statnum != 3)
{
hittype[j].bposz = sj->z += l;
hittype[j].floorz = sc->floorz;
}
}
}
}
else
{
if (abs(sc->floorz - t[1]) < sprite[i].yvel )
{
t[0] = 0;
callsound(s->sectnum, i);
t[2] = 1;
}
else
{
l = sgn(s->z - t[1]) * sprite[i].yvel ;
sc->floorz -= l;
SectIterator it(s->sectnum);
while ((j = it.NextIndex()) >= 0)
{
auto sj = &sprite[j];
if (sj->picnum == APLAYER && sj->owner >= 0)
if (ps[sj->yvel].on_ground == 1)
ps[sj->yvel].posz -= l;
if (sj->zvel == 0 && sj->statnum != 3)
{
hittype[j].bposz = sj->z -= l;
hittype[j].floorz = sc->floorz;
}
}
}
}
}
break; break;
case 32: // True Drop Ceiling case 32: // True Drop Ceiling

View file

@ -88,6 +88,7 @@ void handle_se24(DDukeActor* actor, int16_t* list1, int16_t* list2, int TRIPBOMB
void handle_se25(DDukeActor* a, int t_index, int snd1, int snd2); void handle_se25(DDukeActor* a, int t_index, int snd1, int snd2);
void handle_se26(DDukeActor* i); void handle_se26(DDukeActor* i);
void handle_se27(DDukeActor* i); void handle_se27(DDukeActor* i);
void handle_se31(DDukeActor* a, bool choosedir);
void handle_se32(DDukeActor* i); void handle_se32(DDukeActor* i);
void handle_se35(DDukeActor* i, int SMALLSMOKE, int EXPLOSION2); void handle_se35(DDukeActor* i, int SMALLSMOKE, int EXPLOSION2);
void handle_se128(DDukeActor* i); void handle_se128(DDukeActor* i);