- handle_se15-17.

This commit is contained in:
Christoph Oelckers 2020-10-22 00:25:11 +02:00
parent 33377e1810
commit 5b096ea35e
4 changed files with 59 additions and 68 deletions

View file

@ -3879,20 +3879,20 @@ void handle_se13(DDukeActor* actor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se15(int i) void handle_se15(DDukeActor* actor)
{ {
spritetype* s = &sprite[i]; auto s = &actor->s;
auto t = &hittype[i].temp_data[0]; int* t = &actor->temp_data[0];
if (t[4]) if (t[4])
{ {
s->xvel = 16; s->xvel = 16;
if (t[4] == 1) //Opening if (t[4] == 1) //Opening
{ {
if (t[3] >= (sprite[i].yvel >> 3)) if (t[3] >= (s->yvel >> 3))
{ {
t[4] = 0; //Turn off the sliders t[4] = 0; //Turn off the sliders
callsound(s->sectnum, i); callsound(s->sectnum, actor);
return; return;
} }
t[3]++; t[3]++;
@ -3902,14 +3902,14 @@ void handle_se15(int i)
if (t[3] < 1) if (t[3] < 1)
{ {
t[4] = 0; t[4] = 0;
callsound(s->sectnum, i); callsound(s->sectnum, actor);
return; return;
} }
t[3]--; t[3]--;
} }
ms(i); ms(actor);
setsprite(i, s->x, s->y, s->z); setsprite(actor, s->pos);
} }
} }
@ -3919,10 +3919,10 @@ void handle_se15(int i)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se16(int i, int REACTOR, int REACTOR2) void handle_se16(DDukeActor* actor, int REACTOR, int REACTOR2)
{ {
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];
t[2] += 32; t[2] += 32;
@ -3936,17 +3936,16 @@ void handle_se16(int i, int REACTOR, int REACTOR2)
//If there isn't, then kill this sectoreffector //If there isn't, then kill this sectoreffector
//itself..... //itself.....
SectIterator it(s->sectnum); DukeSectIterator it(s->sectnum);
int j; DDukeActor* a2;
while ((j = it.NextIndex()) >= 0) while ((a2 = it.Next()))
{ {
auto sj = &sprite[j]; if (a2->s.picnum == REACTOR || a2->s.picnum == REACTOR2)
if (sj->picnum == REACTOR || sj->picnum == REACTOR2)
return; return;
} }
if (j == -1) if (a2 == nullptr)
{ {
deletesprite(i); deletesprite(actor);
return; return;
} }
else s->shade = 1; else s->shade = 1;
@ -3955,8 +3954,8 @@ void handle_se16(int i, int REACTOR, int REACTOR2)
if (s->shade) sc->ceilingz += 1024; if (s->shade) sc->ceilingz += 1024;
else sc->ceilingz -= 512; else sc->ceilingz -= 512;
ms(i); ms(actor);
setsprite(i, s->x, s->y, s->z); setsprite(actor, s->pos);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -3965,50 +3964,46 @@ void handle_se16(int i, int REACTOR, int REACTOR2)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se17(int i) void handle_se17(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;
int q = t[0] * (sprite[i].yvel << 2); int q = t[0] * (s->yvel << 2);
sc->ceilingz += q; sc->ceilingz += q;
sc->floorz += q; sc->floorz += q;
SectIterator it(s->sectnum); DukeSectIterator it(s->sectnum);
int j; while (auto act1 = it.Next())
while ((j = it.NextIndex()) >= 0)
{ {
auto sj = &sprite[j]; if (act1->s.statnum == STAT_PLAYER && act1->GetOwner())
if (sj->statnum == 10 && sj->owner >= 0)
{ {
int p = sj->yvel; int p = act1->s.yvel;
if (numplayers < 2) if (numplayers < 2) ps[p].oposz = ps[p].posz;
ps[p].oposz = ps[p].posz;
ps[p].posz += q; ps[p].posz += q;
ps[p].truefz += q; ps[p].truefz += q;
ps[p].truecz += q; ps[p].truecz += q;
if (numplayers > 1) if (numplayers > 1) ps[p].oposz = ps[p].posz;
ps[p].oposz = ps[p].posz;
} }
if (sj->statnum != 3) if (act1->s.statnum != 3)
{ {
hittype[j].bposz = sj->z; act1->bposz = act1->s.z;
sj->z += q; act1->s.z += q;
} }
hittype[j].floorz = sc->floorz; act1->floorz = sc->floorz;
hittype[j].ceilingz = sc->ceilingz; act1->ceilingz = sc->ceilingz;
} }
if (t[0]) //If in motion if (t[0]) //If in motion
{ {
if (abs(sc->floorz - t[2]) <= sprite[i].yvel) if (abs(sc->floorz - t[2]) <= s->yvel)
{ {
activatewarpelevators(i, 0); activatewarpelevators(actor->GetIndex(), 0);
return; return;
} }
@ -4022,27 +4017,23 @@ void handle_se17(int i)
if (t[1] == 0) return; if (t[1] == 0) return;
t[1] = 0; t[1] = 0;
StatIterator it(STAT_EFFECTOR); DDukeActor* act2;
int j; DukeStatIterator it(STAT_EFFECTOR);
while ((j = it.NextIndex()) >= 0) while ((act2 = it.Next()))
{ {
if (i != j && (sprite[j].lotag) == 17) if (actor != act2 && (act2->s.lotag) == 17)
if ((sc->hitag - t[0]) == if ((sc->hitag - t[0]) == (sector[act2->s.sectnum].hitag) && sh == (act2->s.hitag))
(sector[sprite[j].sectnum].hitag)
&& sh == (sprite[j].hitag))
break; break;
} }
if (j == -1) return; if (act2 == nullptr) return;
auto spr2 = &sprite[j]; auto spr2 = &act2->s;
SectIterator its(s->sectnum); DukeSectIterator its(s->sectnum);
int k; while (auto act3 = its.Next())
while ((k = its.NextIndex()) >= 0)
{ {
auto spr3 = &sprite[k]; auto spr3 = &act3->s;
auto act3 = &hittype[k]; if (spr3->statnum == STAT_PLAYER && act3->GetOwner())
if (spr3->statnum == 10 && spr3->owner >= 0)
{ {
int p = spr3->yvel; int p = spr3->yvel;
@ -4061,7 +4052,7 @@ void handle_se17(int i)
ps[p].truecz = act3->ceilingz; ps[p].truecz = act3->ceilingz;
ps[p].bobcounter = 0; ps[p].bobcounter = 0;
changespritesect(k, spr2->sectnum); changespritesect(act3, spr2->sectnum);
ps[p].cursectnum = spr2->sectnum; ps[p].cursectnum = spr2->sectnum;
} }
else if (spr3->statnum != 3) else if (spr3->statnum != 3)
@ -4074,8 +4065,8 @@ void handle_se17(int i)
act3->bposy = spr3->y; act3->bposy = spr3->y;
act3->bposz = spr3->z; act3->bposz = spr3->z;
changespritesect(k, spr2->sectnum); changespritesect(act3, spr2->sectnum);
setsprite(k, spr3->x, spr3->y, spr3->z); setsprite(act3, spr3->pos);
act3->floorz = sector[spr2->sectnum].floorz; act3->floorz = sector[spr2->sectnum].floorz;
act3->ceilingz = sector[spr2->sectnum].ceilingz; act3->ceilingz = sector[spr2->sectnum].ceilingz;

View file

@ -3640,15 +3640,15 @@ void moveeffectors_d(void) //STATNUM 3
break; break;
case SE_15_SLIDING_DOOR: case SE_15_SLIDING_DOOR:
handle_se15(i); handle_se15(&hittype[i]);
break; break;
case SE_16_REACTOR: case SE_16_REACTOR:
handle_se16(i, REACTOR, REACTOR2); handle_se16(&hittype[i], REACTOR, REACTOR2);
break; break;
case SE_17_WARP_ELEVATOR: case SE_17_WARP_ELEVATOR:
handle_se17(i); handle_se17(&hittype[i]);
break; break;
case SE_18_INCREMENTAL_SECTOR_RISE_FALL: case SE_18_INCREMENTAL_SECTOR_RISE_FALL:

View file

@ -3611,15 +3611,15 @@ void moveeffectors_r(void) //STATNUM 3
break; break;
case SE_15_SLIDING_DOOR: case SE_15_SLIDING_DOOR:
handle_se15(i); handle_se15(&hittype[i]);
break; break;
case SE_16_REACTOR: case SE_16_REACTOR:
handle_se16(i, REACTOR, REACTOR2); handle_se16(&hittype[i], REACTOR, REACTOR2);
break; break;
case SE_17_WARP_ELEVATOR: case SE_17_WARP_ELEVATOR:
handle_se17(i); handle_se17(&hittype[i]);
break; break;
case SE_18_INCREMENTAL_SECTOR_RISE_FALL: case SE_18_INCREMENTAL_SECTOR_RISE_FALL:

View file

@ -76,9 +76,9 @@ void handle_se10(DDukeActor* i, const int *);
void handle_se11(DDukeActor* i); void handle_se11(DDukeActor* i);
void handle_se12(DDukeActor* i, int planeonly = 0); void handle_se12(DDukeActor* i, int planeonly = 0);
void handle_se13(DDukeActor* i); void handle_se13(DDukeActor* i);
void handle_se15(int i); void handle_se15(DDukeActor* i);
void handle_se16(int i, int REACTOR, int REACTOR2); void handle_se16(DDukeActor* i, int REACTOR, int REACTOR2);
void handle_se17(int i); void handle_se17(DDukeActor* i);
void handle_se18(int i, bool morecheck); void handle_se18(int i, bool morecheck);
void handle_se19(int i, int BIGFORCE); void handle_se19(int i, int BIGFORCE);
void handle_se20(int i); void handle_se20(int i);