Update animation script

This commit is contained in:
Sezz 2022-03-04 15:51:53 +11:00
parent 3d2e4f5242
commit c8d34bfccb
10 changed files with 60 additions and 65 deletions

View file

@ -1,7 +1,7 @@
-- TR5Main engine settings file
-- TombEngine settings file
-- Created by MontyTRC
-- Place in this LUA script all the engine settings for your game
-- WARNING: bad values could make your game unplayable, please follow with attention the reference guide
-- Place all the engine settings for your game in this LUA script.
-- WARNING: Bad values could make your game unplayable; please follow reference guide attentively.
local settings = Settings.new();
settings.screenWidth = 1920;
@ -16,12 +16,11 @@ settings.errorMode = ErrorMode.WARN;
SetSettings(settings);
local anims = Animations.new();
anims.crawlExtended = true;
anims.crouchRoll = true;
anims.crawlspaceSwandive = true;
anims.monkeyTurn180 = true;
anims.monkeyAutoJump = false;
anims.oscillateHang = true;
anims.pose = false;
anims.overhang = true;
anims.hasSlideExtended = true;
anims.hasCrawlExtended = true;
anims.hasCrouchRoll = true;
anims.hasCrawlspaceSwandive = true;
anims.hasOverhangClimb = true;
anims.hasPose = false;
anims.hasMonkeyAutoJump = false;
SetAnimations(anims);

View file

@ -566,7 +566,7 @@ void lara_as_idle(ITEM_INFO* item, COLL_INFO* coll)
// movement lock will be rather obnoxious.
// Adding some idle breathing would also be nice. @Sezz 2021.10.31
if (lara->Control.Count.Pose >= LARA_POSE_TIME && TestLaraPose(item, coll) &&
g_GameFlow->Animations.Pose)
g_GameFlow->Animations.HasPose)
{
item->TargetState = LS_POSE;
return;

View file

@ -63,7 +63,7 @@ void lara_as_crouch_idle(ITEM_INFO* item, COLL_INFO* coll)
{
if (TrInput & IN_SPRINT && TestLaraCrouchRoll(item, coll) &&
lara->Control.HandStatus == HandStatus::Free &&
g_GameFlow->Animations.CrouchRoll)
g_GameFlow->Animations.HasCrouchRoll)
{
item->TargetState = LS_CROUCH_ROLL;
return;
@ -248,7 +248,7 @@ void lara_as_crouch_turn_left(ITEM_INFO* item, COLL_INFO* coll)
lara->Control.WaterStatus != WaterStatus::Wade)
{
if (TrInput & IN_SPRINT && TestLaraCrouchRoll(item, coll) &&
g_GameFlow->Animations.CrouchRoll)
g_GameFlow->Animations.HasCrouchRoll)
{
item->TargetState = LS_CROUCH_ROLL;
return;
@ -304,7 +304,7 @@ void lara_as_crouch_turn_right(ITEM_INFO* item, COLL_INFO* coll)
lara->Control.WaterStatus != WaterStatus::Wade)
{
if (TrInput & IN_SPRINT && TestLaraCrouchRoll(item, coll) &&
g_GameFlow->Animations.CrouchRoll)
g_GameFlow->Animations.HasCrouchRoll)
{
item->TargetState = LS_CROUCH_ROLL;
return;
@ -389,7 +389,7 @@ void lara_as_crawl_idle(ITEM_INFO* item, COLL_INFO* coll)
if (TrInput & (IN_ACTION | IN_JUMP) &&
crawlVaultResult.Success &&
g_GameFlow->Animations.CrawlExtended)
g_GameFlow->Animations.HasCrawlExtended)
{
item->TargetState = crawlVaultResult.TargetState;
ResetLaraFlex(item);

View file

@ -244,8 +244,7 @@ short GetLaraSlideDirection(ITEM_INFO* item, COLL_INFO* coll)
short direction = item->Position.yRot;
// Get true slope direction.
// TODO: Make it an option for the LD.
if (true/*g_GameFlow->Animations.HasSlideExtended*/)
if (g_GameFlow->Animations.HasSlideExtended)
{
if ((abs(coll->FloorTiltX) > 2 || abs(coll->FloorTiltZ) > 2))
{
@ -261,9 +260,6 @@ short GetLaraSlideDirection(ITEM_INFO* item, COLL_INFO* coll)
float zAngle = acos(-normalisedTiltZ) * -ANGLE(180.0f) / PI;
direction = (xAngle * abs(coll->FloorTiltX) + zAngle * abs(coll->FloorTiltZ)) / (abs(coll->FloorTiltX) + abs(coll->FloorTiltZ));
//float xAngle = phd_atan(CLICK(1) * coll->FloorTiltX, SECTOR(1));
//float zAngle = phd_atan(CLICK(1) * coll->FloorTiltZ, SECTOR(1));
}
}
// Get nearest cardinal slope direction.
@ -546,7 +542,7 @@ void HandleLaraMovementParameters(ITEM_INFO* item, COLL_INFO* coll)
if (lara->Control.Count.Pose < LARA_POSE_TIME &&
TestLaraPose(item, coll) &&
!(TrInput & (IN_WAKE | IN_LOOK)) &&
g_GameFlow->Animations.Pose)
g_GameFlow->Animations.HasPose)
{
lara->Control.Count.Pose++;
}

View file

@ -790,7 +790,7 @@ void lara_as_swan_dive(ITEM_INFO* item, COLL_INFO* coll)
else if (TestLaraSlide(item, coll))
SetLaraSlideState(item, coll);
else if ((TrInput & IN_CROUCH || TestLaraCrawlspaceDive(item, coll)) &&
g_GameFlow->Animations.CrawlspaceSwandive)
g_GameFlow->Animations.HasCrawlspaceDive)
{
item->TargetState = LS_CROUCH_IDLE;

View file

@ -838,7 +838,7 @@ void lara_as_sclimbend(ITEM_INFO* item, COLL_INFO* coll)
// Extends state 10 (AS_HANG)
void SlopeHangExtra(ITEM_INFO* item, COLL_INFO* coll)
{
if (!g_GameFlow->Animations.Overhang)
if (!g_GameFlow->Animations.HasOverhangClimb)
return;
PHD_VECTOR offset = { 0, 0, 0 };
@ -886,7 +886,7 @@ void SlopeHangExtra(ITEM_INFO* item, COLL_INFO* coll)
// Extends state 11 (AS_REACH)
void SlopeReachExtra(ITEM_INFO* item, COLL_INFO* coll)
{
if (!g_GameFlow->Animations.Overhang)
if (!g_GameFlow->Animations.HasOverhangClimb)
return;
PHD_VECTOR now = { item->Position.xPos, item->Position.yPos, item->Position.zPos };
@ -929,7 +929,7 @@ void SlopeReachExtra(ITEM_INFO* item, COLL_INFO* coll)
// Extends state 56 (AS_CLIMBSTNC)
void SlopeClimbExtra(ITEM_INFO* item, COLL_INFO* coll)
{
if (!g_GameFlow->Animations.Overhang)
if (!g_GameFlow->Animations.HasOverhangClimb)
return;
PHD_VECTOR now = { item->Position.xPos, item->Position.yPos, item->Position.zPos };
@ -1003,7 +1003,7 @@ void SlopeClimbExtra(ITEM_INFO* item, COLL_INFO* coll)
void LadderMonkeyExtra(ITEM_INFO* item, COLL_INFO* coll)
{
if (!g_GameFlow->Animations.Overhang)
if (!g_GameFlow->Animations.HasOverhangClimb)
return;
auto result = GetCollisionResult(item);
@ -1019,7 +1019,7 @@ void LadderMonkeyExtra(ITEM_INFO* item, COLL_INFO* coll)
// Extends state 61 (AS_CLIMBDOWN)
void SlopeClimbDownExtra(ITEM_INFO* item, COLL_INFO* coll)
{
if (!g_GameFlow->Animations.Overhang)
if (!g_GameFlow->Animations.HasOverhangClimb)
return;
PHD_VECTOR now = { item->Position.xPos, item->Position.yPos, item->Position.zPos };
@ -1078,7 +1078,7 @@ void SlopeMonkeyExtra(ITEM_INFO* item, COLL_INFO* coll)
{
auto* lara = GetLaraInfo(item);
if (!g_GameFlow->Animations.Overhang)
if (!g_GameFlow->Animations.HasOverhangClimb)
return;
PHD_VECTOR now = { item->Position.xPos, item->Position.yPos, item->Position.zPos };

View file

@ -8,6 +8,7 @@
#include "Game/Lara/lara_collide.h"
#include "Game/Lara/lara_helpers.h"
#include "Game/Lara/lara_tests.h"
#include "Scripting/GameFlowScript.h"
#include "Sound/sound.h"
#include "Specific/input.h"
#include "Specific/level.h"
@ -34,9 +35,9 @@ void lara_as_slide_forward(ITEM_INFO* item, COLL_INFO* coll)
if (TestLaraSlide(item, coll))
{
// TODO: Prepped for another time.
/*if (g_GameFlow->Animations.HasSlideExtended)
if (g_GameFlow->Animations.HasSlideExtended)
{
if (TrInput & IN_LEFT)
/*if (TrInput & IN_LEFT)
{
lara->Control.TurnRate -= LARA_TURN_RATE;
if (lara->Control.TurnRate < -LARA_SLIDE_TURN_MAX)
@ -51,8 +52,8 @@ void lara_as_slide_forward(ITEM_INFO* item, COLL_INFO* coll)
lara->Control.TurnRate = LARA_SLIDE_TURN_MAX;
DoLaraLean(item, coll, LARA_LEAN_MAX, LARA_LEAN_RATE / 3 * 2);
}
}*/
}*/
}
if (TrInput & IN_JUMP)
{
@ -132,9 +133,9 @@ void lara_as_slide_back(ITEM_INFO* item, COLL_INFO* coll)
if (TestLaraSlide(item, coll))
{
// TODO: Prepped for another time.
/*if (g_GameFlow->Animations.HasSlideExtended)
if (g_GameFlow->Animations.HasSlideExtended)
{
if (TrInput & IN_LEFT)
/*if (TrInput & IN_LEFT)
{
lara->Control.TurnRate -= LARA_TURN_RATE;
if (lara->Control.TurnRate < -LARA_SLIDE_TURN_MAX)
@ -149,8 +150,8 @@ void lara_as_slide_back(ITEM_INFO* item, COLL_INFO* coll)
lara->Control.TurnRate = LARA_SLIDE_TURN_MAX;
DoLaraLean(item, coll, -LARA_LEAN_MAX, LARA_LEAN_RATE / 3 * 2);
}
}*/
}*/
}
if (TrInput & IN_JUMP)
{

View file

@ -1030,7 +1030,7 @@ bool TestLaraWaterClimbOut(ITEM_INFO* item, COLL_INFO* coll)
{
if (headroom < LARA_HEIGHT)
{
if (g_GameFlow->Animations.CrawlExtended)
if (g_GameFlow->Animations.HasCrawlExtended)
SetAnimation(item, LA_ONWATER_TO_CROUCH_1_STEP);
else
return false;
@ -1042,7 +1042,7 @@ bool TestLaraWaterClimbOut(ITEM_INFO* item, COLL_INFO* coll)
{
if (headroom < LARA_HEIGHT)
{
if (g_GameFlow->Animations.CrawlExtended)
if (g_GameFlow->Animations.HasCrawlExtended)
SetAnimation(item, LA_ONWATER_TO_CROUCH_M1_STEP);
else
return false;
@ -1055,7 +1055,7 @@ bool TestLaraWaterClimbOut(ITEM_INFO* item, COLL_INFO* coll)
{
if (headroom < LARA_HEIGHT)
{
if (g_GameFlow->Animations.CrawlExtended)
if (g_GameFlow->Animations.HasCrawlExtended)
SetAnimation(item, LA_ONWATER_TO_CROUCH_0_STEP);
else
return false;
@ -2050,7 +2050,7 @@ VaultTestResult TestLaraVault(ITEM_INFO* item, COLL_INFO* coll)
// Vault to crouch up two steps.
vaultResult = TestLaraVault2StepsToCrouch(item, coll);
if (vaultResult.Success &&
g_GameFlow->Animations.CrawlExtended)
g_GameFlow->Animations.HasCrawlExtended)
{
vaultResult.TargetState = LS_VAULT_2_STEPS_CROUCH;
return vaultResult;
@ -2067,7 +2067,7 @@ VaultTestResult TestLaraVault(ITEM_INFO* item, COLL_INFO* coll)
// Vault to crouch up three steps.
vaultResult = TestLaraVault3StepsToCrouch(item, coll);
if (vaultResult.Success &&
g_GameFlow->Animations.CrawlExtended)
g_GameFlow->Animations.HasCrawlExtended)
{
vaultResult.TargetState = LS_VAULT_3_STEPS_CROUCH;
return vaultResult;
@ -2088,7 +2088,7 @@ VaultTestResult TestLaraVault(ITEM_INFO* item, COLL_INFO* coll)
// Auto jump to monkey swing.
vaultResult = TestLaraMonkeyAutoJump(item, coll);
if (vaultResult.Success &&
g_GameFlow->Animations.MonkeyAutoJump)
g_GameFlow->Animations.HasMonkeyAutoJump)
{
vaultResult.TargetState = LS_AUTO_JUMP;
return vaultResult;

View file

@ -2,21 +2,20 @@
#include "GameScriptAnimations.h"
/***
New custom animations which Lara can perform.
New animations and functionality which Lara can perform.
@pregameclass Animations
@pragma nostrip
*/
void GameScriptAnimations::Register(sol::state* lua)
{
lua->new_usertype<GameScriptAnimations>("Animations",
"crawlExtended", &GameScriptAnimations::CrawlExtended,
"crouchRoll", &GameScriptAnimations::CrouchRoll,
"crawlspaceSwandive", &GameScriptAnimations::CrawlspaceSwandive,
"monkeyTurn180", &GameScriptAnimations::MonkeyTurn180,
"monkeyAutoJump", &GameScriptAnimations::MonkeyAutoJump,
"oscillateHang", &GameScriptAnimations::OscillateHang,
"pose", &GameScriptAnimations::Pose,
"overhang", &GameScriptAnimations::Overhang
);
}
lua->new_usertype<GameScriptAnimations>(
"Animations",
"hasSlideExtended", &GameScriptAnimations::HasSlideExtended,
"hasCrawlExtended", &GameScriptAnimations::HasCrawlExtended,
"hasCrouchRoll", &GameScriptAnimations::HasCrouchRoll,
"hasCrawlspaceSwandive", &GameScriptAnimations::HasCrawlspaceDive,
"hasOverhangClimb", &GameScriptAnimations::HasOverhangClimb,
"hasPose", &GameScriptAnimations::HasPose,
"hasMonkeyAutoJump", &GameScriptAnimations::HasMonkeyAutoJump);
}

View file

@ -3,20 +3,20 @@
#include "ScriptAssert.h"
#include <string>
namespace sol {
namespace sol
{
class state;
}
struct GameScriptAnimations
{
bool CrawlExtended; // Extended crawl moveset
bool CrouchRoll; // Crouch roll
bool CrawlspaceSwandive; // Swandive into crawlspaces
bool MonkeyTurn180; // 180 degree turn on monkey swing
bool MonkeyAutoJump; // Auto jump to monkey swing when pressing UP + ACTION beneath
bool OscillateHang; // Grab thin ledge animation from TR1 and 2
bool Pose; // Crossed arms AFK posing
bool Overhang; // Overhang functionality by Krys
bool HasSlideExtended; // Extended slope sliding functionality.
bool HasCrawlExtended; // Extended crawl moveset.
bool HasCrouchRoll; // Crouch roll.
bool HasCrawlspaceDive; // Dive into crawlspaces.
bool HasOverhangClimb; // Overhang functionality.
bool HasPose; // Crossed arms AFK posing.
bool HasMonkeyAutoJump; // Auto jump to monkey swing when pressing UP + ACTION.
static void Register(sol::state* lua);
};
};