- complete cleanup of sub_2A620, now renamed to actRadiusDamage.

This commit is contained in:
Christoph Oelckers 2020-12-02 21:39:37 +01:00
parent 6110ec5cfd
commit 23df336ebe
4 changed files with 114 additions and 108 deletions

View file

@ -2606,115 +2606,116 @@ static void ConcussSprite(DBloodActor* source, DBloodActor* actor, int x, int y,
int actWallBounceVector(int *x, int *y, int nWall, int a4) int actWallBounceVector(int *x, int *y, int nWall, int a4)
{ {
int wx, wy; int wx, wy;
GetWallNormal(nWall, &wx, &wy); GetWallNormal(nWall, &wx, &wy);
int t = DMulScale(*x, wx, *y, wy, 16); int t = DMulScale(*x, wx, *y, wy, 16);
int t2 = mulscale16r(t, a4+0x10000); int t2 = mulscale16r(t, a4+0x10000);
*x -= MulScale(wx, t2, 16); *x -= MulScale(wx, t2, 16);
*y -= MulScale(wy, t2, 16); *y -= MulScale(wy, t2, 16);
return mulscale16r(t, 0x10000-a4); return mulscale16r(t, 0x10000-a4);
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5) int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5)
{ {
int t = 0x10000-a5; int t = 0x10000-a5;
if (sector[nSector].floorheinum == 0) if (sector[nSector].floorheinum == 0)
{ {
int t2 = MulScale(*z, t, 16); int t2 = MulScale(*z, t, 16);
*z = -(*z-t2); *z = -(*z-t2);
return t2; return t2;
} }
walltype *pWall = &wall[sector[nSector].wallptr]; walltype *pWall = &wall[sector[nSector].wallptr];
walltype *pWall2 = &wall[pWall->point2]; walltype *pWall2 = &wall[pWall->point2];
int angle = getangle(pWall2->x-pWall->x, pWall2->y-pWall->y)+512; int angle = getangle(pWall2->x-pWall->x, pWall2->y-pWall->y)+512;
int t2 = sector[nSector].floorheinum<<4; int t2 = sector[nSector].floorheinum<<4;
int t3 = approxDist(-0x10000, t2); int t3 = approxDist(-0x10000, t2);
int t4 = DivScale(-0x10000, t3, 16); int t4 = DivScale(-0x10000, t3, 16);
int t5 = DivScale(t2, t3, 16); int t5 = DivScale(t2, t3, 16);
int t6 = MulScale(t5, Cos(angle), 30); int t6 = MulScale(t5, Cos(angle), 30);
int t7 = MulScale(t5, Sin(angle), 30); int t7 = MulScale(t5, Sin(angle), 30);
int t8 = TMulScale(*x, t6, *y, t7, *z, t4, 16); int t8 = TMulScale(*x, t6, *y, t7, *z, t4, 16);
int t9 = MulScale(t8, 0x10000+a5, 16); int t9 = MulScale(t8, 0x10000+a5, 16);
*x -= MulScale(t6, t9, 16); *x -= MulScale(t6, t9, 16);
*y -= MulScale(t7, t9, 16); *y -= MulScale(t7, t9, 16);
*z -= MulScale(t4, t9, 16); *z -= MulScale(t4, t9, 16);
return mulscale16r(t8, t); return mulscale16r(t8, t);
} }
void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7, int a8, DAMAGE_TYPE a9, int a10, int a11, int , int ) //---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void actRadiusDamage(DBloodActor* source, int x, int y, int z, int nSector, int nDist, int baseDmg, int distDmg, DAMAGE_TYPE dmgType, int flags, int burn)
{ {
uint8_t va0[(kMaxSectors+7)>>3]; uint8_t sectmap[(kMaxSectors + 7) >> 3];
int nOwner = sprite[nSprite].owner; auto pOwner = source->GetOwner();
GetClosestSpriteSectors(nSector, x, y, nDist, va0); GetClosestSpriteSectors(nSector, x, y, nDist, sectmap);
nDist <<= 4; nDist <<= 4;
if (a10 & 2) if (flags & 2)
{ {
int i; BloodStatIterator it(kStatDude);
StatIterator it(kStatDude); while (auto act2 = it.Next())
while ((i = it.NextIndex()) >= 0) {
{ if (act2 != source || (flags & 1))
if (i != nSprite || (a10 & 1)) {
{ auto pSprite2 = &act2->s();
spritetype *pSprite2 = &sprite[i]; if (act2->hasX())
if (pSprite2->extra > 0 && pSprite2->extra < kMaxXSprites) {
{ if (pSprite2->flags & 0x20) continue;
if (!TestBitString(sectmap, pSprite2->sectnum)) continue;
if (!CheckProximity(pSprite2, x, y, z, nSector, nDist)) continue;
if (pSprite2->flags & 0x20) int dx = abs(x - pSprite2->x);
continue; int dy = abs(y - pSprite2->y);
if (!TestBitString(va0, pSprite2->sectnum)) int dz = abs(z - pSprite2->z) >> 4;
continue; int dist = ksqrt(dx * dx + dy * dy + dz * dz);
if (!CheckProximity(pSprite2, x, y, z, nSector, nDist)) if (dist > nDist) continue;
continue;
int dx = abs(x-pSprite2->x);
int dy = abs(y-pSprite2->y);
int dz = abs(z-pSprite2->z)>>4;
int dist = ksqrt(dx*dx+dy*dy+dz*dz);
if (dist > nDist)
continue;
int vcx;
if (dist != 0)
vcx = a7+((nDist-dist)*a8)/nDist;
else
vcx = a7+a8;
actDamageSprite(nSprite, pSprite2, a9, vcx<<4);
if (a11)
actBurnSprite(nOwner, &xsprite[pSprite2->extra], a11);
}
}
}
}
if (a10 & 4)
{
int i;
StatIterator it(kStatThing);
while ((i = it.NextIndex()) >= 0)
{
spritetype *pSprite2 = &sprite[i];
if (pSprite2->flags&0x20) int totaldmg;
continue; if (dist != 0) totaldmg = baseDmg + ((nDist - dist) * distDmg) / nDist;
if (!TestBitString(va0, pSprite2->sectnum)) else totaldmg = baseDmg + distDmg;
continue;
if (!CheckProximity(pSprite2, x, y, z, nSector, nDist)) actDamageSprite(source, act2, dmgType, totaldmg << 4);
continue; if (burn) actBurnSprite(pOwner, act2, burn);
XSPRITE *pXSprite2 = &xsprite[pSprite2->extra]; }
if (pXSprite2->locked) }
continue; }
int dx = abs(x-pSprite2->x); }
int dy = abs(y-pSprite2->y); if (flags & 4)
int dist = ksqrt(dx*dx+dy*dy); {
if (dist > nDist) BloodStatIterator it(kStatDude);
continue; while (auto act2 = it.Next())
int vcx; {
if (dist != 0) auto pSprite2 = &act2->s();
vcx = a7+((nDist-dist)*a8)/nDist;
else if (pSprite2->flags & 0x20) continue;
vcx = a7+a8; if (!TestBitString(sectmap, pSprite2->sectnum)) continue;
actDamageSprite(nSprite, pSprite2, a9, vcx<<4); if (!CheckProximity(pSprite2, x, y, z, nSector, nDist)) continue;
if (a11)
actBurnSprite(nOwner, pXSprite2, a11); XSPRITE* pXSprite2 = &act2->x();
} if (pXSprite2->locked) continue;
}
int dx = abs(x - pSprite2->x);
int dy = abs(y - pSprite2->y);
int dist = ksqrt(dx * dx + dy * dy);
if (dist > nDist) continue;
int totaldmg;
if (dist != 0) totaldmg = baseDmg + ((nDist - dist) * distDmg) / nDist;
else totaldmg = baseDmg + distDmg;
actDamageSprite(source, act2, dmgType, totaldmg << 4);
if (burn) actBurnSprite(pOwner, act2, burn);
}
}
} }
void sub_2AA94(DBloodActor* actor) void sub_2AA94(DBloodActor* actor)
@ -2728,7 +2729,7 @@ void sub_2AA94(DBloodActor* actor)
pSprite->cstat |= 4; pSprite->cstat |= 4;
sfxPlay3DSound(pSprite, 303, 24+(pSprite->flags&3), 1); sfxPlay3DSound(pSprite, 303, 24+(pSprite->flags&3), 1);
sub_2A620(nOwner, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 128, 0, 60, DAMAGE_TYPE_3, 15, 120, 0, 0); actRadiusDamage(actor->GetOwner(), pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 128, 0, 60, DAMAGE_TYPE_3, 15, 120);
if (pXSprite->data4 > 1) if (pXSprite->data4 > 1)
{ {
GibSprite(pSprite, GIBTYPE_5, NULL, NULL); GibSprite(pSprite, GIBTYPE_5, NULL, NULL);
@ -3599,7 +3600,7 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, in
int actDamageSprite(DBloodActor* pSource, DBloodActor* pTarget, DAMAGE_TYPE damageType, int damage) int actDamageSprite(DBloodActor* pSource, DBloodActor* pTarget, DAMAGE_TYPE damageType, int damage)
{ {
return actDamageSprite(pSource->s().index, &pTarget->s(), damageType, damage); return actDamageSprite(pSource? pSource->s().index : -1, &pTarget->s(), damageType, damage);
} }
void actHitcodeToData(int a1, HITINFO *pHitInfo, int *a3, spritetype **a4, XSPRITE **a5, int *a6, walltype **a7, XWALL **a8, int *a9, sectortype **a10, XSECTOR **a11) void actHitcodeToData(int a1, HITINFO *pHitInfo, int *a3, spritetype **a4, XSPRITE **a5, int *a6, walltype **a7, XWALL **a8, int *a9, sectortype **a10, XSECTOR **a11)
@ -3790,7 +3791,7 @@ void actImpactMissile(spritetype *pMissile, int hitCode)
evPost(nSpriteHit, 3, 0, kCallbackFXFlameLick); evPost(nSpriteHit, 3, 0, kCallbackFXFlameLick);
actBurnSprite(pMissile->owner, pXSpriteHit, 480); actBurnSprite(pMissile->owner, pXSpriteHit, 480);
sub_2A620(nOwner, pMissile->x, pMissile->y, pMissile->z, pMissile->sectnum, 16, 20, 10, DAMAGE_TYPE_2, 6, 480, 0, 0); actRadiusDamage(&bloodActors[nOwner], pMissile->x, pMissile->y, pMissile->z, pMissile->sectnum, 16, 20, 10, DAMAGE_TYPE_2, 6, 480);
// by NoOne: allow additional bullet damage for Flare Gun // by NoOne: allow additional bullet damage for Flare Gun
if (gGameOptions.weaponsV10x && !VanillaMode() && !DemoRecordStatus()) { if (gGameOptions.weaponsV10x && !VanillaMode() && !DemoRecordStatus()) {
@ -5605,7 +5606,7 @@ void actProcessSprites(void)
case kThingPodGreenBall: case kThingPodGreenBall:
if ((hit&0xc000) == 0x4000) if ((hit&0xc000) == 0x4000)
{ {
sub_2A620(pSprite->owner, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 200, 1, 20, DAMAGE_TYPE_3, 6, 0, 0, 0); actRadiusDamage(&bloodActors[pSprite->owner], pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 200, 1, 20, DAMAGE_TYPE_3, 6, 0);
evPost(pSprite->index, 3, 0, kCallbackFXPodBloodSplat); evPost(pSprite->index, 3, 0, kCallbackFXPodBloodSplat);
} }
else else

View file

@ -213,7 +213,7 @@ bool IsUnderwaterSector(int nSector);
void actInit(bool bSaveLoad); void actInit(bool bSaveLoad);
int actWallBounceVector(int *x, int *y, int nWall, int a4); int actWallBounceVector(int *x, int *y, int nWall, int a4);
int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5); int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5);
void sub_2A620(int nSprite, int x, int y, int z, int nSector, int nDist, int a7, int a8, DAMAGE_TYPE a9, int a10, int a11, int a12, int a13); void actRadiusDamage(DBloodActor* source, int x, int y, int z, int nSector, int nDist, int a7, int a8, DAMAGE_TYPE a9, int a10, int a11);
void sub_2AA94(DBloodActor *actor); void sub_2AA94(DBloodActor *actor);
spritetype *actSpawnFloor(spritetype *pSprite); spritetype *actSpawnFloor(spritetype *pSprite);
spritetype *actDropAmmo(spritetype *pSprite, int nType); spritetype *actDropAmmo(spritetype *pSprite, int nType);

View file

@ -119,8 +119,7 @@ void podAttack(int, DBloodActor* actor)
void sub_70284(int, DBloodActor* actor) void sub_70284(int, DBloodActor* actor)
{ {
XSPRITE* pXSprite = &actor->x(); auto pSprite = &actor->s();
spritetype* pSprite = &actor->s();
sfxPlay3DSound(pSprite, 2502, -1, 0); sfxPlay3DSound(pSprite, 2502, -1, 0);
int nDist, nBurn; int nDist, nBurn;
DAMAGE_TYPE dmgType; DAMAGE_TYPE dmgType;
@ -137,7 +136,7 @@ void sub_70284(int, DBloodActor* actor)
nDist = 75; nDist = 75;
break; break;
} }
sub_2A620(pSprite->index, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, nDist, 1, 5*(1+gGameOptions.nDifficulty), dmgType, 2, nBurn, 0, 0); actRadiusDamage(actor, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, nDist, 1, 5*(1+gGameOptions.nDifficulty), dmgType, 2, nBurn);
} }
static void aiPodSearch(DBloodActor* actor) static void aiPodSearch(DBloodActor* actor)

View file

@ -124,5 +124,11 @@ inline int DeleteSprite(DBloodActor* nSprite)
return 0; return 0;
} }
inline void actBurnSprite(DBloodActor* pSource, DBloodActor* pTarget, int nTime)
{
auto pXSprite = &pTarget->x();
pXSprite->burnTime = ClipHigh(pXSprite->burnTime + nTime, sprite[pXSprite->reference].statnum == kStatDude ? 2400 : 1200);
pXSprite->burnSource = pSource->s().index;
}
END_BLD_NS END_BLD_NS