Increased itemFlags array; Added startPos to ITEM_INFO; Improved wraiths; Rewritten BuildOutsideRoomsTable;

This commit is contained in:
MontyTRC89 2020-08-04 21:53:58 +02:00
parent 85ac7c74e6
commit fdf2de1e89
4 changed files with 23 additions and 40 deletions

View file

@ -3246,8 +3246,8 @@ int IsRoomOutside(int x, int y, int z)
if (x < 0 || z < 0)
return -2;
int xTable = x / 4 / 1024;
int zTable = z / 4 / 1024;
int xTable = x/* / 4*/ / 1024;
int zTable = z /*/ 4*/ / 1024;
if (OutsideRoomTable[xTable][zTable].size() == 0)
return -2;

View file

@ -55,7 +55,7 @@ typedef struct ITEM_INFO
short carriedItem;
short afterDeath;
short firedWeapon;
short itemFlags[4];
short itemFlags[8];
void* data;
PHD_3DPOS pos;
bool active;
@ -72,6 +72,7 @@ typedef struct ITEM_INFO
int swapMeshFlags;
short drawRoom;
short TOSSPAD;
PHD_3DPOS startPos;
};
// used by fx->shade !

View file

@ -24,7 +24,7 @@ void InitialiseWraith(short itemNumber)
wraithData = game_malloc<WRAITH_INFO>(WRAITH_COUNT);
item->data = wraithData;
item->itemFlags[0] = 0;
item->hitPoints = 0;
item->itemFlags[6] = 0;
item->speed = WraithSpeed;
for (int i = 0; i < WRAITH_COUNT; i++)
@ -51,8 +51,8 @@ void WraithControl(short itemNumber)
// hitPoints stores the target of wraith
ITEM_INFO* target;
if (item->hitPoints)
target = &g_Level.Items[item->hitPoints];
if (item->itemFlags[6])
target = &g_Level.Items[item->itemFlags[6]];
else
target = LaraItem;
@ -190,7 +190,7 @@ void WraithControl(short itemNumber)
if (linkNum != NO_ITEM)
{
item->hitPoints = linkNum;
item->itemFlags[6] = linkNum;
}
}
@ -243,11 +243,11 @@ void WraithControl(short itemNumber)
{
item->speed++;
}
if (item->hitPoints)
if (item->itemFlags[6])
{
if (item->TOSSPAD /*& 0x3E00*/)
if (item->itemFlags[7])
{
item->TOSSPAD--; // = ((item->TOSSPAD & 0xFE00) - 1) & 0x3E00;
item->itemFlags[7]--; // = ((item->TOSSPAD & 0xFE00) - 1) & 0x3E00;
}
}
}
@ -275,8 +275,8 @@ void WraithControl(short itemNumber)
else if (target->objectNumber == ID_ANIMATING10)
{
// ANIMATING10 is the sacred pedistal that can kill WRAITH
item->TOSSPAD++; // ((item->TOSSPAD & 0xFE00) + 512) & 0x3E00; // HACK: maybe create new var for this
if (item->TOSSPAD > 25 /* (item->TOSSPAD & 0x3E00) > 12800*/)
item->itemFlags[7]++;
if (item->itemFlags[7] > 10)
{
item->pos.xPos = target->pos.xPos;
item->pos.yPos = target->pos.yPos - 384;
@ -295,12 +295,12 @@ void WraithControl(short itemNumber)
else
{
// Target is another WRAITH (fire vs ice), they kill both themselves
item->TOSSPAD = item->TOSSPAD & 0xD5 | 0x14;
if (item->TOSSPAD /*& 0x3E00*/)
target->itemFlags[7] = target->itemFlags[7] & 0x6A | 0xA;
if (item->itemFlags[7])
{
TriggerExplosionSparks(item->pos.xPos, item->pos.yPos, item->pos.zPos, 2, -2, 1, item->roomNumber);
target->hitPoints = 0;
KillItem(item->hitPoints);
KillItem(item->itemFlags[6]);
KillItem(itemNumber);
}
}

View file

@ -116,6 +116,7 @@ int LoadItems()
item->shade = ReadInt16();
item->triggerFlags = ReadInt16();
item->flags = ReadInt16();
memcpy(&item->startPos, &item->pos, sizeof(PHD_3DPOS));
}
for (int i = 0; i < g_Level.NumItems; i++)
@ -1113,41 +1114,22 @@ void GetAIPickups()
void BuildOutsideRoomsTable()
{
int maxSlots = 0;
// Clear the tabel
for (int x = 0; x < OUTSIDE_SIZE; x++)
for (int z = 0; z < OUTSIDE_SIZE; z++)
OutsideRoomTable[x][z].clear();
for (int x = 0; x < OUTSIDE_SIZE * 4; x += 4)
for (int x = 0; x < OUTSIDE_SIZE; x++)
{
for (int z = 0; z < OUTSIDE_SIZE * 4; z += 4)
for (int z = 0; z < OUTSIDE_SIZE; z++)
{
for (int i = 0; i < g_Level.Rooms.size(); i++)
{
ROOM_INFO* r = &g_Level.Rooms[i];
int rx = (r->x / 1024) + 1;
int rz = (r->z / 1024) + 1;
bool found = false;
for (int xl = 0; xl < 4; xl++)
{
for (int zl = 0; zl < 4; zl++)
{
if ((x + xl) >= rx && (x + xl) < (rx + r->ySize - 2) &&
(z + zl) >= rz && (z + zl) < (rz + r->xSize - 2))
{
found = true;
break;
}
}
}
if (!found)
continue;
int rx = (r->x / 1024);
int rz = (r->z / 1024);
if (x >= rx + 1 && z >= rz + 1 && x <= (rx + r->ySize - 2) && z <= (rz + r->xSize - 2))
OutsideRoomTable[x][z].push_back(i);
}
}