2021-08-30 17:50:32 +03:00
|
|
|
#include "framework.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Game/control/trigger.h"
|
|
|
|
|
|
|
|
#include "Game/camera.h"
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Game/collision/floordata.h"
|
|
|
|
#include "Game/control/flipeffect.h"
|
|
|
|
#include "Game/control/box.h"
|
|
|
|
#include "Game/control/lot.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Game/effects/lara_fx.h"
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Game/Lara/lara.h"
|
|
|
|
#include "Game/Lara/lara_climb.h"
|
2022-02-02 23:11:57 +11:00
|
|
|
#include "Game/Lara/lara_tests.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Game/items.h"
|
|
|
|
#include "Game/room.h"
|
|
|
|
#include "Game/spotcam.h"
|
2021-09-25 16:00:30 +03:00
|
|
|
#include "Objects/Generic/Switches/generic_switch.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Objects/objectslist.h"
|
|
|
|
#include "Sound/sound.h"
|
|
|
|
#include "Specific/setup.h"
|
2021-08-30 17:50:32 +03:00
|
|
|
|
2021-09-25 11:27:47 +02:00
|
|
|
|
2021-11-22 18:55:29 +03:00
|
|
|
using namespace TEN::Effects::Lara;
|
2021-08-30 17:50:32 +03:00
|
|
|
using namespace TEN::Entities::Switches;
|
|
|
|
|
2021-09-15 21:09:09 +03:00
|
|
|
int TriggerTimer;
|
2021-09-15 17:40:00 +03:00
|
|
|
int KeyTriggerActive;
|
|
|
|
|
2021-08-30 17:52:38 +03:00
|
|
|
int TriggerActive(ITEM_INFO* item)
|
|
|
|
{
|
|
|
|
int flag;
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
flag = (~item->Flags & IFLAG_REVERSE) >> 14;
|
|
|
|
if ((item->Flags & IFLAG_ACTIVATION_MASK) != IFLAG_ACTIVATION_MASK)
|
2021-08-30 17:52:38 +03:00
|
|
|
{
|
|
|
|
flag = !flag;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->Timer)
|
2021-08-30 17:52:38 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->Timer > 0)
|
2021-08-30 17:52:38 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
--item->Timer;
|
|
|
|
if (!item->Timer)
|
|
|
|
item->Timer = -1;
|
2021-08-30 17:52:38 +03:00
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
else if (item->Timer < -1)
|
2021-08-30 17:52:38 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
++item->Timer;
|
|
|
|
if (item->Timer == -1)
|
|
|
|
item->Timer = 0;
|
2021-08-30 17:52:38 +03:00
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->Timer <= -1)
|
2021-08-30 17:52:38 +03:00
|
|
|
flag = !flag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
2021-09-15 10:12:42 +03:00
|
|
|
bool GetKeyTrigger(ITEM_INFO* item)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
|
|
|
auto triggerIndex = GetTriggerIndex(item);
|
|
|
|
|
2021-09-15 10:12:42 +03:00
|
|
|
if (triggerIndex == 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
short* trigger = triggerIndex;
|
|
|
|
|
|
|
|
if (*trigger & END_BIT)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (short* j = &trigger[2]; (*j >> 8) & 0x3C || item != &g_Level.Items[*j & VALUE_BITS]; j++)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2021-09-15 10:12:42 +03:00
|
|
|
if (*j & END_BIT)
|
|
|
|
return false;
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
|
2021-09-15 10:12:42 +03:00
|
|
|
return true;
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
|
2021-09-15 10:12:42 +03:00
|
|
|
int GetSwitchTrigger(ITEM_INFO* item, short* itemNos, int attatchedToSwitch)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
|
|
|
auto triggerIndex = GetTriggerIndex(item);
|
|
|
|
|
2021-09-15 10:12:42 +03:00
|
|
|
if (triggerIndex == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
short* trigger = triggerIndex;
|
|
|
|
|
|
|
|
if (*trigger & END_BIT)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
trigger += 2;
|
|
|
|
short* current = itemNos;
|
|
|
|
int k = 0;
|
2021-08-30 17:50:32 +03:00
|
|
|
|
2021-09-15 10:12:42 +03:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (TRIG_BITS(*trigger) == TO_OBJECT && item != &g_Level.Items[*trigger & VALUE_BITS])
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2021-09-15 10:12:42 +03:00
|
|
|
current[k] = *trigger & VALUE_BITS;
|
|
|
|
++k;
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
2021-09-15 10:12:42 +03:00
|
|
|
|
|
|
|
if (*trigger & END_BIT)
|
|
|
|
break;
|
|
|
|
|
|
|
|
++trigger;
|
|
|
|
|
|
|
|
} while (true);
|
|
|
|
|
|
|
|
return k;
|
2021-08-30 17:50:32 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SwitchTrigger(short itemNum, short timer)
|
|
|
|
{
|
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->Status == ITEM_DEACTIVATED)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if ((!item->ActiveState && item->ObjectNumber != ID_JUMP_SWITCH || item->ActiveState == 1 && item->ObjectNumber == ID_JUMP_SWITCH) && timer > 0)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Timer = timer;
|
|
|
|
item->Status = ITEM_ACTIVE;
|
2021-08-30 17:50:32 +03:00
|
|
|
if (timer != 1)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Timer = 30 * timer;
|
2021-08-30 17:50:32 +03:00
|
|
|
return 1;
|
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->TriggerFlags != 6 || item->ActiveState)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
|
|
|
RemoveActiveItem(itemNum);
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Status = ITEM_NOT_ACTIVE;
|
|
|
|
if (!item->ItemFlags[0] == 0)
|
|
|
|
item->Flags |= ONESHOT;
|
|
|
|
if (item->ActiveState != 1)
|
2021-08-30 17:50:32 +03:00
|
|
|
return 1;
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->TriggerFlags != 5 && item->TriggerFlags != 6)
|
2021-08-30 17:50:32 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Status = ITEM_ACTIVE;
|
2021-08-30 17:50:32 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
else if (item->Status)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
return (item->Flags & ONESHOT) >> 8;
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-09-15 17:20:42 +03:00
|
|
|
int KeyTrigger(short itemNum)
|
|
|
|
{
|
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
|
|
|
int oldkey;
|
|
|
|
|
2022-02-11 01:31:54 +11:00
|
|
|
if ((item->Status != ITEM_ACTIVE || Lara.Control.HandStatus == HandStatus::Busy) && (!KeyTriggerActive || Lara.Control.HandStatus != HandStatus::Busy))
|
2021-09-15 17:20:42 +03:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
oldkey = KeyTriggerActive;
|
|
|
|
|
|
|
|
if (!oldkey)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Status = ITEM_DEACTIVATED;
|
2021-09-15 17:20:42 +03:00
|
|
|
|
|
|
|
KeyTriggerActive = false;
|
|
|
|
|
|
|
|
return oldkey;
|
|
|
|
}
|
|
|
|
|
|
|
|
int PickupTrigger(short itemNum)
|
|
|
|
{
|
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->Flags & IFLAG_KILLED
|
|
|
|
|| (item->Status != ITEM_INVISIBLE
|
|
|
|
|| item->ItemFlags[3] != 1
|
|
|
|
|| item->TriggerFlags & 0x80))
|
2021-09-15 17:20:42 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
KillItem(itemNum);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-10-04 03:14:05 +03:00
|
|
|
void RefreshCamera(short type, short* data)
|
|
|
|
{
|
|
|
|
short trigger, value, targetOk;
|
|
|
|
|
|
|
|
targetOk = 2;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
trigger = *(data++);
|
|
|
|
value = trigger & VALUE_BITS;
|
|
|
|
|
|
|
|
switch (TRIG_BITS(trigger))
|
|
|
|
{
|
|
|
|
case TO_CAMERA:
|
|
|
|
data++;
|
|
|
|
|
|
|
|
if (value == Camera.last)
|
|
|
|
{
|
|
|
|
Camera.number = value;
|
|
|
|
|
2022-02-16 18:13:07 +11:00
|
|
|
if ((Camera.timer < 0) || (Camera.type == CameraType::Look) || (Camera.type == CameraType::Combat))
|
2021-10-04 03:14:05 +03:00
|
|
|
{
|
|
|
|
Camera.timer = -1;
|
|
|
|
targetOk = 0;
|
|
|
|
break;
|
|
|
|
}
|
2022-02-16 18:13:07 +11:00
|
|
|
Camera.type = CameraType::Fixed;
|
2021-10-04 03:14:05 +03:00
|
|
|
targetOk = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
targetOk = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_TARGET:
|
2022-02-16 18:13:07 +11:00
|
|
|
if (Camera.type == CameraType::Look || Camera.type == CameraType::Combat)
|
2021-10-04 03:14:05 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
Camera.item = &g_Level.Items[value];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (!(trigger & END_BIT));
|
|
|
|
|
|
|
|
if (Camera.item)
|
2022-02-09 16:55:46 +11:00
|
|
|
if (!targetOk || (targetOk == 2 && Camera.item->LookedAt && Camera.item != Camera.lastItem))
|
2021-10-04 03:14:05 +03:00
|
|
|
Camera.item = NULL;
|
|
|
|
|
|
|
|
if (Camera.number == -1 && Camera.timer > 0)
|
|
|
|
Camera.timer = -1;
|
|
|
|
}
|
|
|
|
|
2021-08-30 17:50:32 +03:00
|
|
|
short* GetTriggerIndex(FLOOR_INFO* floor, int x, int y, int z)
|
|
|
|
{
|
2021-09-17 15:32:55 +03:00
|
|
|
auto bottomBlock = GetCollisionResult(x, y, z, floor->Room).BottomBlock;
|
2021-08-30 17:50:32 +03:00
|
|
|
|
2021-09-17 15:32:55 +03:00
|
|
|
if (bottomBlock->TriggerIndex == -1)
|
|
|
|
return nullptr;
|
2021-08-30 17:50:32 +03:00
|
|
|
|
2021-09-17 15:32:55 +03:00
|
|
|
return &g_Level.FloorData[bottomBlock->TriggerIndex];
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
short* GetTriggerIndex(ITEM_INFO* item)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
auto roomNumber = item->RoomNumber;
|
|
|
|
auto floor = GetFloor(item->Position.xPos, item->Position.yPos, item->Position.zPos, &roomNumber);
|
|
|
|
return GetTriggerIndex(floor, item->Position.xPos, item->Position.yPos, item->Position.zPos);
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
|
2021-10-01 18:31:06 +03:00
|
|
|
void TestTriggers(FLOOR_INFO* floor, int x, int y, int z, bool heavy, int heavyFlags)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
|
|
|
int flip = -1;
|
|
|
|
int flipAvailable = 0;
|
|
|
|
int newEffect = -1;
|
|
|
|
int switchOff = 0;
|
|
|
|
int switchFlag = 0;
|
|
|
|
short objectNumber = 0;
|
|
|
|
int keyResult = 0;
|
|
|
|
short cameraFlags = 0;
|
|
|
|
short cameraTimer = 0;
|
|
|
|
int spotCamIndex = 0;
|
|
|
|
|
2021-10-01 18:31:06 +03:00
|
|
|
auto data = GetTriggerIndex(floor, x, y, z);
|
|
|
|
|
2021-08-30 17:50:32 +03:00
|
|
|
if (!data)
|
|
|
|
return;
|
|
|
|
|
|
|
|
short triggerType = (*(data++) >> 8) & 0x3F;
|
|
|
|
short flags = *(data++);
|
|
|
|
short timer = flags & 0xFF;
|
|
|
|
|
2022-02-16 18:13:07 +11:00
|
|
|
if (Camera.type != CameraType::Heavy)
|
2021-08-30 17:50:32 +03:00
|
|
|
RefreshCamera(triggerType, data);
|
|
|
|
|
|
|
|
short value = 0;
|
|
|
|
|
|
|
|
if (heavy)
|
|
|
|
{
|
|
|
|
switch (triggerType)
|
|
|
|
{
|
|
|
|
case TRIGGER_TYPES::HEAVY:
|
|
|
|
case TRIGGER_TYPES::HEAVYANTITRIGGER:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::HEAVYSWITCH:
|
|
|
|
if (!heavyFlags)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (heavyFlags >= 0)
|
|
|
|
{
|
|
|
|
flags &= CODE_BITS;
|
|
|
|
if (flags != heavyFlags)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flags |= CODE_BITS;
|
|
|
|
flags += heavyFlags;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// Enemies can only activate heavy triggers
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (triggerType)
|
|
|
|
{
|
|
|
|
case TRIGGER_TYPES::SWITCH:
|
|
|
|
value = *(data++) & 0x3FF;
|
|
|
|
|
|
|
|
if (flags & ONESHOT)
|
2022-02-09 16:55:46 +11:00
|
|
|
g_Level.Items[value].ItemFlags[0] = 1;
|
2021-08-30 17:50:32 +03:00
|
|
|
|
|
|
|
if (!SwitchTrigger(value, timer))
|
|
|
|
return;
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
objectNumber = g_Level.Items[value].ObjectNumber;
|
|
|
|
if (objectNumber >= ID_SWITCH_TYPE1 && objectNumber <= ID_SWITCH_TYPE6 && g_Level.Items[value].TriggerFlags == 5)
|
2021-08-30 17:50:32 +03:00
|
|
|
switchFlag = 1;
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
switchOff = (g_Level.Items[value].ActiveState == 1);
|
2021-08-30 17:50:32 +03:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::MONKEY:
|
2022-02-09 16:55:46 +11:00
|
|
|
if (LaraItem->ActiveState >= LS_MONKEY_IDLE &&
|
|
|
|
(LaraItem->ActiveState <= LS_MONKEY_TURN_180 ||
|
|
|
|
LaraItem->ActiveState == LS_MONKEY_TURN_LEFT ||
|
|
|
|
LaraItem->ActiveState == LS_MONKEY_TURN_RIGHT))
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::TIGHTROPE_T:
|
2022-02-09 16:55:46 +11:00
|
|
|
if (LaraItem->ActiveState >= LS_TIGHTROPE_IDLE &&
|
|
|
|
LaraItem->ActiveState <= LS_TIGHTROPE_RECOVER_BALANCE &&
|
2022-02-21 20:27:30 +11:00
|
|
|
LaraItem->ActiveState != LS_DOVE_SWITCH)
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::CRAWLDUCK_T:
|
2022-02-21 20:27:30 +11:00
|
|
|
if (LaraItem->ActiveState == LS_DOVE_SWITCH ||
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraItem->ActiveState == LS_CRAWL_IDLE ||
|
|
|
|
LaraItem->ActiveState == LS_CRAWL_TURN_LEFT ||
|
|
|
|
LaraItem->ActiveState == LS_CRAWL_TURN_RIGHT ||
|
|
|
|
LaraItem->ActiveState == LS_CRAWL_BACK ||
|
|
|
|
LaraItem->ActiveState == LS_CROUCH_IDLE ||
|
|
|
|
LaraItem->ActiveState == LS_CROUCH_ROLL ||
|
|
|
|
LaraItem->ActiveState == LS_CROUCH_TURN_LEFT ||
|
|
|
|
LaraItem->ActiveState == LS_CROUCH_TURN_RIGHT)
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::CLIMB_T:
|
2022-02-09 16:55:46 +11:00
|
|
|
if (LaraItem->ActiveState == LS_HANG ||
|
|
|
|
LaraItem->ActiveState == LS_LADDER_IDLE ||
|
|
|
|
LaraItem->ActiveState == LS_LADDER_UP ||
|
|
|
|
LaraItem->ActiveState == LS_LADDER_LEFT ||
|
|
|
|
LaraItem->ActiveState == LS_LADDER_STOP ||
|
|
|
|
LaraItem->ActiveState == LS_LADDER_RIGHT ||
|
|
|
|
LaraItem->ActiveState == LS_LADDER_DOWN)
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::PAD:
|
|
|
|
case TRIGGER_TYPES::ANTIPAD:
|
2021-10-01 18:31:06 +03:00
|
|
|
if (GetCollisionResult(floor, x, y, z).Position.Floor == y)
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::KEY:
|
|
|
|
value = *(data++) & 0x3FF;
|
|
|
|
keyResult = KeyTrigger(value);
|
|
|
|
if (keyResult != -1)
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::PICKUP:
|
|
|
|
value = *(data++) & 0x3FF;
|
|
|
|
if (!PickupTrigger(value))
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::COMBAT:
|
2022-02-11 01:31:54 +11:00
|
|
|
if (Lara.Control.HandStatus == HandStatus::WeaponReady)
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case TRIGGER_TYPES::HEAVY:
|
|
|
|
case TRIGGER_TYPES::DUMMY:
|
|
|
|
case TRIGGER_TYPES::HEAVYSWITCH:
|
|
|
|
case TRIGGER_TYPES::HEAVYANTITRIGGER:
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
short targetType = 0;
|
|
|
|
short trigger = 0;
|
|
|
|
|
|
|
|
ITEM_INFO* item = NULL;
|
|
|
|
ITEM_INFO* cameraItem = NULL;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
trigger = *(data++);
|
|
|
|
value = trigger & VALUE_BITS;
|
|
|
|
targetType = (trigger >> 10) & 0xF;
|
|
|
|
|
|
|
|
switch (targetType)
|
|
|
|
{
|
|
|
|
case TO_OBJECT:
|
|
|
|
item = &g_Level.Items[value];
|
|
|
|
|
|
|
|
if (keyResult >= 2 ||
|
|
|
|
(triggerType == TRIGGER_TYPES::ANTIPAD ||
|
|
|
|
triggerType == TRIGGER_TYPES::ANTITRIGGER ||
|
|
|
|
triggerType == TRIGGER_TYPES::HEAVYANTITRIGGER) &&
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags & ATONESHOT)
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (triggerType == TRIGGER_TYPES::SWITCH && item->Flags & SWONESHOT)
|
2021-09-24 05:48:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType != TRIGGER_TYPES::SWITCH
|
|
|
|
&& triggerType != TRIGGER_TYPES::ANTIPAD
|
|
|
|
&& triggerType != TRIGGER_TYPES::ANTITRIGGER
|
|
|
|
&& triggerType != TRIGGER_TYPES::HEAVYANTITRIGGER
|
2022-02-09 16:55:46 +11:00
|
|
|
&& (item->Flags & ONESHOT))
|
2021-09-24 05:48:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType != TRIGGER_TYPES::ANTIPAD
|
|
|
|
&& triggerType != TRIGGER_TYPES::ANTITRIGGER
|
|
|
|
&& triggerType != TRIGGER_TYPES::HEAVYANTITRIGGER)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->ObjectNumber == ID_DART_EMITTER && item->Active)
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Timer = timer;
|
2021-08-30 17:50:32 +03:00
|
|
|
if (timer != 1)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Timer = 30 * timer;
|
2021-08-30 17:50:32 +03:00
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::SWITCH ||
|
|
|
|
triggerType == TRIGGER_TYPES::HEAVYSWITCH)
|
|
|
|
{
|
|
|
|
if (heavyFlags >= 0)
|
|
|
|
{
|
|
|
|
if (switchFlag)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags |= (flags & CODE_BITS);
|
2021-08-30 17:50:32 +03:00
|
|
|
else
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags ^= (flags & CODE_BITS);
|
2021-08-30 17:50:32 +03:00
|
|
|
|
|
|
|
if (flags & ONESHOT)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags |= SWONESHOT;
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (((flags ^ item->Flags) & CODE_BITS) == CODE_BITS)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags ^= (flags & CODE_BITS);
|
2021-08-30 17:50:32 +03:00
|
|
|
if (flags & ONESHOT)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags |= SWONESHOT;
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (triggerType == TRIGGER_TYPES::ANTIPAD ||
|
|
|
|
triggerType == TRIGGER_TYPES::ANTITRIGGER ||
|
|
|
|
triggerType == TRIGGER_TYPES::HEAVYANTITRIGGER)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->ObjectNumber == ID_EARTHQUAKE)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->ItemFlags[0] = 0;
|
|
|
|
item->ItemFlags[1] = 100;
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags &= ~(CODE_BITS | REVERSE);
|
2021-08-30 17:50:32 +03:00
|
|
|
|
|
|
|
if (flags & ONESHOT)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags |= ATONESHOT;
|
2021-08-30 17:50:32 +03:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->Active && Objects[item->ObjectNumber].intelligent)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->HitPoints = NOT_TARGETABLE;
|
2021-08-30 17:50:32 +03:00
|
|
|
DisableBaddieAI(value);
|
|
|
|
KillItem(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (flags & CODE_BITS)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags |= flags & CODE_BITS;
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if ((item->Flags & CODE_BITS) == CODE_BITS)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags |= 0x20;
|
2021-08-30 17:50:32 +03:00
|
|
|
|
|
|
|
if (flags & ONESHOT)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Flags |= ONESHOT;
|
2021-08-30 17:50:32 +03:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (!(item->Active) && !(item->Flags & IFLAG_KILLED))
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (Objects[item->ObjectNumber].intelligent)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->Status != ITEM_NOT_ACTIVE)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->Status == ITEM_INVISIBLE)
|
2021-08-30 17:50:32 +03:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TouchBits = 0;
|
2021-08-30 17:50:32 +03:00
|
|
|
if (EnableBaddieAI(value, 0))
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Status = ITEM_ACTIVE;
|
2021-08-30 17:50:32 +03:00
|
|
|
AddActiveItem(value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Status = ITEM_INVISIBLE;
|
2021-08-30 17:50:32 +03:00
|
|
|
AddActiveItem(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TouchBits = 0;
|
|
|
|
item->Status = ITEM_ACTIVE;
|
2021-08-30 17:50:32 +03:00
|
|
|
AddActiveItem(value);
|
|
|
|
EnableBaddieAI(value, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TouchBits = 0;
|
2021-08-30 17:50:32 +03:00
|
|
|
AddActiveItem(value);
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Status = ITEM_ACTIVE;
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_CAMERA:
|
|
|
|
trigger = *(data++);
|
|
|
|
|
|
|
|
if (keyResult == 1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (g_Level.Cameras[value].flags & ONESHOT)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Camera.number = value;
|
|
|
|
|
2022-02-16 18:13:07 +11:00
|
|
|
if (Camera.type == CameraType::Look || Camera.type == CameraType::Combat && !(g_Level.Cameras[value].flags & 3))
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::COMBAT)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::SWITCH && timer && switchOff)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (Camera.number != Camera.last || triggerType == TRIGGER_TYPES::SWITCH)
|
|
|
|
{
|
|
|
|
Camera.timer = (trigger & 0xFF) * 30;
|
2022-02-16 18:13:07 +11:00
|
|
|
Camera.type = heavy ? CameraType::Heavy : CameraType::Fixed;
|
2021-08-30 17:50:32 +03:00
|
|
|
if (trigger & ONESHOT)
|
|
|
|
g_Level.Cameras[Camera.number].flags |= ONESHOT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FLYBY:
|
|
|
|
trigger = *(data++);
|
|
|
|
|
|
|
|
if (keyResult == 1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::ANTIPAD ||
|
|
|
|
triggerType == TRIGGER_TYPES::ANTITRIGGER ||
|
|
|
|
triggerType == TRIGGER_TYPES::HEAVYANTITRIGGER)
|
|
|
|
UseSpotCam = false;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spotCamIndex = 0;
|
|
|
|
if (SpotCamRemap[value] != 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < SpotCamRemap[value]; i++)
|
|
|
|
{
|
|
|
|
spotCamIndex += CameraCnt[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(SpotCam[spotCamIndex].flags & SCF_CAMERA_ONE_SHOT))
|
|
|
|
{
|
|
|
|
if (trigger & ONESHOT)
|
|
|
|
SpotCam[spotCamIndex].flags |= SCF_CAMERA_ONE_SHOT;
|
|
|
|
|
|
|
|
if (!UseSpotCam || CurrentLevel == 0)
|
|
|
|
{
|
|
|
|
UseSpotCam = true;
|
2022-01-11 15:16:24 +03:00
|
|
|
if (LastSpotCamSequence != value)
|
2021-08-30 17:50:32 +03:00
|
|
|
TrackCameraInit = false;
|
|
|
|
InitialiseSpotCam(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_TARGET:
|
|
|
|
cameraItem = &g_Level.Items[value];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_SINK:
|
2022-02-11 19:26:08 +11:00
|
|
|
Lara.Control.WaterCurrentActive = value + 1;
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FLIPMAP:
|
|
|
|
flipAvailable = true;
|
|
|
|
|
2021-09-13 03:07:58 +03:00
|
|
|
if (FlipMap[value] & ONESHOT)
|
2021-08-30 17:50:32 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (triggerType == TRIGGER_TYPES::SWITCH)
|
|
|
|
FlipMap[value] ^= (flags & CODE_BITS);
|
|
|
|
else if (flags & CODE_BITS)
|
|
|
|
FlipMap[value] |= (flags & CODE_BITS);
|
|
|
|
|
|
|
|
if ((FlipMap[value] & CODE_BITS) == CODE_BITS)
|
|
|
|
{
|
2021-09-13 03:07:58 +03:00
|
|
|
if (flags & ONESHOT)
|
|
|
|
FlipMap[value] |= ONESHOT;
|
2021-08-30 17:50:32 +03:00
|
|
|
if (!FlipStats[value])
|
|
|
|
flip = value;
|
|
|
|
}
|
|
|
|
else if (FlipStats[value])
|
|
|
|
flip = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FLIPON:
|
|
|
|
flipAvailable = true;
|
2021-10-28 06:16:33 +02:00
|
|
|
if ((FlipMap[value] & 0x3E00) == 0x3E00 && !FlipStats[value])
|
2021-08-30 17:50:32 +03:00
|
|
|
flip = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FLIPOFF:
|
|
|
|
flipAvailable = true;
|
2021-10-28 06:16:33 +02:00
|
|
|
if ((FlipMap[value] & 0x3E00) == 0x3E00 && FlipStats[value])
|
2021-08-30 17:50:32 +03:00
|
|
|
flip = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FLIPEFFECT:
|
|
|
|
TriggerTimer = timer;
|
|
|
|
newEffect = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_FINISH:
|
|
|
|
RequiredStartPos = false;
|
|
|
|
LevelComplete = CurrentLevel + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_CD:
|
|
|
|
PlaySoundTrack(value, flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TO_CUTSCENE:
|
|
|
|
// TODO: not used for now
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (!(trigger & END_BIT));
|
|
|
|
|
2022-02-16 18:13:07 +11:00
|
|
|
if (cameraItem && (Camera.type == CameraType::Fixed || Camera.type == CameraType::Heavy))
|
2021-08-30 17:50:32 +03:00
|
|
|
Camera.item = cameraItem;
|
|
|
|
|
|
|
|
if (flip != -1)
|
|
|
|
DoFlipMap(flip);
|
|
|
|
|
|
|
|
if (newEffect != -1 && (flip || !flipAvailable))
|
|
|
|
FlipEffect = newEffect;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestTriggers(ITEM_INFO* item, bool heavy, int heavyFlags)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
TestTriggers(item->Position.xPos, item->Position.yPos, item->Position.zPos, item->RoomNumber, heavy, heavyFlags);
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestTriggers(int x, int y, int z, short roomNumber, bool heavy, int heavyFlags)
|
|
|
|
{
|
|
|
|
auto roomNum = roomNumber;
|
|
|
|
auto floor = GetFloor(x, y, z, &roomNum);
|
|
|
|
|
|
|
|
// Don't process legacy triggers if trigger triggerer wasn't used
|
|
|
|
if (floor->Flags.MarkTriggerer && !floor->Flags.MarkTriggererActive)
|
|
|
|
return;
|
|
|
|
|
2021-10-01 18:31:06 +03:00
|
|
|
TestTriggers(floor, x, y, z, heavy, heavyFlags);
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProcessSectorFlags(ITEM_INFO* item)
|
|
|
|
{
|
2022-01-19 16:17:16 +11:00
|
|
|
ProcessSectorFlags(GetCollisionResult(item).BottomBlock);
|
2021-08-30 17:50:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProcessSectorFlags(int x, int y, int z, short roomNumber)
|
|
|
|
{
|
|
|
|
ProcessSectorFlags(GetCollisionResult(x, y, z, roomNumber).BottomBlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProcessSectorFlags(FLOOR_INFO* floor)
|
|
|
|
{
|
|
|
|
// Monkeyswing
|
2022-02-10 01:38:32 +11:00
|
|
|
Lara.Control.CanMonkeySwing = floor->Flags.Monkeyswing;
|
2021-08-30 17:50:32 +03:00
|
|
|
|
|
|
|
// Burn Lara
|
2022-02-11 01:31:54 +11:00
|
|
|
if (floor->Flags.Death &&
|
2022-02-12 16:25:59 +11:00
|
|
|
(LaraItem->Position.yPos == LaraItem->Floor && !IsJumpState((LaraState)LaraItem->ActiveState) ||
|
2022-02-11 01:31:54 +11:00
|
|
|
Lara.Control.WaterStatus != WaterStatus::Dry))
|
|
|
|
{
|
2021-08-30 17:50:32 +03:00
|
|
|
LavaBurn(LaraItem);
|
2022-02-11 01:31:54 +11:00
|
|
|
}
|
2021-08-30 17:50:32 +03:00
|
|
|
|
|
|
|
// Set climb status
|
2022-02-09 16:55:46 +11:00
|
|
|
if ((1 << (GetQuadrant(LaraItem->Position.yRot) + 8)) & GetClimbFlags(floor))
|
2022-02-10 01:38:32 +11:00
|
|
|
Lara.Control.CanClimbLadder = true;
|
2021-09-04 15:43:37 +03:00
|
|
|
else
|
2022-02-10 01:38:32 +11:00
|
|
|
Lara.Control.CanClimbLadder = false;
|
2022-01-19 22:45:38 +11:00
|
|
|
}
|