- Exhumed: Queen

This commit is contained in:
Christoph Oelckers 2020-11-30 00:40:25 +01:00
parent 026d355096
commit 531d7c96b4
2 changed files with 125 additions and 80 deletions

View file

@ -70,19 +70,6 @@ static actionSeq EggSeq[] = {
{23, 1},
};
int nQHead = 0;
short nEggsFree;
short nHeadVel;
short nVelShift;
short tailspr[kMaxTails];
short nEggFree[kMaxEggs];
short QueenChan[kMaxQueens];
struct Queen
{
short nHealth;
@ -92,7 +79,6 @@ struct Queen
short nTarget;
short field_A;
short field_C;
short pad;
short field_10;
short field_12;
};
@ -100,7 +86,7 @@ struct Queen
struct Egg
{
short nHealth;
short field_2;
short nFrame;
short nAction;
short nSprite;
short field_8;
@ -112,16 +98,26 @@ struct Egg
struct Head
{
short nHealth;
short field_2;
short nFrame;
short nAction;
short nSprite;
short field_8;
short nTarget;
short field_C;
short field_E;
short tails;
};
Egg QueenEgg[kMaxEggs];
FreeListArray<Egg, kMaxEggs> QueenEgg;
int nQHead = 0;
short nHeadVel;
short nVelShift;
short tailspr[kMaxTails];
short QueenChan[kMaxQueens];
Queen QueenList[kMaxQueens];
Head QueenHead;
@ -131,49 +127,98 @@ int MoveQZ[25];
short MoveQS[25];
short MoveQA[25];
FSerializer& Serialize(FSerializer& arc, const char* keyname, Queen& w, Queen* def)
{
if (arc.BeginObject(keyname))
{
arc("health", w.nHealth)
("frame", w.nFrame)
("action", w.nAction)
("sprite", w.nSprite)
("target", w.nTarget)
("ata", w.field_A)
("atc", w.field_C)
("at10", w.field_10)
("at12", w.field_12)
.EndObject();
}
return arc;
}
FSerializer& Serialize(FSerializer& arc, const char* keyname, Egg& w, Egg* def)
{
if (arc.BeginObject(keyname))
{
arc("health", w.nHealth)
("frame", w.nFrame)
("action", w.nAction)
("sprite", w.nSprite)
("target", w.nTarget)
("at8", w.field_8)
("atc", w.field_C)
("ate", w.field_E)
.EndObject();
}
return arc;
}
static SavegameHelper sghqueen("queen",
SV(QueenCount),
SV(nQHead),
SV(nEggsFree),
SV(nHeadVel),
SV(nVelShift),
SV(QueenHead),
SA(tailspr),
SA(nEggFree),
SA(QueenChan),
SA(QueenEgg),
SA(QueenList),
SA(MoveQX),
SA(MoveQY),
SA(MoveQZ),
SA(MoveQS),
SA(MoveQA),
nullptr);
FSerializer& Serialize(FSerializer& arc, const char* keyname, Head& w, Head* def)
{
if (arc.BeginObject(keyname))
{
arc("health", w.nHealth)
("frame", w.nFrame)
("action", w.nAction)
("sprite", w.nSprite)
("target", w.nTarget)
("at8", w.field_8)
("atc", w.field_C)
("tails", w.tails)
.EndObject();
}
return arc;
}
void SerializeQueen(FSerializer& arc)
{
if (arc.BeginObject("queen"))
{
arc("count", QueenCount);
if (QueenCount == 0) // only save the rest if we got a queen. There can only be one.
{
arc("qhead", nQHead)
("headvel", nHeadVel)
("velshift", nVelShift)
("head", QueenHead)
.Array("tailspr", tailspr, countof(tailspr))
("queenchan", QueenChan[0])
("queen", QueenList[0])
("eggs", QueenEgg)
.Array("moveqx", MoveQX, countof(MoveQX))
.Array("moveqy", MoveQY, countof(MoveQY))
.Array("moveqz", MoveQZ, countof(MoveQZ))
.Array("moveqa", MoveQA, countof(MoveQA))
.Array("moveqs", MoveQS, countof(MoveQS));
}
arc.EndObject();
}
}
void InitQueens()
{
QueenCount = 1;
QueenEgg.Clear();
for (int i = 0; i < kMaxEggs; i++)
{
nEggFree[i] = i;
QueenEgg[i].field_8 = -1;
}
nEggsFree = kMaxEggs;
}
int GrabEgg()
{
if (!nEggsFree) {
return -1;
}
nEggsFree--;
return nEggFree[nEggsFree];
auto egg = QueenEgg.Get();
if (egg == -1) return -1;
return egg;
}
void BlowChunks(int nSprite)
@ -207,9 +252,7 @@ void DestroyEgg(short nEgg)
QueenEgg[nEgg].field_8 = -1;
mydeletesprite(nSprite);
nEggFree[nEggsFree] = nEgg;
nEggsFree++;
QueenEgg.Release(nEgg);
}
void DestroyAllEggs()
@ -313,11 +356,11 @@ int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2)
int DestroyTailPart()
{
if (!QueenHead.field_E) {
if (!QueenHead.tails) {
return 0;
}
short nSprite = tailspr[--QueenHead.field_E];
short nSprite = tailspr[--QueenHead.tails];
BlowChunks(nSprite);
BuildExplosion(nSprite);
@ -380,7 +423,7 @@ void BuildTail()
}
nQHead = 0;
QueenHead.field_E = 7;
QueenHead.tails = 7;
}
int BuildQueenEgg(short nQueen, int nVal)
@ -438,7 +481,7 @@ int BuildQueenEgg(short nQueen, int nVal)
GrabTimeSlot(3);
QueenEgg[nEgg].nHealth = 200;
QueenEgg[nEgg].field_2 = 0;
QueenEgg[nEgg].nFrame = 0;
QueenEgg[nEgg].nSprite = nSprite2;
QueenEgg[nEgg].field_E = nVal;
QueenEgg[nEgg].nTarget = QueenList[nQueen].nTarget;
@ -493,16 +536,16 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
short nSeq = SeqOffsets[kSeqQueenEgg] + EggSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, pEgg->field_2);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, pEgg->nFrame);
if (nAction != 4)
{
seq_MoveSequence(nSprite, nSeq, pEgg->field_2);
seq_MoveSequence(nSprite, nSeq, pEgg->nFrame);
pEgg->field_2++;
if (pEgg->field_2 >= SeqSize[nSeq])
pEgg->nFrame++;
if (pEgg->nFrame >= SeqSize[nSeq])
{
pEgg->field_2 = 0;
pEgg->nFrame = 0;
bVal = true;
}
@ -535,7 +578,7 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
if (!RandomSize(1))
{
pEgg->nAction = 1;
pEgg->field_2 = 0;
pEgg->nFrame = 0;
}
else
{
@ -653,7 +696,7 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqQueenEgg] + EggSeq[nAction].a, pEgg->field_2, EggSeq[nAction].b);
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqQueenEgg] + EggSeq[nAction].a, pEgg->nFrame, EggSeq[nAction].b);
break;
}
}
@ -699,14 +742,14 @@ int BuildQueenHead(short nQueen)
QueenHead.nHealth = 800;
QueenHead.nAction = 0;
QueenHead.nTarget = QueenList[nQueen].nTarget;
QueenHead.field_2 = 0;
QueenHead.nFrame = 0;
QueenHead.nSprite = nSprite2;
QueenHead.field_C = 0;
sprite[nSprite2].owner = runlist_AddRunRec(sprite[nSprite2].lotag - 1, 0x1B0000);
QueenHead.field_8 = runlist_AddRunRec(NewRun, 0x1B0000);
QueenHead.field_E = 0;
QueenHead.tails = 0;
return 0;
}
@ -737,14 +780,14 @@ void FuncQueenHead(int a, int nDamage, int nRun)
short nSeq = SeqOffsets[kSeqQueen] + HeadSeq[QueenHead.nAction].a;
seq_MoveSequence(nSprite, nSeq, QueenHead.field_2);
seq_MoveSequence(nSprite, nSeq, QueenHead.nFrame);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, QueenHead.field_2);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, QueenHead.nFrame);
QueenHead.field_2++;
if (QueenHead.field_2 >= SeqSize[nSeq])
QueenHead.nFrame++;
if (QueenHead.nFrame >= SeqSize[nSeq])
{
QueenHead.field_2 = 0;
QueenHead.nFrame = 0;
var_14 = 1;
}
@ -837,7 +880,7 @@ void FuncQueenHead(int a, int nDamage, int nRun)
if (var_14)
{
QueenHead.nAction = 1;
QueenHead.field_2 = 0;
QueenHead.nFrame = 0;
break;
}
fallthrough__;
@ -846,7 +889,7 @@ void FuncQueenHead(int a, int nDamage, int nRun)
if ((sprite[nTarget].z - 51200) > sprite[nSprite].z)
{
QueenHead.nAction = 4;
QueenHead.field_2 = 0;
QueenHead.nFrame = 0;
}
else
{
@ -912,7 +955,7 @@ __MOVEQS:
nHd = nQHead;
for (int i = 0; i < QueenHead.field_E; i++)
for (int i = 0; i < QueenHead.tails; i++)
{
nHd -= 3;
if (nHd < 0) {
@ -949,9 +992,9 @@ __MOVEQS:
{
QueenHead.field_C = 3;
if (QueenHead.field_E--)
if (QueenHead.tails--)
{
if (QueenHead.field_E >= 15 || QueenHead.field_E < 10)
if (QueenHead.tails >= 15 || QueenHead.tails < 10)
{
int x = sprite[nSprite].x;
int y = sprite[nSprite].y;
@ -959,8 +1002,8 @@ __MOVEQS:
short nSector = sprite[nSprite].sectnum;
int nAngle = RandomSize(11) & kAngleMask;
sprite[nSprite].xrepeat = 127 - QueenHead.field_E;
sprite[nSprite].yrepeat = 127 - QueenHead.field_E;
sprite[nSprite].xrepeat = 127 - QueenHead.tails;
sprite[nSprite].yrepeat = 127 - QueenHead.tails;
sprite[nSprite].cstat = 0x8000;
@ -981,8 +1024,8 @@ __MOVEQS:
sprite[nSprite].y = y;
sprite[nSprite].z = z;
if (QueenHead.field_E < 10) {
for (int i = (10 - QueenHead.field_E) * 2; i > 0; i--)
if (QueenHead.tails < 10) {
for (int i = (10 - QueenHead.tails) * 2; i > 0; i--)
{
BuildLavaLimb(nSprite, i, GetSpriteHeight(nSprite));
}
@ -1037,7 +1080,7 @@ __MOVEQS:
{
QueenHead.nTarget = a & 0xFFFF;
QueenHead.nAction = 7;
QueenHead.field_2 = 0;
QueenHead.nFrame = 0;
}
if (QueenHead.nHealth <= 0)
@ -1050,9 +1093,9 @@ __MOVEQS:
else
{
QueenHead.nAction = 5;
QueenHead.field_2 = 0;
QueenHead.nFrame = 0;
QueenHead.field_C = 0;
QueenHead.field_E = 80;
QueenHead.tails = 80;
sprite[nSprite].cstat = 0;
}
}
@ -1076,7 +1119,7 @@ __MOVEQS:
nSeq += 73;
}
seq_PlotSequence(a & 0xFFFF, nSeq, QueenHead.field_2, edx);
seq_PlotSequence(a & 0xFFFF, nSeq, QueenHead.nFrame, edx);
break;
}

View file

@ -42,6 +42,7 @@ void SerializeFish(FSerializer& arc);
void SerializeLavadude(FSerializer& arc);
void SerializeLion(FSerializer& arc);
void SerializeMummy(FSerializer& arc);
void SerializeQueen(FSerializer& arc);
void SerializeRat(FSerializer& arc);
void SerializeRex(FSerializer& arc);
void SerializeRoach(FSerializer& arc);
@ -79,6 +80,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
SerializeLavadude(arc);
SerializeLion(arc);
SerializeMummy(arc);
SerializeQueen(arc);
SerializeRat(arc);
SerializeRex(arc);
SerializeRoach(arc);