- handle_se30.

This commit is contained in:
Christoph Oelckers 2020-10-22 00:00:43 +02:00
parent a6468970c6
commit 80aab4b5f7
4 changed files with 46 additions and 45 deletions

View file

@ -2998,25 +2998,26 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void handle_se30(int i, int JIBS6) void handle_se30(DDukeActor *actor, int JIBS6)
{ {
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;
if (s->owner == -1) auto Owner = actor->GetOwner();
if (Owner == nullptr)
{ {
t[3] = !t[3]; t[3] = !t[3];
hittype[i].SetOwner(LocateTheLocator(t[3], t[0])); Owner = LocateTheLocator(t[3], t[0]);
actor->SetOwner(Owner);
} }
else else
{ {
if (t[4] == 1) // Starting to go if (t[4] == 1) // Starting to go
{ {
if (ldist(&sprite[s->owner], s) < (2048 - 128)) if (ldist(Owner, actor) < (2048 - 128))
t[4] = 2; t[4] = 2;
else else
{ {
@ -3028,7 +3029,7 @@ void handle_se30(int i, int JIBS6)
} }
if (t[4] == 2) if (t[4] == 2)
{ {
int l = FindDistance2D(sprite[s->owner].x - s->x, sprite[s->owner].y - s->y); int l = FindDistance2D(Owner->s.x - s->x, Owner->s.y - s->y);
if (l <= 128) if (l <= 128)
s->xvel = 0; s->xvel = 0;
@ -3039,20 +3040,18 @@ void handle_se30(int i, int JIBS6)
{ {
s->xvel = 0; s->xvel = 0;
operateactivators(s->hitag + (short)t[3], -1); operateactivators(s->hitag + (short)t[3], -1);
s->owner = -1; actor->SetOwner(nullptr);
s->ang += 1024; s->ang += 1024;
t[4] = 0; t[4] = 0;
fi.operateforcefields(i, s->hitag); fi.operateforcefields(actor->GetIndex(), s->hitag);
SectIterator it(s->sectnum); DukeSectIterator it(s->sectnum);
int j; while (auto a2 = it.Next())
while ((j = it.NextIndex()) >= 0)
{ {
auto sj = &sprite[j]; if (a2->s.picnum != SECTOREFFECTOR && a2->s.picnum != LOCATORS)
if (sj->picnum != SECTOREFFECTOR && sj->picnum != LOCATORS)
{ {
hittype[j].bposx = sj->x; a2->bposx = a2->s.x;
hittype[j].bposy = sj->y; a2->bposy = a2->s.y;
} }
} }
@ -3068,7 +3067,9 @@ void handle_se30(int i, int JIBS6)
if ((sc->floorz - sc->ceilingz) < (108 << 8)) if ((sc->floorz - sc->ceilingz) < (108 << 8))
if (ud.clipping == 0) if (ud.clipping == 0)
for (int p = connecthead; p >= 0; p = connectpoint2[p]) for (int p = connecthead; p >= 0; p = connectpoint2[p])
if (sprite[ps[p].i].extra > 0) {
auto psp = ps[p].GetActor();
if (psp->s.extra > 0)
{ {
short k = ps[p].cursectnum; short k = ps[p].cursectnum;
updatesector(ps[p].posx, ps[p].posy, &k); updatesector(ps[p].posx, ps[p].posy, &k);
@ -3078,14 +3079,15 @@ void handle_se30(int i, int JIBS6)
ps[p].posy = s->y; ps[p].posy = s->y;
ps[p].cursectnum = s->sectnum; ps[p].cursectnum = s->sectnum;
setsprite(ps[p].i, s->x, s->y, s->z); setsprite(ps[p].GetActor(), s->pos);
quickkill(&ps[p]); quickkill(&ps[p]);
} }
} }
}
for (int p = connecthead; p >= 0; p = connectpoint2[p]) for (int p = connecthead; p >= 0; p = connectpoint2[p])
{ {
if (sprite[ps[p].i].sectnum == s->sectnum) auto psp = ps[p].GetActor();
if (psp->s.sectnum == s->sectnum)
{ {
ps[p].posx += l; ps[p].posx += l;
ps[p].posy += x; ps[p].posy += x;
@ -3107,12 +3109,10 @@ void handle_se30(int i, int JIBS6)
} }
} }
SectIterator its(s->sectnum); DukeSectIterator its(s->sectnum);
int j; while (auto a2 = its.Next())
while ((j = its.NextIndex()) >= 0)
{ {
auto spa2 = &sprite[j]; auto spa2 = &a2->s;
auto a2 = &hittype[j];
if (spa2->picnum != SECTOREFFECTOR && spa2->picnum != LOCATORS) if (spa2->picnum != SECTOREFFECTOR && spa2->picnum != LOCATORS)
{ {
if (numplayers < 2) if (numplayers < 2)
@ -3132,14 +3132,14 @@ void handle_se30(int i, int JIBS6)
} }
} }
ms(i); ms(actor);
setsprite(i, s->x, s->y, s->z); setsprite(actor, s->pos);
if ((sc->floorz - sc->ceilingz) < (108 << 8)) if ((sc->floorz - sc->ceilingz) < (108 << 8))
{ {
if (ud.clipping == 0) if (ud.clipping == 0)
for (int p = connecthead; p >= 0; p = connectpoint2[p]) for (int p = connecthead; p >= 0; p = connectpoint2[p])
if (sprite[ps[p].i].extra > 0) if (ps[p].GetActor()->s.extra > 0)
{ {
short k = ps[p].cursectnum; short k = ps[p].cursectnum;
updatesector(ps[p].posx, ps[p].posy, &k); updatesector(ps[p].posx, ps[p].posy, &k);
@ -3153,33 +3153,34 @@ void handle_se30(int i, int JIBS6)
ps[p].cursectnum = s->sectnum; ps[p].cursectnum = s->sectnum;
setsprite(ps[p].i, s->x, s->y, s->z); setsprite(ps[p].GetActor(), s->pos);
quickkill(&ps[p]); quickkill(&ps[p]);
} }
} }
SectIterator it(sprite[sprite[i].owner].sectnum); if (Owner)
while ((j = it.NextIndex()) >= 0)
{ {
auto sj = &sprite[j]; DukeSectIterator it(Owner->s.sectnum);
if (sj->statnum == 1 && badguy(&sprite[j]) && sj->picnum != SECTOREFFECTOR && sj->picnum != LOCATORS) while (auto a2 = it.Next())
{ {
// if(sj->sectnum != s->sectnum) if (a2->s.statnum == 1 && badguy(a2) && a2->s.picnum != SECTOREFFECTOR && a2->s.picnum != LOCATORS)
{ {
short k = sj->sectnum; // if(a2->s.sectnum != s->sectnum)
updatesector(sj->x, sj->y, &k);
if (sj->extra >= 0 && k == s->sectnum)
{ {
fi.gutsdir(&sprite[j], JIBS6, 24, myconnectindex); short k = a2->s.sectnum;
S_PlayActorSound(SQUISHED, j); updatesector(a2->s.x, a2->s.y, &k);
deletesprite(j); if (a2->s.extra >= 0 && k == s->sectnum)
{
fi.gutsdir(&a2->s, JIBS6, 24, myconnectindex);
S_PlayActorSound(SQUISHED, a2);
deletesprite(a2);
} }
} }
} }
} }
} }
} }
}
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View file

@ -3628,7 +3628,7 @@ void moveeffectors_d(void) //STATNUM 3
break; break;
case SE_30_TWO_WAY_TRAIN: case SE_30_TWO_WAY_TRAIN:
handle_se30(i, JIBS6); handle_se30(&hittype[i], JIBS6);
break; break;

View file

@ -3589,7 +3589,7 @@ void moveeffectors_r(void) //STATNUM 3
break; break;
case SE_30_TWO_WAY_TRAIN: case SE_30_TWO_WAY_TRAIN:
handle_se30(i, JIBS6); handle_se30(&hittype[i], JIBS6);
break; break;

View file

@ -66,7 +66,7 @@ void scrap(DDukeActor* i, int SCRAP1, int SCRAP6);
void handle_se00(DDukeActor* i, int LASERLINE); void handle_se00(DDukeActor* i, int LASERLINE);
void handle_se01(DDukeActor* i); void handle_se01(DDukeActor* i);
void handle_se14(DDukeActor* i, bool checkstat, int RPG, int JIBS6); void handle_se14(DDukeActor* i, bool checkstat, int RPG, int JIBS6);
void handle_se30(int i, int JIBS6); void handle_se30(DDukeActor* i, int JIBS6);
void handle_se02(int i); void handle_se02(int i);
void handle_se03(int i); void handle_se03(int i);
void handle_se04(int i); void handle_se04(int i);