- Regenerates.

MP only so not really relevant - the code looked broken anyway.
This commit is contained in:
Christoph Oelckers 2021-10-21 10:20:08 +02:00
parent 2f511b3cff
commit 1591d6fbdb
4 changed files with 29 additions and 69 deletions

View file

@ -162,13 +162,9 @@ void FillItems(short nPlayer);
void UseItem(short nPlayer, short nItem);
void UseCurItem(short nPlayer);
int GrabItem(short nPlayer, short nItem);
void DropMagic(short nSprite);
inline void DropMagic(DExhumedActor* actor)
{
DropMagic(actor->GetSpriteIndex());
}
void DropMagic(DExhumedActor* actor);
void InitItems();
void StartRegenerate(short nSprite);
void StartRegenerate(DExhumedActor* nSprite);
void DoRegenerates();
// lavadude

View file

@ -105,16 +105,14 @@ short x/y repeat
*/
short nRegenerates;
short nFirstRegenerate;
TArray<DExhumedActor*> Regenerates;
short nMagicCount;
void SerializeItems(FSerializer& arc)
{
if (arc.BeginObject("items"))
{
arc("regenerates", nRegenerates)
("first", nFirstRegenerate)
arc("regenerates", Regenerates)
("magiccount", nMagicCount)
.EndObject();
}
@ -330,9 +328,9 @@ int GrabItem(short nPlayer, short nItem)
return 1;
}
void DropMagic(short nSprite)
void DropMagic(DExhumedActor* pActor)
{
auto pSprite = &sprite[nSprite];
auto pSprite = &pActor->s();
if (lFinaleStart) {
return;
@ -364,59 +362,30 @@ void DropMagic(short nSprite)
void InitItems()
{
nRegenerates = 0;
nFirstRegenerate = -1;
Regenerates.Clear();
nMagicCount = 0;
}
void StartRegenerate(short nSprite)
void StartRegenerate(DExhumedActor* pActor)
{
spritetype *pSprite = &sprite[nSprite];
spritetype *pSprite = &pActor->s();
int edi = -1;
DExhumedActor* pCurr = nullptr;
int nReg = nFirstRegenerate;
int i = 0;
// for (int i = 0; i < nRegenerates; i++)
while (1)
auto pos = Regenerates.Find(pActor);
if (pos >= Regenerates.Size())
{
if (i >= nRegenerates)
{
// ?? CHECKME
pSprite->xvel = pSprite->xrepeat;
pSprite->zvel = pSprite->shade;
pSprite->yvel = pSprite->pal;
break;
}
else
{
if (nReg != nSprite)
{
edi = nReg;
nReg = sprite[nReg].ang;
i++;
continue;
}
else
{
if (edi == -1)
{
nFirstRegenerate = pSprite->ang;
}
else
{
sprite[edi].ang = pSprite->ang;
}
nRegenerates--;
}
}
// ?? CHECKME
pSprite->xvel = pSprite->xrepeat;
pSprite->zvel = pSprite->shade;
pSprite->yvel = pSprite->pal;
}
else
{
Regenerates.Delete(pos);
}
pSprite->extra = 1350;
pSprite->ang = nFirstRegenerate;
if (!(currentLevel->gameflags & LEVEL_EX_MULTI))
{
@ -428,17 +397,15 @@ void StartRegenerate(short nSprite)
pSprite->yrepeat = 1;
pSprite->pal = 1;
nRegenerates++;
nFirstRegenerate = nSprite;
Regenerates.Push(pActor);
}
void DoRegenerates()
{
int nSprite = nFirstRegenerate;
auto pSprite = &sprite[nSprite];
for (int i = nRegenerates; i > 0; i--, nSprite = pSprite->ang)
for(unsigned i = 0; i < Regenerates.Size(); i++)
{
auto pActor = Regenerates[i];
auto pSprite = &pActor->s();
if (pSprite->extra > 0)
{
pSprite->extra--;
@ -446,7 +413,7 @@ void DoRegenerates()
if (pSprite->extra <= 0)
{
BuildAnim(nullptr, 38, 0, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum, 64, 4);
D3PlayFX(StaticSound[kSoundTorchOn], nSprite);
D3PlayFX(StaticSound[kSoundTorchOn], pActor);
}
else {
continue;
@ -468,7 +435,6 @@ void DoRegenerates()
pSprite->pal = (uint8_t)pSprite->yvel;
pSprite->yvel = pSprite->zvel; // setting to 0
pSprite->xvel = pSprite->zvel; // setting to 0
nRegenerates--;
if (pSprite->statnum == kStatExplodeTrigger) {
pSprite->cstat = 0x101;
@ -476,10 +442,8 @@ void DoRegenerates()
else {
pSprite->cstat = 0;
}
if (nRegenerates == 0) {
nFirstRegenerate = -1;
}
Regenerates.Delete(i);
i--;
}
}
END_PS_NS

View file

@ -2143,7 +2143,7 @@ void AIObject::Tick(RunListEvent* ev)
}
else
{
StartRegenerate(nSprite);
StartRegenerate(pActor);
pObject->nHealth = 120;
pSprite->x = sprite[pObject->field_10].x;

View file

@ -1404,7 +1404,7 @@ sectdone:
}
else
{
StartRegenerate(nValB);
StartRegenerate(pActorB);
}
do_default_b:
// loc_1BA74