- moveexplosions.

This commit is contained in:
Christoph Oelckers 2020-10-22 22:51:51 +02:00
parent 76c4eeddc4
commit f5338d0acb
3 changed files with 82 additions and 88 deletions

View file

@ -3061,7 +3061,6 @@ void moveactors_d(void)
int x; int x;
int sect, p; int sect, p;
unsigned int k; unsigned int k;
Collision coll;
DukeStatIterator it(STAT_ACTOR); DukeStatIterator it(STAT_ACTOR);
while (auto act = it.Next()) while (auto act = it.Next())
@ -3240,27 +3239,26 @@ void moveactors_d(void)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void fireflyflyingeffect(int i) static void fireflyflyingeffect(DDukeActor *actor)
{ {
spritetype* s = &sprite[i]; auto t = &actor->temp_data[0];
auto t = &hittype[i].temp_data[0]; int x, p = findplayer(&actor->s, &x);
int x, p = findplayer(s, &x); execute(actor, p, x);
execute(i, p, x);
auto owner = &sprite[s->owner]; auto Owner = actor->GetOwner();
if (owner->picnum != FIREFLY) if (!Owner || Owner->s.picnum != FIREFLY)
{ {
deletesprite(i); deletesprite(actor);
return; return;
} }
if (owner->xrepeat >= 24 || owner->pal == 1) if (Owner->s.xrepeat >= 24 || Owner->s.pal == 1)
s->cstat |= 0x8000; actor->s.cstat |= 0x8000;
else else
s->cstat &= ~0x8000; actor->s.cstat &= ~0x8000;
double dx = owner->x - sprite[ps[p].i].x; double dx = Owner->s.x - ps[p].GetActor()->s.x;
double dy = owner->y - sprite[ps[p].i].y; double dy = Owner->s.y - ps[p].GetActor()->s.y;
double dist = sqrt(dx * dx + dy * dy); double dist = sqrt(dx * dx + dy * dy);
if (dist != 0.0) if (dist != 0.0)
{ {
@ -3268,13 +3266,13 @@ static void fireflyflyingeffect(int i)
dy /= dist; dy /= dist;
} }
s->x = (int) (owner->x - (dx * -10.0)); actor->s.x = (int) (Owner->s.x - (dx * -10.0));
s->y = (int) (owner->y - (dy * -10.0)); actor->s.y = (int) (Owner->s.y - (dy * -10.0));
s->z = owner->z + 2048; actor->s.z = Owner->s.z + 2048;
if (owner->extra <= 0) if (Owner->s.extra <= 0)
{ {
deletesprite(i); deletesprite(actor);
} }
} }
@ -3287,32 +3285,29 @@ static void fireflyflyingeffect(int i)
void moveexplosions_d(void) // STATNUM 5 void moveexplosions_d(void) // STATNUM 5
{ {
int sect, p; int sect, p;
int x, * t; int x;
spritetype* s;
StatIterator it(STAT_MISC); DukeStatIterator it(STAT_MISC);
int i; while (auto act = it.Next())
while ((i = it.NextIndex()) >= 0)
{ {
t = &hittype[i].temp_data[0]; auto s = &act->s;
s = &sprite[i]; int* t = &act->temp_data[0];
sect = s->sectnum; sect = s->sectnum;
if (sect < 0 || s->xrepeat == 0) if (sect < 0 || s->xrepeat == 0)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
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 FIREFLYFLYINGEFFECT: case FIREFLYFLYINGEFFECT:
if (isWorldTour()) fireflyflyingeffect(i); if (isWorldTour()) fireflyflyingeffect(act);
continue; continue;
case NEON1: case NEON1:
@ -3345,35 +3340,36 @@ void moveexplosions_d(void) // STATNUM 5
if (t[0]) if (t[0])
{ {
t[0]++; t[0]++;
auto Owner = act->GetOwner();
if (t[0] == 8) s->picnum = NUKEBUTTON + 1; if (t[0] == 8) s->picnum = NUKEBUTTON + 1;
else if (t[0] == 16) else if (t[0] == 16 && Owner)
{ {
s->picnum = NUKEBUTTON + 2; s->picnum = NUKEBUTTON + 2;
ps[sprite[s->owner].yvel].fist_incs = 1; ps[Owner->PlayerIndex()].fist_incs = 1;
} }
if (ps[sprite[s->owner].yvel].fist_incs == 26) if (Owner && ps[Owner->PlayerIndex()].fist_incs == 26)
s->picnum = NUKEBUTTON + 3; s->picnum = NUKEBUTTON + 3;
} }
continue; continue;
case FORCESPHERE: case FORCESPHERE:
forcesphereexplode(&hittype[i]); forcesphereexplode(act);
continue; continue;
case WATERSPLASH2: case WATERSPLASH2:
watersplash2(&hittype[i]); watersplash2(act);
continue; continue;
case FRAMEEFFECT1: case FRAMEEFFECT1:
frameeffect1(&hittype[i]); frameeffect1(act);
continue; continue;
case INNERJAW: case INNERJAW:
case INNERJAW + 1: case INNERJAW + 1:
p = findplayer(s, &x); p = findplayer(&act->s, &x);
if (x < 512) if (x < 512)
{ {
SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0)); SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0));
sprite[ps[p].i].extra -= 4; ps[p].GetActor()->s.extra -= 4;
} }
case FIRELASER: case FIRELASER:
@ -3381,23 +3377,22 @@ void moveexplosions_d(void) // STATNUM 5
s->extra = 999; s->extra = 999;
else else
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
break; break;
case TONGUE: case TONGUE:
deletesprite(i); deletesprite(act);
continue; continue;
case MONEY + 1: case MONEY + 1:
case MAIL + 1: case MAIL + 1:
case PAPER + 1: case PAPER + 1:
hittype[i].floorz = s->z = getflorzofslope(s->sectnum, s->x, s->y); act->floorz = s->z = getflorzofslope(s->sectnum, s->x, s->y);
break; break;
case MONEY: case MONEY:
case MAIL: case MAIL:
case PAPER: case PAPER:
money(&hittype[i], BLOODPOOL); money(act, BLOODPOOL);
break; break;
case JIBS1: case JIBS1:
@ -3415,12 +3410,12 @@ void moveexplosions_d(void) // STATNUM 5
case DUKETORSO: case DUKETORSO:
case DUKEGUN: case DUKEGUN:
case DUKELEG: case DUKELEG:
jibs(&hittype[i], JIBS6, true, false, false, s->picnum == DUKELEG || s->picnum == DUKETORSO || s->picnum == DUKEGUN, false); jibs(act, JIBS6, true, false, false, s->picnum == DUKELEG || s->picnum == DUKETORSO || s->picnum == DUKEGUN, false);
continue; continue;
case BLOODPOOL: case BLOODPOOL:
case PUKE: case PUKE:
bloodpool(&hittype[i], s->picnum == PUKE, TIRE); bloodpool(act, s->picnum == PUKE, TIRE);
continue; continue;
@ -3446,25 +3441,25 @@ void moveexplosions_d(void) // STATNUM 5
case FORCERIPPLE: case FORCERIPPLE:
case TRANSPORTERSTAR: case TRANSPORTERSTAR:
case TRANSPORTERBEAM: case TRANSPORTERBEAM:
p = findplayer(s, &x); p = findplayer(&act->s, &x);
execute(i, p, x); execute(act, p, x);
continue; continue;
case SHELL: case SHELL:
case SHOTGUNSHELL: case SHOTGUNSHELL:
shell(&hittype[i], (sector[sect].floorz + (24 << 8)) < s->z); shell(act, (sector[sect].floorz + (24 << 8)) < s->z);
continue; continue;
case GLASSPIECES: case GLASSPIECES:
case GLASSPIECES + 1: case GLASSPIECES + 1:
case GLASSPIECES + 2: case GLASSPIECES + 2:
glasspieces(&hittype[i]); glasspieces(act);
continue; continue;
} }
if (s->picnum >= SCRAP6 && s->picnum <= SCRAP5 + 3) if (s->picnum >= SCRAP6 && s->picnum <= SCRAP5 + 3)
{ {
scrap(&hittype[i], SCRAP1, SCRAP6); scrap(act, SCRAP1, SCRAP6);
} }
} }
} }

View file

@ -3143,26 +3143,24 @@ void moveexplosions_r(void) // STATNUM 5
{ {
int sect, p; int sect, p;
int x, * t; int x, * t;
spritetype* s;
StatIterator it(STAT_MISC); DukeStatIterator it(STAT_MISC);
int i; while (auto act = it.Next())
while ((i = it.NextIndex()) >= 0)
{ {
t = &hittype[i].temp_data[0]; auto s = &act->s;
s = &sprite[i]; t = &act->temp_data[0];
sect = s->sectnum; sect = s->sectnum;
if (sect < 0 || s->xrepeat == 0) if (sect < 0 || s->xrepeat == 0)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
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)
{ {
@ -3170,7 +3168,7 @@ void moveexplosions_r(void) // STATNUM 5
if (sector[s->sectnum].lotag == 800) if (sector[s->sectnum].lotag == 800)
if (s->z >= sector[s->sectnum].floorz - (8 << 8)) if (s->z >= sector[s->sectnum].floorz - (8 << 8))
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
break; break;
@ -3198,7 +3196,7 @@ void moveexplosions_r(void) // STATNUM 5
case FORCESPHERE: case FORCESPHERE:
forcesphereexplode(&hittype[i]); forcesphereexplode(act);
continue; continue;
case MUD: case MUD:
@ -3208,11 +3206,11 @@ void moveexplosions_r(void) // STATNUM 5
{ {
if (sector[sect].floorpicnum != 3073) if (sector[sect].floorpicnum != 3073)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
if (S_CheckSoundPlaying(22)) if (S_CheckSoundPlaying(22))
S_PlayActorSound(22, i); S_PlayActorSound(22, act);
} }
if (t[0] == 3) if (t[0] == 3)
{ {
@ -3220,24 +3218,24 @@ void moveexplosions_r(void) // STATNUM 5
t[1]++; t[1]++;
} }
if (t[1] == 5) if (t[1] == 5)
deletesprite(i); deletesprite(act);
continue; continue;
case WATERSPLASH2: case WATERSPLASH2:
watersplash2(&hittype[i]); watersplash2(act);
continue; continue;
case FRAMEEFFECT1: case FRAMEEFFECT1:
frameeffect1(&hittype[i]); frameeffect1(act);
continue; continue;
case INNERJAW: case INNERJAW:
case INNERJAW + 1: case INNERJAW + 1:
p = findplayer(s, &x); p = findplayer(&act->s, &x);
if (x < 512) if (x < 512)
{ {
SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0)); SetPlayerPal(&ps[p], PalEntry(32, 32, 0, 0));
sprite[ps[p].i].extra -= 4; ps[p].GetActor()->s.extra -= 4;
} }
case COOLEXPLOSION1: case COOLEXPLOSION1:
@ -3248,28 +3246,28 @@ void moveexplosions_r(void) // STATNUM 5
s->extra = 999; s->extra = 999;
else else
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
break; break;
case TONGUE: case TONGUE:
deletesprite(i); deletesprite(act);
continue; continue;
case MONEY + 1: case FEATHER + 1: // feather
hittype[i].floorz = s->z = getflorzofslope(s->sectnum, s->x, s->y); act->floorz = s->z = getflorzofslope(s->sectnum, s->x, s->y);
if (sector[s->sectnum].lotag == 800) if (sector[s->sectnum].lotag == 800)
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
break; break;
case MONEY: case FEATHER:
if (!money(&hittype[i], BLOODPOOL)) continue; if (!money(act, BLOODPOOL)) continue;
if (sector[s->sectnum].lotag == 800) if (sector[s->sectnum].lotag == 800)
if (s->z >= sector[s->sectnum].floorz - (8 << 8)) if (s->z >= sector[s->sectnum].floorz - (8 << 8))
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
@ -3317,25 +3315,25 @@ void moveexplosions_r(void) // STATNUM 5
case DUKETORSO: case DUKETORSO:
case DUKEGUN: case DUKEGUN:
case DUKELEG: case DUKELEG:
if (!jibs(&hittype[i], JIBS6, false, true, true, s->picnum == DUKELEG || s->picnum == DUKETORSO || s->picnum == DUKEGUN, if (!jibs(act, JIBS6, false, true, true, s->picnum == DUKELEG || s->picnum == DUKETORSO || s->picnum == DUKEGUN,
isRRRA() && (s->picnum == RRTILE2465 || s->picnum == RRTILE2560))) continue; isRRRA() && (s->picnum == RRTILE2465 || s->picnum == RRTILE2560))) continue;
if (sector[s->sectnum].lotag == 800) if (sector[s->sectnum].lotag == 800)
if (s->z >= sector[s->sectnum].floorz - (8 << 8)) if (s->z >= sector[s->sectnum].floorz - (8 << 8))
{ {
deletesprite(i); deletesprite(act);
continue; continue;
} }
continue; continue;
case BLOODPOOL: case BLOODPOOL:
if (!bloodpool(&hittype[i], false, TIRE)) continue; if (!bloodpool(act, false, TIRE)) continue;
if (sector[s->sectnum].lotag == 800) if (sector[s->sectnum].lotag == 800)
if (s->z >= sector[s->sectnum].floorz - (8 << 8)) if (s->z >= sector[s->sectnum].floorz - (8 << 8))
{ {
deletesprite(i); deletesprite(act);
} }
continue; continue;
@ -3348,26 +3346,26 @@ void moveexplosions_r(void) // STATNUM 5
case FORCERIPPLE: case FORCERIPPLE:
case TRANSPORTERSTAR: case TRANSPORTERSTAR:
case TRANSPORTERBEAM: case TRANSPORTERBEAM:
p = findplayer(s, &x); p = findplayer(&act->s, &x);
execute(i, p, x); execute(act, p, x);
continue; continue;
case SHELL: case SHELL:
case SHOTGUNSHELL: case SHOTGUNSHELL:
shell(&hittype[i], false); shell(act, false);
continue; continue;
case GLASSPIECES: case GLASSPIECES:
case GLASSPIECES + 1: case GLASSPIECES + 1:
case GLASSPIECES + 2: case GLASSPIECES + 2:
case POPCORN: case POPCORN:
glasspieces(&hittype[i]); glasspieces(act);
continue; continue;
} }
if (s->picnum >= SCRAP6 && s->picnum <= SCRAP5 + 3) if (s->picnum >= SCRAP6 && s->picnum <= SCRAP5 + 3)
{ {
scrap(&hittype[i], SCRAP1, SCRAP6); scrap(act, SCRAP1, SCRAP6);
} }
} }
} }

View file

@ -387,6 +387,7 @@ x(NUKEBARRELDENTED, 1305)
x(NUKEBARRELLEAKED, 1306) x(NUKEBARRELLEAKED, 1306)
x(CANWITHSOMETHING, 1309) x(CANWITHSOMETHING, 1309)
x(MONEY, 1310) x(MONEY, 1310)
x(FEATHER, 1310)
x(BANNER, 1313) x(BANNER, 1313)
x(EXPLODINGBARREL, 1315) x(EXPLODINGBARREL, 1315)
x(EXPLODINGBARREL2, 1316) x(EXPLODINGBARREL2, 1316)