- DoExpDamageTest + DoMineExpMine

This commit is contained in:
Christoph Oelckers 2021-11-05 22:14:05 +01:00
parent 15e7e784c5
commit ddd6f881f0

View file

@ -7538,8 +7538,7 @@ void TraverseBreakableWalls(short start_sect, int x, int y, int z, short ang, in
int DoExpDamageTest(DSWActor* actor) int DoExpDamageTest(DSWActor* actor)
{ {
auto wu = actor->u(); auto wu = actor->u();
int Weapon = wu->SpriteNum; SPRITEp wp = &actor->s();
SPRITEp wp = &sprite[Weapon];
USERp u; USERp u;
SPRITEp sp; SPRITEp sp;
@ -7549,7 +7548,7 @@ int DoExpDamageTest(DSWActor* actor)
int max_stat; int max_stat;
short break_count; short break_count;
SPRITEp found_sp = nullptr; DSWActor* found_act = nullptr;
int found_dist = 999999; int found_dist = 999999;
int DoWallMoveMatch(short match); int DoWallMoveMatch(short match);
@ -7566,11 +7565,11 @@ int DoExpDamageTest(DSWActor* actor)
for (stat = 0; stat < max_stat; stat++) for (stat = 0; stat < max_stat; stat++)
{ {
StatIterator it(StatDamageList[stat]); SWStatIterator it(StatDamageList[stat]);
while ((i = it.NextIndex()) >= 0) while (auto itActor = it.Next())
{ {
sp = &sprite[i]; sp = &itActor->s();
u = User[i].Data(); u = itActor->u();
DISTANCE(sp->x, sp->y, wp->x, wp->y, dist, tx, ty, tmin); DISTANCE(sp->x, sp->y, wp->x, wp->y, dist, tx, ty, tmin);
@ -7582,7 +7581,7 @@ int DoExpDamageTest(DSWActor* actor)
if (StatDamageList[stat] == STAT_SO_SP_CHILD) if (StatDamageList[stat] == STAT_SO_SP_CHILD)
{ {
DoDamage(i, Weapon); DoDamage(itActor->GetSpriteIndex(), actor->GetSpriteIndex());
} }
else else
{ {
@ -7599,7 +7598,7 @@ int DoExpDamageTest(DSWActor* actor)
!FAFcansee(wp->x, wp->y, wp->z, wp->sectnum, sp->x, sp->y, SPRITEp_LOWER(sp), sp->sectnum)) !FAFcansee(wp->x, wp->y, wp->z, wp->sectnum, sp->x, sp->y, SPRITEp_LOWER(sp), sp->sectnum))
continue; continue;
DoDamage(i, Weapon); DoDamage(itActor->GetSpriteIndex(), actor->GetSpriteIndex());
} }
} }
} }
@ -7645,10 +7644,10 @@ int DoExpDamageTest(DSWActor* actor)
return 0; return 0;
// wall damaging // wall damaging
StatIterator it(STAT_WALL_MOVE); SWStatIterator it(STAT_WALL_MOVE);
while ((i = it.NextIndex()) >= 0) while (auto itActor = it.Next())
{ {
sp = &sprite[i]; sp = &itActor->s();
DISTANCE(sp->x, sp->y, wp->x, wp->y, dist, tx, ty, tmin); DISTANCE(sp->x, sp->y, wp->x, wp->y, dist, tx, ty, tmin);
if ((unsigned)dist > wu->Radius/4) if ((unsigned)dist > wu->Radius/4)
@ -7663,18 +7662,17 @@ int DoExpDamageTest(DSWActor* actor)
if (dist < found_dist) if (dist < found_dist)
{ {
found_dist = dist; found_dist = dist;
found_sp = sp; found_act = itActor;
} }
} }
if (found_act)
if (found_sp)
{ {
auto found_sp = &found_act->s();
if (SP_TAG2(found_sp) == 0) if (SP_TAG2(found_sp) == 0)
{ {
// just do one // just do one
DoWallMove(&swActors[found_sp - sprite]); DoWallMove(found_act);
} }
else else
{ {
@ -7684,7 +7682,6 @@ int DoExpDamageTest(DSWActor* actor)
} }
} }
} }
return 0; return 0;
} }
@ -7692,8 +7689,7 @@ int DoExpDamageTest(DSWActor* actor)
int DoMineExpMine(DSWActor* actor) int DoMineExpMine(DSWActor* actor)
{ {
auto wu = actor->u(); auto wu = actor->u();
int Weapon = wu->SpriteNum; SPRITEp wp = &actor->s();
SPRITEp wp = &sprite[Weapon];
USERp u; USERp u;
SPRITEp sp; SPRITEp sp;
@ -7702,29 +7698,27 @@ int DoMineExpMine(DSWActor* actor)
int tmin; int tmin;
int zdist; int zdist;
StatIterator it(STAT_MINE_STUCK); SWStatIterator it(STAT_MINE_STUCK);
while ((i = it.NextIndex()) >= 0) while (auto itActor = it.Next())
{ {
sp = &sprite[i]; sp = &itActor->s();
u = User[i].Data(); u = itActor->u();
DISTANCE(sp->x, sp->y, wp->x, wp->y, dist, tx, ty, tmin); DISTANCE(sp->x, sp->y, wp->x, wp->y, dist, tx, ty, tmin);
if ((unsigned)dist > wu->Radius + u->Radius) if ((unsigned)dist > wu->Radius + u->Radius)
continue; continue;
if (sp == wp) if (itActor == actor)
continue; continue;
//if (!TEST(sp->cstat, CSTAT_SPRITE_BLOCK))
// continue;
if (!TEST(sp->cstat, CSTAT_SPRITE_BLOCK_HITSCAN)) if (!TEST(sp->cstat, CSTAT_SPRITE_BLOCK_HITSCAN))
continue; continue;
// Explosions are spherical, not planes, so let's check that way, well cylindrical at least. // Explosions are spherical, not planes, so let's check that way, well cylindrical at least.
zdist = abs(sp->z - wp->z)>>4; zdist = abs(sp->z - wp->z)>>4;
if (SpriteOverlap(Weapon, i) || (unsigned)zdist < wu->Radius + u->Radius) if (SpriteOverlap(actor->GetSpriteIndex(), itActor->GetSpriteIndex()) || (unsigned)zdist < wu->Radius + u->Radius)
{ {
DoDamage(i, Weapon); DoDamage(itActor->GetSpriteIndex(), actor->GetSpriteIndex());
// only explode one mine at a time // only explode one mine at a time
break; break;
} }