- removed a few compatibility wrappers.

This commit is contained in:
Christoph Oelckers 2020-12-05 23:49:51 +01:00
parent 6a1ffca34f
commit 00d0099333
11 changed files with 66 additions and 74 deletions

View file

@ -33,9 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS BEGIN_BLD_NS
static DBloodActor* actDropObject(DBloodActor* actor, int nType);
VECTORDATA gVectorData[] = { // this is constant EXCEPT for [VECTOR_TYPE_20].maxDist. What were they thinking... VECTORDATA gVectorData[] = { // this is constant EXCEPT for [VECTOR_TYPE_20].maxDist. What were they thinking...
// Tine // Tine
@ -2894,7 +2891,7 @@ static DBloodActor* actDropFlag(DBloodActor* actor, int nType)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static DBloodActor* actDropObject(DBloodActor* actor, int nType) DBloodActor* actDropObject(DBloodActor* actor, int nType)
{ {
DBloodActor* act2 = nullptr; DBloodActor* act2 = nullptr;
@ -2969,7 +2966,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
pSprite->pal = 0; pSprite->pal = 0;
aiGenDudeNewState(pSprite, &genDudeBurnGoto); aiGenDudeNewState(pSprite, &genDudeBurnGoto);
actHealDude(pXSprite, dudeInfo[55].startHealth, dudeInfo[55].startHealth); actHealDude(actor, dudeInfo[55].startHealth, dudeInfo[55].startHealth);
if (pXSprite->burnTime <= 0) pXSprite->burnTime = 1200; if (pXSprite->burnTime <= 0) pXSprite->burnTime = 1200;
actor->dudeExtra.time = PlayClock + 360; actor->dudeExtra.time = PlayClock + 360;
return true; return true;
@ -2991,10 +2988,10 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
aiSetGenIdleState(pSprite, pXSprite); // set idle state aiSetGenIdleState(pSprite, pXSprite); // set idle state
if (pXSprite->key > 0) // drop keys if (pXSprite->key > 0) // drop keys
actDropObject(pSprite, kItemKeyBase + pXSprite->key - 1); actDropObject(actor, kItemKeyBase + pXSprite->key - 1);
if (pXSprite->dropMsg > 0) // drop items if (pXSprite->dropMsg > 0) // drop items
actDropObject(pSprite, pXSprite->dropMsg); actDropObject(actor, pXSprite->dropMsg);
pSprite->flags &= ~kPhysMove; xvel[pSprite->index] = yvel[pSprite->index] = 0; pSprite->flags &= ~kPhysMove; xvel[pSprite->index] = yvel[pSprite->index] = 0;
@ -5076,14 +5073,14 @@ void MoveDude(DBloodActor* actor)
{ {
case kDudeCultistTommy: case kDudeCultistTommy:
case kDudeCultistShotgun: case kDudeCultistShotgun:
aiNewState(&bloodActors[pXSprite->reference], &cultistGoto); aiNewState(actor, &cultistGoto);
break; break;
case kDudeGillBeast: case kDudeGillBeast:
aiNewState(&bloodActors[pXSprite->reference], &gillBeastGoto); aiNewState(actor, &gillBeastGoto);
pSprite->flags |= 6; pSprite->flags |= 6;
break; break;
case kDudeBoneEel: case kDudeBoneEel:
actKillDude(pSprite->index, pSprite, kDamageFall, 1000 << 4); actKillDude(actor, actor, kDamageFall, 1000 << 4);
break; break;
} }
@ -5176,7 +5173,7 @@ void MoveDude(DBloodActor* actor)
case kDudeBat: case kDudeBat:
case kDudeRat: case kDudeRat:
case kDudeBurningInnocent: case kDudeBurningInnocent:
actKillDude(pSprite->index, pSprite, kDamageFall, 1000 << 4); actKillDude(actor, actor, kDamageFall, 1000 << 4);
break; break;
} }
@ -5667,7 +5664,7 @@ void actActivateGibObject(DBloodActor* actor)
if (gib2 > 0) GibSprite(pSprite, (GIBTYPE)(gib2 - 1), nullptr, nullptr); if (gib2 > 0) GibSprite(pSprite, (GIBTYPE)(gib2 - 1), nullptr, nullptr);
if (gib3 > 0 && pXSprite->burnTime > 0) GibSprite(pSprite, (GIBTYPE)(gib3 - 1), nullptr, nullptr); if (gib3 > 0 && pXSprite->burnTime > 0) GibSprite(pSprite, (GIBTYPE)(gib3 - 1), nullptr, nullptr);
if (sound > 0) sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, sound, pSprite->sectnum); if (sound > 0) sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, sound, pSprite->sectnum);
if (dropmsg > 0) actDropObject(pSprite, dropmsg); if (dropmsg > 0) actDropObject(actor, dropmsg);
if (!(pSprite->cstat & 32768) && !(pSprite->flags & kHitagRespawn)) if (!(pSprite->cstat & 32768) && !(pSprite->flags & kHitagRespawn))
actPostSprite(actor, kStatFree); actPostSprite(actor, kStatFree);
@ -7404,22 +7401,6 @@ void SerializeActor(FSerializer& arc)
} }
} }
spritetype* actDropObject(spritetype* pSprite, int nType)
{
auto act = actDropObject(&bloodActors[pSprite->index], nType);
return act ? &act->s() : nullptr;
}
bool actHealDude(XSPRITE* pXDude, int a2, int a3)
{
return actHealDude(&bloodActors[pXDude->reference], a2, a3);
}
void actKillDude(int a1, spritetype* pSprite, DAMAGE_TYPE a3, int a4)
{
actKillDude(&bloodActors[a1], &bloodActors[pSprite->index], a3, a4);
}
int actDamageSprite(int nSource, spritetype* pSprite, DAMAGE_TYPE damageType, int damage) int actDamageSprite(int nSource, spritetype* pSprite, DAMAGE_TYPE damageType, int damage)
{ {
return actDamageSprite(nSource == -1 ? nullptr : &bloodActors[nSource], &bloodActors[pSprite->index], damageType, damage); return actDamageSprite(nSource == -1 ? nullptr : &bloodActors[nSource], &bloodActors[pSprite->index], damageType, damage);

View file

@ -220,11 +220,9 @@ 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 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 actRadiusDamage(DBloodActor* source, int x, int y, int z, int nSector, int nDist, int a7, int a8, DAMAGE_TYPE a9, int a10, int a11);
spritetype *actDropObject(spritetype *pSprite, int nType); DBloodActor *actDropObject(DBloodActor *pSprite, int nType);
bool actHealDude(DBloodActor* pXDude, int a2, int a3); bool actHealDude(DBloodActor* pXDude, int a2, int a3);
bool actHealDude(XSPRITE *pXDude, int a2, int a3);
void actKillDude(DBloodActor* a1, DBloodActor* pSprite, DAMAGE_TYPE a3, int a4); void actKillDude(DBloodActor* a1, DBloodActor* pSprite, DAMAGE_TYPE a3, int a4);
void actKillDude(int a1, spritetype *pSprite, DAMAGE_TYPE a3, int a4);
int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE a3, int a4); int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE a3, int a4);
int actDamageSprite(DBloodActor* pSource, DBloodActor* pTarget, DAMAGE_TYPE damageType, int damage); int actDamageSprite(DBloodActor* pSource, DBloodActor* pTarget, DAMAGE_TYPE damageType, int damage);
void actHitcodeToData(int a1, HITINFO *pHitInfo, DBloodActor **actor, walltype **a7 = nullptr); void actHitcodeToData(int a1, HITINFO *pHitInfo, DBloodActor **actor, walltype **a7 = nullptr);

