- activatewarpelevators
This commit is contained in:
Christoph Oelckers 2020-10-23 17:46:46 +02:00
parent 1a300aa220
commit 4dd9be7b6d
3 changed files with 25 additions and 27 deletions

View file

@ -4003,7 +4003,7 @@ void handle_se17(DDukeActor* actor)
{ {
if (abs(sc->floorz - t[2]) <= s->yvel) if (abs(sc->floorz - t[2]) <= s->yvel)
{ {
activatewarpelevators(actor->GetIndex(), 0); activatewarpelevators(actor, 0);
return; return;
} }

View file

@ -146,7 +146,7 @@ int findplayer(const DDukeActor* s, int* dist);
void operatejaildoors(int hitag); void operatejaildoors(int hitag);
void allignwarpelevators(void); void allignwarpelevators(void);
bool isablockdoor(int tileNum); bool isablockdoor(int tileNum);
bool activatewarpelevators(int s, int w); bool activatewarpelevators(DDukeActor* s, int w);
int check_activator_motion(int lotag); int check_activator_motion(int lotag);
void operateactivators(int l, int w); void operateactivators(int l, int w);
void operateforcefields_common(int s, int low, const std::initializer_list<int>& tiles); void operateforcefields_common(int s, int low, const std::initializer_list<int>& tiles);

View file

@ -431,25 +431,24 @@ int setanimation(short animsect, int animtype, int animtarget, int thegoal, int
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool activatewarpelevators(int s, int d) //Parm = sectoreffectornum bool activatewarpelevators(DDukeActor* actor, int d) //Parm = sectoreffectornum
{ {
int i, sn; int sn = actor->s.sectnum;
sn = sprite[s].sectnum;
// See if the sector exists // See if the sector exists
StatIterator it(STAT_EFFECTOR); DukeStatIterator it(STAT_EFFECTOR);
while ((i = it.NextIndex()) >= 0) DDukeActor *act2;
while ((act2 = it.Next()))
{ {
if (sprite[i].lotag == SE_17_WARP_ELEVATOR || (isRRRA() && sprite[i].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL)) if (act2->s.lotag == SE_17_WARP_ELEVATOR || (isRRRA() && act2->s.lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL))
if (sprite[i].hitag == sprite[s].hitag) if (act2->s.hitag == actor->s.hitag)
if ((abs(sector[sn].floorz - hittype[s].temp_data[2]) > sprite[i].yvel) || if ((abs(sector[sn].floorz - actor->temp_data[2]) > act2->s.yvel) ||
(sector[sprite[i].sectnum].hitag == (sector[sn].hitag - d))) (sector[act2->s.sectnum].hitag == (sector[sn].hitag - d)))
break; break;
} }
if (i == -1) if (act2 == nullptr)
{ {
d = 0; d = 0;
return 1; // No find return 1; // No find
@ -457,24 +456,23 @@ bool activatewarpelevators(int s, int d) //Parm = sectoreffectornum
else else
{ {
if (d == 0) if (d == 0)
S_PlayActorSound(ELEVATOR_OFF, s); S_PlayActorSound(ELEVATOR_OFF, actor);
else S_PlayActorSound(ELEVATOR_ON, s); else S_PlayActorSound(ELEVATOR_ON, actor);
} }
it.Reset(STAT_EFFECTOR); it.Reset(STAT_EFFECTOR);
while ((i = it.NextIndex()) >= 0) while ((act2 = it.Next()))
{ {
if (sprite[i].lotag == SE_17_WARP_ELEVATOR || (isRRRA() && sprite[i].lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL)) if (act2->s.lotag == SE_17_WARP_ELEVATOR || (isRRRA() && act2->s.lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL))
if (sprite[i].hitag == sprite[s].hitag) if (act2->s.hitag == actor->s.hitag)
{ {
hittype[i].temp_data[0] = d; act2->temp_data[0] = d;
hittype[i].temp_data[1] = d; //Make all check warp act2->temp_data[1] = d; //Make all check warp
} }
} }
return 0; return 0;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //
@ -642,18 +640,18 @@ void operatesectors(int sn, int ii)
if (sprite[ii].sectnum == sn) if (sprite[ii].sectnum == sn)
{ {
if (activatewarpelevators(i, -1)) if (activatewarpelevators(&hittype[i], -1))
activatewarpelevators(i, 1); activatewarpelevators(&hittype[i], 1);
else if (activatewarpelevators(i, 1)) else if (activatewarpelevators(&hittype[i], 1))
activatewarpelevators(i, -1); activatewarpelevators(&hittype[i], -1);
return; return;
} }
else else
{ {
if (sptr->floorz > sprite[i].z) if (sptr->floorz > sprite[i].z)
activatewarpelevators(i, -1); activatewarpelevators(&hittype[i], -1);
else else
activatewarpelevators(i, 1); activatewarpelevators(&hittype[i], 1);
} }
return; return;