2020-05-27 09:21:20 +02:00
|
|
|
#include "framework.h"
|
2019-11-09 09:55:56 +01:00
|
|
|
#include "switch.h"
|
|
|
|
#include "door.h"
|
|
|
|
#include "items.h"
|
|
|
|
#include "lot.h"
|
|
|
|
#include "objects.h"
|
|
|
|
#include "Lara.h"
|
2021-05-26 01:58:30 -05:00
|
|
|
#ifdef NEW_INV
|
|
|
|
#include "newinv2.h"
|
|
|
|
#else
|
2019-11-09 09:55:56 +01:00
|
|
|
#include "inventory.h"
|
2021-05-26 01:58:30 -05:00
|
|
|
#endif
|
2019-11-09 09:55:56 +01:00
|
|
|
#include "draw.h"
|
|
|
|
#include "sphere.h"
|
2020-04-12 07:08:22 +02:00
|
|
|
#include "camera.h"
|
2020-05-27 09:21:20 +02:00
|
|
|
#include "setup.h"
|
|
|
|
#include "level.h"
|
|
|
|
#include "input.h"
|
2020-04-24 19:15:05 +02:00
|
|
|
#include "sound.h"
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
byte SequenceUsed[6];
|
|
|
|
byte SequenceResults[3][3][3];
|
|
|
|
byte Sequences[3];
|
|
|
|
byte CurrentSequence;
|
2020-01-07 15:22:13 +01:00
|
|
|
int PulleyItemNumber = NO_ITEM;
|
2019-11-18 07:48:35 +01:00
|
|
|
|
2019-11-15 07:40:22 +01:00
|
|
|
extern PHD_VECTOR OldPickupPos;
|
2021-05-20 14:19:11 -05:00
|
|
|
#ifndef NEW_INV
|
2020-06-16 19:45:06 +02:00
|
|
|
extern Inventory g_Inventory;
|
2021-05-20 14:19:11 -05:00
|
|
|
#endif
|
2021-08-25 08:16:35 +02:00
|
|
|
|
2020-07-25 18:02:35 +02:00
|
|
|
OBJECT_COLLISION_BOUNDS Switch2Bounds =
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
0xFC00, 0x0400, 0xFC00, 0x0400, 0xFC00, 0x0200, 0xC720, 0x38E0, 0xC720, 0x38E0,
|
|
|
|
0xC720, 0x38E0
|
|
|
|
};
|
|
|
|
PHD_VECTOR Switch2Position = { 0, 0, 108 };
|
2020-07-25 18:02:35 +02:00
|
|
|
OBJECT_COLLISION_BOUNDS TurnSwitchBoundsA = // offset 0xA14D8
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
0x0200, 0x0380, 0x0000, 0x0000, 0xFE00, 0x0000, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
|
|
|
|
0xF8E4, 0x071C
|
|
|
|
};
|
|
|
|
PHD_VECTOR TurnSwitchPos = { 650, 0, 138 }; // offset 0xA14F0
|
2020-07-25 18:02:35 +02:00
|
|
|
OBJECT_COLLISION_BOUNDS TurnSwitchBoundsC = // offset 0xA14FC
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
0x0200, 0x0380, 0x0000, 0x0000, 0x0000, 0x0200, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
|
|
|
|
0xF8E4, 0x071C
|
|
|
|
};
|
|
|
|
PHD_VECTOR TurnSwitchPosA = { 650, 0, -138 }; // offset 0xA1514
|
2021-08-25 09:42:17 +02:00
|
|
|
|
2020-07-25 18:02:35 +02:00
|
|
|
OBJECT_COLLISION_BOUNDS FullBlockSwitchBounds = // offset 0xA15F8
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
0xFE80, 0x0180, 0x0000, 0x0100, 0x0000, 0x0200, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
|
|
|
|
0xF8E4, 0x071C
|
|
|
|
};
|
|
|
|
PHD_VECTOR FullBlockSwitchPos = { 0, 0, 0 }; // offset 0xA1610
|
2020-07-25 18:02:35 +02:00
|
|
|
OBJECT_COLLISION_BOUNDS PulleyBounds = // offset 0xA161C
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
0xFF00, 0x0100, 0x0000, 0x0000, 0xFE00, 0x0200, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
|
|
|
|
0xF8E4, 0x071C
|
|
|
|
};
|
|
|
|
PHD_VECTOR PulleyPos = { 0, 0, -148 }; // offset 0xA1634
|
|
|
|
PHD_VECTOR CrowDovePos = { 0, 0, -400 }; // offset 0xA1640
|
2021-08-26 05:46:10 +02:00
|
|
|
|
2019-11-09 09:55:56 +01:00
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void ProcessExplodingSwitchType8(ITEM_INFO* item)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
PHD_VECTOR pos;
|
|
|
|
pos.x = 0;
|
|
|
|
pos.y = 0;
|
|
|
|
pos.z = 0;
|
|
|
|
GetJointAbsPosition(item, &pos, 0);
|
|
|
|
TestTriggersAtXYZ(pos.x, pos.y, pos.z, item->roomNumber, 1, 0);
|
|
|
|
ExplodeItemNode(item, Objects[item->objectNumber].nmeshes - 1, 0, 64);
|
|
|
|
item->meshBits |= 1 << ((Objects[item->objectNumber].nmeshes & 0xFF) - 2);
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void CrowDoveSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
if (item->flags & 0x100
|
|
|
|
|| !(item->meshBits & 4)
|
2019-11-17 08:21:25 +01:00
|
|
|
|| (!(TrInput & IN_ACTION)
|
|
|
|
|| Lara.gunStatus
|
2020-08-04 20:32:07 +10:00
|
|
|
|| l->currentAnimState != LS_STOP
|
|
|
|
|| l->animNumber != LA_STAND_IDLE
|
2019-11-17 08:21:25 +01:00
|
|
|
|| l->gravityStatus)
|
2019-11-09 09:55:56 +01:00
|
|
|
&& (!Lara.isMoving || Lara.generalPtr != (void*)itemNum))
|
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
if (l->currentAnimState != LS_DOVESWITCH)
|
2019-11-09 09:55:56 +01:00
|
|
|
ObjectCollision(itemNum, l, coll);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
int oldYrot = item->pos.yRot;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->pos.yRot = l->pos.yRot;
|
2020-07-25 18:02:35 +02:00
|
|
|
if (TestLaraPosition(&PulleyBounds, item, l))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if (MoveLaraPosition(&CrowDovePos, item, l))
|
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
l->animNumber = LA_DOVESWITCH_TURN;
|
|
|
|
l->currentAnimState = LS_DOVESWITCH;
|
2020-07-21 09:56:47 +02:00
|
|
|
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
AddActiveItem(itemNum);
|
|
|
|
|
2020-04-07 19:20:32 +02:00
|
|
|
item->itemFlags[0] = 0; // This enables the switch again (in TR5 this switch was always triggered by heavy triggers)
|
2019-11-09 09:55:56 +01:00
|
|
|
item->status = ITEM_ACTIVE;
|
|
|
|
item->pos.yRot = oldYrot;
|
|
|
|
Lara.isMoving = false;
|
|
|
|
Lara.headYrot = 0;
|
|
|
|
Lara.headXrot = 0;
|
|
|
|
Lara.torsoYrot = 0;
|
|
|
|
Lara.torsoXrot = 0;
|
|
|
|
Lara.gunStatus = LG_HANDS_BUSY;
|
|
|
|
Lara.generalPtr = (void*)item;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Lara.generalPtr = (void*)itemNum;
|
|
|
|
}
|
|
|
|
item->pos.yRot = oldYrot;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Lara.isMoving && Lara.generalPtr == (void*)itemNum)
|
|
|
|
{
|
|
|
|
Lara.isMoving = false;
|
|
|
|
Lara.gunStatus = LG_NO_ARMS;
|
|
|
|
}
|
|
|
|
item->pos.yRot = oldYrot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void CrowDoveSwitchControl(short itemNumber)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNumber];
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
if ((item->meshBits & 2))
|
|
|
|
{
|
|
|
|
ExplodeItemNode(item, 1, 0, 0x100);
|
2021-05-26 06:04:32 +02:00
|
|
|
SoundEffect(SFX_TR5_RAVENSWITCH_EXP, &item->pos, 0);
|
2019-11-09 09:55:56 +01:00
|
|
|
item->meshBits = 5;
|
|
|
|
RemoveActiveItem(itemNumber);
|
2020-04-07 19:20:32 +02:00
|
|
|
item->itemFlags[0] = 1; // I use this for not making it activable again by trigger
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
2020-04-07 19:20:32 +02:00
|
|
|
else if (!item->itemFlags[0])
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if (item->currentAnimState == 0)
|
|
|
|
item->goalAnimState = 1;
|
|
|
|
|
|
|
|
AnimateItem(item);
|
|
|
|
|
|
|
|
if (item->currentAnimState == 0)
|
|
|
|
item->pos.yRot += ANGLE(90);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void FullBlockSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
if ((!(TrInput & IN_ACTION)
|
|
|
|
|| item->status
|
|
|
|
|| item->flags & 0x100
|
|
|
|
|| CurrentSequence >= 3u
|
|
|
|
|| Lara.gunStatus
|
2020-08-04 20:32:07 +10:00
|
|
|
|| l->currentAnimState != LS_STOP
|
|
|
|
|| l->animNumber != LA_STAND_IDLE)
|
2019-11-09 09:55:56 +01:00
|
|
|
&& (!Lara.isMoving || Lara.generalPtr != (void*)itemNum))
|
|
|
|
{
|
|
|
|
ObjectCollision(itemNum, l, coll);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-25 18:02:35 +02:00
|
|
|
if (TestLaraPosition(&FullBlockSwitchBounds, item, l))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if (MoveLaraPosition(&FullBlockSwitchPos, item, l))
|
|
|
|
{
|
|
|
|
if (item->currentAnimState == 1)
|
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
l->currentAnimState = LS_SWITCH_DOWN;
|
|
|
|
l->animNumber = LA_BUTTON_GIANT_PUSH;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->goalAnimState = 0;
|
|
|
|
}
|
2020-08-04 20:32:07 +10:00
|
|
|
l->goalAnimState = LS_STOP;
|
2020-07-21 09:56:47 +02:00
|
|
|
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->status = ITEM_ACTIVE;
|
|
|
|
|
|
|
|
AddActiveItem(itemNum);
|
|
|
|
AnimateItem(item);
|
|
|
|
|
|
|
|
Lara.isMoving = false;
|
|
|
|
Lara.headYrot = 0;
|
|
|
|
Lara.headXrot = 0;
|
|
|
|
Lara.torsoYrot = 0;
|
|
|
|
Lara.torsoXrot = 0;
|
|
|
|
Lara.gunStatus = LG_HANDS_BUSY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Lara.generalPtr = (void*)itemNum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Lara.isMoving && Lara.generalPtr == (void*)itemNum)
|
|
|
|
{
|
|
|
|
Lara.isMoving = false;
|
|
|
|
Lara.gunStatus = LG_NO_ARMS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void FullBlockSwitchControl(short itemNumber)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNumber];
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
if (item->animNumber != Objects[item->objectNumber].animIndex + 2
|
|
|
|
|| CurrentSequence >= 3u
|
|
|
|
|| item->itemFlags[0])
|
|
|
|
{
|
|
|
|
if (CurrentSequence >= 4u)
|
|
|
|
{
|
|
|
|
item->itemFlags[0] = 0;
|
|
|
|
item->goalAnimState = 1;
|
2020-05-30 15:55:23 +02:00
|
|
|
item->status = ITEM_NOT_ACTIVE;
|
2019-11-09 09:55:56 +01:00
|
|
|
if (++CurrentSequence >= 7u)
|
|
|
|
CurrentSequence = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->itemFlags[0] = 1;
|
|
|
|
Sequences[CurrentSequence++] = item->triggerFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimateItem(item);
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void CrowbarSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
int doSwitch = 0;
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
2019-11-09 09:55:56 +01:00
|
|
|
|
2021-05-20 14:19:11 -05:00
|
|
|
if ((!(TrInput & IN_ACTION) &&
|
|
|
|
#ifdef NEW_INV
|
|
|
|
GLOBAL_inventoryitemchosen != ID_CROWBAR_ITEM
|
|
|
|
#else
|
|
|
|
g_Inventory.GetSelectedObject() != ID_CROWBAR_ITEM
|
|
|
|
#endif
|
2020-08-04 20:32:07 +10:00
|
|
|
|| l->currentAnimState != LS_STOP
|
|
|
|
|| l->animNumber != LA_STAND_IDLE
|
2019-11-09 09:55:56 +01:00
|
|
|
|| Lara.gunStatus
|
|
|
|
|| item->itemFlags[0])
|
2020-08-06 20:41:07 +02:00
|
|
|
&& (!Lara.isMoving || Lara.generalPtr != (void*)itemNum))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
ObjectCollision(itemNum, l, coll);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item->currentAnimState)
|
|
|
|
{
|
|
|
|
if (item->currentAnimState != 1)
|
|
|
|
{
|
|
|
|
ObjectCollision(itemNum, l, coll);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-27 15:12:35 +01:00
|
|
|
l->pos.yRot ^= (short)ANGLE(180);
|
2020-07-25 18:02:35 +02:00
|
|
|
if (TestLaraPosition(&CrowbarBounds2, item, l))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2021-05-20 14:19:11 -05:00
|
|
|
if (Lara.isMoving ||
|
|
|
|
#ifdef NEW_INV
|
|
|
|
GLOBAL_inventoryitemchosen == ID_CROWBAR_ITEM
|
|
|
|
#else
|
|
|
|
g_Inventory.GetSelectedObject() == ID_CROWBAR_ITEM
|
|
|
|
#endif
|
|
|
|
)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if (MoveLaraPosition(&CrowbarPos2, item, l))
|
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
l->animNumber = LA_CROWBAR_USE_ON_FLOOR;
|
2019-11-09 09:55:56 +01:00
|
|
|
doSwitch = 1;
|
2020-07-21 09:56:47 +02:00
|
|
|
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->goalAnimState = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Lara.generalPtr = (void*)itemNum;
|
|
|
|
}
|
2021-05-20 14:19:11 -05:00
|
|
|
#ifdef NEW_INV
|
|
|
|
GLOBAL_inventoryitemchosen = NO_ITEM;
|
|
|
|
#else
|
2020-06-16 19:45:06 +02:00
|
|
|
g_Inventory.SetSelectedObject(NO_ITEM);
|
2021-05-20 14:19:11 -05:00
|
|
|
#endif
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
doSwitch = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Lara.isMoving && Lara.generalPtr == (void*)itemNum)
|
|
|
|
{
|
|
|
|
Lara.isMoving = false;
|
|
|
|
Lara.gunStatus = LG_NO_ARMS;
|
|
|
|
}
|
2019-11-27 15:12:35 +01:00
|
|
|
l->pos.yRot ^= (short)ANGLE(180);
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-25 18:02:35 +02:00
|
|
|
if (!TestLaraPosition(&CrowbarBounds, item, l))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if (Lara.isMoving && Lara.generalPtr == (void*)itemNum)
|
|
|
|
{
|
|
|
|
Lara.isMoving = false;
|
|
|
|
Lara.gunStatus = LG_NO_ARMS;
|
|
|
|
}
|
|
|
|
ObjectCollision(itemNum, l, coll);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-05-20 14:19:11 -05:00
|
|
|
if (!(Lara.isMoving &&
|
|
|
|
#ifdef NEW_INV
|
|
|
|
GLOBAL_inventoryitemchosen != ID_CROWBAR_ITEM)
|
|
|
|
#else
|
|
|
|
g_Inventory.GetSelectedObject() != ID_CROWBAR_ITEM)
|
|
|
|
#endif
|
|
|
|
)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-04-27 14:01:00 +02:00
|
|
|
if (Lara.Crowbar)
|
2021-05-20 14:19:11 -05:00
|
|
|
#ifdef NEW_INV
|
|
|
|
GLOBAL_inventoryitemchosen = ID_CROWBAR_ITEM;
|
|
|
|
#else
|
2020-06-16 19:45:06 +02:00
|
|
|
g_Inventory.SetEnterObject(ID_CROWBAR_ITEM);
|
2021-05-20 14:19:11 -05:00
|
|
|
#endif
|
2019-11-09 09:55:56 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (OldPickupPos.x != l->pos.xPos || OldPickupPos.y != l->pos.yPos || OldPickupPos.z != l->pos.zPos)
|
|
|
|
{
|
|
|
|
OldPickupPos.x = l->pos.xPos;
|
|
|
|
OldPickupPos.y = l->pos.yPos;
|
|
|
|
OldPickupPos.z = l->pos.zPos;
|
|
|
|
SayNo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MoveLaraPosition(&CrowbarPos, item, l))
|
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
l->animNumber = LA_CROWBAR_USE_ON_FLOOR;
|
2019-11-09 09:55:56 +01:00
|
|
|
doSwitch = 1;
|
2020-07-21 09:56:47 +02:00
|
|
|
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->goalAnimState = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Lara.generalPtr = (void*)itemNum;
|
|
|
|
}
|
2021-05-20 14:19:11 -05:00
|
|
|
#ifdef NEW_INV
|
|
|
|
GLOBAL_inventoryitemchosen = NO_ITEM;
|
|
|
|
#else
|
2020-06-16 19:45:06 +02:00
|
|
|
g_Inventory.SetSelectedObject(NO_ITEM);
|
2021-05-20 14:19:11 -05:00
|
|
|
#endif
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!doSwitch)
|
|
|
|
{
|
|
|
|
ObjectCollision(itemNum, l, coll);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doSwitch != -1)
|
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
l->goalAnimState = LS_SWITCH_DOWN;
|
|
|
|
l->currentAnimState = LS_SWITCH_DOWN;
|
2019-11-09 09:55:56 +01:00
|
|
|
Lara.isMoving = false;
|
|
|
|
Lara.headYrot = 0;
|
|
|
|
Lara.headXrot = 0;
|
|
|
|
Lara.torsoYrot = 0;
|
|
|
|
Lara.torsoXrot = 0;
|
|
|
|
Lara.gunStatus = LG_HANDS_BUSY;
|
|
|
|
item->status = ITEM_ACTIVE;
|
|
|
|
|
|
|
|
AddActiveItem(itemNum);
|
|
|
|
AnimateItem(item);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-27 14:01:00 +02:00
|
|
|
if (Lara.Crowbar)
|
2021-05-20 14:19:11 -05:00
|
|
|
#ifdef NEW_INV
|
|
|
|
GLOBAL_enterinventory = ID_CROWBAR_ITEM;
|
|
|
|
#else
|
2020-06-16 19:45:06 +02:00
|
|
|
g_Inventory.SetEnterObject(ID_CROWBAR_ITEM);
|
2021-05-20 14:19:11 -05:00
|
|
|
#endif
|
2019-11-09 09:55:56 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (OldPickupPos.x != l->pos.xPos || OldPickupPos.y != l->pos.yPos || OldPickupPos.z != l->pos.zPos)
|
|
|
|
{
|
|
|
|
OldPickupPos.x = l->pos.xPos;
|
|
|
|
OldPickupPos.y = l->pos.yPos;
|
|
|
|
OldPickupPos.z = l->pos.zPos;
|
|
|
|
SayNo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void TurnSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
2019-11-27 15:12:35 +01:00
|
|
|
int flag = 0;
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
if (item->currentAnimState
|
|
|
|
&& TrInput & IN_ACTION
|
2020-08-04 20:32:07 +10:00
|
|
|
&& l->currentAnimState == LS_STOP
|
|
|
|
&& l->animNumber == LA_STAND_IDLE
|
2019-11-09 09:55:56 +01:00
|
|
|
&& !l->gravityStatus
|
|
|
|
&& Lara.gunStatus == LG_NO_ARMS
|
|
|
|
|| Lara.isMoving && Lara.generalPtr == (void*)itemNum)
|
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
short ItemNos[8];
|
2020-07-25 18:02:35 +02:00
|
|
|
if (TestLaraPosition(&TurnSwitchBoundsA, item, l))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if (MoveLaraPosition(&TurnSwitchPosA, item, l))
|
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
l->animNumber = LA_TURNSWITCH_GRAB_COUNTER_CLOCKWISE;
|
|
|
|
l->frameNumber = g_Level.Anims[LA_TURNSWITCH_GRAB_COUNTER_CLOCKWISE].frameBase;
|
2019-11-09 09:55:56 +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;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->itemFlags[0] = 1;
|
2020-10-05 22:24:57 -03:00
|
|
|
ForcedFixedCamera.x = item->pos.xPos - 1024 * phd_sin(item->pos.yRot);
|
|
|
|
ForcedFixedCamera.z = item->pos.zPos - 1024 * phd_cos(item->pos.yRot);
|
2019-11-09 09:55:56 +01:00
|
|
|
Lara.isMoving = 0;
|
|
|
|
Lara.headYrot = 0;
|
|
|
|
Lara.headXrot = 0;
|
|
|
|
Lara.torsoYrot = 0;
|
|
|
|
Lara.torsoXrot = 0;
|
|
|
|
Lara.gunStatus = LG_HANDS_BUSY;
|
2020-08-04 20:32:07 +10:00
|
|
|
l->currentAnimState = LA_REACH;
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
UseForcedFixedCamera = true;
|
|
|
|
ForcedFixedCamera.y = item->pos.yPos - 2048;
|
|
|
|
ForcedFixedCamera.roomNumber = item->roomNumber;
|
|
|
|
|
|
|
|
AddActiveItem(itemNum);
|
|
|
|
|
|
|
|
item->status = ITEM_ACTIVE;
|
|
|
|
item->itemFlags[1] = 0;
|
|
|
|
|
|
|
|
if (GetSwitchTrigger(item, ItemNos, 0))
|
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
if (!TriggerActive(&g_Level.Items[ItemNos[0]]))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
g_Level.Items[ItemNos[0]].animNumber = Objects[g_Level.Items[ItemNos[0]].objectNumber].animIndex;
|
|
|
|
g_Level.Items[ItemNos[0]].frameNumber = g_Level.Anims[g_Level.Items[ItemNos[0]].animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Lara.generalPtr = (void*)itemNum;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
l->pos.yRot ^= (short)ANGLE(180);
|
2020-07-25 18:02:35 +02:00
|
|
|
if (TestLaraPosition(&TurnSwitchBoundsC, item, l))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if (MoveLaraPosition(&TurnSwitchPos, item, l))
|
|
|
|
{
|
|
|
|
l->animNumber = 319;
|
|
|
|
flag = 1;
|
2020-07-21 09:56:47 +02:00
|
|
|
l->frameNumber = g_Level.Anims[319].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->itemFlags[0] = 2;
|
2020-10-05 22:24:57 -03:00
|
|
|
ForcedFixedCamera.x = item->pos.xPos + 1024 * phd_sin(item->pos.yRot);
|
|
|
|
ForcedFixedCamera.z = item->pos.zPos + 1024 * phd_cos(item->pos.yRot);
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Lara.generalPtr = (void*)itemNum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Lara.isMoving && Lara.generalPtr == (void*)itemNum)
|
|
|
|
{
|
2019-11-21 07:43:34 +01:00
|
|
|
Lara.isMoving = false;
|
2019-11-09 09:55:56 +01:00
|
|
|
Lara.gunStatus = LG_NO_ARMS;
|
|
|
|
}
|
2019-11-27 15:12:35 +01:00
|
|
|
l->pos.yRot ^= (short)ANGLE(180);
|
2019-11-09 09:55:56 +01:00
|
|
|
if (flag)
|
|
|
|
{
|
|
|
|
Lara.isMoving = 0;
|
|
|
|
Lara.headYrot = 0;
|
|
|
|
Lara.headXrot = 0;
|
|
|
|
Lara.torsoYrot = 0;
|
|
|
|
Lara.torsoXrot = 0;
|
|
|
|
Lara.gunStatus = LG_HANDS_BUSY;
|
2020-08-04 20:32:07 +10:00
|
|
|
l->currentAnimState = LA_REACH;
|
2020-07-07 07:32:33 +02:00
|
|
|
UseForcedFixedCamera = true;
|
2019-11-09 09:55:56 +01:00
|
|
|
ForcedFixedCamera.y = item->pos.yPos - 2048;
|
|
|
|
ForcedFixedCamera.roomNumber = item->roomNumber;
|
|
|
|
AddActiveItem(itemNum);
|
|
|
|
item->status = ITEM_ACTIVE;
|
|
|
|
item->itemFlags[1] = 0;
|
|
|
|
if (GetSwitchTrigger(item, ItemNos, 0))
|
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
if (!TriggerActive(&g_Level.Items[ItemNos[0]]))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
g_Level.Items[ItemNos[0]].animNumber = Objects[g_Level.Items[ItemNos[0]].objectNumber].animIndex + 4;
|
|
|
|
g_Level.Items[ItemNos[0]].frameNumber = g_Level.Anims[g_Level.Items[ItemNos[0]].animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (coll->enableBaddiePush && TestBoundsCollide(item, l, coll->radius))
|
|
|
|
{
|
|
|
|
GlobalCollisionBounds.X1 = -512;
|
|
|
|
GlobalCollisionBounds.X2 = 512;
|
|
|
|
GlobalCollisionBounds.Y1 = -512;
|
|
|
|
GlobalCollisionBounds.Y2 = 0;
|
|
|
|
GlobalCollisionBounds.Z1 = -512;
|
|
|
|
GlobalCollisionBounds.Z2 = 512;
|
|
|
|
|
|
|
|
ItemPushLara(item, l, coll, 0, 2);
|
|
|
|
|
|
|
|
GlobalCollisionBounds.X1 = 256;
|
|
|
|
GlobalCollisionBounds.X2 = 1024;
|
|
|
|
GlobalCollisionBounds.Z1 = -128;
|
|
|
|
GlobalCollisionBounds.Z2 = 128;
|
|
|
|
|
|
|
|
ItemPushLara(item, l, coll, 0, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void TurnSwitchControl(short itemNum)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
ITEM_INFO* l = LaraItem;
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
2019-11-09 09:55:56 +01:00
|
|
|
|
2020-07-21 09:56:47 +02:00
|
|
|
if (g_Level.Items[itemNum].itemFlags[0] == 2)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if (item->animNumber == Objects[ID_TURN_SWITCH].animIndex + 2)
|
|
|
|
{
|
|
|
|
item->pos.yRot += ANGLE(90);
|
|
|
|
if (TrInput & IN_ACTION)
|
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
l->animNumber = LA_TURNSWITCH_PUSH_CLOCKWISE_START;
|
2020-07-21 09:56:47 +02:00
|
|
|
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->animNumber = Objects[item->objectNumber].animIndex + 1;
|
2020-07-21 09:56:47 +02:00
|
|
|
item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-04 20:32:07 +10:00
|
|
|
if (l->animNumber == LA_TURNSWITCH_PUSH_CLOCKWISE_END && l->frameNumber == g_Level.Anims[l->animNumber].frameEnd && !item->itemFlags[1])
|
2019-11-09 09:55:56 +01:00
|
|
|
item->itemFlags[1] = 1;
|
|
|
|
|
2020-08-04 20:32:07 +10:00
|
|
|
if (l->frameNumber >= g_Level.Anims[LA_TURNSWITCH_PUSH_CLOCKWISE_START].frameBase &&
|
|
|
|
l->frameNumber <= g_Level.Anims[LA_TURNSWITCH_PUSH_CLOCKWISE_START].frameBase + 43
|
2019-11-09 09:55:56 +01:00
|
|
|
||
|
2020-08-04 20:32:07 +10:00
|
|
|
l->frameNumber >= g_Level.Anims[LA_TURNSWITCH_PUSH_CLOCKWISE_START].frameBase + 58 &&
|
|
|
|
l->frameNumber <= g_Level.Anims[LA_TURNSWITCH_PUSH_CLOCKWISE_START].frameBase + 115)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2021-05-26 06:04:32 +02:00
|
|
|
SoundEffect(SFX_TR4_PUSHABLE_SOUND, &item->pos, 2);
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (item->animNumber == Objects[ID_TURN_SWITCH].animIndex + 6)
|
|
|
|
{
|
|
|
|
item->pos.yRot -= ANGLE(90);
|
|
|
|
if (TrInput & IN_ACTION)
|
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
l->animNumber = LA_TURNSWITCH_PUSH_COUNTER_CLOCKWISE_START;
|
2020-07-21 09:56:47 +02:00
|
|
|
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->animNumber = Objects[item->objectNumber].animIndex + 5;
|
2020-07-21 09:56:47 +02:00
|
|
|
item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-04 20:32:07 +10:00
|
|
|
if (l->animNumber == LA_TURNSWITCH_PUSH_COUNTER_CLOCKWISE_END && l->frameNumber == g_Level.Anims[LA_TURNSWITCH_PUSH_COUNTER_CLOCKWISE_END].frameEnd &&
|
2019-11-09 09:55:56 +01:00
|
|
|
!item->itemFlags[1])
|
|
|
|
item->itemFlags[1] = 1;
|
|
|
|
|
2020-08-04 20:32:07 +10:00
|
|
|
if (l->frameNumber >= g_Level.Anims[LA_TURNSWITCH_PUSH_COUNTER_CLOCKWISE_START].frameBase &&
|
|
|
|
l->frameNumber <= g_Level.Anims[LA_TURNSWITCH_PUSH_COUNTER_CLOCKWISE_START].frameBase + 43
|
2019-11-09 09:55:56 +01:00
|
|
|
||
|
2020-08-04 20:32:07 +10:00
|
|
|
l->frameNumber >= g_Level.Anims[LA_TURNSWITCH_PUSH_COUNTER_CLOCKWISE_START].frameBase + 58 &&
|
|
|
|
l->frameNumber <= g_Level.Anims[LA_TURNSWITCH_PUSH_COUNTER_CLOCKWISE_START].frameBase + 115)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2021-05-26 06:04:32 +02:00
|
|
|
SoundEffect(SFX_TR4_PUSHABLE_SOUND, &item->pos, 2);
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimateItem(item);
|
|
|
|
|
|
|
|
if (item->itemFlags[1] == 1)
|
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
l->animNumber = LA_STAND_IDLE;
|
|
|
|
l->currentAnimState = LS_STOP;
|
2020-07-21 09:56:47 +02:00
|
|
|
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->animNumber = Objects[item->objectNumber].animIndex;
|
2020-07-21 09:56:47 +02:00
|
|
|
item->frameNumber = g_Level.Anims[item->animNumber].frameBase;
|
2020-05-30 15:55:23 +02:00
|
|
|
item->status = ITEM_NOT_ACTIVE;
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
RemoveActiveItem(itemNum);
|
|
|
|
|
|
|
|
Lara.gunStatus = LG_NO_ARMS;
|
|
|
|
UseForcedFixedCamera = 0;
|
|
|
|
item->itemFlags[1] = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void PulleyCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
if (item->flags & 0x100
|
2021-06-08 06:32:51 +02:00
|
|
|
|| (!(TrInput & IN_ACTION)
|
|
|
|
|| Lara.gunStatus
|
|
|
|
|| l->currentAnimState != LS_STOP
|
|
|
|
|| l->animNumber != LA_STAND_IDLE
|
|
|
|
|| item->gravityStatus)
|
|
|
|
&& (!Lara.isMoving
|
|
|
|
|| Lara.generalPtr != (void*)itemNum))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
if (l->currentAnimState != LS_PULLEY)
|
2019-11-09 09:55:56 +01:00
|
|
|
ObjectCollision(itemNum, l, coll);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
short oldYrot = item->pos.yRot;
|
2019-11-09 09:55:56 +01:00
|
|
|
item->pos.yRot = l->pos.yRot;
|
2020-07-25 18:02:35 +02:00
|
|
|
if (TestLaraPosition(&PulleyBounds, item, l))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2021-06-08 06:32:51 +02:00
|
|
|
if (item->itemFlags[1])
|
|
|
|
{
|
|
|
|
if (OldPickupPos.x != l->pos.xPos || OldPickupPos.y != l->pos.yPos || OldPickupPos.z != l->pos.zPos)
|
|
|
|
{
|
|
|
|
OldPickupPos.x = l->pos.xPos;
|
|
|
|
OldPickupPos.y = l->pos.yPos;
|
|
|
|
OldPickupPos.z = l->pos.zPos;
|
|
|
|
SayNo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (MoveLaraPosition(&PulleyPos, item, l))
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-08-04 20:32:07 +10:00
|
|
|
l->animNumber = LA_PULLEY_GRAB;
|
|
|
|
l->currentAnimState = LS_PULLEY;
|
2020-07-21 09:56:47 +02:00
|
|
|
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
|
2019-11-09 09:55:56 +01:00
|
|
|
|
|
|
|
AddActiveItem(itemNum);
|
|
|
|
|
|
|
|
item->pos.yRot = oldYrot;
|
|
|
|
item->status = ITEM_ACTIVE;
|
|
|
|
|
|
|
|
Lara.isMoving = false;
|
|
|
|
Lara.headYrot = 0;
|
|
|
|
Lara.headXrot = 0;
|
|
|
|
Lara.torsoYrot = 0;
|
|
|
|
Lara.torsoXrot = 0;
|
|
|
|
Lara.gunStatus = LG_HANDS_BUSY;
|
|
|
|
Lara.generalPtr = item;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Lara.generalPtr = (void*)itemNum;
|
|
|
|
}
|
|
|
|
item->pos.yRot = oldYrot;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Lara.isMoving && Lara.generalPtr == (void*)itemNum)
|
|
|
|
{
|
|
|
|
Lara.isMoving = false;
|
|
|
|
Lara.gunStatus = LG_NO_ARMS;
|
|
|
|
}
|
|
|
|
item->pos.yRot = oldYrot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
int GetKeyTrigger(ITEM_INFO* item)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &item->roomNumber);
|
|
|
|
GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
|
|
|
|
|
|
|
|
if (TriggerIndex)
|
|
|
|
{
|
2019-11-27 15:12:35 +01:00
|
|
|
short* trigger = TriggerIndex;
|
|
|
|
for (short i = *TriggerIndex; (i & 0x1F) != 4; trigger++)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if (i < 0)
|
|
|
|
break;
|
2019-11-18 07:48:35 +01:00
|
|
|
i = trigger[1];
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
if (*trigger & 4)
|
|
|
|
{
|
2020-10-16 12:06:33 -05:00
|
|
|
for (short* j = &trigger[2]; (*j / 256) & 0x3C || item != &g_Level.Items[*j & 0x3FF]; j++)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if (*j & 0x8000)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
int GetSwitchTrigger(ITEM_INFO* item, short* itemNos, int AttatchedToSwitch)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &item->roomNumber);
|
|
|
|
GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
|
|
|
|
|
|
|
|
if (TriggerIndex)
|
|
|
|
{
|
2020-01-08 16:01:57 -03:00
|
|
|
short* trigger;
|
|
|
|
for (trigger = TriggerIndex; (*trigger & DATA_TYPE) != TRIGGER_TYPE; trigger++)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-01-08 16:01:57 -03:00
|
|
|
if (*trigger & END_BIT)
|
2019-11-09 09:55:56 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*trigger & 4)
|
|
|
|
{
|
2020-01-08 16:01:57 -03:00
|
|
|
trigger += 2;
|
2019-11-27 15:12:35 +01:00
|
|
|
short* current = itemNos;
|
2020-01-07 15:22:13 +01:00
|
|
|
int k = 0;
|
2020-01-08 16:01:57 -03:00
|
|
|
do
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
if (TRIG_BITS(*trigger) == TO_OBJECT && item != &g_Level.Items[*trigger & VALUE_BITS])
|
2020-01-08 16:01:57 -03:00
|
|
|
{
|
|
|
|
current[k] = *trigger & VALUE_BITS;
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
if (*trigger & END_BIT)
|
2020-01-07 15:22:13 +01:00
|
|
|
break;
|
2020-01-08 16:01:57 -03:00
|
|
|
++trigger;
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
2020-01-08 16:01:57 -03:00
|
|
|
while (true);
|
2020-01-07 15:22:13 +01:00
|
|
|
|
|
|
|
return k;
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
int SwitchTrigger(short itemNum, short timer)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
2020-06-04 12:49:08 +02:00
|
|
|
if (item->status == ITEM_DEACTIVATED)
|
2019-11-09 09:55:56 +01:00
|
|
|
{
|
|
|
|
if ((!item->currentAnimState && item->objectNumber != ID_JUMP_SWITCH || item->currentAnimState == 1 && item->objectNumber == ID_JUMP_SWITCH) && timer > 0)
|
|
|
|
{
|
|
|
|
item->timer = timer;
|
|
|
|
item->status = ITEM_ACTIVE;
|
|
|
|
if (timer != 1)
|
|
|
|
item->timer = 30 * timer;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (item->triggerFlags != 6 || item->currentAnimState)
|
|
|
|
{
|
|
|
|
RemoveActiveItem(itemNum);
|
|
|
|
|
2020-05-30 15:55:23 +02:00
|
|
|
item->status = ITEM_NOT_ACTIVE;
|
2019-11-09 09:55:56 +01:00
|
|
|
if (!item->itemFlags[0] == 0)
|
|
|
|
item->flags |= 0x100;
|
|
|
|
if (item->currentAnimState != 1)
|
|
|
|
return 1;
|
|
|
|
if (item->triggerFlags != 5 && item->triggerFlags != 6)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->status = ITEM_ACTIVE;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (item->status)
|
|
|
|
{
|
2020-10-16 12:06:33 -05:00
|
|
|
return ((item->flags & 0x100u) / 256);
|
2019-11-09 09:55:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-01-12 08:02:48 +01:00
|
|
|
void InitialiseShootSwitch(short itemNumber)
|
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNumber];
|
2020-01-12 08:02:48 +01:00
|
|
|
if (item->triggerFlags == 444)
|
|
|
|
item->meshBits &= ~(1 << (Objects[item->objectNumber].nmeshes - 2));
|
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void InitialisePulleySwitch(short itemNumber)
|
2019-11-18 07:48:35 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNumber];
|
2020-01-07 15:22:13 +01:00
|
|
|
|
2019-11-18 07:48:35 +01:00
|
|
|
item->itemFlags[3] = item->triggerFlags;
|
|
|
|
item->triggerFlags = abs(item->triggerFlags);
|
2020-01-07 15:22:13 +01:00
|
|
|
|
2021-06-08 06:32:51 +02:00
|
|
|
if (item->status == ITEM_INVISIBLE)
|
|
|
|
{
|
2020-01-07 15:22:13 +01:00
|
|
|
item->itemFlags[1] = 1;
|
2021-06-08 06:32:51 +02:00
|
|
|
item->status = ITEM_NOT_ACTIVE;
|
|
|
|
}
|
2019-11-18 07:48:35 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void InitialiseCrowDoveSwitch(short itemNumber)
|
2019-11-18 07:48:35 +01:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
g_Level.Items[itemNumber].meshBits = 3;
|
2019-11-18 07:48:35 +01:00
|
|
|
}
|
|
|
|
|
2020-01-11 12:58:12 -03:00
|
|
|
void ShootSwitchCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll)
|
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNumber];
|
2020-01-11 12:58:12 -03:00
|
|
|
|
|
|
|
if (item->objectNumber == ID_SHOOT_SWITCH1 && !(item->meshBits & 1))
|
|
|
|
item->status = ITEM_INVISIBLE;
|
|
|
|
}
|