- 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
};
const int DudeDifficulty[5] = {
512, 384, 256, 208, 160
};
int gPostCount = 0;
@ -2352,6 +2355,12 @@ struct POSTPONE {
POSTPONE gPost[kMaxSprites];
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
bool IsUnderwaterSector(int nSector)
{
int nXSector = sector[nSector].extra;
@ -2360,55 +2369,39 @@ bool IsUnderwaterSector(int nSector)
return 0;
}
const int DudeDifficulty[5] = {
512, 384, 256, 208, 160
};
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void actInit(bool bSaveLoad)
void actInitTraps()
{
#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())
{
switch (act->s().type)
{
case kItemWeaponVoodooDoll:
act->s().type = kAmmoItemVoodooDoll;
break;
}
}
it.Reset(kStatTraps);
BloodStatIterator it(kStatTraps);
while (auto act = it.Next())
{
spritetype* pSprite = &act->s();
auto x = &act->x();
switch (pSprite->type)
if (pSprite->type == kTrapExploder)
{
case kTrapExploder:
pSprite->cstat &= ~1;
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->state = 0;
break;
}
}
}
it.Reset(kStatThing);
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void actInitThings()
{
BloodStatIterator it(kStatThing);
while (auto act = it.Next())
{
if (!act->hasX()) continue;
@ -2452,7 +2445,16 @@ void actInit(bool bSaveLoad)
break;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void actInitDudes()
{
if (gGameOptions.nMonsterSettings == 0)
{
gKillMgr.SetCount(0);
@ -2496,7 +2498,7 @@ void actInit(bool bSaveLoad)
int nType = pSprite->type - kDudeBase;
int seqStartId = dudeInfo[nType].seqStartID;
if (!IsPlayerSprite(pSprite))
if (!act->IsPlayerActor())
{
#ifdef NOONE_EXTENSIONS
switch (pSprite->type)
@ -2511,7 +2513,7 @@ void actInit(bool bSaveLoad)
case kDudePodMother: // FakeDude type (no seq, custom flags, clipdist and cstat)
if (gModernMap) break;
fallthrough__;
[[fallthrough]];
default:
pSprite->clipdist = dudeInfo[nType].clipdist;
pSprite->cstat |= 4096 + CSTAT_SPRITE_BLOCK_HITSCAN + CSTAT_SPRITE_BLOCK;
@ -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)
{
assert(pSprite != NULL);

View file

@ -42,6 +42,43 @@ public:
SPRITEMASS& spriteMass() { return gSpriteMass[sprite[index].extra]; }
GENDUDEEXTRA& genDudeExtra() { return Blood::gGenDudeExtra[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];