- pSprite replacements in blood/src/actor.cpp

This commit is contained in:
Christoph Oelckers 2021-12-22 15:33:13 +01:00
parent a87948677a
commit fbb8f1ee70

View file

@ -2351,11 +2351,10 @@ static void actInitTraps()
BloodStatIterator it(kStatTraps); BloodStatIterator it(kStatTraps);
while (auto act = it.Next()) while (auto act = it.Next())
{ {
spritetype* pSprite = &act->s(); if (act->spr.type == kTrapExploder)
if (pSprite->type == kTrapExploder)
{ {
pSprite->cstat &= ~CSTAT_SPRITE_BLOCK; act->spr.cstat &= ~CSTAT_SPRITE_BLOCK;
pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; act->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
if (!act->hasX()) continue; if (!act->hasX()) continue;
auto x = &act->x(); auto x = &act->x();
x->waitTime = ClipLow(x->waitTime, 1); x->waitTime = ClipLow(x->waitTime, 1);
@ -2376,10 +2375,9 @@ static void actInitThings()
while (auto act = it.Next()) while (auto act = it.Next())
{ {
if (!act->hasX()) continue; if (!act->hasX()) continue;
spritetype* pSprite = &act->s();
XSPRITE* pXSprite = &act->x(); XSPRITE* pXSprite = &act->x();
int nType = pSprite->type - kThingBase; int nType = act->spr.type - kThingBase;
pXSprite->health = thingInfo[nType].startHealth << 4; pXSprite->health = thingInfo[nType].startHealth << 4;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
// allow level designer to set custom clipdist. // allow level designer to set custom clipdist.
@ -2387,13 +2385,13 @@ static void actInitThings()
// but what if it have voxel model...? // but what if it have voxel model...?
if (!gModernMap) if (!gModernMap)
#endif #endif
pSprite->clipdist = thingInfo[nType].clipdist; act->spr.clipdist = thingInfo[nType].clipdist;
pSprite->flags = thingInfo[nType].flags; act->spr.flags = thingInfo[nType].flags;
if (pSprite->flags & kPhysGravity) pSprite->flags |= kPhysFalling; if (act->spr.flags & kPhysGravity) act->spr.flags |= kPhysFalling;
act->xvel = act->yvel = act->zvel = 0; act->xvel = act->yvel = act->zvel = 0;
switch (pSprite->type) switch (act->spr.type)
{ {
case kThingArmedProxBomb: case kThingArmedProxBomb:
case kTrapMachinegun: case kTrapMachinegun:
@ -2446,8 +2444,7 @@ static void actInitDudes()
BloodStatIterator it(kStatDude); BloodStatIterator it(kStatDude);
while (auto act = it.Next()) while (auto act = it.Next())
{ {
spritetype* pSprite = &act->s(); if (act->spr.type < kDudeBase || act->spr.type >= kDudeMax)
if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax)
I_Error("Non-enemy sprite (%d) in the enemy sprite list.\n", act->GetIndex()); I_Error("Non-enemy sprite (%d) in the enemy sprite list.\n", act->GetIndex());
} }
@ -2462,19 +2459,18 @@ static void actInitDudes()
while (auto act = it.Next()) while (auto act = it.Next())
{ {
if (!act->hasX()) continue; if (!act->hasX()) continue;
spritetype* pSprite = &act->s();
XSPRITE* pXSprite = &act->x(); XSPRITE* pXSprite = &act->x();
int nType = pSprite->type - kDudeBase; int nType = act->spr.type - kDudeBase;
int seqStartId = dudeInfo[nType].seqStartID; int seqStartId = dudeInfo[nType].seqStartID;
if (!act->IsPlayerActor()) if (!act->IsPlayerActor())
{ {
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
switch (pSprite->type) switch (act->spr.type)
{ {
case kDudeModernCustom: case kDudeModernCustom:
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
pSprite->cstat |= CSTAT_SPRITE_BLOOD_BIT1 | CSTAT_SPRITE_BLOCK_ALL; act->spr.cstat |= CSTAT_SPRITE_BLOOD_BIT1 | CSTAT_SPRITE_BLOCK_ALL;
seqStartId = genDudeSeqStartId(act); // Custom Dude stores its SEQ in data2 seqStartId = genDudeSeqStartId(act); // Custom Dude stores its SEQ in data2
pXSprite->sysData1 = pXSprite->data3; // move sndStartId to sysData1, because data3 used by the game; pXSprite->sysData1 = pXSprite->data3; // move sndStartId to sysData1, because data3 used by the game;
pXSprite->data3 = 0; pXSprite->data3 = 0;
@ -2484,13 +2480,13 @@ static void actInitDudes()
if (gModernMap) break; if (gModernMap) break;
[[fallthrough]]; [[fallthrough]];
default: default:
pSprite->clipdist = dudeInfo[nType].clipdist; act->spr.clipdist = dudeInfo[nType].clipdist;
pSprite->cstat |= CSTAT_SPRITE_BLOOD_BIT1 | CSTAT_SPRITE_BLOCK_ALL; act->spr.cstat |= CSTAT_SPRITE_BLOOD_BIT1 | CSTAT_SPRITE_BLOCK_ALL;
break; break;
} }
#else #else
pSprite->clipdist = dudeInfo[nType].clipdist; act->spr.clipdist = dudeInfo[nType].clipdist;
pSprite->cstat |= CSTAT_SPRITE_BLOOD_BIT1 | CSTAT_SPRITE_BLOCK_ALL; act->spr.cstat |= CSTAT_SPRITE_BLOOD_BIT1 | CSTAT_SPRITE_BLOCK_ALL;
#endif #endif
act->xvel = act->yvel = act->zvel = 0; act->xvel = act->yvel = act->zvel = 0;
@ -2658,16 +2654,15 @@ void actRadiusDamage(DBloodActor* source, int x, int y, int z, sectortype* pSect
{ {
if (act2 != source || (flags & 1)) if (act2 != source || (flags & 1))
{ {
auto pSprite2 = &act2->s();
if (act2->hasX()) if (act2->hasX())
{ {
if (pSprite2->flags & 0x20) continue; if (act2->spr.flags & 0x20) continue;
if (!CheckSector(sectorMap, pSprite2)) continue; if (!CheckSector(sectorMap, pSprite2)) continue;
if (!CheckProximity(act2, x, y, z, pSector, nDist)) continue; if (!CheckProximity(act2, x, y, z, pSector, nDist)) continue;
int dx = abs(x - pSprite2->pos.X); int dx = abs(x - act2->spr.pos.X);
int dy = abs(y - pSprite2->pos.Y); int dy = abs(y - act2->spr.pos.Y);
int dz = abs(z - pSprite2->pos.Z) >> 4; int dz = abs(z - act2->spr.pos.Z) >> 4;
int dist = ksqrt(dx * dx + dy * dy + dz * dz); int dist = ksqrt(dx * dx + dy * dy + dz * dz);
if (dist > nDist) continue; if (dist > nDist) continue;
@ -2686,17 +2681,15 @@ void actRadiusDamage(DBloodActor* source, int x, int y, int z, sectortype* pSect
BloodStatIterator it(kStatDude); BloodStatIterator it(kStatDude);
while (auto act2 = it.Next()) while (auto act2 = it.Next())
{ {
auto pSprite2 = &act2->s(); if (act2->spr.flags & 0x20) continue;
if (pSprite2->flags & 0x20) continue;
if (!CheckSector(sectorMap, pSprite2)) continue; if (!CheckSector(sectorMap, pSprite2)) continue;
if (!CheckProximity(act2, x, y, z, pSector, nDist)) continue; if (!CheckProximity(act2, x, y, z, pSector, nDist)) continue;
XSPRITE* pXSprite2 = &act2->x(); XSPRITE* pXSprite2 = &act2->x();
if (pXSprite2->locked) continue; if (pXSprite2->locked) continue;
int dx = abs(x - pSprite2->pos.X); int dx = abs(x - act2->spr.pos.X);
int dy = abs(y - pSprite2->pos.Y); int dy = abs(y - act2->spr.pos.Y);
int dist = ksqrt(dx * dx + dy * dy); int dist = ksqrt(dx * dx + dy * dy);
if (dist > nDist) continue; if (dist > nDist) continue;
@ -2779,12 +2772,11 @@ static DBloodActor* actDropAmmo(DBloodActor* actor, int nType)
{ {
auto act2 = actSpawnFloor(actor); auto act2 = actSpawnFloor(actor);
const AMMOITEMDATA* pAmmo = &gAmmoItemData[nType - kItemAmmoBase]; const AMMOITEMDATA* pAmmo = &gAmmoItemData[nType - kItemAmmoBase];
auto pSprite2 = &act2->s(); act2->spr.type = nType;
pSprite2->type = nType; act2->spr.picnum = pAmmo->picnum;
pSprite2->picnum = pAmmo->picnum; act2->spr.shade = pAmmo->shade;
pSprite2->shade = pAmmo->shade; act2->spr.xrepeat = pAmmo->xrepeat;
pSprite2->xrepeat = pAmmo->xrepeat; act2->spr.yrepeat = pAmmo->yrepeat;
pSprite2->yrepeat = pAmmo->yrepeat;
return act2; return act2;
} }
return nullptr; return nullptr;
@ -2798,12 +2790,11 @@ static DBloodActor* actDropWeapon(DBloodActor* actor, int nType)
{ {
auto act2 = actSpawnFloor(actor); auto act2 = actSpawnFloor(actor);
const WEAPONITEMDATA* pWeapon = &gWeaponItemData[nType - kItemWeaponBase]; const WEAPONITEMDATA* pWeapon = &gWeaponItemData[nType - kItemWeaponBase];
auto pSprite2 = &act2->s(); act2->spr.type = nType;
pSprite2->type = nType; act2->spr.picnum = pWeapon->picnum;
pSprite2->picnum = pWeapon->picnum; act2->spr.shade = pWeapon->shade;
pSprite2->shade = pWeapon->shade; act2->spr.xrepeat = pWeapon->xrepeat;
pSprite2->xrepeat = pWeapon->xrepeat; act2->spr.yrepeat = pWeapon->yrepeat;
pSprite2->yrepeat = pWeapon->yrepeat;
return act2; return act2;
} }
return nullptr; return nullptr;
@ -2817,12 +2808,11 @@ static DBloodActor* actDropItem(DBloodActor* actor, int nType)
{ {
auto act2 = actSpawnFloor(actor); auto act2 = actSpawnFloor(actor);
const ITEMDATA* pItem = &gItemData[nType - kItemBase]; const ITEMDATA* pItem = &gItemData[nType - kItemBase];
auto pSprite2 = &act2->s(); act2->spr.type = nType;
pSprite2->type = nType; act2->spr.picnum = pItem->picnum;
pSprite2->picnum = pItem->picnum; act2->spr.shade = pItem->shade;
pSprite2->shade = pItem->shade; act2->spr.xrepeat = pItem->xrepeat;
pSprite2->xrepeat = pItem->xrepeat; act2->spr.yrepeat = pItem->yrepeat;
pSprite2->yrepeat = pItem->yrepeat;
return act2; return act2;
} }
return nullptr; return nullptr;
@ -4214,31 +4204,30 @@ static void checkCeilHit(DBloodActor* actor)
auto actor2 = coll.actor(); auto actor2 = coll.actor();
if (actor2 && actor2->hasX()) if (actor2 && actor2->hasX())
{ {
spritetype* pSprite2 = &actor2->s();
XSPRITE* pXSprite2 = &actor2->x(); XSPRITE* pXSprite2 = &actor2->x();
if ((pSprite2->statnum == kStatThing || pSprite2->statnum == kStatDude) && (actor->xvel != 0 || actor->yvel != 0 || actor->zvel != 0)) if ((actor2->spr.statnum == kStatThing || actor2->spr.statnum == kStatDude) && (actor->xvel != 0 || actor->yvel != 0 || actor->zvel != 0))
{ {
if (pSprite2->statnum == kStatThing) if (actor2->spr.statnum == kStatThing)
{ {
int nType = pSprite2->type - kThingBase; int nType = actor2->spr.type - kThingBase;
const THINGINFO* pThingInfo = &thingInfo[nType]; const THINGINFO* pThingInfo = &thingInfo[nType];
if (pThingInfo->flags & 1) pSprite2->flags |= 1; if (pThingInfo->flags & 1) actor2->spr.flags |= 1;
if (pThingInfo->flags & 2) pSprite2->flags |= 4; if (pThingInfo->flags & 2) actor2->spr.flags |= 4;
// Inlined ? // Inlined ?
actor2->xvel += MulScale(4, pSprite2->pos.X - pSprite->pos.X, 2); actor2->xvel += MulScale(4, actor2->spr.pos.X - pSprite->pos.X, 2);
actor2->yvel += MulScale(4, pSprite2->pos.Y - pSprite->pos.Y, 2); actor2->yvel += MulScale(4, actor2->spr.pos.Y - pSprite->pos.Y, 2);
} }
else else
{ {
pSprite2->flags |= 5; actor2->spr.flags |= 5;
actor2->xvel += MulScale(4, pSprite2->pos.X - pSprite->pos.X, 2); actor2->xvel += MulScale(4, actor2->spr.pos.X - pSprite->pos.X, 2);
actor2->yvel += MulScale(4, pSprite2->pos.Y - pSprite->pos.Y, 2); actor2->yvel += MulScale(4, actor2->spr.pos.Y - pSprite->pos.Y, 2);
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
// add size shroom abilities // add size shroom abilities
if ((actor->IsPlayerActor() && isShrinked(actor)) || (actor2->IsPlayerActor() && isGrown(actor2))) { if ((actor->IsPlayerActor() && isShrinked(actor)) || (actor2->IsPlayerActor() && isGrown(actor2))) {
int mass1 = getDudeInfo(pSprite2->type)->mass; int mass1 = getDudeInfo(actor2->spr.type)->mass;
int mass2 = getDudeInfo(pSprite->type)->mass; int mass2 = getDudeInfo(pSprite->type)->mass;
switch (pSprite->type) switch (pSprite->type)
{ {
@ -4249,7 +4238,7 @@ static void checkCeilHit(DBloodActor* actor)
} }
if (mass1 > mass2) if (mass1 > mass2)
{ {
int dmg = abs((mass1 - mass2) * (pSprite2->clipdist - pSprite->clipdist)); int dmg = abs((mass1 - mass2) * (actor2->spr.clipdist - pSprite->clipdist));
if (actor2->IsDudeActor()) if (actor2->IsDudeActor())
{ {
if (dmg > 0) actDamageSprite(actor2, actor, (Chance(0x2000)) ? kDamageFall : (Chance(0x4000)) ? kDamageExplode : kDamageBullet, dmg); if (dmg > 0) actDamageSprite(actor2, actor, (Chance(0x2000)) ? kDamageFall : (Chance(0x4000)) ? kDamageExplode : kDamageBullet, dmg);
@ -4260,7 +4249,7 @@ static void checkCeilHit(DBloodActor* actor)
#endif #endif
if (!actor->IsPlayerActor() || gPlayer[pSprite->type - kDudePlayer1].godMode == 0) if (!actor->IsPlayerActor() || gPlayer[pSprite->type - kDudePlayer1].godMode == 0)
{ {
switch (pSprite2->type) switch (actor2->spr.type)
{ {
case kDudeTchernobog: case kDudeTchernobog:
actDamageSprite(actor2, actor, kDamageExplode, pXSprite->health << 2); actDamageSprite(actor2, actor, kDamageExplode, pXSprite->health << 2);
@ -4288,7 +4277,7 @@ static void checkCeilHit(DBloodActor* actor)
} }
} }
if (pSprite2->type == kTrapSawCircular) if (actor2->spr.type == kTrapSawCircular)
{ {
if (!pXSprite2->state) actDamageSprite(actor, actor, kDamageBullet, 1); if (!pXSprite2->state) actDamageSprite(actor, actor, kDamageBullet, 1);
else { else {
@ -4322,7 +4311,6 @@ static void checkHit(DBloodActor* actor)
if (coll.actor()->hasX()) if (coll.actor()->hasX())
{ {
auto actor2 = coll.actor(); auto actor2 = coll.actor();
spritetype* pSprite2 = &actor2->s();
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
// add size shroom abilities // add size shroom abilities
@ -4331,8 +4319,8 @@ static void checkHit(DBloodActor* actor)
if (actor->xvel != 0 && actor2->IsDudeActor()) if (actor->xvel != 0 && actor2->IsDudeActor())
{ {
int mass1 = getDudeInfo(pSprite->type)->mass; int mass1 = getDudeInfo(pSprite->type)->mass;
int mass2 = getDudeInfo(pSprite2->type)->mass; int mass2 = getDudeInfo(actor2->spr.type)->mass;
switch (pSprite2->type) switch (actor2->spr.type)
{ {
case kDudeModernCustom: case kDudeModernCustom:
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
@ -4350,7 +4338,7 @@ static void checkHit(DBloodActor* actor)
} }
#endif #endif
switch (pSprite2->type) switch (actor2->spr.type)
{ {
case kThingKickablePail: case kThingKickablePail:
actKickObject(actor, actor2); actKickObject(actor, actor2);
@ -4398,7 +4386,6 @@ static void checkFloorHit(DBloodActor* actor)
if (coll.actor()->hasX()) if (coll.actor()->hasX())
{ {
auto actor2 = coll.actor(); auto actor2 = coll.actor();
spritetype* pSprite2 = &actor2->s();
XSPRITE* pXSprite2 = &actor2->x(); XSPRITE* pXSprite2 = &actor2->x();
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
@ -4407,8 +4394,8 @@ static void checkFloorHit(DBloodActor* actor)
{ {
int mass1 = getDudeInfo(pSprite->type)->mass; int mass1 = getDudeInfo(pSprite->type)->mass;
int mass2 = getDudeInfo(pSprite2->type)->mass; int mass2 = getDudeInfo(actor2->spr.type)->mass;
switch (pSprite2->type) switch (actor2->spr.type)
{ {
case kDudeModernCustom: case kDudeModernCustom:
case kDudeModernCustomBurning: case kDudeModernCustomBurning:
@ -4418,7 +4405,7 @@ static void checkFloorHit(DBloodActor* actor)
if (mass1 > mass2 && actor2->IsDudeActor()) if (mass1 > mass2 && actor2->IsDudeActor())
{ {
if ((IsPlayerSprite(pSprite2) && Chance(0x500)) || !IsPlayerSprite(pSprite2)) if ((actor2->IsPlayerActor() && Chance(0x500)) || !actor2->IsPlayerActor())
actKickObject(actor, actor2); actKickObject(actor, actor2);
int dmg = (mass1 - mass2) + pSprite->clipdist; int dmg = (mass1 - mass2) + pSprite->clipdist;
@ -4430,7 +4417,7 @@ static void checkFloorHit(DBloodActor* actor)
PLAYER* pPlayer = nullptr; PLAYER* pPlayer = nullptr;
if (actor->IsPlayerActor()) pPlayer = &gPlayer[pSprite->type - kDudePlayer1]; if (actor->IsPlayerActor()) pPlayer = &gPlayer[pSprite->type - kDudePlayer1];
switch (pSprite2->type) switch (actor2->spr.type)
{ {
case kThingKickablePail: case kThingKickablePail:
if (pPlayer) if (pPlayer)
@ -5673,9 +5660,8 @@ static void actCheckProximity()
while (auto dudeactor = it1.Next()) while (auto dudeactor = it1.Next())
{ {
auto nextdude = it1.Peek(); auto nextdude = it1.Peek();
spritetype* pSprite2 = &dudeactor->s();
if (pSprite2->flags & 32 || !dudeactor->hasX()) continue; if (dudeactor->spr.flags & 32 || !dudeactor->hasX()) continue;
XSPRITE* pXSprite2 = &dudeactor->x(); XSPRITE* pXSprite2 = &dudeactor->x();
if ((unsigned int)pXSprite2->health > 0) if ((unsigned int)pXSprite2->health > 0)
@ -5695,9 +5681,9 @@ static void actCheckProximity()
spritetype* pOwner = &Owner->s(); spritetype* pOwner = &Owner->s();
PLAYER* pPlayer = &gPlayer[pOwner->type - kDudePlayer1]; PLAYER* pPlayer = &gPlayer[pOwner->type - kDudePlayer1];
PLAYER* pPlayer2 = dudeactor->IsPlayerActor() ? &gPlayer[pSprite2->type - kDudePlayer1] : nullptr; PLAYER* pPlayer2 = dudeactor->IsPlayerActor() ? &gPlayer[dudeactor->spr.type - kDudePlayer1] : nullptr;
if (dudeactor == Owner || pSprite2->type == kDudeZombieAxeBuried || pSprite2->type == kDudeRat || pSprite2->type == kDudeBat) continue; if (dudeactor == Owner || dudeactor->spr.type == kDudeZombieAxeBuried || dudeactor->spr.type == kDudeRat || dudeactor->spr.type == kDudeBat) continue;
if (gGameOptions.nGameType == 3 && pPlayer2 && pPlayer->teamId == pPlayer2->teamId) continue; if (gGameOptions.nGameType == 3 && pPlayer2 && pPlayer->teamId == pPlayer2->teamId) continue;
if (gGameOptions.nGameType == 1 && pPlayer2) continue; if (gGameOptions.nGameType == 1 && pPlayer2) continue;
proxyDist = 512; proxyDist = 512;
@ -5709,7 +5695,7 @@ static void actCheckProximity()
{ {
case kThingDroppedLifeLeech: case kThingDroppedLifeLeech:
if (!Chance(0x4000) && nextdude) continue; if (!Chance(0x4000) && nextdude) continue;
if (pSprite2->cstat & CSTAT_SPRITE_BLOCK) actor->SetTarget(dudeactor); if (dudeactor->spr.cstat & CSTAT_SPRITE_BLOCK) actor->SetTarget(dudeactor);
else continue; else continue;
break; break;