- initcrane and spawneffector.

This commit is contained in:
Christoph Oelckers 2020-11-02 22:20:41 +01:00
parent e2e24fc508
commit 90511a97e7
4 changed files with 43 additions and 36 deletions

View file

@ -194,7 +194,7 @@ void initshell(DDukeActor* actj, DDukeActor* acti, bool isshell);
void initcrane(DDukeActor* actj, DDukeActor* acti, int CRANEPOLE); void initcrane(DDukeActor* actj, DDukeActor* acti, int CRANEPOLE);
void initwaterdrip(DDukeActor* actj, DDukeActor* acti); void initwaterdrip(DDukeActor* actj, DDukeActor* acti);
int initreactor(DDukeActor* actj, DDukeActor* acti, bool isrecon); int initreactor(DDukeActor* actj, DDukeActor* acti, bool isrecon);
void spawneffector(int i); void spawneffector(DDukeActor* actor);
void gameexitfrommenu(); void gameexitfrommenu();
int startrts(int lumpNum, int localPlayer); int startrts(int lumpNum, int localPlayer);

View file

@ -624,12 +624,12 @@ int initreactor(DDukeActor* actj, DDukeActor* actor, bool isrecon)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void spawneffector(int i) void spawneffector(DDukeActor* actor)
{ {
auto sp = &sprite[i]; auto sp = &actor->s;
int sect = sp->sectnum; int sect = sp->sectnum;
auto t = hittype[i].temp_data; auto t = actor->temp_data;
int j, startwall, endwall, x, y, d, s, clostest; int startwall, endwall, x, y, d, s, clostest;
sp->yvel = sector[sect].extra; sp->yvel = sector[sect].extra;
sp->cstat |= 32768; sp->cstat |= 32768;
@ -644,18 +644,21 @@ void spawneffector(int i)
case SE_23_ONE_WAY_TELEPORT:// XPTR END case SE_23_ONE_WAY_TELEPORT:// XPTR END
if (sp->lotag != 23) if (sp->lotag != 23)
{ {
for (j = 0; j < MAXSPRITES; j++) DukeSpriteIterator it;
if (sprite[j].statnum < MAXSTATUS && sprite[j].picnum == SECTOREFFECTOR && (sprite[j].lotag == 7 || sprite[j].lotag == 23) && i != j && sprite[j].hitag == sp->hitag) while (auto act2 = it.Next())
{ {
sp->owner = j; if (act2->s.statnum < MAXSTATUS && act2->s.picnum == SECTOREFFECTOR && (act2->s.lotag == 7 || act2->s.lotag == 23) && actor != act2 && act2->s.hitag == sp->hitag)
{
actor->SetOwner(act2);
break; break;
} }
} }
else sp->owner = i; }
else actor->SetOwner(actor);
t[4] = sector[sect].floorz == sp->z; t[4] = sector[sect].floorz == sp->z;
sp->cstat = 0; sp->cstat = 0;
changespritestat(i, 9); changespritestat(actor, STAT_TRANSPORT);
return; return;
case SE_1_PIVOT: case SE_1_PIVOT:
sp->owner = -1; sp->owner = -1;
@ -750,7 +753,7 @@ void spawneffector(int i)
{ {
startwall = sector[sect].wallptr; startwall = sector[sect].wallptr;
endwall = startwall + sector[sect].wallnum; endwall = startwall + sector[sect].wallnum;
for (j = startwall; j < endwall; j++) for (int j = startwall; j < endwall; j++)
{ {
int x = wall[j].nextsector; int x = wall[j].nextsector;
if (x >= 0) if (x >= 0)
@ -769,10 +772,10 @@ void spawneffector(int i)
break; break;
case SE_17_WARP_ELEVATOR: case SE_17_WARP_ELEVATOR:
{
t[2] = sector[sect].floorz; //Stopping loc t[2] = sector[sect].floorz; //Stopping loc
j = nextsectorneighborz(sect, sector[sect].floorz, -1, -1); int j = nextsectorneighborz(sect, sector[sect].floorz, -1, -1);
t[3] = sector[j].ceilingz; t[3] = sector[j].ceilingz;
j = nextsectorneighborz(sect, sector[sect].ceilingz, 1, 1); j = nextsectorneighborz(sect, sector[sect].ceilingz, 1, 1);
@ -785,7 +788,7 @@ void spawneffector(int i)
} }
break; break;
}
case SE_24_CONVEYOR: case SE_24_CONVEYOR:
sp->yvel <<= 1; sp->yvel <<= 1;
case SE_36_PROJ_SHOOTER: case SE_36_PROJ_SHOOTER:
@ -960,18 +963,20 @@ void spawneffector(int i)
{ {
if (sector[sect].lotag == 30) if (sector[sect].lotag == 30)
{ {
if (sp->pal) sprite[i].clipdist = 1; if (sp->pal) sp->clipdist = 1;
else sprite[i].clipdist = 0; else sp->clipdist = 0;
t[3] = sector[sect].floorz; t[3] = sector[sect].floorz;
sector[sect].hitag = i; // hijack sector[sect].hitag = actor->GetIndex(); // hijack
} }
for (j = 0; j < MAXSPRITES; j++) DukeSpriteIterator it;
bool found = false;
while (auto act2 = it.Next())
{ {
auto spr = &sprite[j]; auto spr = &act2->s;
if (spr->statnum < MAXSTATUS) if (spr->statnum < MAXSTATUS)
if (spr->picnum == SECTOREFFECTOR && if (spr->picnum == SECTOREFFECTOR &&
spr->lotag == 1 && spr->lotag == SE_1_PIVOT &&
spr->hitag == sp->hitag) spr->hitag == sp->hitag)
{ {
if (sp->ang == 512) if (sp->ang == 512)
@ -979,14 +984,15 @@ void spawneffector(int i)
sp->x = spr->x; sp->x = spr->x;
sp->y = spr->y; sp->y = spr->y;
} }
found = true;
actor->SetOwner(act2);
break; break;
} }
} }
if (j == MAXSPRITES) if (!found)
{ {
I_Error("Found lonely Sector Effector (lotag 0) at (%d,%d)\n", sp->x, sp->y); I_Error("Found lonely Sector Effector (lotag 0) at (%d,%d)\n", sp->x, sp->y);
} }
sp->owner = j;
} }
startwall = sector[sect].wallptr; startwall = sector[sect].wallptr;
@ -1013,9 +1019,9 @@ void spawneffector(int i)
sp->extra = 0; sp->extra = 0;
else sp->extra = 1; else sp->extra = 1;
sector[sect].hitag = i; // hijack sector[sect].hitag = actor->GetIndex(); // hijack
j = 0; int j = 0;
for (s = startwall; s < endwall; s++) for (s = startwall; s < endwall; s++)
{ {
@ -1066,14 +1072,16 @@ void spawneffector(int i)
{ {
case SE_6_SUBWAY: case SE_6_SUBWAY:
case SE_14_SUBWAY_CAR: case SE_14_SUBWAY_CAR:
j = callsound(sect, i); {
int j = callsound(sect, actor);
if (j == -1) if (j == -1)
{ {
if (!isRR()) j = SUBWAY; // Duke if (!isRR()) j = SUBWAY; // Duke
else if (sector[sp->sectnum].floorpal == 7) j = 456; else if (sector[sp->sectnum].floorpal == 7) j = 456;
else j = 75; else j = 75;
} }
hittype[i].lastvx = j; actor->lastvx = j;
}
case SE_30_TWO_WAY_TRAIN: case SE_30_TWO_WAY_TRAIN:
if (numplayers > 1) break; if (numplayers > 1) break;
case SE_0_ROTATING_SECTOR: case SE_0_ROTATING_SECTOR:
@ -1083,15 +1091,15 @@ void spawneffector(int i)
case SE_15_SLIDING_DOOR: case SE_15_SLIDING_DOOR:
case SE_16_REACTOR: case SE_16_REACTOR:
case SE_26: case SE_26:
setsectinterpolate(sprite[i].sectnum); setsectinterpolate(actor->s.sectnum);
break; break;
} }
if ((!isRR() && sprite[i].lotag >= 40 && sprite[i].lotag <= 45) || if ((!isRR() && actor->s.lotag >= 40 && actor->s.lotag <= 45) ||
(isRRRA() && sprite[i].lotag >= 150 && sprite[i].lotag <= 155)) (isRRRA() && actor->s.lotag >= 150 && actor->s.lotag <= 155))
changespritestat(i, STAT_RAROR); changespritestat(actor, STAT_RAROR);
else else
changespritestat(i, STAT_EFFECTOR); changespritestat(actor, STAT_EFFECTOR);
} }

View file

@ -1094,11 +1094,11 @@ int spawn_d(int j, int pn)
ssp(i,CLIPMASK0); ssp(i,CLIPMASK0);
} }
case CEILINGSTEAM: case CEILINGSTEAM:
changespritestat(i,6); changespritestat(i,STAT_STANDABLE);
break; break;
case SECTOREFFECTOR: case SECTOREFFECTOR:
spawneffector(i); spawneffector(act);
break; break;

View file

@ -1358,11 +1358,10 @@ int spawn_r(int j, int pn)
ssp(i,CLIPMASK0); ssp(i,CLIPMASK0);
} }
case CEILINGSTEAM: case CEILINGSTEAM:
changespritestat(i,6); changespritestat(i,STAT_STANDABLE);
break; break;
case SECTOREFFECTOR: case SECTOREFFECTOR:
spawneffector(i); spawneffector(act);
break; break;
case SEENINE: case SEENINE: