mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-01 09:18:00 +03:00
Merge branch 'NewLuaScripting' of https://github.com/MontyTRC89/TombEngine into NewLuaScripting
This commit is contained in:
commit
03c7f833ba
4 changed files with 100 additions and 2 deletions
|
@ -814,8 +814,10 @@ GAME_STATUS DoLevel(int index, std::string ambient, bool loadFromSavegame)
|
|||
// Run the level script
|
||||
GameScriptLevel* level = g_GameFlow->Levels[index];
|
||||
std::string err;
|
||||
|
||||
g_GameScript->ExecuteScript(level->ScriptFileName, err);
|
||||
g_GameScript->InitCallbacks();
|
||||
|
||||
// Restore the game?
|
||||
if (loadFromSavegame)
|
||||
{
|
||||
|
@ -929,6 +931,43 @@ void TestTriggers(short *data, int heavy, int HeavyFlags)
|
|||
short cameraTimer = 0;
|
||||
int spotCamIndex = 0;
|
||||
|
||||
// Test trigger volumes if any
|
||||
if (heavy == 0)
|
||||
{
|
||||
ROOM_INFO* room = &g_Level.Rooms[LaraItem->roomNumber];
|
||||
for (int i = 0; i < room->triggerVolumes.size(); i++)
|
||||
{
|
||||
TRIGGER_VOLUME* volume = &room->triggerVolumes[i];
|
||||
/*ANIM_FRAME* frame = GetBestFrame(LaraItem);
|
||||
|
||||
Vector3 boxMin = Vector3(frame->boundingBox.X1, frame->boundingBox.Y1, frame->boundingBox.Z1);
|
||||
Vector3 boxMax = Vector3(frame->boundingBox.X2, frame->boundingBox.Y2, frame->boundingBox.Z2);
|
||||
Vector3 centre = (boxMin + boxMax) / 2.0f;
|
||||
Vector3 extens = boxMax - centre;
|
||||
BoundingBox laraBox = BoundingBox((Vector3)(centre + Vector3(room->x, room->y, room->z)), extens);*/
|
||||
|
||||
/*BoundingOrientedBox volumeBox = BoundingOrientedBox(
|
||||
(Vector3)(volume->position + Vector3(room->x, room->y, room->z)),
|
||||
(Vector3)(volume->scale / 2.0f),
|
||||
volume->rotation);*/
|
||||
|
||||
if (volume->box.Contains(Vector3(LaraItem->pos.xPos, LaraItem->pos.yPos, LaraItem->pos.zPos)) == ContainmentType::CONTAINS)
|
||||
{
|
||||
// Execute trigger
|
||||
//g_GameScript->ExecuteScript();
|
||||
Lara.gunType = WEAPON_UZI;
|
||||
}
|
||||
else
|
||||
Lara.gunType = WEAPON_NONE;
|
||||
|
||||
/*if (volumeBox.Intersects(laraBox))
|
||||
{
|
||||
// Execute trigger
|
||||
g_GameScript->ExecuteScript();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
HeavyTriggered = false;
|
||||
|
||||
if (!heavy)
|
||||
|
|
|
@ -82,6 +82,28 @@ enum RoomEnumFlag
|
|||
ENV_FLAG_UNKNOWN3 = 0x0400
|
||||
};
|
||||
|
||||
enum TriggerStatus
|
||||
{
|
||||
TS_OUTSIDE = 0,
|
||||
TS_ENTERING = 1,
|
||||
TS_INSIDE = 2,
|
||||
TS_LEAVING = 3
|
||||
};
|
||||
|
||||
struct TRIGGER_VOLUME
|
||||
{
|
||||
Vector3 position;
|
||||
Quaternion rotation;
|
||||
Vector3 scale;
|
||||
int activators;
|
||||
std::string onEnter;
|
||||
std::string onInside;
|
||||
std::string onLeave;
|
||||
bool oneShot;
|
||||
TriggerStatus status;
|
||||
BoundingOrientedBox box;
|
||||
};
|
||||
|
||||
struct ROOM_INFO
|
||||
{
|
||||
int x;
|
||||
|
@ -108,6 +130,7 @@ struct ROOM_INFO
|
|||
short itemNumber;
|
||||
short fxNumber;
|
||||
bool boundActive;
|
||||
std::vector<TRIGGER_VOLUME> triggerVolumes;
|
||||
};
|
||||
|
||||
struct ANIM_STRUCT
|
||||
|
|
|
@ -329,5 +329,4 @@ void GameScriptItemInfo::DisableItem()
|
|||
m_item->status = ITEM_DEACTIVATED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -682,6 +682,43 @@ void ReadRooms()
|
|||
room.mesh.push_back(mesh);
|
||||
}
|
||||
|
||||
int numTriggerVolumes = ReadInt32();
|
||||
for (int j = 0; j < numTriggerVolumes; j++)
|
||||
{
|
||||
TRIGGER_VOLUME volume;
|
||||
|
||||
volume.position = Vector3(ReadFloat(), ReadFloat(), ReadFloat());
|
||||
volume.rotation = Quaternion(ReadFloat(), ReadFloat(), ReadFloat(), ReadFloat());
|
||||
volume.scale = Vector3(ReadFloat(), ReadFloat(), ReadFloat());
|
||||
volume.activators = ReadInt32();
|
||||
|
||||
byte numBytes = ReadInt8();
|
||||
char* buffer[255];
|
||||
ZeroMemory(buffer, 256);
|
||||
ReadBytes(buffer, numBytes);
|
||||
volume.onEnter = std::string((const char*)buffer);
|
||||
|
||||
numBytes = ReadInt8();
|
||||
ZeroMemory(buffer, 256);
|
||||
ReadBytes(buffer, numBytes);
|
||||
volume.onInside = std::string((const char*)buffer);
|
||||
|
||||
numBytes = ReadInt8();
|
||||
ZeroMemory(buffer, 256);
|
||||
ReadBytes(buffer, numBytes);
|
||||
volume.onLeave = std::string((const char*)buffer);
|
||||
|
||||
volume.oneShot = ReadInt8();
|
||||
volume.status = TS_OUTSIDE;
|
||||
|
||||
volume.box = BoundingOrientedBox(
|
||||
(Vector3)(volume.position + Vector3(room.x, room.minfloor, room.z)),
|
||||
(Vector3)(volume.scale / 2.0f),
|
||||
volume.rotation);
|
||||
|
||||
room.triggerVolumes.push_back(volume);
|
||||
}
|
||||
|
||||
room.flippedRoom = ReadInt32();
|
||||
room.flags = ReadInt32();
|
||||
room.meshEffect = ReadInt32();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue