This commit is contained in:
MontyTRC89 2021-08-20 05:26:07 +02:00
commit 2e1ac44c08
26 changed files with 104 additions and 64 deletions

View file

@ -920,6 +920,10 @@ void LaraAboveWater(ITEM_INFO* item, COLL_INFO* coll) //hmmmm
// Check for collision with items
LaraBaddieCollision(item, coll);
// FIXME: refresh floor globals because sometimes they are messed by calling GetFloorHeight
// all over the place. Needed for monkeyswing. Remove when block flags decoupled from floordata. -- Lwmte 19.08.21
RefreshFloorGlobals(item);
// Handle Lara collision
if (Lara.Vehicle == NO_ITEM)
lara_collision_routines[item->currentAnimState](item, coll);

View file

@ -1258,6 +1258,13 @@ void DoFloorThings(FLOOR_INFO* floor, int x, int y, int z)
}
}
void RefreshFloorGlobals(ITEM_INFO* item)
{
auto room = item->roomNumber;
auto floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &room);
DoFloorThings(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
}
void GetCollisionInfo(COLL_INFO* coll, int xPos, int yPos, int zPos, int roomNumber, int objectHeight)
{
int resetRoom;

View file

@ -127,6 +127,7 @@ int Move3DPosTo3DPos(PHD_3DPOS* src, PHD_3DPOS* dest, int velocity, short angAdd
int MoveLaraPosition(PHD_VECTOR* pos, ITEM_INFO* item, ITEM_INFO* l);
int TestBoundsCollide(ITEM_INFO* item, ITEM_INFO* l, int radius);
void CreatureCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);
void RefreshFloorGlobals(ITEM_INFO* item);
void GetCollisionInfo(COLL_INFO* coll, int xPos, int yPos, int zPos, int roomNumber, int objectHeight);
void GetObjectCollisionInfo(COLL_INFO* coll, int xPos, int yPos, int zPos, int roomNumber, int objectHeight);
void LaraBaddieCollision(ITEM_INFO* item, COLL_INFO* coll);

View file

@ -133,8 +133,6 @@ HEIGHT_TYPES HeightType;
int HeavyTriggered;
short SkyPos1;
short SkyPos2;
signed char SkyVelocity1;
signed char SkyVelocity2;
CVECTOR SkyColor1;
CVECTOR SkyColor2;
int CutSeqNum;

View file

@ -105,8 +105,6 @@ extern HEIGHT_TYPES HeightType;
extern int HeavyTriggered;
extern short SkyPos1;
extern short SkyPos2;
extern signed char SkyVelocity1;
extern signed char SkyVelocity2;
extern CVECTOR SkyColor1;
extern CVECTOR SkyColor2;
extern int CutSeqNum;

View file

@ -241,12 +241,10 @@ bool GameFlow::DoGameflow()
SkyColor1.r = level->Layer1.R;
SkyColor1.g = level->Layer1.G;
SkyColor1.b = level->Layer1.B;
SkyVelocity1 = level->Layer1.CloudSpeed;
SkyColor2.r = level->Layer2.R;
SkyColor2.g = level->Layer2.G;
SkyColor2.b = level->Layer2.B;
SkyVelocity2 = level->Layer2.CloudSpeed;
}
if (level->Storm)
@ -269,7 +267,7 @@ bool GameFlow::DoGameflow()
else
{
// Prepare inventory objects table
for (int i = 0; i < level->InventoryObjects.size(); i++)
for (size_t i = 0; i < level->InventoryObjects.size(); i++)
{
GameScriptInventoryObject* obj = &level->InventoryObjects[i];
if (obj->slot >= 0 && obj->slot < INVENTORY_TABLE_SIZE)

View file

@ -3,6 +3,7 @@
#include "GameScriptAIObject.h"
#include "ScriptAssert.h"
#include "GameScriptPosition.h"
#include "ScriptUtil.h"
#include <sol.hpp>
/***
AI object
@ -15,6 +16,7 @@ AI object
constexpr auto LUA_CLASS_NAME{ "AIObject" };
static auto index_error = index_error_maker(GameScriptAIObject, LUA_CLASS_NAME);
static auto newindex_error = newindex_error_maker(GameScriptAIObject, LUA_CLASS_NAME);
GameScriptAIObject::GameScriptAIObject(AI_OBJECT & ref, bool temp) : m_aiObject{ref}, m_temporary{ temp }
{};
@ -30,6 +32,7 @@ void GameScriptAIObject::Register(sol::state* state)
{
state->new_usertype<GameScriptAIObject>(LUA_CLASS_NAME,
sol::meta_function::index, index_error,
sol::meta_function::new_index, newindex_error,
/// (@{Position}) position in level
// @mem pos

View file

@ -2,6 +2,7 @@
#include "ScriptAssert.h"
#include "GameScriptCameraInfo.h"
#include "GameScriptPosition.h"
#include "ScriptUtil.h"
/***
Camera info
@ -12,6 +13,7 @@ Camera info
static constexpr auto LUA_CLASS_NAME{ "CameraInfo" };
static auto index_error = index_error_maker(GameScriptCameraInfo, LUA_CLASS_NAME);
static auto newindex_error = newindex_error_maker(GameScriptCameraInfo, LUA_CLASS_NAME);
GameScriptCameraInfo::GameScriptCameraInfo(LEVEL_CAMERA_INFO & ref, bool temp) : m_camera{ref}, m_temporary{ temp }
{};
@ -27,6 +29,7 @@ void GameScriptCameraInfo::Register(sol::state* state)
{
state->new_usertype<GameScriptCameraInfo>(LUA_CLASS_NAME,
sol::meta_function::index, index_error,
sol::meta_function::new_index, newindex_error,
/// (@{Position}) position in level
// @mem pos

View file

@ -29,7 +29,7 @@ associated getters and setters.
@tparam ItemAction action is this usable, equippable, or examinable?
@return an InventoryObject
*/
GameScriptInventoryObject::GameScriptInventoryObject(std::string const& a_name, ItemEnumPair a_slot, float a_yOffset, float a_scale, GameScriptRotation const & a_rot, rotflags a_rotationFlags, int a_meshBits, item_options a_action) :
GameScriptInventoryObject::GameScriptInventoryObject(std::string const& a_name, ItemEnumPair a_slot, short a_yOffset, float a_scale, GameScriptRotation const & a_rot, rotflags a_rotationFlags, int a_meshBits, item_options a_action) :
name{ a_name },
slot{ a_slot.m_pair.second },
yOffset{ a_yOffset },

View file

@ -24,7 +24,7 @@ struct GameScriptInventoryObject
{
std::string name{};
inv_objects slot{ INV_OBJECT_PISTOLS };
float yOffset{ 0.0f };
short yOffset{ 0 };
float scale{ 1.0f };
GameScriptRotation rot{};
rotflags rotationFlags{ rotflags::INV_ROT_X };
@ -32,7 +32,7 @@ struct GameScriptInventoryObject
item_options action{ item_options::OPT_USE };
GameScriptInventoryObject() = default;
GameScriptInventoryObject(std::string const & a_name, ItemEnumPair a_slot, float a_yOffset, float a_scale, GameScriptRotation const & a_rot, rotflags a_rotationFlags, int a_meshBits, item_options a_actions);
GameScriptInventoryObject(std::string const & a_name, ItemEnumPair a_slot, short a_yOffset, float a_scale, GameScriptRotation const & a_rot, rotflags a_rotationFlags, int a_meshBits, item_options a_actions);
static void Register(sol::state* lua);

View file

@ -1,6 +1,7 @@
#include "framework.h"
#include "ScriptAssert.h"
#include "GameScriptItemInfo.h"
#include "ScriptUtil.h"
#include "items.h"
#include "objectslist.h"
#include "level.h"
@ -23,6 +24,7 @@ pickups, and Lara herself.
constexpr auto LUA_CLASS_NAME{ "ItemInfo" };
static auto index_error = index_error_maker(GameScriptItemInfo, LUA_CLASS_NAME);
static auto newindex_error = newindex_error_maker(GameScriptItemInfo, LUA_CLASS_NAME);
GameScriptItemInfo::GameScriptItemInfo(short num, bool temp) : m_item{ &g_Level.Items[num] }, m_num{ num }, m_initialised{ false }, m_temporary{ temp }
{};
@ -167,6 +169,7 @@ void GameScriptItemInfo::Register(sol::state* state)
"newItem", sol::overload(Create<false>, CreateEmpty<false>),
"newItemTemporary", sol::overload(Create<true>, CreateEmpty<true>),
sol::meta_function::index, index_error,
sol::meta_function::new_index, newindex_error,
/// Initialise an item.
//Use this if you called new with no arguments

View file

@ -128,8 +128,15 @@ This is equivalent to TRNG's LevelFarView variable.
__(not yet implemented)__
@mem farView
*/
"farView", sol::property(&GameScriptLevel::SetLevelFarView),
/*** (bool) If true, the player will have an unlimited oxygen supply when in water.
__(not yet implemented)__
@mem unlimitedAir
*/
"unlimitedAir", &GameScriptLevel::UnlimitedAir,
/// (table of @{InventoryObject}s) table of inventory object overrides
//@mem objects
"objects", &GameScriptLevel::InventoryObjects

View file

@ -54,9 +54,9 @@ struct GameScriptLevel
bool Rumble{ false };
LARA_TYPE LaraType{ LARA_TYPE::NORMAL };
GameScriptMirror Mirror;
byte UVRotate{ 0 }; // unused
int LevelFarView{ 0 }; // unused
bool UnlimitedAir{ false }; //unused
byte UVRotate{ 0 };
int LevelFarView{ 0 };
bool UnlimitedAir{ false };
std::vector<GameScriptInventoryObject> InventoryObjects;
void SetUVRotate(byte val);

View file

@ -4,6 +4,7 @@
#include "GameScriptMeshInfo.h"
#include "GameScriptPosition.h"
#include "GameScriptColor.h"
#include "ScriptUtil.h"
#include <sol.hpp>
/***
Mesh info
@ -15,6 +16,7 @@ Mesh info
constexpr auto LUA_CLASS_NAME{ "MeshInfo" };
static auto index_error = index_error_maker(GameScriptMeshInfo, LUA_CLASS_NAME);
static auto newindex_error = newindex_error_maker(GameScriptMeshInfo, LUA_CLASS_NAME);
GameScriptMeshInfo::GameScriptMeshInfo(MESH_INFO & ref, bool temp) : m_mesh{ref}, m_temporary{ temp }
{};
@ -30,6 +32,7 @@ void GameScriptMeshInfo::Register(sol::state* state)
{
state->new_usertype<GameScriptMeshInfo>(LUA_CLASS_NAME,
sol::meta_function::index, index_error,
sol::meta_function::new_index, newindex_error,
/// (@{Position}) position in level
// @mem pos
@ -40,7 +43,7 @@ void GameScriptMeshInfo::Register(sol::state* state)
"yRot", sol::property(&GameScriptMeshInfo::GetRot, &GameScriptMeshInfo::SetRot),
/// (string) unique string identifier.
// e.g. "door_back_room" or "cracked_greek_statue"
// e.g. "my\_vase" or "oldrubble"
// @mem name
"name", sol::property(&GameScriptMeshInfo::GetName, &GameScriptMeshInfo::SetName),

View file

@ -3,13 +3,6 @@
#include <functional>
#include <string>
#define index_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE & item, sol::object key) \
{ \
std::string err = "Attempted to read non-existant var \"" + key.as<std::string>() + "\" from " + LUA_CLASS_NAME; \
throw TENScriptException(err); \
}
template <typename S> using callbackSetName = std::function<bool(std::string const&, S identifier)>;
using callbackRemoveName = std::function<bool(std::string const&)>;

View file

@ -3,6 +3,7 @@
#include "ScriptAssert.h"
#include "GameScriptSinkInfo.h"
#include "GameScriptPosition.h"
#include "ScriptUtil.h"
#include <sol.hpp>
/***
Sink info
@ -14,6 +15,7 @@ Sink info
constexpr auto LUA_CLASS_NAME{ "SinkInfo" };
static auto index_error = index_error_maker(GameScriptSinkInfo, LUA_CLASS_NAME);
static auto newindex_error = newindex_error_maker(GameScriptSinkInfo, LUA_CLASS_NAME);
GameScriptSinkInfo::GameScriptSinkInfo(SINK_INFO & ref, bool temp) : m_sink{ref}, m_temporary{ temp }
{};
@ -29,13 +31,14 @@ void GameScriptSinkInfo::Register(sol::state* state)
{
state->new_usertype<GameScriptSinkInfo>(LUA_CLASS_NAME,
sol::meta_function::index, index_error,
sol::meta_function::new_index, newindex_error,
/// (@{Position}) position in level
// @mem pos
"pos", sol::property(&GameScriptSinkInfo::GetPos, &GameScriptSinkInfo::SetPos),
/// (string) unique string identifier.
// e.g. "door\_back\_room" or "cracked\_greek\_statue"
// e.g. "strong\_river\_current" or "propeller\_death\_sink"
// @mem name
"name", sol::property(&GameScriptSinkInfo::GetName, &GameScriptSinkInfo::SetName),

View file

@ -2,6 +2,7 @@
#include "ScriptAssert.h"
#include "GameScriptSoundSourceInfo.h"
#include "GameScriptPosition.h"
#include "ScriptUtil.h"
/***
Sound source info
@ -12,6 +13,7 @@ Sound source info
static constexpr auto LUA_CLASS_NAME{ "SoundSourceInfo" };
static auto index_error = index_error_maker(GameScriptSoundSourceInfo, LUA_CLASS_NAME);
static auto newindex_error = newindex_error_maker(GameScriptSoundSourceInfo, LUA_CLASS_NAME);
GameScriptSoundSourceInfo::GameScriptSoundSourceInfo(SOUND_SOURCE_INFO & ref, bool temp) : m_soundSource{ref}, m_temporary{ temp }
{};
@ -27,13 +29,14 @@ void GameScriptSoundSourceInfo::Register(sol::state* state)
{
state->new_usertype<GameScriptSoundSourceInfo>(LUA_CLASS_NAME,
sol::meta_function::index, index_error,
sol::meta_function::new_index, newindex_error,
/// (@{Position}) position in level
// @mem pos
"pos", sol::property(&GameScriptSoundSourceInfo::GetPos, &GameScriptSoundSourceInfo::SetPos),
/// (string) unique string identifier.
// e.g. "machine_sound_1" or "discordant_humming"
// e.g. "machine\_sound\_1" or "discordant\_humming"
// @mem name
"name", sol::property(&GameScriptSoundSourceInfo::GetName, &GameScriptSoundSourceInfo::SetName),

View file

@ -1,12 +0,0 @@
#include "framework.h"
#include "LanguageScript.h"
using std::string;
LanguageScript::LanguageScript(char* name)
{
Name = string(name);
}
LanguageScript::~LanguageScript()
{
}

View file

@ -122,13 +122,3 @@
#define STRING_CLOCKWORK_BEETLE "clockwork_beetle"
#define STRING_CLOCKWORK_BEETLE_COMBO1 "clockwork_beetle_combo1"
#define STRING_CLOCKWORK_BEETLE_COMBO2 "clockwork_beetle_combo2"
class LanguageScript
{
public:
std::string Name;
std::unordered_map<size_t, std::string> Strings;
LanguageScript(char* name);
~LanguageScript();
};

View file

@ -0,0 +1,13 @@
#pragma once
#define index_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE & item, sol::object key) \
{ \
std::string err = "Attempted to read non-existant var \"" + key.as<std::string>() + "\" from " + LUA_CLASS_NAME; \
ScriptAssert(false, err);\
}
#define newindex_error_maker(CPP_TYPE, LUA_CLASS_NAME) [](CPP_TYPE & item, sol::object key) \
{ \
std::string err = "Attempted to set non-existant var \"" + key.as<std::string>() + "\" of " + LUA_CLASS_NAME; \
ScriptAssert(false, err);\
}

View file

@ -410,6 +410,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
<ClInclude Include="Scripting\LuaHandler.h" />
<ClInclude Include="Scripting\ObjectIDs.h" />
<ClInclude Include="Scripting\ScriptAssert.h" />
<ClInclude Include="Scripting\ScriptUtil.h" />
<ClInclude Include="Specific\configuration.h" />
<ClInclude Include="Specific\IO\ChunkId.h" />
<ClInclude Include="Specific\IO\ChunkWriter.h" />

View file

@ -1050,6 +1050,9 @@
<ClInclude Include="Scripting\ItemEnumPair.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Scripting\ScriptUtil.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Game\box.cpp">
@ -1151,9 +1154,6 @@
<ClCompile Include="Renderer\Renderer11.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Scripting\LanguageScript.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Specific\configuration.cpp">
<Filter>File di origine</Filter>
</ClCompile>

View file

@ -147,6 +147,10 @@ level file itself.</p>
<td class="summary">(byte) The maximum draw distance, in sectors (blocks), of this particular level.</td>
</tr>
<tr>
<td class="name" ><a href="#Level.unlimitedAir">Level.unlimitedAir</a></td>
<td class="summary">(bool) If true, the player will have an unlimited oxygen supply when in water.</td>
</tr>
<tr>
<td class="name" ><a href="#Level.objects">Level.objects</a></td>
<td class="summary">(table of <a href="../classes/InventoryObject.html#">InventoryObject</a>s) table of inventory object overrides</td>
</tr>
@ -270,8 +274,9 @@ level file itself.</p>
</dt>
<dd>
(<a href="../classes/Color.html#">Color</a>) distance fog RGB color (as seen in TR4's Desert Railroad).
If not provided, distance fog will be black.
<strong>(not yet implemented)</strong>
If not provided, distance fog will be black.</p>
<p> <strong>(not yet implemented)</strong>
@ -300,8 +305,9 @@ level file itself.</p>
</dt>
<dd>
(bool) if true, the horizon graphic will transition smoothly to the sky layer.
If set to false, there will be a black band between the two.
<strong>(not yet implemented)</strong>
If set to false, there will be a black band between the two.</p>
<p> <strong>(not yet implemented)</strong>
@ -316,8 +322,9 @@ level file itself.</p>
</dt>
<dd>
(bool) equivalent to classic TRLE's LIGHTNING setting.
If true, there will be a flickering lightning in the skylayer, as in the TRC Ireland levels.
<strong>(thunder sounds not yet implemented)</strong>
If true, there will be a flickering lightning in the skylayer, as in the TRC Ireland levels.</p>
<p> <strong>(thunder sounds not yet implemented)</strong>
@ -331,8 +338,9 @@ level file itself.</p>
<strong>Level.weather</strong>
</dt>
<dd>
(WeatherType) Must be one of the values WeatherType.NORMAL, WeatherType.RAIN, or WeatherType.SNOW.
<strong>(not yet implemented)</strong>
(WeatherType) Must be one of the values WeatherType.NORMAL, WeatherType.RAIN, or WeatherType.SNOW. </p>
<p> <strong>(not yet implemented)</strong>
@ -442,6 +450,22 @@ number, the faster the scroll will be.</p>
</dd>
<dt>
<a name = "Level.unlimitedAir"></a>
<strong>Level.unlimitedAir</strong>
</dt>
<dd>
(bool) If true, the player will have an unlimited oxygen supply when in water. </p>
<p> <strong>(not yet implemented)</strong>
</dd>
<dt>
<a name = "Level.objects"></a>
@ -487,7 +511,7 @@ number, the faster the scroll will be.</p>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-08-17 03:39:52 </i>
<i style="float:right;">Last updated 2021-08-20 01:47:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -142,7 +142,7 @@
</dt>
<dd>
(string) unique string identifier.
e.g. "door<em>back</em>room" or "cracked<em>greek</em>statue"
e.g. "my_vase" or "oldrubble"
@ -200,7 +200,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-08-16 12:53:44 </i>
<i style="float:right;">Last updated 2021-08-20 01:47:29 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -120,7 +120,7 @@
</dt>
<dd>
(string) unique string identifier.
e.g. "door_back_room" or "cracked_greek_statue"
e.g. "strong_river_current" or "propeller_death_sink"
@ -166,7 +166,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-08-16 12:53:44 </i>
<i style="float:right;">Last updated 2021-08-20 01:50:15 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View file

@ -120,7 +120,7 @@
</dt>
<dd>
(string) unique string identifier.
e.g. "machine<em>sound</em>1" or "discordant_humming"
e.g. "machine_sound_1" or "discordant_humming"
@ -164,7 +164,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-08-16 12:53:44 </i>
<i style="float:right;">Last updated 2021-08-20 01:50:15 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>