diff --git a/TR5Main/Game/Lara/lara_basic.cpp b/TR5Main/Game/Lara/lara_basic.cpp index 2f5025cbc..d48e89879 100644 --- a/TR5Main/Game/Lara/lara_basic.cpp +++ b/TR5Main/Game/Lara/lara_basic.cpp @@ -9,7 +9,7 @@ #include "health.h" #include "Sound\sound.h" #include "draw.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "collide.h" #include "item.h" #include "camera.h" diff --git a/TR5Main/Game/control.cpp b/TR5Main/Game/control.cpp index 6915e651c..ff1ff2797 100644 --- a/TR5Main/Game/control.cpp +++ b/TR5Main/Game/control.cpp @@ -1,7 +1,7 @@ #include "framework.h" #include "collide.h" #include "control.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "puzzles_keys.h" #include "camera.h" #include "Lara.h" diff --git a/TR5Main/Game/control/trigger.cpp b/TR5Main/Game/control/trigger.cpp index 29e39c846..1fff4ef24 100644 --- a/TR5Main/Game/control/trigger.cpp +++ b/TR5Main/Game/control/trigger.cpp @@ -6,7 +6,7 @@ #include "box.h" #include "camera.h" #include "puzzles_keys.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "lot.h" #include "spotcam.h" #include "traps.h" diff --git a/TR5Main/Game/door.cpp b/TR5Main/Game/door.cpp deleted file mode 100644 index 9f0e1b2c9..000000000 --- a/TR5Main/Game/door.cpp +++ /dev/null @@ -1,987 +0,0 @@ -#include "framework.h" -#include "door.h" -#include "items.h" -#include "lot.h" -#include "objects.h" -#include "Lara.h" -#ifdef NEW_INV -#include "newinv2.h" -#else -#include "inventory.h" -#endif -#include "draw.h" -#include "sphere.h" -#include "misc.h" -#include "box.h" -#include "level.h" -#include "input.h" -#include "Sound\sound.h" -#include "Specific\trmath.h" -#include "cog_switch.h" -#include "generic_switch.h" -#include "pickup\pickup.h" -#include "fullblock_switch.h" -#include "creature_info.h" -#include "door_data.h" -using namespace TEN::Entities::Switches; - -PHD_VECTOR DoubleDoorPos(0, 0, 220); -PHD_VECTOR PullDoorPos(-201, 0, 322); -PHD_VECTOR PushDoorPos(201, 0, -702); -PHD_VECTOR KickDoorPos(0, 0, -917); -PHD_VECTOR UnderwaterDoorPos(-251, -540, -46); -PHD_VECTOR CrowbarDoorPos(-412, 0, 256); - -OBJECT_COLLISION_BOUNDS PushPullKickDoorBounds = -{ - 0xFE80, 0x0180, 0x0000, 0x0000, 0xFC00, 0x0200, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0xF8E4, 0x071C -}; - -OBJECT_COLLISION_BOUNDS UnderwaterDoorBounds = -{ - 0xFF00, 0x0100, 0xFC00, 0x0000, 0xFC00, 0x0000, 0xC720, 0x38E0, 0xC720, 0x38E0, 0xC720, 0x38E0 -}; - -OBJECT_COLLISION_BOUNDS CrowbarDoorBounds = -{ - 0xFE00, 0x0200, 0xFC00, 0x0000, 0x0000, 0x0200, 0xC720, 0x38E0, 0xC720, 0x38E0, 0xC720, 0x38E0 -}; - -ITEM_INFO* ClosedDoors[32]; -byte LiftDoor; -int DontUnlockBox; - -#ifndef NEW_INV -extern Inventory g_Inventory; -#endif - -void SequenceDoorControl(short itemNumber) -{ - ITEM_INFO* item = &g_Level.Items[itemNumber]; - DOOR_DATA* door = (DOOR_DATA*)item->data; - - if (CurrentSequence == 3) - { - if (SequenceResults[Sequences[0]][Sequences[1]][Sequences[2]] == item->triggerFlags) - { - if (item->currentAnimState == 1) - item->goalAnimState = 1; - else - item->goalAnimState = 0; - - TestTriggers(item, true, NULL); - } - - CurrentSequence = 4; - } - - if (item->currentAnimState == item->goalAnimState) - { - if (item->currentAnimState == 1) - { - if (!door->opened) - { - OpenThatDoor(&door->d1, door); - OpenThatDoor(&door->d2, door); - OpenThatDoor(&door->d1flip, door); - OpenThatDoor(&door->d2flip, door); - door->opened = true; - item->flags |= 0x3E; - } - } - else - { - if (door->opened) - { - ShutThatDoor(&door->d1, door); - ShutThatDoor(&door->d2, door); - ShutThatDoor(&door->d1flip, door); - ShutThatDoor(&door->d2flip, door); - door->opened = false; - item->flags &= 0xC1; - } - } - } - - AnimateItem(item); -} - -void UnderwaterDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) -{ - ITEM_INFO* item = &g_Level.Items[itemNum]; - - if (TrInput & IN_ACTION - && l->currentAnimState == LS_UNDERWATER_STOP - && !(item->status && item->gravityStatus) - && Lara.waterStatus == LW_UNDERWATER - && !Lara.gunStatus - || Lara.isMoving && Lara.interactedItem == itemNum) - { - l->pos.yRot ^= ANGLE(180.0f); - - if (TestLaraPosition(&UnderwaterDoorBounds, item, l)) - { - if (MoveLaraPosition(&UnderwaterDoorPos, item, l)) - { - l->animNumber = LA_UNDERWATER_DOOR_OPEN; - l->frameNumber = GF(LA_UNDERWATER_DOOR_OPEN, 0); - l->currentAnimState = LS_MISC_CONTROL; - l->fallspeed = 0; - item->status = ITEM_ACTIVE; - AddActiveItem(itemNum); - item->goalAnimState = LS_RUN_FORWARD; - AnimateItem(item); - Lara.isMoving = false; - Lara.gunStatus = LG_HANDS_BUSY; - } - else - { - Lara.interactedItem = itemNum; - } - l->pos.yRot ^= ANGLE(180); - } - else - { - if (Lara.isMoving && Lara.interactedItem == itemNum) - { - Lara.isMoving = false; - Lara.gunStatus = LG_NO_ARMS; - } - l->pos.yRot ^= ANGLE(180); - } - } - else if (item->status == ITEM_ACTIVE) - { - ObjectCollision(itemNum, l, coll); - } -} - -void DoubleDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) -{ - ITEM_INFO* item = &g_Level.Items[itemNum]; - - if (TrInput & IN_ACTION - && l->currentAnimState == LS_STOP - && l->animNumber == LA_STAND_IDLE - && !(item->status && item->gravityStatus) - && !(l->hitStatus) - && !Lara.gunStatus - || Lara.isMoving && Lara.interactedItem == itemNum) - { - item->pos.yRot ^= ANGLE(180); - if (TestLaraPosition(&PushPullKickDoorBounds, item, l)) - { - if (MoveLaraPosition(&DoubleDoorPos, item, l)) - { - l->animNumber = LA_DOUBLEDOOR_OPEN_PUSH; - l->frameNumber = GF(LA_DOUBLEDOOR_OPEN_PUSH, 0); - l->currentAnimState = LS_DOUBLEDOOR_PUSH; - - AddActiveItem(itemNum); - - item->status = ITEM_ACTIVE; - Lara.isMoving = false; - Lara.gunStatus = LG_HANDS_BUSY; - Lara.headYrot = 0; - Lara.headXrot = 0; - Lara.torsoYrot = 0; - Lara.torsoXrot = 0; - } - else - { - Lara.interactedItem = itemNum; - } - item->pos.yRot ^= ANGLE(180); - } - else - { - if (Lara.isMoving && Lara.interactedItem == itemNum) - { - Lara.isMoving = false; - Lara.gunStatus = LG_NO_ARMS; - } - item->pos.yRot ^= ANGLE(180); - } - } -} - -void PushPullKickDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) -{ - ITEM_INFO* item = &g_Level.Items[itemNum]; - if (TrInput & IN_ACTION - && l->currentAnimState == LS_STOP - && l->animNumber == LA_STAND_IDLE - && item->status != ITEM_ACTIVE - && !(l->hitStatus) - && !Lara.gunStatus - || Lara.isMoving && Lara.interactedItem == itemNum) - { - bool applyRot = false; - - if (l->roomNumber == item->roomNumber) - { - item->pos.yRot ^= ANGLE(180); - applyRot = true; - } - - if (!TestLaraPosition(&PushPullKickDoorBounds, item, l)) - { - if (Lara.isMoving && Lara.interactedItem == itemNum) - { - Lara.isMoving = false; - Lara.gunStatus = LG_NO_ARMS; - } - if (applyRot) - item->pos.yRot ^= ANGLE(180); - return; - } - - if (applyRot) - { - if (!MoveLaraPosition(&PullDoorPos, item, l)) - { - Lara.interactedItem = itemNum; - item->pos.yRot ^= ANGLE(180); - return; - } - - l->animNumber = LA_DOOR_OPEN_PULL; - l->frameNumber = GF(LA_DOOR_OPEN_PULL, 0); - item->goalAnimState = 3; - - AddActiveItem(itemNum); - - item->status = ITEM_ACTIVE; - l->currentAnimState = LS_MISC_CONTROL; - l->goalAnimState = LS_STOP; - Lara.isMoving = false; - Lara.gunStatus = LG_HANDS_BUSY; - - if (applyRot) - item->pos.yRot ^= ANGLE(180); - return; - } - - if (item->objectNumber >= ID_KICK_DOOR1) - { - if (MoveLaraPosition(&KickDoorPos, item, l)) - { - l->animNumber = LA_DOOR_OPEN_KICK; - l->frameNumber = GF(LA_DOOR_OPEN_KICK, 0); - item->goalAnimState = 2; - - AddActiveItem(itemNum); - - item->status = ITEM_ACTIVE; - l->currentAnimState = LS_MISC_CONTROL; - l->goalAnimState = LS_STOP; - Lara.isMoving = false; - Lara.gunStatus = LG_HANDS_BUSY; - - if (applyRot) - item->pos.yRot ^= ANGLE(180); - return; - } - } - else if (item->objectNumber == ID_PUSHPULL_DOOR1 || item->objectNumber == ID_PUSHPULL_DOOR2) - { - if (MoveLaraPosition(&PushDoorPos, item, l)) - { - l->animNumber = LA_DOOR_OPEN_PUSH; - l->frameNumber = GF(LA_DOOR_OPEN_PUSH, 0); - item->goalAnimState = 2; - - AddActiveItem(itemNum); - - item->status = ITEM_ACTIVE; - l->currentAnimState = LS_MISC_CONTROL; - l->goalAnimState = LS_STOP; - Lara.isMoving = false; - Lara.gunStatus = LG_HANDS_BUSY; - - if (applyRot) - item->pos.yRot ^= ANGLE(180); - } - return; - } - - Lara.interactedItem = itemNum; - return; - } - - if (!item->currentAnimState) - DoorCollision(itemNum, l, coll); -} - -void PushPullKickDoorControl(short itemNumber) -{ - ITEM_INFO* item; - DOOR_DATA* door; - - item = &g_Level.Items[itemNumber]; - door = (DOOR_DATA*)item->data; - - if (!door->opened) - { - OpenThatDoor(&door->d1, door); - OpenThatDoor(&door->d2, door); - OpenThatDoor(&door->d1flip, door); - OpenThatDoor(&door->d2flip, door); - door->opened = true; - } - - AnimateItem(item); -} - -void DoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) -{ - ITEM_INFO* item = &g_Level.Items[itemNum]; - - if (item->triggerFlags == 2 - && item->status == ITEM_NOT_ACTIVE && !item->gravityStatus // CHECK - && ((TrInput & IN_ACTION || -#ifdef NEW_INV - GLOBAL_inventoryitemchosen == ID_CROWBAR_ITEM -#else - g_Inventory.GetSelectedObject() == ID_CROWBAR_ITEM -#endif - ) - && l->currentAnimState == LS_STOP - && l->animNumber == LA_STAND_IDLE - && !l->hitStatus - && Lara.gunStatus == LG_NO_ARMS - || Lara.isMoving && Lara.interactedItem == itemNum)) - { - item->pos.yRot ^= ANGLE(180); - if (TestLaraPosition(&CrowbarDoorBounds, item, l)) - { - if (!Lara.isMoving) - { -#ifdef NEW_INV - if (GLOBAL_inventoryitemchosen == NO_ITEM) -#else - if (g_Inventory.GetSelectedObject() == NO_ITEM) -#endif - { -#ifdef NEW_INV - if (have_i_got_object(ID_CROWBAR_ITEM)) - { - GLOBAL_enterinventory = ID_CROWBAR_ITEM; - item->pos.yRot ^= ANGLE(180); - } -#else - if (g_Inventory.IsObjectPresentInInventory(ID_CROWBAR_ITEM)) - { - g_Inventory.SetEnterObject(ID_CROWBAR_ITEM); - item->pos.yRot ^= ANGLE(180); - } -#endif - 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(); - } - item->pos.yRot ^= ANGLE(180); - } - return; - } -#ifdef NEW_INV - if (GLOBAL_inventoryitemchosen != ID_CROWBAR_ITEM) -#else - if (g_Inventory.GetSelectedObject() != ID_CROWBAR_ITEM) -#endif - { - item->pos.yRot ^= ANGLE(180); - return; - } - } -#ifdef NEW_INV - GLOBAL_inventoryitemchosen = NO_ITEM; -#else - g_Inventory.SetSelectedObject(NO_ITEM); -#endif - if (MoveLaraPosition(&CrowbarDoorPos, item, l)) - { - l->animNumber = LA_DOOR_OPEN_CROWBAR; - l->frameNumber = GF(LA_DOOR_OPEN_CROWBAR, 0); - l->currentAnimState = LS_MISC_CONTROL; - item->pos.yRot ^= ANGLE(180); - - AddActiveItem(itemNum); - - item->flags |= IFLAG_ACTIVATION_MASK; - item->status = ITEM_ACTIVE; - item->goalAnimState = LS_RUN_FORWARD; - Lara.isMoving = 0; - Lara.gunStatus = LG_HANDS_BUSY; - - return; - } - - Lara.interactedItem = itemNum; - } - else if (Lara.isMoving && Lara.interactedItem == itemNum) - { - Lara.isMoving = 0; - Lara.gunStatus = LG_NO_ARMS; - } - - item->pos.yRot ^= ANGLE(180); - } - - if (TestBoundsCollide(item, l, coll->radius)) - { - if (TestCollision(item, l)) - { - if (coll->enableBaddiePush) - { - if (!(item->objectNumber >= ID_LIFT_DOORS1 && item->objectNumber <= ID_LIFT_DOORS2) || item->itemFlags[0]) - { - ItemPushItem(item, l, coll, FALSE, TRUE); - } - } - } - } -} - -void DoorControl(short itemNumber) -{ - ITEM_INFO* item = &g_Level.Items[itemNumber]; - DOOR_DATA* door = (DOOR_DATA*)item->data; - - if (item->triggerFlags == 1) - { - if (item->itemFlags[0]) - { - BOUNDING_BOX* bounds = GetBoundsAccurate(item); - --item->itemFlags[0]; - item->pos.yPos -= TEN::Entities::Switches::COG_DOOR_SPEED; - int y = bounds->Y1 + item->itemFlags[2] - STEP_SIZE; - if (item->pos.yPos < y) - { - item->pos.yPos = y; - item->itemFlags[0] = 0; - } - if (!door->opened) - { - OpenThatDoor(&door->d1, door); - OpenThatDoor(&door->d2, door); - OpenThatDoor(&door->d1flip, door); - OpenThatDoor(&door->d2flip, door); - door->opened = true; - } - } - else - { - if (item->pos.yPos < item->itemFlags[2]) - item->pos.yPos += 2; - if (item->pos.yPos >= item->itemFlags[2]) - { - item->pos.yPos = item->itemFlags[2]; - if (door->opened) - { - ShutThatDoor(&door->d1, door); - ShutThatDoor(&door->d2, door); - ShutThatDoor(&door->d1flip, door); - ShutThatDoor(&door->d2flip, door); - door->opened = false; - } - } - } - } - - if (item->objectNumber < ID_LIFT_DOORS1 || item->objectNumber > ID_LIFT_DOORS2) - { - if (TriggerActive(item)) - { - if (!item->currentAnimState) - { - item->goalAnimState = 1; - AnimateItem(item); - return; - } - if (!door->opened) - { - OpenThatDoor(&door->d1, door); - OpenThatDoor(&door->d2, door); - OpenThatDoor(&door->d1flip, door); - OpenThatDoor(&door->d2flip, door); - door->opened = true; - } - } - else - { - item->status = ITEM_ACTIVE; - - if (item->currentAnimState == 1) - { - item->goalAnimState = 0; - AnimateItem(item); - return; - } - - if (door->opened) - { - ShutThatDoor(&door->d1, door); - ShutThatDoor(&door->d2, door); - ShutThatDoor(&door->d1flip, door); - ShutThatDoor(&door->d2flip, door); - door->opened = false; - } - } - AnimateItem(item); - return; - } - - if (!TriggerActive(item)) - { - if (item->itemFlags[0] >= SECTOR(4)) - { - if (door->opened) - { - ShutThatDoor(&door->d1, door); - ShutThatDoor(&door->d2, door); - ShutThatDoor(&door->d1flip, door); - ShutThatDoor(&door->d2flip, door); - door->opened = false; - } - } - else - { - if (!item->itemFlags[0]) - SoundEffect(SFX_TR5_LIFT_DOORS, &item->pos, 0); - item->itemFlags[0] += STEP_SIZE; - } - } - else - { - if (item->itemFlags[0] > 0) - { - if (item->itemFlags[0] == SECTOR(4)) - SoundEffect(SFX_TR5_LIFT_DOORS, &item->pos, 0); - item->itemFlags[0] -= STEP_SIZE; - } - if (!door->opened) - { - DontUnlockBox = true; - OpenThatDoor(&door->d1, door); - OpenThatDoor(&door->d2, door); - OpenThatDoor(&door->d1flip, door); - OpenThatDoor(&door->d2flip, door); - DontUnlockBox = false; - door->opened = true; - } - } -} - -void OpenThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd) -{ - FLOOR_INFO* floor = doorPos->floor; - - if (floor != NULL) - { - *doorPos->floor = doorPos->data; - - short boxIndex = doorPos->block; - if (boxIndex != NO_BOX) - { - if (!DontUnlockBox) - g_Level.Boxes[boxIndex].flags &= ~BLOCKED; - - for (int i = 0; i < ActiveCreatures.size(); i++) - { - ActiveCreatures[i]->LOT.targetBox = NO_BOX; - } - } - } - - if (dd->dptr1) - { - short n = dd->dn1 < 0 ? -1 : 1; - if (dd->dn1 & 1) - { - dd->dptr1[0] = n; - } - else if (dd->dn1 & 2) - { - dd->dptr1[1] = n; - } - else - { - dd->dptr1[2] = n; - } - - n = dd->dn3 < 0 ? -1 : 1; - if (dd->dn3 & 1) - { - dd->dptr3[0] = n; - } - else if (dd->dn3 & 2) - { - dd->dptr3[1] = n; - } - else - { - dd->dptr3[2] = n; - } - - if (dd->dptr2) - { - n = dd->dn2 < 0 ? -1 : 1; - if (dd->dn2 & 1) - { - dd->dptr2[0] = n; - } - else if (dd->dn2 & 2) - { - dd->dptr2[1] = n; - } - else - { - dd->dptr2[2] = n; - } - } - - if (dd->dptr4) - { - n = dd->dn4 < 0 ? -1 : 1; - if (dd->dn4 & 1) - { - dd->dptr4[0] = n; - } - else if (dd->dn4 & 2) - { - dd->dptr4[1] = n; - } - else - { - dd->dptr4[2] = n; - } - } - } -} - -void ShutThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd) -{ - FLOOR_INFO* floor = doorPos->floor; - - if (floor) - { - floor->box = NO_BOX; - floor->ceiling = -127; - floor->floor = -127; - floor->index = 0; - floor->skyRoom = NO_ROOM; - floor->pitRoom = NO_ROOM; - - short boxIndex = doorPos->block; - if (boxIndex != NO_BOX) - { - g_Level.Boxes[boxIndex].flags |= BLOCKED; - for (int i = 0; i < ActiveCreatures.size(); i++) - { - ActiveCreatures[i]->LOT.targetBox = NO_BOX; - } - } - } - - if (dd->dptr1) - { - dd->dptr1[0] = 0; - dd->dptr1[1] = 0; - dd->dptr1[2] = 0; - - dd->dptr3[0] = 0; - dd->dptr3[1] = 0; - dd->dptr3[2] = 0; - - if (dd->dptr2) - { - dd->dptr2[0] = 0; - dd->dptr2[1] = 0; - dd->dptr2[2] = 0; - } - - if (dd->dptr4) - { - dd->dptr4[0] = 0; - dd->dptr4[1] = 0; - dd->dptr4[2] = 0; - } - } -} - -void InitialiseDoor(short itemNumber) -{ - ITEM_INFO* item = &g_Level.Items[itemNumber]; - - if (item->objectNumber == ID_SEQUENCE_DOOR1) - item->flags &= 0xBFFFu; - - if (item->objectNumber == ID_LIFT_DOORS1 || item->objectNumber == ID_LIFT_DOORS2) - item->itemFlags[0] = 4096; - item->data = DOOR_DATA(); - DOOR_DATA* door = item->data; - - door->opened = false; - door->dptr1 = nullptr; - door->dptr2 = nullptr; - door->dptr3 = nullptr; - door->dptr4 = nullptr; - - int dz, dx; - ROOM_INFO* r; - ROOM_INFO* b; - short boxNumber, twoRoom, roomNumber; - - dz = dx = 0; - - if (item->pos.yRot == 0) - dz--; - else if (item->pos.yRot == -0x8000) - dz++; - else if (item->pos.yRot == 0x4000) - dx--; - else - dx++; - - r = &g_Level.Rooms[item->roomNumber]; - - door->d1.floor = &r->floor[(item->pos.zPos - r->z) / SECTOR(1) + dz + ((item->pos.xPos - r->x) / SECTOR(1) + dx) * r->xSize]; - roomNumber = GetDoor(door->d1.floor); - if (roomNumber == NO_ROOM) - boxNumber = door->d1.floor->box; - else - { - b = &g_Level.Rooms[roomNumber]; - boxNumber = b->floor[(item->pos.zPos - b->z) / SECTOR(1) + dz + ((item->pos.xPos - b->x) / SECTOR(1) + dx) * b->xSize].box; - } - door->d1.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; - door->d1.data = *door->d1.floor; - - if (r->flippedRoom != -1) - { - r = &g_Level.Rooms[r->flippedRoom]; - - door->d1flip.floor = &r->floor[(item->pos.zPos - r->z) / SECTOR(1) + dz + ((item->pos.xPos - r->x) / SECTOR(1) + dx) * r->xSize]; - roomNumber = GetDoor(door->d1flip.floor); - if (roomNumber == NO_ROOM) - boxNumber = door->d1flip.floor->box; - else - { - b = &g_Level.Rooms[roomNumber]; - boxNumber = b->floor[(item->pos.zPos - b->z) / SECTOR(1) + dz + ((item->pos.xPos - b->x) / SECTOR(1) + dx) * b->xSize].box; - } - door->d1flip.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; - - door->d1flip.data = *door->d1flip.floor; - } - else - door->d1flip.floor = NULL; - - twoRoom = GetDoor(door->d1.floor); - - ShutThatDoor(&door->d1, door); - ShutThatDoor(&door->d1flip, door); - - if (twoRoom == NO_ROOM) - { - door->d2.floor = NULL; - door->d2flip.floor = NULL; - } - else - { - r = &g_Level.Rooms[twoRoom]; - - door->d2.floor = &r->floor[(item->pos.zPos - r->z) / SECTOR(1) + (item->pos.xPos - r->x) / SECTOR(1) * r->xSize]; - roomNumber = GetDoor(door->d2.floor); - if (roomNumber == NO_ROOM) - boxNumber = door->d2.floor->box; - else - { - b = &g_Level.Rooms[roomNumber]; - boxNumber = b->floor[(item->pos.zPos - b->z) / SECTOR(1) + (item->pos.xPos - b->x) / SECTOR(1) * b->xSize].box; - } - door->d2.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; - - door->d2.data = *door->d2.floor; - - if (r->flippedRoom != -1) - { - r = &g_Level.Rooms[r->flippedRoom]; - - door->d2flip.floor = &r->floor[(item->pos.zPos - r->z) / SECTOR(1) + (item->pos.xPos - r->x) / SECTOR(1) * r->xSize]; - roomNumber = GetDoor(door->d2flip.floor); - if (roomNumber == NO_ROOM) - boxNumber = door->d2flip.floor->box; - else - { - b = &g_Level.Rooms[roomNumber]; - boxNumber = b->floor[(item->pos.zPos - b->z) / SECTOR(1) + (item->pos.xPos - b->x) / SECTOR(1) * b->xSize].box; - } - door->d2flip.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; - - door->d2flip.data = *door->d2flip.floor; - } - else - door->d2flip.floor = NULL; - - ShutThatDoor(&door->d2, door); - ShutThatDoor(&door->d2flip, door); - - roomNumber = item->roomNumber; - ItemNewRoom(itemNumber, twoRoom); - item->roomNumber = roomNumber; - item->inDrawRoom = true; - } -} - -void InitialiseClosedDoors() -{ - ZeroMemory(ClosedDoors, 32 * sizeof(ITEM_INFO*)); -} - -void FillDoorPointers(DOOR_DATA* doorData, ITEM_INFO* item, short roomNumber, int dz, int dx) -{ - int absX = dx * SECTOR(1) + item->pos.xPos; - int absZ = dz * SECTOR(1) + item->pos.zPos; - - dx *= SECTOR(1); - dz *= SECTOR(1); - - ROOM_INFO* r = &g_Level.Rooms[item->roomNumber]; - GetClosedDoorNormal(r, &doorData->dptr1, &doorData->dn1, dz, dx, absX, absZ); - - if (r->flippedRoom != -1) - GetClosedDoorNormal(&g_Level.Rooms[r->flippedRoom], &doorData->dptr2, &doorData->dn2, dz, dx, absX, absZ); - - r = &g_Level.Rooms[roomNumber]; - GetClosedDoorNormal(r, &doorData->dptr3, &doorData->dn3, dz, dx, absX, absZ); - - if (r->flippedRoom != -1) - GetClosedDoorNormal(&g_Level.Rooms[r->flippedRoom], &doorData->dptr4, &doorData->dn4, dz, dx, absX, absZ); -} - -void GetClosedDoorNormal(ROOM_INFO* room, short** dptr, byte* n, int z, int x, int absX, int absZ) -{ - /**dptr = NULL; - - int halfX = x >> 1; - int halfZ = z >> 1; - - for (int i = 0; i < room->doors.size(); i++) - { - ROOM_DOOR door = room->doors[i]; - - int x1 = halfX + room->x + ((int)door.vertices[0].x + 128) & 0xFFFFFF00; - int x2 = halfX + room->x + ((int)door.vertices[2].x + 128) & 0xFFFFFF00; - - if (x1 > x2) - { - int temp = x1; - x1 = x2; - x2 = temp; - } - - int z1 = halfZ + room->z + ((int)door.vertices[0].z + 128) & 0xFFFFFF00; - int z2 = halfZ + room->z + ((int)door.vertices[2].z + 128) & 0xFFFFFF00; - - if (z1 > z2) - { - int temp = z1; - z1 = z2; - z2 = temp; - } - - if (absX >= x1 && absX <= x2 && absZ >= z1 && absZ <= z2) - { - *dptr = &door[1]; - - if (door[1]) - { - *n = (byte)door[1] & 0x81 | 1; - } - else if (door[2]) - { - *n = (byte)door[2] & 0x82 | 2; - } - else - { - *n = (byte)door[3] & 0x84 | 4; - } - } - }*/ -} - -void ProcessClosedDoors() -{ - /*for (int i = 0; i < 32; i++) - { - ITEM_INFO* item = ClosedDoors[i]; - - if (item == NULL) - break; - - short roomNumber = item->roomNumber; - if (!g_Level.Rooms[roomNumber].boundActive && !g_Level.Rooms[item->drawRoom].boundActive) - continue; - - if (g_Level.Rooms[item->drawRoom].boundActive) - { - if (!(item->inDrawRoom)) - { - ItemNewRoom(item - Items, item->drawRoom); - item->roomNumber = roomNumber; - item->inDrawRoom = true; - } - } - else if (item->inDrawRoom) - { - item->roomNumber = item->drawRoom; - ItemNewRoom(item - Items, roomNumber); - item->inDrawRoom = false; - } - }*/ -} -// keeping these cocmments for now in case they're actually needed? - -void AssignClosedDoor(ITEM_INFO* item) -{ - for (int i = 0; i < 32; i++) - { - if (ClosedDoors[i] == NULL) - { - ClosedDoors[i] = item; - return; - } - } -} - -void InitialiseSteelDoor(short itemNumber) -{ - ITEM_INFO* item = &g_Level.Items[itemNumber]; - - item->meshBits = 1; - item->pos.yPos -= 1024; -} - -void SteelDoorCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll) -{ - ITEM_INFO* item = &g_Level.Items[itemNumber]; - - if (item->itemFlags[0] != 3) - { - if (TestBoundsCollide(item, l, coll->radius)) - { - if (TestCollision(item, l)) - { - if (coll->enableBaddiePush) - ItemPushItem(item, l, coll, 0, 1); - } - } - } -} diff --git a/TR5Main/Game/door.h b/TR5Main/Game/door.h deleted file mode 100644 index e7195d651..000000000 --- a/TR5Main/Game/door.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -struct COLL_INFO; -struct ITEM_INFO; -struct ROOM_INFO; -struct DOORPOS_DATA; -struct DOOR_DATA; - - -void SequenceDoorControl(short itemNumber); -void UnderwaterDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); -void DoubleDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); -void PushPullKickDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); -void PushPullKickDoorControl(short itemNumber); -void DoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); -void DoorControl(short itemNumber); -void OpenThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd); -void ShutThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd); -void InitialiseDoor(short itemNumber); -void InitialiseSteelDoor(short itemNumber); -void SteelDoorCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll); -void AssignClosedDoor(ITEM_INFO* item); -void InitialiseClosedDoors(); -void ProcessClosedDoors(); -void GetClosedDoorNormal(ROOM_INFO* room, short** dptr, byte* n, int z, int x, int absX, int absZ); -void FillDoorPointers(DOOR_DATA* doorData, ITEM_INFO* item, short roomNumber, int dz, int dx); diff --git a/TR5Main/Game/flipeffect.cpp b/TR5Main/Game/flipeffect.cpp index 6dada73cc..d808197f3 100644 --- a/TR5Main/Game/flipeffect.cpp +++ b/TR5Main/Game/flipeffect.cpp @@ -14,7 +14,7 @@ #include "tr5_bats_emitter.h" #include "tr5_spider_emitter.h" #include "tr5_pushableblock.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "puzzles_keys.h" #include "lara_fire.h" #include "effects\effects.h" diff --git a/TR5Main/Game/health.cpp b/TR5Main/Game/health.cpp index 131eed58f..1e18ca638 100644 --- a/TR5Main/Game/health.cpp +++ b/TR5Main/Game/health.cpp @@ -1,7 +1,7 @@ #include "framework.h" #include "health.h" #include "draw.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "lara.h" #include "camera.h" #include "level.h" diff --git a/TR5Main/Game/item.h b/TR5Main/Game/item.h index 69d1a3536..4f3317377 100644 --- a/TR5Main/Game/item.h +++ b/TR5Main/Game/item.h @@ -4,10 +4,9 @@ #include #include "itemdata.h" #include "roomvector.h" + enum GAME_OBJECT_ID : short; - - struct ITEM_INFO { int floor; uint32_t touchBits; diff --git a/TR5Main/Game/memory/malloc.cpp b/TR5Main/Game/memory/malloc.cpp new file mode 100644 index 000000000..313e318cd --- /dev/null +++ b/TR5Main/Game/memory/malloc.cpp @@ -0,0 +1,17 @@ +#include "framework.h" +#include "malloc.h" + +char* malloc_buffer; +int malloc_size; +char* malloc_ptr; +int malloc_free; +int malloc_used; +void init_game_malloc() noexcept +{ +} + +void game_free(void* ptr) noexcept +{ + + delete[] ptr; +} \ No newline at end of file diff --git a/TR5Main/Game/newinv2.cpp b/TR5Main/Game/newinv2.cpp index 8a733245e..75e0ae3dc 100644 --- a/TR5Main/Game/newinv2.cpp +++ b/TR5Main/Game/newinv2.cpp @@ -16,7 +16,7 @@ #include "lara_two_guns.h" #include "level.h" #include "input.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "Renderer11.h" using namespace TEN::Renderer; diff --git a/TR5Main/Game/pickup/pickup.cpp b/TR5Main/Game/pickup/pickup.cpp index 37f4268e6..88588253b 100644 --- a/TR5Main/Game/pickup/pickup.cpp +++ b/TR5Main/Game/pickup/pickup.cpp @@ -1,5 +1,5 @@ #include "framework.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "Specific\phd_global.h" #include "lara.h" #include "draw.h" diff --git a/TR5Main/Game/puzzles_keys.cpp b/TR5Main/Game/puzzles_keys.cpp index dd9f2d856..fae997f2b 100644 --- a/TR5Main/Game/puzzles_keys.cpp +++ b/TR5Main/Game/puzzles_keys.cpp @@ -8,7 +8,7 @@ #include "inventory.h" #endif #include "switch.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "draw.h" #include "control.h" #include "puzzles_keys.h" diff --git a/TR5Main/Game/savegame.cpp b/TR5Main/Game/savegame.cpp index 1aa0d54fb..2aa54dcb8 100644 --- a/TR5Main/Game/savegame.cpp +++ b/TR5Main/Game/savegame.cpp @@ -3,7 +3,7 @@ #include "Lara.h" #include "items.h" #include "box.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "lot.h" #include "switch.h" #include "spotcam.h" diff --git a/TR5Main/Game/switch.cpp b/TR5Main/Game/switch.cpp index c9743e10f..02c1fa617 100644 --- a/TR5Main/Game/switch.cpp +++ b/TR5Main/Game/switch.cpp @@ -1,6 +1,5 @@ #include "framework.h" #include "switch.h" -#include "door.h" #include "items.h" #include "lot.h" #include "objects.h" diff --git a/TR5Main/Objects/Generic/Doors/double_doors.cpp b/TR5Main/Objects/Generic/Doors/double_doors.cpp new file mode 100644 index 000000000..e162bca6a --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/double_doors.cpp @@ -0,0 +1,83 @@ +#include "framework.h" +#include "generic_doors.h" +#include "level.h" +#include "control.h" +#include "box.h" +#include "items.h" +#include "lot.h" +#include "newinv2.h" +#include "input.h" +#include "pickup.h" +#include "sound.h" +#include "draw.h" +#include "sphere.h" +#include "lara_struct.h" +#include "lara.h" +#include "trmath.h" +#include "misc.h" +#include "double_doors.h" +#include "collide.h" + +namespace TEN::Entities::Doors +{ + PHD_VECTOR DoubleDoorPos(0, 0, 220); + + OBJECT_COLLISION_BOUNDS DoubleDoorBounds = + { + -384, 384, + 0, 0, + -1024, 512, + -ANGLE(10), ANGLE(10), + -ANGLE(30), ANGLE(30), + -ANGLE(10), ANGLE(10), + }; + + void DoubleDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) + { + ITEM_INFO* item = &g_Level.Items[itemNum]; + + if (TrInput & IN_ACTION + && l->currentAnimState == LS_STOP + && l->animNumber == LA_STAND_IDLE + && !(item->status && item->gravityStatus) + && !(l->hitStatus) + && !Lara.gunStatus + || Lara.isMoving && Lara.interactedItem == itemNum) + { + item->pos.yRot ^= ANGLE(180); + if (TestLaraPosition(&DoubleDoorBounds, item, l)) + { + if (MoveLaraPosition(&DoubleDoorPos, item, l)) + { + l->animNumber = LA_DOUBLEDOOR_OPEN_PUSH; + l->frameNumber = GF(LA_DOUBLEDOOR_OPEN_PUSH, 0); + l->currentAnimState = LS_DOUBLEDOOR_PUSH; + + AddActiveItem(itemNum); + + item->status = ITEM_ACTIVE; + Lara.isMoving = false; + Lara.gunStatus = LG_HANDS_BUSY; + Lara.headYrot = 0; + Lara.headXrot = 0; + Lara.torsoYrot = 0; + Lara.torsoXrot = 0; + } + else + { + Lara.interactedItem = itemNum; + } + item->pos.yRot ^= ANGLE(180); + } + else + { + if (Lara.isMoving && Lara.interactedItem == itemNum) + { + Lara.isMoving = false; + Lara.gunStatus = LG_NO_ARMS; + } + item->pos.yRot ^= ANGLE(180); + } + } + } +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/double_doors.h b/TR5Main/Objects/Generic/Doors/double_doors.h new file mode 100644 index 000000000..d06fda401 --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/double_doors.h @@ -0,0 +1,9 @@ +#pragma once + +struct ITEM_INFO; +struct COLL_INFO; + +namespace TEN::Entities::Doors +{ + void DoubleDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/generic_doors.cpp b/TR5Main/Objects/Generic/Doors/generic_doors.cpp new file mode 100644 index 000000000..3b7ab3374 --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/generic_doors.cpp @@ -0,0 +1,459 @@ +#include "framework.h" +#include "generic_doors.h" +#include "level.h" +#include "control.h" +#include "box.h" +#include "items.h" +#include "lot.h" +#include "newinv2.h" +#include "input.h" +#include "pickup.h" +#include "sound.h" +#include "draw.h" +#include "sphere.h" +#include "cog_switch.h" +#include "objectslist.h" +#include "lara_struct.h" +#include "lara.h" +#include "trmath.h" +#include "misc.h" +#include "door_data.h" +#include "collide.h" +#include "itemdata/itemdata.h" + +namespace TEN::Entities::Doors +{ + PHD_VECTOR CrowbarDoorPos(-412, 0, 256); + + OBJECT_COLLISION_BOUNDS CrowbarDoorBounds = + { + -512, 512, + -1024, 0, + 0, 512, + -ANGLE(80), ANGLE(80), + -ANGLE(80), ANGLE(80), + -ANGLE(80), ANGLE(80) + }; + + void InitialiseDoor(short itemNumber) + { + ITEM_INFO* item = &g_Level.Items[itemNumber]; + + if (item->objectNumber == ID_SEQUENCE_DOOR1) + item->flags &= 0xBFFFu; + + if (item->objectNumber == ID_LIFT_DOORS1 || item->objectNumber == ID_LIFT_DOORS2) + item->itemFlags[0] = 4096; + + item->data = DOOR_DATA(); + DOOR_DATA* door = item->data; + + door->opened = false; + door->dptr1 = NULL; + door->dptr2 = NULL; + door->dptr3 = NULL; + door->dptr4 = NULL; + + int dz, dx; + ROOM_INFO* r; + ROOM_INFO* b; + short boxNumber, twoRoom, roomNumber; + + dz = dx = 0; + + if (item->pos.yRot == 0) + dz--; + else if (item->pos.yRot == -ANGLE(180)) + dz++; + else if (item->pos.yRot == ANGLE(90)) + dx--; + else + dx++; + + r = &g_Level.Rooms[item->roomNumber]; + + door->d1.floor = &r->floor[(item->pos.zPos - r->z) / SECTOR(1) + dz + ((item->pos.xPos - r->x) / SECTOR(1) + dx) * r->xSize]; + roomNumber = GetDoor(door->d1.floor); + if (roomNumber == NO_ROOM) + boxNumber = door->d1.floor->box; + else + { + b = &g_Level.Rooms[roomNumber]; + boxNumber = b->floor[(item->pos.zPos - b->z) / SECTOR(1) + dz + ((item->pos.xPos - b->x) / SECTOR(1) + dx) * b->xSize].box; + } + door->d1.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; + + memcpy(&door->d1.data, door->d1.floor, sizeof(FLOOR_INFO)); + + if (r->flippedRoom != -1) + { + r = &g_Level.Rooms[r->flippedRoom]; + + door->d1flip.floor = &r->floor[(item->pos.zPos - r->z) / SECTOR(1) + dz + ((item->pos.xPos - r->x) / SECTOR(1) + dx) * r->xSize]; + roomNumber = GetDoor(door->d1flip.floor); + if (roomNumber == NO_ROOM) + boxNumber = door->d1flip.floor->box; + else + { + b = &g_Level.Rooms[roomNumber]; + boxNumber = b->floor[(item->pos.zPos - b->z) / SECTOR(1) + dz + ((item->pos.xPos - b->x) / SECTOR(1) + dx) * b->xSize].box; + } + door->d1flip.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; + + memcpy(&door->d1flip.data, door->d1flip.floor, sizeof(FLOOR_INFO)); + } + else + door->d1flip.floor = NULL; + + twoRoom = GetDoor(door->d1.floor); + + ShutThatDoor(&door->d1, door); + ShutThatDoor(&door->d1flip, door); + + if (twoRoom == NO_ROOM) + { + door->d2.floor = NULL; + door->d2flip.floor = NULL; + } + else + { + r = &g_Level.Rooms[twoRoom]; + + door->d2.floor = &r->floor[(item->pos.zPos - r->z) / SECTOR(1) + (item->pos.xPos - r->x) / SECTOR(1) * r->xSize]; + roomNumber = GetDoor(door->d2.floor); + if (roomNumber == NO_ROOM) + boxNumber = door->d2.floor->box; + else + { + b = &g_Level.Rooms[roomNumber]; + boxNumber = b->floor[(item->pos.zPos - b->z) / SECTOR(1) + (item->pos.xPos - b->x) / SECTOR(1) * b->xSize].box; + } + door->d2.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; + + memcpy(&door->d2.data, door->d2.floor, sizeof(FLOOR_INFO)); + + if (r->flippedRoom != -1) + { + r = &g_Level.Rooms[r->flippedRoom]; + + door->d2flip.floor = &r->floor[(item->pos.zPos - r->z) / SECTOR(1) + (item->pos.xPos - r->x) / SECTOR(1) * r->xSize]; + roomNumber = GetDoor(door->d2flip.floor); + if (roomNumber == NO_ROOM) + boxNumber = door->d2flip.floor->box; + else + { + b = &g_Level.Rooms[roomNumber]; + boxNumber = b->floor[(item->pos.zPos - b->z) / SECTOR(1) + (item->pos.xPos - b->x) / SECTOR(1) * b->xSize].box; + } + door->d2flip.block = (boxNumber != NO_BOX && g_Level.Boxes[boxNumber].flags & BLOCKABLE) ? boxNumber : NO_BOX; + + memcpy(&door->d2flip.data, door->d2flip.floor, sizeof(FLOOR_INFO)); + } + else + door->d2flip.floor = NULL; + + ShutThatDoor(&door->d2, door); + ShutThatDoor(&door->d2flip, door); + + roomNumber = item->roomNumber; + ItemNewRoom(itemNumber, twoRoom); + item->roomNumber = roomNumber; + item->inDrawRoom = true; + } + } + + void DoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) + { + ITEM_INFO* item = &g_Level.Items[itemNum]; + + if (item->triggerFlags == 2 + && item->status == ITEM_NOT_ACTIVE && !item->gravityStatus // CHECK + && ((TrInput & IN_ACTION || +#ifdef NEW_INV + GLOBAL_inventoryitemchosen == ID_CROWBAR_ITEM +#else + g_Inventory.GetSelectedObject() == ID_CROWBAR_ITEM +#endif + ) + && l->currentAnimState == LS_STOP + && l->animNumber == LA_STAND_IDLE + && !l->hitStatus + && Lara.gunStatus == LG_NO_ARMS + || Lara.isMoving && Lara.interactedItem == itemNum)) + { + item->pos.yRot ^= ANGLE(180); + if (TestLaraPosition(&CrowbarDoorBounds, item, l)) + { + if (!Lara.isMoving) + { +#ifdef NEW_INV + if (GLOBAL_inventoryitemchosen == NO_ITEM) +#else + if (g_Inventory.GetSelectedObject() == NO_ITEM) +#endif + { +#ifdef NEW_INV + if (have_i_got_object(ID_CROWBAR_ITEM)) + { + GLOBAL_enterinventory = ID_CROWBAR_ITEM; + item->pos.yRot ^= ANGLE(180); + } +#else + if (g_Inventory.IsObjectPresentInInventory(ID_CROWBAR_ITEM)) + { + g_Inventory.SetEnterObject(ID_CROWBAR_ITEM); + item->pos.yRot ^= ANGLE(180); + } +#endif + 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(); + } + item->pos.yRot ^= ANGLE(180); + } + return; + } +#ifdef NEW_INV + if (GLOBAL_inventoryitemchosen != ID_CROWBAR_ITEM) +#else + if (g_Inventory.GetSelectedObject() != ID_CROWBAR_ITEM) +#endif + { + item->pos.yRot ^= ANGLE(180); + return; + } + } +#ifdef NEW_INV + GLOBAL_inventoryitemchosen = NO_ITEM; +#else + g_Inventory.SetSelectedObject(NO_ITEM); +#endif + if (MoveLaraPosition(&CrowbarDoorPos, item, l)) + { + l->animNumber = LA_DOOR_OPEN_CROWBAR; + l->frameNumber = GF(LA_DOOR_OPEN_CROWBAR, 0); + l->currentAnimState = LS_MISC_CONTROL; + item->pos.yRot ^= ANGLE(180); + + AddActiveItem(itemNum); + + item->flags |= IFLAG_ACTIVATION_MASK; + item->status = ITEM_ACTIVE; + item->goalAnimState = LS_RUN_FORWARD; + Lara.isMoving = 0; + Lara.gunStatus = LG_HANDS_BUSY; + + return; + } + + Lara.interactedItem = itemNum; + } + else if (Lara.isMoving && Lara.interactedItem == itemNum) + { + Lara.isMoving = 0; + Lara.gunStatus = LG_NO_ARMS; + } + + item->pos.yRot ^= ANGLE(180); + } + + if (TestBoundsCollide(item, l, coll->radius)) + { + if (TestCollision(item, l)) + { + if (coll->enableBaddiePush) + { + if (!(item->objectNumber >= ID_LIFT_DOORS1 && item->objectNumber <= ID_LIFT_DOORS2) || item->itemFlags[0]) + { + ItemPushItem(item, l, coll, FALSE, TRUE); + } + } + } + } + } + + void DoorControl(short itemNumber) + { + ITEM_INFO* item = &g_Level.Items[itemNumber]; + DOOR_DATA* door = (DOOR_DATA*)item->data; + + // Doors with OCB = 1 are raisable with cog switchs + if (item->triggerFlags == 1) + { + if (item->itemFlags[0]) + { + BOUNDING_BOX* bounds = GetBoundsAccurate(item); + + item->itemFlags[0]--; + item->pos.yPos -= TEN::Entities::Switches::COG_DOOR_SPEED; + + int y = bounds->Y1 + item->itemFlags[2] - STEP_SIZE; + if (item->pos.yPos < y) + { + item->pos.yPos = y; + item->itemFlags[0] = 0; + } + if (!door->opened) + { + OpenThatDoor(&door->d1, door); + OpenThatDoor(&door->d2, door); + OpenThatDoor(&door->d1flip, door); + OpenThatDoor(&door->d2flip, door); + door->opened = true; + } + } + else + { + if (item->pos.yPos < item->startPos.yPos) + item->pos.yPos += 4; + if (item->pos.yPos >= item->startPos.yPos) + { + item->pos.yPos = item->startPos.yPos; + if (door->opened) + { + ShutThatDoor(&door->d1, door); + ShutThatDoor(&door->d2, door); + ShutThatDoor(&door->d1flip, door); + ShutThatDoor(&door->d2flip, door); + door->opened = false; + } + } + } + + return; + } + + if (item->objectNumber < ID_LIFT_DOORS1 || item->objectNumber > ID_LIFT_DOORS2) + { + if (TriggerActive(item)) + { + if (item->currentAnimState == 0) + { + item->goalAnimState = 1; + } + else if (!door->opened) + { + OpenThatDoor(&door->d1, door); + OpenThatDoor(&door->d2, door); + OpenThatDoor(&door->d1flip, door); + OpenThatDoor(&door->d2flip, door); + door->opened = true; + } + } + else + { + item->status = ITEM_ACTIVE; + + if (item->currentAnimState == 1) + { + item->goalAnimState = 0; + } + else if (door->opened) + { + ShutThatDoor(&door->d1, door); + ShutThatDoor(&door->d2, door); + ShutThatDoor(&door->d1flip, door); + ShutThatDoor(&door->d2flip, door); + door->opened = false; + } + } + } + else + { + // TR5 lift doors + /*if (!TriggerActive(item)) + { + if (item->itemFlags[0] >= SECTOR(4)) + { + if (door->opened) + { + ShutThatDoor(&door->d1, door); + ShutThatDoor(&door->d2, door); + ShutThatDoor(&door->d1flip, door); + ShutThatDoor(&door->d2flip, door); + door->opened = false; + } + } + else + { + if (!item->itemFlags[0]) + SoundEffect(SFX_TR5_LIFT_DOORS, &item->pos, 0); + item->itemFlags[0] += STEP_SIZE; + } + } + else + { + if (item->itemFlags[0] > 0) + { + if (item->itemFlags[0] == SECTOR(4)) + SoundEffect(SFX_TR5_LIFT_DOORS, &item->pos, 0); + item->itemFlags[0] -= STEP_SIZE; + } + if (!door->opened) + { + DontUnlockBox = true; + OpenThatDoor(&door->d1, door); + OpenThatDoor(&door->d2, door); + OpenThatDoor(&door->d1flip, door); + OpenThatDoor(&door->d2flip, door); + DontUnlockBox = false; + door->opened = true; + } + }*/ + } + + AnimateItem(item); + } + + void OpenThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd) + { + FLOOR_INFO* floor = doorPos->floor; + + if (floor != NULL) + { + *doorPos->floor = doorPos->data; + + short boxIndex = doorPos->block; + if (boxIndex != NO_BOX) + { + g_Level.Boxes[boxIndex].flags &= ~BLOCKED; + + for (int i = 0; i < ActiveCreatures.size(); i++) + { + ActiveCreatures[i]->LOT.targetBox = NO_BOX; + } + } + } + } + + void ShutThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd) + { + FLOOR_INFO* floor = doorPos->floor; + + if (floor) + { + floor->box = NO_BOX; + floor->ceiling = -127; + floor->floor = -127; + floor->index = 0; + floor->skyRoom = NO_ROOM; + floor->pitRoom = NO_ROOM; + + short boxIndex = doorPos->block; + if (boxIndex != NO_BOX) + { + g_Level.Boxes[boxIndex].flags |= BLOCKED; + + for (int i = 0; i < ActiveCreatures.size(); i++) + { + ActiveCreatures[i]->LOT.targetBox = NO_BOX; + } + } + } + } +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/generic_doors.h b/TR5Main/Objects/Generic/Doors/generic_doors.h new file mode 100644 index 000000000..43844af78 --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/generic_doors.h @@ -0,0 +1,16 @@ +#pragma once + +struct DOORPOS_DATA; +struct DOOR_DATA; +struct ITEM_INFO; +struct COLL_INFO; +struct FLOOR_INFO; + +namespace TEN::Entities::Doors +{ + void InitialiseDoor(short itemNumber); + void DoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); + void DoorControl(short itemNumber); + void OpenThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd); + void ShutThatDoor(DOORPOS_DATA* doorPos, DOOR_DATA* dd); +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/pushpull_kick_door.cpp b/TR5Main/Objects/Generic/Doors/pushpull_kick_door.cpp new file mode 100644 index 000000000..ee5c0d543 --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/pushpull_kick_door.cpp @@ -0,0 +1,158 @@ +#include "framework.h" +#include "generic_doors.h" +#include "level.h" +#include "control.h" +#include "box.h" +#include "items.h" +#include "lot.h" +#include "newinv2.h" +#include "input.h" +#include "pickup.h" +#include "sound.h" +#include "draw.h" +#include "sphere.h" +#include "lara_struct.h" +#include "lara.h" +#include "trmath.h" +#include "misc.h" +#include "pushpull_kick_door.h" +#include "collide.h" +#include "door_data.h" + +namespace TEN::Entities::Doors +{ + enum STATES_PUSHPULL_KICK_DOOR + { + STATE_PUSHPULL_KICK_DOOR_OPEN = 0, + STATE_PUSHPULL_KICK_DOOR_CLOSED = 1, + STATE_PUSHPULL_KICK_DOOR_PUSH = 2, + STATE_PUSHPULL_KICK_DOOR_PULL = 3 + }; + PHD_VECTOR PullDoorPos(-201, 0, 322); + PHD_VECTOR PushDoorPos(201, 0, -702); + PHD_VECTOR KickDoorPos(0, 0, -917); + + OBJECT_COLLISION_BOUNDS PushPullKickDoorBounds = + { + -384, 384, + 0, 0, + -1024, 512, + -ANGLE(10), ANGLE(10), + -ANGLE(30), ANGLE(30), + -ANGLE(10), ANGLE(10), + }; + + void PushPullKickDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) + { + ITEM_INFO* item = &g_Level.Items[itemNum]; + + if (TrInput & IN_ACTION + && l->currentAnimState == LS_STOP + && l->animNumber == LA_STAND_IDLE + && item->status != ITEM_ACTIVE + && !(l->hitStatus) + && !Lara.gunStatus + || Lara.isMoving && Lara.interactedItem == itemNum) + { + bool pull = false; + + if (l->roomNumber == item->roomNumber) + { + item->pos.yRot ^= ANGLE(180); + pull = true; + } + + if (TestLaraPosition(&PushPullKickDoorBounds, item, l)) + { + bool openTheDoor = false; + + if (pull) + { + if (MoveLaraPosition(&PullDoorPos, item, l)) + { + l->animNumber = LA_DOOR_OPEN_PULL; + l->frameNumber = GF(LA_DOOR_OPEN_PULL, 0); + item->goalAnimState = STATE_PUSHPULL_KICK_DOOR_PULL; + openTheDoor = true; + } + else + { + Lara.interactedItem = itemNum; + } + } + else + { + if (item->objectNumber >= ID_KICK_DOOR1) + { + if (MoveLaraPosition(&KickDoorPos, item, l)) + { + l->animNumber = LA_DOOR_OPEN_KICK; + l->frameNumber = GF(LA_DOOR_OPEN_KICK, 0); + item->goalAnimState = STATE_PUSHPULL_KICK_DOOR_PUSH; + openTheDoor = true; + } + else + { + Lara.interactedItem = itemNum; + } + } + else + { + if (MoveLaraPosition(&PushDoorPos, item, l)) + { + l->animNumber = LA_DOOR_OPEN_PUSH; + l->frameNumber = GF(LA_DOOR_OPEN_PUSH, 0); + item->goalAnimState = STATE_PUSHPULL_KICK_DOOR_PUSH; + openTheDoor = true; + } + else + { + Lara.interactedItem = itemNum; + } + } + } + + if (openTheDoor) + { + AddActiveItem(itemNum); + + item->status = ITEM_ACTIVE; + l->currentAnimState = LS_MISC_CONTROL; + l->goalAnimState = LS_STOP; + Lara.isMoving = false; + Lara.gunStatus = LG_HANDS_BUSY; + } + } + else if (Lara.isMoving && Lara.interactedItem == itemNum) + { + Lara.isMoving = false; + Lara.gunStatus = LG_NO_ARMS; + } + + if (pull) + item->pos.yRot ^= ANGLE(180); + } + else if (item->currentAnimState <= STATE_PUSHPULL_KICK_DOOR_CLOSED) + DoorCollision(itemNum, l, coll); + } + + void PushPullKickDoorControl(short itemNumber) + { + ITEM_INFO* item; + DOOR_DATA* door; + + item = &g_Level.Items[itemNumber]; + door = (DOOR_DATA*)item->data; + + if (!door->opened) + { + OpenThatDoor(&door->d1, door); + OpenThatDoor(&door->d2, door); + OpenThatDoor(&door->d1flip, door); + OpenThatDoor(&door->d2flip, door); + door->opened = true; + } + + AnimateItem(item); + } +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/pushpull_kick_door.h b/TR5Main/Objects/Generic/Doors/pushpull_kick_door.h new file mode 100644 index 000000000..49b66e144 --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/pushpull_kick_door.h @@ -0,0 +1,10 @@ +#pragma once + +struct ITEM_INFO; +struct COLL_INFO; + +namespace TEN::Entities::Doors +{ + void PushPullKickDoorControl(short itemNumber); + void PushPullKickDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/sequence_door.cpp b/TR5Main/Objects/Generic/Doors/sequence_door.cpp new file mode 100644 index 000000000..57bacac12 --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/sequence_door.cpp @@ -0,0 +1,76 @@ +#include "framework.h" +#include "generic_doors.h" +#include "level.h" +#include "control.h" +#include "box.h" +#include "items.h" +#include "lot.h" +#include "newinv2.h" +#include "input.h" +#include "pickup.h" +#include "sound.h" +#include "draw.h" +#include "sphere.h" +#include "lara_struct.h" +#include "lara.h" +#include "trmath.h" +#include "misc.h" +#include "sequence_door.h" +#include "fullblock_switch.h" +#include "door_data.h" + +using namespace TEN::Entities::Switches; + +namespace TEN::Entities::Doors +{ + void SequenceDoorControl(short itemNumber) + { + ITEM_INFO* item = &g_Level.Items[itemNumber]; + DOOR_DATA* door = (DOOR_DATA*)item->data; + + if (CurrentSequence == 3) + { + if (SequenceResults[Sequences[0]][Sequences[1]][Sequences[2]] == item->triggerFlags) + { + if (item->currentAnimState == 1) + item->goalAnimState = 1; + else + item->goalAnimState = 0; + + TestTriggers(item, true, NULL); + } + + CurrentSequence = 4; + } + + if (item->currentAnimState == item->goalAnimState) + { + if (item->currentAnimState == 1) + { + if (!door->opened) + { + OpenThatDoor(&door->d1, door); + OpenThatDoor(&door->d2, door); + OpenThatDoor(&door->d1flip, door); + OpenThatDoor(&door->d2flip, door); + door->opened = true; + item->flags |= 0x3E; + } + } + else + { + if (door->opened) + { + ShutThatDoor(&door->d1, door); + ShutThatDoor(&door->d2, door); + ShutThatDoor(&door->d1flip, door); + ShutThatDoor(&door->d2flip, door); + door->opened = false; + item->flags &= 0xC1; + } + } + } + + AnimateItem(item); + } +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/sequence_door.h b/TR5Main/Objects/Generic/Doors/sequence_door.h new file mode 100644 index 000000000..1a6a7e687 --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/sequence_door.h @@ -0,0 +1,9 @@ +#pragma once + +struct ITEM_INFO; +struct COLL_INFO; + +namespace TEN::Entities::Doors +{ + void SequenceDoorControl(short itemNumber); +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/steel_door.cpp b/TR5Main/Objects/Generic/Doors/steel_door.cpp new file mode 100644 index 000000000..d74014f88 --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/steel_door.cpp @@ -0,0 +1,47 @@ +#include "framework.h" +#include "generic_doors.h" +#include "level.h" +#include "control.h" +#include "box.h" +#include "items.h" +#include "lot.h" +#include "newinv2.h" +#include "input.h" +#include "pickup.h" +#include "sound.h" +#include "draw.h" +#include "sphere.h" +#include "lara_struct.h" +#include "lara.h" +#include "trmath.h" +#include "misc.h" +#include "steel_door.h" +#include "collide.h" + +namespace TEN::Entities::Doors +{ + void InitialiseSteelDoor(short itemNumber) + { + ITEM_INFO* item = &g_Level.Items[itemNumber]; + + item->meshBits = 1; + item->pos.yPos -= 1024; + } + + void SteelDoorCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll) + { + ITEM_INFO* item = &g_Level.Items[itemNumber]; + + if (item->itemFlags[0] != 3) + { + if (TestBoundsCollide(item, l, coll->radius)) + { + if (TestCollision(item, l)) + { + if (coll->enableBaddiePush) + ItemPushItem(item, l, coll, 0, 1); + } + } + } + } +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/steel_door.h b/TR5Main/Objects/Generic/Doors/steel_door.h new file mode 100644 index 000000000..426ac696a --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/steel_door.h @@ -0,0 +1,10 @@ +#pragma once + +struct ITEM_INFO; +struct COLL_INFO; + +namespace TEN::Entities::Doors +{ + void InitialiseSteelDoor(short itemNumber); + void SteelDoorCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll); +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/underwater_door.cpp b/TR5Main/Objects/Generic/Doors/underwater_door.cpp new file mode 100644 index 000000000..c282217c8 --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/underwater_door.cpp @@ -0,0 +1,88 @@ +#include "framework.h" +#include "generic_doors.h" +#include "level.h" +#include "control.h" +#include "box.h" +#include "items.h" +#include "lot.h" +#include "newinv2.h" +#include "input.h" +#include "pickup.h" +#include "sound.h" +#include "draw.h" +#include "sphere.h" +#include "lara_struct.h" +#include "lara.h" +#include "trmath.h" +#include "misc.h" +#include "underwater_door.h" +#include "collide.h" + +namespace TEN::Entities::Doors +{ + PHD_VECTOR UnderwaterDoorPos(-251, -540, -46); + + OBJECT_COLLISION_BOUNDS UnderwaterDoorBounds = + { + -256, 256, + -1024, 0, + -1024, 0, + -ANGLE(80), ANGLE(80), + -ANGLE(80), ANGLE(80), + -ANGLE(80), ANGLE(80) + }; + + void UnderwaterDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) + { + ITEM_INFO* item = &g_Level.Items[itemNum]; + + if (TrInput & IN_ACTION + && l->currentAnimState == LS_UNDERWATER_STOP + && !(item->status && item->gravityStatus) + && Lara.waterStatus == LW_UNDERWATER + && !Lara.gunStatus + || Lara.isMoving && Lara.interactedItem == itemNum) + { + l->pos.yRot ^= ANGLE(180.0f); + + if (TestLaraPosition(&UnderwaterDoorBounds, item, l)) + { + if (MoveLaraPosition(&UnderwaterDoorPos, item, l)) + { + l->animNumber = LA_UNDERWATER_DOOR_OPEN; + l->frameNumber = GF(LA_UNDERWATER_DOOR_OPEN, 0); + l->currentAnimState = LS_MISC_CONTROL; + l->fallspeed = 0; + item->status = ITEM_ACTIVE; + + AddActiveItem(itemNum); + + item->goalAnimState = LS_RUN_FORWARD; + + AnimateItem(item); + + Lara.isMoving = false; + Lara.gunStatus = LG_HANDS_BUSY; + } + else + { + Lara.interactedItem = itemNum; + } + l->pos.yRot ^= ANGLE(180); + } + else + { + if (Lara.isMoving && Lara.interactedItem == itemNum) + { + Lara.isMoving = false; + Lara.gunStatus = LG_NO_ARMS; + } + l->pos.yRot ^= ANGLE(180); + } + } + else if (item->status == ITEM_ACTIVE) + { + ObjectCollision(itemNum, l, coll); + } + } +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Doors/underwater_door.h b/TR5Main/Objects/Generic/Doors/underwater_door.h new file mode 100644 index 000000000..a7bbf2a5a --- /dev/null +++ b/TR5Main/Objects/Generic/Doors/underwater_door.h @@ -0,0 +1,9 @@ +#pragma once + +struct ITEM_INFO; +struct COLL_INFO; + +namespace TEN::Entities::Doors +{ + void UnderwaterDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); +} \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Switches/cog_switch.cpp b/TR5Main/Objects/Generic/Switches/cog_switch.cpp index b116cbd45..dd404846c 100644 --- a/TR5Main/Objects/Generic/Switches/cog_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/cog_switch.cpp @@ -6,6 +6,11 @@ #include "generic_switch.h" #include "door_data.h" #include "Box.h" +#include "generic_doors.h" +#include "collide.h" + +using namespace TEN::Entities::Doors; + namespace TEN::Entities::Switches { OBJECT_COLLISION_BOUNDS CogSwitchBounds = @@ -77,7 +82,6 @@ namespace TEN::Entities::Switches if (!door->opened) { AddActiveItem((target - g_Level.Items.data())); - target->itemFlags[2] = target->pos.yPos; target->status = ITEM_ACTIVE; } } diff --git a/TR5Main/Objects/Generic/Switches/cog_switch.h b/TR5Main/Objects/Generic/Switches/cog_switch.h index 0d4316c1d..078f2a52b 100644 --- a/TR5Main/Objects/Generic/Switches/cog_switch.h +++ b/TR5Main/Objects/Generic/Switches/cog_switch.h @@ -1,7 +1,7 @@ #pragma once -#include "items.h" -#include +struct ITEM_INFO; +struct COLL_INFO; namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/crowbar_switch.cpp b/TR5Main/Objects/Generic/Switches/crowbar_switch.cpp index f27d38c00..5e05ce010 100644 --- a/TR5Main/Objects/Generic/Switches/crowbar_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/crowbar_switch.cpp @@ -1,13 +1,14 @@ #include "framework.h" -#include "jump_switch.h" +#include "generic_switch.h" #include "control.h" #include "input.h" #include "lara.h" #include "crowbar_switch.h" #include "newinv2.h" #include "Sound\sound.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "level.h" +#include "collide.h" namespace TEN::Entities::Switches { @@ -40,94 +41,110 @@ namespace TEN::Entities::Switches int doSwitch = 0; ITEM_INFO* item = &g_Level.Items[itemNum]; - if ((!(TrInput & IN_ACTION) && + if ((((TrInput & IN_ACTION) || #ifdef NEW_INV - GLOBAL_inventoryitemchosen != ID_CROWBAR_ITEM + GLOBAL_inventoryitemchosen == ID_CROWBAR_ITEM) #else - g_Inventory.GetSelectedObject() != ID_CROWBAR_ITEM + g_Inventory.GetSelectedObject() == ID_CROWBAR_ITEM #endif - || l->currentAnimState != LS_STOP - || l->animNumber != LA_STAND_IDLE - || Lara.gunStatus - || item->itemFlags[0]) - && (!Lara.isMoving || Lara.interactedItem !=itemNum)) + && l->currentAnimState == LS_STOP + && l->animNumber == LA_STAND_IDLE + && Lara.gunStatus == LG_NO_ARMS + && item->itemFlags[0] == 0) + || (Lara.isMoving && Lara.interactedItem == itemNum)) { - ObjectCollision(itemNum, l, coll); - return; - } - - if (item->currentAnimState) - { - if (item->currentAnimState != 1) + if (item->currentAnimState == SWITCH_ON) { - ObjectCollision(itemNum, l, coll); - return; - } + l->pos.yRot ^= (short)ANGLE(180); - l->pos.yRot ^= (short)ANGLE(180); - if (TestLaraPosition(&CrowbarBounds2, item, l)) - { - if (Lara.isMoving || -#ifdef NEW_INV - GLOBAL_inventoryitemchosen == ID_CROWBAR_ITEM -#else - g_Inventory.GetSelectedObject() == ID_CROWBAR_ITEM -#endif - ) + if (TestLaraPosition(&CrowbarBounds2, item, l)) { - if (MoveLaraPosition(&CrowbarPos2, item, l)) + if (Lara.isMoving || +#ifdef NEW_INV + GLOBAL_inventoryitemchosen == ID_CROWBAR_ITEM +#else + g_Inventory.GetSelectedObject() == ID_CROWBAR_ITEM +#endif + ) { - l->animNumber = LA_CROWBAR_USE_ON_FLOOR; - doSwitch = 1; - l->frameNumber = g_Level.Anims[l->animNumber].frameBase; - item->goalAnimState = 0; + if (MoveLaraPosition(&CrowbarPos2, item, l)) + { + doSwitch = 1; + l->animNumber = LA_CROWBAR_USE_ON_FLOOR; + l->frameNumber = g_Level.Anims[l->animNumber].frameBase; + item->goalAnimState = SWITCH_OFF; + } + else + { + Lara.interactedItem = itemNum; + } +#ifdef NEW_INV + GLOBAL_inventoryitemchosen = NO_ITEM; +#else + g_Inventory.SetSelectedObject(NO_ITEM); +#endif } else { - Lara.interactedItem = itemNum; + doSwitch = -1; } -#ifdef NEW_INV - GLOBAL_inventoryitemchosen = NO_ITEM; -#else - g_Inventory.SetSelectedObject(NO_ITEM); -#endif } - else - { - doSwitch = -1; - } - } - else if (Lara.isMoving && Lara.interactedItem == itemNum) - { - Lara.isMoving = false; - Lara.gunStatus = LG_NO_ARMS; - } - l->pos.yRot ^= (short)ANGLE(180); - } - else - { - if (!TestLaraPosition(&CrowbarBounds, item, l)) - { - if (Lara.isMoving && Lara.interactedItem == itemNum) + else if (Lara.isMoving && Lara.interactedItem == itemNum) { Lara.isMoving = false; Lara.gunStatus = LG_NO_ARMS; } - ObjectCollision(itemNum, l, coll); - return; + l->pos.yRot ^= (short)ANGLE(180); } - - if (!(Lara.isMoving && + else + { + if (TestLaraPosition(&CrowbarBounds, item, l)) + { + if (Lara.isMoving || #ifdef NEW_INV - GLOBAL_inventoryitemchosen != ID_CROWBAR_ITEM) + GLOBAL_inventoryitemchosen == ID_CROWBAR_ITEM #else - g_Inventory.GetSelectedObject() != ID_CROWBAR_ITEM) + g_Inventory.GetSelectedObject() == ID_CROWBAR_ITEM #endif - ) + ) + { + if (MoveLaraPosition(&CrowbarPos, item, l)) + { + doSwitch = 1; + l->animNumber = LA_CROWBAR_USE_ON_FLOOR; + l->frameNumber = g_Level.Anims[l->animNumber].frameBase; + item->goalAnimState = SWITCH_ON; + } + else + { + Lara.interactedItem = itemNum; + } +#ifdef NEW_INV + GLOBAL_inventoryitemchosen = NO_ITEM; +#else + g_Inventory.SetSelectedObject(NO_ITEM); +#endif + } + else + { + doSwitch = -1; + } + } + else if (Lara.isMoving && Lara.interactedItem == itemNum) + { + Lara.isMoving = false; + Lara.gunStatus = LG_NO_ARMS; + } + } + } + + if (doSwitch) + { + if (doSwitch == -1) { if (Lara.Crowbar) #ifdef NEW_INV - GLOBAL_inventoryitemchosen = ID_CROWBAR_ITEM; + GLOBAL_enterinventory = ID_CROWBAR_ITEM; #else g_Inventory.SetEnterObject(ID_CROWBAR_ITEM); #endif @@ -141,67 +158,26 @@ namespace TEN::Entities::Switches SayNo(); } } - return; - } - - if (MoveLaraPosition(&CrowbarPos, item, l)) - { - l->animNumber = LA_CROWBAR_USE_ON_FLOOR; - doSwitch = 1; - l->frameNumber = g_Level.Anims[l->animNumber].frameBase; - item->goalAnimState = 1; } else { - Lara.interactedItem = itemNum; + l->goalAnimState = LS_SWITCH_DOWN; + l->currentAnimState = LS_SWITCH_DOWN; + 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); } -#ifdef NEW_INV - GLOBAL_inventoryitemchosen = NO_ITEM; -#else - g_Inventory.SetSelectedObject(NO_ITEM); -#endif } - - if (!doSwitch) - { - ObjectCollision(itemNum, l, coll); - return; - } - - if (doSwitch != -1) - { - l->goalAnimState = LS_SWITCH_DOWN; - l->currentAnimState = LS_SWITCH_DOWN; - 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; - } - - if (Lara.Crowbar) -#ifdef NEW_INV - GLOBAL_enterinventory = ID_CROWBAR_ITEM; -#else - g_Inventory.SetEnterObject(ID_CROWBAR_ITEM); -#endif 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(); - } + ObjectCollision(itemNum, l, coll); } } - } \ No newline at end of file diff --git a/TR5Main/Objects/Generic/Switches/crowbar_switch.h b/TR5Main/Objects/Generic/Switches/crowbar_switch.h index 2fdfd48e4..7bd94c7b0 100644 --- a/TR5Main/Objects/Generic/Switches/crowbar_switch.h +++ b/TR5Main/Objects/Generic/Switches/crowbar_switch.h @@ -1,7 +1,7 @@ #pragma once -#include "items.h" -#include +struct ITEM_INFO; +struct COLL_INFO; namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/fullblock_switch.cpp b/TR5Main/Objects/Generic/Switches/fullblock_switch.cpp index fdd0ef9d5..e5a7ba2be 100644 --- a/TR5Main/Objects/Generic/Switches/fullblock_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/fullblock_switch.cpp @@ -7,6 +7,7 @@ #include "setup.h" #include "collide.h" #include "level.h" + namespace TEN::Entities::Switches { OBJECT_COLLISION_BOUNDS FullBlockSwitchBounds = diff --git a/TR5Main/Objects/Generic/Switches/generic_switch.cpp b/TR5Main/Objects/Generic/Switches/generic_switch.cpp index 31a4fa0ab..b3477b104 100644 --- a/TR5Main/Objects/Generic/Switches/generic_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/generic_switch.cpp @@ -7,6 +7,7 @@ #include "draw.h" #include "collide.h" #include "floordata.h" + namespace TEN::Entities::Switches { OBJECT_COLLISION_BOUNDS SwitchBounds = @@ -106,43 +107,6 @@ namespace TEN::Entities::Switches } item->goalAnimState = SWITCH_OFF; - - // NOTE: TR5 OCBs, to evaluate if keep them - /*if (item->triggerFlags) - { - if (item->triggerFlags >= 3) - { - if (item->triggerFlags == 4) - { - l->currentAnimState = LS_SWITCH_UP; - l->animNumber = LA_SWITCH_SMALL_DOWN; - item->goalAnimState = SWITCH_OFF; - } - else - { - if (item->triggerFlags >= 5 && item->triggerFlags <= 7) - { - if (item->triggerFlags == 6) - DisableLaraControl = true; - l->currentAnimState = LS_SWITCH_DOWN; - l->animNumber = LA_BUTTON_SMALL_PUSH; - } - item->goalAnimState = SWITCH_OFF; - } - } - else - { - l->animNumber = LA_HOLESWITCH_ACTIVATE; - l->currentAnimState = LS_HOLE; - item->goalAnimState = SWITCH_OFF; - } - } - else - { - l->currentAnimState = LS_SWITCH_UP; - l->animNumber = LA_WALLSWITCH_DOWN; - item->goalAnimState = SWITCH_OFF; - }*/ } else /* Switch up */ { @@ -165,38 +129,6 @@ namespace TEN::Entities::Switches } item->goalAnimState = SWITCH_ON; - - // NOTE: TR5 OCBs, to evaluate if keep them - /*if (item->triggerFlags) - { - if (item->triggerFlags == 3) - { - l->currentAnimState = LS_SWITCH_DOWN; - l->animNumber = LA_BUTTON_LARGE_PUSH; - } - else if (item->triggerFlags == 4) - { - l->currentAnimState = LS_SWITCH_DOWN; - l->animNumber = LA_SWITCH_SMALL_UP; - } - else if (item->triggerFlags < 8) - { - l->currentAnimState = LS_HOLE; - l->animNumber = LA_HOLESWITCH_ACTIVATE; - } - else - { - l->currentAnimState = LS_SWITCH_DOWN; - l->animNumber = LA_VALVE_TURN; - } - } - else - { - l->currentAnimState = LS_SWITCH_DOWN; - l->animNumber = LA_WALLSWITCH_UP; - } - - item->goalAnimState = SWITCH_ON;*/ } l->frameNumber = g_Level.Anims[l->animNumber].frameBase; diff --git a/TR5Main/Objects/Generic/Switches/generic_switch.h b/TR5Main/Objects/Generic/Switches/generic_switch.h index c68696d92..365058c6c 100644 --- a/TR5Main/Objects/Generic/Switches/generic_switch.h +++ b/TR5Main/Objects/Generic/Switches/generic_switch.h @@ -1,8 +1,8 @@ #pragma once - struct ITEM_INFO; struct COLL_INFO; + namespace TEN::Entities::Switches { enum SwitchStatus diff --git a/TR5Main/Objects/Generic/Switches/jump_switch.cpp b/TR5Main/Objects/Generic/Switches/jump_switch.cpp index 9e5e8fefe..eb0e6302a 100644 --- a/TR5Main/Objects/Generic/Switches/jump_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/jump_switch.cpp @@ -5,6 +5,7 @@ #include "lara.h" #include "generic_switch.h" #include "level.h" +#include "collide.h" namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/jump_switch.h b/TR5Main/Objects/Generic/Switches/jump_switch.h index 5169758a2..46a9a2fcd 100644 --- a/TR5Main/Objects/Generic/Switches/jump_switch.h +++ b/TR5Main/Objects/Generic/Switches/jump_switch.h @@ -1,7 +1,7 @@ #pragma once -#include "items.h" -#include +struct ITEM_INFO; +struct COLL_INFO; namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/pulley_switch.cpp b/TR5Main/Objects/Generic/Switches/pulley_switch.cpp index e9b2c42bd..4b29e173e 100644 --- a/TR5Main/Objects/Generic/Switches/pulley_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/pulley_switch.cpp @@ -5,8 +5,9 @@ #include "lara.h" #include "generic_switch.h" #include "Sound\sound.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "level.h" +#include "collide.h" namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/pulley_switch.h b/TR5Main/Objects/Generic/Switches/pulley_switch.h index 9fc7fa849..410a33714 100644 --- a/TR5Main/Objects/Generic/Switches/pulley_switch.h +++ b/TR5Main/Objects/Generic/Switches/pulley_switch.h @@ -1,7 +1,7 @@ #pragma once -#include "items.h" -#include +struct ITEM_INFO; +struct COLL_INFO; namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/rail_switch.cpp b/TR5Main/Objects/Generic/Switches/rail_switch.cpp index 43cd81846..dbc6592a6 100644 --- a/TR5Main/Objects/Generic/Switches/rail_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/rail_switch.cpp @@ -5,6 +5,7 @@ #include "lara.h" #include "generic_switch.h" #include "level.h" +#include "collide.h" namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/rail_switch.h b/TR5Main/Objects/Generic/Switches/rail_switch.h index 6a2c3f4b3..ca5bb81ae 100644 --- a/TR5Main/Objects/Generic/Switches/rail_switch.h +++ b/TR5Main/Objects/Generic/Switches/rail_switch.h @@ -1,7 +1,7 @@ #pragma once -#include "items.h" -#include +struct ITEM_INFO; +struct COLL_INFO; namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/turn_switch.cpp b/TR5Main/Objects/Generic/Switches/turn_switch.cpp index 3ff1d28ce..2bda4e355 100644 --- a/TR5Main/Objects/Generic/Switches/turn_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/turn_switch.cpp @@ -4,12 +4,12 @@ #include "input.h" #include "lara.h" #include "generic_switch.h" -#include "door.h" -#include "Sound\sound.h" +#include "sound.h" #include "switch.h" #include "setup.h" #include "camera.h" #include "level.h" +#include "collide.h" namespace TEN::Entities::Switches { @@ -47,17 +47,16 @@ namespace TEN::Entities::Switches void TurnSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) { ITEM_INFO* item = &g_Level.Items[itemNum]; - int flag = 0; + int doSwitch = 0; - if (item->currentAnimState + if (item->currentAnimState == TURN_SWITCH_STOP && TrInput & IN_ACTION && l->currentAnimState == LS_STOP && l->animNumber == LA_STAND_IDLE - && !l->gravityStatus + && l->gravityStatus == false && Lara.gunStatus == LG_NO_ARMS || Lara.isMoving && Lara.interactedItem == itemNum) { - short ItemNos[8]; if (TestLaraPosition(&TurnSwitchBoundsA, item, l)) { if (MoveLaraPosition(&TurnSwitchPosA, item, l)) @@ -66,38 +65,16 @@ namespace TEN::Entities::Switches l->frameNumber = g_Level.Anims[LA_TURNSWITCH_GRAB_COUNTER_CLOCKWISE].frameBase; item->animNumber = Objects[item->objectNumber].animIndex + 4; item->frameNumber = g_Level.Anims[item->animNumber].frameBase; - item->itemFlags[0] = 1; + item->itemFlags[0] = TURN_SWITCH_ANTICLOCKWISE; ForcedFixedCamera.x = item->pos.xPos - 1024 * phd_sin(item->pos.yRot); ForcedFixedCamera.z = item->pos.zPos - 1024 * phd_cos(item->pos.yRot); - - Lara.isMoving = false; - Lara.headYrot = 0; - Lara.headXrot = 0; - Lara.torsoYrot = 0; - Lara.torsoXrot = 0; - Lara.gunStatus = LG_HANDS_BUSY; - l->currentAnimState = LA_REACH; - 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)) - { - if (!TriggerActive(&g_Level.Items[ItemNos[0]])) - { - 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; - } - } - return; + doSwitch = -1; + } + else + { + Lara.interactedItem = itemNum; } - Lara.interactedItem = itemNum; } else { @@ -106,12 +83,12 @@ namespace TEN::Entities::Switches { if (MoveLaraPosition(&TurnSwitchPos, item, l)) { - l->animNumber = 319; - flag = 1; - l->frameNumber = g_Level.Anims[319].frameBase; - item->itemFlags[0] = 2; + l->animNumber = LA_TURNSWITCH_GRAB_CLOCKWISE; + l->frameNumber = g_Level.Anims[l->animNumber].frameBase; + item->itemFlags[0] = TURN_SWITCH_CLOCKWISE; ForcedFixedCamera.x = item->pos.xPos + 1024 * phd_sin(item->pos.yRot); ForcedFixedCamera.z = item->pos.zPos + 1024 * phd_cos(item->pos.yRot); + doSwitch = 1; } else { @@ -124,51 +101,59 @@ namespace TEN::Entities::Switches Lara.gunStatus = LG_NO_ARMS; } l->pos.yRot ^= (short)ANGLE(180); - if (flag) - { - Lara.isMoving = 0; - Lara.headYrot = 0; - Lara.headXrot = 0; - Lara.torsoYrot = 0; - Lara.torsoXrot = 0; - Lara.gunStatus = LG_HANDS_BUSY; - l->currentAnimState = LA_REACH; - 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)) - { - if (!TriggerActive(&g_Level.Items[ItemNos[0]])) - { - 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; - } - } - return; - } } } - if (coll->enableBaddiePush && TestBoundsCollide(item, l, coll->radius)) + if (doSwitch) { - GlobalCollisionBounds.X1 = -512; - GlobalCollisionBounds.X2 = 512; - GlobalCollisionBounds.Y1 = -512; - GlobalCollisionBounds.Y2 = 0; - GlobalCollisionBounds.Z1 = -512; - GlobalCollisionBounds.Z2 = 512; + short ItemNos[8]; - ItemPushItem(item, l, coll, 0, 2); + Lara.isMoving = false; + Lara.headYrot = 0; + Lara.headXrot = 0; + Lara.torsoYrot = 0; + Lara.torsoXrot = 0; + Lara.gunStatus = LG_HANDS_BUSY; + l->currentAnimState = LA_REACH; - GlobalCollisionBounds.X1 = 256; - GlobalCollisionBounds.X2 = 1024; - GlobalCollisionBounds.Z1 = -128; - GlobalCollisionBounds.Z2 = 128; + UseForcedFixedCamera = true; + ForcedFixedCamera.y = item->pos.yPos - 2048; + ForcedFixedCamera.roomNumber = item->roomNumber; - ItemPushItem(item, l, coll, 0, 2); + AddActiveItem(itemNum); + + item->status = ITEM_ACTIVE; + item->itemFlags[1] = 0; + + if (GetSwitchTrigger(item, ItemNos, 0)) + { + if (!TriggerActive(&g_Level.Items[ItemNos[0]])) + { + 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; + } + } + } + else + { + 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; + + ItemPushItem(item, l, coll, 0, 2); + + GlobalCollisionBounds.X1 = 256; + GlobalCollisionBounds.X2 = 1024; + GlobalCollisionBounds.Z1 = -128; + GlobalCollisionBounds.Z2 = 128; + + ItemPushItem(item, l, coll, 0, 2); + } } } diff --git a/TR5Main/Objects/Generic/Switches/turn_switch.h b/TR5Main/Objects/Generic/Switches/turn_switch.h index 33dccbb5d..a6d84e616 100644 --- a/TR5Main/Objects/Generic/Switches/turn_switch.h +++ b/TR5Main/Objects/Generic/Switches/turn_switch.h @@ -1,7 +1,7 @@ #pragma once -#include "items.h" -#include +struct ITEM_INFO; +struct COLL_INFO; namespace TEN::Entities::Switches { diff --git a/TR5Main/Objects/Generic/Switches/underwater_switch.cpp b/TR5Main/Objects/Generic/Switches/underwater_switch.cpp index 9e246db4e..3a543a237 100644 --- a/TR5Main/Objects/Generic/Switches/underwater_switch.cpp +++ b/TR5Main/Objects/Generic/Switches/underwater_switch.cpp @@ -52,6 +52,20 @@ namespace TEN::Entities::Switches { ITEM_INFO* item = &g_Level.Items[itemNum]; + if (item->triggerFlags == 0) + { + WallUnderwaterSwitchCollision(itemNum, l, coll); + } + else + { + CeilingUnderwaterSwitchCollision(itemNum, l, coll); + } + } + + void WallUnderwaterSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) + { + ITEM_INFO* item = &g_Level.Items[itemNum]; + if (TrInput & IN_ACTION) { if (item->status == ITEM_NOT_ACTIVE diff --git a/TR5Main/Objects/Generic/Switches/underwater_switch.h b/TR5Main/Objects/Generic/Switches/underwater_switch.h index b76afcde5..4ebf47fe0 100644 --- a/TR5Main/Objects/Generic/Switches/underwater_switch.h +++ b/TR5Main/Objects/Generic/Switches/underwater_switch.h @@ -1,10 +1,11 @@ #pragma once -#include "items.h" -#include +struct ITEM_INFO; +struct COLL_INFO; namespace TEN::Entities::Switches { void UnderwaterSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); void CeilingUnderwaterSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); + void WallUnderwaterSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); } \ No newline at end of file diff --git a/TR5Main/Objects/Generic/generic_objects.cpp b/TR5Main/Objects/Generic/generic_objects.cpp index c6cc0ef97..f4eb29e89 100644 --- a/TR5Main/Objects/Generic/generic_objects.cpp +++ b/TR5Main/Objects/Generic/generic_objects.cpp @@ -14,11 +14,21 @@ #include "underwater_switch.h" #include "pulley_switch.h" #include "fullblock_switch.h" +#include "turn_switch.h" + +// Doors +#include "generic_doors.h" +#include "double_doors.h" +#include "pushpull_kick_door.h" +#include "sequence_door.h" +#include "steel_door.h" +#include "underwater_door.h" /// necessary import #include "setup.h" using namespace TEN::Entities::Switches; +using namespace TEN::Entities::Doors; static void StartObject() { @@ -231,7 +241,7 @@ void StartSwitches() if (obj->loaded) { obj->control = SwitchControl; - obj->collision = objNum < ID_UNDERWATER_SWITCH3 ? UnderwaterSwitchCollision : CeilingUnderwaterSwitchCollision; + obj->collision = UnderwaterSwitchCollision; obj->saveFlags = true; obj->saveAnim = true; } @@ -247,6 +257,15 @@ void StartSwitches() obj->saveAnim = true; } + obj = &Objects[ID_TURN_SWITCH]; + if (obj->loaded) + { + obj->control = TurnSwitchControl; + obj->collision = TurnSwitchCollision; + obj->saveFlags = true; + obj->saveAnim = true; + } + obj = &Objects[ID_SEQUENCE_SWITCH1]; if (obj->loaded) { @@ -275,8 +294,111 @@ void StartSwitches() } } +void StartDoors() +{ + OBJECT_INFO* obj; + + for (int objNum = ID_DOOR_TYPE1; objNum <= ID_CLOSED_DOOR6; objNum++) + { + obj = &Objects[objNum]; + if (obj->loaded) + { + obj->initialise = InitialiseDoor; + obj->control = DoorControl; + obj->collision = DoorCollision; + obj->hitEffect = HIT_RICOCHET; + obj->saveAnim = true; + obj->saveFlags = true; + obj->saveMesh = true; + } + } + + obj = &Objects[ID_LIFT_DOORS1]; + if (obj->loaded) + { + obj->initialise = InitialiseDoor; + obj->control = DoorControl; + obj->hitEffect = HIT_RICOCHET; + obj->saveFlags = true; + } + + obj = &Objects[ID_LIFT_DOORS2]; + if (obj->loaded) + { + obj->initialise = InitialiseDoor; + obj->control = DoorControl; + obj->hitEffect = HIT_RICOCHET; + obj->saveFlags = true; + } + + obj = &Objects[ID_SEQUENCE_DOOR1]; + if (obj->loaded) + { + obj->initialise = InitialiseDoor; + obj->collision = DoorCollision; + obj->control = SequenceDoorControl; + obj->hitEffect = HIT_RICOCHET; + obj->saveAnim = true; + obj->saveFlags = true; + } + + for (int i = ID_DOUBLE_DOORS1; i <= ID_DOUBLE_DOORS4; i++) + { + obj = &Objects[i]; + if (obj->loaded) + { + obj->initialise = InitialiseDoor; + obj->collision = DoubleDoorCollision; + obj->control = PushPullKickDoorControl; + obj->hitEffect = HIT_RICOCHET; + obj->saveAnim = true; + obj->saveFlags = true; + } + } + + for (int i = ID_UNDERWATER_DOOR1; i <= ID_UNDERWATER_DOOR4; i++) + { + obj = &Objects[i]; + if (obj->loaded) + { + obj->initialise = InitialiseDoor; + obj->collision = UnderwaterDoorCollision; + obj->control = PushPullKickDoorControl; + obj->hitEffect = HIT_RICOCHET; + obj->saveAnim = true; + obj->saveFlags = true; + } + } + + for (int objNum = ID_PUSHPULL_DOOR1; objNum <= ID_KICK_DOOR4; objNum++) + { + obj = &Objects[objNum]; + if (obj->loaded) + { + obj->initialise = InitialiseDoor; + obj->collision = PushPullKickDoorCollision; + obj->control = PushPullKickDoorControl; + obj->hitEffect = HIT_RICOCHET; + obj->saveAnim = true; + obj->saveFlags = true; + } + } + + obj = &Objects[ID_STEEL_DOOR]; + if (obj->loaded) + { + obj->initialise = InitialiseSteelDoor; + obj->collision = SteelDoorCollision; + obj->saveAnim = true; + obj->saveFlags = true; + obj->saveMesh = true; + obj->savePosition = true; + } +} + void InitialiseGenericObjects() { StartObject(); StartSwitches(); + StartDoors(); } diff --git a/TR5Main/Objects/TR4/Object/tr4_obelisk.cpp b/TR5Main/Objects/TR4/Object/tr4_obelisk.cpp index 628e113a0..e579bfe9f 100644 --- a/TR5Main/Objects/TR4/Object/tr4_obelisk.cpp +++ b/TR5Main/Objects/TR4/Object/tr4_obelisk.cpp @@ -9,6 +9,7 @@ #include "effects\effects.h" #include "items.h" #include "effects\tomb4fx.h" +#include "input.h" void InitialiseObelisk(short itemNumber) { @@ -39,11 +40,10 @@ void InitialiseObelisk(short itemNumber) void ObeliskControl(short itemNumber) { - return;//unfinished - ITEM_INFO* item; - short number; - - item = &g_Level.Items[itemNumber]; + ITEM_INFO* item = &g_Level.Items[itemNumber]; + short someNumber; + PHD_3DPOS pos; + PHD_3DPOS pos2; if (TriggerActive(item)) { @@ -52,123 +52,169 @@ void ObeliskControl(short itemNumber) item->itemFlags[3]++; - if ((GlobalCounter & 1) || (item->itemFlags[3] < 256 && !(GetRandomControl() & 1))) + byte r = (GetRandomControl() & 0x1F) + 224; + byte g = r - (GetRandomControl() & 0x1F) - 32; + byte b = g - (GetRandomControl() & 0x1F) - 128; + + if (!(GlobalCounter & 1)) { - - if (!(GlobalCounter & 1)) - number = 0x2000; - wtf: - if (item->itemFlags[3] >= 256 && item->triggerFlags == 2) + someNumber = 8192; + if (GetRandomControl() & 1) { - PHD_3DPOS pos; - PHD_3DPOS pos2; - int m = phd_sin(item->pos.yRot + 0x4000); - - pos.xPos = item->pos.xPos + (m << 15);//check cos and sin - pos.yPos = item->pos.yPos; - m = phd_cos(item->pos.yRot + 0x4000); - pos.zPos = item->pos.zPos + (m << 15); - SoundEffect(197, &pos, 0); - - if ((GlobalCounter & 1) != 0) + if (item->itemFlags[3] < 256 + && (GetRandomControl() & 1) + && !(GlobalCounter & 3)) { - pos2.xPos = (GetRandomControl() & 0x3FF) + pos.xPos - 512; - pos2.yPos = (GetRandomControl() & 0x3FF) + pos.yPos - 512; - pos2.zPos = (GetRandomControl() & 0x3FF) + pos.zPos - 512; - - if (abs(pos.xPos - LaraItem->pos.xPos) < 0x5000) - { - if (abs(pos.yPos - LaraItem->pos.yPos) < 0x5000) - { - if (abs(pos.zPos - LaraItem->pos.zPos) < 0x5000 - && abs(pos2.xPos - LaraItem->pos.xPos) < 0x5000 - && abs(pos2.yPos - LaraItem->pos.yPos) < 0x5000 - && abs(pos2.zPos - LaraItem->pos.zPos) < 0x5000) - { - if (item->itemFlags[2] != NO_ITEM) - { - ITEM_INFO* item2 = &g_Level.Items[item->itemFlags[2]]; - ExplodeItemNode(item2, 0, 0, 128); - KillItem(item->itemFlags[2]); - TriggerExplosionSparks(pos.xPos, pos.yPos, pos.zPos, 3, -2, 0, item2->roomNumber); - TriggerExplosionSparks(pos.xPos, pos.yPos, pos.zPos, 3, -1, 0, item2->roomNumber); - item->itemFlags[2] = NO_ITEM; - item2 = find_a_fucking_item(ID_PUZZLE_ITEM1_COMBO1); - item2->status = ITEM_NOT_ACTIVE; - SoundEffect(105, &item2->pos, 0); - SoundEffect(106, &item2->pos, 0); - } - - int r = (GetRandomControl() & 0x1F) + 224; - int b = (GetRandomControl() & 0x1F) + 192;//this feels wrong :) - int g = (GetRandomControl() & 0x1F) + 64; - int clr = (g | ((b | (r << 8)) << 8)) | 0x18000000; - TriggerLightning((PHD_VECTOR*)&pos, (PHD_VECTOR*)&pos2, (GetRandomControl() & 0xF) + 16, r, g, b, 3, 3, 24, 3); - TriggerLightningGlow(pos.xPos, pos.yPos, pos.zPos, 0x100, r | 0x4000, g, b); - } - } - } + SoundEffect(SFX_TR4_ELEC_ONE_SHOT, &item->pos, 0); + someNumber = (GetRandomControl() & 0xFFF) + 3456; } - } - return; - } + pos.xPos = item->pos.xPos + (3456 * phd_sin(item->pos.yRot + ANGLE(90))); + pos.yPos = item->pos.yPos - 256; + pos.zPos = item->pos.zPos + (3456 * phd_cos(item->pos.yRot + ANGLE(90))); - if (item->itemFlags[3] < 256 && !(GlobalCounter & 3)) - { - SoundEffect(198, &item->pos, 0); - number = (GetRandomControl() & 0xFFF) + 3456; - } + pos2.xPos = item->pos.xPos + (someNumber * phd_sin(item->pos.yRot + ANGLE(90))); + pos2.yPos = item->pos.yPos; + pos2.xPos = item->pos.zPos + (someNumber * phd_cos(item->pos.zRot + ANGLE(90))); - PHD_3DPOS* pos; - PHD_3DPOS* pos2; - - pos->xPos = item->pos.xPos + (3456 * phd_sin(item->pos.yRot + 0x4000)); - pos->yPos = item->pos.yPos - 256; - pos->zPos = item->pos.zPos + (3456 * phd_sin(item->pos.yRot + 0x4000)); - - pos2->xPos = item->pos.xPos + (number * phd_sin(item->pos.yRot + 0x4000)); - pos2->yPos = item->pos.yPos; - pos2->xPos = item->pos.zPos + (number * phd_sin(item->pos.zRot + 0x4000)); - - if (abs(pos->xPos - LaraItem->pos.xPos) < 0x5000) - { - if (abs(pos->yPos - LaraItem->pos.yPos) < 0x5000) - { - if (abs(pos->zPos - LaraItem->pos.zPos) < 0x5000) + if (abs(pos.xPos - LaraItem->pos.xPos) < SECTOR(20) + && abs(pos.yPos - LaraItem->pos.yPos) < SECTOR(20) + && abs(pos.zPos - LaraItem->pos.zPos) < SECTOR(20) + && abs(pos2.xPos - LaraItem->pos.xPos) < SECTOR(20) + && abs(pos2.yPos - LaraItem->pos.yPos) < SECTOR(20) + && abs(pos2.zPos - LaraItem->pos.zPos) < SECTOR(20)) { - if (abs(pos2->xPos - LaraItem->pos.xPos) < 0x5000) + if (!(GlobalCounter & 3)) { - if (abs(pos2->yPos - LaraItem->pos.yPos) < 0x5000) - { - if (abs(pos2->zPos - LaraItem->pos.zPos) < 0x5000) - { - if (!(GlobalCounter & 3)) - { - /* v23 = v39; - BYTE1(v23) = HIBYTE(v39) | 0x18; - v37 = v42 | ((itemNumbera | (v23 << 8)) << 8); - v24 = GetRandomControl(); - TriggerLightning(&v45, &v46, (v24 & 0x1F) + 32, v37, 1, 32, 5); - v18 = v45.z; - v16 = v45.x;*/ - } - - /* - v25 = v39; - BYTE1(v25) = HIBYTE(v39) | 0x30; - LODWORD(v13) = TriggerLightningGlow(v16, v45.y, v18, v42 | ((itemNumbera | (v25 << 8)) << 8)); - */ - - } - } + TriggerLightning( + (PHD_VECTOR*)&pos, + (PHD_VECTOR*)&pos2, + (GetRandomControl() & 0x1F) + 32, + r, + g, + b, + 24, + 1, + 32, + 5); } + + TriggerLightningGlow(pos.xPos, pos.yPos, pos.zPos, 48, r, g, b); } } } - goto wtf; + + if (item->itemFlags[3] >= 256 && item->triggerFlags == 2) + { + pos.xPos = item->pos.xPos + 8192 * phd_sin(item->pos.yRot); + pos.yPos = item->pos.yPos; + pos.zPos = item->pos.zPos + 8192 * phd_cos(item->pos.yRot + ANGLE(90)); + + SoundEffect(SFX_TR4_ELEC_ARCING_LOOP, &pos, 0); + + if (GlobalCounter & 1) + { + pos2.xPos = (GetRandomControl() & 0x3FF) + pos.xPos - 512; + pos2.yPos = (GetRandomControl() & 0x3FF) + pos.yPos - 512; + pos2.zPos = (GetRandomControl() & 0x3FF) + pos.zPos - 512; + + if (abs(pos.xPos - LaraItem->pos.xPos) < SECTOR(20) + && abs(pos.yPos - LaraItem->pos.yPos) < SECTOR(20) + && abs(pos.zPos - LaraItem->pos.zPos) < SECTOR(20) + && abs(pos2.xPos - LaraItem->pos.xPos) < SECTOR(20) + && abs(pos2.yPos - LaraItem->pos.yPos) < SECTOR(20) + && abs(pos2.zPos - LaraItem->pos.zPos) < SECTOR(20)) + { + if (item->itemFlags[2] != NO_ITEM) + { + ITEM_INFO* item2 = &g_Level.Items[item->itemFlags[2]]; + ExplodeItemNode(item2, 0, 0, 128); + KillItem(item->itemFlags[2]); + + TriggerExplosionSparks(pos.xPos, pos.yPos, pos.zPos, 3, -2, 0, item2->roomNumber); + TriggerExplosionSparks(pos.xPos, pos.yPos, pos.zPos, 3, -1, 0, item2->roomNumber); + + item->itemFlags[2] = NO_ITEM; + item2 = find_a_fucking_item(ID_PUZZLE_ITEM1_COMBO1); + item2->status = ITEM_NOT_ACTIVE; + + SoundEffect(SFX_TR4_EXPLOSION1, &item2->pos, 0); + SoundEffect(SFX_TR4_EXPLOSION2, &item2->pos, 0); + } + + TriggerLightning( + (PHD_VECTOR*)&pos, + (PHD_VECTOR*)&pos2, + (GetRandomControl() & 0xF) + 16, + r, + g, + b, + 24, + 3, + 24, + 3); + } + } + } } + else + { + AnimateItem(item); + OBJECT_INFO* obj = &Objects[item->objectNumber]; + bool flag = false; + if (item->animNumber == obj->animIndex + 2) + { + item->pos.yRot -= ANGLE(90); + if (TrInput & IN_ACTION) + { + item->animNumber = obj->animIndex + 1; + item->frameNumber = g_Level.Anims[item->animNumber].frameBase; + } + else + { + flag = true; + } + } + if (item->animNumber == obj->animIndex + 6) + { + item->pos.yRot += ANGLE(90); + if (!(TrInput & IN_ACTION)) + { + item->animNumber = obj->animIndex + 3; + item->frameNumber = g_Level.Anims[item->animNumber].frameBase; + flag = false; + } + else + { + item->animNumber = obj->animIndex + 5; + item->frameNumber = g_Level.Anims[item->animNumber].frameBase; + } + } + + if (flag) + { + item->animNumber = obj->animIndex + 3; + item->frameNumber = g_Level.Anims[item->animNumber].frameBase; + } + + if (item->triggerFlags == 2) + { + for (int i = 0; i < g_Level.Items.size(); i++) + { + ITEM_INFO* currentItem = &g_Level.Items[i]; + + if (currentItem->objectNumber == ID_PULLEY) + { + currentItem->itemFlags[1] = + (item->pos.yRot != -ANGLE(90) + || g_Level.Items[item->itemFlags[0]].pos.yRot != ANGLE(90) + || g_Level.Items[item->itemFlags[1]].pos.yRot != 0 ? 0 : 1) ^ 1; + break; + } + } + } + } } diff --git a/TR5Main/Objects/TR4/Object/tr4_obelisk.h b/TR5Main/Objects/TR4/Object/tr4_obelisk.h index 5a67b2549..e078bb651 100644 --- a/TR5Main/Objects/TR4/Object/tr4_obelisk.h +++ b/TR5Main/Objects/TR4/Object/tr4_obelisk.h @@ -1,3 +1,4 @@ #pragma once void InitialiseObelisk(short itemNumber); +void ObeliskControl(short itemNumber); \ No newline at end of file diff --git a/TR5Main/Objects/TR4/Object/tr4_sarcophagus.cpp b/TR5Main/Objects/TR4/Object/tr4_sarcophagus.cpp index 569083dae..a0e1e45fd 100644 --- a/TR5Main/Objects/TR4/Object/tr4_sarcophagus.cpp +++ b/TR5Main/Objects/TR4/Object/tr4_sarcophagus.cpp @@ -4,7 +4,7 @@ #include "input.h" #include "lara.h" #include "items.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "setup.h" #include "health.h" diff --git a/TR5Main/Objects/TR4/tr4_objects.cpp b/TR5Main/Objects/TR4/tr4_objects.cpp index 657199c4e..6f39da5af 100644 --- a/TR5Main/Objects/TR4/tr4_objects.cpp +++ b/TR5Main/Objects/TR4/tr4_objects.cpp @@ -1,6 +1,6 @@ #include "framework.h" #include "tr4_objects.h" -#include "pickup\pickup.h" +#include "pickup.h" /// entities #include "tr4_ahmet.h" // OK #include "tr4_baddy.h" // OK @@ -38,6 +38,8 @@ #include "tr4_sarcophagus.h" #include "tr4_senet.h" #include "tr4_clockwork_beetle.h" +#include "tr4_obelisk.h" + /// puzzle #include "tr4_scales.h" /// switch @@ -942,6 +944,16 @@ static void StartObject(OBJECT_INFO* obj) { obj->collision = PickupCollision; } + + obj = &Objects[ID_OBELISK]; + if (obj->loaded) + { + obj->initialise = InitialiseObelisk; + obj->control = ObeliskControl; + obj->collision = ObjectCollision; + obj->savePosition = true; + obj->saveFlags = true; + } } static void StartTrap(OBJECT_INFO* obj) diff --git a/TR5Main/Objects/TR5/tr5_objects.cpp b/TR5Main/Objects/TR5/tr5_objects.cpp index cf883bd54..5c00512ac 100644 --- a/TR5Main/Objects/TR5/tr5_objects.cpp +++ b/TR5Main/Objects/TR5/tr5_objects.cpp @@ -59,7 +59,7 @@ #include "lara_one_gun.h" #include "lara_flare.h" #include "lara_initialise.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "effects\flmtorch.h" #include "setup.h" #include "switch.h" diff --git a/TR5Main/Objects/Utils/object_helper.cpp b/TR5Main/Objects/Utils/object_helper.cpp index 63123b970..9be864fcf 100644 --- a/TR5Main/Objects/Utils/object_helper.cpp +++ b/TR5Main/Objects/Utils/object_helper.cpp @@ -2,7 +2,7 @@ #include "object_helper.h" #include "collide.h" #include "objects.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "puzzles_keys.h" #include "level.h" #include "tr5_smashobject.h" diff --git a/TR5Main/Objects/objectslist.h b/TR5Main/Objects/objectslist.h index a547ac5a3..3ef728be9 100644 --- a/TR5Main/Objects/objectslist.h +++ b/TR5Main/Objects/objectslist.h @@ -606,63 +606,63 @@ enum GAME_OBJECT_ID : short ID_CLOCKWORK_BEETLE_COMBO2, // TR4 - OK /* Switches */ - ID_SWITCH_TYPE1 = 800, - ID_SWITCH_TYPE2, - ID_SWITCH_TYPE3, - ID_SWITCH_TYPE4, - ID_SWITCH_TYPE5, - ID_SWITCH_TYPE6, - ID_SWITCH_TYPE7, - ID_SWITCH_TYPE8, - ID_SWITCH_TYPE9, - ID_SWITCH_TYPE10, - ID_SWITCH_TYPE11, - ID_SWITCH_TYPE12, - ID_SWITCH_TYPE13, - ID_SWITCH_TYPE14, - ID_SWITCH_TYPE15, - ID_SWITCH_TYPE16, + ID_SWITCH_TYPE1 = 800, // OK + ID_SWITCH_TYPE2, // OK + ID_SWITCH_TYPE3, // OK + ID_SWITCH_TYPE4, // OK + ID_SWITCH_TYPE5, // OK + ID_SWITCH_TYPE6, // OK + ID_SWITCH_TYPE7, // OK + ID_SWITCH_TYPE8, // OK + ID_SWITCH_TYPE9, // OK + ID_SWITCH_TYPE10, // OK + ID_SWITCH_TYPE11, // OK + ID_SWITCH_TYPE12, // OK + ID_SWITCH_TYPE13, // OK + ID_SWITCH_TYPE14, // OK + ID_SWITCH_TYPE15, // OK + ID_SWITCH_TYPE16, // OK ID_SHOOT_SWITCH1, ID_SHOOT_SWITCH2, ID_SHOOT_SWITCH3, ID_SHOOT_SWITCH4, ID_AIRLOCK_SWITCH, - ID_UNDERWATER_SWITCH1, - ID_UNDERWATER_SWITCH2, - ID_UNDERWATER_SWITCH3, - ID_UNDERWATER_SWITCH4, + ID_UNDERWATER_SWITCH1, // OK + ID_UNDERWATER_SWITCH2, // OK + ID_UNDERWATER_SWITCH3, // OK + ID_UNDERWATER_SWITCH4, // OK ID_TURN_SWITCH, ID_COG_SWITCH, // TR4 - OK ID_LEVER_SWITCH, // TR4 - OK ID_JUMP_SWITCH, // TR4 - OK - ID_CROWBAR_SWITCH, - ID_PULLEY, + ID_CROWBAR_SWITCH, // TR4 - OK + ID_PULLEY, // TR4 - OK ID_CROWDOVE_SWITCH, - ID_DOOR_TYPE1 = 850, - ID_DOOR_TYPE2, - ID_DOOR_TYPE3, - ID_DOOR_TYPE4, - ID_DOOR_TYPE5, - ID_DOOR_TYPE6, - ID_DOOR_TYPE7, - ID_DOOR_TYPE8, - ID_DOOR_TYPE9, - ID_DOOR_TYPE10, - ID_DOOR_TYPE11, - ID_DOOR_TYPE12, - ID_DOOR_TYPE13, - ID_DOOR_TYPE14, - ID_DOOR_TYPE15, - ID_DOOR_TYPE16, - ID_DOOR_TYPE17, - ID_DOOR_TYPE18, - ID_DOOR_TYPE19, - ID_DOOR_TYPE20, - ID_DOOR_TYPE21, - ID_DOOR_TYPE22, - ID_DOOR_TYPE23, - ID_DOOR_TYPE24, + ID_DOOR_TYPE1 = 850, // OK + ID_DOOR_TYPE2, // OK + ID_DOOR_TYPE3, // OK + ID_DOOR_TYPE4, // OK + ID_DOOR_TYPE5, // OK + ID_DOOR_TYPE6, // OK + ID_DOOR_TYPE7, // OK + ID_DOOR_TYPE8, // OK + ID_DOOR_TYPE9, // OK + ID_DOOR_TYPE10, // OK + ID_DOOR_TYPE11, // OK + ID_DOOR_TYPE12, // OK + ID_DOOR_TYPE13, // OK + ID_DOOR_TYPE14, // OK + ID_DOOR_TYPE15, // OK + ID_DOOR_TYPE16, // OK + ID_DOOR_TYPE17, // OK + ID_DOOR_TYPE18, // OK + ID_DOOR_TYPE19, // OK + ID_DOOR_TYPE20, // OK + ID_DOOR_TYPE21, // OK + ID_DOOR_TYPE22, // OK + ID_DOOR_TYPE23, // OK + ID_DOOR_TYPE24, // OK ID_CLOSED_DOOR1, ID_CLOSED_DOOR2, ID_CLOSED_DOOR3, @@ -671,26 +671,26 @@ enum GAME_OBJECT_ID : short ID_CLOSED_DOOR6, ID_LIFT_DOORS1, ID_LIFT_DOORS2, - ID_PUSHPULL_DOOR1, - ID_PUSHPULL_DOOR2, - ID_PUSHPULL_DOOR3, - ID_PUSHPULL_DOOR4, - ID_KICK_DOOR1, - ID_KICK_DOOR2, - ID_KICK_DOOR3, - ID_KICK_DOOR4, - ID_UNDERWATER_DOOR1, // NEW - ID_UNDERWATER_DOOR2, - ID_UNDERWATER_DOOR3, - ID_UNDERWATER_DOOR4, - ID_DOUBLE_DOORS1, - ID_DOUBLE_DOORS2, - ID_DOUBLE_DOORS3, - ID_DOUBLE_DOORS4, - ID_SEQUENCE_DOOR1, - ID_SEQUENCE_SWITCH1, - ID_SEQUENCE_SWITCH2, - ID_SEQUENCE_SWITCH3, + ID_PUSHPULL_DOOR1, // TR4 - OK + ID_PUSHPULL_DOOR2, // TR4 - OK + ID_PUSHPULL_DOOR3, // TR4 - OK + ID_PUSHPULL_DOOR4, // TR4 - OK + ID_KICK_DOOR1, // TR4 - OK + ID_KICK_DOOR2, // TR4 - OK + ID_KICK_DOOR3, // TR4 - OK + ID_KICK_DOOR4, // TR4 - OK + ID_UNDERWATER_DOOR1, // OK + ID_UNDERWATER_DOOR2, // OK + ID_UNDERWATER_DOOR3, // OK + ID_UNDERWATER_DOOR4, // OK + ID_DOUBLE_DOORS1, // TR4 - OK + ID_DOUBLE_DOORS2, // TR4 - OK + ID_DOUBLE_DOORS3, // TR4 - OK + ID_DOUBLE_DOORS4, // TR4 - OK + ID_SEQUENCE_DOOR1, // TR4 - OK + ID_SEQUENCE_SWITCH1, // TR4 - OK + ID_SEQUENCE_SWITCH2, // TR4 - OK + ID_SEQUENCE_SWITCH3, // TR4 - OK ID_STEEL_DOOR, ID_GOD_HEAD, diff --git a/TR5Main/Renderer/Renderer11.cpp b/TR5Main/Renderer/Renderer11.cpp index bb7a38df1..94dc0ce56 100644 --- a/TR5Main/Renderer/Renderer11.cpp +++ b/TR5Main/Renderer/Renderer11.cpp @@ -6,7 +6,7 @@ #include "configuration.h" #include "draw.h" #include "health.h" -#include "pickup\pickup.h" +#include "pickup.h" #ifndef NEW_INV #include "inventory.h" #endif diff --git a/TR5Main/Renderer/Renderer11Draw.cpp b/TR5Main/Renderer/Renderer11Draw.cpp index dc508ac6a..7b0db080d 100644 --- a/TR5Main/Renderer/Renderer11Draw.cpp +++ b/TR5Main/Renderer/Renderer11Draw.cpp @@ -14,7 +14,6 @@ #include "gameflow.h" #include "rope.h" #include "effects\tomb4fx.h" -#include "door.h" #include "level.h" #include "setup.h" #include "control.h" diff --git a/TR5Main/Scripting/GameLogicScript.cpp b/TR5Main/Scripting/GameLogicScript.cpp index ef4fede63..90e221ba1 100644 --- a/TR5Main/Scripting/GameLogicScript.cpp +++ b/TR5Main/Scripting/GameLogicScript.cpp @@ -11,7 +11,7 @@ #include "level.h" #include "effects\tomb4fx.h" #include "effects\effects.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "newinv2.h" #include "ObjectIDs.h" #include "camera.h" diff --git a/TR5Main/Specific/level.cpp b/TR5Main/Specific/level.cpp index d0384968b..adec495ab 100644 --- a/TR5Main/Specific/level.cpp +++ b/TR5Main/Specific/level.cpp @@ -8,17 +8,19 @@ #include "spotcam.h" #include "camera.h" #include "control.h" -#include "pickup\pickup.h" -#include "door.h" +#include "pickup.h" +#include "generic_doors.h" #include "box.h" -#include "Sound\sound.h" +#include "sound.h" #include "GameFlowScript.h" #include #include #include "Renderer11.h" + using TEN::Renderer::g_Renderer; using std::vector; using std::string; +using namespace TEN::Entities::Doors; FILE* LevelFilePtr; uintptr_t hLoadLevel; @@ -100,7 +102,6 @@ int LoadItems() g_Level.Items.resize(NUM_ITEMS); - InitialiseClosedDoors(); InitialiseItemArray(NUM_ITEMS); if (g_Level.NumItems > 0) @@ -331,7 +332,6 @@ void LoadObjects() } InitialiseObjects(); - InitialiseClosedDoors(); int numStatics = ReadInt32(); for (int i = 0; i < numStatics; i++) diff --git a/TR5Main/Specific/setup.cpp b/TR5Main/Specific/setup.cpp index f9d82a9f9..9cc054171 100644 --- a/TR5Main/Specific/setup.cpp +++ b/TR5Main/Specific/setup.cpp @@ -7,13 +7,12 @@ #include "switch.h" #include "missile.h" #include "control.h" -#include "pickup\pickup.h" +#include "pickup.h" #include "camera.h" #include "lara_one_gun.h" #include "lara_flare.h" #include "lara_fire.h" #include "objects.h" -#include "door.h" #include "rope.h" #include "traps.h" #include "effects\flmtorch.h" @@ -170,92 +169,6 @@ void ObjectObjects() obj->saveAnim = true; }*/ - for (int objNum = ID_DOOR_TYPE1; objNum <= ID_CLOSED_DOOR6; objNum++) - { - obj = &Objects[objNum]; - if (obj->loaded) - { - obj->initialise = InitialiseDoor; - obj->control = DoorControl; - obj->collision = DoorCollision; - obj->hitEffect = HIT_RICOCHET; - obj->saveAnim = true; - obj->saveFlags = true; - obj->saveMesh = true; - } - } - - obj = &Objects[ID_LIFT_DOORS1]; - if (obj->loaded) - { - obj->initialise = InitialiseDoor; - obj->control = DoorControl; - obj->hitEffect = HIT_RICOCHET; - obj->saveFlags = true; - } - - obj = &Objects[ID_LIFT_DOORS2]; - if (obj->loaded) - { - obj->initialise = InitialiseDoor; - obj->control = DoorControl; - obj->hitEffect = HIT_RICOCHET; - obj->saveFlags = true; - } - - obj = &Objects[ID_SEQUENCE_DOOR1]; - if (obj->loaded) - { - obj->initialise = InitialiseDoor; - obj->collision = DoorCollision; - obj->control = SequenceDoorControl; - obj->hitEffect = HIT_RICOCHET; - obj->saveAnim = true; - obj->saveFlags = true; - } - - for (int i = ID_DOUBLE_DOORS1; i <= ID_DOUBLE_DOORS4; i++) - { - obj = &Objects[i]; - if (obj->loaded) - { - obj->initialise = InitialiseDoor; - obj->collision = DoubleDoorCollision; - obj->control = PushPullKickDoorControl; - obj->hitEffect = HIT_RICOCHET; - obj->saveAnim = true; - obj->saveFlags = true; - } - } - - for (int i = ID_UNDERWATER_DOOR1; i <= ID_UNDERWATER_DOOR4; i++) - { - obj = &Objects[i]; - if (obj->loaded) - { - obj->initialise = InitialiseDoor; - obj->collision = UnderwaterDoorCollision; - obj->control = PushPullKickDoorControl; - obj->hitEffect = HIT_RICOCHET; - obj->saveAnim = true; - obj->saveFlags = true; - } - } - - for (int objNum = ID_PUSHPULL_DOOR1; objNum <= ID_KICK_DOOR4; objNum++) - { - obj = &Objects[objNum]; - if (obj->loaded) - { - obj->initialise = InitialiseDoor; - obj->collision = PushPullKickDoorCollision; - obj->control = PushPullKickDoorControl; - obj->hitEffect = HIT_RICOCHET; - obj->saveAnim = true; - obj->saveFlags = true; - } - } - for (int objNum = ID_KEY_HOLE1; objNum <= ID_KEY_HOLE16; objNum++) { InitKeyHole(obj, objNum); @@ -295,18 +208,6 @@ void ObjectObjects() obj->collision = ParallelBarsCollision; } - obj = &Objects[ID_STEEL_DOOR]; - if (obj->loaded) - { - obj->initialise = InitialiseSteelDoor; - obj->collision = SteelDoorCollision; - //obj->control = Legacy_SteelDoorControl; - obj->saveAnim = true; - obj->saveFlags = true; - obj->saveMesh = true; - obj->savePosition = true; - } - obj = &Objects[ID_EARTHQUAKE]; if (obj->loaded) { diff --git a/TR5Main/TombEngine.vcxproj b/TR5Main/TombEngine.vcxproj index 455206624..0461853ba 100644 --- a/TR5Main/TombEngine.vcxproj +++ b/TR5Main/TombEngine.vcxproj @@ -66,7 +66,7 @@ true _CRT_SECURE_NO_WARNINGS;WIN32;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;NOMINMAX;NEW_INV;NEW_TIGHTROPE;CREATURE_AI_PRIORITY_OPTIMIZATION;%(PreprocessorDefinitions) false - D:\Dokumente\TR5Main\TR5Main\Game\itemdata;$(SolutionDir)TR5Main\Game\itemdata;$(SolutionDir)TR5Main;$(SolutionDir)TR5Main\Game;$(SolutionDir)TR5Main\Game\Lara;$(SolutionDir)TR5Main\Objects;$(SolutionDir)TR5Main\Objects\Utils;$(SolutionDir)TR5Main\Objects\Effects;$(SolutionDir)TR5Main\Objects\Generic;$(SolutionDir)TR5Main\Objects\Generic\Switches;$(SolutionDir)TR5Main\Objects\Generic\Object;$(SolutionDir)TR5Main\Objects\TR1;$(SolutionDir)TR5Main\Objects\TR1\Entity;$(SolutionDir)TR5Main\Objects\TR1\Trap;$(SolutionDir)TR5Main\Objects\TR2;$(SolutionDir)TR5Main\Objects\TR2\Entity;$(SolutionDir)TR5Main\Objects\TR2\Trap;$(SolutionDir)TR5Main\Objects\TR2\Vehicles;$(SolutionDir)TR5Main\Objects\TR3;$(SolutionDir)TR5Main\Objects\TR3\Entity;$(SolutionDir)TR5Main\Objects\TR3\Trap;$(SolutionDir)TR5Main\Objects\TR3\Vehicles;$(SolutionDir)TR5Main\Objects\TR4;$(SolutionDir)TR5Main\Objects\TR4\Entity;$(SolutionDir)TR5Main\Objects\TR4\Trap;$(SolutionDir)TR5Main\Objects\TR4\Object;$(SolutionDir)TR5Main\Objects\TR4\Floor;$(SolutionDir)TR5Main\Objects\TR4\Switch;$(SolutionDir)TR5Main\Objects\TR4\Vehicles;$(SolutionDir)TR5Main\Objects\TR5;$(SolutionDir)TR5Main\Objects\TR5\Entity;$(SolutionDir)TR5Main\Objects\TR5\Trap;$(SolutionDir)TR5Main\Objects\TR5\Light;$(SolutionDir)TR5Main\Objects\TR5\Emitter;$(SolutionDir)TR5Main\Objects\TR5\Shatter;$(SolutionDir)TR5Main\Objects\TR5\Switch;$(SolutionDir)TR5Main\Objects\TR5\Object;$(SolutionDir)TR5Main\Objects\Vehicles;$(SolutionDir)TR5Main\Renderer;$(SolutionDir)TR5Main\Scripting;$(SolutionDir)TR5Main\Specific;$(SolutionDir)TR5Main\Specific\IO;%(AdditionalIncludeDirectories) + $(SolutionDir)TR5Main;$(SolutionDir)TR5Main\Game;$(SolutionDir)TR5Main\Game\Lara;$(SolutionDir)TR5Main\Objects;$(SolutionDir)TR5Main\Objects\Utils;$(SolutionDir)TR5Main\Objects\Effects;$(SolutionDir)TR5Main\Objects\Generic;$(SolutionDir)TR5Main\Objects\Generic\Doors;$(SolutionDir)TR5Main\Objects\Generic\Switches;$(SolutionDir)TR5Main\Objects\Generic\Object;$(SolutionDir)TR5Main\Objects\TR1;$(SolutionDir)TR5Main\Objects\TR1\Entity;$(SolutionDir)TR5Main\Objects\TR1\Trap;$(SolutionDir)TR5Main\Objects\TR2;$(SolutionDir)TR5Main\Objects\TR2\Entity;$(SolutionDir)TR5Main\Objects\TR2\Trap;$(SolutionDir)TR5Main\Objects\TR2\Vehicles;$(SolutionDir)TR5Main\Objects\TR3;$(SolutionDir)TR5Main\Objects\TR3\Entity;$(SolutionDir)TR5Main\Objects\TR3\Trap;$(SolutionDir)TR5Main\Objects\TR3\Vehicles;$(SolutionDir)TR5Main\Objects\TR4;$(SolutionDir)TR5Main\Objects\TR4\Entity;$(SolutionDir)TR5Main\Objects\TR4\Trap;$(SolutionDir)TR5Main\Objects\TR4\Object;$(SolutionDir)TR5Main\Objects\TR4\Floor;$(SolutionDir)TR5Main\Objects\TR4\Switch;$(SolutionDir)TR5Main\Objects\TR4\Vehicles;$(SolutionDir)TR5Main\Objects\TR5;$(SolutionDir)TR5Main\Objects\TR5\Entity;$(SolutionDir)TR5Main\Objects\TR5\Trap;$(SolutionDir)TR5Main\Objects\TR5\Light;$(SolutionDir)TR5Main\Objects\TR5\Emitter;$(SolutionDir)TR5Main\Objects\TR5\Shatter;$(SolutionDir)TR5Main\Objects\TR5\Switch;$(SolutionDir)TR5Main\Objects\TR5\Object;$(SolutionDir)TR5Main\Objects\Vehicles;$(SolutionDir)TR5Main\Renderer;$(SolutionDir)TR5Main\Scripting;$(SolutionDir)TR5Main\Specific;$(SolutionDir)TR5Main\Specific\IO;$(SolutionDir)TR5Main\Sound;$(SolutionDir)TR5Main\Game\pickup;$(SolutionDir)TR5Main\Game\itemdata;$(SolutionDir)TR5Main\Game\effects;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL false true @@ -97,7 +97,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" false _CRT_SECURE_NO_WARNINGS;WIN32;TR5MAIN_EXPORTS;_WINDOWS;_USRDLL;NOMINMAX;NEW_INV;NEW_TIGHTROPE;CREATURE_AI_PRIORITY_OPTIMIZATION;%(PreprocessorDefinitions) false - $(SolutionDir)TR5Main;$(SolutionDir)TR5Main\Game;$(SolutionDir)TR5Main\Game\Lara;$(SolutionDir)TR5Main\Objects;$(SolutionDir)TR5Main\Objects\Utils;$(SolutionDir)TR5Main\Objects\Effects;$(SolutionDir)TR5Main\Objects\Generic;$(SolutionDir)TR5Main\Objects\Generic\Switches;$(SolutionDir)TR5Main\Objects\Generic\Object;$(SolutionDir)TR5Main\Objects\TR1;$(SolutionDir)TR5Main\Objects\TR1\Entity;$(SolutionDir)TR5Main\Objects\TR1\Trap;$(SolutionDir)TR5Main\Objects\TR2;$(SolutionDir)TR5Main\Objects\TR2\Entity;$(SolutionDir)TR5Main\Objects\TR2\Trap;$(SolutionDir)TR5Main\Objects\TR2\Vehicles;$(SolutionDir)TR5Main\Objects\TR3;$(SolutionDir)TR5Main\Objects\TR3\Entity;$(SolutionDir)TR5Main\Objects\TR3\Trap;$(SolutionDir)TR5Main\Objects\TR3\Vehicles;$(SolutionDir)TR5Main\Objects\TR4;$(SolutionDir)TR5Main\Objects\TR4\Entity;$(SolutionDir)TR5Main\Objects\TR4\Trap;$(SolutionDir)TR5Main\Objects\TR4\Object;$(SolutionDir)TR5Main\Objects\TR4\Floor;$(SolutionDir)TR5Main\Objects\TR4\Switch;$(SolutionDir)TR5Main\Objects\TR4\Vehicles;$(SolutionDir)TR5Main\Objects\TR5;$(SolutionDir)TR5Main\Objects\TR5\Entity;$(SolutionDir)TR5Main\Objects\TR5\Trap;$(SolutionDir)TR5Main\Objects\TR5\Light;$(SolutionDir)TR5Main\Objects\TR5\Emitter;$(SolutionDir)TR5Main\Objects\TR5\Shatter;$(SolutionDir)TR5Main\Objects\TR5\Switch;$(SolutionDir)TR5Main\Objects\TR5\Object;$(SolutionDir)TR5Main\Objects\Vehicles;$(SolutionDir)TR5Main\Renderer;$(SolutionDir)TR5Main\Scripting;$(SolutionDir)TR5Main\Specific;$(SolutionDir)TR5Main\Specific\IO;%(AdditionalIncludeDirectories) + $(SolutionDir)TR5Main;$(SolutionDir)TR5Main\Game;$(SolutionDir)TR5Main\Game\Lara;$(SolutionDir)TR5Main\Objects;$(SolutionDir)TR5Main\Objects\Utils;$(SolutionDir)TR5Main\Objects\Effects;$(SolutionDir)TR5Main\Objects\Generic;$(SolutionDir)TR5Main\Objects\Generic\Doors;$(SolutionDir)TR5Main\Objects\Generic\Switches;$(SolutionDir)TR5Main\Objects\Generic\Object;$(SolutionDir)TR5Main\Objects\TR1;$(SolutionDir)TR5Main\Objects\TR1\Entity;$(SolutionDir)TR5Main\Objects\TR1\Trap;$(SolutionDir)TR5Main\Objects\TR2;$(SolutionDir)TR5Main\Objects\TR2\Entity;$(SolutionDir)TR5Main\Objects\TR2\Trap;$(SolutionDir)TR5Main\Objects\TR2\Vehicles;$(SolutionDir)TR5Main\Objects\TR3;$(SolutionDir)TR5Main\Objects\TR3\Entity;$(SolutionDir)TR5Main\Objects\TR3\Trap;$(SolutionDir)TR5Main\Objects\TR3\Vehicles;$(SolutionDir)TR5Main\Objects\TR4;$(SolutionDir)TR5Main\Objects\TR4\Entity;$(SolutionDir)TR5Main\Objects\TR4\Trap;$(SolutionDir)TR5Main\Objects\TR4\Object;$(SolutionDir)TR5Main\Objects\TR4\Floor;$(SolutionDir)TR5Main\Objects\TR4\Switch;$(SolutionDir)TR5Main\Objects\TR4\Vehicles;$(SolutionDir)TR5Main\Objects\TR5;$(SolutionDir)TR5Main\Objects\TR5\Entity;$(SolutionDir)TR5Main\Objects\TR5\Trap;$(SolutionDir)TR5Main\Objects\TR5\Light;$(SolutionDir)TR5Main\Objects\TR5\Emitter;$(SolutionDir)TR5Main\Objects\TR5\Shatter;$(SolutionDir)TR5Main\Objects\TR5\Switch;$(SolutionDir)TR5Main\Objects\TR5\Object;$(SolutionDir)TR5Main\Objects\Vehicles;$(SolutionDir)TR5Main\Renderer;$(SolutionDir)TR5Main\Scripting;$(SolutionDir)TR5Main\Specific;$(SolutionDir)TR5Main\Specific\IO;$(SolutionDir)TR5Main\Sound;$(SolutionDir)TR5Main\Game\pickup;$(SolutionDir)TR5Main\Game\itemdata;$(SolutionDir)TR5Main\Game\effects;%(AdditionalIncludeDirectories) MultiThreadedDLL false true @@ -181,6 +181,12 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" + + + + + + @@ -463,7 +469,6 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" - @@ -548,6 +553,12 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" + + + + + + @@ -769,7 +780,6 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\" - diff --git a/TR5Main/TombEngine.vcxproj.filters b/TR5Main/TombEngine.vcxproj.filters index 6362061e9..a54800257 100644 --- a/TR5Main/TombEngine.vcxproj.filters +++ b/TR5Main/TombEngine.vcxproj.filters @@ -27,9 +27,6 @@ File di intestazione - - File di intestazione - File di intestazione @@ -1092,6 +1089,81 @@ File di intestazione + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + + + File di intestazione + @@ -1106,9 +1178,6 @@ File di origine - - File di origine - File di origine @@ -1697,9 +1766,6 @@ File di origine - - File di origine - File di origine @@ -2003,6 +2069,27 @@ File di origine + + File di origine + + + File di origine + + + File di origine + + + File di origine + + + File di origine + + + File di origine + + + File di origine +