2021-07-28 18:44:24 +01:00
|
|
|
#include "framework.h"
|
2021-11-25 23:34:02 +00:00
|
|
|
#include <sol.hpp>
|
2021-07-28 18:44:24 +01:00
|
|
|
#include "GameScriptLevel.h"
|
2021-08-17 13:36:34 +01:00
|
|
|
#include "ScriptAssert.h"
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
/***
|
2021-08-23 19:16:24 +01:00
|
|
|
Stores level metadata.
|
|
|
|
These are things things which aren't present in the compiled level file itself.
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
@pregameclass Level
|
2021-08-07 19:20:17 +01:00
|
|
|
@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-23 19:16:24 +01:00
|
|
|
/// (string) string key for the level's (localised) name.
|
|
|
|
// Corresponds to an entry in strings.lua.
|
2021-08-09 20:02:55 +01:00
|
|
|
//@mem nameKey
|
|
|
|
"nameKey", &GameScriptLevel::NameStringKey,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
/// (string) Level-specific Lua script file.
|
|
|
|
// Path of the Lua file holding the level's logic script, relative to the location of the tombengine executable
|
2021-08-09 20:02:55 +01:00
|
|
|
//@mem scriptFile
|
|
|
|
"scriptFile", &GameScriptLevel::ScriptFileName,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
/// (string) Compiled file path.
|
|
|
|
// This path is relative to the location of the TombEngine executable.
|
2021-08-09 20:02:55 +01:00
|
|
|
//@mem levelFile
|
|
|
|
"levelFile", &GameScriptLevel::FileName,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
/// (string) Load screen image.
|
|
|
|
// Path of the level's load screen file (.png or .jpg), relative to the location of the tombengine executable
|
2021-08-09 20:02:55 +01:00
|
|
|
//@mem loadScreenFile
|
|
|
|
"loadScreenFile", &GameScriptLevel::LoadScreenFileName,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-23 19:16:24 +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
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
/// (@{SkyLayer}) Secondary sky layer
|
|
|
|
// __(not yet implemented)__
|
2021-08-07 19:20:17 +01:00
|
|
|
//@mem layer2
|
2021-07-28 18:44:24 +01:00
|
|
|
"layer2", &GameScriptLevel::Layer2,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-11-22 16:16:58 +01:00
|
|
|
/// (@{Fog}) omni fog RGB color and distance.
|
2021-08-23 19:16:24 +01:00
|
|
|
// 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
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
/// (bool) Draw sky layer? (default: false)
|
2021-08-07 19:20:17 +01:00
|
|
|
//@mem horizon
|
2021-07-28 18:44:24 +01:00
|
|
|
"horizon", &GameScriptLevel::Horizon,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
/// (bool) Enable smooth transition from horizon graphic to sky layer.
|
2021-08-07 19:20:17 +01:00
|
|
|
// 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
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
/// (bool) Enable flickering lightning in the sky.
|
|
|
|
// Equivalent to classic TRLE's LIGHTNING setting. As in the TRC Ireland levels.
|
2021-08-23 19:22:31 +01:00
|
|
|
//
|
2021-08-07 19:20:17 +01:00
|
|
|
//@mem storm
|
2021-07-28 18:44:24 +01:00
|
|
|
"storm", &GameScriptLevel::Storm,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
/// (WeatherType) Choose weather effect.
|
2021-11-11 01:16:27 +03:00
|
|
|
// Must be one of the values `WeatherType.None`, `WeatherType.Rain`, or `WeatherType.Snow`.
|
2021-08-17 13:36:34 +01:00
|
|
|
//
|
2021-08-07 19:20:17 +01:00
|
|
|
//@mem weather
|
2021-07-28 18:44:24 +01:00
|
|
|
"weather", &GameScriptLevel::Weather,
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-11-11 01:16:27 +03:00
|
|
|
/// (float) Choose weather strength.
|
|
|
|
// Must be value between `0.1` and `1.0`.
|
|
|
|
//
|
|
|
|
//@mem weatherStrength
|
|
|
|
"weatherStrength", sol::property(&GameScriptLevel::SetWeatherStrength),
|
|
|
|
|
2021-08-07 19:20:17 +01:00
|
|
|
/*** (LaraType) Must be one of the LaraType values.
|
|
|
|
These are:
|
|
|
|
|
2021-11-11 01:16:27 +03:00
|
|
|
Normal
|
|
|
|
Young
|
|
|
|
Bunhead
|
|
|
|
Catsuit
|
|
|
|
Divesuit
|
|
|
|
Invisible
|
2021-08-07 19:20:17 +01:00
|
|
|
|
2021-11-11 01:16:27 +03:00
|
|
|
e.g. `myLevel.laraType = LaraType.Divesuit`
|
2021-08-07 19:20:17 +01:00
|
|
|
|
|
|
|
__(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-23 19:16:24 +01:00
|
|
|
/// (bool) Enable occasional screen shake effect.
|
|
|
|
// As seen in TRC's Sinking Submarine.
|
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-23 19:16:24 +01:00
|
|
|
/// (@{Mirror}) Location and size of the level'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-23 19:16:24 +01:00
|
|
|
/*** (byte) The maximum draw distance for level.
|
|
|
|
Given in sectors (blocks).
|
2021-08-17 13:36:34 +01:00
|
|
|
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
|
|
|
|
2021-08-23 19:16:24 +01:00
|
|
|
/*** (bool) Enable unlimited oxygen supply when in water.
|
2021-08-20 01:48:06 +01:00
|
|
|
|
|
|
|
__(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
|
|
|
|
2021-11-11 01:16:27 +03:00
|
|
|
void GameScriptLevel::SetWeatherStrength(float val)
|
2021-08-17 13:36:34 +01:00
|
|
|
{
|
2021-11-11 01:16:27 +03:00
|
|
|
bool cond = val <= 1.0f && val >= 0.0f;
|
|
|
|
std::string msg{ "weatherStrength value must be in the range [0.1, 1.0]." };
|
2021-08-17 13:36:34 +01:00
|
|
|
if (!ScriptAssert(cond, msg))
|
|
|
|
{
|
2021-11-11 01:16:27 +03:00
|
|
|
ScriptWarn("Setting weatherStrength view to 1.");
|
|
|
|
WeatherStrength = 1.0f;
|
2021-08-17 13:36:34 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-11 01:16:27 +03:00
|
|
|
WeatherStrength = val;
|
2021-08-17 13:36:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|