From 4be36258515edd3409ac92ff151b37b9d6375dcd Mon Sep 17 00:00:00 2001 From: Sezz Date: Fri, 16 Dec 2022 12:42:58 +1100 Subject: [PATCH 01/19] Partially move things into namespace --- TombEngine/Game/control/control.cpp | 8 +- TombEngine/Game/control/volume.h | 75 ++++++++++--------- .../Objects/ScriptInterfaceObjectsHandler.h | 14 ++-- .../Scripting/Include/ScriptInterfaceGame.h | 7 +- .../Internal/TEN/Objects/ObjectsHandler.cpp | 44 ++++------- .../Internal/TEN/Objects/ObjectsHandler.h | 14 ++-- 6 files changed, 75 insertions(+), 87 deletions(-) diff --git a/TombEngine/Game/control/control.cpp b/TombEngine/Game/control/control.cpp index 2e3fb9658..6f4bde600 100644 --- a/TombEngine/Game/control/control.cpp +++ b/TombEngine/Game/control/control.cpp @@ -32,7 +32,7 @@ #include "Game/room.h" #include "Game/savegame.h" #include "Game/spotcam.h" -#include "Math/Random.h" +#include "Math/Math.h" #include "Objects/Effects/tr4_locusts.h" #include "Objects/Generic/Object/objects.h" #include "Objects/Generic/Object/rope.h" @@ -65,7 +65,7 @@ using namespace TEN::Entities::Switches; using namespace TEN::Entities::TR4; using namespace TEN::Floordata; using namespace TEN::Input; -using namespace TEN::Math::Random; +using namespace TEN::Math; using namespace TEN::Renderer; int GameTimer = 0; @@ -357,12 +357,12 @@ void KillMoveEffects() int GetRandomControl() { - return GenerateInt(); + return Random::GenerateInt(); } int GetRandomDraw() { - return GenerateInt(); + return Random::GenerateInt(); } void CleanUp() diff --git a/TombEngine/Game/control/volume.h b/TombEngine/Game/control/volume.h index 62f7fa61a..3bf958a99 100644 --- a/TombEngine/Game/control/volume.h +++ b/TombEngine/Game/control/volume.h @@ -6,48 +6,53 @@ struct CollisionSetup; -constexpr auto NO_EVENT_SET = -1; - -constexpr auto VOLUME_BUSY_TIMEOUT = 10; -constexpr auto VOLUME_LEAVE_TIMEOUT = 5; - -constexpr auto VOLUME_STATE_QUEUE_SIZE = 16; - -enum class VolumeStateStatus +namespace TEN::Control::Volumes { - Outside, - Entering, - Inside, - Leaving -}; + constexpr auto NO_EVENT_SET = -1; -enum class VolumeType -{ - Box, - Sphere, - Prism // TODO: Unsupported as of now. -}; + constexpr auto VOLUME_BUSY_TIMEOUT = 10; + constexpr auto VOLUME_LEAVE_TIMEOUT = 5; -struct VolumeState -{ - VolumeStateStatus Status = VolumeStateStatus::Outside; - VolumeActivator Activator = nullptr; - int Timestamp = 0; -}; + constexpr auto VOLUME_STATE_QUEUE_SIZE = 16; -struct TriggerVolume -{ - bool Enabled = true; - int EventSetIndex = 0; + enum class VolumeStateStatus + { + Outside, + Entering, + Inside, + Leaving + }; - VolumeType Type = VolumeType::Box; - std::string Name = {}; + enum class VolumeType + { + Box, + Sphere, + Prism // TODO: Unsupported as of now. + }; - BoundingOrientedBox Box = BoundingOrientedBox(); - BoundingSphere Sphere = BoundingSphere(); + struct VolumeState + { + VolumeStateStatus Status = VolumeStateStatus::Outside; + VolumeActivator Activator = nullptr; - std::vector StateQueue = {}; -}; + int Timestamp = 0; + }; +} + +// TODO: Move into namespace and deal with errors. + struct TriggerVolume + { + bool Enabled = true; + int EventSetIndex = 0; + + std::string Name = {}; + VolumeType Type = VolumeType::Box; + + BoundingOrientedBox Box = BoundingOrientedBox(); + BoundingSphere Sphere = BoundingSphere(); + + std::vector StateQueue = {}; + }; namespace TEN::Control::Volumes { diff --git a/TombEngine/Scripting/Include/Objects/ScriptInterfaceObjectsHandler.h b/TombEngine/Scripting/Include/Objects/ScriptInterfaceObjectsHandler.h index de48c1e30..77c3adeed 100644 --- a/TombEngine/Scripting/Include/Objects/ScriptInterfaceObjectsHandler.h +++ b/TombEngine/Scripting/Include/Objects/ScriptInterfaceObjectsHandler.h @@ -1,11 +1,12 @@ #pragma once -#include #include +#include #include "Specific/level.h" typedef DWORD D3DCOLOR; -using VarMapVal = std::variant< short, +using VarMapVal = std::variant< + short, std::reference_wrapper, std::reference_wrapper, std::reference_wrapper, @@ -13,16 +14,16 @@ using VarMapVal = std::variant< short, std::reference_wrapper, std::reference_wrapper>; -using CallbackDrawString = std::function; +using CallbackDrawString = std::function; class ScriptInterfaceObjectsHandler { public: virtual ~ScriptInterfaceObjectsHandler() = default; - [[nodiscard]] virtual short GetIndexByName(std::string const& name) const = 0; - virtual bool AddName(std::string const& key, VarMapVal val) = 0; - virtual bool NotifyKilled(ItemInfo *) = 0; + [[nodiscard]] virtual short GetIndexByName(const std::string& name) const = 0; + virtual bool AddName(const std::string& key, VarMapVal val) = 0; + virtual bool NotifyKilled(ItemInfo*) = 0; virtual void FreeEntities() = 0; virtual void AssignLara() = 0; @@ -32,4 +33,3 @@ public: }; extern ScriptInterfaceObjectsHandler* g_GameScriptEntities; - diff --git a/TombEngine/Scripting/Include/ScriptInterfaceGame.h b/TombEngine/Scripting/Include/ScriptInterfaceGame.h index 824e9947e..59fb59cb6 100644 --- a/TombEngine/Scripting/Include/ScriptInterfaceGame.h +++ b/TombEngine/Scripting/Include/ScriptInterfaceGame.h @@ -1,13 +1,14 @@ #pragma once -#include #include +#include #include "Game/control/volumeactivator.h" #include "Game/room.h" #include "Specific/level.h" typedef DWORD D3DCOLOR; -using VarMapVal = std::variant< short, +using VarMapVal = std::variant< + short, std::reference_wrapper, std::reference_wrapper, std::reference_wrapper, @@ -16,9 +17,7 @@ using VarMapVal = std::variant< short, std::reference_wrapper>; using CallbackDrawString = std::function; - using VarSaveType = std::variant; - using IndexTable = std::vector>; struct FuncName diff --git a/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp b/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp index 7a8f01c23..061acd670 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.cpp @@ -19,7 +19,7 @@ Moveables, statics, cameras, and so on. @pragma nostrip */ -ObjectsHandler::ObjectsHandler(sol::state* lua, sol::table & parent) : +ObjectsHandler::ObjectsHandler(sol::state* lua, sol::table& parent) : m_handler{ lua }, m_table_objects(sol::table{m_handler.GetState()->lua_state(), sol::create}) { @@ -102,44 +102,37 @@ ObjectsHandler::ObjectsHandler(sol::state* lua, sol::table & parent) : Moveable::Register(m_table_objects); Moveable::SetNameCallbacks( [this](auto && ... param) { return AddName(std::forward(param)...); }, - [this](auto && ... param) { return RemoveName(std::forward(param)...); } - ); + [this](auto && ... param) { return RemoveName(std::forward(param)...); }); Static::Register(m_table_objects); Static::SetNameCallbacks( [this](auto && ... param) { return AddName(std::forward(param)...); }, - [this](auto && ... param) { return RemoveName(std::forward(param)...); } - ); + [this](auto && ... param) { return RemoveName(std::forward(param)...); }); CameraObject::Register(m_table_objects); CameraObject::SetNameCallbacks( [this](auto && ... param) { return AddName(std::forward(param)...); }, - [this](auto && ... param) { return RemoveName(std::forward(param)...); } - ); + [this](auto && ... param) { return RemoveName(std::forward(param)...); }); Sink::Register(m_table_objects); Sink::SetNameCallbacks( [this](auto && ... param) { return AddName(std::forward(param)...); }, - [this](auto && ... param) { return RemoveName(std::forward(param)...); } - ); + [this](auto && ... param) { return RemoveName(std::forward(param)...); }); AIObject::Register(m_table_objects); AIObject::SetNameCallbacks( [this](auto && ... param) { return AddName(std::forward(param)...); }, - [this](auto && ... param) { return RemoveName(std::forward(param)...); } - ); + [this](auto && ... param) { return RemoveName(std::forward(param)...); } ); SoundSource::Register(m_table_objects); SoundSource::SetNameCallbacks( [this](auto && ... param) { return AddName(std::forward(param)...); }, - [this](auto && ... param) { return RemoveName(std::forward(param)...); } - ); + [this](auto && ... param) { return RemoveName(std::forward(param)...); }); Volume::Register(m_table_objects); Volume::SetNameCallbacks( [this](auto && ... param) { return AddName(std::forward(param)...); }, - [this](auto && ... param) { return RemoveName(std::forward(param)...); } - ); + [this](auto && ... param) { return RemoveName(std::forward(param)...); }); m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_ObjID, kObjIDs); m_handler.MakeReadOnlyTable(m_table_objects, ScriptReserved_LaraWeaponType, LaraWeaponTypeMap); @@ -148,11 +141,9 @@ ObjectsHandler::ObjectsHandler(sol::state* lua, sol::table & parent) : void ObjectsHandler::TestCollidingObjects() { - // remove any items which can't collide + // Remove any items which can't collide. for (const auto id : m_collidingItemsToRemove) - { m_collidingItems.erase(id); - } m_collidingItemsToRemove.clear(); for (const auto idOne : m_collidingItems) @@ -160,7 +151,7 @@ void ObjectsHandler::TestCollidingObjects() auto item = &g_Level.Items[idOne]; if (!item->Callbacks.OnObjectCollided.empty()) { - //test against other moveables + // Test against other moveables. GetCollidedObjects(item, 0, true, CollidedItems, nullptr, 0); size_t i = 0; while (CollidedItems[i]) @@ -173,11 +164,9 @@ void ObjectsHandler::TestCollidingObjects() if (!item->Callbacks.OnRoomCollided.empty()) { - //test against room geometry + // Test against room geometry. if (TestItemRoomCollisionAABB(item)) - { g_GameScript->ExecuteFunction(item->Callbacks.OnRoomCollided, idOne); - } } } } @@ -187,18 +176,17 @@ void ObjectsHandler::AssignLara() m_table_objects.set(ScriptReserved_Lara, LaraObject(Lara.ItemNumber, true)); } - bool ObjectsHandler::NotifyKilled(ItemInfo* key) { auto it = m_moveables.find(key); if (std::end(m_moveables) != it) { for (auto& m : m_moveables[key]) - { m->Invalidate(); - } + return true; } + return false; } @@ -226,12 +214,10 @@ bool ObjectsHandler::RemoveMoveableFromMap(ItemInfo* key, Moveable* mov) auto& set = m_moveables[key]; bool erased = static_cast(set.erase(mov)); if (erased && set.empty()) - { erased = erased && static_cast(m_moveables.erase(key)); - } + return erased; } + return false; } - - diff --git a/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.h b/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.h index 9e6db77b2..10517884d 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.h +++ b/TombEngine/Scripting/Internal/TEN/Objects/ObjectsHandler.h @@ -1,6 +1,7 @@ #pragma once #include #include + #include "LuaHandler.h" #include "Objects/ScriptInterfaceObjectsHandler.h" #include "Objects/Moveable/MoveableObject.h" @@ -9,7 +10,6 @@ class ObjectsHandler : public ScriptInterfaceObjectsHandler { - public: ObjectsHandler::ObjectsHandler(sol::state* lua, sol::table& parent); @@ -56,7 +56,7 @@ private: void AssignLara() override; template - std::unique_ptr GetByName(std::string const& name) + std::unique_ptr GetByName(const std::string& name) { if (!ScriptAssertF(m_nameMap.find(name) != m_nameMap.end(), "{} name not found: {}", S, name)) return nullptr; @@ -100,21 +100,21 @@ private: return items; } - [[nodiscard]] short GetIndexByName(std::string const& name) const override + [[nodiscard]] short GetIndexByName(const std::string& name) const override { return std::get(m_nameMap.at(name)); } - bool AddName(std::string const& key, VarMapVal val) override + bool AddName(const std::string& key, VarMapVal val) override { if (key.empty()) return false; - auto p = std::pair{ key, val }; + auto p = std::pair< const std::string&, VarMapVal>{ key, val }; return m_nameMap.insert(p).second; } - bool RemoveName(std::string const& key) + bool RemoveName(const std::string& key) { return m_nameMap.erase(key); } @@ -124,5 +124,3 @@ private: m_nameMap.clear(); } }; - - From 6bebb1acd07a7b3fc0a1637b2c9367d4b3eaac2e Mon Sep 17 00:00:00 2001 From: Sezz Date: Fri, 16 Dec 2022 21:13:34 +1100 Subject: [PATCH 02/19] Maybe fix vertical position when shimmying around corners of steep slopes --- TombEngine/Game/Lara/lara_tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TombEngine/Game/Lara/lara_tests.cpp b/TombEngine/Game/Lara/lara_tests.cpp index 212faeeea..ca7f1c0d2 100644 --- a/TombEngine/Game/Lara/lara_tests.cpp +++ b/TombEngine/Game/Lara/lara_tests.cpp @@ -635,7 +635,7 @@ CornerType TestLaraHangCorner(ItemInfo* item, CollisionInfo* coll, float testAng // Store next position item->Pose = cornerResult.RealPositionResult; lara->NextCornerPos.Position.x = item->Pose.Position.x; - lara->NextCornerPos.Position.y = GetCollision(item, item->Pose.Orientation.y, coll->Setup.Radius * 2, -(abs(bounds.Y1) + LARA_HEADROOM)).Position.Floor + abs(bounds.Y1); + lara->NextCornerPos.Position.y = GetCollision(item, item->Pose.Orientation.y, coll->Setup.Radius * 1.25f, -(abs(bounds.Y1) + LARA_HEADROOM)).Position.Floor + abs(bounds.Y1); lara->NextCornerPos.Position.z = item->Pose.Position.z; lara->NextCornerPos.Orientation.y = item->Pose.Orientation.y; lara->Control.MoveAngle = item->Pose.Orientation.y; From d277cc5a16bb707d0e0e32f9f7bfff7525904219 Mon Sep 17 00:00:00 2001 From: Kubsy Date: Fri, 16 Dec 2022 10:30:18 +0000 Subject: [PATCH 03/19] Update Changes.txt --- Documentation/Changes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/Changes.txt b/Documentation/Changes.txt index 94b1911e6..0e8db6c70 100644 --- a/Documentation/Changes.txt +++ b/Documentation/Changes.txt @@ -20,6 +20,7 @@ Version 1.0.4 - Fix crash when attacking. * Fix TR5 Autogun Rotation. * Fix Choppy camera movement. +* Fix Lara's vertical position when shimmying around steep slope corners. * Fix legacy pickup triggers not working in certain cases. * Fix crawl pickup not actually doing any pickups. * Fix demigod and harpy shooting in incorrect directions. From 8e1aca9b7cbd395f84b6e827cf2cfa013dd393c2 Mon Sep 17 00:00:00 2001 From: Nemoel-Tomo Date: Fri, 16 Dec 2022 11:48:19 +0100 Subject: [PATCH 04/19] Tr4 SAS fix (#908) * fix-SAS not final * fixed SAS fixed grenades and AI GUARD and AI MODIFY. * there are no changes in this file * removed all changes in box.cpp * fixed 2 errors * Fix flag errors and formatting changes * Revert "Fix flag errors and formatting changes" This reverts commit 0c685e0032205fd012304467055c024a8b956347. * Restore braces * Tidy up SAS * Organise * Remove commented block Co-authored-by: Sezz --- TombEngine/Game/control/box.cpp | 3 +- TombEngine/Game/effects/tomb4fx.cpp | 92 +-- TombEngine/Objects/TR4/Entity/tr4_sas.cpp | 655 +++++++++++----------- TombEngine/Objects/TR4/Entity/tr4_sas.h | 10 +- 4 files changed, 335 insertions(+), 425 deletions(-) diff --git a/TombEngine/Game/control/box.cpp b/TombEngine/Game/control/box.cpp index ca9d96c94..ab74429b9 100644 --- a/TombEngine/Game/control/box.cpp +++ b/TombEngine/Game/control/box.cpp @@ -1292,8 +1292,7 @@ void GetAITarget(CreatureInfo* creature) abs(enemy->Pose.Position.y - item->Pose.Position.y) < REACHED_GOAL_RADIUS && abs(enemy->Pose.Position.z - item->Pose.Position.z) < REACHED_GOAL_RADIUS) { - TestTriggers(enemy, true); - + TestTriggers(enemy, true); creature->ReachedGoal = true; creature->Enemy = LaraItem; item->AIBits &= ~(AMBUSH /* | MODIFY*/); diff --git a/TombEngine/Game/effects/tomb4fx.cpp b/TombEngine/Game/effects/tomb4fx.cpp index 9ca3001e3..c46026c2d 100644 --- a/TombEngine/Game/effects/tomb4fx.cpp +++ b/TombEngine/Game/effects/tomb4fx.cpp @@ -21,6 +21,7 @@ #include "Specific/setup.h" using namespace TEN::Effects::Environment; +using namespace TEN::Effects::Smoke; using namespace TEN::Floordata; using namespace TEN::Math; using std::vector; @@ -620,96 +621,7 @@ byte TriggerGunSmoke_SubFunction(LaraWeaponType weaponType) void TriggerGunSmoke(int x, int y, int z, short xv, short yv, short zv, byte initial, LaraWeaponType weaponType, byte count) { - /* - SMOKE_SPARKS* spark; - - spark = &SmokeSparks[GetFreeSmokeSpark()]; - spark->on = true; - spark->sShade = 0; - spark->dShade = (count << 2); - spark->colFadeSpeed = 4; - spark->fadeToBlack = 32 - (initial << 4); - spark->life = (GetRandomControl() & 3) + 40; - spark->sLife = spark->life; - - if (weaponType == LaraWeaponType::Pistol || weaponType == LaraWeaponType::Revolver || weaponType == LaraWeaponType::Uzi) - { - if (spark->dShade > 64) - spark->dShade = 64; - } - - spark->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE; - spark->x = x + (GetRandomControl() & 31) - 16; - spark->y = y + (GetRandomControl() & 31) - 16; - spark->z = z + (GetRandomControl() & 31) - 16; - - if (initial) - { - spark->xVel = ((GetRandomControl() & 1023) - 512) + xv; - spark->yVel = ((GetRandomControl() & 1023) - 512) + yv; - spark->zVel = ((GetRandomControl() & 1023) - 512) + zv; - } - else - { - float f = (frand() * 6) - 3; - spark->xVel = (frand() * 6) - 3; - spark->yVel = (frand() * 6) - 3; - spark->zVel = (frand() * 6) - 3; - } - - spark->friction = 4; - - if (GetRandomControl() & 1) - { - if (g_Level.Rooms[LaraItem->roomNumber].flags & ENV_FLAG_WIND) - spark->flags = SP_ROTATE | SP_WIND; - else - spark->flags = SP_ROTATE; - - spark->rotAng = GetRandomControl() & 0xFFF; - - if (GetRandomControl() & 1) - spark->rotAdd = -(GetRandomControl() & 0x0F) - 16; - else - spark->rotAdd = (GetRandomControl() & 0x0F) + 16; - } - else if (g_Level.Rooms[LaraItem->roomNumber].flags & ENV_FLAG_WIND) - { - spark->flags = SP_WIND; - } - else - { - spark->flags = SP_NONE; - } - float gravity = frand() * 1.25f; - spark->gravity = gravity; - spark->maxYvel = frand() * 16; - - byte size = ((GetRandomControl() & 0x0F) + 24); // -TriggerGunSmoke_SubFunction(weaponType); - - if (initial) - { - spark->sSize = size >> 1; - spark->size = size >> 1; - spark->dSize = (size << 1) + 8; - } - else - { - spark->sSize = size >> 2; - spark->size = size >> 2; - spark->dSize = size; - } - - /*if (gfLevelFlags & 0x20 && LaraItem->roomNumber == gfMirrorRoom) // 0x20 = GF_MIRROR_ENABLED - { - spark->mirror = 1; - } - else - { - spark->mirror = 0; - }*/ - TEN::Effects::Smoke::TriggerGunSmokeParticles(x, y, z, xv, yv, zv, initial, weaponType, count); - + TriggerGunSmokeParticles(x, y, z, xv, yv, zv, initial, weaponType, count); } void TriggerShatterSmoke(int x, int y, int z) diff --git a/TombEngine/Objects/TR4/Entity/tr4_sas.cpp b/TombEngine/Objects/TR4/Entity/tr4_sas.cpp index 612c6dcd3..c6d332971 100644 --- a/TombEngine/Objects/TR4/Entity/tr4_sas.cpp +++ b/TombEngine/Objects/TR4/Entity/tr4_sas.cpp @@ -3,6 +3,7 @@ #include "Game/animation.h" #include "Game/collision/collide_item.h" +#include "Game/collision/collide_room.h" #include "Game/control/box.h" #include "Game/control/control.h" #include "Game/control/volume.h" @@ -15,36 +16,40 @@ #include "Game/Lara/lara_helpers.h" #include "Game/Lara/lara_one_gun.h" #include "Game/people.h" +#include "Game/misc.h" +#include "Math/Math.h" #include "Specific/Input/Input.h" #include "Specific/level.h" -#include "Math/Random.h" #include "Specific/setup.h" -using namespace TEN::Input; -using namespace TEN::Math::Random; using namespace TEN::Control::Volumes; +using namespace TEN::Input; +using namespace TEN::Math; namespace TEN::Entities::TR4 { - const auto SasGunBite = BiteInfo(Vector3(0.0f, 300.0f, 64.0f), 7); + constexpr auto SAS_SHOT_DAMAGE = 15; + + constexpr auto SAS_WALK_RANGE = SQUARE(BLOCK(2)); + constexpr auto SAS_SHOOT_RANGE = SQUARE(BLOCK(3)); + + const auto SasGunBite = BiteInfo(Vector3(0.0f, 550.0f, 84.0f), 7); const auto SasDragBodyPosition = Vector3i(0, 0, -460); const auto SasDragBounds = ObjectCollisionBounds { GameBoundingBox( - -BLOCK(1.0f / 4), BLOCK(1.0f / 4), + -BLOCK(0.25f), BLOCK(0.25f), -100, 100, - -BLOCK(1.0f / 2), -460 - ), + -BLOCK(0.5f), -460), std::pair( EulerAngles(ANGLE(-10.0f), ANGLE(-30.0f), 0), - EulerAngles(ANGLE(10.0f), ANGLE(30.0f), 0) - ) + EulerAngles(ANGLE(10.0f), ANGLE(30.0f), 0)) }; enum SasState { - SAS_STATE_NONE = 0, + // No state 0. SAS_STATE_IDLE = 1, SAS_STATE_WALK = 2, SAS_STATE_RUN = 3, @@ -100,14 +105,28 @@ namespace TEN::Entities::TR4 void InitialiseSas(short itemNumber) { - auto* item = &g_Level.Items[itemNumber]; + auto& item = g_Level.Items[itemNumber]; ClearItem(itemNumber); + SetAnimation(&item, SAS_ANIM_STAND); + } - item->Animation.AnimNumber = Objects[item->ObjectNumber].animIndex + SAS_ANIM_STAND; - item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase; - item->Animation.TargetState = SAS_STATE_IDLE; - item->Animation.ActiveState = SAS_STATE_IDLE; + void InitialiseInjuredSas(short itemNumber) + { + auto& item = g_Level.Items[itemNumber]; + + if (item.TriggerFlags) + { + item.Animation.AnimNumber = Objects[item.ObjectNumber].animIndex; + item.Animation.TargetState = item.Animation.ActiveState = 1; + } + else + { + item.Animation.AnimNumber = Objects[item.ObjectNumber].animIndex + 3; + item.Animation.TargetState = item.Animation.ActiveState = 4; + } + + item.Animation.FrameNumber = g_Level.Anims[item.Animation.AnimNumber].frameBase; } void SasControl(short itemNumber) @@ -115,9 +134,9 @@ namespace TEN::Entities::TR4 if (!CreatureActive(itemNumber)) return; - auto* item = &g_Level.Items[itemNumber]; - auto* creature = (CreatureInfo*)item->Data; - auto* enemy = creature->Enemy; + auto& item = g_Level.Items[itemNumber]; + auto& creature = *(CreatureInfo*)item.Data; + auto& enemy = creature.Enemy; short tilt = 0; short angle = 0; @@ -126,233 +145,221 @@ namespace TEN::Entities::TR4 short joint2 = 0; // Handle SAS firing. - if (creature->FiredWeapon) + if (creature.FiredWeapon) { - auto pos = GetJointPosition(item, SasGunBite.meshNum, Vector3i(SasGunBite.Position)); + auto pos = GetJointPosition(&item, SasGunBite.meshNum, Vector3i(SasGunBite.Position)); TriggerDynamicLight(pos.x, pos.y, pos.z, 10, 24, 16, 4); - creature->FiredWeapon--; + creature.FiredWeapon--; } - if (item->HitPoints > 0) + if (item.HitPoints > 0) { - if (item->AIBits) - GetAITarget(creature); + if (item.AIBits) + GetAITarget(&creature); else - creature->Enemy = LaraItem; + creature.Enemy = LaraItem; AI_INFO AI; - CreatureAIInfo(item, &AI); + CreatureAIInfo(&item, &AI); - int distance = 0; + float distance2D = 0; int angle = 0; - if (creature->Enemy->IsLara()) + if (creature.Enemy->IsLara()) { angle = AI.angle; - distance = AI.distance; + distance2D = AI.distance; } else { - int dx = LaraItem->Pose.Position.x - item->Pose.Position.x; - int dz = LaraItem->Pose.Position.z - item->Pose.Position.z; - int ang = phd_atan(dz, dx) - item->Pose.Orientation.y; - distance = pow(dx, 2) + pow(dz, 2); + distance2D = Vector2::Distance( + Vector2(item.Pose.Position.x, item.Pose.Position.z), + Vector2(LaraItem->Pose.Position.x, LaraItem->Pose.Position.z)); } - GetCreatureMood(item, &AI, !creature->Enemy->IsLara()); + GetCreatureMood(&item, &AI, !creature.Enemy->IsLara()); // Vehicle handling if (Lara.Vehicle != NO_ITEM && AI.bite) - creature->Mood = MoodType::Escape; + creature.Mood = MoodType::Escape; - CreatureMood(item, &AI, !creature->Enemy->IsLara()); - angle = CreatureTurn(item, creature->MaxTurn); + CreatureMood(&item, &AI, !creature.Enemy->IsLara()); + angle = CreatureTurn(&item, creature.MaxTurn); - if (item->HitStatus) + if (item.HitStatus) AlertAllGuards(itemNumber); int angle1 = 0; int angle2 = 0; - switch (item->Animation.ActiveState) + switch (item.Animation.ActiveState) { case SAS_STATE_IDLE: - creature->MaxTurn = 0; - creature->Flags = 0; + creature.MaxTurn = 0; + creature.Flags = 0; joint2 = angle; - if (item->Animation.AnimNumber == Objects[item->ObjectNumber].animIndex + SAS_ANIM_WALK_TO_STAND) + if (item.Animation.AnimNumber == Objects[item.ObjectNumber].animIndex + SAS_ANIM_WALK_TO_STAND) { - if (abs(AI.angle) >= ANGLE(10.0f)) - { - if (AI.angle >= 0) - item->Pose.Orientation.y += ANGLE(10.0f); - else - item->Pose.Orientation.y -= ANGLE(10.0f); - } + if (abs(AI.angle) < ANGLE(10.0f)) + item.Pose.Orientation.y += AI.angle; + else if (AI.angle < 0) + item.Pose.Orientation.y -= ANGLE(10.0f); else - item->Pose.Orientation.y += AI.angle; + item.Pose.Orientation.y += ANGLE(10.0f); } - else if (item->AIBits & MODIFY || Lara.Vehicle != NO_ITEM) + else if (item.AIBits & MODIFY || Lara.Vehicle != NO_ITEM) { - if (abs(AI.angle) >= ANGLE(2.0f)) - { - if (AI.angle >= 0) - item->Pose.Orientation.y += ANGLE(2.0f); - else - item->Pose.Orientation.y -= ANGLE(2.0f); - } + if (abs(AI.angle) < ANGLE(2.0f)) + item.Pose.Orientation.y += AI.angle; + else if (AI.angle < 0) + item.Pose.Orientation.y -= ANGLE(2.0f); else - item->Pose.Orientation.y += AI.angle; + item.Pose.Orientation.y += ANGLE(2.0f); } - if (item->AIBits & GUARD) + if (item.AIBits & GUARD) { - joint2 = AIGuard(creature); + joint2 = AIGuard(&creature); - if (!GetRandomControl()) + if (!(GetRandomControl() & 0xFF)) { - if (item->Animation.ActiveState == SAS_STATE_IDLE) - { - item->Animation.TargetState = SAS_STATE_WAIT; - break; - } - - item->Animation.TargetState = SAS_STATE_IDLE; + if (item.Animation.ActiveState == SAS_STATE_IDLE) + item.Animation.TargetState = SAS_STATE_WAIT; + else + item.Animation.TargetState = SAS_STATE_IDLE; } } - else if (!(item->AIBits & PATROL1) || - item->AIBits & MODIFY || - Lara.Vehicle != NO_ITEM) + else if (item.AIBits & PATROL1 && + item.AIBits != MODIFY && + Lara.Vehicle == NO_ITEM) { - if (Targetable(item, &AI)) + item.Animation.TargetState = SAS_STATE_WALK; + joint2 = 0; + } + else if (Targetable(&item, &AI)) + { + if (AI.distance >= SAS_SHOOT_RANGE && + AI.zoneNumber == AI.enemyZone) { - if (AI.distance < pow(SECTOR(3), 2) || - AI.zoneNumber != AI.enemyZone) - { - if (TestProbability(0.5f)) - item->Animation.TargetState = SAS_STATE_SIGHT_AIM; - else if (TestProbability(0.5f)) - item->Animation.TargetState = SAS_STATE_HOLD_AIM; - else - item->Animation.TargetState = SAS_STATE_KNEEL_AIM; - } - else if (!(item->AIBits & MODIFY)) - item->Animation.TargetState = SAS_STATE_WALK; + if (item.AIBits != MODIFY) + item.Animation.TargetState = SAS_STATE_WALK; + } + else if (Random::TestProbability(1 / 2.0f)) + { + item.Animation.TargetState = SAS_STATE_SIGHT_AIM; + } + else if (Random::TestProbability(1 / 2.0f)) + { + item.Animation.TargetState = SAS_STATE_HOLD_AIM; } else { - if (item->AIBits & MODIFY) - item->Animation.TargetState = SAS_STATE_IDLE; - else - { - if (creature->Mood == MoodType::Escape) - item->Animation.TargetState = SAS_STATE_RUN; - else - { - if ((creature->Alerted || - creature->Mood != MoodType::Bored) && - (!(item->AIBits & FOLLOW) || - !creature->ReachedGoal && - distance <= pow(SECTOR(2), 2))) - { - if (creature->Mood == MoodType::Bored || - AI.distance <= pow(SECTOR(2), 2)) - { - item->Animation.TargetState = SAS_STATE_WALK; - break; - } - item->Animation.TargetState = SAS_STATE_RUN; - } - else - item->Animation.TargetState = SAS_STATE_IDLE; - } - } + item.Animation.TargetState = SAS_STATE_KNEEL_AIM; + } + } + else if (item.AIBits == MODIFY) + { + item.Animation.TargetState = SAS_STATE_IDLE; + } + else if (creature.Mood == MoodType::Escape) + { + item.Animation.TargetState = SAS_STATE_RUN; + } + else if ((creature.Alerted || creature.Mood != MoodType::Bored) && + (!(item.AIBits & FOLLOW) || (!creature.ReachedGoal && distance2D <= SAS_WALK_RANGE))) + { + if (creature.Mood != MoodType::Bored && + AI.distance > SAS_WALK_RANGE) + { + item.Animation.TargetState = SAS_STATE_RUN; + } + else + { + item.Animation.TargetState = SAS_STATE_WALK; } } else { - item->Animation.TargetState = SAS_STATE_WALK; - joint2 = 0; + item.Animation.TargetState = SAS_STATE_IDLE; } break; case SAS_STATE_WAIT: - creature->MaxTurn = 0; - creature->Flags = 0; + creature.MaxTurn = 0; + creature.Flags = 0; joint2 = angle; - if (item->AIBits & GUARD) + if (item.AIBits & GUARD) { - joint2 = AIGuard(creature); + joint2 = AIGuard(&creature); - if (!GetRandomControl()) - item->Animation.TargetState = SAS_STATE_IDLE; + if (!(GetRandomControl() & 0xFF)) + item.Animation.TargetState = SAS_STATE_IDLE; } - else if (Targetable(item, &AI) || - creature->Mood != MoodType::Bored || + else if (Targetable(&item, &AI) || + creature.Mood == MoodType::Bored || !AI.ahead || - item->AIBits & MODIFY || + item.AIBits & MODIFY || Lara.Vehicle != NO_ITEM) { - item->Animation.TargetState = SAS_STATE_IDLE; + item.Animation.TargetState = SAS_STATE_IDLE; } break; case SAS_STATE_WALK: - creature->MaxTurn = ANGLE(5.0f); - creature->Flags = 0; + creature.MaxTurn = ANGLE(5.0f); + creature.Flags = 0; joint2 = angle; - if (item->AIBits & PATROL1) - item->Animation.TargetState = SAS_STATE_WALK; - else if (Lara.Vehicle == NO_ITEM || - !(item->AIBits & MODIFY) && - item->AIBits) + if (item.AIBits & PATROL1) { - if (creature->Mood == MoodType::Escape) - item->Animation.TargetState = SAS_STATE_RUN; + item.Animation.TargetState = SAS_STATE_WALK; + } + else if (Lara.Vehicle != NO_ITEM && + (item.AIBits == MODIFY || + !item.AIBits)) + { + item.Animation.TargetState = SAS_STATE_IDLE; + } + else if (creature.Mood == MoodType::Escape) + { + item.Animation.TargetState = SAS_STATE_RUN; + } + else if (item.AIBits & GUARD || + item.AIBits & FOLLOW && + (creature.ReachedGoal || + distance2D > SAS_WALK_RANGE)) + { + item.Animation.TargetState = SAS_STATE_IDLE; + } + else if (Targetable(&item, &AI)) + { + if (AI.distance >= SAS_SHOOT_RANGE && + AI.zoneNumber == AI.enemyZone) + { + item.Animation.TargetState = SAS_STATE_WALK_AIM; + } else { - if (item->AIBits & GUARD || - item->AIBits & FOLLOW && - (creature->ReachedGoal || - distance > pow(SECTOR(2), 2))) - { - item->Animation.TargetState = SAS_STATE_IDLE; - break; - } - if (Targetable(item, &AI)) - { - if (AI.distance < pow(SECTOR(3), 2) || - AI.enemyZone != AI.zoneNumber) - { - item->Animation.TargetState = SAS_STATE_IDLE; - break; - } - - item->Animation.TargetState = SAS_STATE_WALK_AIM; - } - else if (creature->Mood != MoodType::Bored) - { - if (AI.distance > pow(SECTOR(2), 2)) - item->Animation.TargetState = SAS_STATE_RUN; - } - else if (AI.ahead) - { - item->Animation.TargetState = SAS_STATE_IDLE; - break; - } + item.Animation.TargetState = SAS_STATE_IDLE; } } - else - item->Animation.TargetState = SAS_STATE_IDLE; + else if (creature.Mood != MoodType::Bored) + { + if (AI.distance > SAS_WALK_RANGE) + item.Animation.TargetState = SAS_STATE_RUN; + } + else if (AI.ahead) + { + item.Animation.TargetState = SAS_STATE_IDLE; + } break; case SAS_STATE_RUN: - creature->MaxTurn = ANGLE(10.0f); + creature.MaxTurn = ANGLE(10.0f); tilt = angle / 2; if (AI.ahead) @@ -360,35 +367,30 @@ namespace TEN::Entities::TR4 if (Lara.Vehicle != NO_ITEM) { - if (item->AIBits & MODIFY || !item->AIBits) + if (item.AIBits == MODIFY || !item.AIBits) { - item->Animation.TargetState = SAS_STATE_WAIT; + item.Animation.TargetState = SAS_STATE_WALK; break; } } - if (item->AIBits & GUARD || - item->AIBits & FOLLOW && - (creature->ReachedGoal || - distance > pow(SECTOR(2), 2))) + if (item.AIBits & GUARD || + (item.AIBits & FOLLOW && (creature.ReachedGoal || distance2D > SAS_WALK_RANGE))) { - item->Animation.TargetState = SAS_STATE_WALK; - break; + item.Animation.TargetState = SAS_STATE_WALK; } - - if (creature->Mood != MoodType::Escape) + else if (creature.Mood != MoodType::Escape) { - if (Targetable(item, &AI)) - item->Animation.TargetState = SAS_STATE_WALK; - else + if (Targetable(&item, &AI)) { - if (creature->Mood != MoodType::Bored || - creature->Mood == MoodType::Stalk && - item->AIBits & FOLLOW && - AI.distance < pow(SECTOR(2), 2)) - { - item->Animation.TargetState = SAS_STATE_WALK; - } + item.Animation.TargetState = SAS_STATE_WALK; + } + else if (creature.Mood == MoodType::Bored || + (creature.Mood == MoodType::Stalk && + !(item.AIBits & FOLLOW) && + AI.distance < SAS_WALK_RANGE)) + { + item.Animation.TargetState = SAS_STATE_WALK; } } @@ -397,42 +399,52 @@ namespace TEN::Entities::TR4 case SAS_STATE_SIGHT_AIM: case SAS_STATE_HOLD_AIM: case SAS_STATE_KNEEL_AIM: - creature->Flags = 0; + creature.Flags = 0; if (AI.ahead) { joint0 = AI.angle; joint1 = AI.xAngle; - if (Targetable(item, &AI)) + if (Targetable(&item, &AI)) { - if (item->Animation.ActiveState == SAS_STATE_SIGHT_AIM) - item->Animation.TargetState = SAS_STATE_SIGHT_SHOOT; - else if (item->Animation.ActiveState == SAS_STATE_KNEEL_AIM) - item->Animation.TargetState = SAS_STATE_KNEEL_SHOOT; - else if (TestProbability(0.5f)) - item->Animation.TargetState = SAS_STATE_HOLD_SHOOT; + if (item.Animation.ActiveState == SAS_STATE_SIGHT_AIM) + { + item.Animation.TargetState = SAS_STATE_SIGHT_SHOOT; + } + else if (item.Animation.ActiveState == SAS_STATE_KNEEL_AIM) + { + item.Animation.TargetState = SAS_STATE_KNEEL_SHOOT; + } + else if (Random::TestProbability(1 / 2.0f)) + { + item.Animation.TargetState = SAS_STATE_HOLD_SHOOT; + } else - item->Animation.TargetState = SAS_STATE_HOLD_PREPARE_GRENADE; + { + item.Animation.TargetState = SAS_STATE_HOLD_PREPARE_GRENADE; + } } else - item->Animation.TargetState = SAS_STATE_IDLE; + { + item.Animation.TargetState = SAS_STATE_IDLE; + } } break; case SAS_STATE_WALK_AIM: - creature->Flags = 0; + creature.Flags = 0; if (AI.ahead) { joint0 = AI.angle; joint1 = AI.xAngle; - if (Targetable(item, &AI)) - item->Animation.TargetState = SAS_STATE_WALK_SHOOT; + if (Targetable(&item, &AI)) + item.Animation.TargetState = SAS_STATE_WALK_SHOOT; else - item->Animation.TargetState = SAS_STATE_WALK; + item.Animation.TargetState = SAS_STATE_WALK; } break; @@ -454,7 +466,7 @@ namespace TEN::Entities::TR4 joint0 = AI.angle; joint1 = AI.xAngle; - if (AI.distance > pow(SECTOR(3), 2)) + if (AI.distance > SAS_SHOOT_RANGE) { angle2 = sqrt(AI.distance) + AI.xAngle - ANGLE(5.6f); joint1 = angle2; @@ -466,9 +478,9 @@ namespace TEN::Entities::TR4 angle2 = 0; } - if (item->Animation.FrameNumber == g_Level.Anims[item->Animation.AnimNumber].frameBase + 20) + if (item.Animation.FrameNumber == (g_Level.Anims[item.Animation.AnimNumber].frameBase + 20)) { - if (!creature->Enemy->Animation.Velocity.z) + if (!creature.Enemy->Animation.Velocity.z) { angle1 += (GetRandomControl() & 0x1FF) - 256; angle2 += (GetRandomControl() & 0x1FF) - 256; @@ -478,8 +490,8 @@ namespace TEN::Entities::TR4 SasFireGrenade(item, angle2, angle1); - if (Targetable(item, &AI)) - item->Animation.TargetState = SAS_STATE_HOLD_PREPARE_GRENADE; + if (Targetable(&item, &AI)) + item.Animation.TargetState = SAS_STATE_HOLD_PREPARE_GRENADE; } break; @@ -488,18 +500,18 @@ namespace TEN::Entities::TR4 case SAS_STATE_KNEEL_SHOOT: case SAS_STATE_SIGHT_SHOOT: case SAS_STATE_WALK_SHOOT: - if (item->Animation.ActiveState == SAS_STATE_HOLD_SHOOT || - item->Animation.ActiveState == SAS_STATE_KNEEL_SHOOT) + if (item.Animation.ActiveState == SAS_STATE_HOLD_SHOOT || + item.Animation.ActiveState == SAS_STATE_KNEEL_SHOOT) { - if (item->Animation.TargetState != SAS_STATE_IDLE && - item->Animation.TargetState != SAS_STATE_KNEEL_STOP && - (creature->Mood == MoodType::Escape || - !Targetable(item, &AI))) + if (item.Animation.TargetState != SAS_STATE_IDLE && + item.Animation.TargetState != SAS_STATE_KNEEL_STOP && + (creature.Mood == MoodType::Escape || + !Targetable(&item, &AI))) { - if (item->Animation.ActiveState == SAS_STATE_HOLD_SHOOT) - item->Animation.TargetState = SAS_STATE_IDLE; + if (item.Animation.ActiveState == SAS_STATE_HOLD_SHOOT) + item.Animation.TargetState = SAS_STATE_IDLE; else - item->Animation.TargetState = SAS_STATE_KNEEL_STOP; + item.Animation.TargetState = SAS_STATE_KNEEL_STOP; } } @@ -509,20 +521,22 @@ namespace TEN::Entities::TR4 joint1 = AI.xAngle; } - if (creature->Flags) - creature->Flags -= 1; + if (creature.Flags) + { + creature.Flags -= 1; + } else { - ShotLara(item, &AI, SasGunBite, joint0, 15); - creature->Flags = 5; - creature->FiredWeapon = 3; + ShotLara(&item, &AI, SasGunBite, joint0, SAS_SHOT_DAMAGE); + creature.FiredWeapon = 3; + creature.Flags = 5; } break; case SAS_STATE_BLIND: - if (!FlashGrenadeAftershockTimer && !(GetRandomControl() & 0x7F)) - item->Animation.TargetState = SAS_STATE_WAIT; + if (!FlashGrenadeAftershockTimer && !(GetRandomControl() & 0x7F)) // TODO: This is a probabliity of roughly 0.998f. + item.Animation.TargetState = SAS_STATE_WAIT; break; @@ -531,169 +545,150 @@ namespace TEN::Entities::TR4 } if (FlashGrenadeAftershockTimer > 100 && - item->Animation.ActiveState != SAS_STATE_BLIND) + item.Animation.ActiveState != SAS_STATE_BLIND) { - item->Animation.AnimNumber = Objects[item->ObjectNumber].animIndex + SAS_ANIM_BLIND; - item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase + (GetRandomControl() & 7); - item->Animation.ActiveState = SAS_STATE_BLIND; - creature->MaxTurn = 0; + SetAnimation(&item, SAS_ANIM_BLIND, Random::GenerateInt(0, 8)); + creature.MaxTurn = 0; } } else { - if (item->Animation.ActiveState != SAS_STATE_DEATH) - { - item->Animation.AnimNumber = Objects[item->ObjectNumber].animIndex + SAS_ANIM_DEATH; - item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase; - item->Animation.ActiveState = SAS_STATE_DEATH; - } + if (item.Animation.ActiveState != SAS_STATE_DEATH) + SetAnimation(&item, SAS_ANIM_DEATH); } - CreatureTilt(item, tilt); - CreatureJoint(item, 0, joint0); - CreatureJoint(item, 1, joint1); - CreatureJoint(item, 2, joint2); + CreatureTilt(&item, tilt); + CreatureJoint(&item, 0, joint0); + CreatureJoint(&item, 1, joint1); + CreatureJoint(&item, 2, joint2); CreatureAnimation(itemNumber, angle, 0); } - void SasFireGrenade(ItemInfo* item, short angle1, short angle2) - { - short itemNumber = CreateItem(); - if (itemNumber != NO_ITEM) - { - auto* grenadeItem = &g_Level.Items[itemNumber]; - - grenadeItem->Color = Vector4(0.5f, 0.5f, 0.5f, 1.0f); - grenadeItem->ObjectNumber = ID_GRENADE; - grenadeItem->RoomNumber = item->RoomNumber; - - auto pos = GetJointPosition(item, SasGunBite.meshNum, Vector3i(SasGunBite.Position)); - grenadeItem->Pose.Position = pos; - - auto probe = GetCollision(pos.x, pos.y, pos.z, grenadeItem->RoomNumber); - grenadeItem->RoomNumber = probe.RoomNumber; - - if (probe.Position.Floor < grenadeItem->Pose.Position.y) - { - grenadeItem->Pose.Position = Vector3i(item->Pose.Position.x, probe.Position.Floor, item->Pose.Position.z); - grenadeItem->RoomNumber = item->RoomNumber; - } - - for (int i = 0; i < 5; i++) - TriggerGunSmoke(pos.x, pos.y, pos.z, 0, 0, 0, 1, LaraWeaponType::GrenadeLauncher, 32); - - InitialiseItem(itemNumber); - - grenadeItem->Pose.Orientation.x = angle1 + item->Pose.Orientation.x; - grenadeItem->Pose.Orientation.y = angle2 + item->Pose.Orientation.y; - grenadeItem->Pose.Orientation.z = 0; - - if (TestProbability(0.75f)) - grenadeItem->ItemFlags[0] = (int)GrenadeType::Normal; - else - grenadeItem->ItemFlags[0] = (int)GrenadeType::Super; - - grenadeItem->Animation.ActiveState = grenadeItem->Pose.Orientation.x; - grenadeItem->Animation.TargetState = grenadeItem->Pose.Orientation.y; - grenadeItem->Animation.RequiredState = 0; - grenadeItem->Animation.Velocity.z = 128; - grenadeItem->Animation.Velocity.y = -128 * phd_sin(grenadeItem->Pose.Orientation.x); - grenadeItem->HitPoints = 120; - grenadeItem->ItemFlags[2] = 1; - - AddActiveItem(itemNumber); - } - } - - void InitialiseInjuredSas(short itemNumber) - { - auto* item = &g_Level.Items[itemNumber]; - - if (item->TriggerFlags) - { - item->Animation.AnimNumber = Objects[item->ObjectNumber].animIndex; - item->Animation.TargetState = item->Animation.ActiveState = 1; - } - else - { - item->Animation.AnimNumber = Objects[item->ObjectNumber].animIndex + 3; - item->Animation.TargetState = item->Animation.ActiveState = 4; - } - - item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase; - } - void InjuredSasControl(short itemNumber) { - auto* item = &g_Level.Items[itemNumber]; + auto& item = g_Level.Items[itemNumber]; - if (item->Animation.ActiveState == 1) + if (item.Animation.ActiveState == 1) { - if (TestProbability(1.0f / 128)) + if (Random::TestProbability(1 / 128.0f)) { - item->Animation.TargetState = 2; - AnimateItem(item); + item.Animation.TargetState = 2; + AnimateItem(&item); } else if (!(byte)GetRandomControl()) - item->Animation.TargetState = 3; + { + item.Animation.TargetState = 3; + } } - else if (item->Animation.ActiveState == 4 && - TestProbability(1.0f / 128)) + else if (item.Animation.ActiveState == 4 && + Random::TestProbability(1 / 128.0f)) { - item->Animation.TargetState = 5; - AnimateItem(item); + item.Animation.TargetState = 5; + AnimateItem(&item); } else - AnimateItem(item); + { + AnimateItem(&item); + } } void SasDragBlokeCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* coll) { - auto* item = &g_Level.Items[itemNumber]; - auto* lara = GetLaraInfo(laraItem); + auto& item = g_Level.Items[itemNumber]; + auto& player = *GetLaraInfo(laraItem); if ((IsHeld(In::Action) && laraItem->Animation.ActiveState == LS_IDLE && laraItem->Animation.AnimNumber == LA_STAND_IDLE && - lara->Control.HandStatus == HandStatus::Free && + player.Control.HandStatus == HandStatus::Free && !laraItem->Animation.IsAirborne && - !(item->Flags & IFLAG_ACTIVATION_MASK)) || - lara->Control.IsMoving && lara->InteractedItem == itemNumber) + !(item.Flags & IFLAG_ACTIVATION_MASK)) || + player.Control.IsMoving && player.InteractedItem == itemNumber) { - if (TestLaraPosition(SasDragBounds, item, laraItem)) + if (TestLaraPosition(SasDragBounds, &item, laraItem)) { - if (MoveLaraPosition(SasDragBodyPosition, item, laraItem)) + if (MoveLaraPosition(SasDragBodyPosition, &item, laraItem)) { SetAnimation(laraItem, LA_DRAG_BODY); ResetLaraFlex(laraItem); - laraItem->Pose.Orientation.y = item->Pose.Orientation.y; - lara->Control.HandStatus = HandStatus::Busy; - lara->Control.IsMoving = false; + laraItem->Pose.Orientation.y = item.Pose.Orientation.y; + player.Control.HandStatus = HandStatus::Busy; + player.Control.IsMoving = false; AddActiveItem(itemNumber); - item->Flags |= IFLAG_ACTIVATION_MASK; - item->Status = ITEM_ACTIVE; + item.Flags |= IFLAG_ACTIVATION_MASK; + item.Status = ITEM_ACTIVE; } else - lara->InteractedItem = itemNumber; + { + player.InteractedItem = itemNumber; + } } } else { - if (item->Status != ITEM_ACTIVE) + if (item.Status != ITEM_ACTIVE) { ObjectCollision(itemNumber, laraItem, coll); return; } - if (!TestLastFrame(item)) + if (!TestLastFrame(&item)) return; - auto pos = GetJointPosition(item, 0); - TestTriggers(pos.x, pos.y, pos.z, item->RoomNumber, true); + auto pos = GetJointPosition(&item, 0); + TestTriggers(pos.x, pos.y, pos.z, item.RoomNumber, true); RemoveActiveItem(itemNumber); - item->Status = ITEM_DEACTIVATED; + item.Status = ITEM_DEACTIVATED; } } + + void SasFireGrenade(ItemInfo& item, short angle1, short angle2) + { + short itemNumber = CreateItem(); + if (itemNumber == NO_ITEM) + return; + + auto grenadeItem = &g_Level.Items[itemNumber]; + + grenadeItem->Color = Vector4(0.5f, 0.5f, 0.5f, 1.0f); + grenadeItem->ObjectNumber = ID_GRENADE; + grenadeItem->RoomNumber = item.RoomNumber; + + auto pos = GetJointPosition(&item, SasGunBite.meshNum, Vector3i(SasGunBite.Position)); + grenadeItem->Pose.Position = pos; + + auto floorHeight = GetCollision(pos.x, pos.y, pos.z, grenadeItem->RoomNumber).Position.Floor; + if (floorHeight < pos.y) + { + grenadeItem->Pose.Position = Vector3i(item.Pose.Position.x, pos.y, item.Pose.Position.z); + grenadeItem->RoomNumber = item.RoomNumber; + } + + for (int i = 0; i < 5; i++) + TriggerGunSmoke(pos.x, pos.y, pos.z, 0, 0, 0, 1, LaraWeaponType::GrenadeLauncher, 32); + + InitialiseItem(itemNumber); + + grenadeItem->Pose.Orientation = EulerAngles( + angle1 + item.Pose.Orientation.x, + angle2 + item.Pose.Orientation.y, + 0); + grenadeItem->Animation.Velocity.y = -128 * phd_sin(grenadeItem->Pose.Orientation.x); + grenadeItem->Animation.Velocity.z = 128; + grenadeItem->Animation.ActiveState = grenadeItem->Pose.Orientation.x; + grenadeItem->Animation.TargetState = grenadeItem->Pose.Orientation.y; + grenadeItem->Animation.RequiredState = 0; + + if (Random::TestProbability(3 / 4.0f)) + grenadeItem->ItemFlags[0] = (int)ProjectileType::Grenade; + else + grenadeItem->ItemFlags[0] = (int)ProjectileType::FragGrenade; + + grenadeItem->HitPoints = 120; + grenadeItem->ItemFlags[2] = 1; + + AddActiveItem(itemNumber); + } } diff --git a/TombEngine/Objects/TR4/Entity/tr4_sas.h b/TombEngine/Objects/TR4/Entity/tr4_sas.h index 3ee4f90db..badcea359 100644 --- a/TombEngine/Objects/TR4/Entity/tr4_sas.h +++ b/TombEngine/Objects/TR4/Entity/tr4_sas.h @@ -1,12 +1,16 @@ #pragma once -#include "Game/collision/collide_room.h" + +struct CollisionInfo; +struct ItemInfo; namespace TEN::Entities::TR4 { void InitialiseSas(short itemNumber); - void SasControl(short itemNumber); void InitialiseInjuredSas(short itemNumber); + + void SasControl(short itemNumber); void InjuredSasControl(short itemNumber); + void SasDragBlokeCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* coll); - void SasFireGrenade(ItemInfo* item, short angle1, short angle2); + void SasFireGrenade(ItemInfo& item, short angle1, short angle2); } From a8ba3b8e6e06cbd3d3074b4159a1be2b71b73614 Mon Sep 17 00:00:00 2001 From: Kubsy Date: Fri, 16 Dec 2022 10:53:22 +0000 Subject: [PATCH 05/19] Update Changes.txt --- Documentation/Changes.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/Changes.txt b/Documentation/Changes.txt index 0e8db6c70..08387b03e 100644 --- a/Documentation/Changes.txt +++ b/Documentation/Changes.txt @@ -18,6 +18,9 @@ Version 1.0.4 - Restored spark effects. - Can destroy statics in shatter slots. - Fix crash when attacking. +* SAS fix: + - Fix grenade shooting + - Fix AI_MODIFY and AI_GUARD for SAS * Fix TR5 Autogun Rotation. * Fix Choppy camera movement. * Fix Lara's vertical position when shimmying around steep slope corners. From 8acdbf7cd53ada2a35e5167c6a869b2cd3b8f9c9 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri, 16 Dec 2022 13:26:10 +0200 Subject: [PATCH 06/19] Update volume.h --- TombEngine/Game/control/volume.h | 33 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/TombEngine/Game/control/volume.h b/TombEngine/Game/control/volume.h index 3bf958a99..8848e147d 100644 --- a/TombEngine/Game/control/volume.h +++ b/TombEngine/Game/control/volume.h @@ -37,25 +37,7 @@ namespace TEN::Control::Volumes int Timestamp = 0; }; -} -// TODO: Move into namespace and deal with errors. - struct TriggerVolume - { - bool Enabled = true; - int EventSetIndex = 0; - - std::string Name = {}; - VolumeType Type = VolumeType::Box; - - BoundingOrientedBox Box = BoundingOrientedBox(); - BoundingSphere Sphere = BoundingSphere(); - - std::vector StateQueue = {}; - }; - -namespace TEN::Control::Volumes -{ void TestVolumes(short roomNumber, const BoundingOrientedBox& box, VolumeActivatorFlags activatorFlag, VolumeActivator activator); void TestVolumes(short itemNumber, const CollisionSetup* coll = nullptr); void TestVolumes(short roomNumber, MESH_INFO* mesh); @@ -63,3 +45,18 @@ namespace TEN::Control::Volumes void InitialiseNodeScripts(); } + +// TODO: Move into namespace and deal with errors. +struct TriggerVolume +{ + bool Enabled = true; + int EventSetIndex = 0; + + std::string Name = {}; + VolumeType Type = VolumeType::Box; + + BoundingOrientedBox Box = BoundingOrientedBox(); + BoundingSphere Sphere = BoundingSphere(); + + std::vector StateQueue = {}; +}; \ No newline at end of file From 32336bc0360cc28ee1a51814ba7f0cdb04e523a7 Mon Sep 17 00:00:00 2001 From: Sezz Date: Fri, 16 Dec 2022 22:50:50 +1100 Subject: [PATCH 07/19] Add setup functions for recently modified entities --- TombEngine/Objects/TR1/Trap/DamoclesSword.cpp | 2 +- .../Objects/TR4/Entity/tr4_knight_templar.cpp | 19 +++ .../Objects/TR4/Entity/tr4_knight_templar.h | 3 + TombEngine/Objects/TR4/Entity/tr4_sas.cpp | 36 ++++ TombEngine/Objects/TR4/Entity/tr4_sas.h | 5 + TombEngine/Objects/TR4/Entity/tr4_setha.cpp | 16 ++ TombEngine/Objects/TR4/Entity/tr4_setha.h | 3 + TombEngine/Objects/TR4/tr4_objects.cpp | 158 +++++++----------- 8 files changed, 143 insertions(+), 99 deletions(-) diff --git a/TombEngine/Objects/TR1/Trap/DamoclesSword.cpp b/TombEngine/Objects/TR1/Trap/DamoclesSword.cpp index f1e0563c3..236f77f83 100644 --- a/TombEngine/Objects/TR1/Trap/DamoclesSword.cpp +++ b/TombEngine/Objects/TR1/Trap/DamoclesSword.cpp @@ -30,7 +30,7 @@ namespace TEN::Entities::Traps::TR1 object.initialise = InitialiseDamoclesSword; object.control = ControlDamoclesSword; object.collision = CollideDamoclesSword; - //object->shadowSize = UNIT_SHADOW; + object.shadowType = ShadowMode::All; } void InitialiseDamoclesSword(short itemNumber) diff --git a/TombEngine/Objects/TR4/Entity/tr4_knight_templar.cpp b/TombEngine/Objects/TR4/Entity/tr4_knight_templar.cpp index 2924a76b7..c3831c320 100644 --- a/TombEngine/Objects/TR4/Entity/tr4_knight_templar.cpp +++ b/TombEngine/Objects/TR4/Entity/tr4_knight_templar.cpp @@ -2,6 +2,7 @@ #include "Objects/TR4/Entity/tr4_knight_templar.h" #include "Game/animation.h" +#include "Game/collision/collide_item.h" #include "Game/control/box.h" #include "Game/effects/debris.h" #include "Game/effects/effects.h" @@ -56,6 +57,24 @@ namespace TEN::Entities::TR4 KTEMPLAR_ANIM_WALK_FORWARD_RIGHT_2 = 12 }; + void SetupKnightTemplar(ObjectInfo& object) + { + object.initialise = InitialiseKnightTemplar; + object.control = KnightTemplarControl; + object.collision = CreatureCollision; + object.shadowType = ShadowMode::All; + object.HitPoints = 15; + object.hitEffect = HIT_SMOKE; + object.pivotLength = 50; + object.radius = 128; + object.intelligent = true; + object.undead = true; + object.ZoneType = ZoneType::Basic; + + g_Level.Bones[object.boneIndex + 6 * 4] |= ROT_X | ROT_Y; + g_Level.Bones[object.boneIndex + 7 * 4] |= ROT_Y; + } + void InitialiseKnightTemplar(short itemNumber) { auto* item = &g_Level.Items[itemNumber]; diff --git a/TombEngine/Objects/TR4/Entity/tr4_knight_templar.h b/TombEngine/Objects/TR4/Entity/tr4_knight_templar.h index 4552f0da9..fbe26d43d 100644 --- a/TombEngine/Objects/TR4/Entity/tr4_knight_templar.h +++ b/TombEngine/Objects/TR4/Entity/tr4_knight_templar.h @@ -1,7 +1,10 @@ #pragma once +struct ObjectInfo; + namespace TEN::Entities::TR4 { + void SetupKnightTemplar(ObjectInfo& object); void InitialiseKnightTemplar(short itemNumber); void KnightTemplarControl(short itemNumber); } diff --git a/TombEngine/Objects/TR4/Entity/tr4_sas.cpp b/TombEngine/Objects/TR4/Entity/tr4_sas.cpp index c6d332971..fcfae73cd 100644 --- a/TombEngine/Objects/TR4/Entity/tr4_sas.cpp +++ b/TombEngine/Objects/TR4/Entity/tr4_sas.cpp @@ -18,6 +18,7 @@ #include "Game/people.h" #include "Game/misc.h" #include "Math/Math.h" +#include "Objects/Generic/Object/objects.h" #include "Specific/Input/Input.h" #include "Specific/level.h" #include "Specific/setup.h" @@ -103,6 +104,41 @@ namespace TEN::Entities::TR4 SAS_ANIM_BLIND_TO_STAND = 29 }; + void SetupSas(ObjectInfo& object) + { + object.initialise = InitialiseSas; + object.control = SasControl; + object.collision = CreatureCollision; + object.shadowType = ShadowMode::All; + object.biteOffset = 10; + object.HitPoints = 40; + object.hitEffect = HIT_BLOOD; + object.pivotLength = 50; + object.radius = 102; + object.intelligent = true; + object.ZoneType = ZoneType::HumanClassic; + + g_Level.Bones[object.boneIndex] |= ROT_Y; + g_Level.Bones[object.boneIndex] |= ROT_X; + g_Level.Bones[object.boneIndex + 28 * 4] |= ROT_Y; + g_Level.Bones[object.boneIndex + 28 * 4] |= ROT_X; + } + + void SetupInjuredSas(ObjectInfo& object) + { + object.initialise = InitialiseInjuredSas; + object.control = InjuredSasControl; + object.collision = ObjectCollision; + object.hitEffect = HIT_BLOOD; + object.ZoneType = ZoneType::Basic; + } + + void SetupSasDraggableSas(ObjectInfo& object) + { + object.control = AnimatingControl; + object.collision = SasDragBlokeCollision; + } + void InitialiseSas(short itemNumber) { auto& item = g_Level.Items[itemNumber]; diff --git a/TombEngine/Objects/TR4/Entity/tr4_sas.h b/TombEngine/Objects/TR4/Entity/tr4_sas.h index badcea359..5886bd5eb 100644 --- a/TombEngine/Objects/TR4/Entity/tr4_sas.h +++ b/TombEngine/Objects/TR4/Entity/tr4_sas.h @@ -2,9 +2,14 @@ struct CollisionInfo; struct ItemInfo; +struct ObjectInfo; namespace TEN::Entities::TR4 { + void SetupSas(ObjectInfo& object); + void SetupInjuredSas(ObjectInfo& object); + void SetupSasDraggableSas(ObjectInfo& object); + void InitialiseSas(short itemNumber); void InitialiseInjuredSas(short itemNumber); diff --git a/TombEngine/Objects/TR4/Entity/tr4_setha.cpp b/TombEngine/Objects/TR4/Entity/tr4_setha.cpp index 5d193b9d7..0b9c76ab2 100644 --- a/TombEngine/Objects/TR4/Entity/tr4_setha.cpp +++ b/TombEngine/Objects/TR4/Entity/tr4_setha.cpp @@ -3,6 +3,7 @@ #include "Game/animation.h" #include "Game/camera.h" +#include "Game/collision/collide_item.h" #include "Game/collision/collide_room.h" #include "Game/control/control.h" #include "Game/effects/effects.h" @@ -108,6 +109,21 @@ namespace TEN::Entities::TR4 SETH_ANIM_HOVER_IDLE = 28 }; + void SetupSeth(ObjectInfo& object) + { + object.initialise = InitialiseSeth; + object.control = SethControl; + object.collision = CreatureCollision; + object.shadowType = ShadowMode::All; + object.HitPoints = 500; + object.hitEffect = HIT_NONE; + object.pivotLength = 50; + object.radius = 341; + object.intelligent = true; + object.undead = true; + object.ZoneType = ZoneType::Basic; + } + void InitialiseSeth(short itemNumber) { auto& item = g_Level.Items[itemNumber]; diff --git a/TombEngine/Objects/TR4/Entity/tr4_setha.h b/TombEngine/Objects/TR4/Entity/tr4_setha.h index 6d4bfa537..0b331fd5c 100644 --- a/TombEngine/Objects/TR4/Entity/tr4_setha.h +++ b/TombEngine/Objects/TR4/Entity/tr4_setha.h @@ -2,11 +2,14 @@ class Pose; struct ItemInfo; +struct ObjectInfo; namespace TEN::Entities::TR4 { + void SetupSeth(ObjectInfo& object); void InitialiseSeth(short itemNumber); void SethControl(short itemNumber); + void SethProjectileAttack(const Pose& pose, int roomNumber, int flags); void SethAttack(int itemNumber); void SethKillAttack(ItemInfo* item, ItemInfo* laraItem); diff --git a/TombEngine/Objects/TR4/tr4_objects.cpp b/TombEngine/Objects/TR4/tr4_objects.cpp index 2cec48b94..1bcabc275 100644 --- a/TombEngine/Objects/TR4/tr4_objects.cpp +++ b/TombEngine/Objects/TR4/tr4_objects.cpp @@ -10,76 +10,76 @@ #include "Specific/level.h" // Creatures -#include "tr4_enemy_jeep.h" -#include "tr4_ahmet.h" // OK -#include "tr4_baddy.h" // OK -#include "tr4_bat.h" // OK -#include "tr4_big_scorpion.h" // OK -#include "tr4_crocodile.h" // OK -#include "tr4_demigod.h" // OK -#include "tr4_guide.h" // OK -#include "tr4_harpy.h" // OK -#include "tr4_horseman.h" // OFF -#include "tr4_jean_yves.h" // OK -#include "tr4_knight_templar.h" // OK +#include "Objects/TR4/Entity/tr4_enemy_jeep.h" +#include "Objects/TR4/Entity/tr4_ahmet.h" // OK +#include "Objects/TR4/Entity/tr4_baddy.h" // OK +#include "Objects/TR4/Entity/tr4_bat.h" // OK +#include "Objects/TR4/Entity/tr4_big_scorpion.h" // OK +#include "Objects/TR4/Entity/tr4_crocodile.h" // OK +#include "Objects/TR4/Entity/tr4_demigod.h" // OK +#include "Objects/TR4/Entity/tr4_guide.h" // OK +#include "Objects/TR4/Entity/tr4_harpy.h" // OK +#include "Objects/TR4/Entity/tr4_horseman.h" // OFF +#include "Objects/TR4/Entity/tr4_jean_yves.h" // OK +#include "Objects/TR4/Entity/tr4_knight_templar.h" // OK +#include "Objects/TR4/Entity/tr4_lara_double.h" #include "Objects/TR4/Entity/tr4_beetle_swarm.h" -#include "tr4_mummy.h" // OK -#include "tr4_sas.h" // OK -#include "tr4_sentry_gun.h" // OK -#include "tr4_skeleton.h" // OK -#include "tr4_small_scorpion.h" // OK -#include "tr4_sphinx.h" // OK -#include "tr4_troops.h" // OK -#include "tr4_wild_boar.h" // OK -#include "tr4_wraith.h" // OFF -#include "tr4_baboon.h" // OK -#include "tr4_mutant.h" // OK -#include "tr4_locusts.h" // OK -#include "tr4_big_beetle.h" // OFF -#include "tr4_joby_spikes.h" -#include "tr4_mapper.h" -#include "tr4_moving_blade.h" -#include "tr4_element_puzzle.h" -#include "tr4_von_croy.h" -#include "tr4_hammerhead.h" -#include "tr4_dog.h" -#include "tr4_hammer.h" +#include "Objects/TR4/Entity/tr4_mummy.h" // OK +#include "Objects/TR4/Entity/tr4_sas.h" // OK +#include "Objects/TR4/Entity/tr4_sentry_gun.h" // OK +#include "Objects/TR4/Entity/tr4_skeleton.h" // OK +#include "Objects/TR4/Entity/tr4_small_scorpion.h" // OK +#include "Objects/TR4/Entity/tr4_sphinx.h" // OK +#include "Objects/TR4/Entity/tr4_troops.h" // OK +#include "Objects/TR4/Entity/tr4_wild_boar.h" // OK +#include "Objects/TR4/Entity/tr4_wraith.h" // OFF +#include "Objects/TR4/Entity/tr4_baboon.h" // OK +#include "Objects/TR4/Entity/tr4_mutant.h" // OK +#include "Objects/TR4/Entity/tr4_big_beetle.h" // OFF +#include "Objects/TR4/Entity/tr4_von_croy.h" +#include "Objects/TR4/Entity/tr4_hammerhead.h" +#include "Objects/TR4/Entity/tr4_dog.h" +#include "Objects/TR4/Entity/tr4_setha.h" // Objects -#include "tr4_sarcophagus.h" -#include "tr4_senet.h" +#include "Objects/TR4/Object/tr4_element_puzzle.h" +#include "Objects/TR4/Object/tr4_mapper.h" +#include "Objects/TR4/Object/tr4_sarcophagus.h" +#include "Objects/TR4/Object/tr4_senet.h" #include "Objects/TR4/Object/tr4_clockwork_beetle.h" -#include "tr4_obelisk.h" - -// Puzzles -#include "tr4_scales.h" +#include "Objects/TR4/Object/tr4_obelisk.h" +#include "Objects/TR4/Object/tr4_scales.h" // Switches // Traps -#include "tr4_birdblade.h" -#include "tr4_blade.h" -#include "tr4_catwalkblade.h" -#include "tr4_chain.h" -#include "tr4_fourblades.h" -#include "tr4_mine.h" -#include "tr4_plinthblade.h" -#include "tr4_plough.h" -#include "tr4_sethblade.h" -#include "tr4_slicerdicer.h" -#include "tr4_spikeball.h" -#include "tr4_spikywall.h" -#include "tr4_spikyceiling.h" -#include "tr4_stargate.h" -#include "tr4_cog.h" -#include "tr4_lara_double.h" -#include "tr4_setha.h" -#include "tr4_teethspike.h" +#include "Objects/TR4/Trap/tr4_birdblade.h" +#include "Objects/TR4/Trap/tr4_blade.h" +#include "Objects/TR4/Trap/tr4_catwalkblade.h" +#include "Objects/TR4/Trap/tr4_chain.h" +#include "Objects/TR4/Trap/tr4_fourblades.h" +#include "Objects/TR4/Trap/tr4_hammer.h" +#include "Objects/TR4/Trap/tr4_joby_spikes.h" +#include "Objects/TR4/Trap/tr4_mine.h" +#include "Objects/TR4/Trap/tr4_moving_blade.h" +#include "Objects/TR4/Trap/tr4_plinthblade.h" +#include "Objects/TR4/Trap/tr4_plough.h" +#include "Objects/TR4/Trap/tr4_sethblade.h" +#include "Objects/TR4/Trap/tr4_slicerdicer.h" +#include "Objects/TR4/Trap/tr4_spikeball.h" +#include "Objects/TR4/Trap/tr4_spikywall.h" +#include "Objects/TR4/Trap/tr4_spikyceiling.h" +#include "Objects/TR4/Trap/tr4_stargate.h" +#include "Objects/TR4/Trap/tr4_cog.h" +#include "Objects/TR4/Trap/tr4_teethspike.h" // Vehicles #include "Objects/TR4/Vehicles/jeep.h" #include "Objects/TR4/Vehicles/motorbike.h" +// Effects +#include "Objects/Effects/tr4_locusts.h" // OK + using namespace TEN::Entities::Traps; namespace TEN::Entities @@ -242,23 +242,7 @@ namespace TEN::Entities obj = &Objects[ID_SAS_CAIRO]; if (obj->loaded) - { - obj->biteOffset = 10; - obj->initialise = InitialiseSas; - obj->control = SasControl; - obj->collision = CreatureCollision; - obj->shadowType = ShadowMode::All; - obj->HitPoints = 40; - obj->hitEffect = HIT_BLOOD; - obj->pivotLength = 50; - obj->radius = 102; - obj->intelligent = true; - obj->ZoneType = ZoneType::HumanClassic; - g_Level.Bones[obj->boneIndex] |= ROT_Y; - g_Level.Bones[obj->boneIndex] |= ROT_X; - g_Level.Bones[obj->boneIndex + 28 * 4] |= ROT_Y; - g_Level.Bones[obj->boneIndex + 28 * 4] |= ROT_X; - } + SetupSas(*obj); obj = &Objects[ID_MUMMY]; if (obj->loaded) @@ -298,19 +282,6 @@ namespace TEN::Entities obj = &Objects[ID_KNIGHT_TEMPLAR]; if (obj->loaded) { - obj->initialise = InitialiseKnightTemplar; - obj->control = KnightTemplarControl; - obj->collision = CreatureCollision; - obj->shadowType = ShadowMode::All; - obj->HitPoints = 15; - obj->hitEffect = HIT_SMOKE; - obj->pivotLength = 50; - obj->radius = 128; - obj->intelligent = true; - obj->undead = true; - obj->ZoneType = ZoneType::Basic; - g_Level.Bones[obj->boneIndex + 6 * 4] |= ROT_X | ROT_Y; - g_Level.Bones[obj->boneIndex + 7 * 4] |= ROT_Y; } obj = &Objects[ID_BIG_BEETLE]; @@ -650,13 +621,7 @@ namespace TEN::Entities obj = &Objects[ID_SAS_DYING]; if (obj->loaded) - { - obj->initialise = InitialiseInjuredSas; - obj->control = InjuredSasControl; - obj->collision = ObjectCollision; - obj->hitEffect = HIT_BLOOD; - obj->ZoneType = ZoneType::Basic; - } + SetupInjuredSas(*obj); obj = &Objects[ID_ENEMY_JEEP]; if (obj->loaded) @@ -699,10 +664,7 @@ namespace TEN::Entities { obj = &Objects[ID_SAS_DRAG_BLOKE]; if (obj->loaded) - { - obj->control = AnimatingControl; - obj->collision = SasDragBlokeCollision; - } + SetupSasDraggableSas(*obj); obj = &Objects[ID_SARCOPHAGUS]; if (obj->loaded) From dd36ead0fea4a7d987dc04ad07afaa50882bd617 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri, 16 Dec 2022 14:05:12 +0200 Subject: [PATCH 08/19] Deduplicate event loading code --- TombEngine/Specific/level.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/TombEngine/Specific/level.cpp b/TombEngine/Specific/level.cpp index 0283dd3ca..cd4e96abf 100644 --- a/TombEngine/Specific/level.cpp +++ b/TombEngine/Specific/level.cpp @@ -962,6 +962,14 @@ void LoadAIObjects() } } +void LoadEvent(VolumeEvent& event) +{ + event.Mode = (VolumeEventMode)ReadInt32(); + event.Function = ReadString(); + event.Data = ReadString(); + event.CallCounter = ReadInt32(); +} + void LoadEventSets() { int eventSetCount = ReadInt32(); @@ -974,20 +982,9 @@ void LoadEventSets() eventSet.Name = ReadString(); eventSet.Activators = (VolumeActivatorFlags)ReadInt32(); - eventSet.OnEnter.Mode = (VolumeEventMode)ReadInt32(); - eventSet.OnEnter.Function = ReadString(); - eventSet.OnEnter.Data = ReadString(); - eventSet.OnEnter.CallCounter = ReadInt32(); - - eventSet.OnInside.Mode = (VolumeEventMode)ReadInt32(); - eventSet.OnInside.Function = ReadString(); - eventSet.OnInside.Data = ReadString(); - eventSet.OnInside.CallCounter = ReadInt32(); - - eventSet.OnLeave.Mode = (VolumeEventMode)ReadInt32(); - eventSet.OnLeave.Function = ReadString(); - eventSet.OnLeave.Data = ReadString(); - eventSet.OnLeave.CallCounter = ReadInt32(); + LoadEvent(eventSet.OnEnter); + LoadEvent(eventSet.OnInside); + LoadEvent(eventSet.OnLeave); g_Level.EventSets.push_back(eventSet); } From 87e2e79ea8fe2be107f57c8c3b2d749d46f7c3f9 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri, 16 Dec 2022 14:57:39 +0200 Subject: [PATCH 09/19] Fix distance tests --- .../Scripting/Internal/TEN/Misc/Miscellanous.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/TombEngine/Scripting/Internal/TEN/Misc/Miscellanous.cpp b/TombEngine/Scripting/Internal/TEN/Misc/Miscellanous.cpp index f38309899..0fe5919e7 100644 --- a/TombEngine/Scripting/Internal/TEN/Misc/Miscellanous.cpp +++ b/TombEngine/Scripting/Internal/TEN/Misc/Miscellanous.cpp @@ -239,8 +239,9 @@ namespace Misc //@treturn int the direct distance from one position to the other static int CalculateDistance(Vec3 const& pos1, Vec3 const& pos2) { - auto result = sqrt(SQUARE(pos1.x - pos2.x) + SQUARE(pos1.y - pos2.y) + SQUARE(pos1.z - pos2.z)); - return static_cast(round(result)); + auto p1 = Vector3{ (float)pos1.x, (float)pos1.y, (float)pos1.z }; + auto p2 = Vector3{ (float)pos2.x, (float)pos2.y, (float)pos2.z }; + return static_cast(round(Vector3::Distance(p1, p2))); } ///Calculate the horizontal distance between two positions. @@ -250,8 +251,9 @@ namespace Misc //@treturn int the direct distance on the XZ plane from one position to the other static int CalculateHorizontalDistance(Vec3 const& pos1, Vec3 const& pos2) { - auto result = sqrt(SQUARE(pos1.x - pos2.x) + SQUARE(pos1.z - pos2.z)); - return static_cast(round(result)); + auto p1 = Vector2{ (float)pos1.x, (float)pos1.z }; + auto p2 = Vector2{ (float)pos2.x, (float)pos2.z }; + return static_cast(round(Vector2::Distance(p1, p2))); } ///Translate a pair of percentages to screen-space pixel coordinates. From ff4e2f42aa2b9ae958709284390aafbe3293b7cd Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri, 16 Dec 2022 15:10:08 +0200 Subject: [PATCH 10/19] Update Changes.txt --- Documentation/Changes.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/Changes.txt b/Documentation/Changes.txt index 3a32a22a1..e3c41a939 100644 --- a/Documentation/Changes.txt +++ b/Documentation/Changes.txt @@ -19,9 +19,9 @@ Version 1.0.4 - Restored spark effects. - Can destroy statics in shatter slots. - Fix crash when attacking. -* SAS fix: - - Fix grenade shooting - - Fix AI_MODIFY and AI_GUARD for SAS +* SAS enhancements: + - Fix grenade shooting. + - Fix AI_MODIFY and AI_GUARD behaviour. * Fix TR5 Autogun Rotation. * Fix Choppy camera movement. * Fix Lara's vertical position when shimmying around steep slope corners. @@ -66,6 +66,7 @@ Lua API changes: * Fix mounted vehicles ignoring Disable, Shatter and Explode script commands. * Fix SetPosition command not updating room number correctly. * Fix Rotation class using integers under the hood which prevented using fractional rotation values. +* Fix distance tests failing on a very high distances. Version 1.0.3 ============= From 74f560dcbe03b615d0e2a68cef4251f8f4d4b674 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri, 16 Dec 2022 16:07:40 +0200 Subject: [PATCH 11/19] Fix IsMoveableInside script function --- .../Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp index 3add85e2c..a52907258 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp @@ -178,7 +178,7 @@ bool Volume::IsMoveableInside(const Moveable& moveable) short id = std::get(entry.Activator); auto& mov = std::make_unique(id); - if (mov.get() == &moveable) + if (mov.get()->GetName() == moveable.GetName()) return true; } } From 5219a1466575370a9046a5aaf401481a4d35b879 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri, 16 Dec 2022 17:08:59 +0200 Subject: [PATCH 12/19] Update Changes.txt --- Documentation/Changes.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/Changes.txt b/Documentation/Changes.txt index e3c41a939..a02e742cb 100644 --- a/Documentation/Changes.txt +++ b/Documentation/Changes.txt @@ -22,8 +22,7 @@ Version 1.0.4 * SAS enhancements: - Fix grenade shooting. - Fix AI_MODIFY and AI_GUARD behaviour. -* Fix TR5 Autogun Rotation. -* Fix Choppy camera movement. +* Fix choppy camera movement in several cases. * Fix Lara's vertical position when shimmying around steep slope corners. * Fix legacy pickup triggers not working in certain cases. * Fix crawl pickup not actually doing any pickups. @@ -38,6 +37,7 @@ Version 1.0.4 * Fix original bug with incorrect climb up behaviour on ladders under sloped ceilings. * Fix original bug with reassigned control keys still triggering default events. * Fix TR1 centaur bubble targeting. +* Fix TR5 autogun rotation. * Fix occasional wrong rollingball collision in narrow pits. * Fix classic rollingball and big rollingball not behaving properly. * Fix caustics not turning off in display settings. From 5df1fdfb207303a0fd19f4c255a12766689febff Mon Sep 17 00:00:00 2001 From: Kubsy Date: Fri, 16 Dec 2022 17:13:24 +0000 Subject: [PATCH 13/19] fix combined pickups in inventory upon game reload --- Documentation/Changes.txt | 6 ++++++ TombEngine/Game/savegame.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Documentation/Changes.txt b/Documentation/Changes.txt index a02e742cb..4d0e13fda 100644 --- a/Documentation/Changes.txt +++ b/Documentation/Changes.txt @@ -1,3 +1,9 @@ +Version 1.0.5 +============= + +* Fix combined items not existing in inventory upon game reload. + + Version 1.0.4 ============= diff --git a/TombEngine/Game/savegame.cpp b/TombEngine/Game/savegame.cpp index ee330be42..09ae0c11e 100644 --- a/TombEngine/Game/savegame.cpp +++ b/TombEngine/Game/savegame.cpp @@ -1737,7 +1737,7 @@ bool SaveGame::Load(int slot) ZeroMemory(Lara.Inventory.PickupsCombo, NUM_PICKUPS * 2 * sizeof(int)); for (int i = 0; i < s->lara()->inventory()->pickups_combo()->size(); i++) { - Lara.Inventory.Pickups[i] = s->lara()->inventory()->pickups_combo()->Get(i); + Lara.Inventory.PickupsCombo[i] = s->lara()->inventory()->pickups_combo()->Get(i); } ZeroMemory(Lara.Inventory.Examines, NUM_EXAMINES * sizeof(int)); From 8af424dd3fdec2ecdfb5cb7dfecce479c6a14279 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri, 16 Dec 2022 19:13:50 +0200 Subject: [PATCH 14/19] Fix doc comment --- .../Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp index c653c1197..4357d94df 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp @@ -418,6 +418,7 @@ ScriptReserved_GetSlotHP, & Moveable::GetSlotHP, /// Get the object's joint position // @function Moveable:GetJointPosition +// @tparam int index of a joint to get position // @treturn Vec3 a copy of the moveable's position ScriptReserved_GetJointPosition, & Moveable::GetJointPos, From 1afcfac55b943e7f795ef6b5c430e2bf92f6c026 Mon Sep 17 00:00:00 2001 From: hispidence Date: Fri, 16 Dec 2022 18:36:21 +0000 Subject: [PATCH 15/19] Fix doc comments --- .../Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp | 4 ++-- .../Internal/TEN/Objects/Moveable/MoveableObject.cpp | 2 +- .../Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp | 2 +- TombEngine/Scripting/Internal/TEN/Rotation/Rotation.cpp | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp index 9026a55b0..3769a8239 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Lara/LaraObject.cpp @@ -239,7 +239,7 @@ int LaraObject::GetAmmoCount() const /// Get current vehicle, if it exists // @function LaraObject:GetVehicle -// @treturn Moveable current vehicle (nil if no vehicle present) +// @treturn Objects.Moveable current vehicle (nil if no vehicle present) // @usage // local vehicle = Lara:GetVehicle() std::unique_ptr LaraObject::GetVehicle() const @@ -254,7 +254,7 @@ std::unique_ptr LaraObject::GetVehicle() const /// Get current target enemy, if it exists // @function LaraObject:GetTarget -// @treturn Moveable current target enemy (nil if no target present) +// @treturn Objects.Moveable current target enemy (nil if no target present) // @usage // local target = Lara:GetTarget() std::unique_ptr LaraObject::GetTarget() const diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp index 4357d94df..b1312da9c 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp @@ -451,7 +451,7 @@ ScriptReserved_GetSlotHP, & Moveable::GetSlotHP, /// Test if the object is in a valid state (i.e. has not been destroyed through Lua or killed by Lara). // @function Moveable:GetValid -// @treturn valid bool true if the object is still not destroyed +// @treturn bool valid true if the object is still not destroyed ScriptReserved_GetValid, &Moveable::GetValid, /// Destroy the moveable. This will mean it can no longer be used, except to re-initialise it with another object. diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp index a52907258..571810f3b 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp @@ -88,7 +88,7 @@ void Volume::Register(sol::table& parent) /// Check if specified moveable is inside the volume // @function Volume:IsMoveableInside - // @tparam Moveable moveable which should be checked for containment + // @tparam Objects.Moveable Moveable which should be checked for containment ScriptReserved_IsMoveableInside, &Volume::IsMoveableInside); } diff --git a/TombEngine/Scripting/Internal/TEN/Rotation/Rotation.cpp b/TombEngine/Scripting/Internal/TEN/Rotation/Rotation.cpp index 26ea621ab..66e1273d6 100644 --- a/TombEngine/Scripting/Internal/TEN/Rotation/Rotation.cpp +++ b/TombEngine/Scripting/Internal/TEN/Rotation/Rotation.cpp @@ -35,9 +35,9 @@ void Rotation::Register(sol::table& parent) } /*** -@float X rotation about x axis -@float Y rotation about y axis -@float Z rotation about z axis +@tparam float X rotation about x axis +@tparam float Y rotation about y axis +@tparam float Z rotation about z axis @treturn Rotation A Rotation object. @function Rotation */ From 0f0d57cd6614aa975e13c0989393684fa2990560 Mon Sep 17 00:00:00 2001 From: hispidence Date: Fri, 16 Dec 2022 18:36:42 +0000 Subject: [PATCH 16/19] Regenerate docs --- Documentation/doc/1 modules/Effects.html | 3 +- Documentation/doc/1 modules/Flow.html | 3 +- Documentation/doc/1 modules/Inventory.html | 3 +- Documentation/doc/1 modules/Logic.html | 3 +- Documentation/doc/1 modules/Misc.html | 3 +- Documentation/doc/1 modules/Objects.html | 35 +- Documentation/doc/1 modules/Strings.html | 3 +- .../doc/2 classes/Flow.Animations.html | 3 +- Documentation/doc/2 classes/Flow.Fog.html | 3 +- .../doc/2 classes/Flow.InventoryItem.html | 3 +- Documentation/doc/2 classes/Flow.Level.html | 3 +- Documentation/doc/2 classes/Flow.Mirror.html | 3 +- .../doc/2 classes/Flow.Settings.html | 3 +- .../doc/2 classes/Flow.SkyLayer.html | 3 +- .../doc/2 classes/Objects.AIObject.html | 3 +- .../doc/2 classes/Objects.Camera.html | 3 +- .../doc/2 classes/Objects.LaraObject.html | 36 +- .../doc/2 classes/Objects.Moveable.html | 18 +- Documentation/doc/2 classes/Objects.Sink.html | 3 +- .../doc/2 classes/Objects.SoundSource.html | 3 +- .../doc/2 classes/Objects.Static.html | 3 +- .../doc/2 classes/Objects.Volume.html | 426 ++++++++++++++++++ .../doc/2 classes/Strings.DisplayString.html | 3 +- .../doc/3 primitive classes/Color.html | 3 +- .../doc/3 primitive classes/Rotation.html | 23 +- .../doc/3 primitive classes/Vec3.html | 3 +- .../doc/4 enums/Effects.BlendID.html | 3 +- .../doc/4 enums/Effects.EffectID.html | 3 +- Documentation/doc/4 enums/Misc.ActionID.html | 3 +- Documentation/doc/4 enums/Objects.ObjID.html | 3 +- .../5 lua utility modules/EventSequence.html | 3 +- .../doc/5 lua utility modules/Timer.html | 3 +- Documentation/doc/index.html | 7 +- 33 files changed, 578 insertions(+), 48 deletions(-) create mode 100644 Documentation/doc/2 classes/Objects.Volume.html diff --git a/Documentation/doc/1 modules/Effects.html b/Documentation/doc/1 modules/Effects.html index 119174d18..5edc00aee 100644 --- a/Documentation/doc/1 modules/Effects.html +++ b/Documentation/doc/1 modules/Effects.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -515,7 +516,7 @@
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/1 modules/Flow.html b/Documentation/doc/1 modules/Flow.html index 4458b1e72..523b132d6 100644 --- a/Documentation/doc/1 modules/Flow.html +++ b/Documentation/doc/1 modules/Flow.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -656,7 +657,7 @@ Specify which translations in the strings table correspond to which languages.
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/1 modules/Inventory.html b/Documentation/doc/1 modules/Inventory.html index a6f288427..a2fbdb75e 100644 --- a/Documentation/doc/1 modules/Inventory.html +++ b/Documentation/doc/1 modules/Inventory.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -238,7 +239,7 @@ Similar to GiveItem but repla
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/1 modules/Logic.html b/Documentation/doc/1 modules/Logic.html index 4b3eb8417..c48504088 100644 --- a/Documentation/doc/1 modules/Logic.html +++ b/Documentation/doc/1 modules/Logic.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -365,7 +366,7 @@ and provides the delta time (a float representing game time since last call) via
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/1 modules/Misc.html b/Documentation/doc/1 modules/Misc.html index db252ba4e..337b6e0ab 100644 --- a/Documentation/doc/1 modules/Misc.html +++ b/Documentation/doc/1 modules/Misc.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -801,7 +802,7 @@ To be used with
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/1 modules/Objects.html b/Documentation/doc/1 modules/Objects.html index 695e8a8d8..707203a2e 100644 --- a/Documentation/doc/1 modules/Objects.html +++ b/Documentation/doc/1 modules/Objects.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -122,6 +123,10 @@ GetAIObjectByName(name) Get an AIObject by its name. + + GetVolumeByName(name) + Get a Volume by its name. +
    @@ -354,6 +359,34 @@ + +
    + + GetVolumeByName(name) +
    +
    + Get a Volume by its name. + + + +

    Parameters:

    +
      +
    • name + string + the unique name of the volume as set in, or generated by, Tomb Editor +
    • +
    + +

    Returns:

    +
      + + Volume + a non-owning Volume referencing the room. +
    + + + +
    @@ -362,7 +395,7 @@
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/1 modules/Strings.html b/Documentation/doc/1 modules/Strings.html index 60c7a9ca2..c9284a9cb 100644 --- a/Documentation/doc/1 modules/Strings.html +++ b/Documentation/doc/1 modules/Strings.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -166,7 +167,7 @@ with a call to ShowString, or
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Flow.Animations.html b/Documentation/doc/2 classes/Flow.Animations.html index 5eeced275..00aea5e6e 100644 --- a/Documentation/doc/2 classes/Flow.Animations.html +++ b/Documentation/doc/2 classes/Flow.Animations.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -99,7 +100,7 @@
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Flow.Fog.html b/Documentation/doc/2 classes/Flow.Fog.html index 6b97cb7bf..949ede98e 100644 --- a/Documentation/doc/2 classes/Flow.Fog.html +++ b/Documentation/doc/2 classes/Flow.Fog.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -226,7 +227,7 @@
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Flow.InventoryItem.html b/Documentation/doc/2 classes/Flow.InventoryItem.html index 3a385d85c..ba982a7f6 100644 --- a/Documentation/doc/2 classes/Flow.InventoryItem.html +++ b/Documentation/doc/2 classes/Flow.InventoryItem.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -183,7 +184,7 @@ EXAMINE
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Flow.Level.html b/Documentation/doc/2 classes/Flow.Level.html index 5035ca332..53cf02481 100644 --- a/Documentation/doc/2 classes/Flow.Level.html +++ b/Documentation/doc/2 classes/Flow.Level.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -529,7 +530,7 @@ Must be at least 4.

    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Flow.Mirror.html b/Documentation/doc/2 classes/Flow.Mirror.html index 8ae531f14..cc0cbcd6b 100644 --- a/Documentation/doc/2 classes/Flow.Mirror.html +++ b/Documentation/doc/2 classes/Flow.Mirror.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -99,7 +100,7 @@
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Flow.Settings.html b/Documentation/doc/2 classes/Flow.Settings.html index 1773c3bf8..d7f6c8540 100644 --- a/Documentation/doc/2 classes/Flow.Settings.html +++ b/Documentation/doc/2 classes/Flow.Settings.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -139,7 +140,7 @@ has an unrecoverable error, the game will close.
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Flow.SkyLayer.html b/Documentation/doc/2 classes/Flow.SkyLayer.html index abae105ce..f75ecd565 100644 --- a/Documentation/doc/2 classes/Flow.SkyLayer.html +++ b/Documentation/doc/2 classes/Flow.SkyLayer.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -197,7 +198,7 @@ Less is more. City of The Dead, for example, uses a speed value of 16.
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Objects.AIObject.html b/Documentation/doc/2 classes/Objects.AIObject.html index 288082ea0..f7c9ed101 100644 --- a/Documentation/doc/2 classes/Objects.AIObject.html +++ b/Documentation/doc/2 classes/Objects.AIObject.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -377,7 +378,7 @@ aiObj:SetObjectID(TEN.Objects.ObjID.AI_PATROL1)
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Objects.Camera.html b/Documentation/doc/2 classes/Objects.Camera.html index ab50b452e..bbeb101f2 100644 --- a/Documentation/doc/2 classes/Objects.Camera.html +++ b/Documentation/doc/2 classes/Objects.Camera.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -261,7 +262,7 @@
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Objects.LaraObject.html b/Documentation/doc/2 classes/Objects.LaraObject.html index 1de37b2f7..ecf61a761 100644 --- a/Documentation/doc/2 classes/Objects.LaraObject.html +++ b/Documentation/doc/2 classes/Objects.LaraObject.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -154,6 +155,10 @@ LaraObject:GetTarget() Get current target enemy, if it exists + + LaraObject:TorchIsLit() + Get current light state of the torch, if it exists +
    @@ -540,7 +545,7 @@ ROCKETLAUNCHER

    Returns:

      - Moveable + Moveable current vehicle (nil if no vehicle present)
    @@ -565,7 +570,7 @@ ROCKETLAUNCHER

    Returns:

      - Moveable + Moveable current target enemy (nil if no target present)
    @@ -576,6 +581,31 @@ ROCKETLAUNCHER
    local target = Lara:GetTarget()
    + +
    + + LaraObject:TorchIsLit() +
    +
    + Get current light state of the torch, if it exists + + + + +

    Returns:

    +
      + + bool + is torch currently lit or not? (false if no torch exists) +
    + + + +

    Usage:

    +
      +
      local torchIsLit = Lara:TorchIsLit()
      +
    +
    @@ -584,7 +614,7 @@ ROCKETLAUNCHER
    generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
    diff --git a/Documentation/doc/2 classes/Objects.Moveable.html b/Documentation/doc/2 classes/Objects.Moveable.html index 3191544b5..8a012f3c1 100644 --- a/Documentation/doc/2 classes/Objects.Moveable.html +++ b/Documentation/doc/2 classes/Objects.Moveable.html @@ -56,6 +56,7 @@
  • Objects.Sink
  • Objects.SoundSource
  • Objects.Static
  • +
  • Objects.Volume
  • Strings.DisplayString
  • 3 Primitive Classes

    @@ -275,7 +276,7 @@ associated getters and setters. Determine whether the moveable is active or not - Moveable:GetJointPosition() + Moveable:GetJointPosition(index) Get the object's joint position @@ -1377,13 +1378,20 @@ sas:SetAIBits({1, 0,
    - Moveable:GetJointPosition() + Moveable:GetJointPosition(index)
    Get the object's joint position +

    Parameters:

    +
      +
    • index + int + of a joint to get position +
    • +

    Returns:

      @@ -1505,8 +1513,8 @@ sas:SetAIBits({1, 0, Returns:
        - valid - bool true if the object is still not destroyed + bool + valid true if the object is still not destroyed
      @@ -1732,7 +1740,7 @@ sas:SetPosition(destinationPosition, false)
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/2 classes/Objects.Sink.html b/Documentation/doc/2 classes/Objects.Sink.html index c75df2602..cb1c67ecd 100644 --- a/Documentation/doc/2 classes/Objects.Sink.html +++ b/Documentation/doc/2 classes/Objects.Sink.html @@ -56,6 +56,7 @@
    1. Objects.Sink
    2. Objects.SoundSource
    3. Objects.Static
    4. +
    5. Objects.Volume
    6. Strings.DisplayString
    7. 3 Primitive Classes

      @@ -263,7 +264,7 @@
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/2 classes/Objects.SoundSource.html b/Documentation/doc/2 classes/Objects.SoundSource.html index 94c13e65b..cac8ecfc8 100644 --- a/Documentation/doc/2 classes/Objects.SoundSource.html +++ b/Documentation/doc/2 classes/Objects.SoundSource.html @@ -56,6 +56,7 @@
    8. Objects.Sink
    9. Objects.SoundSource
    10. Objects.Static
    11. +
    12. Objects.Volume
    13. Strings.DisplayString
    14. 3 Primitive Classes

      @@ -261,7 +262,7 @@
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/2 classes/Objects.Static.html b/Documentation/doc/2 classes/Objects.Static.html index 634d84ab4..a39bda525 100644 --- a/Documentation/doc/2 classes/Objects.Static.html +++ b/Documentation/doc/2 classes/Objects.Static.html @@ -56,6 +56,7 @@
    15. Objects.Sink
    16. Objects.SoundSource
    17. Objects.Static
    18. +
    19. Objects.Volume
    20. Strings.DisplayString
    21. 3 Primitive Classes

      @@ -547,7 +548,7 @@
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/2 classes/Objects.Volume.html b/Documentation/doc/2 classes/Objects.Volume.html new file mode 100644 index 000000000..f4ef3d03f --- /dev/null +++ b/Documentation/doc/2 classes/Objects.Volume.html @@ -0,0 +1,426 @@ + + + + + TombEngine 1.0.4 Lua API + + + + +
      + +
      + +
      +
      +
      + + +
      + + + + + + +
      + +

      Class Objects.Volume

      +

      Volumes

      +

      + +

      + + +

      Functions

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Volume:Enable()Enable the volume.
      Volume:Disable()Disable the volume.
      Volume:GetActive()Determine whether the volume is active or not
      Volume:GetPosition()Get the volume's position.
      Volume:SetPosition(position)Set the volume's position.
      Volume:GetRotation()Get the volume's rotation.
      Volume:SetRotation(rotation)Set the volume's rotation.
      Volume:GetScale()Get the volume's scale (separately on all 3 axes).
      Volume:SetScale(scale)Set the volume's scale (separately on all 3 axes).
      Volume:GetName()Get the volume's unique string identifier.
      Volume:SetName(name)Set the volume's name (its unique string identifier).
      Volume:ClearActivators()Clear activator list for volumes (makes volume trigger everything again)
      Volume:IsMoveableInside(Moveable)Check if specified moveable is inside the volume
      + +
      +
      + + +

      Functions

      + +
      +
      + + Volume:Enable() +
      +
      + Enable the volume. + + + + + + + + +
      +
      + + Volume:Disable() +
      +
      + Disable the volume. + + + + + + + + +
      +
      + + Volume:GetActive() +
      +
      + Determine whether the volume is active or not + + + + +

      Returns:

      +
        + + bool + true if the volume is active +
      + + + + +
      +
      + + Volume:GetPosition() +
      +
      + Get the volume's position. + + + + +

      Returns:

      +
        + + Vec3 + a copy of the volume's position +
      + + + + +
      +
      + + Volume:SetPosition(position) +
      +
      + Set the volume's position. + + + +

      Parameters:

      +
        +
      • position + Vec3 + the new position of the volume +
      • +
      + + + + + +
      +
      + + Volume:GetRotation() +
      +
      + Get the volume's rotation. + + + + +

      Returns:

      +
        + + Rotation + a copy of the volume's rotation +
      + + + + +
      +
      + + Volume:SetRotation(rotation) +
      +
      + Set the volume's rotation. + + + +

      Parameters:

      +
        +
      • rotation + Rotation + the volume's new rotation +
      • +
      + + + + + +
      +
      + + Volume:GetScale() +
      +
      + Get the volume's scale (separately on all 3 axes). + + + + +

      Returns:

      +
        + + Vec3 + current volume scale +
      + + + + +
      +
      + + Volume:SetScale(scale) +
      +
      + Set the volume's scale (separately on all 3 axes). + + + +

      Parameters:

      +
        +
      • scale + Vec3 + the volume's new scale +
      • +
      + + + + + +
      +
      + + Volume:GetName() +
      +
      + Get the volume's unique string identifier. + + + + +

      Returns:

      +
        + + string + the volume's name +
      + + + + +
      +
      + + Volume:SetName(name) +
      +
      + Set the volume's name (its unique string identifier). + + + +

      Parameters:

      +
        +
      • name + string + The volume's new name +
      • +
      + + + + + +
      +
      + + Volume:ClearActivators() +
      +
      + Clear activator list for volumes (makes volume trigger everything again) + + + + + + + + +
      +
      + + Volume:IsMoveableInside(Moveable) +
      +
      + Check if specified moveable is inside the volume + + + +

      Parameters:

      +
        +
      • Moveable + Moveable + which should be checked for containment +
      • +
      + + + + + +
      +
      + + +
      +
      +
      +generated by LDoc 1.4.6 +Last updated 2022-12-16 18:35:53 +
      +
      + + diff --git a/Documentation/doc/2 classes/Strings.DisplayString.html b/Documentation/doc/2 classes/Strings.DisplayString.html index 5b55bdbda..1d0b13492 100644 --- a/Documentation/doc/2 classes/Strings.DisplayString.html +++ b/Documentation/doc/2 classes/Strings.DisplayString.html @@ -56,6 +56,7 @@
    22. Objects.Sink
    23. Objects.SoundSource
    24. Objects.Static
    25. +
    26. Objects.Volume
    27. Strings.DisplayString
    28. 3 Primitive Classes

      @@ -336,7 +337,7 @@ TEN.Strings.DisplayStringOption.SHADOW -- will give the text a small shadow
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/3 primitive classes/Color.html b/Documentation/doc/3 primitive classes/Color.html index 26b887055..6e17f86c9 100644 --- a/Documentation/doc/3 primitive classes/Color.html +++ b/Documentation/doc/3 primitive classes/Color.html @@ -56,6 +56,7 @@
    29. Objects.Sink
    30. Objects.SoundSource
    31. Objects.Static
    32. +
    33. Objects.Volume
    34. Strings.DisplayString
    35. 3 Primitive Classes

      @@ -315,7 +316,7 @@
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/3 primitive classes/Rotation.html b/Documentation/doc/3 primitive classes/Rotation.html index 030328dae..3940c5e18 100644 --- a/Documentation/doc/3 primitive classes/Rotation.html +++ b/Documentation/doc/3 primitive classes/Rotation.html @@ -56,6 +56,7 @@
    36. Objects.Sink
    37. Objects.SoundSource
    38. Objects.Static
    39. +
    40. Objects.Volume
    41. Strings.DisplayString
    42. 3 Primitive Classes

      @@ -85,22 +86,22 @@

      Represents a rotation.

      Rotations are specifed as a combination of individual angles, in degrees, about each axis. -All values will be clamped to [-32768, 32767].

      +All values will be clamped to [0.0f, 360.0f].

      Members

      - + - + - +
      x(int) rotation about x axis(float) rotation about x axis
      y(int) rotation about y axis(float) rotation about y axis
      z(int) rotation about z axis(float) rotation about z axis

      Functions

      @@ -131,7 +132,7 @@ All values will be clamped to [-32768, 32767].

      x
      - (int) rotation about x axis + (float) rotation about x axis @@ -146,7 +147,7 @@ All values will be clamped to [-32768, 32767].

      y
      - (int) rotation about y axis + (float) rotation about y axis @@ -161,7 +162,7 @@ All values will be clamped to [-32768, 32767].

      z
      - (int) rotation about z axis + (float) rotation about z axis @@ -189,15 +190,15 @@ All values will be clamped to [-32768, 32767].

      Parameters:

      • X - int + float rotation about x axis
      • Y - int + float rotation about y axis
      • Z - int + float rotation about z axis
      @@ -250,7 +251,7 @@ All values will be clamped to [-32768, 32767].

      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/3 primitive classes/Vec3.html b/Documentation/doc/3 primitive classes/Vec3.html index 98540afe7..19b087f32 100644 --- a/Documentation/doc/3 primitive classes/Vec3.html +++ b/Documentation/doc/3 primitive classes/Vec3.html @@ -56,6 +56,7 @@
    43. Objects.Sink
    44. Objects.SoundSource
    45. Objects.Static
    46. +
    47. Objects.Volume
    48. Strings.DisplayString
    49. 3 Primitive Classes

      @@ -278,7 +279,7 @@ However, this function would return it as (0, 1, 1).
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/4 enums/Effects.BlendID.html b/Documentation/doc/4 enums/Effects.BlendID.html index 5ca1189c1..ec0a37762 100644 --- a/Documentation/doc/4 enums/Effects.BlendID.html +++ b/Documentation/doc/4 enums/Effects.BlendID.html @@ -56,6 +56,7 @@
    50. Objects.Sink
    51. Objects.SoundSource
    52. Objects.Static
    53. +
    54. Objects.Volume
    55. Strings.DisplayString
    56. 3 Primitive Classes

      @@ -145,7 +146,7 @@ ALPHABLEND
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/4 enums/Effects.EffectID.html b/Documentation/doc/4 enums/Effects.EffectID.html index 5e77002a4..ad1652360 100644 --- a/Documentation/doc/4 enums/Effects.EffectID.html +++ b/Documentation/doc/4 enums/Effects.EffectID.html @@ -56,6 +56,7 @@
    57. Objects.Sink
    58. Objects.SoundSource
    59. Objects.Static
    60. +
    61. Objects.Volume
    62. Strings.DisplayString
    63. 3 Primitive Classes

      @@ -141,7 +142,7 @@ CUSTOM
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/4 enums/Misc.ActionID.html b/Documentation/doc/4 enums/Misc.ActionID.html index f7933bebe..9d4b76b42 100644 --- a/Documentation/doc/4 enums/Misc.ActionID.html +++ b/Documentation/doc/4 enums/Misc.ActionID.html @@ -56,6 +56,7 @@
    64. Objects.Sink
    65. Objects.SoundSource
    66. Objects.Static
    67. +
    68. Objects.Volume
    69. Strings.DisplayString
    70. 3 Primitive Classes

      @@ -152,7 +153,7 @@ STEPRIGHT
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/4 enums/Objects.ObjID.html b/Documentation/doc/4 enums/Objects.ObjID.html index 499168dbd..8850fdc7f 100644 --- a/Documentation/doc/4 enums/Objects.ObjID.html +++ b/Documentation/doc/4 enums/Objects.ObjID.html @@ -56,6 +56,7 @@
    71. Objects.Sink
    72. Objects.SoundSource
    73. Objects.Static
    74. +
    75. Objects.Volume
    76. Strings.DisplayString
    77. 3 Primitive Classes

      @@ -1307,7 +1308,7 @@ PC_SAVE_INV_ITEM
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/5 lua utility modules/EventSequence.html b/Documentation/doc/5 lua utility modules/EventSequence.html index c6944c3e4..87246ecaa 100644 --- a/Documentation/doc/5 lua utility modules/EventSequence.html +++ b/Documentation/doc/5 lua utility modules/EventSequence.html @@ -56,6 +56,7 @@
    78. Objects.Sink
    79. Objects.SoundSource
    80. Objects.Static
    81. +
    82. Objects.Volume
    83. Strings.DisplayString
    84. 3 Primitive Classes

      @@ -337,7 +338,7 @@ LevelFuncs.SpawnBaddy = function(baddy, name, pos)
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/5 lua utility modules/Timer.html b/Documentation/doc/5 lua utility modules/Timer.html index 008018830..d82d8f880 100644 --- a/Documentation/doc/5 lua utility modules/Timer.html +++ b/Documentation/doc/5 lua utility modules/Timer.html @@ -56,6 +56,7 @@
    85. Objects.Sink
    86. Objects.SoundSource
    87. Objects.Static
    88. +
    89. Objects.Volume
    90. Strings.DisplayString
    91. 3 Primitive Classes

      @@ -513,7 +514,7 @@ LevelFuncs.TriggerTimer = function(obj)
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      diff --git a/Documentation/doc/index.html b/Documentation/doc/index.html index 5ac1cb72a..a5ed1e697 100644 --- a/Documentation/doc/index.html +++ b/Documentation/doc/index.html @@ -56,6 +56,7 @@
    92. Objects.Sink
    93. Objects.SoundSource
    94. Objects.Static
    95. +
    96. Objects.Volume
    97. Strings.DisplayString
    98. 3 Primitive Classes

      @@ -193,6 +194,10 @@ local door = GetMoveableByName("door_type4_14") Objects.Static Statics + + Objects.Volume + Volumes + Strings.DisplayString A string appearing on the screen. @@ -248,7 +253,7 @@ local door = GetMoveableByName("door_type4_14")
      generated by LDoc 1.4.6 -Last updated 2022-12-11 18:38:45 +Last updated 2022-12-16 18:35:53
      From 29fb15afbda0289021affd4b4024b4ff29997e88 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri, 16 Dec 2022 20:07:56 +0200 Subject: [PATCH 17/19] Update VolumeObject.cpp --- .../Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp index 571810f3b..9b4c85b21 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Volume/VolumeObject.cpp @@ -89,6 +89,7 @@ void Volume::Register(sol::table& parent) /// Check if specified moveable is inside the volume // @function Volume:IsMoveableInside // @tparam Objects.Moveable Moveable which should be checked for containment + // @treturn bool state of the moveable, true if contained, false if not ScriptReserved_IsMoveableInside, &Volume::IsMoveableInside); } From 8d8f77b98bd3d56d09216d9c46f76178ff8aa51d Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Fri, 16 Dec 2022 20:10:24 +0200 Subject: [PATCH 18/19] Update MoveableObject.cpp --- .../Internal/TEN/Objects/Moveable/MoveableObject.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp index b1312da9c..16ca85e25 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp @@ -460,7 +460,9 @@ ScriptReserved_GetSlotHP, & Moveable::GetSlotHP, /// Attach camera to an object. // @function Moveable:AttachObjCamera -// @tparam int mesh 1 for camera, mesh 2 for target +// @tparam int mesh of a moveable to use as a camera position +// @tparam Moveable target moveable to attach camera to +// @tparam int mesh of a target moveable to use as a camera target ScriptReserved_AttachObjCamera, &Moveable::AttachObjCamera, /// Borrow animation from an object From 7c617b0929d19af49b0fea534efc173453237951 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Sat, 17 Dec 2022 03:20:09 +0200 Subject: [PATCH 19/19] Fix cold room flag not affecting Lara breath --- TombEngine/Game/effects/item_fx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TombEngine/Game/effects/item_fx.cpp b/TombEngine/Game/effects/item_fx.cpp index 8475fd1c1..0a1768e0d 100644 --- a/TombEngine/Game/effects/item_fx.cpp +++ b/TombEngine/Game/effects/item_fx.cpp @@ -81,7 +81,7 @@ namespace TEN::Effects::Items void LaraBreath(ItemInfo* item) { - if (item->IsLara()) + if (!item->IsLara()) return; auto* lara = GetLaraInfo(item);