- split actInit into several smaller functions.

This commit is contained in:
Christoph Oelckers 2020-12-02 20:22:13 +01:00
parent eee972d446
commit 51205fbdac
2 changed files with 254 additions and 180 deletions

View file

@ -2342,6 +2342,9 @@ static const short gPlayerGibThingComments[] = {
734, 735, 736, 737, 738, 739, 740, 741, 3038, 3049 734, 735, 736, 737, 738, 739, 740, 741, 3038, 3049
}; };
const int DudeDifficulty[5] = {
512, 384, 256, 208, 160
};
int gPostCount = 0; int gPostCount = 0;
@ -2352,6 +2355,12 @@ struct POSTPONE {
POSTPONE gPost[kMaxSprites]; POSTPONE gPost[kMaxSprites];
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool IsUnderwaterSector(int nSector) bool IsUnderwaterSector(int nSector)
{ {
int nXSector = sector[nSector].extra; int nXSector = sector[nSector].extra;
@ -2360,55 +2369,39 @@ bool IsUnderwaterSector(int nSector)
return 0; return 0;
} }
const int DudeDifficulty[5] = { //---------------------------------------------------------------------------
512, 384, 256, 208, 160 //
}; //
//
//---------------------------------------------------------------------------
void actInit(bool bSaveLoad) void actInitTraps()
{ {
BloodStatIterator it(kStatTraps);
#ifdef NOONE_EXTENSIONS
if (!gModernMap)
{
//Printf("> This map *does not* provides modern features.\n");
nnExtResetGlobals();
}
else
{
//Printf("> This map provides modern features.\n");
nnExtInitModernStuff(bSaveLoad);
}
#endif
BloodStatIterator it(kStatItem);
while (auto act = it.Next()) while (auto act = it.Next())
{ {
switch (act->s().type) spritetype* pSprite = &act->s();
if (pSprite->type == kTrapExploder)
{ {
case kItemWeaponVoodooDoll:
act->s().type = kAmmoItemVoodooDoll;
break;
}
}
it.Reset(kStatTraps);
while (auto act = it.Next())
{
spritetype *pSprite = &act->s();
auto x = &act->x();
switch (pSprite->type)
{
case kTrapExploder:
pSprite->cstat &= ~1; pSprite->cstat &= ~1;
pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; pSprite->cstat |= CSTAT_SPRITE_INVISIBLE;
if (pSprite->extra <= 0 || pSprite->extra >= kMaxXSprites) continue; if (!act->hasX()) continue;
auto x = &act->x();
x->waitTime = ClipLow(x->waitTime, 1); x->waitTime = ClipLow(x->waitTime, 1);
x->state = 0; x->state = 0;
break;
} }
} }
}
it.Reset(kStatThing); //---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void actInitThings()
{
BloodStatIterator it(kStatThing);
while (auto act = it.Next()) while (auto act = it.Next())
{ {
if (!act->hasX()) continue; if (!act->hasX()) continue;
@ -2417,12 +2410,12 @@ void actInit(bool bSaveLoad)
int nType = pSprite->type - kThingBase; int nType = pSprite->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.
// this is especially useful for various Gib and Explode objects which have clipdist 1 for some reason predefined, // this is especially useful for various Gib and Explode objects which have clipdist 1 for some reason predefined,
// 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; pSprite->clipdist = thingInfo[nType].clipdist;
pSprite->flags = thingInfo[nType].flags; pSprite->flags = thingInfo[nType].flags;
@ -2432,13 +2425,13 @@ void actInit(bool bSaveLoad)
switch (pSprite->type) { switch (pSprite->type) {
case kThingArmedProxBomb: case kThingArmedProxBomb:
case kTrapMachinegun: case kTrapMachinegun:
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
case kModernThingTNTProx: case kModernThingTNTProx:
#endif #endif
pXSprite->state = 0; pXSprite->state = 0;
break; break;
case kThingBloodChunks: { case kThingBloodChunks: {
SEQINST *pInst = GetInstance(3, pSprite->extra); SEQINST* pInst = GetInstance(3, pSprite->extra);
if (pInst) if (pInst)
{ {
auto seq = getSequence(pInst->nSeqID); auto seq = getSequence(pInst->nSeqID);
@ -2452,14 +2445,23 @@ void actInit(bool bSaveLoad)
break; break;
} }
} }
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void actInitDudes()
{
if (gGameOptions.nMonsterSettings == 0) if (gGameOptions.nMonsterSettings == 0)
{ {
gKillMgr.SetCount(0); gKillMgr.SetCount(0);
BloodStatIterator it(kStatDude); BloodStatIterator it(kStatDude);
while (auto act = it.Next()) while (auto act = it.Next())
{ {
spritetype *pSprite = &act->s(); spritetype* pSprite = &act->s();
if (act->hasX() && act->x().key > 0) // Drop Key if (act->hasX() && act->x().key > 0) // Drop Key
actDropObject(pSprite, kItemKeyBase + (act->x().key - 1)); actDropObject(pSprite, kItemKeyBase + (act->x().key - 1));
DeleteSprite(act); DeleteSprite(act);
@ -2469,12 +2471,12 @@ void actInit(bool bSaveLoad)
{ {
// by NoOne: WTF is this? // by NoOne: WTF is this?
/////////////// ///////////////
char unk[kDudeMax-kDudeBase]; char unk[kDudeMax - kDudeBase];
memset(unk, 0, sizeof(unk)); memset(unk, 0, sizeof(unk));
BloodStatIterator it(kStatDude); BloodStatIterator it(kStatDude);
while (auto act = it.Next()) while (auto act = it.Next())
{ {
spritetype *pSprite = &act->s(); spritetype* pSprite = &act->s();
if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax) if (pSprite->type < kDudeBase || pSprite->type >= kDudeMax)
I_Error("Non-enemy sprite (%d) in the enemy sprite list.\n", pSprite->index); I_Error("Non-enemy sprite (%d) in the enemy sprite list.\n", pSprite->index);
unk[pSprite->type - kDudeBase] = 1; unk[pSprite->type - kDudeBase] = 1;
@ -2491,14 +2493,14 @@ void actInit(bool bSaveLoad)
while (auto act = it.Next()) while (auto act = it.Next())
{ {
if (!act->hasX()) continue; if (!act->hasX()) continue;
spritetype *pSprite = &act->s(); spritetype* pSprite = &act->s();
XSPRITE *pXSprite = &act->x(); XSPRITE* pXSprite = &act->x();
int nType = pSprite->type - kDudeBase; int nType = pSprite->type - kDudeBase;
int seqStartId = dudeInfo[nType].seqStartID; int seqStartId = dudeInfo[nType].seqStartID;
if (!IsPlayerSprite(pSprite)) if (!act->IsPlayerActor())
{ {
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
switch (pSprite->type) switch (pSprite->type)
{ {
case kDudeModernCustom: case kDudeModernCustom:
@ -2511,26 +2513,26 @@ void actInit(bool bSaveLoad)
case kDudePodMother: // FakeDude type (no seq, custom flags, clipdist and cstat) case kDudePodMother: // FakeDude type (no seq, custom flags, clipdist and cstat)
if (gModernMap) break; if (gModernMap) break;
fallthrough__; [[fallthrough]];
default: default:
pSprite->clipdist = dudeInfo[nType].clipdist; pSprite->clipdist = dudeInfo[nType].clipdist;
pSprite->cstat |= 4096 + CSTAT_SPRITE_BLOCK_HITSCAN + CSTAT_SPRITE_BLOCK; pSprite->cstat |= 4096 + CSTAT_SPRITE_BLOCK_HITSCAN + CSTAT_SPRITE_BLOCK;
break; break;
} }
#else #else
pSprite->clipdist = dudeInfo[nType].clipdist; pSprite->clipdist = dudeInfo[nType].clipdist;
pSprite->cstat |= 4096 + CSTAT_SPRITE_BLOCK_HITSCAN + CSTAT_SPRITE_BLOCK; pSprite->cstat |= 4096 + CSTAT_SPRITE_BLOCK_HITSCAN + CSTAT_SPRITE_BLOCK;
#endif #endif
act->xvel() = act->yvel() = act->zvel() = 0; act->xvel() = act->yvel() = act->zvel() = 0;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
// add a way to set custom hp for every enemy - should work only if map just started and not loaded. // add a way to set custom hp for every enemy - should work only if map just started and not loaded.
if (!gModernMap || pXSprite->sysData2 <= 0) pXSprite->health = dudeInfo[nType].startHealth << 4; if (!gModernMap || pXSprite->sysData2 <= 0) pXSprite->health = dudeInfo[nType].startHealth << 4;
else pXSprite->health = ClipRange(pXSprite->sysData2 << 4, 1, 65535); else pXSprite->health = ClipRange(pXSprite->sysData2 << 4, 1, 65535);
#else #else
pXSprite->health = dudeInfo[nType].startHealth << 4; pXSprite->health = dudeInfo[nType].startHealth << 4;
#endif #endif
} }
@ -2540,6 +2542,41 @@ void actInit(bool bSaveLoad)
} }
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void actInit(bool bSaveLoad)
{
#ifdef NOONE_EXTENSIONS
if (!gModernMap) nnExtResetGlobals();
else nnExtInitModernStuff(bSaveLoad);
#endif
BloodStatIterator it(kStatItem);
while (auto act = it.Next())
{
if (act->s().type == kItemWeaponVoodooDoll)
{
act->s().type = kAmmoItemVoodooDoll;
break;
}
}
actInitTraps();
actInitThings();
actInitDudes();
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void ConcussSprite(int a1, spritetype *pSprite, int x, int y, int z, int a6) void ConcussSprite(int a1, spritetype *pSprite, int x, int y, int z, int a6)
{ {
assert(pSprite != NULL); assert(pSprite != NULL);

View file

@ -42,6 +42,43 @@ public:
SPRITEMASS& spriteMass() { return gSpriteMass[sprite[index].extra]; } SPRITEMASS& spriteMass() { return gSpriteMass[sprite[index].extra]; }
GENDUDEEXTRA& genDudeExtra() { return Blood::gGenDudeExtra[index]; } GENDUDEEXTRA& genDudeExtra() { return Blood::gGenDudeExtra[index]; }
POINT3D& basePoint() { return Blood::baseSprite[index]; } POINT3D& basePoint() { return Blood::baseSprite[index]; }
void SetOwner(DBloodActor* own)
{
s().owner = own? own->s().index : -1;
}
DBloodActor* GetOwner()
{
if (s().owner == -1) return nullptr;
return base() + s().owner;
}
bool IsPlayerActor()
{
return s().type >= kDudePlayer1 && s().type <= kDudePlayer8;
}
bool IsDudeActor()
{
return s().type >= kDudeBase && s().type < kDudeMax;
}
bool IsItemActor()
{
return s().type >= kItemBase && s().type < kItemMax;
}
bool IsWeaponActor()
{
return s().type >= kItemWeaponBase && s().type < kItemWeaponMax;
}
bool IsAmmoActor()
{
return s().type >= kItemAmmoBase && s().type < kItemAmmoMax;
}
}; };
extern DBloodActor bloodActors[kMaxSprites]; extern DBloodActor bloodActors[kMaxSprites];