PCExhumed: Big bunch of AI tidying, code consistency changes and misc fixes. Aiming to get compatibility with new demos from DOS exe.

# Conflicts:
#	source/exhumed/src/anubis.cpp
#	source/exhumed/src/bubbles.cpp
#	source/exhumed/src/bubbles.h
#	source/exhumed/src/bullet.cpp
#	source/exhumed/src/bullet.h
#	source/exhumed/src/fish.cpp
#	source/exhumed/src/fish.h
#	source/exhumed/src/grenade.cpp
#	source/exhumed/src/grenade.h
#	source/exhumed/src/lavadude.cpp
#	source/exhumed/src/lavadude.h
#	source/exhumed/src/lion.cpp
#	source/exhumed/src/lion.h
#	source/exhumed/src/mummy.cpp
#	source/exhumed/src/mummy.h
#	source/exhumed/src/queen.cpp
#	source/exhumed/src/queen.h
#	source/exhumed/src/ra.cpp
#	source/exhumed/src/ra.h
#	source/exhumed/src/rat.cpp
#	source/exhumed/src/rat.h
#	source/exhumed/src/rex.cpp
#	source/exhumed/src/roach.cpp
#	source/exhumed/src/roach.h
#	source/exhumed/src/runlist.cpp
#	source/exhumed/src/scorp.cpp
#	source/exhumed/src/set.cpp
#	source/exhumed/src/set.h
#	source/exhumed/src/snake.cpp
#	source/exhumed/src/snake.h
#	source/exhumed/src/spider.cpp
#	source/exhumed/src/spider.h
#	source/exhumed/src/wasp.cpp
#	source/exhumed/src/wasp.h
This commit is contained in:
sirlemonhead 2020-03-02 21:08:31 +00:00 committed by Christoph Oelckers
parent 6656547908
commit df34d8ca85
41 changed files with 763 additions and 749 deletions

View file

