mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-12 21:47:03 +03:00
Use script for setting weather
This commit is contained in:
parent
16bbeb48a9
commit
c4090b7c9a
14 changed files with 91 additions and 115 deletions
|
@ -714,12 +714,10 @@ void LaraControl(ITEM_INFO* item, COLL_INFO* coll)
|
|||
case LW_UNDERWATER:
|
||||
if (item->hitPoints >= 0)
|
||||
{
|
||||
if (LaraDrawType == LARA_TYPE::DIVESUIT)
|
||||
{
|
||||
/* Hardcoded code */
|
||||
}
|
||||
else
|
||||
auto level = g_GameFlow->GetLevel(CurrentLevel);
|
||||
if (level->LaraType != LaraType::Divesuit)
|
||||
Lara.air--;
|
||||
|
||||
if (Lara.air < 0)
|
||||
{
|
||||
// if (LaraDrawType == LARA_TYPE::DIVESUIT && Lara.anxiety < 251)
|
||||
|
@ -912,7 +910,9 @@ void LaraUnderWater(ITEM_INFO* item, COLL_INFO* coll)
|
|||
|
||||
lara_control_routines[item->currentAnimState](item, coll);
|
||||
|
||||
if (LaraDrawType == LARA_TYPE::DIVESUIT)
|
||||
auto level = g_GameFlow->GetLevel(CurrentLevel);
|
||||
|
||||
if (level->LaraType == LaraType::Divesuit)
|
||||
{
|
||||
if (Lara.turnRate < -ANGLE(0.5f))
|
||||
Lara.turnRate += ANGLE(0.5f);
|
||||
|
@ -930,7 +930,7 @@ void LaraUnderWater(ITEM_INFO* item, COLL_INFO* coll)
|
|||
|
||||
item->pos.yRot += Lara.turnRate;
|
||||
|
||||
if (LaraDrawType == LARA_TYPE::DIVESUIT)
|
||||
if (level->LaraType == LaraType::Divesuit)
|
||||
UpdateSubsuitAngles();
|
||||
|
||||
if (item->pos.zRot < -ANGLE(2.0f))
|
||||
|
@ -945,7 +945,7 @@ void LaraUnderWater(ITEM_INFO* item, COLL_INFO* coll)
|
|||
else if (item->pos.xRot > ANGLE(85.0f))
|
||||
item->pos.xRot = ANGLE(85.0f);
|
||||
|
||||
if (LaraDrawType == LARA_TYPE::DIVESUIT)
|
||||
if (level->LaraType == LaraType::Divesuit)
|
||||
{
|
||||
if (item->pos.zRot > ANGLE(44.0f))
|
||||
item->pos.zRot = ANGLE(44.0f);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "lara_tests.h"
|
||||
#include "items.h"
|
||||
#include "setup.h"
|
||||
#include "GameFlowScript.h"
|
||||
#include "GameScriptLevel.h"
|
||||
|
||||
/*this file has all the generic **collision** test functions called in lara's state code*/
|
||||
|
@ -370,8 +371,9 @@ void LaraSwimCollision(ITEM_INFO* item, COLL_INFO* coll)
|
|||
int height = LARA_HEIGHT * phd_sin(item->pos.xRot);
|
||||
height = abs(height);
|
||||
|
||||
if (height < ((LaraDrawType == LARA_TYPE::DIVESUIT) << 6) + 200)
|
||||
height = ((LaraDrawType == LARA_TYPE::DIVESUIT) << 6) + 200;
|
||||
auto level = g_GameFlow->GetLevel(CurrentLevel);
|
||||
if (height < ((level->LaraType == LaraType::Divesuit) << 6) + 200)
|
||||
height = ((level->LaraType == LaraType::Divesuit) << 6) + 200;
|
||||
|
||||
coll->Setup.BadHeightUp = -(STEP_SIZE / 4);
|
||||
coll->Setup.Height = height;
|
||||
|
|
|
@ -360,7 +360,7 @@ void LaraGun()
|
|||
{
|
||||
Lara.requestGunType = Lara.lastGunType;
|
||||
}
|
||||
else if (TrInput & IN_FLARE && (g_GameFlow->GetLevel(CurrentLevel)->LaraType != LARA_TYPE::YOUNG))
|
||||
else if (TrInput & IN_FLARE && (g_GameFlow->GetLevel(CurrentLevel)->LaraType != LaraType::Young))
|
||||
{
|
||||
if (LaraItem->currentAnimState == LS_CROUCH_IDLE && LaraItem->animNumber != LA_CROUCH_IDLE)
|
||||
return;
|
||||
|
|
|
@ -99,11 +99,12 @@ void lara_as_tread(ITEM_INFO* item, COLL_INFO* coll)
|
|||
if (item->hitPoints <= 0)
|
||||
{
|
||||
item->goalAnimState = LS_WATER_DEATH;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (TrInput & IN_ROLL && LaraDrawType != LARA_TYPE::DIVESUIT)
|
||||
auto level = g_GameFlow->GetLevel(CurrentLevel);
|
||||
|
||||
if (TrInput & IN_ROLL && level->LaraType != LaraType::Divesuit)
|
||||
{
|
||||
SetAnimation(item, LA_UNDERWATER_ROLL_180_START);
|
||||
return;
|
||||
|
@ -112,7 +113,7 @@ void lara_as_tread(ITEM_INFO* item, COLL_INFO* coll)
|
|||
if (TrInput & IN_LOOK)
|
||||
LookUpDown();
|
||||
|
||||
if (LaraDrawType == LARA_TYPE::DIVESUIT)
|
||||
if (level->LaraType == LaraType::Divesuit)
|
||||
SwimTurnSubsuit(item);
|
||||
else
|
||||
SwimTurn(item);
|
||||
|
@ -134,17 +135,18 @@ void lara_as_glide(ITEM_INFO* item, COLL_INFO* coll)
|
|||
if (item->hitPoints <= 0)
|
||||
{
|
||||
item->goalAnimState = LS_WATER_DEATH;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (TrInput & IN_ROLL && LaraDrawType != LARA_TYPE::DIVESUIT)
|
||||
auto level = g_GameFlow->GetLevel(CurrentLevel);
|
||||
|
||||
if (TrInput & IN_ROLL && level->LaraType != LaraType::Divesuit)
|
||||
{
|
||||
SetAnimation(item, LA_UNDERWATER_ROLL_180_START);
|
||||
return;
|
||||
}
|
||||
|
||||
if (LaraDrawType != LARA_TYPE::DIVESUIT)
|
||||
if (level->LaraType != LaraType::Divesuit)
|
||||
SwimTurn(item);
|
||||
else
|
||||
SwimTurnSubsuit(item);
|
||||
|
@ -165,17 +167,18 @@ void lara_as_swim(ITEM_INFO* item, COLL_INFO* coll)
|
|||
if (item->hitPoints <= 0)
|
||||
{
|
||||
item->goalAnimState = LS_WATER_DEATH;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (TrInput & IN_ROLL && LaraDrawType != LARA_TYPE::DIVESUIT)
|
||||
auto level = g_GameFlow->GetLevel(CurrentLevel);
|
||||
|
||||
if (TrInput & IN_ROLL && level->LaraType != LaraType::Divesuit)
|
||||
{
|
||||
SetAnimation(item, LA_UNDERWATER_ROLL_180_START);
|
||||
return;
|
||||
}
|
||||
|
||||
if (LaraDrawType != LARA_TYPE::DIVESUIT)
|
||||
if (level->LaraType != LaraType::Divesuit)
|
||||
SwimTurn(item);
|
||||
else
|
||||
SwimTurnSubsuit(item);
|
||||
|
|
|
@ -81,9 +81,6 @@ short NextItemFree;
|
|||
short NextFxActive;
|
||||
short NextFxFree;
|
||||
|
||||
int WeatherType;
|
||||
int LaraDrawType;
|
||||
|
||||
int WeaponDelay;
|
||||
int WeaponEnemyTimer;
|
||||
|
||||
|
@ -347,7 +344,7 @@ GAME_STATUS ControlPhase(int numFrames, int demoMode)
|
|||
|
||||
// Update Lara's ponytails
|
||||
HairControl(0, 0, 0);
|
||||
if (level->LaraType == LARA_TYPE::YOUNG)
|
||||
if (level->LaraType == LaraType::Young)
|
||||
HairControl(0, 1, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,9 +58,6 @@ extern short NextItemFree;
|
|||
extern short NextFxActive;
|
||||
extern short NextFxFree;
|
||||
|
||||
extern int WeatherType;
|
||||
extern int LaraDrawType;
|
||||
|
||||
extern int WeaponDelay;
|
||||
extern int WeaponEnemyTimer;
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ void HairControl(int cutscene, int ponytail, ANIM_FRAME* framePtr)
|
|||
OBJECT_INFO* object = &Objects[ID_LARA];
|
||||
ANIM_FRAME* frame;
|
||||
int spaz;
|
||||
bool youngLara = g_GameFlow->GetLevel(CurrentLevel)->LaraType == LARA_TYPE::YOUNG;
|
||||
bool youngLara = g_GameFlow->GetLevel(CurrentLevel)->LaraType == LaraType::Young;
|
||||
|
||||
if (framePtr == NULL)
|
||||
{
|
||||
|
|
|
@ -1039,7 +1039,9 @@ void LaraBubbles(ITEM_INFO* item)
|
|||
|
||||
pos.x = 0;
|
||||
|
||||
if (LaraDrawType == LARA_TYPE::DIVESUIT)
|
||||
auto level = g_GameFlow->GetLevel(CurrentLevel);
|
||||
|
||||
if (level->LaraType == LaraType::Divesuit)
|
||||
{
|
||||
pos.y = -192;
|
||||
pos.z = -160;
|
||||
|
|
|
@ -66,17 +66,9 @@ namespace Environment
|
|||
FlashColorBase = Vector3::Zero;
|
||||
|
||||
// Clear weather
|
||||
Weather = WeatherType::None;
|
||||
WeatherStrength = 1.0f;
|
||||
Particles.clear();
|
||||
}
|
||||
|
||||
void EnvironmentController::SetWeather(WeatherType weather, float strength)
|
||||
{
|
||||
Weather = weather;
|
||||
WeatherStrength = strength;
|
||||
}
|
||||
|
||||
void EnvironmentController::Flash(int r, int g, int b, float speed)
|
||||
{
|
||||
FlashProgress = 1.0f;
|
||||
|
@ -330,14 +322,14 @@ namespace Environment
|
|||
if (Particles.size() > 0)
|
||||
Particles.erase(std::remove_if(Particles.begin(), Particles.end(), [](const WeatherParticle& part) { return !part.Enabled; }), Particles.end());
|
||||
|
||||
if (Weather == WeatherType::None || WeatherStrength == 0.0f)
|
||||
if (level->Weather == WeatherType::None || level->WeatherStrength == 0.0f)
|
||||
return;
|
||||
|
||||
int spawnDensity = round((float)(Weather == WeatherType::Rain ? RAIN_SPAWN_DENSITY : SNOW_SPAWN_DENSITY) * WeatherStrength);
|
||||
int maxCount = (Weather == WeatherType::Rain) ? WEATHER_PARTICLES_MAX_COUNT : WEATHER_PARTICLES_MAX_COUNT / SNOW_PARTICLES_COUNT_DIVIDER;
|
||||
int spawnDensity = round((float)(level->Weather == WeatherType::Rain ? RAIN_SPAWN_DENSITY : SNOW_SPAWN_DENSITY) * level->WeatherStrength);
|
||||
int maxCount = (level->Weather == WeatherType::Rain) ? WEATHER_PARTICLES_MAX_COUNT : WEATHER_PARTICLES_MAX_COUNT / SNOW_PARTICLES_COUNT_DIVIDER;
|
||||
int newParticlesCount = 0;
|
||||
|
||||
if (Weather != WeatherType::None)
|
||||
if (level->Weather != WeatherType::None)
|
||||
{
|
||||
while (Particles.size() < maxCount)
|
||||
{
|
||||
|
@ -361,7 +353,7 @@ namespace Environment
|
|||
|
||||
auto part = WeatherParticle();
|
||||
|
||||
switch (Weather)
|
||||
switch (level->Weather)
|
||||
{
|
||||
case WeatherType::Snow:
|
||||
part.Size = MAX_SNOW_SIZE + ((GetRandomDraw() & (MAX_SNOW_SIZE / 2)) - (MAX_SNOW_SIZE / 2));
|
||||
|
@ -380,7 +372,7 @@ namespace Environment
|
|||
break;
|
||||
}
|
||||
|
||||
part.Type = Weather;
|
||||
part.Type = level->Weather;
|
||||
part.Room = IsRoomOutsideNo;
|
||||
part.Position.x = xPos;
|
||||
part.Position.y = yPos;
|
||||
|
|
|
@ -20,13 +20,6 @@ namespace Environment
|
|||
|
||||
constexpr auto SKY_POSITION_LIMIT = 9728;
|
||||
|
||||
enum class WeatherType
|
||||
{
|
||||
None,
|
||||
Rain,
|
||||
Snow
|
||||
};
|
||||
|
||||
struct WeatherParticle
|
||||
{
|
||||
WeatherType Type;
|
||||
|
@ -65,8 +58,6 @@ namespace Environment
|
|||
|
||||
private:
|
||||
// Weather
|
||||
float WeatherStrength = 1.0f;
|
||||
WeatherType Weather = WeatherType::Snow;
|
||||
std::vector<WeatherParticle> Particles;
|
||||
|
||||
// Sky
|
||||
|
|
|
@ -1928,7 +1928,7 @@ void InventoryClass::construct_object_list()
|
|||
CurrentGrenadeGunAmmoType = 0;
|
||||
CurrentCrossBowAmmoType = 0;
|
||||
|
||||
if (!(g_GameFlow->GetLevel(CurrentLevel)->LaraType == LARA_TYPE::YOUNG))
|
||||
if (!(g_GameFlow->GetLevel(CurrentLevel)->LaraType == LaraType::Young))
|
||||
{
|
||||
if (Lara.Weapons[WEAPON_PISTOLS].Present)
|
||||
insert_object_into_list(INV_OBJECT_PISTOLS);
|
||||
|
@ -2133,7 +2133,7 @@ void InventoryClass::construct_combine_object_list()
|
|||
for (int i = 0; i < INVENTORY_TABLE_SIZE; i++)
|
||||
rings[RING_AMMO]->current_object_list[i].invitem = NO_ITEM;
|
||||
|
||||
if (!(g_GameFlow->GetLevel(CurrentLevel)->LaraType == LARA_TYPE::YOUNG))
|
||||
if (!(g_GameFlow->GetLevel(CurrentLevel)->LaraType == LaraType::Young))
|
||||
{
|
||||
if (Lara.Weapons[WEAPON_REVOLVER].Present)
|
||||
{
|
||||
|
|
|
@ -75,28 +75,32 @@ void GameScriptLevel::Register(sol::state* state)
|
|||
/// (bool) Enable flickering lightning in the sky.
|
||||
// Equivalent to classic TRLE's LIGHTNING setting. As in the TRC Ireland levels.
|
||||
//
|
||||
// __(thunder sounds not yet implemented)__
|
||||
//@mem storm
|
||||
"storm", &GameScriptLevel::Storm,
|
||||
|
||||
/// (WeatherType) Choose weather effect.
|
||||
// Must be one of the values `WeatherType.NORMAL`, `WeatherType.RAIN`, or `WeatherType.SNOW`.
|
||||
// Must be one of the values `WeatherType.None`, `WeatherType.Rain`, or `WeatherType.Snow`.
|
||||
//
|
||||
// __(not yet implemented)__
|
||||
//@mem weather
|
||||
"weather", &GameScriptLevel::Weather,
|
||||
|
||||
/// (float) Choose weather strength.
|
||||
// Must be value between `0.1` and `1.0`.
|
||||
//
|
||||
//@mem weatherStrength
|
||||
"weatherStrength", sol::property(&GameScriptLevel::SetWeatherStrength),
|
||||
|
||||
/*** (LaraType) Must be one of the LaraType values.
|
||||
These are:
|
||||
|
||||
NORMAL
|
||||
YOUNG
|
||||
BUNHEAD
|
||||
CATSUIT
|
||||
DIVESUIT
|
||||
INVISIBLE
|
||||
Normal
|
||||
Young
|
||||
Bunhead
|
||||
Catsuit
|
||||
Divesuit
|
||||
Invisible
|
||||
|
||||
e.g. `myLevel.laraType = LaraType.DIVESUIT`
|
||||
e.g. `myLevel.laraType = LaraType.Divesuit`
|
||||
|
||||
__(not yet fully implemented)__
|
||||
@mem laraType*/
|
||||
|
@ -113,20 +117,6 @@ e.g. `myLevel.laraType = LaraType.DIVESUIT`
|
|||
//@mem mirror
|
||||
"mirror", &GameScriptLevel::Mirror,
|
||||
|
||||
/*** (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 for level.
|
||||
Given in sectors (blocks).
|
||||
Must be in the range [1, 127], and equal to or less than the value passed to SetGameFarView.
|
||||
|
@ -151,18 +141,18 @@ __(not yet implemented)__
|
|||
);
|
||||
}
|
||||
|
||||
void GameScriptLevel::SetUVRotate(byte val)
|
||||
void GameScriptLevel::SetWeatherStrength(float val)
|
||||
{
|
||||
bool cond = val <= 64 && val >= -64;
|
||||
std::string msg{ "UVRotate value must be in the range [-64, 64]." };
|
||||
bool cond = val <= 1.0f && val >= 0.0f;
|
||||
std::string msg{ "weatherStrength value must be in the range [0.1, 1.0]." };
|
||||
if (!ScriptAssert(cond, msg))
|
||||
{
|
||||
ScriptWarn("Setting UVRotate to 0.");
|
||||
UVRotate = 0;
|
||||
ScriptWarn("Setting weatherStrength view to 1.");
|
||||
WeatherStrength = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
UVRotate = val;
|
||||
WeatherStrength = val;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,36 +5,38 @@
|
|||
#include "GameScriptColor.h"
|
||||
#include "GameScriptInventoryObject.h"
|
||||
|
||||
enum class WEATHER_TYPE
|
||||
enum class WeatherType
|
||||
{
|
||||
NORMAL,
|
||||
RAIN,
|
||||
SNOW
|
||||
None,
|
||||
Rain,
|
||||
Snow
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, WEATHER_TYPE> kWeatherTypes{
|
||||
{"NORMAL", WEATHER_TYPE::NORMAL},
|
||||
{"RAIN", WEATHER_TYPE::RAIN},
|
||||
{"SNOW", WEATHER_TYPE::SNOW}
|
||||
};
|
||||
|
||||
enum LARA_TYPE
|
||||
static const std::unordered_map<std::string, WeatherType> kWeatherTypes
|
||||
{
|
||||
NORMAL = 1,
|
||||
YOUNG = 2,
|
||||
BUNHEAD = 3,
|
||||
CATSUIT = 4,
|
||||
DIVESUIT = 5,
|
||||
INVISIBLE = 7
|
||||
{"None", WeatherType::None},
|
||||
{"Rain", WeatherType::Rain},
|
||||
{"Snow", WeatherType::Snow}
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, LARA_TYPE> kLaraTypes{
|
||||
{"NORMAL", LARA_TYPE::NORMAL},
|
||||
{"YOUNG", LARA_TYPE::YOUNG},
|
||||
{"BUNHEAD", LARA_TYPE::BUNHEAD},
|
||||
{"CATSUIT", LARA_TYPE::CATSUIT},
|
||||
{"DIVESUIT", LARA_TYPE::DIVESUIT},
|
||||
{"INVISIBLE", LARA_TYPE::INVISIBLE}
|
||||
enum LaraType
|
||||
{
|
||||
Normal = 1,
|
||||
Young = 2,
|
||||
Bunhead = 3,
|
||||
Catsuit = 4,
|
||||
Divesuit = 5,
|
||||
Invisible = 7
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, LaraType> kLaraTypes
|
||||
{
|
||||
{"Normal", LaraType::Normal},
|
||||
{"Young", LaraType::Young},
|
||||
{"Bunhead", LaraType::Bunhead},
|
||||
{"Catsuit", LaraType::Catsuit},
|
||||
{"Divesuit", LaraType::Divesuit},
|
||||
{"Invisible", LaraType::Invisible}
|
||||
};
|
||||
|
||||
struct GameScriptLevel
|
||||
|
@ -50,16 +52,16 @@ struct GameScriptLevel
|
|||
bool ColAddHorizon{ false };
|
||||
GameScriptColor Fog{ 0, 0, 0 };
|
||||
bool Storm{ false };
|
||||
WEATHER_TYPE Weather{ WEATHER_TYPE::NORMAL };
|
||||
WeatherType Weather{ WeatherType::None };
|
||||
float WeatherStrength{ 1.0f };
|
||||
bool Rumble{ false };
|
||||
LARA_TYPE LaraType{ LARA_TYPE::NORMAL };
|
||||
LaraType LaraType{ LaraType::Normal };
|
||||
GameScriptMirror Mirror;
|
||||
byte UVRotate{ 0 };
|
||||
int LevelFarView{ 0 };
|
||||
bool UnlimitedAir{ false };
|
||||
std::vector<GameScriptInventoryObject> InventoryObjects;
|
||||
|
||||
void SetUVRotate(byte val);
|
||||
void SetWeatherStrength(float val);
|
||||
void SetLevelFarView(byte val);
|
||||
static void Register(sol::state* state);
|
||||
};
|
||||
|
|
|
@ -1044,8 +1044,8 @@ unsigned CALLBACK LoadLevel(void* data)
|
|||
|
||||
g_Renderer.updateProgress(20);
|
||||
|
||||
WeatherType = ReadInt8();
|
||||
LaraDrawType = ReadInt8();
|
||||
ReadInt8(); // TODO: Remove!
|
||||
ReadInt8(); // TODO: Remove!
|
||||
|
||||
LoadRooms();
|
||||
g_Renderer.updateProgress(40);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue