- refactored actDamageSprite

This commit is contained in:
Christoph Oelckers 2020-12-03 00:30:19 +01:00
parent b8dcd09f77
commit fc11f9327a
8 changed files with 228 additions and 165 deletions

View file

@ -33,6 +33,9 @@ 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
@ -2462,7 +2465,7 @@ static void actInitDudes()
for (int i = 0; i < kDudeMax - kDudeBase; i++) for (int i = 0; i < kDudeMax - kDudeBase; i++)
for (int j = 0; j < 7; j++) 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); it.Reset(kStatDude);
while (auto act = it.Next()) 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; DBloodActor* act2 = nullptr;
if (nType >= kItemKeyBase && nType < kItemKeyMax) act2 = actDropKey(pSprite, nType); if (nType >= kItemKeyBase && nType < kItemKeyMax) act2 = actDropKey(actor, nType);
else if (nType == kItemFlagA || nType == kItemFlagB) act2 = actDropFlag(pSprite, nType); else if (nType == kItemFlagA || nType == kItemFlagB) act2 = actDropFlag(actor, nType);
else if (nType >= kItemBase && nType < kItemMax) act2 = actDropItem(pSprite, nType); else if (nType >= kItemBase && nType < kItemMax) act2 = actDropItem(actor, nType);
else if (nType >= kItemAmmoBase && nType < kItemAmmoMax) act2 = actDropAmmo(pSprite, nType); else if (nType >= kItemAmmoBase && nType < kItemAmmoMax) act2 = actDropAmmo(actor, nType);
else if (nType >= kItemWeaponBase && nType < kItemWeaponMax) act2 = actDropWeapon(pSprite, nType); else if (nType >= kItemWeaponBase && nType < kItemWeaponMax) act2 = actDropWeapon(actor, nType);
if (act2) if (act2)
{ {
@ -2967,7 +2970,7 @@ static bool actKillModernDude(DBloodActor* actor, DAMAGE_TYPE damageType)
aiGenDudeNewState(pSprite, &genDudeBurnGoto); aiGenDudeNewState(pSprite, &genDudeBurnGoto);
actHealDude(pXSprite, dudeInfo[55].startHealth, dudeInfo[55].startHealth); actHealDude(pXSprite, dudeInfo[55].startHealth, dudeInfo[55].startHealth);
if (pXSprite->burnTime <= 0) pXSprite->burnTime = 1200; if (pXSprite->burnTime <= 0) pXSprite->burnTime = 1200;
gDudeExtra[pSprite->extra].time = PlayClock + 360; actor->dudeExtra().time = PlayClock + 360;
return true; return true;
} }
@ -3665,126 +3668,136 @@ void actKillDude(DBloodActor* killerActor, DBloodActor* actor, DAMAGE_TYPE damag
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, int damage) { static int actDamageDude(DBloodActor* source, DBloodActor* actor, int damage, DAMAGE_TYPE damageType)
assert(nSource < kMaxSprites); {
auto pSprite = &actor->s();
XSPRITE* pXSprite = &actor->x();
if (pSprite->flags&32 || pSprite->extra <= 0 || pSprite->extra >= kMaxXSprites || xsprite[pSprite->extra].reference != pSprite->index) if (!actor->IsDudeActor())
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"); 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; 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"); //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]; int nType = pSprite->type - kDudeBase;
#ifdef NOONE_EXTENSIONS int nDamageFactor = getDudeInfo(nType + kDudeBase)->damageVal[damageType];
#ifdef NOONE_EXTENSIONS
if (pSprite->type == kDudeModernCustom) if (pSprite->type == kDudeModernCustom)
nDamageFactor = gGenDudeExtra[pSprite->index].dmgControl[damageType]; nDamageFactor = actor->genDudeExtra().dmgControl[damageType];
#endif #endif
if (!nDamageFactor) return 0; if (!nDamageFactor) return 0;
else if (nDamageFactor != 256) else if (nDamageFactor != 256) damage = MulScale(damage, nDamageFactor, 8);
damage = MulScale(damage, nDamageFactor, 8);
if (!IsPlayerSprite(pSprite)) {
if (!IsPlayerSprite(pSprite))
{
if (pXSprite->health <= 0) return 0; if (pXSprite->health <= 0) return 0;
damage = aiDamageSprite(pSprite, pXSprite, nSource, damageType, damage); damage = aiDamageSprite(source, actor, damageType, damage);
if (pXSprite->health <= 0) if (pXSprite->health <= 0)
actKillDude(nSource, pSprite, ((damageType == DAMAGE_TYPE_3 && damage < 160) ? DAMAGE_TYPE_0 : damageType), damage); actKillDude(source, actor, ((damageType == DAMAGE_TYPE_3 && damage < 160) ? DAMAGE_TYPE_0 : damageType), damage);
}
} else { else
{
PLAYER *pPlayer = &gPlayer[pSprite->type - kDudePlayer1]; PLAYER* pPlayer = &gPlayer[pSprite->type - kDudePlayer1];
if (pXSprite->health > 0 || playerSeqPlaying(pPlayer, 16)) if (pXSprite->health > 0 || playerSeqPlaying(pPlayer, 16))
damage = playerDamageSprite(nSource, pPlayer, damageType, damage); damage = playerDamageSprite(source, pPlayer, damageType, damage);
} }
} return damage;
break; }
case kStatThing:
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
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); assert(pSprite->type >= kThingBase && pSprite->type < kThingMax);
int nType = pSprite->type - kThingBase; int nDamageFactor = thingInfo[nType].dmgControl[damageType]; int nType = pSprite->type - kThingBase;
int nDamageFactor = thingInfo[nType].dmgControl[damageType];
if (!nDamageFactor) return 0; if (!nDamageFactor) return 0;
else if (nDamageFactor != 256) else if (nDamageFactor != 256) damage = MulScale(damage, nDamageFactor, 8);
damage = MulScale(damage, nDamageFactor, 8);
pXSprite->health = ClipLow(pXSprite->health - damage, 0); pXSprite->health = ClipLow(pXSprite->health - damage, 0);
if (pXSprite->health <= 0) { if (pXSprite->health <= 0)
switch (pSprite->type) { {
auto Owner = actor->GetOwner();
switch (pSprite->type)
{
case kThingDroppedLifeLeech: case kThingDroppedLifeLeech:
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
case kModernThingEnemyLifeLeech: case kModernThingEnemyLifeLeech:
#endif #endif
GibSprite(pSprite, GIBTYPE_14, NULL, NULL); GibSprite(pSprite, GIBTYPE_14, NULL, NULL);
pXSprite->data1 = pXSprite->data2 = pXSprite->data3 = pXSprite->DudeLockout = 0; pXSprite->data1 = pXSprite->data2 = pXSprite->data3 = pXSprite->DudeLockout = 0;
pXSprite->stateTimer = pXSprite->data4 = pXSprite->isTriggered = 0; pXSprite->stateTimer = pXSprite->data4 = pXSprite->isTriggered = 0;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
if (pSprite->owner >= 0 && sprite[pSprite->owner].type == kDudeModernCustom) if (Owner && Owner->s().type == kDudeModernCustom)
sprite[pSprite->owner].owner = kMaxSprites - 1; // indicates if custom dude had life leech. Owner->SetSpecialOwner(); // indicates if custom dude had life leech.
#endif #endif
break; break;
default: default:
if (!(pSprite->flags & kHitagRespawn)) if (!(pSprite->flags & kHitagRespawn))
pSprite->owner = nSource; actor->SetOwner(source);
break; break;
} }
trTriggerSprite(pSprite->index, pXSprite, kCmdOff); trTriggerSprite(pSprite->index, pXSprite, kCmdOff);
switch (pSprite->type) { switch (pSprite->type)
{
case kThingObjectGib: case kThingObjectGib:
case kThingObjectExplode: case kThingObjectExplode:
case kThingBloodBits: case kThingBloodBits:
case kThingBloodChunks: case kThingBloodChunks:
case kThingZombieHead: case kThingZombieHead:
if (damageType == 3 && pSourcePlayer && PlayClock > pSourcePlayer->laughCount && Chance(0x4000)) { if (damageType == 3 && pSourcePlayer && PlayClock > pSourcePlayer->laughCount && Chance(0x4000))
{
sfxPlay3DSound(pSourcePlayer->pSprite, gPlayerGibThingComments[Random(10)], 0, 2); sfxPlay3DSound(pSourcePlayer->pSprite, gPlayerGibThingComments[Random(10)], 0, 2);
pSourcePlayer->laughCount = PlayClock+3600; pSourcePlayer->laughCount = PlayClock + 3600;
} }
break; break;
case kTrapMachinegun: case kTrapMachinegun:
seqSpawn(28, 3, pSprite->extra, -1); seqSpawn(28, 3, pSprite->extra, -1);
break; break;
case kThingFluorescent: case kThingFluorescent:
seqSpawn(12, 3, pSprite->extra, -1); seqSpawn(12, 3, pSprite->extra, -1);
GibSprite(pSprite, GIBTYPE_6, NULL, NULL); GibSprite(pSprite, GIBTYPE_6, NULL, NULL);
break; break;
case kThingSpiderWeb: case kThingSpiderWeb:
seqSpawn(15, 3, pSprite->extra, -1); seqSpawn(15, 3, pSprite->extra, -1);
break; break;
case kThingMetalGrate: case kThingMetalGrate:
seqSpawn(21, 3, pSprite->extra, -1); seqSpawn(21, 3, pSprite->extra, -1);
GibSprite(pSprite, GIBTYPE_4, NULL, NULL); GibSprite(pSprite, GIBTYPE_4, NULL, NULL);
break; break;
case kThingFlammableTree: case kThingFlammableTree:
switch (pXSprite->data1) { switch (pXSprite->data1)
{
case -1: case -1:
GibSprite(pSprite, GIBTYPE_14, NULL, NULL); GibSprite(pSprite, GIBTYPE_14, NULL, NULL);
sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, 312, pSprite->sectnum); sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, 312, pSprite->sectnum);
actPostSprite(pSprite->index, kStatFree); actPostSprite(actor, kStatFree);
break; break;
case 0: case 0:
seqSpawn(25, 3, pSprite->extra, nTreeToGibClient); seqSpawn(25, actor, nTreeToGibClient);
sfxPlay3DSound(pSprite, 351, -1, 0); sfxPlay3DSound(pSprite, 351, -1, 0);
break; break;
case 1: case 1:
seqSpawn(26, 3, pSprite->extra, nTreeToGibClient); seqSpawn(26, 3, pSprite->extra, nTreeToGibClient);
sfxPlay3DSound(pSprite, 351, -1, 0); sfxPlay3DSound(pSprite, 351, -1, 0);
@ -3793,16 +3806,50 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE damageType, in
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; break;
} }
return damage >> 4; return damage >> 4;
} }
int actDamageSprite(DBloodActor* pSource, DBloodActor* pTarget, DAMAGE_TYPE damageType, int 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)
{ {
@ -3895,7 +3942,7 @@ void actImpactMissile(spritetype *pMissile, int hitCode)
DAMAGE_TYPE rand1 = (DAMAGE_TYPE)Random(7); DAMAGE_TYPE rand1 = (DAMAGE_TYPE)Random(7);
int rand2 = (7 + Random(7)) << 4; int rand2 = (7 + Random(7)) << 4;
int nDamage = actDamageSprite(nOwner, pSpriteHit, rand1, rand2); 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); actBurnSprite(pMissile->owner, pXSpriteHit, 360);
// by NoOne: make Life Leech heal user, just like it was in 1.0x versions // 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); sfxKill3DSound(pMissile, -1, -1);
if ((hitCode == 3 && pSpriteHit) && (pThingInfo || pDudeInfo)) { if ((hitCode == 3 && pSpriteHit) && (pThingInfo || pDudeInfo)) {
int nOwner = pMissile->owner; 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) if (pThingInfo && pSpriteHit->type == kThingTNTBarrel && pXSpriteHit->burnTime == 0)
evPost(nSpriteHit, 3, 0, kCallbackFXFlameLick); evPost(nSpriteHit, 3, 0, kCallbackFXFlameLick);
@ -7185,7 +7232,7 @@ void SerializeActor(FSerializer& arc)
{ {
for (int i = 0; i < kDudeMax - kDudeBase; i++) for (int i = 0; i < kDudeMax - kDudeBase; i++)
for (int j = 0; j < 7; j++) 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); 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 END_BLD_NS

View file

@ -92,7 +92,7 @@ bool isImmune(spritetype* pSprite, int dmgType, int minScale)
else if (IsDudeSprite(pSprite)) else if (IsDudeSprite(pSprite))
{ {
if (IsPlayerSprite(pSprite)) return (gPlayer[pSprite->type - kDudePlayer1].godMode || gPlayer[pSprite->type - kDudePlayer1].damageControl[dmgType] <= minScale); 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) if (!pXSprite->health)
return 0; return 0;
auto actor = &bloodActors[pXSprite->reference];
pXSprite->health = ClipLow(pXSprite->health - nDamage, 0); pXSprite->health = ClipLow(pXSprite->health - nDamage, 0);
cumulDamage[pSprite->extra] += nDamage; cumulDamage[pSprite->extra] += nDamage;
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
int nSprite = pXSprite->reference; int nSprite = pXSprite->reference;
if (nSource >= 0) if (source)
{ {
spritetype *pSource = &sprite[nSource]; spritetype *pSource = &source->s();
int nSource = pSource->index;
if (pSprite == pSource) if (pSprite == pSource)
return 0; return 0;
if (pXSprite->target == -1 || (nSource != pXSprite->target && Chance(pSprite->type == pSource->type ? nDamage*pDudeInfo->changeTargetKin : nDamage*pDudeInfo->changeTarget))) if (pXSprite->target == -1 || (nSource != pXSprite->target && Chance(pSprite->type == pSource->type ? nDamage*pDudeInfo->changeTargetKin : nDamage*pDudeInfo->changeTarget)))

View file

@ -88,7 +88,6 @@ struct TARGETTRACK {
extern const int dword_138BB0[5]; extern const int dword_138BB0[5];
extern DUDEEXTRA gDudeExtra[]; extern DUDEEXTRA gDudeExtra[];
extern int gDudeSlope[];
bool dudeIsPlayingSeq(spritetype *pSprite, int nSeq); bool dudeIsPlayingSeq(spritetype *pSprite, int nSeq);
void aiPlay3DSound(spritetype *pSprite, int a2, AI_SFX_PRIORITY a3, int a4); 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 aiActivateDude(DBloodActor *actor);
void aiSetTarget(XSPRITE *pXSprite, int x, int y, int z); void aiSetTarget(XSPRITE *pXSprite, int x, int y, int z);
void aiSetTarget(XSPRITE *pXSprite, int nTarget); 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 aiThinkTarget(DBloodActor* actor);
void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite); void sub_5F15C(spritetype *pSprite, XSPRITE *pXSprite);
void aiProcessDudes(void); void aiProcessDudes(void);

View file

@ -46,10 +46,20 @@ public:
DBloodActor* GetOwner() DBloodActor* GetOwner()
{ {
if (s().owner == -1) return nullptr; if (s().owner == -1 || s().owner == kMaxSprites-1) return nullptr;
return base() + s().owner; return base() + s().owner;
} }
void SetSpecialOwner() // nnext hackery
{
s().owner = kMaxSprites - 1;
}
bool GetSpecialOwner()
{
return (s().owner == kMaxSprites - 1);
}
bool IsPlayerActor() bool IsPlayerActor()
{ {
return s().type >= kDudePlayer1 && s().type <= kDudePlayer8; return s().type >= kDudePlayer1 && s().type <= kDudePlayer8;

View file

@ -49,7 +49,7 @@ struct DUDEINFO {
int angSpeed; // turn speed int angSpeed; // turn speed
int nGibType[3]; // which gib used when explode dude int nGibType[3]; // which gib used when explode dude
int startDamage[7]; // start damage shift int startDamage[7]; // start damage shift
int at70[7]; // real damage? Hmm? int damageVal[7]; // real damage? Hmm?
int at8c; // unused ? int at8c; // unused ?
int at90; // unused ? int at90; // unused ?
}; };

View file

@ -126,7 +126,7 @@ bool nnExtIsImmune(spritetype* pSprite, int dmgType, int minScale) {
else if (IsDudeSprite(pSprite)) { else if (IsDudeSprite(pSprite)) {
if (IsPlayerSprite(pSprite)) return (gPlayer[pSprite->type - kDudePlayer1].damageControl[dmgType]); if (IsPlayerSprite(pSprite)) return (gPlayer[pSprite->type - kDudePlayer1].damageControl[dmgType]);
else if (pSprite->type == kDudeModernCustom) return (gGenDudeExtra[pSprite->index].dmgControl[dmgType] <= minScale); 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 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 ((pXSprite->health = ClipLow(pXSprite->health - dmg, 1)) > 16) return;
else if (!pPlayer) actKillDude(pSource->index, pSprite, DAMAGE_TYPE_2, dmg); 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; return;
} }

View file

@ -581,7 +581,7 @@ void playerSetRace(PLAYER *pPlayer, int nLifeMode)
pPlayer->pSprite->clipdist = pDudeInfo->clipdist; pPlayer->pSprite->clipdist = pDudeInfo->clipdist;
for (int i = 0; i < 7; i++) 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) void playerSetGodMode(PLAYER *pPlayer, bool bGodMode)
@ -1882,9 +1882,9 @@ spritetype *flagDropped(PLAYER *pPlayer, int a2)
return pSprite; 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); assert(pPlayer != NULL);
if (pPlayer->damageControl[nDamageType] || pPlayer->godMode) if (pPlayer->damageControl[nDamageType] || pPlayer->godMode)
return 0; return 0;
@ -2115,7 +2115,7 @@ void PlayerKneelsOver(int, DBloodActor* actor)
if (gPlayer[p].pXSprite == pXSprite) if (gPlayer[p].pXSprite == pXSprite)
{ {
PLAYER *pPlayer = &gPlayer[p]; PLAYER *pPlayer = &gPlayer[p];
playerDamageSprite(pPlayer->fraggerId, pPlayer, DAMAGE_TYPE_5, 500<<4); playerDamageSprite(pPlayer->fragger(), pPlayer, DAMAGE_TYPE_5, 500<<4);
return; return;
} }
} }

View file

@ -274,7 +274,7 @@ void playerFrag(PLAYER *pKiller, PLAYER *pVictim);
void FragPlayer(PLAYER *pPlayer, int nSprite); void FragPlayer(PLAYER *pPlayer, int nSprite);
int playerDamageArmor(PLAYER *pPlayer, DAMAGE_TYPE nType, int nDamage); int playerDamageArmor(PLAYER *pPlayer, DAMAGE_TYPE nType, int nDamage);
spritetype *flagDropped(PLAYER *pPlayer, int a2); 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); int UseAmmo(PLAYER *pPlayer, int nAmmoType, int nDec);
void voodooTarget(PLAYER *pPlayer); void voodooTarget(PLAYER *pPlayer);
void playerLandingSound(PLAYER *pPlayer); void playerLandingSound(PLAYER *pPlayer);