2021-07-28 18:44:24 +01:00
|
|
|
#include "framework.h"
|
|
|
|
#include "GameScriptLevel.h"
|
2021-08-17 13:36:34 +01:00
|
|
|
#include "ScriptAssert.h"
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
/***
|
|
|
|
A container for level metadata - things which aren't present in the compiled
|
|
|
|
level file itself.
|
|
|
|
|
|
|
|
@classmod Level
|
|
|
|
@pragma nostrip
|
|
|
|
*/
|
2021-07-28 18:44:24 +01:00
|
|
|
|
2021-08-11 14:50:10 +01:00
|
|
|
/*** Make a new Level object.
|
|
|
|
@function Level.new
|
|
|
|
@return a Level object
|
|
|
|
*/
|
2021-07-28 18:44:24 +01:00
|
|
|
void GameScriptLevel::Register(sol::state* state)
|
|
|
|
{
|
|
|
|
state->new_usertype<GameScriptLevel>("Level",
|
|
|
|
sol::constructors<GameScriptLevel()>(),
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-09 20:02:55 +01:00
|
|
|
/// (string) string key for the level's (localised) name. Corresponds to an entry in strings.lua.
|
|
|
|
//@mem nameKey
|
|
|
|
"nameKey", &GameScriptLevel::NameStringKey,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-09 20:02:55 +01:00
|
|
|
/// (string) path of the Lua file holding the level's logic script, relative to the location of the tombengine executable
|
|
|
|
//@mem scriptFile
|
|
|
|
"scriptFile", &GameScriptLevel::ScriptFileName,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-09 20:02:55 +01:00
|
|
|
/// (string) path of the compiled level file, relative to the location of the tombengine executable
|
|
|
|
//@mem levelFile
|
|
|
|
"levelFile", &GameScriptLevel::FileName,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-09 20:02:55 +01:00
|
|
|
/// (string) path of the level's load screen file (.png or .jpg), relative to the location of the tombengine executable
|
|
|
|
//@mem loadScreenFile
|
|
|
|
"loadScreenFile", &GameScriptLevel::LoadScreenFileName,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-09 20:02:55 +01:00
|
|
|
/// (string) initial ambient sound track to play - this is the filename of the track __without__ the .wav extension
|
2021-08-07 19:20:17 +01:00
|
|
|
//@mem ambientTrack
|
2021-07-28 18:44:24 +01:00
|
|
|
"ambientTrack", &GameScriptLevel::AmbientTrack,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
/// (@{SkyLayer}) Primary sky layer
|
|
|
|
//@mem layer1
|
2021-07-28 18:44:24 +01:00
|
|
|
"layer1", &GameScriptLevel::Layer1,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
/// (@{SkyLayer}) Secondary sky layer __(not yet implemented)__
|
|
|
|
//@mem layer2
|
2021-07-28 18:44:24 +01:00
|
|
|
"layer2", &GameScriptLevel::Layer2,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
/// (@{Color}) distance fog RGB color (as seen in TR4's Desert Railroad).
|
2021-08-17 13:36:34 +01:00
|
|
|
// If not provided, distance fog will be black.
|
|
|
|
//
|
2021-08-07 19:20:17 +01:00
|
|
|
// __(not yet implemented)__
|
|
|
|
//@mem fog
|
2021-07-28 18:44:24 +01:00
|
|
|
"fog", &GameScriptLevel::Fog,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
/// (bool) if set to true, the horizon and sky layer will be drawn; if set to false; they won't.
|
|
|
|
//@mem horizon
|
2021-07-28 18:44:24 +01:00
|
|
|
"horizon", &GameScriptLevel::Horizon,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
/// (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.
|
2021-08-17 13:36:34 +01:00
|
|
|
//
|
2021-08-07 19:20:17 +01:00
|
|
|
// __(not yet implemented)__
|
|
|
|
//@mem colAddHorizon
|
2021-07-28 18:44:24 +01:00
|
|
|
"colAddHorizon", &GameScriptLevel::ColAddHorizon,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
/// (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.
|
2021-08-17 13:36:34 +01:00
|
|
|
//
|
2021-08-07 19:20:17 +01:00
|
|
|
// __(thunder sounds not yet implemented)__
|
|
|
|
//@mem storm
|
2021-07-28 18:44:24 +01:00
|
|
|
"storm", &GameScriptLevel::Storm,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
/// (WeatherType) Must be one of the values WeatherType.NORMAL, WeatherType.RAIN, or WeatherType.SNOW.
|
2021-08-17 13:36:34 +01:00
|
|
|
//
|
2021-08-07 19:20:17 +01:00
|
|
|
// __(not yet implemented)__
|
|
|
|
//@mem weather
|
2021-07-28 18:44:24 +01:00
|
|
|
"weather", &GameScriptLevel::Weather,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
/*** (LaraType) Must be one of the LaraType values.
|
|
|
|
These are:
|
|
|
|
|
|
|
|
NORMAL
|
|
|
|
YOUNG
|
|
|
|
BUNHEAD
|
|
|
|
CATSUIT
|
|
|
|
DIVESUIT
|
|
|
|
INVISIBLE
|
|
|
|
|
|
|
|
e.g. `myLevel.laraType = LaraType.DIVESUIT`
|
|
|
|
|
|
|
|
__(not yet fully implemented)__
|
|
|
|
@mem laraType*/
|
2021-07-28 18:44:24 +01:00
|
|
|
"laraType", &GameScriptLevel::LaraType,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-09 00:07:08 +01:00
|
|
|
/// (bool) If true, an occasional screen shake effect (as seen in TRC's Sinking Submarine) will
|
|
|
|
// happen throughout the level.
|
2021-08-07 19:20:17 +01:00
|
|
|
//@mem rumble
|
2021-07-28 18:44:24 +01:00
|
|
|
"rumble", &GameScriptLevel::Rumble,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-11 14:50:10 +01:00
|
|
|
/// (@{Mirror}) object holding the location and size of the room's mirror, if present.
|
2021-08-17 13:36:34 +01:00
|
|
|
//
|
2021-08-09 00:07:08 +01:00
|
|
|
// __(not yet implemented)__
|
2021-08-07 19:20:17 +01:00
|
|
|
//@mem mirror
|
2021-07-28 18:44:24 +01:00
|
|
|
"mirror", &GameScriptLevel::Mirror,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-17 13:36:34 +01:00
|
|
|
/*** (byte) Default speed of "UVRotate" animated textures.
|
|
|
|
|
|
|
|
Must be in the range [-64, 64].
|
|
|
|
|
|
|
|
A level texture can be set in Tomb Editor to use "UVRotate" animation.
|
|
|
|
This gives the effect of the texture looping downwards or upwards in place.
|
|
|
|
Positive values will cause the texture to loop downwards, and negative values
|
|
|
|
will cause an upwards loop. The higher a positive number or the lower a negative
|
|
|
|
number, the faster the scroll will be.
|
|
|
|
|
|
|
|
__(not yet implemented)__
|
|
|
|
@mem UVRotate*/
|
|
|
|
"UVRotate", sol::property(&GameScriptLevel::SetUVRotate),
|
|
|
|
|
|
|
|
/*** (byte) The maximum draw distance, in sectors (blocks), of this particular level.
|
|
|
|
|
|
|
|
Must be in the range [1, 127], and equal to or less than the value passed to SetGameFarView.
|
|
|
|
|
|
|
|
This is equivalent to TRNG's LevelFarView variable.
|
|
|
|
|
|
|
|
__(not yet implemented)__
|
|
|
|
@mem farView
|
|
|
|
*/
|
|
|
|
"farView", sol::property(&GameScriptLevel::SetLevelFarView),
|
2021-08-20 01:48:06 +01:00
|
|
|
|
|
|
|
/*** (bool) If true, the player will have an unlimited oxygen supply when in water.
|
|
|
|
|
|
|
|
__(not yet implemented)__
|
|
|
|
@mem unlimitedAir
|
|
|
|
*/
|
|
|
|
"unlimitedAir", &GameScriptLevel::UnlimitedAir,
|
|
|
|
|
2021-08-11 14:50:10 +01:00
|
|
|
/// (table of @{InventoryObject}s) table of inventory object overrides
|
2021-08-09 20:02:55 +01:00
|
|
|
//@mem objects
|
2021-07-28 18:44:24 +01:00
|
|
|
"objects", &GameScriptLevel::InventoryObjects
|
|
|
|
);
|
|
|
|
}
|
2021-08-17 13:36:34 +01:00
|
|
|
|
|
|
|
void GameScriptLevel::SetUVRotate(byte val)
|
|
|
|
{
|
|
|
|
bool cond = val <= 64 && val >= -64;
|
|
|
|
std::string msg{ "UVRotate value must be in the range [-64, 64]." };
|
|
|
|
if (!ScriptAssert(cond, msg))
|
|
|
|
{
|
|
|
|
ScriptWarn("Setting UVRotate to 0.");
|
|
|
|
UVRotate = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
UVRotate = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameScriptLevel::SetLevelFarView(byte val)
|
|
|
|
{
|
|
|
|
bool cond = val <= 127 && val >= 1;
|
|
|
|
std::string msg{ "levelFarView value must be in the range [1, 127]." };
|
|
|
|
if (!ScriptAssert(cond, msg))
|
|
|
|
{
|
|
|
|
ScriptWarn("Setting levelFarView view to 32.");
|
|
|
|
LevelFarView = 32;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LevelFarView = val;
|
|
|
|
}
|
|
|
|
}
|