From b1074c300bdaa9fd10c18be2340faddde1d63804 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 3 Dec 2020 00:30:19 +0100 Subject: [PATCH] - refactored actDamageSprite --- source/games/blood/src/actor.cpp | 346 ++++++++++++++++------------ source/games/blood/src/ai.cpp | 14 +- source/games/blood/src/ai.h | 3 +- source/games/blood/src/bloodactor.h | 12 +- source/games/blood/src/dude.h | 2 +- source/games/blood/src/nnexts.cpp | 6 +- source/games/blood/src/player.cpp | 8 +- source/games/blood/src/player.h | 2 +- 8 files changed, 228 insertions(+), 165 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 311032e46..03e9743d4 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -33,6 +33,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 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... // Tine @@ -2462,7 +2465,7 @@ static void actInitDudes() for (int i = 0; i < kDudeMax - kDudeBase; i++) for (int j = 0; j < 7; j++) - dudeInfo[i].at70[j] = MulScale(DudeDifficulty[gGameOptions.nDifficulty], dudeInfo[i].startDamage[j], 8); + dudeInfo[i].damageVal[j] = MulScale(DudeDifficulty[gGameOptions.nDifficulty], dudeInfo[i].startDamage[j], 8); it.Reset(kStatDude); while (auto act = it.Next()) @@ -2890,15 +2893,15 @@ static DBloodActor* actDropFlag(DBloodActor* actor, int nType) // //--------------------------------------------------------------------------- -static DBloodActor* actDropObject(DBloodActor* pSprite, int nType) +static DBloodActor* actDropObject(DBloodActor* actor, int nType) { DBloodActor* act2 = nullptr; - if (nType >= kItemKeyBase && nType < kItemKeyMax) act2 = actDropKey(pSprite, nType); - else if (nType == kItemFlagA || nType == kItemFlagB) act2 = actDropFlag(pSprite, nType); - else if (nType >= kItemBase && nType < kItemMax) act2 = actDropItem(pSprite, nType); - else if (nType >= kItemAmmoBase && nType < kItemAmmoMax) act2 = actDropAmmo(pSprite, nType); - else if (nType >= kItemWeaponBase && nType < kItemWeaponMax) act2 = actDropWeapon(pSprite, nType); + if (nType >= kItemKeyBase && nType < kItemKeyMax) act2 = actDropKey(actor, nType); + else if (nType == kItemFlagA || nType == kItemFlagB) act2 = actDropFlag(actor, nType); + else if (nType >= kItemBase && nType < kItemMax) act2 = actDropItem(actor, nType); + else if (nType >= kItemAmmoBase && nType < kItemAmmoMax) act2 = actDropAmmo(actor, nType); + else if (nType >= kItemWeaponBase && nType < kItemWeaponMax) act2 = actDropWeapon(actor, nType); if (act2) { @@ -2967,7 +2970,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType) aiGenDudeNewState(pSprite, &genDudeBurnGoto); actHealDude(pXSprite, dudeInfo[55].startHealth, dudeInfo[55].startHealth); if (pXSprite->burnTime <= 0) pXSprite->burnTime = 1200; - gDudeExtra[pSprite->extra].time = PlayClock + 360; + actor->dudeExtra().time = PlayClock + 360; return true; } @@ -3665,145 +3668,189 @@ void actKillDude(DBloodActor* killerActor, DBloodActor* actor, DAMAGE_TYPE damag // //--------------------------------------------------------------------------- -int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, int damage) { - assert(nSource < kMaxSprites); - - if (pSprite->flags&32 || pSprite->extra <= 0 || pSprite->extra >= kMaxXSprites || xsprite[pSprite->extra].reference != pSprite->index) - return 0; - - XSPRITE *pXSprite = &xsprite[pSprite->extra]; - if ((pXSprite->health == 0 && pSprite->statnum != kStatDude) || pXSprite->locked) - return 0; - - if (nSource == -1) - nSource = pSprite->index; - - PLAYER *pSourcePlayer = NULL; - if (IsPlayerSprite(&sprite[nSource])) pSourcePlayer = &gPlayer[sprite[nSource].type - kDudePlayer1]; - if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pSourcePlayer, pSprite)) return 0; - - switch (pSprite->statnum) { - case kStatDude: { - if (!IsDudeSprite(pSprite)) { - Printf(PRINT_HIGH, "Bad Dude Failed: initial=%d type=%d %s\n", (int)pSprite->inittype, (int)pSprite->type, (int)(pSprite->flags & kHitagRespawn) ? "RESPAWN" : "NORMAL"); - return damage >> 4; - //I_Error("Bad Dude Failed: initial=%d type=%d %s\n", (int)pSprite->inittype, (int)pSprite->type, (int)(pSprite->flags & 16) ? "RESPAWN" : "NORMAL"); - } - - int nType = pSprite->type - kDudeBase; int nDamageFactor = getDudeInfo(nType+kDudeBase)->at70[damageType]; - #ifdef NOONE_EXTENSIONS - if (pSprite->type == kDudeModernCustom) - nDamageFactor = gGenDudeExtra[pSprite->index].dmgControl[damageType]; - #endif - - if (!nDamageFactor) return 0; - else if (nDamageFactor != 256) - damage = MulScale(damage, nDamageFactor, 8); - - if (!IsPlayerSprite(pSprite)) { - - if (pXSprite->health <= 0) return 0; - damage = aiDamageSprite(pSprite, pXSprite, nSource, damageType, damage); - if (pXSprite->health <= 0) - actKillDude(nSource, pSprite, ((damageType == DAMAGE_TYPE_3 && damage < 160) ? DAMAGE_TYPE_0 : damageType), damage); - - } else { - - PLAYER *pPlayer = &gPlayer[pSprite->type - kDudePlayer1]; - if (pXSprite->health > 0 || playerSeqPlaying(pPlayer, 16)) - damage = playerDamageSprite(nSource, pPlayer, damageType, damage); - - } - } - break; - case kStatThing: - assert(pSprite->type >= kThingBase && pSprite->type < kThingMax); - int nType = pSprite->type - kThingBase; int nDamageFactor = thingInfo[nType].dmgControl[damageType]; - - if (!nDamageFactor) return 0; - else if (nDamageFactor != 256) - damage = MulScale(damage, nDamageFactor, 8); - - pXSprite->health = ClipLow(pXSprite->health - damage, 0); - if (pXSprite->health <= 0) { - switch (pSprite->type) { - case kThingDroppedLifeLeech: - #ifdef NOONE_EXTENSIONS - case kModernThingEnemyLifeLeech: - #endif - GibSprite(pSprite, GIBTYPE_14, NULL, NULL); - pXSprite->data1 = pXSprite->data2 = pXSprite->data3 = pXSprite->DudeLockout = 0; - pXSprite->stateTimer = pXSprite->data4 = pXSprite->isTriggered = 0; - - #ifdef NOONE_EXTENSIONS - if (pSprite->owner >= 0 && sprite[pSprite->owner].type == kDudeModernCustom) - sprite[pSprite->owner].owner = kMaxSprites - 1; // indicates if custom dude had life leech. - #endif - break; - - default: - if (!(pSprite->flags & kHitagRespawn)) - pSprite->owner = nSource; - break; - } - - trTriggerSprite(pSprite->index, pXSprite, kCmdOff); - - switch (pSprite->type) { - case kThingObjectGib: - case kThingObjectExplode: - case kThingBloodBits: - case kThingBloodChunks: - case kThingZombieHead: - if (damageType == 3 && pSourcePlayer && PlayClock > pSourcePlayer->laughCount && Chance(0x4000)) { - sfxPlay3DSound(pSourcePlayer->pSprite, gPlayerGibThingComments[Random(10)], 0, 2); - pSourcePlayer->laughCount = PlayClock+3600; - } - break; - case kTrapMachinegun: - seqSpawn(28, 3, pSprite->extra, -1); - break; - case kThingFluorescent: - seqSpawn(12, 3, pSprite->extra, -1); - GibSprite(pSprite, GIBTYPE_6, NULL, NULL); - break; - case kThingSpiderWeb: - seqSpawn(15, 3, pSprite->extra, -1); - break; - case kThingMetalGrate: - seqSpawn(21, 3, pSprite->extra, -1); - GibSprite(pSprite, GIBTYPE_4, NULL, NULL); - break; - case kThingFlammableTree: - switch (pXSprite->data1) { - case -1: - GibSprite(pSprite, GIBTYPE_14, NULL, NULL); - sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, 312, pSprite->sectnum); - actPostSprite(pSprite->index, kStatFree); - break; - case 0: - seqSpawn(25, 3, pSprite->extra, nTreeToGibClient); - sfxPlay3DSound(pSprite, 351, -1, 0); - break; - case 1: - seqSpawn(26, 3, pSprite->extra, nTreeToGibClient); - sfxPlay3DSound(pSprite, 351, -1, 0); - break; - } - break; - } - } - break; - } - - return damage >> 4; -} - -int actDamageSprite(DBloodActor* pSource, DBloodActor* pTarget, DAMAGE_TYPE damageType, int damage) +static int actDamageDude(DBloodActor* source, DBloodActor* actor, int damage, DAMAGE_TYPE damageType) { - return actDamageSprite(pSource? pSource->s().index : -1, &pTarget->s(), damageType, damage); + auto pSprite = &actor->s(); + XSPRITE* pXSprite = &actor->x(); + + if (!actor->IsDudeActor()) + { + Printf(PRINT_HIGH, "Bad Dude Failed: initial=%d type=%d %s\n", (int)pSprite->inittype, (int)pSprite->type, (int)(pSprite->flags & kHitagRespawn) ? "RESPAWN" : "NORMAL"); + return damage >> 4; + //I_Error("Bad Dude Failed: initial=%d type=%d %s\n", (int)pSprite->inittype, (int)pSprite->type, (int)(pSprite->flags & 16) ? "RESPAWN" : "NORMAL"); + } + + int nType = pSprite->type - kDudeBase; + int nDamageFactor = getDudeInfo(nType + kDudeBase)->damageVal[damageType]; +#ifdef NOONE_EXTENSIONS + if (pSprite->type == kDudeModernCustom) + nDamageFactor = actor->genDudeExtra().dmgControl[damageType]; +#endif + + if (!nDamageFactor) return 0; + else if (nDamageFactor != 256) damage = MulScale(damage, nDamageFactor, 8); + + if (!IsPlayerSprite(pSprite)) + { + if (pXSprite->health <= 0) return 0; + damage = aiDamageSprite(source, actor, damageType, damage); + if (pXSprite->health <= 0) + actKillDude(source, actor, ((damageType == DAMAGE_TYPE_3 && damage < 160) ? DAMAGE_TYPE_0 : damageType), damage); + } + else + { + PLAYER* pPlayer = &gPlayer[pSprite->type - kDudePlayer1]; + if (pXSprite->health > 0 || playerSeqPlaying(pPlayer, 16)) + damage = playerDamageSprite(source, pPlayer, damageType, damage); + + } + return damage; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static int actDamageThing(DBloodActor* source, DBloodActor* actor, int damage, DAMAGE_TYPE damageType, PLAYER* pSourcePlayer) +{ + auto pSprite = &actor->s(); + XSPRITE* pXSprite = &actor->x(); + + assert(pSprite->type >= kThingBase && pSprite->type < kThingMax); + int nType = pSprite->type - kThingBase; + int nDamageFactor = thingInfo[nType].dmgControl[damageType]; + + if (!nDamageFactor) return 0; + else if (nDamageFactor != 256) damage = MulScale(damage, nDamageFactor, 8); + + pXSprite->health = ClipLow(pXSprite->health - damage, 0); + if (pXSprite->health <= 0) + { + auto Owner = actor->GetOwner(); + switch (pSprite->type) + { + case kThingDroppedLifeLeech: +#ifdef NOONE_EXTENSIONS + case kModernThingEnemyLifeLeech: +#endif + GibSprite(pSprite, GIBTYPE_14, NULL, NULL); + pXSprite->data1 = pXSprite->data2 = pXSprite->data3 = pXSprite->DudeLockout = 0; + pXSprite->stateTimer = pXSprite->data4 = pXSprite->isTriggered = 0; + +#ifdef NOONE_EXTENSIONS + if (Owner && Owner->s().type == kDudeModernCustom) + Owner->SetSpecialOwner(); // indicates if custom dude had life leech. +#endif + break; + + default: + if (!(pSprite->flags & kHitagRespawn)) + actor->SetOwner(source); + break; + } + + trTriggerSprite(pSprite->index, pXSprite, kCmdOff); + + switch (pSprite->type) + { + case kThingObjectGib: + case kThingObjectExplode: + case kThingBloodBits: + case kThingBloodChunks: + case kThingZombieHead: + if (damageType == 3 && pSourcePlayer && PlayClock > pSourcePlayer->laughCount && Chance(0x4000)) + { + sfxPlay3DSound(pSourcePlayer->pSprite, gPlayerGibThingComments[Random(10)], 0, 2); + pSourcePlayer->laughCount = PlayClock + 3600; + } + break; + case kTrapMachinegun: + seqSpawn(28, 3, pSprite->extra, -1); + break; + + case kThingFluorescent: + seqSpawn(12, 3, pSprite->extra, -1); + GibSprite(pSprite, GIBTYPE_6, NULL, NULL); + break; + + case kThingSpiderWeb: + seqSpawn(15, 3, pSprite->extra, -1); + break; + + case kThingMetalGrate: + seqSpawn(21, 3, pSprite->extra, -1); + GibSprite(pSprite, GIBTYPE_4, NULL, NULL); + break; + + case kThingFlammableTree: + switch (pXSprite->data1) + { + case -1: + GibSprite(pSprite, GIBTYPE_14, NULL, NULL); + sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, 312, pSprite->sectnum); + actPostSprite(actor, kStatFree); + break; + + case 0: + seqSpawn(25, actor, nTreeToGibClient); + sfxPlay3DSound(pSprite, 351, -1, 0); + break; + + case 1: + seqSpawn(26, 3, pSprite->extra, nTreeToGibClient); + sfxPlay3DSound(pSprite, 351, -1, 0); + break; + } + break; + } + } + return damage; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +int actDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE damageType, int damage) +{ + auto pSprite = &actor->s(); + + if (pSprite->flags & 32 || !actor->hasX()) + return 0; + + XSPRITE* pXSprite = &actor->x(); + if ((pXSprite->health == 0 && pSprite->statnum != kStatDude) || pXSprite->locked) + return 0; + + if (source == nullptr) source = actor; + + PLAYER* pSourcePlayer = NULL; + if (source->IsPlayerActor()) pSourcePlayer = &gPlayer[source->s().type - kDudePlayer1]; + if (!gGameOptions.bFriendlyFire && IsTargetTeammate(pSourcePlayer, pSprite)) return 0; + + switch (pSprite->statnum) + { + case kStatDude: + damage = actDamageDude(source, actor, damage, damageType); + break; + case kStatThing: + damage = actDamageThing(source, actor, damage, damageType, pSourcePlayer); + break; + } + + return damage >> 4; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void actHitcodeToData(int a1, HITINFO *pHitInfo, int *a3, spritetype **a4, XSPRITE **a5, int *a6, walltype **a7, XWALL **a8, int *a9, sectortype **a10, XSECTOR **a11) { assert(pHitInfo != NULL); @@ -3895,7 +3942,7 @@ void actImpactMissile(spritetype *pMissile, int hitCode) DAMAGE_TYPE rand1 = (DAMAGE_TYPE)Random(7); int rand2 = (7 + Random(7)) << 4; int nDamage = actDamageSprite(nOwner, pSpriteHit, rand1, rand2); - if ((pThingInfo && pThingInfo->dmgControl[DAMAGE_TYPE_1] != 0) || (pDudeInfo && pDudeInfo->at70[DAMAGE_TYPE_1] != 0)) + if ((pThingInfo && pThingInfo->dmgControl[DAMAGE_TYPE_1] != 0) || (pDudeInfo && pDudeInfo->damageVal[DAMAGE_TYPE_1] != 0)) actBurnSprite(pMissile->owner, pXSpriteHit, 360); // by NoOne: make Life Leech heal user, just like it was in 1.0x versions @@ -3987,7 +4034,7 @@ void actImpactMissile(spritetype *pMissile, int hitCode) sfxKill3DSound(pMissile, -1, -1); if ((hitCode == 3 && pSpriteHit) && (pThingInfo || pDudeInfo)) { int nOwner = pMissile->owner; - if ((pThingInfo && pThingInfo->dmgControl[DAMAGE_TYPE_1] != 0) || (pDudeInfo && pDudeInfo->at70[DAMAGE_TYPE_1] != 0)) { + if ((pThingInfo && pThingInfo->dmgControl[DAMAGE_TYPE_1] != 0) || (pDudeInfo && pDudeInfo->damageVal[DAMAGE_TYPE_1] != 0)) { if (pThingInfo && pSpriteHit->type == kThingTNTBarrel && pXSpriteHit->burnTime == 0) evPost(nSpriteHit, 3, 0, kCallbackFXFlameLick); @@ -7185,7 +7232,7 @@ void SerializeActor(FSerializer& arc) { for (int i = 0; i < kDudeMax - kDudeBase; i++) for (int j = 0; j < 7; j++) - dudeInfo[i].at70[j] = MulScale(DudeDifficulty[gGameOptions.nDifficulty], dudeInfo[i].startDamage[j], 8); + dudeInfo[i].damageVal[j] = MulScale(DudeDifficulty[gGameOptions.nDifficulty], dudeInfo[i].startDamage[j], 8); } } } @@ -7206,5 +7253,10 @@ 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) +{ + return actDamageSprite(nSource == -1 ? nullptr : &bloodActors[nSource], &bloodActors[pSprite->index], damageType, damage); +} + END_BLD_NS diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index 347f94c34..beac0ff94 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -92,7 +92,7 @@ bool isImmune(spritetype* pSprite, int dmgType, int minScale) else if (IsDudeSprite(pSprite)) { if (IsPlayerSprite(pSprite)) return (gPlayer[pSprite->type - kDudePlayer1].godMode || gPlayer[pSprite->type - kDudePlayer1].damageControl[dmgType] <= minScale); - else return (dudeInfo[pSprite->type - kDudeBase].at70[dmgType] <= minScale); + else return (dudeInfo[pSprite->type - kDudeBase].damageVal[dmgType] <= minScale); } } @@ -878,19 +878,21 @@ void aiSetTarget(XSPRITE *pXSprite, int nTarget) } -int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_TYPE nDmgType, int nDamage) +int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType, int nDamage) { - assert(nSource < kMaxSprites); + auto pSprite = &actor->s(); + XSPRITE* pXSprite = &actor->x(); + if (!pXSprite->health) return 0; - auto actor = &bloodActors[pXSprite->reference]; pXSprite->health = ClipLow(pXSprite->health - nDamage, 0); cumulDamage[pSprite->extra] += nDamage; DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); int nSprite = pXSprite->reference; - if (nSource >= 0) + if (source) { - spritetype *pSource = &sprite[nSource]; + spritetype *pSource = &source->s(); + int nSource = pSource->index; if (pSprite == pSource) return 0; if (pXSprite->target == -1 || (nSource != pXSprite->target && Chance(pSprite->type == pSource->type ? nDamage*pDudeInfo->changeTargetKin : nDamage*pDudeInfo->changeTarget))) diff --git a/source/games/blood/src/ai.h b/source/games/blood/src/ai.h index 5061ce60e..ca0eef908 100644 --- a/source/games/blood/src/ai.h +++ b/source/games/blood/src/ai.h @@ -88,7 +88,6 @@ struct TARGETTRACK { extern const int dword_138BB0[5]; extern DUDEEXTRA gDudeExtra[]; -extern int gDudeSlope[]; bool dudeIsPlayingSeq(spritetype *pSprite, int nSeq); void aiPlay3DSound(spritetype *pSprite, int a2, AI_SFX_PRIORITY a3, int a4); @@ -100,7 +99,7 @@ void aiMoveDodge(DBloodActor *actor); void aiActivateDude(DBloodActor *actor); void aiSetTarget(XSPRITE *pXSprite, int x, int y, int z); void aiSetTarget(XSPRITE *pXSprite, int nTarget); -int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_TYPE nDmgType, int nDamage); +int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType, int nDamage); void aiThinkTarget(DBloodActor* actor); void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite); void aiProcessDudes(void); diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index e5a058b7b..4947650ea 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -46,10 +46,20 @@ public: DBloodActor* GetOwner() { - if (s().owner == -1) return nullptr; + if (s().owner == -1 || s().owner == kMaxSprites-1) return nullptr; return base() + s().owner; } + void SetSpecialOwner() // nnext hackery + { + s().owner = kMaxSprites - 1; + } + + bool GetSpecialOwner() + { + return (s().owner == kMaxSprites - 1); + } + bool IsPlayerActor() { return s().type >= kDudePlayer1 && s().type <= kDudePlayer8; diff --git a/source/games/blood/src/dude.h b/source/games/blood/src/dude.h index 5bf74b744..57d065a77 100644 --- a/source/games/blood/src/dude.h +++ b/source/games/blood/src/dude.h @@ -49,7 +49,7 @@ struct DUDEINFO { int angSpeed; // turn speed int nGibType[3]; // which gib used when explode dude int startDamage[7]; // start damage shift - int at70[7]; // real damage? Hmm? + int damageVal[7]; // real damage? Hmm? int at8c; // unused ? int at90; // unused ? }; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index ecbd18e60..c49388ef7 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -126,7 +126,7 @@ bool nnExtIsImmune(spritetype* pSprite, int dmgType, int minScale) { else if (IsDudeSprite(pSprite)) { if (IsPlayerSprite(pSprite)) return (gPlayer[pSprite->type - kDudePlayer1].damageControl[dmgType]); else if (pSprite->type == kDudeModernCustom) return (gGenDudeExtra[pSprite->index].dmgControl[dmgType] <= minScale); - else return (getDudeInfo(pSprite->type)->at70[dmgType] <= minScale); + else return (getDudeInfo(pSprite->type)->damageVal[dmgType] <= minScale); } } @@ -2335,11 +2335,11 @@ void useSpriteDamager(XSPRITE* pXSource, spritetype* pSprite) { } else if (!pPlayer) actKillDude(pSource->index, pSprite, (DAMAGE_TYPE)dmgType, dmg); - else playerDamageSprite(pSource->index, pPlayer, (DAMAGE_TYPE)dmgType, dmg); + else playerDamageSprite(&bloodActors[pSource->index], pPlayer, (DAMAGE_TYPE)dmgType, dmg); } else if ((pXSprite->health = ClipLow(pXSprite->health - dmg, 1)) > 16) return; else if (!pPlayer) actKillDude(pSource->index, pSprite, DAMAGE_TYPE_2, dmg); - else playerDamageSprite(pSource->index, pPlayer, DAMAGE_TYPE_2, dmg); + else playerDamageSprite(&bloodActors[pSource->index], pPlayer, DAMAGE_TYPE_2, dmg); return; } diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index a42428bd3..b32c5e76d 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -581,7 +581,7 @@ void playerSetRace(PLAYER *pPlayer, int nLifeMode) pPlayer->pSprite->clipdist = pDudeInfo->clipdist; for (int i = 0; i < 7; i++) - pDudeInfo->at70[i] = MulScale(Handicap[gSkill], pDudeInfo->startDamage[i], 8); + pDudeInfo->damageVal[i] = MulScale(Handicap[gSkill], pDudeInfo->startDamage[i], 8); } void playerSetGodMode(PLAYER *pPlayer, bool bGodMode) @@ -1882,9 +1882,9 @@ spritetype *flagDropped(PLAYER *pPlayer, int a2) return pSprite; } -int playerDamageSprite(int nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, int nDamage) +int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, int nDamage) { - assert(nSource < kMaxSprites); + int nSource = source ? source->s().index : -1; assert(pPlayer != NULL); if (pPlayer->damageControl[nDamageType] || pPlayer->godMode) return 0; @@ -2115,7 +2115,7 @@ void PlayerKneelsOver(int, DBloodActor* actor) if (gPlayer[p].pXSprite == pXSprite) { PLAYER *pPlayer = &gPlayer[p]; - playerDamageSprite(pPlayer->fraggerId, pPlayer, DAMAGE_TYPE_5, 500<<4); + playerDamageSprite(pPlayer->fragger(), pPlayer, DAMAGE_TYPE_5, 500<<4); return; } } diff --git a/source/games/blood/src/player.h b/source/games/blood/src/player.h index bec6d98a7..245042027 100644 --- a/source/games/blood/src/player.h +++ b/source/games/blood/src/player.h @@ -274,7 +274,7 @@ void playerFrag(PLAYER *pKiller, PLAYER *pVictim); void FragPlayer(PLAYER *pPlayer, int nSprite); int playerDamageArmor(PLAYER *pPlayer, DAMAGE_TYPE nType, int nDamage); spritetype *flagDropped(PLAYER *pPlayer, int a2); -int playerDamageSprite(int nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, int nDamage); +int playerDamageSprite(DBloodActor* nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, int nDamage); int UseAmmo(PLAYER *pPlayer, int nAmmoType, int nDec); void voodooTarget(PLAYER *pPlayer); void playerLandingSound(PLAYER *pPlayer);