@ -18,6 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "ns.h"
#include "exhumed.h"
#include "anubis.h"
#include "aistuff.h"
#include "engine.h"
#include "runlist.h"
#include "sequence.h"
@ -48,7 +49,6 @@ struct Anubis
Anubis AnubisList[kMaxAnubis];
short AnubisSprite = -1;
short AnubisCount = -1;
static actionSeq ActionSeq[] = {
@ -82,7 +82,6 @@ static SavegameHelper sgh("anubis",
void InitAnubis()
{
AnubisCount = kMaxAnubis;
AnubisSprite = 1;
nAnubisDrum = 1;
}
@ -164,17 +163,23 @@ int BuildAnubis(int nSprite, int x, int y, int z, int nSector, int nAngle, uint8
void FuncAnubis(int a, int nDamage, int nRun)
{
short nAnubis = RunData[nRun].nVal;
int var_14 = 0;
assert(nAnubis >= 0 && nAnubis < kMaxAnubis);
short nSprite = AnubisList[nAnubis].nSprite;
short nAction = AnubisList[nAnubis].nAction;
int nMessage = a & 0x7F0000;
bool bVal = false;
int nMessage = a & kMessageMask;
switch (nMessage)
{
default:
{
DebugOut("unknown msg %d for Anubis\n", nMessage);
return;
}
case 0x20000:
{
if (nAction < 11) {
@ -191,7 +196,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
if (AnubisList[nAnubis].nFrame >= SeqSize[nSeq])
{
AnubisList[nAnubis].nFrame = 0;
var_14 = 1;
bVal = true;
}
short nTarget = AnubisList[nAnubis].nTarget;
@ -199,10 +204,10 @@ void FuncAnubis(int a, int nDamage, int nRun)
short nFrame = SeqBase[nSeq] + AnubisList[nAnubis].nFrame;
short nFlag = FrameFlag[nFrame];
int c = 0;
int nMov = 0;
if (nAction > 0 && nAction < 11) {
c = MoveCreatureWithCaution(nSprite);
nMov = MoveCreatureWithCaution(nSprite);
}
switch (nAction)
@ -234,15 +239,16 @@ void FuncAnubis(int a, int nDamage, int nRun)
{
PlotCourseToSprite(nSprite, nTarget);
sprite[nSprite].xvel = Cos(sprite[nSprite].ang & 0xFFF8) >> 2;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang & 0xFFF8) >> 2;
int nAngle = sprite[nSprite].ang & 0xFFF8;
sprite[nSprite].xvel = Cos(nAngle) >> 2;
sprite[nSprite].yvel = Sin(nAngle) >> 2;
}
switch (c & 0xC000)
switch (nMov & 0xC000)
{
case 0xC000:
{
if ((c & 0x3FFF) == nTarget)
if ((nMov & 0x3FFF) == nTarget)
{
int nAng = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y);
int nAngDiff = AngleDiff(sprite[nSprite].ang, nAng);
@ -252,7 +258,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
AnubisList[nAnubis].nAction = 2;
AnubisList[nAnubis].nFrame = 0;
}
break; // only break if condition met
break;
}
// else we fall through to 0x8000
fallthrough__;
@ -278,10 +284,11 @@ void FuncAnubis(int a, int nDamage, int nRun)
if (cansee(sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z - GetSpriteHeight(nSprite), sprite[nSprite].sectnum,
sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z - GetSpriteHeight(nTarget), sprite[nTarget].sectnum))
{
AnubisList[nAnubis].nAction = 3;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].ang = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y);
AnubisList[nAnubis].nAction = 3;
AnubisList[nAnubis].nFrame = 0;
}
}
@ -316,7 +323,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
}
case 3:
{
if (var_14)
if (bVal)
{
AnubisList[nAnubis].nAction = 1;
@ -341,7 +348,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
if (var_14)
if (bVal)
{
AnubisList[nAnubis].nAction = 1;
AnubisList[nAnubis].nFrame = 0;
@ -354,7 +361,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
case 9:
case 10:
{
if (var_14)
if (bVal)
{
AnubisList[nAnubis].nAction = (RandomSize(3) % 5) + 6;
AnubisList[nAnubis].nFrame = 0;
@ -364,7 +371,7 @@ void FuncAnubis(int a, int nDamage, int nRun)
case 11:
case 12:
{
if (var_14)
if (bVal)
{
AnubisList[nAnubis].nAction = nAction + 2;
AnubisList[nAnubis].nFrame = 0;
@ -492,11 +499,6 @@ void FuncAnubis(int a, int nDamage, int nRun)
return;
}
default:
{
Printf("unknown msg %d for Anubis\n", a & 0x7F0000);
return;
}
}
}
END_PS_NS

View file

@ -37,10 +37,10 @@ BEGIN_PS_NS
struct Bubble
{
short _0;
short _2;
short nFrame;
short nSeq;
short nSprite;
short _6;
short nRun;
};
struct machine
@ -86,7 +86,7 @@ void DestroyBubble(short nBubble)
runlist_DoSubRunRec(sprite[nSprite].lotag - 1);
runlist_DoSubRunRec(sprite[nSprite].owner);
runlist_SubRunRec(BubbleList[nBubble]._6);
runlist_SubRunRec(BubbleList[nBubble].nRun);
mydeletesprite(nSprite);
@ -141,12 +141,12 @@ int BuildBubble(int x, int y, int z, short nSector)
// GrabTimeSlot(3);
BubbleList[nBubble].nSprite = nSprite;
BubbleList[nBubble]._0 = 0;
BubbleList[nBubble]._2 = SeqOffsets[kSeqBubble] + nSize;
BubbleList[nBubble].nFrame = 0;
BubbleList[nBubble].nSeq = SeqOffsets[kSeqBubble] + nSize;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nBubble | 0x140000);
BubbleList[nBubble]._6 = runlist_AddRunRec(NewRun, nBubble | 0x140000);
BubbleList[nBubble].nRun = runlist_AddRunRec(NewRun, nBubble | 0x140000);
return nBubble | 0x140000;
}
@ -156,20 +156,20 @@ void FuncBubble(int a, int UNUSED(b), int nRun)
assert(nBubble >= 0 && nBubble < kMaxBubbles);
short nSprite = BubbleList[nBubble].nSprite;
short dx = BubbleList[nBubble]._2;
short nSeq = BubbleList[nBubble].nSeq;
int nMessage = a & 0x7F0000;
int nMessage = a & kMessageMask;
switch (nMessage)
{
case 0x20000:
{
seq_MoveSequence(nSprite, dx, BubbleList[nBubble]._0);
seq_MoveSequence(nSprite, nSeq, BubbleList[nBubble].nFrame);
BubbleList[nBubble]._0++;
BubbleList[nBubble].nFrame++;
if (BubbleList[nBubble]._0 >= SeqSize[dx]) {
BubbleList[nBubble]._0 = 0;
if (BubbleList[nBubble].nFrame >= SeqSize[nSeq]) {
BubbleList[nBubble].nFrame = 0;
}
sprite[nSprite].z += sprite[nSprite].zvel;
@ -192,7 +192,7 @@ void FuncBubble(int a, int UNUSED(b), int nRun)
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, dx, BubbleList[nBubble]._0, 1);
seq_PlotSequence(a & 0xFFFF, nSeq, BubbleList[nBubble].nFrame, 1);
tsprite[a & 0xFFFF].owner = -1;
return;
}
@ -227,6 +227,7 @@ void BuildBubbleMachine(int nSprite)
{
if (nMachineCount >= kMaxMachines) {
I_Error("too many bubble machines in level %d\n", levelnew);
exit(-1);
}
Machine[nMachineCount]._4 = 75;
@ -234,7 +235,7 @@ void BuildBubbleMachine(int nSprite)
Machine[nMachineCount]._0 = Machine[nMachineCount]._4;
nMachineCount++;
sprite[nSprite].cstat = 0x8000u;
sprite[nSprite].cstat = 0x8000;
}
void DoBubbles(int nPlayer)

View file

@ -19,13 +19,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __bubbles_h__
#define __bubbles_h__
#include "aistuff.h"
BEGIN_PS_NS
void InitBubbles();
void BuildBubbleMachine(int nSprite);
void DoBubbleMachines();
void DoBubbles(int nPlayer);
void FuncBubble(int, int, int);

View file

@ -50,9 +50,9 @@ short BulletFree[kMaxBullets];
// 32 bytes
struct Bullet
{
short nSeq; // 0
short field_2; // 2
short nSprite; // 4
short nSeq;
short nFrame;
short nSprite;
short field_6;
short field_8;
short nType;
@ -340,7 +340,7 @@ int MoveBullet(short nBullet)
if (pBullet->field_E == 3)
{
pBullet->nSeq = 45;
pBullet->field_2 = 0;
pBullet->nFrame = 0;
pSprite->xrepeat = 40;
pSprite->yrepeat = 40;
pSprite->shade = 0;
@ -650,7 +650,7 @@ int BuildBullet(short nSprite, int nType, int UNUSED(ebx), int UNUSED(ecx), int
pBullet->field_10 = 0;
pBullet->field_E = pBulletInfo->field_2;
pBullet->field_2 = 0;
pBullet->nFrame = 0;
short nSeq;
@ -801,23 +801,23 @@ void FuncBullet(int a, int UNUSED(b), int nRun)
short nSeq = SeqOffsets[BulletList[nBullet].nSeq];
short nSprite = BulletList[nBullet].nSprite;
int nMessage = a & 0x7F0000;
int nMessage = a & kMessageMask;
switch (nMessage)
{
case 0x20000:
{
short nFlag = FrameFlag[SeqBase[nSeq] + BulletList[nBullet].field_2];
short nFlag = FrameFlag[SeqBase[nSeq] + BulletList[nBullet].nFrame];
seq_MoveSequence(nSprite, nSeq, BulletList[nBullet].field_2);
seq_MoveSequence(nSprite, nSeq, BulletList[nBullet].nFrame);
if (nFlag & 0x80)
{
BuildAnim(-1, 45, 0, sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z, sprite[nSprite].sectnum, sprite[nSprite].xrepeat, 0);
}
BulletList[nBullet].field_2++;
if (BulletList[nBullet].field_2 >= SeqSize[nSeq])
BulletList[nBullet].nFrame++;
if (BulletList[nBullet].nFrame >= SeqSize[nSeq])
{
if (!BulletList[nBullet].field_12)
{
@ -825,7 +825,7 @@ void FuncBullet(int a, int UNUSED(b), int nRun)
BulletList[nBullet].field_12++;
}
BulletList[nBullet].field_2 = 0;
BulletList[nBullet].nFrame = 0;
}
if (BulletList[nBullet].field_E != -1 && --BulletList[nBullet].field_E == 0)
@ -846,11 +846,11 @@ void FuncBullet(int a, int UNUSED(b), int nRun)
if (BulletList[nBullet].nType == 15)
{
seq_PlotArrowSequence(nSprite2, nSeq, BulletList[nBullet].field_2);
seq_PlotArrowSequence(nSprite2, nSeq, BulletList[nBullet].nFrame);
}
else
{
seq_PlotSequence(nSprite2, nSeq, BulletList[nBullet].field_2, 0);
seq_PlotSequence(nSprite2, nSeq, BulletList[nBullet].nFrame, 0);
tsprite[nSprite2].owner = -1;
}
break;
@ -861,7 +861,7 @@ void FuncBullet(int a, int UNUSED(b), int nRun)
default:
{
Printf("unknown msg %x for bullet\n", a & 0x7F0000);
Printf("unknown msg %d for bullet\n", nMessage);
return;
}
}

View file

@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __bullet_h__
#define __bullet_h__
#include "aistuff.h"
BEGIN_PS_NS
// 32 bytes

View file

@ -16,7 +16,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "aistuff.h"
#include "fish.h"
#include "anims.h"
#include "engine.h"
@ -35,7 +34,6 @@ BEGIN_PS_NS
#define kMaxFishes 128
#define kMaxChunks 128
short FishSprite = -1;
short FishCount = 0;
static actionSeq ActionSeq[] = {
@ -58,13 +56,13 @@ int nFreeChunk[kMaxChunks] = { 0 };
struct Fish
{
short nHealth;
short field_2;
short nFrame;
short nAction;
short nSprite;
short nTarget;
short field_A;
short field_C;
short field_E;
short nRun;
};
struct Chunk
@ -91,7 +89,6 @@ static SavegameHelper sgh("fish",
void InitFishes()
{
FishCount = 0;
FishSprite = 1;
nChunksFree = kMaxChunks;
for (int i = 0; i < kMaxChunks; i++) {
@ -132,7 +129,6 @@ int BuildFishLimb(short nFish, short edx)
sprite[nSprite2].yoffset = 0;
sprite[nSprite2].zvel = (-(RandomByte() + 512)) * 2;
// not sure what's going on here... return value doesn't seem to be used
seq_GetSeqPicnum(kSeqFish, FishChunk[nFree].field_4, 0);
sprite[nSprite2].picnum = edx;
@ -157,7 +153,6 @@ void FuncFishLimb(int a, int UNUSED(nDamage), int nRun)
{
short nFish = RunData[nRun].nVal;
short nSprite = FishChunk[nFish].nSprite;
assert(nSprite >= 0 && nSprite < kMaxSprites);
int nSeq = SeqOffsets[kSeqFish] + FishChunk[nFish].field_4;
@ -207,8 +202,8 @@ void FuncFishLimb(int a, int UNUSED(nDamage), int nRun)
{
if (movesprite(nSprite, sprite[nSprite].xvel << 8, sprite[nSprite].yvel << 8, sprite[nSprite].zvel, 2560, -2560, CLIPMASK1))
{
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
}
}
@ -274,10 +269,10 @@ int BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle)
FishList[nFish].nSprite = nSprite;
FishList[nFish].nTarget = -1;
FishList[nFish].field_C = 60;
FishList[nFish].field_2 = 0;
FishList[nFish].nFrame = 0;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nFish | 0x120000);
FishList[nFish].field_E = runlist_AddRunRec(NewRun, nFish | 0x120000);
FishList[nFish].nRun = runlist_AddRunRec(NewRun, nFish | 0x120000);
nCreaturesLeft++;
@ -295,7 +290,7 @@ void IdleFish(short nFish, short edx)
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 8;
FishList[nFish].nAction = 0;
FishList[nFish].field_2 = 0;
FishList[nFish].nFrame = 0;
sprite[nSprite].zvel = RandomSize(9);
@ -317,7 +312,7 @@ void DestroyFish(short nFish)
runlist_DoSubRunRec(sprite[nSprite].owner);
runlist_FreeRun(sprite[nSprite].lotag - 1);
runlist_SubRunRec(FishList[nFish].field_E);
runlist_SubRunRec(FishList[nFish].nRun);
mydeletesprite(nSprite);
}
@ -341,7 +336,7 @@ void FuncFish(int a, int nDamage, int nRun)
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqFish] + ActionSeq[nAction].a, FishList[nFish].field_2, ActionSeq[nAction].b);
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqFish] + ActionSeq[nAction].a, FishList[nFish].nFrame, ActionSeq[nAction].b);
tsprite[a & 0xFFFF].owner = -1;
return;
}
@ -390,7 +385,7 @@ void FuncFish(int a, int nDamage, int nRun)
else
{
FishList[nFish].nAction = 9;
FishList[nFish].field_2 = 0;
FishList[nFish].nFrame = 0;
}
return;
@ -404,7 +399,7 @@ void FuncFish(int a, int nDamage, int nRun)
}
FishList[nFish].nAction = 4;
FishList[nFish].field_2 = 0;
FishList[nFish].nFrame = 0;
FishList[nFish].field_C += 10;
}
@ -420,13 +415,13 @@ void FuncFish(int a, int nDamage, int nRun)
short nSeq = SeqOffsets[kSeqFish] + ActionSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, FishList[nFish].field_2);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, FishList[nFish].nFrame);
seq_MoveSequence(nSprite, nSeq, FishList[nFish].field_2);
seq_MoveSequence(nSprite, nSeq, FishList[nFish].nFrame);
FishList[nFish].field_2++;
if (FishList[nFish].field_2 >= SeqSize[nSeq]) {
FishList[nFish].field_2 = 0;
FishList[nFish].nFrame++;
if (FishList[nFish].nFrame >= SeqSize[nSeq]) {
FishList[nFish].nFrame = 0;
}
short nTarget = FishList[nFish].nTarget;
@ -446,7 +441,7 @@ void FuncFish(int a, int nDamage, int nRun)
{
FishList[nFish].nTarget = nTarget;
FishList[nFish].nAction = 2;
FishList[nFish].field_2 = 0;
FishList[nFish].nFrame = 0;
int nAngle = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].z - sprite[nSprite].z);
sprite[nSprite].zvel = Sin(nAngle) >> 5;
@ -479,21 +474,17 @@ void FuncFish(int a, int nDamage, int nRun)
PlotCourseToSprite(nSprite, nTarget);
int nHeight = GetSpriteHeight(nSprite) >> 1;
int z = sprite[nTarget].z - sprite[nSprite].z;
if (z < 0) {
z = -z;
}
int z = klabs(sprite[nTarget].z - sprite[nSprite].z);
if (z <= nHeight)
{
sprite[nSprite].xvel = (Sin(sprite[nSprite].ang + 512) >> 5) - (Sin(sprite[nSprite].ang + 512) >> 7);
sprite[nSprite].xvel = (Cos(sprite[nSprite].ang) >> 5) - (Cos(sprite[nSprite].ang) >> 7);
sprite[nSprite].yvel = (Sin(sprite[nSprite].ang) >> 5) - (Sin(sprite[nSprite].ang) >> 7);
}
else
{
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
}
sprite[nSprite].zvel = (sprite[nTarget].z - sprite[nSprite].z) >> 3;
@ -503,7 +494,7 @@ void FuncFish(int a, int nDamage, int nRun)
case 4:
{
if (FishList[nFish].field_2 == 0)
if (FishList[nFish].nFrame == 0)
{
IdleFish(nFish, 0);
}
@ -517,7 +508,7 @@ void FuncFish(int a, int nDamage, int nRun)
case 9:
{
if (FishList[nFish].field_2 == 0)
if (FishList[nFish].nFrame == 0)
{
DestroyFish(nFish);
}
@ -531,7 +522,7 @@ void FuncFish(int a, int nDamage, int nRun)
short nSector = sprite[nSprite].sectnum;
// loc_2EF54
int nVal = movesprite(nSprite, sprite[nSprite].xvel << 13, sprite[nSprite].yvel << 13, sprite[nSprite].zvel << 2, 0, 0, CLIPMASK0);
int nMov = movesprite(nSprite, sprite[nSprite].xvel << 13, sprite[nSprite].yvel << 13, sprite[nSprite].zvel << 2, 0, 0, CLIPMASK0);
if (!(SectFlag[sprite[nSprite].sectnum] & kSectUnderwater))
{
@ -549,43 +540,43 @@ void FuncFish(int a, int nDamage, int nRun)
return;
}
if (!nVal)
if (!nMov)
{
if (nAction == 3)
{
FishList[nFish].nAction = 2;
FishList[nFish].field_2 = 0;
FishList[nFish].nFrame = 0;
}
return;
}
if ((nVal & 0x30000) == 0)
if ((nMov & 0x30000) == 0)
{
if ((nVal & 0xC000) == 0x8000)
if ((nMov & 0xC000) == 0x8000)
{
IdleFish(nFish, 0);
}
else if ((nVal & 0xC000) == 0xC000)
else if ((nMov & 0xC000) == 0xC000)
{
if (sprite[nVal & 0x3FFF].statnum == 100)
if (sprite[nMov & 0x3FFF].statnum == 100)
{
FishList[nFish].nTarget = nVal & 0x3FFF;
FishList[nFish].nTarget = nMov & 0x3FFF;
sprite[nSprite].ang = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y);
if (nAction != 3)
{
FishList[nFish].nAction = 3;
FishList[nFish].field_2 = 0;
FishList[nFish].nFrame = 0;
}
if (!FishList[nFish].field_2)
if (!FishList[nFish].nFrame)
{
runlist_DamageEnemy(nTarget, nSprite, 2);
}
}
}
}
else if (nVal & 0x20000)
else if (nMov & 0x20000)
{
IdleFish(nFish, -1);
}

View file

@ -19,11 +19,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __fish_h__
#define __fish_h__
#include "aistuff.h"
BEGIN_PS_NS
void InitFishes();
int BuildFish(int nSprite, int x, int y, int z, int nSector, int nAngle);
void FuncFish(int, int, int);
void FuncFishLimb(int a, int b, int c);

View file

@ -16,7 +16,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "aistuff.h"
#include "grenade.h"
#include "engine.h"
#include "player.h"

View file

@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __grenade_h__
#define __grenade_h__
#include "aistuff.h"
BEGIN_PS_NS
#define kMaxGrenades 50

View file

@ -435,8 +435,8 @@ void MoveWeapons(short nPlayer)
if (Ra[nPlayer].nTarget == -1)
break;
Ra[nPlayer].field_0 = 0;
Ra[nPlayer].field_2 = 0;
Ra[nPlayer].nAction = 0;
Ra[nPlayer].nFrame = 0;
Ra[nPlayer].field_C = 1;
}

View file

@ -36,18 +36,17 @@ BEGIN_PS_NS
struct Lava
{
short nSprite;
short field_2;
short nRun;
short nAction;
short nTarget;
short nHealth;
short field_10;
short field_12;
short nFrame;
short nChannel;
};
Lava LavaList[kMaxLavas];
short LavaCount = 0;
short LavaSprite = -1;
static actionSeq ActionSeq[] = {
{0, 1},
@ -68,11 +67,9 @@ static SavegameHelper sgh("lavadude",
nullptr);
// done
void InitLava()
{
LavaCount = 0;
LavaSprite = 1;
}
int BuildLavaLimb(int nSprite, int edx, int ebx)
@ -91,8 +88,8 @@ int BuildLavaLimb(int nSprite, int edx, int ebx)
sprite[nLimbSprite].xvel = (RandomSize(5) - 16) << 8;
sprite[nLimbSprite].yvel = (RandomSize(5) - 16) << 8;
sprite[nLimbSprite].zvel = 2560 - (RandomSize(5) << 8);
sprite[nLimbSprite].yoffset = 0;
sprite[nLimbSprite].xoffset = 0;
sprite[nLimbSprite].yoffset = 0;
sprite[nLimbSprite].xrepeat = 90;
sprite[nLimbSprite].yrepeat = 90;
sprite[nLimbSprite].picnum = (edx & 3) % 3;
@ -109,12 +106,12 @@ int BuildLavaLimb(int nSprite, int edx, int ebx)
return nLimbSprite;
}
void FuncLavaLimb(int eax, int UNUSED(nDamage), int nRun)
void FuncLavaLimb(int a, int UNUSED(nDamage), int nRun)
{
short nSprite = RunData[nRun].nVal;
assert(nSprite >= 0 && nSprite < kMaxSprites);
int nMessage = eax & 0x7F0000;
int nMessage = a & kMessageMask;
switch (nMessage)
{
@ -126,9 +123,9 @@ void FuncLavaLimb(int eax, int UNUSED(nDamage), int nRun)
if (nRet || sprite[nSprite].shade > 100)
{
sprite[nSprite].zvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 0;
runlist_DoSubRunRec(sprite[nSprite].owner);
runlist_FreeRun(sprite[nSprite].lotag - 1);
@ -141,7 +138,7 @@ void FuncLavaLimb(int eax, int UNUSED(nDamage), int nRun)
case 0x90000:
{
seq_PlotSequence(eax, (SeqOffsets[kSeqLavag] + 30) + sprite[nSprite].picnum, 0, 1);
seq_PlotSequence(a & 0xFFFF, (SeqOffsets[kSeqLavag] + 30) + sprite[nSprite].picnum, 0, 1);
break;
}
@ -150,7 +147,7 @@ void FuncLavaLimb(int eax, int UNUSED(nDamage), int nRun)
}
}
int BuildLava(short nSprite, int x, int y, int UNUSED(z), short nSector, short nAngle, int lastArg)
int BuildLava(short nSprite, int x, int y, int UNUSED(z), short nSector, short nAngle, int nChannel)
{
short nLava = LavaCount;
LavaCount++;
@ -178,7 +175,7 @@ int BuildLava(short nSprite, int x, int y, int UNUSED(z), short nSector, short n
sprite[nSprite].x = x;
sprite[nSprite].y = y;
sprite[nSprite].z = sector[nSector].floorz;
sprite[nSprite].cstat = 0x8000u;
sprite[nSprite].cstat = 0x8000;
sprite[nSprite].xrepeat = 200;
sprite[nSprite].yrepeat = 200;
sprite[nSprite].shade = -12;
@ -202,11 +199,11 @@ int BuildLava(short nSprite, int x, int y, int UNUSED(z), short nSector, short n
LavaList[nLava].nHealth = 4000;
LavaList[nLava].nSprite = nSprite;
LavaList[nLava].nTarget = -1;
LavaList[nLava].field_12 = lastArg;
LavaList[nLava].field_10 = 0;
LavaList[nLava].nChannel = nChannel;
LavaList[nLava].nFrame = 0;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nLava | 0x150000);
LavaList[nLava].field_2 = runlist_AddRunRec(NewRun, nLava | 0x150000);
LavaList[nLava].nRun = runlist_AddRunRec(NewRun, nLava | 0x150000);
nCreaturesLeft++;
@ -219,24 +216,22 @@ void FuncLava(int a, int nDamage, int nRun)
assert(nLava >= 0 && nLava < kMaxLavas);
short nAction = LavaList[nLava].nAction;
short nSeq = ActionSeq[nAction].a + SeqOffsets[kSeqLavag];
short nSprite = LavaList[nLava].nSprite;
int nMessage = a & 0x7F0000;
int nMessage = a & kMessageMask;
switch (nMessage)
{
default:
{
Printf("unknown msg %d for Lava\n", a & 0x7F0000);
Printf("unknown msg %d for Lava\n", nMessage);
return;
}
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, nSeq, LavaList[nLava].field_10, ActionSeq[nAction].b);
seq_PlotSequence(a & 0xFFFF, nSeq, LavaList[nLava].nFrame, ActionSeq[nAction].b);
tsprite[a & 0xFFFF].owner = -1;
return;
}
@ -258,7 +253,7 @@ void FuncLava(int a, int nDamage, int nRun)
{
LavaList[nLava].nHealth = 0;
LavaList[nLava].nAction = 5;
LavaList[nLava].field_10 = 0;
LavaList[nLava].nFrame = 0;
nCreaturesLeft--;
@ -281,12 +276,12 @@ void FuncLava(int a, int nDamage, int nRun)
if (!RandomSize(2))
{
LavaList[nLava].nAction = 4;
LavaList[nLava].field_10 = 0;
LavaList[nLava].nFrame = 0;
sprite[nSprite].cstat = 0;
}
}
BuildLavaLimb(nSprite, totalmoves, 0xFA00);
BuildLavaLimb(nSprite, totalmoves, 64000);
}
return;
@ -294,8 +289,8 @@ void FuncLava(int a, int nDamage, int nRun)
case 0x20000:
{
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, LavaList[nLava].field_10);
int var_38 = LavaList[nLava].field_10;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, LavaList[nLava].nFrame);
int var_38 = LavaList[nLava].nFrame;
short nFlag = FrameFlag[SeqBase[nSeq] + var_38];
@ -305,11 +300,11 @@ void FuncLava(int a, int nDamage, int nRun)
{
seq_MoveSequence(nSprite, nSeq, var_38);
LavaList[nLava].field_10++;
if (LavaList[nLava].field_10 >= SeqSize[nSeq])
LavaList[nLava].nFrame++;
if (LavaList[nLava].nFrame >= SeqSize[nSeq])
{
var_1C = 1;
LavaList[nLava].field_10 = 0;
LavaList[nLava].nFrame = 0;
}
else
{
@ -341,7 +336,7 @@ void FuncLava(int a, int nDamage, int nRun)
PlotCourseToSprite(nSprite, nTarget);
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512);
sprite[nSprite].xvel = Cos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang);
if (nTarget >= 0 && !RandomSize(1))
@ -349,7 +344,7 @@ void FuncLava(int a, int nDamage, int nRun)
LavaList[nLava].nTarget = nTarget;
LavaList[nLava].nAction = 2;
sprite[nSprite].cstat = 0x101;
LavaList[nLava].field_10 = 0;
LavaList[nLava].nFrame = 0;
break;
}
}
@ -368,8 +363,8 @@ void FuncLava(int a, int nDamage, int nRun)
sprite[nSprite].y = y;
sprite[nSprite].z = z;
sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & 0x7FF;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512);
sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang);
break;
}
@ -378,14 +373,14 @@ void FuncLava(int a, int nDamage, int nRun)
break;
}
if ((nVal & 0x0C000) == 0x8000)
if ((nVal & 0xC000) == 0x8000)
{
sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & 0x7FF;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512);
sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang);
break;
}
else if ((nVal & 0x0C000) == 0x0C000)
else if ((nVal & 0xC000) == 0xC000)
{
if ((nVal & 0x3FFF) == nTarget)
{
@ -393,8 +388,8 @@ void FuncLava(int a, int nDamage, int nRun)
if (AngleDiff(sprite[nSprite].ang, nAng) < 64)
{
LavaList[nLava].nAction = 2;
LavaList[nLava].nFrame = 0;
sprite[nSprite].cstat = 0x101;
LavaList[nLava].field_10 = 0;
break;
}
}
@ -414,7 +409,7 @@ void FuncLava(int a, int nDamage, int nRun)
if (var_1C)
{
LavaList[nLava].nAction = 3;
LavaList[nLava].field_10 = 0;
LavaList[nLava].nFrame = 0;
PlotCourseToSprite(nSprite, nTarget);
@ -429,15 +424,15 @@ void FuncLava(int a, int nDamage, int nRun)
if ((nFlag & 0x80) && nTarget > -1)
{
int nHeight = GetSpriteHeight(nSprite);
GetUpAngle(nSprite, 0x0FFFF0600, nTarget, (-(nHeight >> 1)));
GetUpAngle(nSprite, -64000, nTarget, (-(nHeight >> 1)));
BuildBullet(nSprite, 10, Sin(sprite[nSprite].ang + 512) << 8, Sin(sprite[nSprite].ang) << 8, -1, sprite[nSprite].ang, nTarget + 10000, 1);
BuildBullet(nSprite, 10, Cos(sprite[nSprite].ang) << 8, Sin(sprite[nSprite].ang) << 8, -1, sprite[nSprite].ang, nTarget + 10000, 1);
}
else if (var_1C)
{
PlotCourseToSprite(nSprite, nTarget);
LavaList[nLava].nAction = 7;
LavaList[nLava].field_10 = 0;
LavaList[nLava].nFrame = 0;
}
break;
@ -458,22 +453,22 @@ void FuncLava(int a, int nDamage, int nRun)
{
if (nFlag & 0x40)
{
int nLimbSprite = BuildLavaLimb(nSprite, LavaList[nLava].field_10, 0xFA00u);
int nLimbSprite = BuildLavaLimb(nSprite, LavaList[nLava].nFrame, 64000);
D3PlayFX(StaticSound[kSound26], nLimbSprite);
}
if (LavaList[nLava].field_10)
if (LavaList[nLava].nFrame)
{
if (nFlag & 0x80)
{
int ecx = 0;
do
{
BuildLavaLimb(nSprite, ecx, 0xFA00u);
BuildLavaLimb(nSprite, ecx, 64000);
ecx++;
}
while (ecx < 20);
runlist_ChangeChannel(LavaList[nLava].field_12, 1);
runlist_ChangeChannel(LavaList[nLava].nChannel, 1);
}
}
else
@ -489,7 +484,7 @@ void FuncLava(int a, int nDamage, int nRun)
runlist_DoSubRunRec(sprite[nSprite].owner);
runlist_FreeRun(sprite[nSprite].lotag - 1);
runlist_SubRunRec(LavaList[nLava].field_2);
runlist_SubRunRec(LavaList[nLava].nRun);
mydeletesprite(nSprite);
}
@ -501,7 +496,7 @@ void FuncLava(int a, int nDamage, int nRun)
if (var_1C)
{
LavaList[nLava].nAction = 8;
LavaList[nLava].field_10 = 0;
LavaList[nLava].nFrame = 0;
}
break;
}
@ -511,7 +506,7 @@ void FuncLava(int a, int nDamage, int nRun)
if (var_1C)
{
LavaList[nLava].nAction = 0;
LavaList[nLava].field_10 = 0;
LavaList[nLava].nFrame = 0;
sprite[nSprite].cstat = 0x8000;
}
break;

View file

@ -19,10 +19,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __lavadude_h__
#define __lavadude_h__
#include "aistuff.h"
BEGIN_PS_NS
void InitLava();
int BuildLava(short nSprite, int x, int y, int z, short nSector, short nAngle, int lastArg);
int BuildLava(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel);
int BuildLavaLimb(int nSprite, int edx, int ebx);
void FuncLavaLimb(int, int, int);
void FuncLava(int, int, int);

View file

@ -33,21 +33,32 @@ BEGIN_PS_NS
#define kMaxLions 40
short LionCount = -1;
short MoveHook[kMaxLions];
static actionSeq ActionSeq[] = {{54, 1}, {18, 1}, {0, 0}, {10, 0}, {44, 0}, {18, 0}, {26, 0}, {34, 0}, {8, 1}, {9, 1}, {52, 1}, {53, 1}};
static actionSeq ActionSeq[] = {
{54, 1},
{18, 0},
{0, 0},
{10, 0},
{44, 0},
{18, 0},
{26, 0},
{34, 0},
{8, 1},
{9, 1},
{52, 1},
{53, 1}
};
struct Lion
{
short nHealth;
short _b;
short nFrame;
short nAction;
short nSprite;
short nTarget;
short _f;
short _g;
short _h;
};
Lion LionList[kMaxLions];
@ -84,7 +95,6 @@ int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
y = sprite[nSprite].y;
z = sector[sprite[nSprite].sectnum].floorz;
nAngle = sprite[nSprite].ang;
}
assert(nSprite >= 0 && nSprite < kMaxSprites);
@ -113,7 +123,7 @@ int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
LionList[nLion].nAction = 0;
LionList[nLion].nHealth = 500;
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
LionList[nLion].nSprite = nSprite;
LionList[nLion].nTarget = -1;
LionList[nLion]._g = 0;
@ -130,15 +140,15 @@ int BuildLion(short nSprite, int x, int y, int z, short nSector, short nAngle)
void FuncLion(int a, int nDamage, int nRun)
{
int var_18 = 0;
short nLion = RunData[nRun].nVal;
assert(nLion >= 0 && nLion < kMaxLions);
short nSprite = LionList[nLion].nSprite;
short nAction = LionList[nLion].nAction;
int nMessage = a & 0x7F0000;
bool bVal = false;
int nMessage = a & kMessageMask;
switch (nMessage)
{
@ -150,7 +160,7 @@ void FuncLion(int a, int nDamage, int nRun)
case 0x90000:
{
seq_PlotSequence(a, SeqOffsets[kSeqLion] + ActionSeq[nAction].a, LionList[nLion]._b, ActionSeq[nAction].b);
seq_PlotSequence(a, SeqOffsets[kSeqLion] + ActionSeq[nAction].a, LionList[nLion].nFrame, ActionSeq[nAction].b);
return;
}
@ -171,9 +181,10 @@ void FuncLion(int a, int nDamage, int nRun)
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 0;
LionList[nLion].nHealth = 0;
sprite[nSprite].cstat &= 0xFEFE;
LionList[nLion].nHealth = 0;
nCreaturesLeft--;
if (nAction < 10)
@ -188,7 +199,7 @@ void FuncLion(int a, int nDamage, int nRun)
LionList[nLion].nAction = 10;
}
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
return;
}
}
@ -215,18 +226,17 @@ void FuncLion(int a, int nDamage, int nRun)
PlotCourseToSprite(nSprite, nTarget);
LionList[nLion].nAction = 5;
LionList[nLion]._g = RandomSize(3);
sprite[nSprite].ang = (sprite[nSprite].ang - (RandomSize(1) << 8)) + (RandomSize(1) << 8);
sprite[nSprite].ang = (sprite[nSprite].ang - (RandomSize(1) << 8)) + (RandomSize(1) << 8); // NOTE: no angle mask in original code
}
else
{
LionList[nLion].nAction = 8;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
LionList[nLion].nAction = 8;
sprite[nSprite].cstat &= 0xFEFE;
}
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
}
}
}
@ -242,21 +252,21 @@ void FuncLion(int a, int nDamage, int nRun)
short nSeq = SeqOffsets[kSeqLion] + ActionSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, LionList[nLion]._b);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, LionList[nLion].nFrame);
seq_MoveSequence(nSprite, nSeq, LionList[nLion]._b);
seq_MoveSequence(nSprite, nSeq, LionList[nLion].nFrame);
LionList[nLion]._b++;
if (LionList[nLion]._b >= SeqSize[nSeq])
LionList[nLion].nFrame++;
if (LionList[nLion].nFrame >= SeqSize[nSeq])
{
LionList[nLion]._b = 0;
var_18 = 1;
LionList[nLion].nFrame = 0;
bVal = true;
}
short nFlag = FrameFlag[SeqBase[nSeq] + LionList[nLion]._b];
short nFlag = FrameFlag[SeqBase[nSeq] + LionList[nLion].nFrame];
short nTarget = LionList[nLion].nTarget;
int nVal = MoveCreatureWithCaution(nSprite);
int nMov = MoveCreatureWithCaution(nSprite);
switch (nAction)
{
@ -266,7 +276,7 @@ void FuncLion(int a, int nDamage, int nRun)
case 0:
case 1:
{
if ((LionList[nLion]._f & 31) == (totalmoves & 31))
if ((LionList[nLion]._f & 0x1F) == (totalmoves & 0x1F))
{
if (nTarget < 0)
{
@ -275,9 +285,9 @@ void FuncLion(int a, int nDamage, int nRun)
{
D3PlayFX(StaticSound[kSound24], nSprite);
LionList[nLion].nAction = 2;
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512) >> 1;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1;
LionList[nLion].nTarget = nTarget;
return;
@ -293,7 +303,7 @@ void FuncLion(int a, int nDamage, int nRun)
if (RandomBit())
{
sprite[nSprite].ang = RandomWord() & kAngleMask;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512) >> 1;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1;
}
else
@ -315,35 +325,35 @@ void FuncLion(int a, int nDamage, int nRun)
{
PlotCourseToSprite(nSprite, nTarget);
short nAng = sprite[nSprite].ang & 0xFFF8;
int nAng = sprite[nSprite].ang & 0xFFF8;
if (sprite[nSprite].cstat & 0x8000)
{
sprite[nSprite].xvel = Sin(nAng + 512) * 2;
sprite[nSprite].xvel = Cos(nAng) * 2;
sprite[nSprite].yvel = Sin(nAng) * 2;
}
else
{
sprite[nSprite].xvel = Sin(nAng + 512) >> 1;
sprite[nSprite].xvel = Cos(nAng) >> 1;
sprite[nSprite].yvel = Sin(nAng) >> 1;
}
}
if ((nVal & 0xC000) < 0x8000)
if ((nMov & 0xC000) < 0x8000)
{
break;
}
else if ((nVal & 0xC000) == 0x8000)
else if ((nMov & 0xC000) == 0x8000)
{
// loc_378FA:
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512) >> 1;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1;
break;
}
else if ((nVal & 0xC000) == 0xC000)
else if ((nMov & 0xC000) == 0xC000)
{
if ((nVal & 0x3FFF) == nTarget)
if ((nMov & 0x3FFF) == nTarget)
{
if (sprite[nSprite].cstat & 0x8000)
{
@ -362,14 +372,14 @@ void FuncLion(int a, int nDamage, int nRun)
}
}
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
break;
}
else
{
// loc_378FA:
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512) >> 1;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1;
break;
}
@ -402,13 +412,13 @@ void FuncLion(int a, int nDamage, int nRun)
case 4:
{
if (var_18)
if (bVal)
{
LionList[nLion].nAction = 2;
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
}
if (nVal & 0x20000)
if (nMov & 0x20000)
{
sprite[nSprite].xvel >>= 1;
sprite[nSprite].yvel >>= 1;
@ -417,7 +427,7 @@ void FuncLion(int a, int nDamage, int nRun)
return;
}
case 5:
case 5: // Jump away when damaged
{
LionList[nLion]._g--;
if (LionList[nLion]._g <= 0)
@ -429,11 +439,10 @@ void FuncLion(int a, int nDamage, int nRun)
int y = sprite[nSprite].y;
int z = sprite[nSprite].z - (GetSpriteHeight(nSprite) >> 1);
int var_40 = 0x7FFFFFFF;
int nCheckDist = 0x7FFFFFFF;
short var_28 = sprite[nSprite].ang;
short nAng = (sprite[nSprite].ang - 512) & kAngleMask;
short nAngle = sprite[nSprite].ang;
short nScanAngle = (sprite[nSprite].ang - 512) & kAngleMask;
for (int i = 0; i < 5; i++)
{
@ -441,33 +450,33 @@ void FuncLion(int a, int nDamage, int nRun)
int hitx, hity;
vec3_t startPos = { x, y, z };
hitdata_t hitData;
hitscan(&startPos, sprite[nSprite].sectnum, Sin(nAng + 512), Sin(nAng), 0, &hitData, CLIPMASK1);
hitscan(&startPos, sprite[nSprite].sectnum, Cos(nScanAngle), Sin(nScanAngle), 0, &hitData, CLIPMASK1);
hitx = hitData.pos.x;
hity = hitData.pos.y;
hitwall = hitData.wall;
if (hitwall > -1)
{
int ebx = klabs(hitx - x);
int eax = klabs(hity - y);
int theX = klabs(hitx - x);
int theY = klabs(hity - y);
ebx += eax;
if (ebx < var_40)
if ((theX + theY) < nCheckDist)
{
var_40 = ebx;
var_28 = nAng;
nCheckDist = theX;
nAngle = nScanAngle;
}
}
nAng += 256;
nAng &= kAngleMask;
nScanAngle += 256;
nScanAngle &= kAngleMask;
}
sprite[nSprite].ang = var_28;
sprite[nSprite].ang = nAngle;
LionList[nLion].nAction = 6;
sprite[nSprite].xvel = (Sin(sprite[nSprite].ang + 512)) - (Sin(sprite[nSprite].ang + 512) >> 3);
sprite[nSprite].xvel = (Cos(sprite[nSprite].ang)) - (Cos(sprite[nSprite].ang) >> 3);
sprite[nSprite].yvel = (Sin(sprite[nSprite].ang)) - (Sin(sprite[nSprite].ang) >> 3);
D3PlayFX(StaticSound[kSound24], nSprite);
}
@ -477,36 +486,36 @@ void FuncLion(int a, int nDamage, int nRun)
case 6:
{
if (nVal & 0x30000)
if (nMov & 0x30000)
{
LionList[nLion].nAction = 2;
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
return;
}
if ((nVal & 0xC000) == 0x8000)
if ((nMov & 0xC000) == 0x8000)
{
LionList[nLion].nAction = 7;
sprite[nSprite].ang = (GetWallNormal(nVal & 0x3FFF) + 1024) & kAngleMask;
sprite[nSprite].ang = (GetWallNormal(nMov & 0x3FFF) + 1024) & kAngleMask;
LionList[nLion]._g = RandomSize(4);
return;
}
else if ((nVal & 0xC000) == 0xC000)
else if ((nMov & 0xC000) == 0xC000)
{
if ((nVal & 0x3FFF) == nTarget)
if ((nMov & 0x3FFF) == nTarget)
{
int nAng = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y);
if (AngleDiff(sprite[nSprite].ang, nAng) < 64)
{
LionList[nLion].nAction = 3;
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
}
}
else
{
// loc_378FA:
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512) >> 1;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1;
break;
}
@ -534,7 +543,7 @@ void FuncLion(int a, int nDamage, int nRun)
sprite[nSprite].zvel = -1000;
LionList[nLion].nAction = 6;
sprite[nSprite].xvel = (Sin(sprite[nSprite].ang + 512)) - (Sin(sprite[nSprite].ang + 512) >> 3);
sprite[nSprite].xvel = (Cos(sprite[nSprite].ang)) - (Cos(sprite[nSprite].ang) >> 3);
sprite[nSprite].yvel = (Sin(sprite[nSprite].ang)) - (Sin(sprite[nSprite].ang) >> 3);
D3PlayFX(StaticSound[kSound24], nSprite);
}
@ -544,10 +553,10 @@ void FuncLion(int a, int nDamage, int nRun)
case 8:
{
if (var_18)
if (bVal)
{
LionList[nLion].nAction = 2;
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
sprite[nSprite].cstat |= 0x8000;
}
return;
@ -555,9 +564,9 @@ void FuncLion(int a, int nDamage, int nRun)
case 9:
{
if (var_18)
if (bVal)
{
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
LionList[nLion].nAction = 2;
sprite[nSprite].cstat |= 0x101;
}
@ -567,7 +576,7 @@ void FuncLion(int a, int nDamage, int nRun)
case 10:
case 11:
{
if (var_18)
if (bVal)
{
runlist_SubRunRec(sprite[nSprite].owner);
runlist_SubRunRec(MoveHook[nLion]);
@ -583,7 +592,7 @@ void FuncLion(int a, int nDamage, int nRun)
if (!(sprite[nTarget].cstat & 0x101))
{
LionList[nLion].nAction = 1;
LionList[nLion]._b = 0;
LionList[nLion].nFrame = 0;
LionList[nLion]._g = 100;
LionList[nLion].nTarget = -1;
sprite[nSprite].xvel = 0;

View file

@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __lion_h__
#define __lion_h__
#include "aistuff.h"
BEGIN_PS_NS
void InitLion();

View file

@ -1192,13 +1192,13 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
int eax = klabs(Cos(sprite[nSprite].zvel));
int x = ((Cos(nAngle) * ebx) >> 14)* eax;
int x = ((Cos(nAngle) * ebx) >> 14) * eax;
int y = ((Sin(nAngle) * ebx) >> 14) * eax;
int xshift = x >> 8;
int yshift = y >> 8;
int z = Sin(sprite[nSprite].zvel) * ksqrt((yshift * yshift) + (xshift * xshift));
int z = Sin(sprite[nSprite].zvel) * ksqrt((xshift * xshift) + (yshift * yshift));
return movesprite(nSprite, x >> 2, y >> 2, (z >> 13) + (Sin(ecx) >> 5), 0, 0, nClipType);
}

View file

@ -16,7 +16,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "aistuff.h"
#include "mummy.h"
#include "sequence.h"
#include "move.h"
@ -182,6 +181,12 @@ void FuncMummy(int a, int nDamage, int nRun)
switch (nMessage)
{
default:
{
DebugOut("unknown msg %d for Mummy\n", nMessage);
break;
}
case 0x20000:
{
Gravity(nSprite);
@ -195,7 +200,7 @@ void FuncMummy(int a, int nDamage, int nRun)
seq_MoveSequence(nSprite, nSeq, MummyList[nMummy].B);
bool bVal = 0;
bool bVal = false;
MummyList[nMummy].B++;
if (MummyList[nMummy].B >= SeqSize[nSeq])
@ -427,10 +432,12 @@ void FuncMummy(int a, int nDamage, int nRun)
{
if (bVal)
{
MummyList[nMummy].nAction = 0;
sprite[nSprite].cstat = 0x101;
MummyList[nMummy].nAction = 0;
MummyList[nMummy].nHealth = 300;
MummyList[nMummy].nTarget = -1;
nCreaturesLeft++;
}
return;
@ -518,12 +525,6 @@ void FuncMummy(int a, int nDamage, int nRun)
return;
}
default:
{
Printf("unknown msg %d for Mummy\n", a & 0x7F0000);
break;
}
}
}
END_PS_NS

View file

@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __mummy_h__
#define __mummy_h__
#include "aistuff.h"
#include "runlist.h"
BEGIN_PS_NS
@ -26,8 +27,7 @@ BEGIN_PS_NS
#define kMaxMummies 150
void InitMummy();
int BuildMummy(int val, int x, int y, int z, int nSector, int angle);
int BuildMummy(int val, int x, int y, int z, int nSector, int nAngle);
void FuncMummy(int nSector, int edx, int nRun);
END_PS_NS

View file

@ -842,7 +842,7 @@ void DoKenTest()
}
}
void FuncPlayer(int pA, int nDamage, int nRun)
void FuncPlayer(int a, int nDamage, int nRun)
{
int var_48 = 0;
int var_40;
@ -860,7 +860,7 @@ void FuncPlayer(int pA, int nDamage, int nRun)
short nAction = PlayerList[nPlayer].nAction;
short nActionB = PlayerList[nPlayer].nAction;
int nMessage = pA & 0x7F0000;
int nMessage = a & kMessageMask;
short nSprite2;
@ -873,7 +873,7 @@ void FuncPlayer(int pA, int nDamage, int nRun)
{
case 0x90000:
{
seq_PlotSequence(pA & 0xFFFF, SeqOffsets[PlayerList[nPlayer].nSeq] + ActionSeq[nAction].a, PlayerList[nPlayer].field_2, ActionSeq[nAction].b);
seq_PlotSequence(a & 0xFFFF, SeqOffsets[PlayerList[nPlayer].nSeq] + ActionSeq[nAction].a, PlayerList[nPlayer].field_2, ActionSeq[nAction].b);
return;
}
@ -902,7 +902,7 @@ void FuncPlayer(int pA, int nDamage, int nRun)
return;
}
nSprite2 = pA & 0xFFFF;
nSprite2 = a & 0xFFFF;
}
// ok continue case 0x80000 as normal, loc_1C57C

View file

@ -16,10 +16,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "exhumed.h"
#include "aistuff.h"
#include "engine.h"
#include "queen.h"
#include "exhumed.h"
#include "engine.h"
#include "move.h"
#include "sequence.h"
#include "runlist.h"
@ -41,37 +40,37 @@ BEGIN_PS_NS
short QueenCount = 0;
static actionSeq ActionSeq[] = {
{ 0, 0 },
{ 0, 0 },
{ 9, 0 },
{ 36, 0 },
{ 18, 0 },
{ 27, 0 },
{ 45, 0 },
{ 45, 0 },
{ 54, 1 },
{ 53, 1 },
{ 55, 1 }
{0, 0},
{0, 0},
{9, 0},
{36, 0},
{18, 0},
{27, 0},
{45, 0},
{45, 0},
{54, 1},
{53, 1},
{55, 1}
};
static actionSeq HeadSeq[] = {
{ 56, 1 },
{ 65, 0 },
{ 65, 0 },
{ 65, 0 },
{ 65, 0 },
{ 65, 0 },
{ 74, 0 },
{ 82, 0 },
{ 90, 0 }
{56, 1},
{65, 0},
{65, 0},
{65, 0},
{65, 0},
{65, 0},
{74, 0},
{82, 0},
{90, 0}
};
static actionSeq EggSeq[] = {
{ 19, 1 },
{ 18, 1 },
{ 0, 0 },
{ 9, 0 },
{ 23, 1 },
{19, 1},
{18, 1},
{0, 0},
{9, 0},
{23, 1},
};
int nQHead = 0;
@ -90,7 +89,7 @@ short QueenChan[kMaxQueens];
struct Queen
{
short nHealth;
short field_2;
short nFrame;
short nAction;
short nSprite;
short nTarget;
@ -454,18 +453,24 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
{
short nEgg = RunData[nRun].nVal;
int var_14 = 0;
Egg *pEgg = &QueenEgg[nEgg];
short nSprite = pEgg->nSprite;
short nAction = pEgg->nAction;
short nTarget;
int nMessage = a & 0x7F0000;
bool bVal = false;
int nMessage = a & kMessageMask;
switch (nMessage)
{
default:
{
DebugOut("unknown msg %d for Queenhead\n", nMessage);
break;
}
case 0x20000:
{
if (pEgg->nHealth <= 0)
@ -490,7 +495,7 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
if (pEgg->field_2 >= SeqSize[nSeq])
{
pEgg->field_2 = 0;
var_14 = 1;
bVal = true;
}
nTarget = UpdateEnemy(&pEgg->nTarget);
@ -555,7 +560,7 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
case 1:
{
if (var_14)
if (bVal)
{
pEgg->nAction = 3;
sprite[nSprite].cstat = 0x101;
@ -643,13 +648,7 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqQueenEgg] + EggSeq[nAction].a, pEgg->field_2, EggSeq[nAction].b);
break;
}
default:
{
DebugOut("unknown msg %d for Queenhead\n", a & 0x7F0000);
break;
}
}
}
int BuildQueenHead(short nQueen)
@ -1130,7 +1129,7 @@ int BuildQueen(int nSprite, int x, int y, int z, int nSector, int nAngle, int nC
QueenList[nQueen].nAction = 0;
QueenList[nQueen].nHealth = 4000;
QueenList[nQueen].field_2 = 0;
QueenList[nQueen].nFrame = 0;
QueenList[nQueen].nSprite = nSprite;
QueenList[nQueen].nTarget = -1;
QueenList[nQueen].field_A = 0;
@ -1158,20 +1157,27 @@ void SetQueenSpeed(short nSprite, int nSpeed)
void FuncQueen(int a, int nDamage, int nRun)
{
int var_18 = 0;
short nQueen = RunData[nRun].nVal;
assert(nQueen >= 0 && nQueen < kMaxQueens);
int nMessage = a & 0x7F0000;
short nSprite = QueenList[nQueen].nSprite;
short nAction = QueenList[nQueen].nAction;
short si = QueenList[nQueen].field_A;
short nTarget = QueenList[nQueen].nTarget;
bool bVal = false;
int nMessage = a & kMessageMask;
switch (nMessage)
{
default:
{
DebugOut("unknown msg %d for Queen\n", nMessage);
break;
}
case 0x20000:
{
if (si < 3) {
@ -1180,18 +1186,18 @@ void FuncQueen(int a, int nDamage, int nRun)
short nSeq = SeqOffsets[kSeqQueen] + ActionSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, QueenList[nQueen].field_2);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, QueenList[nQueen].nFrame);
seq_MoveSequence(nSprite, nSeq, QueenList[nQueen].field_2);
seq_MoveSequence(nSprite, nSeq, QueenList[nQueen].nFrame);
QueenList[nQueen].field_2++;
if (QueenList[nQueen].field_2 >= SeqSize[nSeq])
QueenList[nQueen].nFrame++;
if (QueenList[nQueen].nFrame >= SeqSize[nSeq])
{
QueenList[nQueen].field_2 = 0;
var_18 = 1;
QueenList[nQueen].nFrame = 0;
bVal = true;
}
short nFlag = FrameFlag[SeqBase[nSeq] + QueenList[nQueen].field_2];
short nFlag = FrameFlag[SeqBase[nSeq] + QueenList[nQueen].nFrame];
if (nTarget > -1)
{
@ -1217,7 +1223,7 @@ void FuncQueen(int a, int nDamage, int nRun)
if (nTarget >= 0)
{
QueenList[nQueen].nAction = QueenList[nQueen].field_A + 1;
QueenList[nQueen].field_2 = 0;
QueenList[nQueen].nFrame = 0;
QueenList[nQueen].nTarget = nTarget;
QueenList[nQueen].field_C = RandomSize(7);
@ -1228,7 +1234,7 @@ void FuncQueen(int a, int nDamage, int nRun)
case 6:
{
if (var_18)
if (bVal)
{
BuildQueenEgg(nQueen, 1);
QueenList[nQueen].nAction = 3;
@ -1250,7 +1256,7 @@ void FuncQueen(int a, int nDamage, int nRun)
{
if (QueenList[nQueen].field_C <= 0)
{
QueenList[nQueen].field_2 = 0;
QueenList[nQueen].nFrame = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
QueenList[nQueen].nAction = si + 4;
@ -1274,7 +1280,7 @@ void FuncQueen(int a, int nDamage, int nRun)
if (nWaspCount < 100)
{
QueenList[nQueen].nAction = 6;
QueenList[nQueen].field_2 = 0;
QueenList[nQueen].nFrame = 0;
break;
}
else
@ -1315,7 +1321,7 @@ void FuncQueen(int a, int nDamage, int nRun)
if (!(sprite[nTarget].cstat & 0x101))
{
QueenList[nQueen].nAction = 0;
QueenList[nQueen].field_2 = 0;
QueenList[nQueen].nFrame = 0;
QueenList[nQueen].field_C = 100;
QueenList[nQueen].nTarget = -1;
@ -1330,7 +1336,7 @@ void FuncQueen(int a, int nDamage, int nRun)
case 4:
case 5:
{
if (var_18 && QueenList[nQueen].field_10 <= 0)
if (bVal && QueenList[nQueen].field_10 <= 0)
{
QueenList[nQueen].nAction = 0;
QueenList[nQueen].field_C = 15;
@ -1359,10 +1365,10 @@ void FuncQueen(int a, int nDamage, int nRun)
case 7:
{
if (var_18)
if (bVal)
{
QueenList[nQueen].nAction = 0;
QueenList[nQueen].field_2 = 0;
QueenList[nQueen].nFrame = 0;
}
break;
@ -1371,7 +1377,7 @@ void FuncQueen(int a, int nDamage, int nRun)
case 8:
case 9:
{
if (var_18)
if (bVal)
{
if (nAction == 9)
{
@ -1385,8 +1391,8 @@ void FuncQueen(int a, int nDamage, int nRun)
short nChunkSprite = BuildCreatureChunk(nSprite, seq_GetSeqPicnum(kSeqQueen, 57, 0)) & 0xFFFF;
sprite[nChunkSprite].picnum = kTile3117 + (i % 3);
sprite[nChunkSprite].yrepeat = 100;
sprite[nChunkSprite].xrepeat = 100;
sprite[nChunkSprite].yrepeat = 100;
}
short nChunkSprite = BuildCreatureChunk(nSprite, seq_GetSeqPicnum(kSeqQueen, 57, 0));
@ -1394,12 +1400,14 @@ void FuncQueen(int a, int nDamage, int nRun)
sprite[nChunkSprite].picnum = kTile3126;
sprite[nChunkSprite].yrepeat = 100;
sprite[nChunkSprite].xrepeat = 100;
PlayFXAtXYZ(
StaticSound[kSound40],
sprite[nSprite].x,
sprite[nSprite].y,
sprite[nSprite].z,
sprite[nSprite].sectnum);
BuildQueenHead(nQueen);
QueenList[nQueen].nAction++;
@ -1474,14 +1482,14 @@ void FuncQueen(int a, int nDamage, int nRun)
break;
}
QueenList[nQueen].field_2 = 0;
QueenList[nQueen].nFrame = 0;
}
else
{
if (si > 0 && !RandomSize(4))
{
QueenList[nQueen].nAction = 7;
QueenList[nQueen].field_2 = 0;
QueenList[nQueen].nFrame = 0;
}
}
}
@ -1490,15 +1498,9 @@ void FuncQueen(int a, int nDamage, int nRun)
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqQueen] + ActionSeq[nAction].a, QueenList[nQueen].field_2, ActionSeq[nAction].b);
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqQueen] + ActionSeq[nAction].a, QueenList[nQueen].nFrame, ActionSeq[nAction].b);
break;
}
default:
{
DebugOut("unknown msg %d for Queen\n", a & 0x7F0000);
break;
}
}
}
END_PS_NS

View file

@ -19,12 +19,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __queen_h__
#define __queen_h__
#include "aistuff.h"
BEGIN_PS_NS
void InitQueens();
int BuildQueen(int nSprite, int x, int y, int z, int nSector, int nAngle, int nVal);
void FuncQueenEgg(int, int, int);
void FuncQueenHead(int, int, int);
void FuncQueen(int, int, int);

View file

@ -32,13 +32,14 @@ BEGIN_PS_NS
/* bjd - the content of the ra.* files originally resided in gun.c I think... */
//#define kMaxRA 8
RA Ra[kMaxPlayers]; // one Ra for each player
short RaCount;
static actionSeq ActionSeq[] = {
{2, 1}, {0, 0}, {1, 0}, {2, 0}
{2, 1},
{0, 0},
{1, 0},
{2, 0}
};
static SavegameHelper sgh("ra",
@ -49,7 +50,7 @@ static SavegameHelper sgh("ra",
void FreeRa(short nPlayer)
{
int nRun = Ra[nPlayer].field_4;
int nRun = Ra[nPlayer].nRun;
int nSprite = Ra[nPlayer].nSprite;
runlist_SubRunRec(nRun);
@ -84,12 +85,12 @@ int BuildRa(short nPlayer)
Ra[nPlayer].nSprite = nSprite;
Ra[nPlayer].field_4 = runlist_AddRunRec(NewRun, nPlayer | 0x210000);
Ra[nPlayer].nRun = runlist_AddRunRec(NewRun, nPlayer | 0x210000);
Ra[nPlayer].nTarget = -1;
Ra[nPlayer].field_2 = 0;
Ra[nPlayer].field_0 = 0;
Ra[nPlayer].nFrame = 0;
Ra[nPlayer].nAction = 0;
Ra[nPlayer].field_C = 0;
Ra[nPlayer].field_E = nPlayer;
Ra[nPlayer].nPlayer = nPlayer;
return nPlayer | 0x210000;
}
@ -104,19 +105,19 @@ void MoveRaToEnemy(short nPlayer)
{
short nTarget = Ra[nPlayer].nTarget;
short nSprite = Ra[nPlayer].nSprite;
short field_0 = Ra[nPlayer].field_0;
short nAction = Ra[nPlayer].nAction;
if (nTarget != -1)
{
if (!(sprite[nTarget].cstat & 0x101) || sprite[nTarget].sectnum == MAXSECTORS)
{
Ra[nPlayer].nTarget = -1;
if (!field_0 || field_0 == 3) {
if (nAction == 0 || nAction == 3) {
return;
}
Ra[nPlayer].field_0 = 3;
Ra[nPlayer].field_2 = 0;
Ra[nPlayer].nAction = 3;
Ra[nPlayer].nFrame = 0;
return;
}
else
@ -128,14 +129,14 @@ void MoveRaToEnemy(short nPlayer)
}
else
{
if (field_0 == 1 || field_0 == 2)
if (nAction == 1 || nAction == 2)
{
Ra[nPlayer].field_0 = 3;
Ra[nPlayer].field_2 = 0;
Ra[nPlayer].nAction = 3;
Ra[nPlayer].nFrame = 0;
return;
}
if (field_0) {
if (nAction) {
return;
}
@ -157,18 +158,18 @@ void FuncRa(int a, int UNUSED(nDamage), int nRun)
short nPlayer = RunData[nRun].nVal;
short nCurrentWeapon = PlayerList[nPlayer].nCurrentWeapon;
int var_14 = 0;
short edx = SeqOffsets[kSeqEyeHit] + ActionSeq[Ra[nPlayer].field_0].a;
short nSeq = SeqOffsets[kSeqEyeHit] + ActionSeq[Ra[nPlayer].nAction].a;
short nSprite = Ra[nPlayer].nSprite;
int nMessage = a & 0x7F0000;
bool bVal = false;
int nMessage = a & kMessageMask;
switch (nMessage)
{
default:
{
Printf("unknown msg %d for Ra\n", a & 0x7F0000);
Printf("unknown msg %d for Ra\n", nMessage);
return;
}
@ -179,21 +180,21 @@ void FuncRa(int a, int UNUSED(nDamage), int nRun)
case 0x20000:
{
Ra[nPlayer].nTarget = sPlayerInput[nPlayer].nTarget;
sprite[nSprite].picnum = seq_GetSeqPicnum2(edx, Ra[nPlayer].field_2);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, Ra[nPlayer].nFrame);
if (Ra[nPlayer].field_0)
if (Ra[nPlayer].nAction)
{
seq_MoveSequence(nSprite, edx, Ra[nPlayer].field_2);
seq_MoveSequence(nSprite, nSeq, Ra[nPlayer].nFrame);
Ra[nPlayer].field_2++;
if (Ra[nPlayer].field_2 >= SeqSize[edx])
Ra[nPlayer].nFrame++;
if (Ra[nPlayer].nFrame >= SeqSize[nSeq])
{
Ra[nPlayer].field_2 = 0;
var_14 = 1;
Ra[nPlayer].nFrame = 0;
bVal = true;
}
}
switch (Ra[nPlayer].field_0)
switch (Ra[nPlayer].nAction)
{
case 0:
{
@ -206,8 +207,8 @@ void FuncRa(int a, int UNUSED(nDamage), int nRun)
else
{
sprite[nSprite].cstat &= 0x7FFF;
Ra[nPlayer].field_0 = 1;
Ra[nPlayer].field_2 = 0;
Ra[nPlayer].nAction = 1;
Ra[nPlayer].nFrame = 0;
}
return;
@ -217,13 +218,13 @@ void FuncRa(int a, int UNUSED(nDamage), int nRun)
{
if (!Ra[nPlayer].field_C)
{
Ra[nPlayer].field_0 = 3;
Ra[nPlayer].field_2 = 0;
Ra[nPlayer].nAction = 3;
Ra[nPlayer].nFrame = 0;
}
else
{
if (var_14) {
Ra[nPlayer].field_0 = 2;
if (bVal) {
Ra[nPlayer].nAction = 2;
}
MoveRaToEnemy(nPlayer);
@ -238,32 +239,32 @@ void FuncRa(int a, int UNUSED(nDamage), int nRun)
if (nCurrentWeapon != kWeaponRing)
{
Ra[nPlayer].field_0 = 3;
Ra[nPlayer].field_2 = 0;
Ra[nPlayer].nAction = 3;
Ra[nPlayer].nFrame = 0;
}
else
{
if (Ra[nPlayer].field_2 || Ra[nPlayer].nTarget <= -1)
if (Ra[nPlayer].nFrame || Ra[nPlayer].nTarget <= -1)
{
if (!var_14) {
if (!bVal) {
return;
}
Ra[nPlayer].field_0 = 3;
Ra[nPlayer].field_2 = 0;
Ra[nPlayer].nAction = 3;
Ra[nPlayer].nFrame = 0;
}
else
{
if (PlayerList[nPlayer].nAmmo[kWeaponRing] > 0)
{
runlist_DamageEnemy(Ra[nPlayer].nTarget, PlayerList[Ra[nPlayer].field_E].nSprite, BulletInfo[kWeaponRing].nDamage);
runlist_DamageEnemy(Ra[nPlayer].nTarget, PlayerList[Ra[nPlayer].nPlayer].nSprite, BulletInfo[kWeaponRing].nDamage);
AddAmmo(nPlayer, kWeaponRing, -WeaponInfo[kWeaponRing].d);
SetQuake(nSprite, 100);
}
else
{
Ra[nPlayer].field_0 = 3;
Ra[nPlayer].field_2 = 0;
Ra[nPlayer].nAction = 3;
Ra[nPlayer].nFrame = 0;
SelectNewWeapon(nPlayer);
}
}
@ -274,11 +275,11 @@ void FuncRa(int a, int UNUSED(nDamage), int nRun)
case 3:
{
if (var_14)
if (bVal)
{
sprite[nSprite].cstat |= 0x8000;
Ra[nPlayer].field_0 = 0;
Ra[nPlayer].field_2 = 0;
Ra[nPlayer].nAction = 0;
Ra[nPlayer].nFrame = 0;
Ra[nPlayer].field_C = 0;
}
@ -293,7 +294,7 @@ void FuncRa(int a, int UNUSED(nDamage), int nRun)
case 0x90000:
{
short nSprite2 = a & 0xFFFF;
seq_PlotSequence(nSprite2, edx, Ra[nPlayer].field_2, 1);
seq_PlotSequence(nSprite2, nSeq, Ra[nPlayer].nFrame, 1);
tsprite[nSprite2].owner = -1;
return;
}

View file

@ -19,18 +19,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __ra_h__
#define __ra_h__
#include "aistuff.h"
BEGIN_PS_NS
struct RA
{
short field_0;
short field_2;
short field_4;
short nAction;
short nFrame;
short nRun;
short nSprite;
short nTarget;
short field_A;
short field_C;
short field_E;
short nPlayer;
};
extern RA Ra[];

View file

@ -16,8 +16,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "engine.h"
#include "rat.h"
#include "engine.h"
#include "sequence.h"
#include "runlist.h"
#include "random.h"
@ -38,19 +38,24 @@ short nMaxChunk;
struct Rat
{
short a;
short nFrame;
short nAction;
short nSprite;
short d;
short nRun;
short nTarget;
short f;
short g;
// short _pad;
};
Rat RatList[kMaxRats];
static actionSeq ActionSeq[] = {{0, 1}, {1, 0}, {1, 0}, {9, 1}, {0, 1}};
static actionSeq ActionSeq[] = {
{0, 1},
{1, 0},
{1, 0},
{9, 1},
{0, 1}
};
static SavegameHelper sgh("rat",
@ -120,8 +125,8 @@ int BuildRat(short nSprite, int x, int y, int z, short nSector, int nAngle)
sprite[nSprite].ang = nAngle;
sprite[nSprite].xrepeat = 50;
sprite[nSprite].yrepeat = 50;
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1;
sprite[nSprite].hitag = 0;
@ -134,7 +139,7 @@ int BuildRat(short nSprite, int x, int y, int z, short nSector, int nAngle)
RatList[nRat].nAction = 4;
}
RatList[nRat].a = 0;
RatList[nRat].nFrame = 0;
RatList[nRat].nSprite = nSprite;
RatList[nRat].nTarget = -1;
RatList[nRat].f = RandomSize(5);
@ -142,7 +147,7 @@ int BuildRat(short nSprite, int x, int y, int z, short nSector, int nAngle)
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nRat | 0x240000);
RatList[nRat].d = runlist_AddRunRec(NewRun, nRat | 0x240000);
RatList[nRat].nRun = runlist_AddRunRec(NewRun, nRat | 0x240000);
return 0;
}
@ -190,9 +195,9 @@ void FuncRat(int a, int nDamage, int nRun)
short nSprite = RatList[nRat].nSprite;
short nAction = RatList[nRat].nAction;
bool var_20 = false;
bool bVal = false;
int nMessage = a & 0x7F0000;
int nMessage = a & kMessageMask;
switch (nMessage)
{
@ -216,29 +221,29 @@ void FuncRat(int a, int nDamage, int nRun)
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
RatList[nRat].nAction = 3;
RatList[nRat].a = 0;
RatList[nRat].nFrame = 0;
}
return;
}
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqRat] + ActionSeq[nAction].a, RatList[nRat].a, ActionSeq[nAction].b);
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqRat] + ActionSeq[nAction].a, RatList[nRat].nFrame, ActionSeq[nAction].b);
return;
}
case 0x20000:
{
int nSeq = SeqOffsets[kSeqRat] + ActionSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, RatList[nRat].a);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, RatList[nRat].nFrame);
seq_MoveSequence(nSprite, nSeq, RatList[nRat].a);
seq_MoveSequence(nSprite, nSeq, RatList[nRat].nFrame);
RatList[nRat].a++;
if (RatList[nRat].a >= SeqSize[nSeq])
RatList[nRat].nFrame++;
if (RatList[nRat].nFrame >= SeqSize[nSeq])
{
var_20 = true;
RatList[nRat].a = 0;
bVal = true;
RatList[nRat].nFrame = 0;
}
short nTarget = RatList[nRat].nTarget;
@ -263,7 +268,7 @@ void FuncRat(int a, int nDamage, int nRun)
if (xVal > 50 || yVal > 50)
{
RatList[nRat].nAction = 2;
RatList[nRat].a = 0;
RatList[nRat].nFrame = 0;
RatList[nRat].nTarget = -1;
sprite[nSprite].xvel = 0;
@ -271,7 +276,7 @@ void FuncRat(int a, int nDamage, int nRun)
return;
}
RatList[nRat].a ^= 1;
RatList[nRat].nFrame ^= 1;
RatList[nRat].f = RandomSize(5) + 4;
RatList[nRat].g--;
@ -289,7 +294,7 @@ void FuncRat(int a, int nDamage, int nRun)
RatList[nRat].nAction = 1;
RatList[nRat].g = 900;
RatList[nRat].a = 0;
RatList[nRat].nFrame = 0;
}
return;
@ -301,7 +306,7 @@ void FuncRat(int a, int nDamage, int nRun)
if (RatList[nRat].g <= 0)
{
RatList[nRat].nAction = 2;
RatList[nRat].a = 0;
RatList[nRat].nFrame = 0;
RatList[nRat].nTarget = -1;
sprite[nSprite].xvel = 0;
@ -328,7 +333,7 @@ void FuncRat(int a, int nDamage, int nRun)
}
RatList[nRat].nAction = 0;
RatList[nRat].a = 0;
RatList[nRat].nFrame = 0;
RatList[nRat].g = RandomSize(3);
sprite[nSprite].xvel = 0;
@ -366,7 +371,7 @@ void FuncRat(int a, int nDamage, int nRun)
SetRatVel(nSprite);
RatList[nRat].nAction = 1;
RatList[nRat].g = 900;
RatList[nRat].a = 0;
RatList[nRat].nFrame = 0;
return;
}
}
@ -375,11 +380,11 @@ void FuncRat(int a, int nDamage, int nRun)
}
case 3:
{
if (var_20)
if (bVal)
{
runlist_DoSubRunRec(sprite[nSprite].owner);
runlist_FreeRun(sprite[nSprite].lotag - 1);
runlist_SubRunRec(RatList[nRat].d);
runlist_SubRunRec(RatList[nRat].nRun);
sprite[nSprite].cstat = 0x8000;
mydeletesprite(nSprite);

View file

@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __rat_h__
#define __rat_h__
#include "aistuff.h"
BEGIN_PS_NS
void InitRats();

View file

@ -39,7 +39,7 @@ short RexChan[kMaxRex];
struct Rex
{
short nHealth;
short field_2;
short nFrame;
short nAction;
short nSprite;
short nTarget;
@ -72,7 +72,7 @@ void InitRexs()
RexCount = kMaxRex;
}
int BuildRex(short nSprite, int x, int y, int z, short nSector, short nAngle, int nVal)
int BuildRex(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel)
{
RexCount--;
@ -120,15 +120,16 @@ int BuildRex(short nSprite, int x, int y, int z, short nSector, short nAngle, in
RexList[nRex].nAction = 0;
RexList[nRex].nHealth = 4000;
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
RexList[nRex].nSprite = nSprite;
RexList[nRex].nTarget = -1;
RexList[nRex].field_A = 0;
RexChan[nRex] = nVal;
RexChan[nRex] = nChannel;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nRex | 0x180000);
// this isn't stored anywhere...
// this isn't stored anywhere.
runlist_AddRunRec(NewRun, nRex | 0x180000);
nCreaturesLeft++;
@ -141,18 +142,18 @@ void FuncRex(int a, int nDamage, int nRun)
short nRex = RunData[nRun].nVal;
assert(nRex >= 0 && nRex < kMaxRex);
int var_1C = 0;
short nAction = RexList[nRex].nAction;
short nSprite = RexList[nRex].nSprite;
int nMessage = a & 0x7F0000;
bool bVal = false;
int nMessage = a & kMessageMask;
switch (nMessage)
{
default:
{
Printf("unknown msg %d for Rex\n", a & 0x7F0000);
Printf("unknown msg %d for Rex\n", nMessage);
return;
}
@ -182,17 +183,19 @@ void FuncRex(int a, int nDamage, int nRun)
if (RexList[nRex].nHealth <= 0)
{
sprite[nSprite].zvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
RexList[nRex].nHealth = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 0;
sprite[nSprite].cstat &= 0xFEFE;
RexList[nRex].nHealth = 0;
nCreaturesLeft--;
if (nAction < 6)
{
RexList[nRex].nAction = 6;
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
}
}
}
@ -202,7 +205,7 @@ void FuncRex(int a, int nDamage, int nRun)
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqRex] + ActionSeq[nAction].a, RexList[nRex].field_2, ActionSeq[nAction].b);
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqRex] + ActionSeq[nAction].a, RexList[nRex].nFrame, ActionSeq[nAction].b);
return;
}
@ -212,31 +215,28 @@ void FuncRex(int a, int nDamage, int nRun)
int nSeq = SeqOffsets[kSeqRex] + ActionSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, RexList[nRex].field_2);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, RexList[nRex].nFrame);
int ecx;
int ecx = 2;
if (nAction != 2) {
ecx = 1;
}
else {
ecx = 2;
}
// moves the mouth open and closed as it's idle?
while (--ecx != -1)
{
seq_MoveSequence(nSprite, nSeq, RexList[nRex].field_2);
seq_MoveSequence(nSprite, nSeq, RexList[nRex].nFrame);
RexList[nRex].field_2++;
if (RexList[nRex].field_2 >= SeqSize[nSeq])
RexList[nRex].nFrame++;
if (RexList[nRex].nFrame >= SeqSize[nSeq])
{
RexList[nRex].field_2 = 0;
var_1C = 1;
RexList[nRex].nFrame = 0;
bVal = true;
}
}
int nFlag = FrameFlag[SeqBase[nSeq] + RexList[nRex].field_2];
int nFlag = FrameFlag[SeqBase[nSeq] + RexList[nRex].nFrame];
short nTarget = RexList[nRex].nTarget;
@ -245,7 +245,6 @@ void FuncRex(int a, int nDamage, int nRun)
default:
return;
// OK
case 0:
{
if (!RexList[nRex].field_A)
@ -270,7 +269,7 @@ void FuncRex(int a, int nDamage, int nRun)
if (RexList[nRex].field_A <= 0)
{
RexList[nRex].nAction = 1;
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2;
@ -284,7 +283,6 @@ void FuncRex(int a, int nDamage, int nRun)
return;
}
// OK
case 1:
{
if (RexList[nRex].field_A > 0)
@ -297,51 +295,56 @@ void FuncRex(int a, int nDamage, int nRun)
if (!RandomSize(1))
{
RexList[nRex].nAction = 5;
RexList[nRex].field_2 = 0;
sprite[nSprite].yvel = 0;
RexList[nRex].nFrame = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
return;
}
else
{
if (((PlotCourseToSprite(nSprite, nTarget) >> 8) >= 60) || RexList[nRex].field_A > 0)
{
sprite[nSprite].xvel = Sin((sprite[nSprite].ang & 0xFFF8) + 512) >> 2;
sprite[nSprite].yvel = Sin((sprite[nSprite].ang & 0xFFF8)) >> 2;
int nAngle = sprite[nSprite].ang & 0xFFF8;
sprite[nSprite].xvel = Cos(nAngle) >> 2;
sprite[nSprite].yvel = Sin(nAngle) >> 2;
}
else
{
RexList[nRex].nAction = 2;
RexList[nRex].field_A = 240;
D3PlayFX(StaticSound[kSound48], nSprite);
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
return;
}
}
}
int nVal = MoveCreatureWithCaution(nSprite);
int nMov = MoveCreatureWithCaution(nSprite);
switch ((nVal & 0xC000))
switch ((nMov & 0xC000))
{
case 0xc000:
if ((nVal & 0x3FFF) == nTarget)
case 0xC000:
{
if ((nMov & 0x3FFF) == nTarget)
{
PlotCourseToSprite(nSprite, nTarget);
RexList[nRex].nAction = 4;
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
break;
}
fallthrough__;
}
case 0x8000:
{
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2;
RexList[nRex].nAction = 1;
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
nAction = 1;
break;
}
}
break;
}
@ -356,11 +359,12 @@ void FuncRex(int a, int nDamage, int nRun)
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1;
int nVal = MoveCreatureWithCaution(nSprite);
int nMov = MoveCreatureWithCaution(nSprite);
switch(nVal & 0x0C000)
switch (nMov & 0xC000)
{
case 0x8000:
{
SetQuake(nSprite, 25);
RexList[nRex].field_A = 60;
@ -368,14 +372,16 @@ void FuncRex(int a, int nDamage, int nRun)
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2;
RexList[nRex].nAction = 1;
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
nAction = 1;
break;
case 0xc000:
}
case 0xC000:
{
RexList[nRex].nAction = 3;
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
short nSprite2 = nVal & 0x3FFF;
short nSprite2 = nMov & 0x3FFF;
if (sprite[nSprite2].statnum && sprite[nSprite2].statnum < 107)
{
@ -383,20 +389,20 @@ void FuncRex(int a, int nDamage, int nRun)
runlist_DamageEnemy(nSprite2, nSprite, 15);
int ebx = Cos(nAngle) * 15;
int edx = Sin(nAngle) * 15;
int xVel = Cos(nAngle) * 15;
int yVel = Sin(nAngle) * 15;
if (sprite[nSprite2].statnum == 100)
{
short nPlayer = GetPlayerFromSprite(nSprite2);
nXDamage[nPlayer] += (ebx << 4);
nYDamage[nPlayer] += (edx << 4);
nXDamage[nPlayer] += (xVel << 4);
nYDamage[nPlayer] += (yVel << 4);
sprite[nSprite2].zvel = -3584;
}
else
{
sprite[nSprite2].xvel += (ebx >> 3);
sprite[nSprite2].yvel += (edx >> 3);
sprite[nSprite2].xvel += (xVel >> 3);
sprite[nSprite2].yvel += (yVel >> 3);
sprite[nSprite2].zvel = -2880;
}
}
@ -405,10 +411,11 @@ void FuncRex(int a, int nDamage, int nRun)
return;
}
}
}
else
{
RexList[nRex].nAction = 1;
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
RexList[nRex].field_A = 90;
}
@ -417,7 +424,7 @@ void FuncRex(int a, int nDamage, int nRun)
case 3:
{
if (var_1C)
if (bVal)
{
RexList[nRex].nAction = 2;
}
@ -445,7 +452,7 @@ void FuncRex(int a, int nDamage, int nRun)
case 5:
{
if (var_1C)
if (bVal)
{
RexList[nRex].nAction = 1;
RexList[nRex].field_A = 15;
@ -455,10 +462,10 @@ void FuncRex(int a, int nDamage, int nRun)
case 6:
{
if (var_1C)
if (bVal)
{
RexList[nRex].nAction = 7;
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
runlist_ChangeChannel(RexChan[nRex], 1);
}
return;
@ -477,11 +484,11 @@ void FuncRex(int a, int nDamage, int nRun)
if ((nTarget != -1) && (!(sprite[nTarget].cstat & 0x101)))
{
RexList[nRex].nAction = 0;
RexList[nRex].field_2 = 0;
RexList[nRex].nFrame = 0;
RexList[nRex].field_A = 0;
RexList[nRex].nTarget = -1;
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
}
}
return;

View file

@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS
void InitRexs();
int BuildRex(short nSprite, int x, int y, int z, short nSector, short nAngle, int nVal);
int BuildRex(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel);
void FuncRex(int, int, int);
END_PS_NS

View file

@ -16,10 +16,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "roach.h"
#include "exhumed.h"
#include "engine.h"
#include "runlist.h"
#include "roach.h"
#include "typedefs.h"
#include "sequence.h"
#include "move.h"
@ -33,10 +33,17 @@ BEGIN_PS_NS
#define kMaxRoach 100
int16_t RoachSprite = -1;
int16_t RoachCount = -1;
static actionSeq ActionSeq[] = {{ 24, 0 }, { 0, 0 }, { 0, 0 }, { 16, 0 }, { 8, 0 }, { 32, 1 }, { 42, 1 }};
static actionSeq ActionSeq[] = {
{24, 0},
{0, 0},
{0, 0},
{16, 0},
{8, 0},
{32, 1},
{42, 1}
};
struct Roach
{
@ -64,7 +71,6 @@ static SavegameHelper sgh("roach",
void InitRoachs()
{
RoachCount = kMaxRoach;
RoachSprite = 1;
}
// TODO - make nType a bool?
@ -137,7 +143,7 @@ int BuildRoach(int nType, int nSprite, int x, int y, int z, short nSector, int a
void GoRoach(short nSprite)
{
sprite[nSprite].xvel = (Sin(sprite[nSprite].ang + 512) >> 1) - (Sin(sprite[nSprite].ang + 512) >> 3);
sprite[nSprite].xvel = (Cos(sprite[nSprite].ang) >> 1) - (Cos(sprite[nSprite].ang) >> 3);
sprite[nSprite].yvel = (Sin(sprite[nSprite].ang) >> 1) - (Sin(sprite[nSprite].ang) >> 3);
}
@ -146,17 +152,18 @@ void FuncRoach(int a, int nDamage, int nRun)
short nRoach = RunData[nRun].nVal;
assert(nRoach >= 0 && nRoach < kMaxRoach);
bool bVar_24 = false;
short nSprite = RoachList[nRoach].nSprite;
short nAction = RoachList[nRoach].nAction;
int nMessage = a & 0x7F0000;
bool bVal = false;
int nMessage = a & kMessageMask;
switch (nMessage)
{
default:
{
Printf("unknown msg %d for Roach\n", a & 0x7F0000);
Printf("unknown msg %d for Roach\n", nMessage);
return;
}
@ -185,9 +192,9 @@ void FuncRoach(int a, int nDamage, int nRun)
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 0;
RoachList[nRoach].nHealth = 0;
sprite[nSprite].cstat &= 0xFEFE;
nCreaturesLeft++; // This seems to be incorrect in original exe? should be decrementing?
RoachList[nRoach].nHealth = 0;
if (nAction < 5)
{
@ -195,6 +202,8 @@ void FuncRoach(int a, int nDamage, int nRun)
RoachList[nRoach].nAction = 5;
RoachList[nRoach].field_2 = 0;
}
nCreaturesLeft--; // NOTE: This was incrementing in original code. Bug?
}
else
{
@ -238,7 +247,7 @@ void FuncRoach(int a, int nDamage, int nRun)
RoachList[nRoach].field_2++;
if (RoachList[nRoach].field_2 >= SeqSize[nSeq])
{
bVar_24 = true;
bVal = true;
RoachList[nRoach].field_2 = 0;
}
@ -283,7 +292,7 @@ void FuncRoach(int a, int nDamage, int nRun)
case 1:
{
// parltly the same as case 0...
// partly the same as case 0.
if (((nRoach & 0xF) == (totalmoves & 0xF)) && nTarget < 0)
{
short nTarget = FindPlayer(nSprite, 100);
@ -307,11 +316,11 @@ void FuncRoach(int a, int nDamage, int nRun)
GoRoach(nSprite);
}
int nVal = MoveCreatureWithCaution(nSprite);
int nMov = MoveCreatureWithCaution(nSprite);
if ((nVal & 0xC000) == 49152)
if ((nMov & 0xC000) == 0xC000)
{
if ((nVal & 0x3FFF) == nTarget)
if ((nMov & 0x3FFF) == nTarget)
{
// repeated below
RoachList[nRoach].field_E = RandomSize(2) + 1;
@ -329,12 +338,11 @@ void FuncRoach(int a, int nDamage, int nRun)
GoRoach(nSprite);
}
}
else if ((nVal & 0xC000) == 32768)
else if ((nMov & 0xC000) == 0x8000)
{
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
GoRoach(nSprite);
}
//else if ((nVal & 0xC000) < 32768)
else
{
if (RoachList[nRoach].field_C != 0)
@ -370,7 +378,7 @@ void FuncRoach(int a, int nDamage, int nRun)
case 3:
{
if (bVar_24)
if (bVal)
{
RoachList[nRoach].field_E--;
if (RoachList[nRoach].field_E <= 0)
@ -394,7 +402,7 @@ void FuncRoach(int a, int nDamage, int nRun)
case 4:
{
if (bVar_24)
if (bVal)
{
RoachList[nRoach].nAction = 2;
RoachList[nRoach].field_2 = 0;
@ -405,7 +413,7 @@ void FuncRoach(int a, int nDamage, int nRun)
case 5:
{
if (bVar_24)
if (bVal)
{
sprite[nSprite].cstat = 0;
RoachList[nRoach].nAction = 6;

View file

@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __roach_h__
#define __roach_h__
#include "aistuff.h"
BEGIN_PS_NS
void InitRoachs();

View file

@ -72,25 +72,8 @@ short NewRun;
int sRunStack[kMaxRunStack];
short RunFree[kMaxRuns];
RunChannel sRunChannels[kMaxChannels];
RunStruct RunData[kMaxRuns];
short word_96760 = 0;
/* variables
Name: _sRunStack
Name: _RunFree
Name: _channel
Name: _RunData
Name: _nRadialOwner
Name: _nDamageRadius
Name: _nRadialDamage
Name: _RunCount
Name: _nRadialSpr
Name: _nStackCount
*/
AiFunc aiFunctions[kFuncMax] = {
FuncElev,
FuncSwReady,
@ -102,7 +85,7 @@ AiFunc aiFunctions[kFuncMax] = {
FuncWallFace,
FuncSlide,
FuncAnubis,
FuncPlayer, // 10
FuncPlayer,
FuncBullet,
FuncSpider,
FuncCreatureChunk,
@ -112,7 +95,7 @@ AiFunc aiFunctions[kFuncMax] = {
FuncSnake,
FuncFish,
FuncLion,
FuncBubble, // 20
FuncBubble,
FuncLava,
FuncLavaLimb,
FuncObject,
@ -122,10 +105,10 @@ AiFunc aiFunctions[kFuncMax] = {
FuncQueenHead,
FuncRoach,
FuncQueenEgg,
FuncWasp, // 30
FuncWasp,
FuncTrap,
FuncFishLimb,
FuncRa, // 33
FuncRa,
FuncScorp,
FuncSoul,
FuncRat,
@ -134,7 +117,6 @@ AiFunc aiFunctions[kFuncMax] = {
};
int runlist_GrabRun()
{
assert(RunCount > 0 && RunCount <= kMaxRuns);
@ -159,7 +141,6 @@ int runlist_FreeRun(int nRun)
return 1;
}
// done
int runlist_HeadRun()
{
int nRun = runlist_GrabRun();
@ -170,7 +151,6 @@ int runlist_HeadRun()
return nRun;
}
// sub 4
void runlist_InitRun()
{
int i;
@ -220,7 +200,6 @@ int runlist_UnlinkRun(int nRun)
return nRun;
}
// done ?
int runlist_InsertRun(int RunLst, int RunNum)
{
assert(RunLst >= 0 && RunLst < kMaxRuns);
@ -238,7 +217,6 @@ int runlist_InsertRun(int RunLst, int RunNum)
return RunNum;
}
// done
int runlist_AddRunRec(int a, int b)
{
int nRun = runlist_GrabRun();
@ -281,7 +259,6 @@ void runlist_CleanRunRecs()
}
}
// done
void runlist_SubRunRec(int RunPtr)
{
assert(RunPtr >= 0 && RunPtr < kMaxRuns);
@ -348,6 +325,7 @@ int runlist_PopMoveRun()
{
if (nStackCount <= 0) {
I_Error("PopMoveRun() called inappropriately\n");
exit(-1);
}
nStackCount--;
@ -1643,8 +1621,6 @@ void runlist_RadialDamageEnemy(short nSprite, short nDamage, short nRadius)
return;
}
word_96760++;
if (nRadialSpr == -1)
{
nRadialDamage = nDamage * 4;
@ -1655,7 +1631,6 @@ void runlist_RadialDamageEnemy(short nSprite, short nDamage, short nRadius)
runlist_ExplodeSignalRun();
nRadialSpr = -1;
word_96760--;
}
}

View file

@ -16,8 +16,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "engine.h"
#include "scorp.h"
#include "engine.h"
#include "runlist.h"
#include "exhumed.h"
#include "move.h"
@ -35,8 +35,23 @@ BEGIN_PS_NS
Selkis Boss AI code
*/
#define kMaxScorpions 5
short ScorpCount = -1;
struct Scorpion
{
short nHealth;
short nFrame;
short nAction;
short nSprite;
short nTarget;
short f;
short g;
int8_t h;
int8_t i;
};
Scorpion scorpion[kMaxScorpions];
short ScorpChan[kMaxScorpions];
@ -102,9 +117,9 @@ int BuildScorp(short nSprite, int x, int y, int z, short nSector, short nAngle,
sprite[nSprite].xoffset = 0;
sprite[nSprite].yoffset = 0;
sprite[nSprite].ang = nAngle;
sprite[nSprite].zvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1;
sprite[nSprite].extra = -1;
sprite[nSprite].hitag = 0;
@ -134,20 +149,20 @@ void FuncScorp(int a, int nDamage, int nRun)
short nScorp = RunData[nRun].nVal;
assert(nScorp >= 0 && nScorp < kMaxScorpions);
int edi = 0;
short nSprite = scorpion[nScorp].nSprite;
short nAction = scorpion[nScorp].nAction;
bool bVal = false;
short nTarget = -1;
int nMessage = a & 0x7F0000;
int nMessage = a & kMessageMask;
switch (nMessage)
{
default:
{
Printf("unknown msg %d for Scorp\n", a & 0x7F0000);
Printf("unknown msg %d for Scorp\n", nMessage);
return;
}
@ -178,19 +193,16 @@ void FuncScorp(int a, int nDamage, int nRun)
if (scorpion[nScorp].nHealth <= 0)
{
scorpion[nScorp].nHealth = 0;
scorpion[nScorp].nAction = 4;
scorpion[nScorp].nFrame = 0;
scorpion[nScorp].g = 10;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 0;
scorpion[nScorp].nAction = 4;
scorpion[nScorp].nFrame = 0;
sprite[nSprite].cstat &= 0xFEFE;
nCreaturesLeft--;
scorpion[nScorp].g = 10;
return;
}
else
@ -238,7 +250,7 @@ void FuncScorp(int a, int nDamage, int nRun)
if (scorpion[nScorp].nFrame >= SeqSize[nSeq])
{
scorpion[nScorp].nFrame = 0;
edi = 1;
bVal = true;
}
int nFlag = FrameFlag[SeqBase[nSeq] + scorpion[nScorp].nFrame];
@ -257,7 +269,7 @@ void FuncScorp(int a, int nDamage, int nRun)
return;
}
if ((nScorp & 31) == (totalmoves & 31))
if ((nScorp & 0x1F) == (totalmoves & 0x1F))
{
if (nTarget < 0)
{
@ -268,7 +280,7 @@ void FuncScorp(int a, int nDamage, int nRun)
D3PlayFX(StaticSound[kSound41], nSprite);
scorpion[nScorp].nFrame = 0;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512);
sprite[nSprite].xvel = Cos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang);
scorpion[nScorp].nAction = 1;
@ -292,10 +304,10 @@ void FuncScorp(int a, int nDamage, int nRun)
}
else
{
int nMove = MoveCreatureWithCaution(nSprite);
if ((nMove & 0xC000) == 0xC000)
int nMov = MoveCreatureWithCaution(nSprite);
if ((nMov & 0xC000) == 0xC000)
{
if (nTarget == (nMove & 0x3FFF))
if (nTarget == (nMov & 0x3FFF))
{
int nAngle = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y);
if (AngleDiff(sprite[nSprite].ang, nAngle) < 64)
@ -304,23 +316,19 @@ void FuncScorp(int a, int nDamage, int nRun)
scorpion[nScorp].nFrame = 0;
}
// GOTO FS_Red
goto FS_Red;
}
else
{
// GOTO FS_Pink_A
goto FS_Pink_A;
}
}
else if ((nMove & 0xC000) == 0x8000)
else if ((nMov & 0xC000) == 0x8000)
{
// GOTO FS_Pink_A
goto FS_Pink_A;
}
else
{
// GOTO FS_Pink_B
goto FS_Pink_B;
}
}
@ -345,20 +353,19 @@ void FuncScorp(int a, int nDamage, int nRun)
}
}
// GOTO FS_Red
goto FS_Red;
}
case 3:
{
if (edi)
if (bVal)
{
scorpion[nScorp].h--;
if (scorpion[nScorp].h <= 0)
{
scorpion[nScorp].nAction = 1;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512);
sprite[nSprite].xvel = Cos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang);
scorpion[nScorp].nFrame = 0;
@ -384,7 +391,7 @@ void FuncScorp(int a, int nDamage, int nRun)
case 6:
case 7:
{
if (!edi) {
if (!bVal) {
return;
}
@ -411,7 +418,7 @@ void FuncScorp(int a, int nDamage, int nRun)
case 8:
{
if (edi)
if (bVal)
{
scorpion[nScorp].nAction++; // set to 9
scorpion[nScorp].nFrame = 0;
@ -427,10 +434,10 @@ void FuncScorp(int a, int nDamage, int nRun)
sprite[nSpiderSprite].ang = RandomSize(11);
int nRnd = RandomSize(5) + 1;
int nVel = RandomSize(5) + 1;
sprite[nSpiderSprite].xvel = (Sin(sprite[nSpiderSprite].ang + 512) >> 8) * nRnd;
sprite[nSpiderSprite].yvel = (Sin(sprite[nSpiderSprite].ang) >> 8) * nRnd;
sprite[nSpiderSprite].xvel = (Cos(sprite[nSpiderSprite].ang) >> 8) * nVel;
sprite[nSpiderSprite].yvel = (Sin(sprite[nSpiderSprite].ang) >> 8) * nVel;
sprite[nSpiderSprite].zvel = (-(RandomSize(5) + 3)) << 8;
}
@ -441,7 +448,7 @@ void FuncScorp(int a, int nDamage, int nRun)
{
sprite[nSprite].cstat &= 0xFEFE;
if (edi)
if (bVal)
{
runlist_SubRunRec(scorpion[nScorp].f);
runlist_DoSubRunRec(sprite[nSprite].owner);
@ -463,7 +470,7 @@ FS_Pink_A:
sprite[nSprite].ang += RandomSize(7) - 63;
sprite[nSprite].ang &= kAngleMask;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512);
sprite[nSprite].xvel = Cos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang);
FS_Pink_B:
@ -478,8 +485,8 @@ FS_Pink_B:
if (cansee(sprite[nSprite].x, sprite[nSprite].y, sprite[nSprite].z - GetSpriteHeight(nSprite), sprite[nSprite].sectnum,
sprite[nTarget].x, sprite[nTarget].y, sprite[nTarget].z - GetSpriteHeight(nTarget), sprite[nTarget].sectnum))
{
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].ang = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y);
scorpion[nScorp].h = RandomSize(2) + RandomSize(3);

View file

@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define __scorp_h__
#include "compat.h"
#include "aistuff.h"
BEGIN_PS_NS
@ -27,21 +28,6 @@ BEGIN_PS_NS
Selkis Boss AI code
*/
#define kMaxScorpions 5
struct Scorpion
{
short nHealth;
short nFrame;
short nAction;
short nSprite;
short nTarget;
short f;
short g;
int8_t h;
int8_t i;
};
void InitScorp();
int BuildScorp(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel);
void FuncScorp(int, int, int);

View file

@ -51,7 +51,7 @@ static actionSeq ActionSeq[] = {
struct Set
{
short nHealth;
short field_2;
short nFrame;
short nAction;
short nSprite;
short nTarget;
@ -76,7 +76,7 @@ void InitSets()
SetCount = kMaxSets;
}
int BuildSet(short nSprite, int x, int y, int z, short nSector, short nAngle, int nVal)
int BuildSet(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel)
{
SetCount--;
@ -125,17 +125,17 @@ int BuildSet(short nSprite, int x, int y, int z, short nSector, short nAngle, in
SetList[nSet].nAction = 1;
SetList[nSet].nHealth = 8000;
SetList[nSet].nSprite = nSprite;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
SetList[nSet].nTarget = -1;
SetList[nSet].field_A = 90;
SetList[nSet].field_C = 0;
SetList[nSet].field_D = 0;
SetChan[nSet] = nVal;
SetChan[nSet] = nChannel;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nSet | 0x190000);
// this isn't stored anywhere...
// this isn't stored anywhere.
runlist_AddRunRec(NewRun, nSet | 0x190000);
nCreaturesLeft++;
@ -150,7 +150,7 @@ int BuildSoul(int nSet)
assert(nSprite >= 0 && nSprite < kMaxSprites);
sprite[nSprite].cstat = 0x8000u;
sprite[nSprite].cstat = 0x8000;
sprite[nSprite].shade = -127;
sprite[nSprite].xrepeat = 1;
sprite[nSprite].yrepeat = 1;
@ -162,7 +162,7 @@ int BuildSoul(int nSet)
sprite[nSprite].ang = RandomSize(11);
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 65280 - RandomSize(10);
sprite[nSprite].zvel = (-256) - RandomSize(10);
sprite[nSprite].x = sprite[nSetSprite].x;
sprite[nSprite].y = sprite[nSetSprite].y;
@ -180,41 +180,41 @@ int BuildSoul(int nSet)
return nSprite | 0x230000;
}
void FuncSoul(int pA, int, int nRun)
void FuncSoul(int a, int, int nRun)
{
short nSoulSprite = RunData[nRun].nVal;
short nSprite = RunData[nRun].nVal;
int nMessage = pA & 0x7F0000;
int nMessage = a & kMessageMask;
switch (nMessage)
{
case 0x20000:
{
seq_MoveSequence(nSoulSprite, SeqOffsets[kSeqSet] + 75, 0);
seq_MoveSequence(nSprite, SeqOffsets[kSeqSet] + 75, 0);
if (sprite[nSoulSprite].xrepeat < 32)
if (sprite[nSprite].xrepeat < 32)
{
sprite[nSoulSprite].xrepeat++;
sprite[nSoulSprite].yrepeat++;
sprite[nSprite].xrepeat++;
sprite[nSprite].yrepeat++;
}
sprite[nSoulSprite].extra += (nSoulSprite & 0x0F) + 5;
sprite[nSoulSprite].extra &= 0x7FF;
sprite[nSprite].extra += (nSprite & 0x0F) + 5;
sprite[nSprite].extra &= kAngleMask;
int ebx = (Sin(sprite[nSoulSprite].extra + 512) >> 7);// *Sin(sprite[nSoulSprite].ang);
int nVel = (Cos(sprite[nSprite].extra) >> 7);
if (movesprite(nSoulSprite, Sin(sprite[nSoulSprite].ang + 512) * ebx, Sin(sprite[nSoulSprite].ang) * ebx, sprite[nSoulSprite].zvel, 5120, 0, CLIPMASK0) & 0x10000)
if (movesprite(nSprite, Cos(sprite[nSprite].ang) * nVel, Sin(sprite[nSprite].ang) * nVel, sprite[nSprite].zvel, 5120, 0, CLIPMASK0) & 0x10000)
{
int nSet = sprite[nSoulSprite].hitag;
int nSet = sprite[nSprite].hitag;
int nSetSprite = SetList[nSet].nSprite;
sprite[nSoulSprite].cstat = 0;
sprite[nSoulSprite].yrepeat = 1;
sprite[nSoulSprite].xrepeat = 1;
sprite[nSoulSprite].x = sprite[nSetSprite].x;
sprite[nSoulSprite].y = sprite[nSetSprite].y;
sprite[nSoulSprite].z = sprite[nSetSprite].z - (GetSpriteHeight(nSetSprite) >> 1);
mychangespritesect(nSoulSprite, sprite[nSetSprite].sectnum);
sprite[nSprite].cstat = 0;
sprite[nSprite].yrepeat = 1;
sprite[nSprite].xrepeat = 1;
sprite[nSprite].x = sprite[nSetSprite].x;
sprite[nSprite].y = sprite[nSetSprite].y;
sprite[nSprite].z = sprite[nSetSprite].z - (GetSpriteHeight(nSetSprite) >> 1);
mychangespritesect(nSprite, sprite[nSetSprite].sectnum);
return;
}
}
@ -231,15 +231,15 @@ void FuncSoul(int pA, int, int nRun)
void FuncSet(int a, int nDamage, int nRun)
{
int var_24 = 0;
short nSet = RunData[nRun].nVal;
assert(nSet >= 0 && nSet < kMaxSets);
short nSprite = SetList[nSet].nSprite;
short nAction = SetList[nSet].nAction;
int nMessage = a & 0x7F0000;
bool bVal = false;
int nMessage = a & kMessageMask;
switch (nMessage)
{
@ -273,21 +273,22 @@ void FuncSet(int a, int nDamage, int nRun)
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 0;
SetList[nSet].nHealth = 0;
sprite[nSprite].cstat &= 0xFEFE;
SetList[nSet].nHealth = 0;
nCreaturesLeft--;
if (nAction < 10)
{
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
SetList[nSet].nAction = 10;
}
}
else if (nAction == 1)
{
SetList[nSet].nAction = 2;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
}
}
return;
@ -295,7 +296,7 @@ void FuncSet(int a, int nDamage, int nRun)
case 0x90000:
{
seq_PlotSequence(a, SeqOffsets[kSeqSet] + ActionSeq[nAction].a, SetList[nSet].field_2, ActionSeq[nAction].b);
seq_PlotSequence(a, SeqOffsets[kSeqSet] + ActionSeq[nAction].a, SetList[nSet].nFrame, ActionSeq[nAction].b);
return;
}
@ -304,24 +305,24 @@ void FuncSet(int a, int nDamage, int nRun)
Gravity(nSprite);
short nSeq = SeqOffsets[kSeqSet] + ActionSeq[SetList[nSet].nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, SetList[nSet].field_2);
seq_MoveSequence(nSprite, nSeq, SetList[nSet].field_2);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, SetList[nSet].nFrame);
seq_MoveSequence(nSprite, nSeq, SetList[nSet].nFrame);
if (nAction == 3)
{
if (SetList[nSet].field_D) {
SetList[nSet].field_2++;
SetList[nSet].nFrame++;
}
}
SetList[nSet].field_2++;
if (SetList[nSet].field_2 >= SeqSize[nSeq])
SetList[nSet].nFrame++;
if (SetList[nSet].nFrame >= SeqSize[nSeq])
{
SetList[nSet].field_2 = 0;
var_24 = 1;
SetList[nSet].nFrame = 0;
bVal = true;
}
short nFlag = FrameFlag[SeqBase[nSeq] + SetList[nSet].field_2];
short nFlag = FrameFlag[SeqBase[nSeq] + SetList[nSet].nFrame];
short nTarget = SetList[nSet].nTarget;
if (nTarget > -1 && nAction < 10)
@ -330,21 +331,20 @@ void FuncSet(int a, int nDamage, int nRun)
{
SetList[nSet].nTarget = -1;
SetList[nSet].nAction = 0;
SetList[nSet].nFrame = 0;
nTarget = -1;
SetList[nSet].field_2 = 0;
}
}
int nVal = MoveCreature(nSprite);
int nSprite_b = nSprite;
int nMov = MoveCreature(nSprite);
pushmove_old(&sprite[nSprite].x, &sprite[nSprite].y, &sprite[nSprite].z, &sprite[nSprite].sectnum, sprite[nSprite].clipdist << 2, 5120, -5120, CLIPMASK0);
if (sprite[nSprite].zvel > 4000)
{
if (nVal & 0x20000)
if (nMov & 0x20000)
{
SetQuake(nSprite_b, 100);
SetQuake(nSprite, 100);
}
}
@ -365,10 +365,10 @@ void FuncSet(int a, int nDamage, int nRun)
if (nTarget >= 0)
{
SetList[nSet].nAction = 3;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
SetList[nSet].nTarget = nTarget;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512) >> 1;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1;
}
}
@ -384,7 +384,7 @@ void FuncSet(int a, int nDamage, int nRun)
if (SetList[nSet].field_A <= 0)
{
SetList[nSet].nAction = 2;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
}
}
@ -393,13 +393,14 @@ void FuncSet(int a, int nDamage, int nRun)
case 2:
{
if (var_24)
if (bVal)
{
SetList[nSet].nAction = 7;
SetList[nSet].field_C = 0;
SetList[nSet].field_2 = 0;
sprite[nSprite].yvel = 0;
SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
SetList[nSet].nTarget = FindPlayer(nSprite, 1000);
}
@ -410,7 +411,7 @@ void FuncSet(int a, int nDamage, int nRun)
{
if (nTarget != -1)
{
if (nFlag & 0x10 && nVal != 0x20000)
if ((nFlag & 0x10) && (nMov & 0x20000))
{
SetQuake(nSprite, 100);
}
@ -428,9 +429,9 @@ void FuncSet(int a, int nDamage, int nRun)
{
SetList[nSet].field_C = 0;
SetList[nSet].nAction = 7;
SetList[nSet].field_2 = 0;
sprite[nSprite].yvel = 0;
SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
return;
}
case 1:
@ -438,10 +439,10 @@ void FuncSet(int a, int nDamage, int nRun)
PlotCourseToSprite(nSprite, nTarget);
SetList[nSet].nAction = 6;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
SetList[nSet].field_E = 5;
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
return;
}
default:
@ -460,8 +461,9 @@ void FuncSet(int a, int nDamage, int nRun)
}
// loc_338E2
sprite[nSprite].xvel = Sin((sprite[nSprite].ang & 0xF8) + 512) >> 1;
sprite[nSprite].yvel = Sin((sprite[nSprite].ang & 0xF8)) >> 1;
int nAngle = sprite[nSprite].ang & 0xFFF8;
sprite[nSprite].xvel = Cos(nAngle) >> 1;
sprite[nSprite].yvel = Sin(nAngle) >> 1;
if (SetList[nSet].field_D)
{
@ -469,13 +471,9 @@ void FuncSet(int a, int nDamage, int nRun)
sprite[nSprite].yvel *= 2;
}
if ((nVal & 0xC000) < 0x8000)
if ((nMov & 0xC000) == 0x8000)
{
break;
}
else if ((nVal & 0xC000) == 0x8000)
{
short nWall = nVal & 0x3FFF;
short nWall = nMov & 0x3FFF;
short nSector = wall[nWall].nextsector;
if (nSector >= 0)
@ -486,28 +484,28 @@ void FuncSet(int a, int nDamage, int nRun)
{
SetList[nSet].field_C = 1;
SetList[nSet].nAction = 7;
SetList[nSet].field_2 = 0;
sprite[nSprite].yvel = 0;
SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
return;
}
}
}
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512) >> 1;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1;
break;
}
else if ((nVal & 0xC000) == 0xC000)
else if ((nMov & 0xC000) == 0xC000)
{
if (nTarget == (nVal & 0x3FFF))
if (nTarget == (nMov & 0x3FFF))
{
int nAng = getangle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].y - sprite[nSprite].y);
if (AngleDiff(sprite[nSprite].ang, nAng) < 64)
{
SetList[nSet].nAction = 4;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
}
break;
}
@ -515,9 +513,9 @@ void FuncSet(int a, int nDamage, int nRun)
{
SetList[nSet].field_C = 1;
SetList[nSet].nAction = 7;
SetList[nSet].field_2 = 0;
sprite[nSprite].yvel = 0;
SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
return;
}
}
@ -527,7 +525,7 @@ void FuncSet(int a, int nDamage, int nRun)
else
{
SetList[nSet].nAction = 0;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
return;
}
}
@ -556,7 +554,7 @@ void FuncSet(int a, int nDamage, int nRun)
case 5:
{
if (var_24)
if (bVal)
{
SetList[nSet].nAction = 0;
SetList[nSet].field_A = 15;
@ -576,7 +574,7 @@ void FuncSet(int a, int nDamage, int nRun)
if (SetList[nSet].field_E <= 0 || !RandomBit())
{
SetList[nSet].nAction = 0;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
}
}
return;
@ -584,7 +582,7 @@ void FuncSet(int a, int nDamage, int nRun)
case 7:
{
if (var_24)
if (bVal)
{
if (SetList[nSet].field_C)
{
@ -596,9 +594,9 @@ void FuncSet(int a, int nDamage, int nRun)
}
SetList[nSet].nAction = 8;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512);
sprite[nSprite].xvel = Cos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang);
}
return;
@ -606,16 +604,16 @@ void FuncSet(int a, int nDamage, int nRun)
case 8:
{
if (var_24)
if (bVal)
{
SetList[nSet].field_2 = SeqSize[nSeq] - 1;
SetList[nSet].nFrame = SeqSize[nSeq] - 1;
}
if (nVal & 0x20000)
if (nMov & 0x20000)
{
SetQuake(nSprite, 200);
SetList[nSet].nAction = 9;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
}
return;
}
@ -625,19 +623,19 @@ void FuncSet(int a, int nDamage, int nRun)
sprite[nSprite].xvel >>= 1;
sprite[nSprite].yvel >>= 1;
if (var_24)
if (bVal)
{
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
PlotCourseToSprite(nSprite, nTarget);
SetList[nSet].nAction = 6;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
SetList[nSet].field_E = 5;
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
}
return;
}
@ -651,10 +649,10 @@ void FuncSet(int a, int nDamage, int nRun)
sprite[nSprite].z += GetSpriteHeight(nSprite);
}
if (var_24)
if (bVal)
{
SetList[nSet].nAction = 11;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
runlist_ChangeChannel(SetChan[nSet], 1);
@ -668,7 +666,7 @@ void FuncSet(int a, int nDamage, int nRun)
case 11:
{
sprite[nSprite].cstat &= 0x0FEFE;
sprite[nSprite].cstat &= 0xFEFE;
return;
}
}
@ -681,7 +679,7 @@ void FuncSet(int a, int nDamage, int nRun)
if (!(sprite[nTarget].cstat & 0x101))
{
SetList[nSet].nAction = 0;
SetList[nSet].field_2 = 0;
SetList[nSet].nFrame = 0;
SetList[nSet].field_A = 100;
SetList[nSet].nTarget = -1;
sprite[nSprite].xvel = 0;

View file

@ -19,10 +19,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __set_h__
#define __set_h__
#include "aistuff.h"
BEGIN_PS_NS
void InitSets();
int BuildSet(short nSprite, int x, int y, int z, short nSector, short nAngle, int nVal);
int BuildSet(short nSprite, int x, int y, int z, short nSector, short nAngle, int nChannel);
void FuncSoul(int, int, int);
void FuncSet(int, int, int);

View file

@ -308,7 +308,7 @@ int FindSnakeEnemy(short nSnake)
void FuncSnake(int a, int UNUSED(nDamage), int nRun)
{
int nMessage = a & 0x7F0000;
int nMessage = a & kMessageMask;
switch (nMessage)
{
@ -426,7 +426,7 @@ SEARCH_ENEMY:
default:
{
Printf("unknown msg %x for bullet\n", a & 0x7F0000);
Printf("unknown msg %x for bullet\n", nMessage);
break;
}
}

View file

@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __snake_h__
#define __snake_h__
#include "aistuff.h"
BEGIN_PS_NS
#define kSnakeSprites 8 // or rename to kSnakeParts?

View file

@ -16,8 +16,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h"
#include "exhumed.h"
#include "spider.h"
#include "exhumed.h"
#include "engine.h"
#include "runlist.h"
#include "move.h"
@ -29,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_PS_NS
short SpiderSprite = -1;
short SpiderCount = 0;
#define kMaxSpiders 100
@ -37,18 +36,24 @@ short SpiderCount = 0;
struct Spider
{
short nHealth;
short b;
short nFrame;
short nAction;
short nSprite;
short nTarget;
short f;
short g;
short h;
short nRun;
};
Spider SpiderList[kMaxSpiders];
static actionSeq ActionSeq[] = { {16, 0}, {8, 0}, {32, 0}, {24, 0}, {0, 0}, {40, 1}, {41, 1} };
static actionSeq ActionSeq[] = {
{16, 0},
{8, 0},
{32, 0},
{24, 0},
{0, 0},
{40, 1},
{41, 1}
};
static SavegameHelper sgh("spider",
SV(SpiderSprite),
@ -59,7 +64,6 @@ static SavegameHelper sgh("spider",
void InitSpider()
{
SpiderCount = 0;
SpiderSprite = 1;
}
int BuildSpider(int nSprite, int x, int y, int z, short nSector, int nAngle)
@ -107,14 +111,14 @@ int BuildSpider(int nSprite, int x, int y, int z, short nSector, int nAngle)
// GrabTimeSlot(3);
SpiderList[nSpider].nAction = 0;
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
SpiderList[nSpider].nSprite = nSprite;
SpiderList[nSpider].nTarget = -1;
SpiderList[nSpider].nHealth = 160;
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nSpider | 0xC0000);
SpiderList[nSpider].h = runlist_AddRunRec(NewRun, nSpider | 0xC0000);
SpiderList[nSpider].nRun = runlist_AddRunRec(NewRun, nSpider | 0xC0000);
nCreaturesLeft++;
@ -126,18 +130,24 @@ void FuncSpider(int a, int nDamage, int nRun)
short nSpider = RunData[nRun].nVal;
assert(nSpider >= 0 && nSpider < kMaxSpiders);
int var_14;
int nVel = 0;
short nSprite = SpiderList[nSpider].nSprite;
short nAction = SpiderList[nSpider].nAction;
int nMessage = a & 0x7F0000;
int nMessage = a & kMessageMask;
switch (nMessage)
{
default:
{
DebugOut("unknown msg %d for Spider\n", nMessage);
break;
}
case 0x20000:
{
var_14 = 6;
nVel = 6;
if (SpiderList[nSpider].nHealth)
{
@ -153,15 +163,15 @@ void FuncSpider(int a, int nDamage, int nRun)
int nSeq = SeqOffsets[kSeqSpider] + ActionSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, SpiderList[nSpider].b);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, SpiderList[nSpider].nFrame);
seq_MoveSequence(nSprite, nSeq, SpiderList[nSpider].b);
seq_MoveSequence(nSprite, nSeq, SpiderList[nSpider].nFrame);
int nFrameFlag = FrameFlag[SeqBase[nSeq] + SpiderList[nSpider].b];
int nFrameFlag = FrameFlag[SeqBase[nSeq] + SpiderList[nSpider].nFrame];
SpiderList[nSpider].b++;
if (SpiderList[nSpider].b >= SeqSize[nSeq]) {
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame++;
if (SpiderList[nSpider].nFrame >= SeqSize[nSeq]) {
SpiderList[nSpider].nFrame = 0;
}
short nTarget = SpiderList[nSpider].nTarget;
@ -184,7 +194,7 @@ void FuncSpider(int a, int nDamage, int nRun)
if (nTarget >= 0)
{
SpiderList[nSpider].nAction = 1;
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
SpiderList[nSpider].nTarget = nTarget;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang);
@ -198,19 +208,18 @@ void FuncSpider(int a, int nDamage, int nRun)
case 1:
{
if (nTarget >= 0) {
var_14++;
nVel++;
}
goto case_3;
break;
}
case 4:
{
if (!SpiderList[nSpider].b)
if (!SpiderList[nSpider].nFrame)
{
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
SpiderList[nSpider].nAction = 1;
}
//break; // fall through
fallthrough__;
}
case 3:
@ -229,7 +238,7 @@ void FuncSpider(int a, int nDamage, int nRun)
sprite[nSprite].zvel = 1;
SpiderList[nSpider].nAction = 3;
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
}
}
@ -252,7 +261,7 @@ void FuncSpider(int a, int nDamage, int nRun)
{
if (sprite[nSprite].cstat & 8)
{
sprite[nSprite].cstat ^= 8u;
sprite[nSprite].cstat ^= 8;
sprite[nSprite].zvel = 1;
sprite[nSprite].z = sector[nSector].ceilingz + GetSpriteHeight(nSprite);
}
@ -262,7 +271,7 @@ void FuncSpider(int a, int nDamage, int nRun)
}
SpiderList[nSpider].nAction = 3;
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
if (!RandomSize(3)) {
D3PlayFX(StaticSound[kSound29], nSprite);
@ -273,11 +282,11 @@ void FuncSpider(int a, int nDamage, int nRun)
}
case 5:
{
if (!SpiderList[nSpider].b)
if (!SpiderList[nSpider].nFrame)
{
runlist_DoSubRunRec(sprite[nSprite].owner);
runlist_FreeRun(sprite[nSprite].lotag - 1);
runlist_SubRunRec(SpiderList[nSpider].h);
runlist_SubRunRec(SpiderList[nSpider].nRun);
sprite[nSprite].cstat = 0x8000;
mydeletesprite(nSprite);
}
@ -306,7 +315,7 @@ void FuncSpider(int a, int nDamage, int nRun)
sprite[nSprite].yvel = 0;
}
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
break;
}
}
@ -315,13 +324,13 @@ void FuncSpider(int a, int nDamage, int nRun)
{
SpiderList[nSpider].nTarget = -1;
SpiderList[nSpider].nAction = 0;
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
}
int nMov = movesprite(nSprite, sprite[nSprite].xvel << var_14, sprite[nSprite].yvel << var_14, sprite[nSprite].zvel, 1280, -1280, CLIPMASK0);
int nMov = movesprite(nSprite, sprite[nSprite].xvel << nVel, sprite[nSprite].yvel << nVel, sprite[nSprite].zvel, 1280, -1280, CLIPMASK0);
if (!nMov)
return;
@ -336,7 +345,7 @@ void FuncSpider(int a, int nDamage, int nRun)
sprite[nSprite].zvel = 0;
SpiderList[nSpider].nAction = 1;
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
return;
}
else
@ -358,7 +367,7 @@ void FuncSpider(int a, int nDamage, int nRun)
if (AngleDiff(sprite[nSprite].ang, nAng) < 64)
{
SpiderList[nSpider].nAction = 2;
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
}
}
return;
@ -370,7 +379,7 @@ void FuncSpider(int a, int nDamage, int nRun)
if (SpiderList[nSpider].nAction == 3)
{
SpiderList[nSpider].nAction = 1;
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
}
return;
}
@ -380,7 +389,7 @@ void FuncSpider(int a, int nDamage, int nRun)
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqSpider] + ActionSeq[nAction].a, SpiderList[nSpider].b, ActionSeq[nAction].b);
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqSpider] + ActionSeq[nAction].a, SpiderList[nSpider].nFrame, ActionSeq[nAction].b);
break;
}
@ -405,7 +414,8 @@ void FuncSpider(int a, int nDamage, int nRun)
if (SpiderList[nSpider].nHealth > 0)
{
/*
TODO - nTarget check was added, but should we return if it's invalid instead
NOTE:
nTarget check was added, but should we return if it's invalid instead
or should code below (action set, b set) happen?
Other AI doesn't show consistency in this regard (see Scorpion code)
*/
@ -415,14 +425,14 @@ void FuncSpider(int a, int nDamage, int nRun)
}
SpiderList[nSpider].nAction = 4;
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
}
else
{
// creature is dead, make some chunks
SpiderList[nSpider].nHealth = 0;
SpiderList[nSpider].nAction = 5;
SpiderList[nSpider].b = 0;
SpiderList[nSpider].nFrame = 0;
sprite[nSprite].cstat &= 0xFEFE;
@ -436,12 +446,6 @@ void FuncSpider(int a, int nDamage, int nRun)
return;
}
default:
{
Printf("unknown msg %d for Spider\n", a & 0x7F0000);
break;
}
}
}
END_PS_NS

View file

@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __spider_h__
#define __spider_h__
#include "aistuff.h"
BEGIN_PS_NS
void InitSpider();

View file

@ -24,6 +24,7 @@ BEGIN_PS_NS
#define kAngleMask 0x7FF
int GetMyAngle(int x, int y);
int AngleDiff(short a, short b);
int AngleDelta(int a, int b, int c);

View file

@ -51,15 +51,11 @@ extern fix16_t nDestVertPan[];
extern short dVertPan[];
extern fix16_t nVertPan[];
extern short nQuake[];
extern int nCamerax;
extern int nCameray;
extern int nCameraz;
extern short bTouchFloor;
extern short nChunkTotal;
extern int gFov;
static inline int angle_interpolate16(int a, int b, int smooth)

View file

@ -38,22 +38,30 @@ short nWaspCount;
struct Wasp
{
short nHealth;
short field_2;
short nFrame;
short nAction;
short nSprite;
short field_8;
short nRun;
short nTarget;
short field_C;
short field_E;
short field_10;
short field_12;
short field_14;
short field_16;
short nDamage;
};
Wasp WaspList[kMaxWasps];
static actionSeq ActionSeq[] = {{0,0}, {0,0}, {9,0}, {18,0}, {27,1}, {28,1}, {29,1}};
static actionSeq ActionSeq[] = {
{0, 0},
{0, 0},
{9, 0},
{18, 0},
{27, 1},
{28, 1},
{29, 1}
};
static SavegameHelper sgh("wasp",
SV(nVelShift),
@ -71,15 +79,14 @@ void SetWaspVel(short nSprite)
{
if (nVelShift < 0)
{
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512) << -nVelShift;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) << -nVelShift;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) << -nVelShift;
}
else
{
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512) >> nVelShift;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> nVelShift;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> nVelShift;
}
}
int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
@ -118,8 +125,8 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
if (bEggWasp)
{
sprite[nSprite].yrepeat = 20;
sprite[nSprite].xrepeat = 20;
sprite[nSprite].yrepeat = 20;
}
else
{
@ -131,8 +138,8 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
sprite[nSprite].yoffset = 0;
sprite[nSprite].picnum = 1;
sprite[nSprite].ang = nAngle;
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 0;
sprite[nSprite].hitag = 0;
sprite[nSprite].lotag = runlist_HeadRun() + 1;
@ -141,16 +148,16 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
// GrabTimeSlot(3);
WaspList[nWasp].nAction = 0;
WaspList[nWasp].field_2 = 0;
WaspList[nWasp].nFrame = 0;
WaspList[nWasp].nSprite = nSprite;
WaspList[nWasp].nTarget = -1;
WaspList[nWasp].nHealth = 800;
WaspList[nWasp].field_16 = 10;
WaspList[nWasp].nDamage = 10;
if (bEggWasp)
{
WaspList[nWasp].field_C = 60;
WaspList[nWasp].field_16 = (WaspList[nWasp].field_16 - 1) >> 1;
WaspList[nWasp].nDamage /= 2;
}
else
{
@ -164,7 +171,7 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
sprite[nSprite].owner = runlist_AddRunRec(sprite[nSprite].lotag - 1, nWasp | 0x1E0000);
WaspList[nWasp].field_8 = runlist_AddRunRec(NewRun, nWasp | 0x1E0000);
WaspList[nWasp].nRun = runlist_AddRunRec(NewRun, nWasp | 0x1E0000);
nCreaturesLeft++;
return nSprite;
@ -173,21 +180,20 @@ int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
void FuncWasp(int a, int nDamage, int nRun)
{
short nWasp = RunData[nRun].nVal;
short nTarget = -1;
short nSprite = WaspList[nWasp].nSprite;
short nAction = WaspList[nWasp].nAction;
int someval = 0;
short nTarget = -1;
int nMessage = a & 0x7F0000;
bool bVal = false;
int nMessage = a & kMessageMask;
switch (nMessage)
{
case 0x90000:
{
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqWasp] + ActionSeq[nAction].a, WaspList[nWasp].field_2, ActionSeq[nAction].b);
seq_PlotSequence(a & 0xFFFF, SeqOffsets[kSeqWasp] + ActionSeq[nAction].a, WaspList[nWasp].nFrame, ActionSeq[nAction].b);
return;
}
@ -216,7 +222,7 @@ void FuncWasp(int a, int nDamage, int nRun)
if (!RandomSize(4))
{
WaspList[nWasp].nAction = 3;
WaspList[nWasp].field_2 = 0;
WaspList[nWasp].nFrame = 0;
}
WaspList[nWasp].nAction = 1;
@ -230,20 +236,19 @@ void FuncWasp(int a, int nDamage, int nRun)
else
{
// Wasp is dead
WaspList[nWasp].nAction = 4;
WaspList[nWasp].field_2 = 0;
nVelShift = 0;
WaspList[nWasp].nAction = 4;
WaspList[nWasp].nFrame = 0;
sprite[nSprite].cstat = 0;
nCreaturesLeft--;
sprite[nSprite].ang = (sprite[nSprite].ang + 1024) & kAngleMask;
SetWaspVel(nSprite);
sprite[nSprite].zvel = 512;
nCreaturesLeft--;
}
}
return;
@ -253,15 +258,15 @@ void FuncWasp(int a, int nDamage, int nRun)
{
short nSeq = SeqOffsets[kSeqWasp] + ActionSeq[nAction].a;
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, WaspList[nWasp].field_2);
sprite[nSprite].picnum = seq_GetSeqPicnum2(nSeq, WaspList[nWasp].nFrame);
seq_MoveSequence(nSprite, nSeq, WaspList[nWasp].field_2);
seq_MoveSequence(nSprite, nSeq, WaspList[nWasp].nFrame);
WaspList[nWasp].field_2++;
if (WaspList[nWasp].field_2 >= SeqSize[nSeq])
WaspList[nWasp].nFrame++;
if (WaspList[nWasp].nFrame >= SeqSize[nSeq])
{
WaspList[nWasp].field_2 = 0;
someval = 1;
WaspList[nWasp].nFrame = 0;
bVal = true;
}
if (WaspList[nWasp].nHealth > 0)
@ -280,6 +285,9 @@ void FuncWasp(int a, int nDamage, int nRun)
switch (nAction)
{
default:
return;
case 0:
{
sprite[nSprite].zvel = Sin(WaspList[nWasp].field_E) >> 4;
@ -298,9 +306,9 @@ void FuncWasp(int a, int nDamage, int nRun)
}
else
{
WaspList[nWasp].nAction = 1;
sprite[nSprite].zvel = 0;
WaspList[nWasp].field_2 = 0;
WaspList[nWasp].nAction = 1;
WaspList[nWasp].nFrame = 0;
WaspList[nWasp].field_12 = 1500;
WaspList[nWasp].field_C = RandomSize(5) + 60;
}
@ -343,11 +351,11 @@ void FuncWasp(int a, int nDamage, int nRun)
short nSprite2 = (nChaseVal & 0x3FFF);
if (nSprite2 == nTarget)
{
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
runlist_DamageEnemy(nSprite2, nSprite, WaspList[nWasp].field_16);
sprite[nSprite].yvel = 0;
runlist_DamageEnemy(nSprite2, nSprite, WaspList[nWasp].nDamage);
WaspList[nWasp].nAction = 2;
WaspList[nWasp].field_2 = 0;
WaspList[nWasp].nFrame = 0;
}
return;
}
@ -359,15 +367,14 @@ void FuncWasp(int a, int nDamage, int nRun)
case 2:
case 3:
{
if (someval)
if (bVal)
{
WaspList[nWasp].nAction = 1;
sprite[nSprite].ang = RandomSize(9) + 768;
sprite[nSprite].ang += RandomSize(9) + 768;
sprite[nSprite].ang &= kAngleMask;
WaspList[nWasp].field_12 = 3000;
sprite[nSprite].zvel = (-20) - RandomSize(6);
WaspList[nWasp].nAction = 1;
WaspList[nWasp].field_12 = 3000;
}
return;
}
@ -378,11 +385,11 @@ void FuncWasp(int a, int nDamage, int nRun)
if (nMove)
{
sprite[nSprite].yvel = 0;
WaspList[nWasp].nAction = 5;
sprite[nSprite].xvel = 0;
WaspList[nWasp].field_2 = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 1024;
WaspList[nWasp].nAction = 5;
WaspList[nWasp].nFrame = 0;
}
return;
@ -401,21 +408,17 @@ void FuncWasp(int a, int nDamage, int nRun)
sprite[nSprite].cstat |= 0x8000;
}
sprite[nSprite].zvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].xvel = 0;
sprite[nSprite].yvel = 0;
sprite[nSprite].zvel = 0;
WaspList[nWasp].nAction = 6;
WaspList[nWasp].field_2 = 0;
runlist_SubRunRec(WaspList[nWasp].field_8);
WaspList[nWasp].nFrame = 0;
runlist_SubRunRec(WaspList[nWasp].nRun);
}
return;
}
default:
{
return;
}
}
break;
}

View file

@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __wasp_h__
#define __wasp_h__
#include "aistuff.h"
BEGIN_PS_NS
extern short nWaspCount;