View file

@ -991,14 +991,14 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
pSprite->pal = 0; pSprite->pal = 0;
aiGenDudeNewState(pSprite, &genDudeBurnGoto); aiGenDudeNewState(pSprite, &genDudeBurnGoto);
actHealDude(pXSprite, dudeInfo[55].startHealth, dudeInfo[55].startHealth); actHealDude(actor, dudeInfo[55].startHealth, dudeInfo[55].startHealth);
actor->dudeExtra.time = PlayClock + 360; actor->dudeExtra.time = PlayClock + 360;
evKill(nSprite, 3, kCallbackFXFlameLick); evKill(nSprite, 3, kCallbackFXFlameLick);
} }
} else { } else {
actKillDude(nSource, pSprite, kDamageFall, 65535); actKillDude(actor, actor, kDamageFall, 65535);
} }
} else if (canWalk(pSprite) && !inDodge(pXSprite->aiState) && !inRecoil(pXSprite->aiState)) { } else if (canWalk(pSprite) && !inDodge(pXSprite->aiState) && !inRecoil(pXSprite->aiState)) {
@ -1056,7 +1056,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
aiPlay3DSound(pSprite, 361, AI_SFX_PRIORITY_0, -1); aiPlay3DSound(pSprite, 361, AI_SFX_PRIORITY_0, -1);
aiPlay3DSound(pSprite, 1031+Random(2), AI_SFX_PRIORITY_2, -1); aiPlay3DSound(pSprite, 1031+Random(2), AI_SFX_PRIORITY_2, -1);
actor->dudeExtra.time = PlayClock+360; actor->dudeExtra.time = PlayClock+360;
actHealDude(pXSprite, dudeInfo[40].startHealth, dudeInfo[40].startHealth); actHealDude(actor, dudeInfo[40].startHealth, dudeInfo[40].startHealth);
evKill(nSprite, 3, kCallbackFXFlameLick); evKill(nSprite, 3, kCallbackFXFlameLick);
} }
break; break;
@ -1067,7 +1067,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
aiNewState(actor, &cultistBurnGoto); aiNewState(actor, &cultistBurnGoto);
aiPlay3DSound(pSprite, 361, AI_SFX_PRIORITY_0, -1); aiPlay3DSound(pSprite, 361, AI_SFX_PRIORITY_0, -1);
actor->dudeExtra.time = PlayClock+360; actor->dudeExtra.time = PlayClock+360;
actHealDude(pXSprite, dudeInfo[39].startHealth, dudeInfo[39].startHealth); actHealDude(actor, dudeInfo[39].startHealth, dudeInfo[39].startHealth);
evKill(nSprite, 3, kCallbackFXFlameLick); evKill(nSprite, 3, kCallbackFXFlameLick);
} }
break; break;
@ -1103,7 +1103,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
aiPlay3DSound(pSprite, 1202, AI_SFX_PRIORITY_2, -1); aiPlay3DSound(pSprite, 1202, AI_SFX_PRIORITY_2, -1);
pSprite->type = kDudeBurningZombieButcher; pSprite->type = kDudeBurningZombieButcher;
aiNewState(actor, &zombieFBurnGoto); aiNewState(actor, &zombieFBurnGoto);
actHealDude(pXSprite, dudeInfo[42].startHealth, dudeInfo[42].startHealth); actHealDude(actor, dudeInfo[42].startHealth, dudeInfo[42].startHealth);
evKill(nSprite, 3, kCallbackFXFlameLick); evKill(nSprite, 3, kCallbackFXFlameLick);
} }
break; break;
@ -1122,7 +1122,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
} }
aiPlay3DSound(pSprite, 361, AI_SFX_PRIORITY_0, -1); aiPlay3DSound(pSprite, 361, AI_SFX_PRIORITY_0, -1);
actor->dudeExtra.time = PlayClock+360; actor->dudeExtra.time = PlayClock+360;
actHealDude(pXSprite, dudeInfo[39].startHealth, dudeInfo[39].startHealth); actHealDude(actor, dudeInfo[39].startHealth, dudeInfo[39].startHealth);
evKill(nSprite, 3, kCallbackFXFlameLick); evKill(nSprite, 3, kCallbackFXFlameLick);
} }
break; break;
@ -1132,7 +1132,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
pSprite->type = kDudeBeast; pSprite->type = kDudeBeast;
aiPlay3DSound(pSprite, 9008, AI_SFX_PRIORITY_1, -1); aiPlay3DSound(pSprite, 9008, AI_SFX_PRIORITY_1, -1);
aiNewState(actor, &beastMorphFromCultist); aiNewState(actor, &beastMorphFromCultist);
actHealDude(pXSprite, dudeInfo[51].startHealth, dudeInfo[51].startHealth); actHealDude(actor, dudeInfo[51].startHealth, dudeInfo[51].startHealth);
} }
break; break;
case kDudeZombieAxeNormal: case kDudeZombieAxeNormal:
@ -1143,7 +1143,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType
aiPlay3DSound(pSprite, 1106, AI_SFX_PRIORITY_2, -1); aiPlay3DSound(pSprite, 1106, AI_SFX_PRIORITY_2, -1);
pSprite->type = kDudeBurningZombieAxe; pSprite->type = kDudeBurningZombieAxe;
aiNewState(actor, &zombieABurnGoto); aiNewState(actor, &zombieABurnGoto);
actHealDude(pXSprite, dudeInfo[41].startHealth, dudeInfo[41].startHealth); actHealDude(actor, dudeInfo[41].startHealth, dudeInfo[41].startHealth);
evKill(nSprite, 3, kCallbackFXFlameLick); evKill(nSprite, 3, kCallbackFXFlameLick);
} }
break; break;

View file

@ -535,19 +535,17 @@ static void gargThinkChase(DBloodActor* actor)
static void entryFStatue(DBloodActor* actor) static void entryFStatue(DBloodActor* actor)
{ {
auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
DUDEINFO *pDudeInfo = &dudeInfo[6]; DUDEINFO *pDudeInfo = &dudeInfo[6];
actHealDude(pXSprite, pDudeInfo->startHealth, pDudeInfo->startHealth); actHealDude(actor, pDudeInfo->startHealth, pDudeInfo->startHealth);
pSprite->type = kDudeGargoyleFlesh; pSprite->type = kDudeGargoyleFlesh;
} }
static void entrySStatue(DBloodActor* actor) static void entrySStatue(DBloodActor* actor)
{ {
auto pXSprite = &actor->x();
auto pSprite = &actor->s(); auto pSprite = &actor->s();
DUDEINFO *pDudeInfo = &dudeInfo[7]; DUDEINFO *pDudeInfo = &dudeInfo[7];
actHealDude(pXSprite, pDudeInfo->startHealth, pDudeInfo->startHealth); actHealDude(actor, pDudeInfo->startHealth, pDudeInfo->startHealth);
pSprite->type = kDudeGargoyleStone; pSprite->type = kDudeGargoyleStone;
} }

