2020-05-27 09:21:20 +02:00
|
|
|
#include "framework.h"
|
|
|
|
#include "tr4_guide.h"
|
|
|
|
#include "items.h"
|
|
|
|
#include "box.h"
|
|
|
|
#include "sphere.h"
|
|
|
|
#include "lot.h"
|
2021-09-08 18:07:48 +03:00
|
|
|
#include "effects\effects.h"
|
|
|
|
#include "effects\tomb4fx.h"
|
2020-05-27 09:21:20 +02:00
|
|
|
#include "setup.h"
|
|
|
|
#include "level.h"
|
|
|
|
#include "lara.h"
|
2021-09-08 18:19:06 +03:00
|
|
|
#include "Sound\sound.h"
|
2019-12-05 17:35:57 +01:00
|
|
|
|
2020-09-01 07:06:31 +02:00
|
|
|
#define STATE_GUIDE_STOP 1
|
|
|
|
#define STATE_GUIDE_WALK 2
|
|
|
|
#define STATE_GUIDE_RUN 3
|
|
|
|
#define STATE_GUIDE_IGNITE_TORCH 11
|
2021-06-06 06:49:49 +02:00
|
|
|
#define STATE_GUIDE_LOOK_BACK 22
|
|
|
|
#define STATE_GUIDE_TORCH_ATTACK 31
|
|
|
|
#define STATE_GUIDE_PICKUP_TORCH 37
|
2020-09-01 07:06:31 +02:00
|
|
|
|
2019-12-05 17:35:57 +01:00
|
|
|
BITE_INFO guideBiteInfo1 = { 0, 20, 200, 18 };
|
|
|
|
BITE_INFO guideBiteInfo2 = { 30, 80, 50, 15 };
|
|
|
|
|
2020-05-27 09:21:20 +02:00
|
|
|
void InitialiseGuide(short itemNumber)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNumber];
|
2019-12-05 17:35:57 +01:00
|
|
|
|
2020-05-27 09:21:20 +02:00
|
|
|
ClearItem(itemNumber);
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
item->animNumber = Objects[item->objectNumber].animIndex + 4;
|
2020-07-21 09:56:47 +02:00
|
|
|
item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
|
|
|
item->currentAnimState = STATE_GUIDE_STOP;
|
2021-06-06 06:49:49 +02:00
|
|
|
|
|
|
|
if (Objects[ID_WRAITH1].loaded)
|
|
|
|
{
|
|
|
|
item->swapMeshFlags = 0;
|
|
|
|
item->itemFlags[1] = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->swapMeshFlags = 0x40000;
|
|
|
|
}
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
|
2020-05-27 09:21:20 +02:00
|
|
|
void GuideControl(short itemNumber)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-05-27 09:21:20 +02:00
|
|
|
if (!CreatureActive(itemNumber))
|
2019-12-05 17:35:57 +01:00
|
|
|
return;
|
|
|
|
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNumber];
|
2019-12-05 17:35:57 +01:00
|
|
|
CREATURE_INFO* creature = (CREATURE_INFO*)item->data;
|
2020-07-07 07:32:33 +02:00
|
|
|
OBJECT_INFO* obj = &Objects[item->objectNumber];
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
short angle = 0;
|
|
|
|
short tilt = 0;
|
|
|
|
short joint2 = 0;
|
|
|
|
short joint1 = 0;
|
|
|
|
short joint0 = 0;
|
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
// Ignite torch
|
2019-12-05 17:35:57 +01:00
|
|
|
if (item->itemFlags[1] == 2)
|
|
|
|
{
|
|
|
|
PHD_VECTOR pos;
|
|
|
|
|
|
|
|
pos.x = guideBiteInfo1.x;
|
|
|
|
pos.y = guideBiteInfo1.y;
|
|
|
|
pos.z = guideBiteInfo1.z;
|
|
|
|
|
|
|
|
GetJointAbsPosition(item, &pos, guideBiteInfo1.meshNum);
|
|
|
|
|
|
|
|
AddFire(pos.x, pos.y, pos.z, 0, item->roomNumber, 0);
|
2021-05-26 06:04:32 +02:00
|
|
|
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0);
|
2021-04-29 06:26:17 +02:00
|
|
|
TriggerFireFlame(pos.x, pos.y - 40, pos.z, -1, 7);
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
short random = GetRandomControl();
|
2020-10-17 23:36:06 -05:00
|
|
|
TriggerDynamicLight(pos.x, pos.y, pos.z, 15, 255 - ((random / 16) & 0x1F), 192 - ((random / 64) & 0x1F), random & 0x3F);
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
if (item->animNumber == obj->animIndex + 61)
|
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
if (item->frameNumber > g_Level.Anims[item->animNumber].frameBase + 32 &&
|
|
|
|
item->frameNumber < g_Level.Anims[item->animNumber].frameBase + 42)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2021-04-29 06:26:17 +02:00
|
|
|
TriggerFireFlame(
|
2019-12-05 17:35:57 +01:00
|
|
|
(random & 0x3F) + pos.x - 32,
|
2020-10-17 23:36:06 -05:00
|
|
|
((random / 8) & 0x3F) + pos.y - 128,
|
|
|
|
pos.z + ((random / 64) & 0x3F) - 32,
|
2019-12-05 17:35:57 +01:00
|
|
|
-1,
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
|
|
|
|
GetAITarget(creature);
|
|
|
|
|
|
|
|
AI_INFO info;
|
|
|
|
AI_INFO laraInfo;
|
|
|
|
|
|
|
|
int dx = LaraItem->pos.xPos - item->pos.xPos;
|
|
|
|
int dz = LaraItem->pos.zPos - item->pos.zPos;
|
|
|
|
|
2020-04-25 16:23:53 +02:00
|
|
|
laraInfo.angle = phd_atan(dz, dx) - item->pos.yRot;
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
laraInfo.ahead = true;
|
|
|
|
if (laraInfo.angle <= -ANGLE(90) || laraInfo.angle >= ANGLE(90))
|
|
|
|
laraInfo.ahead = false;
|
|
|
|
|
|
|
|
int distance = 0;
|
|
|
|
if (dz > 32000 || dz < -32000 || dx > 32000 || dx < -32000)
|
|
|
|
laraInfo.distance = 0x7FFFFFFF;
|
|
|
|
else
|
2021-06-06 06:49:49 +02:00
|
|
|
laraInfo.distance = SQUARE(dx) + SQUARE(dz);
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
dx = abs(dx);
|
|
|
|
dz = abs(dz);
|
|
|
|
|
|
|
|
int dy = item->pos.yPos - LaraItem->pos.yPos;
|
|
|
|
short rot2 = 0;
|
|
|
|
|
|
|
|
if (dx <= dz)
|
2020-10-17 23:36:06 -05:00
|
|
|
laraInfo.xAngle = phd_atan(dz + (dx / 2), dy);
|
2019-12-05 17:35:57 +01:00
|
|
|
else
|
2020-10-17 23:36:06 -05:00
|
|
|
laraInfo.xAngle = phd_atan(dx + (dz / 2), dy);
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
ITEM_INFO* foundEnemy = NULL;
|
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
if (!Objects[ID_WRAITH1].loaded)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
if (item->currentAnimState < 4
|
|
|
|
|| item->currentAnimState == STATE_GUIDE_TORCH_ATTACK)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
int minDistance = 0x7FFFFFFF;
|
|
|
|
CREATURE_INFO* baddie = &BaddieSlots[0];
|
2019-12-05 17:35:57 +01:00
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
for (int i = 0; i < NUM_SLOTS; i++)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
baddie = &BaddieSlots[i];
|
2019-12-05 17:35:57 +01:00
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
if (baddie->itemNum == NO_ITEM || baddie->itemNum == itemNumber)
|
|
|
|
continue;
|
2019-12-05 17:35:57 +01:00
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
ITEM_INFO* currentItem = &g_Level.Items[baddie->itemNum];
|
|
|
|
if (currentItem->objectNumber != ID_GUIDE &&
|
|
|
|
abs(currentItem->pos.yPos - item->pos.yPos) <= 512)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
dx = currentItem->pos.xPos - item->pos.xPos;
|
|
|
|
dy = currentItem->pos.yPos - item->pos.yPos;
|
|
|
|
dz = currentItem->pos.zPos - item->pos.zPos;
|
|
|
|
|
|
|
|
if (dx > 32000 || dx < -32000 || dz > 32000 || dz < -32000)
|
|
|
|
distance = 0x7FFFFFFF;
|
|
|
|
else
|
|
|
|
distance = SQUARE(dx) + SQUARE(dz);
|
|
|
|
|
|
|
|
if (distance < minDistance
|
|
|
|
&& distance < SQUARE(2048)
|
|
|
|
&& (abs(dy) < 256
|
|
|
|
|| laraInfo.distance < SQUARE(2048)
|
|
|
|
|| currentItem->objectNumber == ID_DOG))
|
|
|
|
{
|
|
|
|
foundEnemy = currentItem;
|
|
|
|
minDistance = distance;
|
|
|
|
}
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ITEM_INFO* enemy = creature->enemy;
|
|
|
|
if (foundEnemy)
|
|
|
|
creature->enemy = foundEnemy;
|
|
|
|
|
|
|
|
CreatureAIInfo(item, &info);
|
|
|
|
|
|
|
|
GetCreatureMood(item, &info, VIOLENT);
|
|
|
|
CreatureMood(item, &info, VIOLENT);
|
|
|
|
|
|
|
|
angle = CreatureTurn(item, creature->maximumTurn);
|
|
|
|
|
|
|
|
if (foundEnemy)
|
|
|
|
{
|
|
|
|
creature->enemy = enemy;
|
|
|
|
enemy = foundEnemy;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool someFlag = false;
|
|
|
|
FLOOR_INFO* floor;
|
|
|
|
PHD_VECTOR pos1;
|
|
|
|
short frameNumber;
|
|
|
|
short random;
|
|
|
|
|
|
|
|
printf("Guide state: %d\n", item->currentAnimState);
|
|
|
|
|
|
|
|
switch (item->currentAnimState)
|
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
case STATE_GUIDE_STOP:
|
2019-12-05 17:35:57 +01:00
|
|
|
creature->LOT.isJumping = false;
|
|
|
|
creature->flags = 0;
|
|
|
|
creature->maximumTurn = 0;
|
2020-10-17 23:36:06 -05:00
|
|
|
joint2 = info.angle / 2;
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
if (laraInfo.ahead)
|
|
|
|
{
|
2020-10-17 23:36:06 -05:00
|
|
|
joint0 = laraInfo.angle / 2;
|
|
|
|
joint1 = laraInfo.xAngle / 2;
|
|
|
|
joint2 = laraInfo.angle / 2;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
else if (info.ahead)
|
|
|
|
{
|
2020-10-17 23:36:06 -05:00
|
|
|
joint0 = info.angle / 2;
|
|
|
|
joint1 = info.xAngle / 2;
|
|
|
|
joint2 = info.angle / 2;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
if (Objects[ID_WRAITH1].loaded)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
if (item->itemFlags[3] == 5)
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_WALK;
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
if (item->itemFlags[3] == 5 || item->itemFlags[3] == 6)
|
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
break;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
2021-06-06 06:49:49 +02:00
|
|
|
}
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
if (item->requiredAnimState)
|
|
|
|
{
|
|
|
|
item->goalAnimState = item->requiredAnimState;
|
|
|
|
}
|
2021-06-06 06:49:49 +02:00
|
|
|
else if (Lara.location >= item->itemFlags[3]
|
|
|
|
|| item->itemFlags[1] != 2)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
if (!creature->reachedGoal || foundEnemy)
|
|
|
|
{
|
|
|
|
if (item->swapMeshFlags == 0x40000)
|
|
|
|
{
|
|
|
|
item->goalAnimState = 40;
|
|
|
|
}
|
|
|
|
else if (foundEnemy && info.distance < SQUARE(1024))
|
|
|
|
{
|
|
|
|
if (info.bite)
|
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_TORCH_ATTACK;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
2021-06-06 06:49:49 +02:00
|
|
|
else if (enemy != LaraItem || info.distance > SQUARE(2048))
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_WALK;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!enemy->flags)
|
|
|
|
{
|
|
|
|
creature->reachedGoal = false;
|
|
|
|
creature->enemy = NULL;
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
item->itemFlags[3]++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.distance <= SQUARE(128))
|
|
|
|
{
|
|
|
|
switch (enemy->flags)
|
|
|
|
{
|
|
|
|
case 0x02:
|
|
|
|
item->goalAnimState = 38;
|
|
|
|
item->requiredAnimState = 38;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x20:
|
2021-06-06 06:49:49 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_PICKUP_TORCH;
|
|
|
|
item->requiredAnimState = STATE_GUIDE_PICKUP_TORCH;
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x28:
|
|
|
|
if (laraInfo.distance < SQUARE(2048))
|
|
|
|
{
|
|
|
|
item->goalAnimState = 39;
|
|
|
|
item->requiredAnimState = 39;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x10:
|
|
|
|
if (laraInfo.distance < SQUARE(2048))
|
|
|
|
{
|
|
|
|
// Ignite torch
|
|
|
|
item->goalAnimState = 36;
|
|
|
|
item->requiredAnimState = 36;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x04:
|
|
|
|
if (laraInfo.distance < SQUARE(2048))
|
|
|
|
{
|
|
|
|
item->goalAnimState = 36;
|
|
|
|
item->requiredAnimState = 43;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
case 0x3E:
|
2019-12-05 17:35:57 +01:00
|
|
|
item->status = ITEM_INVISIBLE;
|
2020-05-27 09:21:20 +02:00
|
|
|
RemoveActiveItem(itemNumber);
|
|
|
|
DisableBaddieAI(itemNumber);
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
creature->maximumTurn = 0;
|
|
|
|
item->requiredAnimState = 42 - (info.ahead != 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2020-09-01 07:06:31 +02:00
|
|
|
case STATE_GUIDE_WALK:
|
2019-12-05 17:35:57 +01:00
|
|
|
creature->LOT.isJumping = false;
|
|
|
|
|
|
|
|
creature->maximumTurn = ANGLE(7);
|
|
|
|
|
|
|
|
if (laraInfo.ahead)
|
|
|
|
{
|
|
|
|
if (info.ahead)
|
|
|
|
{
|
|
|
|
joint2 = info.angle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
joint2 = laraInfo.angle;
|
|
|
|
}
|
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
if (Objects[ID_WRAITH1].loaded && item->itemFlags[3] == 5)
|
|
|
|
{
|
|
|
|
item->itemFlags[3] = 6;
|
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
|
|
|
}
|
|
|
|
else if (item->itemFlags[1] == 1)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2021-06-06 06:49:49 +02:00
|
|
|
item->requiredAnimState = STATE_GUIDE_IGNITE_TORCH;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
else if (creature->reachedGoal)
|
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
if (!enemy->flags)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
creature->reachedGoal = false;
|
|
|
|
creature->enemy = NULL;
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
item->itemFlags[3]++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Lara.location >= item->itemFlags[3])
|
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
if (!foundEnemy
|
|
|
|
|| info.distance >= 0x200000
|
|
|
|
&& (item->swapMeshFlags & 0x40000
|
|
|
|
|| info.distance >= SQUARE(3072)))
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
if (creature->enemy == LaraItem)
|
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
if (info.distance >= SQUARE(2048))
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
if (info.distance > SQUARE(4096))
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_RUN;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
2021-06-06 06:49:49 +02:00
|
|
|
else if (Lara.location > item->itemFlags[3]
|
|
|
|
&& laraInfo.distance > SQUARE(2048))
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_RUN;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2020-09-01 07:06:31 +02:00
|
|
|
case STATE_GUIDE_RUN:
|
2019-12-05 17:35:57 +01:00
|
|
|
if (info.ahead)
|
|
|
|
{
|
|
|
|
joint2 = info.angle;
|
|
|
|
}
|
|
|
|
|
|
|
|
creature->maximumTurn = ANGLE(11);
|
|
|
|
tilt = angle / 2;
|
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
if (info.distance < SQUARE(2048)
|
|
|
|
|| Lara.location < item->itemFlags[3])
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2019-12-05 17:35:57 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (creature->reachedGoal)
|
|
|
|
{
|
|
|
|
if (!enemy->flags)
|
|
|
|
{
|
|
|
|
creature->reachedGoal = false;
|
|
|
|
creature->enemy = NULL;
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
item->itemFlags[3]++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
2021-06-06 06:49:49 +02:00
|
|
|
else if (foundEnemy &&
|
|
|
|
(info.distance < 0x200000
|
|
|
|
|| !(item->swapMeshFlags & 0x40000)
|
|
|
|
&& info.distance < SQUARE(3072)))
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2019-12-05 17:35:57 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2020-09-01 07:06:31 +02:00
|
|
|
case STATE_GUIDE_IGNITE_TORCH:
|
2019-12-05 17:35:57 +01:00
|
|
|
// Ignite torch
|
|
|
|
pos1.x = guideBiteInfo2.x;
|
|
|
|
pos1.y = guideBiteInfo2.y;
|
|
|
|
pos1.z = guideBiteInfo2.z;
|
|
|
|
|
|
|
|
GetJointAbsPosition(item, &pos1, guideBiteInfo2.meshNum);
|
|
|
|
|
2020-07-21 09:56:47 +02:00
|
|
|
frameNumber = item->frameNumber - g_Level.Anims[item->animNumber].frameBase;
|
2019-12-05 17:35:57 +01:00
|
|
|
random = GetRandomControl();
|
|
|
|
|
|
|
|
if (frameNumber == 32)
|
|
|
|
{
|
|
|
|
item->swapMeshFlags |= 0x8000;
|
|
|
|
}
|
|
|
|
else if (frameNumber == 216)
|
|
|
|
{
|
|
|
|
item->swapMeshFlags &= 0x7FFF;
|
|
|
|
}
|
|
|
|
else if (frameNumber <= 79 || frameNumber >= 84)
|
|
|
|
{
|
|
|
|
if (frameNumber <= 83 || frameNumber >= 94)
|
|
|
|
{
|
|
|
|
if (frameNumber <= 159 || frameNumber >= 164)
|
|
|
|
{
|
|
|
|
if (frameNumber > 163 && frameNumber < 181)
|
|
|
|
{
|
2021-04-29 06:26:17 +02:00
|
|
|
TriggerFireFlame(
|
2019-12-05 17:35:57 +01:00
|
|
|
(random & 0x3F) + pos1.x - 64,
|
2020-10-17 23:36:06 -05:00
|
|
|
((random / 32) & 0x3F) + pos1.y - 96,
|
|
|
|
((random / 1024) & 0x3F) + pos1.z - 64,
|
2019-12-05 17:35:57 +01:00
|
|
|
-1,
|
|
|
|
7);
|
|
|
|
|
|
|
|
TriggerDynamicLight(
|
|
|
|
pos1.x - 32,
|
|
|
|
pos1.y - 64,
|
|
|
|
pos1.z - 32,
|
|
|
|
10,
|
2020-10-17 23:36:06 -05:00
|
|
|
192 - ((random / 16) & 0x1F),
|
|
|
|
128 - ((random / 64) & 0x1F),
|
2019-12-05 17:35:57 +01:00
|
|
|
random & 0x1F);
|
|
|
|
|
|
|
|
item->itemFlags[1] = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TriggerMetalSparks(pos1.x, pos1.y, pos1.z, -1, -1, 0, 1);
|
2020-10-17 23:36:06 -05:00
|
|
|
TriggerDynamicLight(pos1.x, pos1.y, pos1.z, 10, random & 0x1F, 96 - ((random / 64) & 0x1F), 128 - ((random / 16) & 0x1F));
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-17 23:36:06 -05:00
|
|
|
TriggerDynamicLight(pos1.x - 32, pos1.y - 64, pos1.z - 32, 10, 192 - ((random / 16) & 0x1F), 128 - ((random / 64) & 0x1F), random & 0x1F);
|
2019-12-05 17:35:57 +01:00
|
|
|
|
2021-04-29 06:26:17 +02:00
|
|
|
TriggerFireFlame(
|
2019-12-05 17:35:57 +01:00
|
|
|
(random & 0x3F) + pos1.x - 64,
|
2020-10-17 23:36:06 -05:00
|
|
|
((random / 32) & 0x3F) + pos1.y - 96,
|
|
|
|
((random / 1024) & 0x3F) + pos1.z - 64,
|
2019-12-05 17:35:57 +01:00
|
|
|
-1,
|
|
|
|
7);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-17 23:36:06 -05:00
|
|
|
TriggerDynamicLight(pos1.x, pos1.y, pos1.z, 10, random & 0x1F, 96 - ((random / 64) & 0x1F), 128 - ((random / 16) & 0x1F));
|
2019-12-05 17:35:57 +01:00
|
|
|
TriggerMetalSparks(pos1.x, pos1.y, pos1.z, -1, -1, 0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
case STATE_GUIDE_LOOK_BACK:
|
2019-12-05 17:35:57 +01:00
|
|
|
creature->maximumTurn = 0;
|
|
|
|
|
|
|
|
if (laraInfo.angle < -256)
|
|
|
|
{
|
|
|
|
item->pos.yRot -= 399;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
case STATE_GUIDE_TORCH_ATTACK:
|
2019-12-05 17:35:57 +01:00
|
|
|
if (info.ahead)
|
|
|
|
{
|
2020-10-17 23:36:06 -05:00
|
|
|
joint0 = info.angle / 2;
|
|
|
|
joint2 = info.angle / 2;
|
|
|
|
joint1 = info.xAngle / 2;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
creature->maximumTurn = 0;
|
|
|
|
|
|
|
|
if (abs(info.angle) >= ANGLE(7))
|
|
|
|
{
|
|
|
|
if (info.angle < 0)
|
|
|
|
{
|
|
|
|
item->pos.yRot += ANGLE(7);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->pos.yRot -= ANGLE(7);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->pos.yRot += info.angle;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!creature->flags)
|
|
|
|
{
|
|
|
|
if (enemy)
|
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
if (item->frameNumber > g_Level.Anims[item->animNumber].frameBase + 15 &&
|
|
|
|
item->frameNumber < g_Level.Anims[item->animNumber].frameBase + 26)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
dx = abs(enemy->pos.xPos - item->pos.xPos);
|
|
|
|
dy = abs(enemy->pos.yPos - item->pos.yPos);
|
|
|
|
dz = abs(enemy->pos.zPos - item->pos.zPos);
|
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
if (dx < 512 && dy < 512 && dz < 512)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
enemy->hitPoints -= 20;
|
|
|
|
|
|
|
|
if (enemy->hitPoints <= 0)
|
|
|
|
{
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
enemy->hitStatus = true;
|
|
|
|
creature->flags = 1;
|
|
|
|
|
|
|
|
CreatureEffect2(
|
|
|
|
item,
|
|
|
|
&guideBiteInfo1,
|
|
|
|
8,
|
|
|
|
-1,
|
|
|
|
DoBloodSplat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 35:
|
|
|
|
creature->maximumTurn = 0;
|
|
|
|
|
|
|
|
if (laraInfo.angle > 256)
|
|
|
|
{
|
|
|
|
item->pos.yRot += 399;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 36:
|
|
|
|
case 43:
|
|
|
|
if (enemy)
|
|
|
|
{
|
|
|
|
short deltaAngle = enemy->pos.yRot - item->pos.yRot;
|
2021-06-06 06:49:49 +02:00
|
|
|
if (deltaAngle <= ANGLE(2))
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
if (deltaAngle < -ANGLE(2))
|
|
|
|
item->pos.yRot -= ANGLE(2);
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-06-06 06:49:49 +02:00
|
|
|
item->pos.yRot += ANGLE(2);
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item->requiredAnimState == 43)
|
|
|
|
{
|
|
|
|
item->goalAnimState = 43;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (item->animNumber != obj->animIndex + 57
|
2020-07-21 09:56:47 +02:00
|
|
|
&& item->frameNumber == g_Level.Anims[item->animNumber].frameEnd - 20)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2021-08-26 12:12:05 +03:00
|
|
|
TestTriggers(item, true, NULL);
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
creature->reachedGoal = false;
|
|
|
|
creature->enemy = NULL;
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
item->itemFlags[3]++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2021-06-06 06:49:49 +02:00
|
|
|
case STATE_GUIDE_PICKUP_TORCH:
|
2020-07-21 09:56:47 +02:00
|
|
|
if (item->frameNumber == g_Level.Anims[item->animNumber].frameBase)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
someFlag = true;
|
|
|
|
|
|
|
|
item->pos.xPos = enemy->pos.xPos;
|
|
|
|
item->pos.yPos = enemy->pos.yPos;
|
|
|
|
item->pos.zPos = enemy->pos.zPos;
|
|
|
|
item->pos.xRot = enemy->pos.xRot;
|
|
|
|
item->pos.yRot = enemy->pos.yRot;
|
|
|
|
item->pos.zRot = enemy->pos.zRot;
|
|
|
|
}
|
2020-07-21 09:56:47 +02:00
|
|
|
else if (item->frameNumber == g_Level.Anims[item->animNumber].frameBase + 35)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
item->swapMeshFlags &= 0xFFFBFFFF;
|
|
|
|
|
2020-07-21 09:56:47 +02:00
|
|
|
ROOM_INFO* room = &g_Level.Rooms[item->roomNumber];
|
2019-12-05 17:35:57 +01:00
|
|
|
ITEM_INFO* currentItem = NULL;
|
|
|
|
|
2020-05-27 09:21:20 +02:00
|
|
|
short currentitemNumber = room->itemNumber;
|
|
|
|
while (currentitemNumber != NO_ITEM)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
currentItem = &g_Level.Items[currentitemNumber];
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
if (currentItem->objectNumber >= ID_ANIMATING1
|
|
|
|
&& currentItem->objectNumber <= ID_ANIMATING15
|
|
|
|
&& trunc(item->pos.xPos) == trunc(currentItem->pos.xPos)
|
|
|
|
&& trunc(item->pos.zPos) == trunc(currentItem->pos.zPos))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-05-27 09:21:20 +02:00
|
|
|
currentitemNumber = currentItem->nextItem;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (currentItem != NULL)
|
|
|
|
currentItem->meshBits = 0xFFFFFFFD;
|
|
|
|
}
|
|
|
|
|
|
|
|
item->itemFlags[1] = 1;
|
|
|
|
if (someFlag)
|
|
|
|
{
|
|
|
|
creature->reachedGoal = false;
|
|
|
|
creature->enemy = NULL;
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
item->itemFlags[3]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 38:
|
2020-07-21 09:56:47 +02:00
|
|
|
if (item->frameNumber == g_Level.Anims[item->animNumber].frameBase)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
item->pos.xPos = enemy->pos.xPos;
|
|
|
|
item->pos.yPos = enemy->pos.yPos;
|
|
|
|
item->pos.zPos = enemy->pos.zPos;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
if (item->frameNumber == g_Level.Anims[item->animNumber].frameBase + 42)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
|
2021-08-26 12:12:05 +03:00
|
|
|
TestTriggers(item, true, NULL);
|
2019-12-05 17:35:57 +01:00
|
|
|
item->pos.yRot = enemy->pos.yRot;
|
2021-06-06 06:49:49 +02:00
|
|
|
|
2019-12-05 17:35:57 +01:00
|
|
|
creature->reachedGoal = false;
|
|
|
|
creature->enemy = NULL;
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
item->itemFlags[3]++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2021-06-06 06:49:49 +02:00
|
|
|
else if (item->frameNumber < g_Level.Anims[item->animNumber].frameBase + 42)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
|
|
|
if (enemy->pos.yRot - item->pos.yRot <= ANGLE(2))
|
|
|
|
{
|
|
|
|
if (enemy->pos.yRot - item->pos.yRot < -ANGLE(2))
|
|
|
|
{
|
|
|
|
item->pos.yRot -= ANGLE(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->pos.yRot += ANGLE(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 39:
|
2020-07-21 09:56:47 +02:00
|
|
|
if (item->frameNumber >= g_Level.Anims[item->animNumber].frameBase + 20)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
if (item->frameNumber == g_Level.Anims[item->animNumber].frameBase + 20)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2019-12-05 17:35:57 +01:00
|
|
|
|
2021-08-26 12:12:05 +03:00
|
|
|
TestTriggers(item, true, NULL);
|
2019-12-05 17:35:57 +01:00
|
|
|
|
|
|
|
creature->reachedGoal = false;
|
|
|
|
creature->enemy = NULL;
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
item->itemFlags[3]++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-07-21 09:56:47 +02:00
|
|
|
if (item->frameNumber == g_Level.Anims[item->animNumber].frameBase + 70 && item->roomNumber == 70)
|
2019-12-05 17:35:57 +01:00
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->requiredAnimState = STATE_GUIDE_RUN;
|
2019-12-05 17:35:57 +01:00
|
|
|
item->swapMeshFlags |= 0x200000;
|
2020-03-02 09:49:11 +01:00
|
|
|
SoundEffect(SFX_TR4_GUIDE_SCARE, &item->pos, 0);
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (enemy->pos.yRot - item->pos.yRot <= ANGLE(2))
|
|
|
|
{
|
|
|
|
if (enemy->pos.yRot - item->pos.yRot < -ANGLE(2))
|
|
|
|
{
|
|
|
|
item->pos.yRot -= ANGLE(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->pos.yRot += ANGLE(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 40:
|
|
|
|
creature->LOT.isJumping;
|
|
|
|
creature->maximumTurn = ANGLE(7);
|
|
|
|
|
|
|
|
if (laraInfo.ahead)
|
|
|
|
{
|
|
|
|
if (info.ahead)
|
|
|
|
{
|
|
|
|
joint2 = info.angle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
joint2 = laraInfo.angle;
|
|
|
|
}
|
|
|
|
if (!(creature->reachedGoal))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!enemy->flags)
|
|
|
|
{
|
|
|
|
creature->reachedGoal = false;
|
|
|
|
creature->enemy = NULL;
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
item->itemFlags[3]++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (enemy->flags == 42)
|
|
|
|
{
|
2021-08-26 12:12:05 +03:00
|
|
|
TestTriggers(item, true, NULL);
|
2021-06-06 06:49:49 +02:00
|
|
|
|
2019-12-05 17:35:57 +01:00
|
|
|
creature->reachedGoal = false;
|
|
|
|
creature->enemy = NULL;
|
|
|
|
item->aiBits = FOLLOW;
|
|
|
|
item->itemFlags[3]++;
|
|
|
|
}
|
|
|
|
else if (item->triggerFlags <= 999)
|
|
|
|
{
|
2020-09-01 07:06:31 +02:00
|
|
|
item->goalAnimState = STATE_GUIDE_STOP;
|
2019-12-05 17:35:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-27 09:21:20 +02:00
|
|
|
KillItem(itemNumber);
|
|
|
|
DisableBaddieAI(itemNumber);
|
2019-12-05 17:35:57 +01:00
|
|
|
item->flags |= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 41:
|
|
|
|
case 42:
|
|
|
|
creature->maximumTurn = 0;
|
|
|
|
MoveCreature3DPos(&item->pos, &enemy->pos, 15, enemy->pos.yRot - item->pos.yRot, ANGLE(10));
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CreatureTilt(item, tilt);
|
|
|
|
CreatureJoint(item, 0, joint0);
|
|
|
|
CreatureJoint(item, 1, joint1);
|
|
|
|
CreatureJoint(item, 2, joint2);
|
|
|
|
CreatureJoint(item, 3, joint1);
|
2020-05-27 09:21:20 +02:00
|
|
|
CreatureAnimation(itemNumber, angle, 0);
|
2018-11-30 20:17:57 +01:00
|
|
|
}
|