- moveactors.

This commit is contained in:
Christoph Oelckers 2020-10-22 22:48:51 +02:00
parent 2ad31247ec
commit 76c4eeddc4
2 changed files with 113 additions and 121 deletions

View file

@ -3058,36 +3058,34 @@ DETONATEB:
void moveactors_d(void) void moveactors_d(void)
{ {
int x, * t; int x;
short j, sect, p; int sect, p;
spritetype* s; unsigned int k;
unsigned short k; Collision coll;
StatIterator it(STAT_ACTOR); DukeStatIterator it(STAT_ACTOR);
int i; while (auto act = it.Next())
while ((i = it.NextIndex()) >= 0)
{ {
s = &sprite[i]; auto s = &act->s;
sect = s->sectnum; sect = s->sectnum;
if (s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS) if (s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
t = &hittype[i].temp_data[0]; int *t = &act->temp_data[0];
hittype[i].bposx = s->x; act->bposx = s->x;
hittype[i].bposy = s->y; act->bposy = s->y;
hittype[i].bposz = s->z; act->bposz = s->z;
switch (s->picnum) switch (s->picnum)
{ {
case FLAMETHROWERFLAME: case FLAMETHROWERFLAME:
if (isWorldTour()) flamethrowerflame(&hittype[i]); if (isWorldTour()) flamethrowerflame(act);
continue; continue;
case DUCK: case DUCK:
@ -3104,22 +3102,20 @@ void moveactors_d(void)
} }
else else
{ {
j = fi.ifhitbyweapon(&hittype[i]); int j = fi.ifhitbyweapon(act);
if (j >= 0) if (j >= 0)
{ {
s->cstat = 32 + 128; s->cstat = 32 + 128;
k = 1; k = 1;
StatIterator it(STAT_ACTOR); DukeStatIterator it(STAT_ACTOR);
int j; while (auto act2 = it.Next())
while ((j = it.NextIndex()) >= 0)
{ {
auto sj = &sprite[j]; if (act2->s.lotag == s->lotag &&
if (sj->lotag == s->lotag && act2->s.picnum == s->picnum)
sj->picnum == s->picnum)
{ {
if ((sj->hitag && !(sj->cstat & 32)) || if ((act2->s.hitag && !(act2->s.cstat & 32)) ||
(!sj->hitag && (sj->cstat & 32)) (!act2->s.hitag && (act2->s.cstat & 32))
) )
{ {
k = 0; k = 0;
@ -3131,7 +3127,7 @@ void moveactors_d(void)
if (k == 1) if (k == 1)
{ {
operateactivators(s->lotag, -1); operateactivators(s->lotag, -1);
fi.operateforcefields(i, s->lotag); fi.operateforcefields(act->GetIndex(), s->lotag);
operatemasterswitches(s->lotag); operatemasterswitches(s->lotag);
} }
} }
@ -3141,7 +3137,7 @@ void moveactors_d(void)
case RESPAWNMARKERRED: case RESPAWNMARKERRED:
case RESPAWNMARKERYELLOW: case RESPAWNMARKERYELLOW:
case RESPAWNMARKERGREEN: case RESPAWNMARKERGREEN:
if (!respawnmarker(&hittype[i], RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue; if (!respawnmarker(act, RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue;
break; break;
case HELECOPT: case HELECOPT:
@ -3150,39 +3146,39 @@ void moveactors_d(void)
s->z += s->zvel; s->z += s->zvel;
t[0]++; t[0]++;
if (t[0] == 4) S_PlayActorSound(WAR_AMBIENCE2, i); if (t[0] == 4) S_PlayActorSound(WAR_AMBIENCE2, act);
if (t[0] > (26 * 8)) if (t[0] > (26 * 8))
{ {
S_PlaySound(RPG_EXPLODE); S_PlaySound(RPG_EXPLODE);
for (j = 0; j < 32; j++) for (int j = 0; j < 32; j++)
RANDOMSCRAP(s, i); RANDOMSCRAP(act);
earthquaketime = 16; earthquaketime = 16;
deletesprite(i); deletesprite(act);
continue; continue;
} }
else if ((t[0] & 3) == 0) else if ((t[0] & 3) == 0)
fi.spawn(i, EXPLOSION2); spawn(act, EXPLOSION2);
ssp(i, CLIPMASK0); ssp(act, CLIPMASK0);
break; break;
case RAT: case RAT:
if (!rat(&hittype[i], true)) continue; if (!rat(act, true)) continue;
break; break;
case QUEBALL: case QUEBALL:
case STRIPEBALL: case STRIPEBALL:
if (!queball(&hittype[i], POCKET, QUEBALL, STRIPEBALL)) continue; if (!queball(act, POCKET, QUEBALL, STRIPEBALL)) continue;
break; break;
case FORCESPHERE: case FORCESPHERE:
forcesphere(&hittype[i], FORCESPHERE); forcesphere(act, FORCESPHERE);
continue; continue;
case RECON: case RECON:
recon(&hittype[i], EXPLOSION2, FIRELASER, RECO_ATTACK, RECO_PAIN, RECO_ROAM, 10, [](DDukeActor* i)->int { return PIGCOP; }); recon(act, EXPLOSION2, FIRELASER, RECO_ATTACK, RECO_PAIN, RECO_ROAM, 10, [](DDukeActor* i)->int { return PIGCOP; });
continue; continue;
case OOZ: case OOZ:
case OOZ2: case OOZ2:
ooz(&hittype[i]); ooz(act);
continue; continue;
case GREENSLIME: case GREENSLIME:
@ -3193,16 +3189,15 @@ void moveactors_d(void)
case GREENSLIME + 5: case GREENSLIME + 5:
case GREENSLIME + 6: case GREENSLIME + 6:
case GREENSLIME + 7: case GREENSLIME + 7:
greenslime(&hittype[i]); greenslime(act);
continue; continue;
case BOUNCEMINE: case BOUNCEMINE:
case MORTER: case MORTER:
j = fi.spawn(i, FRAMEEFFECT1); spawn(act, FRAMEEFFECT1)->temp_data[0] = 3;
hittype[j].temp_data[0] = 3;
case HEAVYHBOMB: case HEAVYHBOMB:
heavyhbomb(&hittype[i]); heavyhbomb(act);
continue; continue;
case REACTORBURNT: case REACTORBURNT:
@ -3211,17 +3206,17 @@ void moveactors_d(void)
case REACTOR: case REACTOR:
case REACTOR2: case REACTOR2:
reactor(&hittype[i], REACTOR, REACTOR2, REACTORBURNT, REACTOR2BURNT, REACTORSPARK, REACTOR2SPARK); reactor(act, REACTOR, REACTOR2, REACTORBURNT, REACTOR2BURNT, REACTORSPARK, REACTOR2SPARK);
continue; continue;
case CAMERA1: case CAMERA1:
camera(&hittype[i]); camera(act);
continue; continue;
} }
// #ifndef VOLOMEONE // #ifndef VOLOMEONE
if (ud.multimode < 2 && badguy(s)) if (ud.multimode < 2 && badguy(act))
{ {
if (actor_tog == 1) if (actor_tog == 1)
{ {
@ -3232,9 +3227,9 @@ void moveactors_d(void)
} }
// #endif // #endif
p = findplayer(s, &x); p = findplayer(&act->s, &x);
execute(i, p, x); execute(act, p, x);
} }
} }

View file

@ -2860,8 +2860,8 @@ static int henstand(DDukeActor *actor)
void moveactors_r(void) void moveactors_r(void)
{ {
int x; int x;
int j, sect, p; int p;
spritetype *s; Collision coll;
dojaildoor(); dojaildoor();
moveminecart(); moveminecart();
@ -2872,27 +2872,24 @@ void moveactors_r(void)
} }
rr_specialstats(); rr_specialstats();
StatIterator it(STAT_ACTOR); DukeStatIterator it(STAT_ACTOR);
int i; while (auto act = it.Next())
while ((i = it.NextIndex()) >= 0)
{ {
auto s = &act->s;
bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites. bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites.
auto sect = s->sectnum;
s = &sprite[i];
sect = s->sectnum;
if( s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS) if( s->xrepeat == 0 || sect < 0 || sect >= MAXSECTORS)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
auto t = &hittype[i].temp_data[0]; auto t = &act->temp_data[0];
hittype[i].bposx = s->x; act->bposx = s->x;
hittype[i].bposy = s->y; act->bposy = s->y;
hittype[i].bposz = s->z; act->bposz = s->z;
switch(s->picnum) switch(s->picnum)
@ -2900,48 +2897,48 @@ void moveactors_r(void)
case RESPAWNMARKERRED: case RESPAWNMARKERRED:
case RESPAWNMARKERYELLOW: case RESPAWNMARKERYELLOW:
case RESPAWNMARKERGREEN: case RESPAWNMARKERGREEN:
if (!respawnmarker(&hittype[i], RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue; if (!respawnmarker(act, RESPAWNMARKERYELLOW, RESPAWNMARKERGREEN)) continue;
break; break;
case RAT: case RAT:
if (!rat(&hittype[i], !isRRRA())) continue; if (!rat(act, !isRRRA())) continue;
break; break;
case RRTILE3190: case RRTILE3190:
case RRTILE3191: case RRTILE3191:
case RRTILE3192: case RRTILE3192:
if (!chickenplant) if (!chickenplant)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
if (sector[sprite[i].sectnum].lotag == 903) if (sector[sect].lotag == 903)
makeitfall(i); makeitfall(act);
j = fi.movesprite(i, movesprite_ex(act,
(s->xvel*sintable[(s->ang+512)&2047])>>14, (s->xvel*sintable[(s->ang+512)&2047])>>14,
(s->xvel*sintable[s->ang&2047])>>14, (s->xvel*sintable[s->ang&2047])>>14,
s->zvel,CLIPMASK0); s->zvel,CLIPMASK0, coll);
switch (sector[sprite[i].sectnum].lotag) switch (sector[sect].lotag)
{ {
case 901: case 901:
sprite[i].picnum = RRTILE3191; s->picnum = RRTILE3191;
break; break;
case 902: case 902:
sprite[i].picnum = RRTILE3192; s->picnum = RRTILE3192;
break; break;
case 903: case 903:
if (sprite[i].z >= sector[sprite[i].sectnum].floorz - (8<<8)) if (s->z >= sector[sect].floorz - (8<<8))
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
break; break;
case 904: case 904:
deletesprite(i); deletesprite(act);
continue; continue;
break; break;
} }
if ((j & 32768) == 32768) if (coll.type > kHitSector)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
break; break;
@ -2950,55 +2947,55 @@ void moveactors_r(void)
case RRTILE3122: case RRTILE3122:
case RRTILE3123: case RRTILE3123:
case RRTILE3124: case RRTILE3124:
if (!chickenplant) if (!chickenplant)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
makeitfall(i); makeitfall(act);
j = fi.movesprite(i, movesprite_ex(act,
(s->xvel*(sintable[(s->ang+512)&2047]))>>14, (s->xvel*(sintable[(s->ang+512)&2047]))>>14,
(s->xvel*(sintable[s->ang&2047]))>>14, (s->xvel*(sintable[s->ang&2047]))>>14,
s->zvel,CLIPMASK0); s->zvel,CLIPMASK0, coll);
if ((j & 32768) == 32768) if (coll.type > kHitSector)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
if (sector[s->sectnum].lotag == 903) if (sector[sect].lotag == 903)
{ {
if (sprite[i].z >= sector[sprite[i].sectnum].floorz - (4<<8)) if (s->z >= sector[sect].floorz - (4<<8))
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
} }
else if (sector[s->sectnum].lotag == 904) else if (sector[sect].lotag == 904)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
break; break;
case RRTILE3132: case RRTILE3132:
if (!chickenplant) if (!chickenplant)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
makeitfall(i); makeitfall(act);
j = fi.movesprite(i, movesprite_ex(act,
(s->xvel*sintable[(s->ang+512)&2047])>>14, (s->xvel*sintable[(s->ang+512)&2047])>>14,
(s->xvel*sintable[s->ang&2047])>>14, (s->xvel*sintable[s->ang&2047])>>14,
s->zvel,CLIPMASK0); s->zvel,CLIPMASK0, coll);
if (s->z >= sector[s->sectnum].floorz - (8<<8)) if (s->z >= sector[sect].floorz - (8<<8))
{ {
if (sector[s->sectnum].lotag == 1) if (sector[sect].lotag == 1)
{ {
j = fi.spawn(i,WATERSPLASH2); auto j = spawn(act, WATERSPLASH2);
sprite[j].z = sector[sprite[j].sectnum].floorz; j->s.z = sector[j->s.sectnum].floorz;
} }
deletesprite(i); deletesprite(act);
continue; continue;
} }
break; break;
@ -3006,12 +3003,12 @@ void moveactors_r(void)
if (s->xvel) if (s->xvel)
{ {
if(!S_CheckSoundPlaying(356)) if(!S_CheckSoundPlaying(356))
S_PlayActorSound(356,i); S_PlayActorSound(356,act);
} }
else else
{ {
fi.spawn(i,BOWLINGBALLSPRITE); spawn(act,BOWLINGBALLSPRITE);
deletesprite(i); deletesprite(act);
continue; continue;
} }
if (sector[s->sectnum].lotag == 900) if (sector[s->sectnum].lotag == 900)
@ -3023,7 +3020,7 @@ void moveactors_r(void)
case HENSTAND: case HENSTAND:
case HENSTAND+1: case HENSTAND+1:
{ {
int todo = henstand(&hittype[i]); int todo = henstand(act);
if (todo == 2) deleteafterexecute = true; if (todo == 2) deleteafterexecute = true;
if (todo == 1) continue; if (todo == 1) continue;
break; break;
@ -3031,10 +3028,10 @@ void moveactors_r(void)
case QUEBALL: case QUEBALL:
case STRIPEBALL: case STRIPEBALL:
if (!queball(&hittype[i], POCKET, QUEBALL, STRIPEBALL)) continue; if (!queball(act, POCKET, QUEBALL, STRIPEBALL)) continue;
break; break;
case FORCESPHERE: case FORCESPHERE:
forcesphere(&hittype[i], FORCESPHERE); forcesphere(act, FORCESPHERE);
continue; continue;
case RECON: case RECON:
@ -3043,9 +3040,9 @@ void moveactors_r(void)
case UFO3: case UFO3:
case UFO4: case UFO4:
case UFO5: case UFO5:
recon(&hittype[i], EXPLOSION2, FIRELASER, -1, -1, 457, 8, [](DDukeActor* i) ->int recon(act, EXPLOSION2, FIRELASER, -1, -1, 457, 8, [](DDukeActor* act) ->int
{ {
auto s = &i->s; auto s = &act->s;
if (isRRRA() && ufospawnsminion) if (isRRRA() && ufospawnsminion)
return MINION; return MINION;
else if (s->picnum == UFO1_RR) else if (s->picnum == UFO1_RR)
@ -3063,33 +3060,33 @@ void moveactors_r(void)
continue; continue;
case OOZ: case OOZ:
ooz(&hittype[i]); ooz(act);
continue; continue;
case EMPTYBIKE: case EMPTYBIKE:
if (!isRRRA()) break; if (!isRRRA()) break;
makeitfall(i); makeitfall(act);
getglobalz(i); getglobalz(act);
if (sector[sect].lotag == 1) if (sector[sect].lotag == 1)
{ {
setsprite(i,s->x,s->y,hittype[i].floorz+(16<<8)); setsprite(act,s->x,s->y,act->floorz+(16<<8));
} }
break; break;
case EMPTYBOAT: case EMPTYBOAT:
if (!isRRRA()) break; if (!isRRRA()) break;
makeitfall(i); makeitfall(act);
getglobalz(i); getglobalz(act);
break; break;
case TRIPBOMBSPRITE: case TRIPBOMBSPRITE:
if (!isRRRA() || (sector[sect].lotag != 1 && sector[sect].lotag != 160)) if (!isRRRA() || (sector[sect].lotag != 1 && sector[sect].lotag != 160))
if (s->xvel) if (s->xvel)
{ {
j = fi.movesprite(i, movesprite_ex(act,
(s->xvel*sintable[(s->ang+512)&2047])>>14, (s->xvel*sintable[(s->ang+512)&2047])>>14,
(s->xvel*sintable[s->ang&2047])>>14, (s->xvel*sintable[s->ang&2047])>>14,
s->zvel,CLIPMASK0); s->zvel,CLIPMASK0, coll);
s->xvel--; s->xvel--;
} }
break; break;
@ -3098,7 +3095,7 @@ void moveactors_r(void)
if (!isRRRA()) break; if (!isRRRA()) break;
case MORTER: case MORTER:
case HEAVYHBOMB: case HEAVYHBOMB:
heavyhbomb(&hittype[i]); heavyhbomb(act);
continue; continue;
case REACTORBURNT: case REACTORBURNT:
@ -3107,17 +3104,17 @@ void moveactors_r(void)
case REACTOR: case REACTOR:
case REACTOR2: case REACTOR2:
reactor(&hittype[i], REACTOR, REACTOR2, REACTORBURNT, REACTOR2BURNT, REACTORSPARK, REACTOR2SPARK); reactor(act, REACTOR, REACTOR2, REACTORBURNT, REACTOR2BURNT, REACTORSPARK, REACTOR2SPARK);
continue; continue;
case CAMERA1: case CAMERA1:
camera(&hittype[i]); camera(act);
continue; continue;
} }
// #ifndef VOLOMEONE // #ifndef VOLOMEONE
if( ud.multimode < 2 && badguy(s) ) if( ud.multimode < 2 && badguy(act) )
{ {
if( actor_tog == 1) if( actor_tog == 1)
{ {
@ -3128,10 +3125,10 @@ void moveactors_r(void)
} }
// #endif // #endif
p = findplayer(s,&x); p = findplayer(&act->s,&x);
execute(i,p,x); execute(act,p,x);
if (deleteafterexecute) deletesprite(i); if (deleteafterexecute) deletesprite(act);
} }
} }