View file

@ -656,7 +656,7 @@ static void unicultThinkChase(DBloodActor* actor)
if (CheckProximity(pSprite, pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pExpl->radius >> 1)) { if (CheckProximity(pSprite, pTarget->x, pTarget->y, pTarget->z, pTarget->sectnum, pExpl->radius >> 1)) {
xvel[pSprite->index] = zvel[pSprite->index] = yvel[pSprite->index] = 0; xvel[pSprite->index] = zvel[pSprite->index] = yvel[pSprite->index] = 0;
if (doExplosion(pSprite, nType) && pXSprite->health > 0) if (doExplosion(pSprite, nType) && pXSprite->health > 0)
actDamageSprite(pSprite->index, pSprite, kDamageExplode, 65535); actDamageSprite(&bloodActors[pSprite->index], &bloodActors[pSprite->index], kDamageExplode, 65535);
} }
return; return;
} }
@ -1228,7 +1228,7 @@ void removeDudeStuff(spritetype* pSprite) {
while ((nSprite = it.NextIndex()) >= 0) while ((nSprite = it.NextIndex()) >= 0)
{ {
if (sprite[nSprite].owner != pSprite->index) continue; if (sprite[nSprite].owner != pSprite->index) continue;
actDamageSprite(sprite[nSprite].owner, &sprite[nSprite], (DAMAGE_TYPE) 0, 65535); actDamageSprite(&bloodActors[sprite[nSprite].owner], &bloodActors[nSprite], (DAMAGE_TYPE) 0, 65535);
} }
} }
@ -1259,7 +1259,7 @@ void removeLeech(spritetype* pLeech, bool delSprite) {
void killDudeLeech(spritetype* pLeech) { void killDudeLeech(spritetype* pLeech) {
if (pLeech != NULL) { if (pLeech != NULL) {
actDamageSprite(pLeech->owner, pLeech, kDamageExplode, 65535); actDamageSprite(&bloodActors[pLeech->owner], &bloodActors[pLeech->index], kDamageExplode, 65535);
sfxPlay3DSoundCP(pLeech, 522, -1, 0, 60000); sfxPlay3DSoundCP(pLeech, 522, -1, 0, 60000);
if (pLeech->owner >= 0 && pLeech->owner < kMaxSprites) if (pLeech->owner >= 0 && pLeech->owner < kMaxSprites)

View file

@ -208,6 +208,11 @@ inline void PLAYER::setFragger(DBloodActor* actor)
fraggerId = actor == nullptr ? -1 : actor->s().index; fraggerId = actor == nullptr ? -1 : actor->s().index;
} }
inline DBloodActor* PLAYER::actor()
{
return &bloodActors[pSprite->index];
}
// Wrapper around the insane collision info mess from Build. // Wrapper around the insane collision info mess from Build.
struct Collision struct Collision

View file

@ -602,6 +602,7 @@ void sub_76A08(spritetype *pSprite, spritetype *pSprite2, PLAYER *pPlayer) // ??
void DropVoodooCb(int nSprite) // unused void DropVoodooCb(int nSprite) // unused
{ {
auto actor = &bloodActors[nSprite];
spritetype *pSprite = &sprite[nSprite]; spritetype *pSprite = &sprite[nSprite];
int nOwner = pSprite->owner; int nOwner = pSprite->owner;
if (nOwner < 0 || nOwner >= kMaxSprites) if (nOwner < 0 || nOwner >= kMaxSprites)
@ -637,6 +638,7 @@ void DropVoodooCb(int nSprite) // unused
int nNextSprite = it.PeekIndex(); int nNextSprite = it.PeekIndex();
if (nOwner == nSprite2) if (nOwner == nSprite2)
continue; continue;
auto actor2 = &bloodActors[nSprite2];
spritetype *pSprite2 = &sprite[nSprite2]; spritetype *pSprite2 = &sprite[nSprite2];
int nXSprite2 = pSprite2->extra; int nXSprite2 = pSprite2->extra;
if (nXSprite2 > 0 && nXSprite2 < kMaxXSprites) if (nXSprite2 > 0 && nXSprite2 < kMaxXSprites)
@ -660,7 +662,7 @@ void DropVoodooCb(int nSprite) // unused
t += ((3200-pPlayer2->armor[2])<<15)/3200; t += ((3200-pPlayer2->armor[2])<<15)/3200;
if (Chance(t) || nNextSprite < 0) if (Chance(t) || nNextSprite < 0)
{ {
int nDmg = actDamageSprite(nOwner, pSprite2, kDamageSpirit, pXSprite->data1<<4); int nDmg = actDamageSprite(actor, actor2, kDamageSpirit, pXSprite->data1<<4);
pXSprite->data1 = ClipLow(pXSprite->data1-nDmg, 0); pXSprite->data1 = ClipLow(pXSprite->data1-nDmg, 0);
sub_76A08(pSprite2, pSprite, pPlayer2); sub_76A08(pSprite2, pSprite, pPlayer2);
evPost(nSprite, 3, 0, kCallbackRemove); evPost(nSprite, 3, 0, kCallbackRemove);

View file

@ -304,7 +304,7 @@ const char* GameInterface::GenericCheat(int player, int cheat)
SetToys(true); SetToys(true);
break; break;
case kCheatKevorkian: case kCheatKevorkian:
actDamageSprite(gMe->nSprite, gMe->pSprite, kDamageBullet, 8000); actDamageSprite(gMe->actor(), gMe->actor(), kDamageBullet, 8000);
return GStrings("TXTB_KEVORKIAN"); return GStrings("TXTB_KEVORKIAN");
case kCheatMcGee: case kCheatMcGee:
@ -315,12 +315,12 @@ const char* GameInterface::GenericCheat(int player, int cheat)
return GStrings("TXTB_FIRED"); return GStrings("TXTB_FIRED");
} }
case kCheatEdmark: case kCheatEdmark:
actDamageSprite(gMe->nSprite, gMe->pSprite, kDamageExplode, 8000); actDamageSprite(gMe->actor(), gMe->actor(), kDamageExplode, 8000);
return GStrings("TXTB_THEDAYS"); return GStrings("TXTB_THEDAYS");
case kCheatKrueger: case kCheatKrueger:
{ {
actHealDude(gMe->pXSprite, 200, 200); actHealDude(gMe->actor(), 200, 200);
gMe->armor[1] = VanillaMode() ? 200 : 3200; gMe->armor[1] = VanillaMode() ? 200 : 3200;
if (!gMe->pXSprite->burnTime) if (!gMe->pXSprite->burnTime)
evPost(gMe->nSprite, 3, 0, kCallbackFXFlameLick); evPost(gMe->nSprite, 3, 0, kCallbackFXFlameLick);
@ -334,7 +334,7 @@ const char* GameInterface::GenericCheat(int player, int cheat)
gMe->flickerEffect = 360; gMe->flickerEffect = 360;
break; break;
case kCheatSpork: case kCheatSpork:
actHealDude(gMe->pXSprite, 200, 200); actHealDude(gMe->actor(), 200, 200);
break; break;
case kCheatClarice: case kCheatClarice:
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
@ -383,7 +383,7 @@ const char* GameInterface::GenericCheat(int player, int cheat)
SetWooMode(true); SetWooMode(true);
break; break;
case kCheatCousteau: case kCheatCousteau:
actHealDude(gMe->pXSprite, 200, 200); actHealDude(gMe->actor(), 200, 200);
gMe->packSlots[1].curAmount = 100; gMe->packSlots[1].curAmount = 100;
if (!VanillaMode()) if (!VanillaMode())
gMe->pwUpTime[kPwUpDivingSuit] = gPowerUpInfo[kPwUpDivingSuit].bonusTime; gMe->pwUpTime[kPwUpDivingSuit] = gPowerUpInfo[kPwUpDivingSuit].bonusTime;
@ -507,7 +507,7 @@ static void cmd_Give(int player, uint8_t **stream, bool skip)
break; break;
case GIVE_HEALTH: case GIVE_HEALTH:
actHealDude(gMe->pXSprite, 200, 200); actHealDude(gMe->actor(), 200, 200);
bPlayerCheated = true; bPlayerCheated = true;
break; break;

View file

@ -936,14 +936,19 @@ int randomGetDataValue(XSPRITE* pXSprite, int randType) {
} }
// this function drops random item using random pickup generator(s) // this function drops random item using random pickup generator(s)
spritetype* randomDropPickupObject(spritetype* pSource, short prevItem) { spritetype* randomDropPickupObject(spritetype* pSource, short prevItem)
{
auto actor = &bloodActors[pSource->index];
spritetype* pSprite2 = NULL; int selected = -1; int maxRetries = 9; spritetype* pSprite2 = NULL; int selected = -1; int maxRetries = 9;
if (xspriRangeIsFine(pSource->extra)) { if (xspriRangeIsFine(pSource->extra)) {
XSPRITE* pXSource = &xsprite[pSource->extra]; XSPRITE* pXSource = &xsprite[pSource->extra];
while ((selected = randomGetDataValue(pXSource, kRandomizeItem)) == prevItem) if (maxRetries-- <= 0) break; while ((selected = randomGetDataValue(pXSource, kRandomizeItem)) == prevItem) if (maxRetries-- <= 0) break;
if (selected > 0) { if (selected > 0)
pSprite2 = actDropObject(pSource, selected); {
if (pSprite2 != NULL) { DBloodActor* spawned = actDropObject(actor, selected);
if (spawned) {
pSprite2 = &spawned->s();
pXSource->dropMsg = uint8_t(pSprite2->type); // store dropped item type in dropMsg pXSource->dropMsg = uint8_t(pSprite2->type); // store dropped item type in dropMsg
pSprite2->x = pSource->x; pSprite2->x = pSource->x;
@ -3016,24 +3021,25 @@ void damageSprites(XSPRITE* pXSource, spritetype* pSprite) {
actDamageSprite(pSource->index, pSprite, (DAMAGE_TYPE)dmgType, dmg); actDamageSprite(pSource->index, pSprite, (DAMAGE_TYPE)dmgType, dmg);
for (int i = 0; i < 3; pPlayer->armor[i] = armor[i], i++); for (int i = 0; i < 3; pPlayer->armor[i] = armor[i], i++);
} else { }
else {
actDamageSprite(pSource->index, pSprite, (DAMAGE_TYPE)dmgType, dmg); actDamageSprite(pSource->index, pSprite, (DAMAGE_TYPE)dmgType, dmg);
} }
} else { }
else {
Printf(PRINT_HIGH, "Dude type %d is immune to damage type %d!", pSprite->type, dmgType); Printf(PRINT_HIGH, "Dude type %d is immune to damage type %d!", pSprite->type, dmgType);
} }
} }
else if (!pPlayer) actKillDude(pSource->index, pSprite, (DAMAGE_TYPE)dmgType, dmg); else if (!pPlayer) actKillDude(&bloodActors[pSource->index], &bloodActors[pSprite->index], (DAMAGE_TYPE)dmgType, dmg);
else playerDamageSprite(&bloodActors[pSource->index], pPlayer, (DAMAGE_TYPE)dmgType, dmg); else playerDamageSprite(&bloodActors[pSource->index], pPlayer, (DAMAGE_TYPE)dmgType, dmg);
} }
else if ((pXSprite->health = ClipLow(health, 1)) > 16); else if ((pXSprite->health = ClipLow(health, 1)) > 16);
else if (!pPlayer) actKillDude(pSource->index, pSprite, kDamageBullet, dmg); else if (!pPlayer) actKillDude(&bloodActors[pSource->index], &bloodActors[pSprite->index], kDamageBullet, dmg);
else playerDamageSprite(&bloodActors[pSource->index], pPlayer, kDamageBullet, dmg); else playerDamageSprite(&bloodActors[pSource->index], pPlayer, kDamageBullet, dmg);
if (pXSprite->health > 0) { if (pXSprite->health > 0) {
@ -5061,7 +5067,7 @@ bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite
switch (cmd) { switch (cmd) {
case 36: case 36:
actHealDude(pPlayer->pXSprite, ((pXSprite->data2 > 0) ? ClipHigh(pXSprite->data2, 200) : getDudeInfo(pPlayer->pSprite->type)->startHealth), 200); actHealDude(pPlayer->actor(), ((pXSprite->data2 > 0) ? ClipHigh(pXSprite->data2, 200) : getDudeInfo(pPlayer->pSprite->type)->startHealth), 200);
pPlayer->curWeapon = kWeapPitchFork; pPlayer->curWeapon = kWeapPitchFork;
break; break;
} }
@ -5874,7 +5880,7 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
// heal dude a bit in case of friendly fire // heal dude a bit in case of friendly fire
int startHp = (pXSprite->sysData2 > 0) ? ClipRange(pXSprite->sysData2 << 4, 1, 65535) : pDudeInfo->startHealth << 4; int startHp = (pXSprite->sysData2 > 0) ? ClipRange(pXSprite->sysData2 << 4, 1, 65535) : pDudeInfo->startHealth << 4;
if (pXSprite->health < (unsigned)startHp) actHealDude(pXSprite, receiveHp, startHp); if (pXSprite->health < (unsigned)startHp) actHealDude(&bloodActors[pXSprite->reference], receiveHp, startHp);
} else if (xsprite[pBurnSource->extra].health <= 0) { } else if (xsprite[pBurnSource->extra].health <= 0) {
pXSprite->burnTime = 0; pXSprite->burnTime = 0;
} }
@ -5934,11 +5940,11 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) {
// heal dude // heal dude
int startHp = (pXSprite->sysData2 > 0) ? ClipRange(pXSprite->sysData2 << 4, 1, 65535) : pDudeInfo->startHealth << 4; int startHp = (pXSprite->sysData2 > 0) ? ClipRange(pXSprite->sysData2 << 4, 1, 65535) : pDudeInfo->startHealth << 4;
if (pXSprite->health < (unsigned)startHp) actHealDude(pXSprite, receiveHp, startHp); if (pXSprite->health < (unsigned)startHp) actHealDude(&bloodActors[pXSprite->reference], receiveHp, startHp);
// heal mate // heal mate
startHp = (pXMate->sysData2 > 0) ? ClipRange(pXMate->sysData2 << 4, 1, 65535) : getDudeInfo(pMate->type)->startHealth << 4; startHp = (pXMate->sysData2 > 0) ? ClipRange(pXMate->sysData2 << 4, 1, 65535) : getDudeInfo(pMate->type)->startHealth << 4;
if (pXMate->health < (unsigned)startHp) actHealDude(pXMate, receiveHp, startHp); if (pXMate->health < (unsigned)startHp) actHealDude(&bloodActors[pXMate->reference], receiveHp, startHp);
if (pXMate->target > -1 && sprite[pXMate->target].extra >= 0) { if (pXMate->target > -1 && sprite[pXMate->target].extra >= 0) {
pTarget = &sprite[pXMate->target]; pTarget = &sprite[pXMate->target];

View file

@ -486,7 +486,7 @@ void packUseItem(PLAYER *pPlayer, int nPack)
if (health < 100) if (health < 100)
{ {
int heal = ClipHigh(100-health, pPlayer->packSlots[0].curAmount); int heal = ClipHigh(100-health, pPlayer->packSlots[0].curAmount);
actHealDude(pXSprite, heal, 100); actHealDude(pPlayer->actor(), heal, 100);
pPlayer->packSlots[0].curAmount -= heal; pPlayer->packSlots[0].curAmount -= heal;
} }
break; break;
@ -1078,7 +1078,7 @@ char PickupItem(PLAYER *pPlayer, spritetype *pItem) {
addPower = xsprite[sprite[pItem->index].extra].data1; addPower = xsprite[sprite[pItem->index].extra].data1;
#endif #endif
if (!actHealDude(pXSprite, addPower, gPowerUpInfo[nType].maxTime)) return 0; if (!actHealDude(pPlayer->actor(), addPower, gPowerUpInfo[nType].maxTime)) return 0;
return 1; return 1;
} }
case kItemHealthDoctorBag: case kItemHealthDoctorBag:
@ -1901,13 +1901,14 @@ int playerDamageArmor(PLAYER *pPlayer, DAMAGE_TYPE nType, int nDamage)
spritetype *flagDropped(PLAYER *pPlayer, int a2) spritetype *flagDropped(PLAYER *pPlayer, int a2)
{ {
auto actor = pPlayer->actor();
char buffer[80]; char buffer[80];
spritetype *pSprite = NULL; spritetype *pSprite = NULL;
switch (a2) switch (a2)
{ {
case kItemFlagA: case kItemFlagA:
pPlayer->hasFlag &= ~1; pPlayer->hasFlag &= ~1;
pSprite = actDropObject(pPlayer->pSprite, kItemFlagA); pSprite = &actDropObject(actor, kItemFlagA)->s();
if (pSprite) if (pSprite)
pSprite->owner = pPlayer->used2[0]; pSprite->owner = pPlayer->used2[0];
gBlueFlagDropped = true; gBlueFlagDropped = true;
@ -1917,7 +1918,7 @@ spritetype *flagDropped(PLAYER *pPlayer, int a2)
break; break;
case kItemFlagB: case kItemFlagB:
pPlayer->hasFlag &= ~2; pPlayer->hasFlag &= ~2;
pSprite = actDropObject(pPlayer->pSprite, kItemFlagB); pSprite = &actDropObject(actor, kItemFlagB)->s();
if (pSprite) if (pSprite)
pSprite->owner = pPlayer->used2[1]; pSprite->owner = pPlayer->used2[1];
gRedFlagDropped = true; gRedFlagDropped = true;
@ -2163,7 +2164,7 @@ void PlayerSurvive(int, DBloodActor* actor)
XSPRITE* pXSprite = &actor->x(); XSPRITE* pXSprite = &actor->x();
spritetype* pSprite = &actor->s(); spritetype* pSprite = &actor->s();
char buffer[80]; char buffer[80];
actHealDude(pXSprite, 1, 2); actHealDude(actor, 1, 2);
if (gGameOptions.nGameType > 0 && numplayers > 1) if (gGameOptions.nGameType > 0 && numplayers > 1)
{ {
sfxPlay3DSound(pSprite, 3009, 0, 6); sfxPlay3DSound(pSprite, 3009, 0, 6);

View file

@ -81,6 +81,7 @@ extern POSTURE gPostureDefaults[kModeMax][kPostureMax];
struct PLAYER struct PLAYER
{ {
DBloodActor* actor();
spritetype* pSprite; spritetype* pSprite;
XSPRITE* pXSprite; XSPRITE* pXSprite;
DUDEINFO* pDudeInfo; DUDEINFO* pDudeInfo;