2020-08-14 17:54:25 -05:00
# include "framework.h"
# include "lara.h"
# include "lara_basic.h"
# include "lara_tests.h"
# include "lara_collide.h"
# include "lara_slide.h"
# include "lara_monkey.h"
2021-09-28 01:22:47 +10:00
# include "lara_helpers.h"
2020-08-14 17:54:25 -05:00
# include "input.h"
2021-09-19 18:29:25 +03:00
# include "level.h"
2021-09-25 16:04:16 +03:00
# include "setup.h"
2020-08-14 17:54:25 -05:00
# include "health.h"
2021-09-19 18:29:25 +03:00
# include "Sound/sound.h"
2021-09-16 05:06:03 +03:00
# include "animation.h"
2021-09-11 10:13:04 +03:00
# include "pickup.h"
2021-08-28 13:27:58 +02:00
# include "collide.h"
2021-09-19 23:41:26 +03:00
# include "items.h"
2021-08-28 13:27:58 +02:00
# include "camera.h"
2021-09-25 11:27:47 +02:00
2021-10-08 15:47:54 +11:00
using namespace std ;
2021-10-09 14:39:06 +11:00
// ------------------------------
// BASIC MOVEMENT & MISCELLANEOUS
2021-10-08 20:08:55 +11:00
// Control & Collision Functions
2021-10-09 14:39:06 +11:00
// ------------------------------
// --------------
// MISCELLANEOUS:
// --------------
2021-10-08 20:08:55 +11:00
2021-02-03 01:50:59 -03:00
void lara_void_func ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
return ;
}
2021-02-03 01:50:59 -03:00
void lara_default_col ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = STEPUP_HEIGHT ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesArePits = true ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2021-09-25 13:00:14 +03:00
LaraResetGravityStatus ( item , coll ) ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_as_special ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
Camera . flags = CF_FOLLOW_CENTER ;
Camera . targetAngle = ANGLE ( 170.0f ) ;
2020-09-26 05:06:08 +10:00
Camera . targetElevation = - ANGLE ( 25.0f ) ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_as_null ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2021-09-10 00:20:59 +03:00
coll - > Setup . EnableObjectPush = false ;
coll - > Setup . EnableSpaz = false ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_as_controlled ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
Lara . look = false ;
2021-09-10 00:20:59 +03:00
coll - > Setup . EnableObjectPush = false ;
coll - > Setup . EnableSpaz = false ;
2021-10-09 14:39:06 +11:00
2020-08-14 17:54:25 -05:00
if ( item - > frameNumber = = g_Level . Anims [ item - > animNumber ] . frameEnd - 1 )
{
Lara . gunStatus = LG_NO_ARMS ;
2021-10-09 14:39:06 +11:00
2020-08-14 17:54:25 -05:00
if ( UseForcedFixedCamera )
UseForcedFixedCamera = 0 ;
}
}
2021-02-03 01:50:59 -03:00
void lara_as_controlledl ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
Lara . look = false ;
2021-09-10 00:20:59 +03:00
coll - > Setup . EnableObjectPush = false ;
coll - > Setup . EnableSpaz = false ;
2020-08-14 17:54:25 -05:00
}
2021-10-09 14:39:06 +11:00
// ---------------
// BASIC MOVEMENT:
// ---------------
// State: LS_WALK_FORWARD (0)
// Collision: lara_col_walk()
2021-02-03 01:50:59 -03:00
void lara_as_walk ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-09 14:39:06 +11:00
{
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
// TODO: What is this for? Investigate. @Sezz 2021.10.09
if ( Lara . isMoving )
return ;
2021-10-09 23:53:39 +11:00
// TODO: If stopping and not holding WALK, Lara won't turn. Change animation's state to LS_STOP to solve issue? @Sezz 2021.10.09
2021-10-09 14:39:06 +11:00
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX / 3 ) / 12 ;
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot + = ( LARA_LEAN_MAX / 3 - item - > pos . zRot ) / 12 ;
}
2021-10-11 00:05:49 +11:00
// Crouch failsafe.
// TODO: Idle crouch state dispatch. @Sezz 2021.10.11
if ( TestLaraStandUp ( coll ) )
{
item - > goalAnimState = LS_STOP ;
return ;
}
2021-10-09 14:39:06 +11:00
if ( TrInput & IN_FORWARD )
{
if ( Lara . waterStatus = = LW_WADE )
item - > goalAnimState = LS_WADE_FORWARD ;
else if ( TrInput & IN_WALK )
item - > goalAnimState = LS_WALK_FORWARD ;
else
item - > goalAnimState = LS_RUN_FORWARD ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
// LEGACY
void old_lara_as_walk ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 0*/
/*collision: lara_col_walk*/
2020-08-14 17:54:25 -05:00
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
2020-09-26 05:06:08 +10:00
if ( ! Lara . isMoving )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_LEFT )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate - = LARA_TURN_RATE ;
2021-10-02 15:44:34 +03:00
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_RIGHT )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate + = LARA_TURN_RATE ;
2021-10-02 15:44:34 +03:00
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_FORWARD )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
if ( Lara . waterStatus = = LW_WADE )
{
item - > goalAnimState = LS_WADE_FORWARD ;
}
else if ( TrInput & IN_WALK )
{
item - > goalAnimState = LS_WALK_FORWARD ;
}
else
{
item - > goalAnimState = LS_RUN_FORWARD ;
}
2020-08-14 17:54:25 -05:00
}
else
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_STOP ;
2020-08-14 17:54:25 -05:00
}
}
}
2021-10-09 14:39:06 +11:00
// State: LA_WALK_FORWARD (0)
// Control: lara_as_walk_forward()
2021-02-03 01:50:59 -03:00
void lara_col_walk ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-09 14:39:06 +11:00
{
Lara . moveAngle = item - > pos . yRot ;
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
coll - > Setup . BadHeightDown = STEPUP_HEIGHT ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . SlopesArePits = true ;
coll - > Setup . DeathFlagIsPit = 1 ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
GetCollisionInfo ( coll , item ) ;
if ( TestLaraHitCeiling ( coll ) )
{
SetLaraHitCeiling ( item , coll ) ;
return ;
}
if ( TestLaraVault ( item , coll ) )
return ;
if ( LaraDeflectEdge ( item , coll ) )
{
item - > goalAnimState = LS_SPLAT ;
if ( GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) )
return ;
LaraCollideStop ( item , coll ) ;
}
if ( TestLaraFall ( coll ) )
{
SetLaraFallState ( item ) ;
return ;
}
2021-10-09 16:56:07 +11:00
if ( TestLaraSlide ( item , coll ) )
{
SetLaraSlideState ( item , coll ) ;
return ;
}
2021-10-09 14:39:06 +11:00
if ( TestLaraStep ( coll ) )
{
DoLaraStep ( item , coll ) ;
2021-10-09 16:56:07 +11:00
return ;
2021-10-09 14:39:06 +11:00
}
2021-10-09 23:00:26 +11:00
// LEGACY step
2021-10-09 14:39:06 +11:00
/*if (coll->Middle.Floor > STEP_SIZE / 2)
{
if ( coll - > Front . Floor = = NO_HEIGHT | | coll - > Front . Floor < = STEP_SIZE / 2 )
{
coll - > Middle . Floor = 0 ;
}
else
{
item - > goalAnimState = LS_STEP_DOWN ;
GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) ;
}
}
if ( coll - > Middle . Floor > = - STEPUP_HEIGHT & & coll - > Middle . Floor < - STEP_SIZE / 2 )
{
if ( coll - > Front . Floor = = NO_HEIGHT | |
coll - > Front . Floor < - STEPUP_HEIGHT | |
coll - > Front . Floor > = - STEP_SIZE / 2 )
{
coll - > Middle . Floor = 0 ;
}
else
{
item - > goalAnimState = LS_STEP_UP ;
GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) ;
}
} */
}
// LEGACY
void old_lara_col_walk ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 0*/
/*state code: lara_as_walk*/
2020-08-14 17:54:25 -05:00
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-09-26 05:06:08 +10:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = STEPUP_HEIGHT ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
2020-09-26 05:06:08 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . SlopesArePits = true ;
2021-09-13 09:55:54 +03:00
coll - > Setup . DeathFlagIsPit = 1 ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( ! LaraHitCeiling ( item , coll ) & & ! TestLaraVault ( item , coll ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( LaraDeflectEdge ( item , coll ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_SPLAT ;
if ( GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) )
return ;
LaraCollideStop ( item , coll ) ;
2020-09-26 03:28:30 +10:00
}
2020-09-26 05:06:08 +10:00
if ( ! LaraFallen ( item , coll ) )
2020-09-26 03:28:30 +10:00
{
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > STEP_SIZE / 2 )
2020-08-14 17:54:25 -05:00
{
2021-09-10 00:18:47 +03:00
if ( coll - > Front . Floor = = NO_HEIGHT | | coll - > Front . Floor < = STEP_SIZE / 2 )
2020-09-26 05:06:08 +10:00
{
2021-09-10 00:18:47 +03:00
coll - > Middle . Floor = 0 ;
2020-09-26 05:06:08 +10:00
}
else
{
item - > goalAnimState = LS_STEP_DOWN ;
GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) ;
}
}
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > = - STEPUP_HEIGHT & & coll - > Middle . Floor < - STEP_SIZE / 2 )
2020-09-26 05:06:08 +10:00
{
2021-09-10 00:18:47 +03:00
if ( coll - > Front . Floor = = NO_HEIGHT | |
coll - > Front . Floor < - STEPUP_HEIGHT | |
coll - > Front . Floor > = - STEP_SIZE / 2 )
2020-09-26 05:06:08 +10:00
{
2021-09-10 00:18:47 +03:00
coll - > Middle . Floor = 0 ;
2020-09-26 05:06:08 +10:00
}
else
{
item - > goalAnimState = LS_STEP_UP ;
GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) ;
}
2020-08-14 17:54:25 -05:00
}
2020-09-26 03:28:30 +10:00
2021-09-10 00:18:47 +03:00
if ( ! TestLaraSlide ( item , coll ) & & coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-09-26 03:28:30 +10:00
}
}
2020-09-26 05:06:08 +10:00
}
2020-09-26 03:28:30 +10:00
2021-09-26 17:51:28 +10:00
// State: LS_RUN_FORWARD (1)
// Collision: lara_col_run()
2021-02-03 01:50:59 -03:00
void lara_as_run ( ITEM_INFO * item , COLL_INFO * coll )
2021-09-26 17:51:28 +10:00
{
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_DEATH ;
return ;
}
2021-10-04 22:02:02 +11:00
// TODO: Look function needs complete evaluation.
2021-09-26 17:51:28 +10:00
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_FAST_TURN )
Lara . turnRate = - LARA_FAST_TURN ;
if ( TestLaraLean ( item , coll ) )
2021-09-29 18:35:21 +10:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX ) / 8 ;
2021-09-26 17:51:28 +10:00
2021-10-04 22:02:02 +11:00
// TODO: Make lean rate proportional to the turn rate, allowing for nicer aesthetics with future analog stick input.
// The following commented line makes the lean rate LINEARLY proportional, but it's visually much too subtle.
// Ideally, lean rate should be on a curve, approaching LARA_LEAN_MAX faster at Lara.turnRate values near zero
// and falling off as Lara.turnRate approaches LARA_FAST_TURN.
// Unfortunately I am terrible at mathematics and I don't know how to do this.
// Would a library of easing functions be helpful here? @Sezz 2021.09.26
// item->pos.zRot -= (item->pos.zRot - LARA_LEAN_MAX / LARA_FAST_TURN * Lara.turnRate) / 3;
2021-09-26 17:51:28 +10:00
else
2021-09-29 18:35:21 +10:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX * 3 / 6 ) / 8 ;
2021-09-26 17:51:28 +10:00
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_FAST_TURN )
Lara . turnRate = LARA_FAST_TURN ;
if ( TestLaraLean ( item , coll ) )
2021-09-29 18:35:21 +10:00
item - > pos . zRot + = ( LARA_LEAN_MAX - item - > pos . zRot ) / 8 ;
2021-09-26 17:51:28 +10:00
else
2021-09-29 18:35:21 +10:00
item - > pos . zRot + = ( LARA_LEAN_MAX * 3 / 6 - item - > pos . zRot ) / 8 ;
2021-09-26 17:51:28 +10:00
}
2021-09-28 14:00:58 +10:00
static bool allowJump = false ;
2021-09-26 17:51:28 +10:00
if ( item - > animNumber = = LA_STAND_TO_RUN )
2021-09-28 14:00:58 +10:00
allowJump = false ;
2021-09-26 17:51:28 +10:00
else if ( item - > animNumber = = LA_RUN & & item - > frameNumber = = 4 )
2021-09-28 14:00:58 +10:00
allowJump = true ;
2021-09-26 17:51:28 +10:00
else
2021-09-28 14:00:58 +10:00
allowJump = true ;
2021-09-26 17:51:28 +10:00
2021-09-28 14:00:58 +10:00
// Pseudo action queue which makes JUMP input take complete precedence.
// This creates a committal lock to perform a forward jump when JUMP is pressed and released while allowJump isn't true yet.
// TODO: Get others to try this out. @Sezz 2021.09.28
static bool commitToJump = false ;
2021-09-26 17:51:28 +10:00
2021-10-09 14:39:06 +11:00
if ( ( TrInput & IN_JUMP | | commitToJump ) & &
! item - > gravityStatus )
2021-09-26 17:51:28 +10:00
{
2021-09-28 14:00:58 +10:00
commitToJump = TrInput & IN_FORWARD ;
2021-09-26 17:51:28 +10:00
2021-09-28 14:00:58 +10:00
if ( allowJump )
2021-09-26 17:51:28 +10:00
{
2021-09-28 14:00:58 +10:00
commitToJump = false ;
2021-09-26 17:51:28 +10:00
item - > goalAnimState = LS_JUMP_FORWARD ;
}
return ;
}
2021-10-09 14:39:06 +11:00
if ( TrInput & IN_SPRINT & &
DashTimer )
2021-09-26 17:51:28 +10:00
{
item - > goalAnimState = LS_SPRINT ;
return ;
}
if ( TrInput & IN_ROLL )
{
2021-10-04 22:02:02 +11:00
item - > goalAnimState = LS_ROLL_FORWARD ;
2021-09-26 17:51:28 +10:00
return ;
}
2021-10-11 00:05:49 +11:00
if ( ( TrInput & IN_DUCK | | TestLaraStandUp ( coll ) ) & &
2021-10-09 14:39:06 +11:00
( Lara . gunStatus = = LG_NO_ARMS | | ! IsStandingWeapon ( Lara . gunType ) ) & &
Lara . waterStatus ! = LW_WADE ) // TODO: Check if this is required for other dispatches. @Sezz 2021.10.05
2021-09-26 17:51:28 +10:00
{
item - > goalAnimState = LS_CROUCH_IDLE ;
return ;
}
2021-10-09 14:39:06 +11:00
// TODO: Probe for SPLAT dispatch. @Sezz 2021.10.09
2021-09-26 17:51:28 +10:00
if ( TrInput & IN_FORWARD )
{
if ( Lara . waterStatus = = LW_WADE )
item - > goalAnimState = LS_WADE_FORWARD ;
else if ( TrInput & IN_WALK )
item - > goalAnimState = LS_WALK_FORWARD ;
else [[likely]]
item - > goalAnimState = LS_RUN_FORWARD ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
// LEGACY
void old_lara_as_run ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 05:06:08 +10:00
{
/*state 1*/
/*collision: lara_col_run*/
if ( item - > hitPoints < = 0 )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_DEATH ;
return ;
2020-09-26 03:28:30 +10:00
}
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_ROLL )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
item - > animNumber = LA_ROLL_180_START ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase + 2 ;
item - > currentAnimState = LS_ROLL_FORWARD ;
item - > goalAnimState = LS_STOP ;
2020-08-14 17:54:25 -05:00
return ;
}
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_SPRINT & & DashTimer )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_SPRINT ;
2020-09-26 03:28:30 +10:00
return ;
}
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_DUCK & &
Lara . waterStatus ! = LW_WADE & &
( Lara . gunStatus = = LG_NO_ARMS | |
Lara . gunType = = WEAPON_NONE | |
Lara . gunType = = WEAPON_PISTOLS | |
Lara . gunType = = WEAPON_REVOLVER | |
Lara . gunType = = WEAPON_UZI | |
Lara . gunType = = WEAPON_FLARE ) )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_CROUCH_IDLE ;
2020-08-14 17:54:25 -05:00
return ;
}
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_FAST_TURN )
2020-09-26 03:28:30 +10:00
Lara . turnRate = - LARA_FAST_TURN ;
2020-09-26 05:06:08 +10:00
if ( TestLaraLean ( item , coll ) )
2021-09-26 12:23:58 +10:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX ) / 7 ;
2021-07-09 19:41:56 -05:00
else
2021-09-26 12:23:58 +10:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX * 3 / 6 ) / 7 ;
2020-08-14 17:54:25 -05:00
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_FAST_TURN )
2020-09-26 03:28:30 +10:00
Lara . turnRate = LARA_FAST_TURN ;
2020-09-26 05:06:08 +10:00
if ( TestLaraLean ( item , coll ) )
2021-09-26 12:23:58 +10:00
item - > pos . zRot + = ( LARA_LEAN_MAX - item - > pos . zRot ) / 7 ;
2021-07-09 19:41:56 -05:00
else
2021-09-26 12:23:58 +10:00
item - > pos . zRot + = ( LARA_LEAN_MAX * 3 / 6 - item - > pos . zRot ) / 7 ;
2020-08-14 17:54:25 -05:00
}
2021-09-14 00:35:10 +03:00
static bool doJump = false ;
2021-09-13 09:19:35 +03:00
2020-08-14 17:54:25 -05:00
if ( item - > animNumber = = LA_STAND_TO_RUN )
{
2021-09-13 09:19:35 +03:00
doJump = false ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else if ( item - > animNumber = = LA_RUN )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( item - > frameNumber = = 4 )
2021-09-13 09:19:35 +03:00
doJump = true ;
2020-08-14 17:54:25 -05:00
}
else
{
2021-09-13 09:19:35 +03:00
doJump = true ;
2020-08-14 17:54:25 -05:00
}
2021-09-13 09:19:35 +03:00
if ( TrInput & IN_JUMP & & doJump & & ! item - > gravityStatus )
2020-08-14 17:54:25 -05:00
{
item - > goalAnimState = LS_JUMP_FORWARD ;
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_FORWARD )
2020-08-14 17:54:25 -05:00
{
if ( Lara . waterStatus = = LW_WADE )
{
item - > goalAnimState = LS_WADE_FORWARD ;
}
else
{
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_WALK )
item - > goalAnimState = LS_WALK_FORWARD ;
else
item - > goalAnimState = LS_RUN_FORWARD ;
2020-08-14 17:54:25 -05:00
}
}
2020-09-26 05:06:08 +10:00
else
{
item - > goalAnimState = LS_STOP ;
}
2020-08-14 17:54:25 -05:00
}
2021-10-09 16:56:07 +11:00
// State: LS_RUN_FORWARD (1)
// Control: lara_as_run()
2021-02-03 01:50:59 -03:00
void lara_col_run ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-09 16:56:07 +11:00
{
Lara . moveAngle = item - > pos . yRot ;
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
GetCollisionInfo ( coll , item ) ;
LaraResetGravityStatus ( item , coll ) ;
if ( TestLaraHitCeiling ( coll ) )
{
SetLaraHitCeiling ( item , coll ) ;
return ;
}
if ( TestLaraVault ( item , coll ) )
return ;
if ( LaraDeflectEdge ( item , coll ) )
{
item - > pos . zRot = 0 ;
2021-10-11 16:12:04 +11:00
if ( coll - > HitTallObject | | TestLaraWall ( item , 256 , 0 , - 640 ) )
2021-10-09 16:56:07 +11:00
{
item - > goalAnimState = LS_SPLAT ;
if ( GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) )
{
item - > currentAnimState = LS_SPLAT ;
return ;
}
}
LaraCollideStop ( item , coll ) ;
}
if ( TestLaraFall ( coll ) )
{
SetLaraFallState ( item ) ;
return ;
}
if ( TestLaraSlide ( item , coll ) )
{
SetLaraSlideState ( item , coll ) ;
return ;
}
if ( TestLaraStep ( coll ) )
{
DoLaraStep ( item , coll ) ;
return ;
}
2021-10-09 23:00:26 +11:00
// LEGACY step
//if (coll->Front.Floor == NO_HEIGHT || coll->Front.Floor < -STEPUP_HEIGHT || coll->Front.Floor >= -STEP_SIZE / 2)
//{
// coll->Middle.Floor = 0;
//}
//else
//{
// item->goalAnimState = LS_STEP_UP;
// GetChange(item, &g_Level.Anims[item->animNumber]);
//}
//if (coll->Middle.Floor < 50)
//{
// if (coll->Middle.Floor != NO_HEIGHT)
// item->pos.yPos += coll->Middle.Floor;
//}
//else
//{
// item->goalAnimState = LS_STEP_DOWN; // for theoretical running stepdown anims, not in default anims
// if (GetChange(item, &g_Level.Anims[item->animNumber]))
// item->pos.yPos += coll->Middle.Floor; // move Lara to middle.Floor
// else
// item->pos.yPos += 50; // do the default aligment
//}
2021-10-09 16:56:07 +11:00
}
// LEGACY
void old_lara_col_run ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 1*/
/*state code: lara_col_run*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-17 22:55:09 +03:00
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2021-09-25 13:00:14 +03:00
LaraResetGravityStatus ( item , coll ) ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( ! LaraHitCeiling ( item , coll ) & & ! TestLaraVault ( item , coll ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( LaraDeflectEdge ( item , coll ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > pos . zRot = 0 ;
2021-10-07 11:01:39 +03:00
if ( coll - > HitTallObject | | TestLaraWall ( item , 256 , 0 , - 640 ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_SPLAT ;
if ( GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) )
{
item - > currentAnimState = LS_SPLAT ;
return ;
}
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
LaraCollideStop ( item , coll ) ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
if ( ! LaraFallen ( item , coll ) )
2020-08-14 17:54:25 -05:00
{
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > = - STEPUP_HEIGHT & & coll - > Middle . Floor < - STEP_SIZE / 2 )
2020-08-14 17:54:25 -05:00
{
2021-09-10 00:18:47 +03:00
if ( coll - > Front . Floor = = NO_HEIGHT | | coll - > Front . Floor < - STEPUP_HEIGHT | | coll - > Front . Floor > = - STEP_SIZE / 2 )
2020-09-26 05:06:08 +10:00
{
2021-09-10 00:18:47 +03:00
coll - > Middle . Floor = 0 ;
2020-09-26 05:06:08 +10:00
}
else
{
item - > goalAnimState = LS_STEP_UP ;
GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) ;
}
}
if ( ! TestLaraSlide ( item , coll ) )
{
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor < 50 )
2020-09-26 05:06:08 +10:00
{
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-09-26 05:06:08 +10:00
}
else
{
item - > goalAnimState = LS_STEP_DOWN ; // for theoretical running stepdown anims, not in default anims
if ( GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) )
2021-09-10 00:18:47 +03:00
item - > pos . yPos + = coll - > Middle . Floor ; // move Lara to middle.Floor
2020-09-26 05:06:08 +10:00
else
item - > pos . yPos + = 50 ; // do the default aligment
}
2020-08-14 17:54:25 -05:00
}
}
}
2020-09-26 05:06:08 +10:00
}
2020-08-14 17:54:25 -05:00
2021-09-28 01:22:47 +10:00
// State: LS_STOP (2)
// Collision: lara_col_stop()
2020-09-26 05:06:08 +10:00
void lara_as_stop ( ITEM_INFO * item , COLL_INFO * coll )
2021-09-28 01:22:47 +10:00
{
2021-10-08 15:47:54 +11:00
// TODO: New probe.
2021-09-28 01:22:47 +10:00
auto fHeight = LaraCollisionFront ( item , item - > pos . yRot , LARA_RAD + 4 ) ;
auto cHeight = LaraCeilingCollisionFront ( item , item - > pos . yRot , LARA_RAD + 4 , LARA_HEIGHT ) ;
2021-10-04 22:02:02 +11:00
auto rHeight = LaraCollisionFront ( item , item - > pos . yRot + ANGLE ( 180.0f ) , LARA_RAD + 4 ) ;
2021-09-28 01:22:47 +10:00
// TODO: Hardcoding. @Sezz 2021.09.28
if ( item - > animNumber ! = LA_SPRINT_TO_STAND_RIGHT & & item - > animNumber ! = LA_SPRINT_TO_STAND_LEFT )
StopSoundEffect ( SFX_TR4_LARA_SLIPPING ) ;
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_DEATH ;
return ;
}
// TODO: Hardcoding. @Sezz 2021.09.28
// Handles waterskin and clockwork beetle.
if ( UseSpecialItem ( item ) )
return ;
if ( TrInput & IN_LOOK )
LookUpDown ( ) ;
2021-09-28 23:06:20 +10:00
// Permit turning when Lara is stationary and cannot dispatch into a true turn.
2021-10-08 15:47:54 +11:00
if ( TrInput & IN_LEFT & &
! ( TrInput & IN_JUMP ) ) // Temp solution: JUMP locks y rotation.
2021-09-28 13:05:29 +10:00
{
Lara . turnRate - = LARA_TURN_RATE ;
2021-09-28 23:06:20 +10:00
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
2021-09-28 13:05:29 +10:00
}
2021-10-08 15:47:54 +11:00
else if ( TrInput & IN_RIGHT & &
! ( TrInput & IN_JUMP ) )
2021-09-28 13:05:29 +10:00
{
Lara . turnRate + = LARA_TURN_RATE ;
2021-09-28 23:06:20 +10:00
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
2021-09-28 13:05:29 +10:00
}
2021-09-28 01:22:47 +10:00
// TODO: Refine this handling. Create LS_WADE_IDLE state? Might complicate things. @Sezz 2021.09.28
if ( Lara . waterStatus = = LW_WADE )
{
LaraWadeStop ( item , coll , fHeight , rHeight ) ;
return ;
}
2021-10-08 15:47:54 +11:00
if ( TrInput & IN_JUMP & &
( coll - > Middle . Ceiling < - LARA_HEADROOM * 0.7f ) )
2021-09-28 01:22:47 +10:00
{
item - > goalAnimState = LS_JUMP_PREPARE ;
return ;
}
if ( TrInput & IN_ROLL )
{
2021-10-04 22:02:02 +11:00
item - > goalAnimState = LS_ROLL_FORWARD ;
2021-09-28 01:22:47 +10:00
return ;
}
// TODO: Test failsafe which automatically crouches Lara if the ceiling above her is too low.
2021-10-08 15:47:54 +11:00
if ( ( TrInput & IN_DUCK | | TestLaraStandUp ( coll ) ) & &
( Lara . gunStatus = = LG_NO_ARMS | | ! IsStandingWeapon ( Lara . gunType ) ) )
2021-09-28 01:22:47 +10:00
{
2021-10-13 19:50:46 +11:00
if ( Lara . gunType = = WEAPON_REVOLVER ) // TODO: Cleaner handling. @Sezz 2021.10.13
2021-10-04 22:02:02 +11:00
{
if ( ! LaserSight )
item - > goalAnimState = LS_CROUCH_IDLE ;
}
else
item - > goalAnimState = LS_CROUCH_IDLE ;
2021-09-28 01:22:47 +10:00
return ;
}
2021-10-08 15:47:54 +11:00
if ( TrInput & IN_FORWARD & &
! ( ( fHeight . Position . Slope & & ( fHeight . Position . Floor < 0 | | cHeight . Position . Ceiling > 0 ) ) | | // Slope in front.
coll - > CollisionType = = CT_FRONT ) ) // Wall/ceiling/object in front.
2021-09-28 01:22:47 +10:00
{
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_WALK ) // TODO: Make sprinting from walk commit to sprint, and walking from sprint commit to walk, when both inputs are registered. @Sezz 2021.10.13
2021-10-08 15:47:54 +11:00
item - > goalAnimState = LS_WALK_FORWARD ;
2021-10-13 19:50:46 +11:00
else if ( TrInput & IN_SPRINT )
item - > goalAnimState = LS_SPRINT ;
2021-09-28 01:22:47 +10:00
else [[likely]]
item - > goalAnimState = LS_RUN_FORWARD ;
return ;
}
if ( TrInput & IN_BACK )
{
// TODO: Create new LS_WADE_BACK state? Its function would make a direct call to lara_as_back().
// TODO: Allow turning while holding BACK against a wall. @Sezz 2021.06.27
2021-10-11 00:05:49 +11:00
// TODO: Lara drops off ledges when holding WALK. My fault? @Sezz 2021.10.11
2021-09-28 01:22:47 +10:00
if ( TrInput & IN_WALK
& & ( rHeight . Position . Floor < ( STEPUP_HEIGHT - 1 ) )
2021-10-06 14:03:12 +11:00
& & ( rHeight . Position . Floor > - ( STEPUP_HEIGHT - 1 ) )
2021-10-08 15:47:54 +11:00
& & ! rHeight . Position . Slope )
2021-09-28 01:22:47 +10:00
{
item - > goalAnimState = LS_WALK_BACK ;
}
2021-10-06 14:03:12 +11:00
else if ( rHeight . Position . Floor > - ( STEPUP_HEIGHT - 1 )
& & ! rHeight . Position . Slope ) [[likely]]
{
2021-09-28 01:22:47 +10:00
item - > goalAnimState = LS_HOP_BACK ;
2021-10-06 14:03:12 +11:00
}
2021-09-28 01:22:47 +10:00
return ;
}
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_LSTEP & &
TestLaraStepLeft ( item ) )
2021-09-28 01:22:47 +10:00
{
2021-10-08 15:47:54 +11:00
item - > goalAnimState = LS_STEP_LEFT ;
2021-09-28 01:22:47 +10:00
return ;
}
2021-10-13 19:50:46 +11:00
else if ( TrInput & IN_RSTEP & &
TestLaraStepRight ( item ) )
2021-09-28 01:22:47 +10:00
{
2021-10-08 15:47:54 +11:00
item - > goalAnimState = LS_STEP_RIGHT ;
2021-09-28 01:22:47 +10:00
return ;
}
2021-10-08 15:47:54 +11:00
if ( TrInput & IN_LEFT )
2021-09-28 01:22:47 +10:00
{
2021-10-08 20:08:55 +11:00
if ( TrInput & IN_SPRINT | |
2021-10-10 00:35:06 +11:00
Lara . gunStatus = = LG_READY | | // TODO: Check torch. @Sezz 2021.10.10
( Lara . gunStatus = = LG_DRAW_GUNS & & Lara . gunType ! = WEAPON_FLARE & & Lara . gunType ! = WEAPON_TORCH ) ) // Why are these weapons??? @Sezz 2021.10.10
2021-10-08 20:08:55 +11:00
{
item - > goalAnimState = LS_TURN_LEFT_FAST ;
}
else [[likely]]
item - > goalAnimState = LS_TURN_LEFT_SLOW ;
2021-09-28 01:22:47 +10:00
2021-10-04 22:02:02 +11:00
return ;
2021-09-28 01:22:47 +10:00
}
2021-10-08 15:47:54 +11:00
else if ( TrInput & IN_RIGHT )
2021-09-28 01:22:47 +10:00
{
2021-10-08 20:08:55 +11:00
if ( TrInput & IN_SPRINT | |
2021-10-10 00:35:06 +11:00
Lara . gunStatus = = LG_READY | |
( Lara . gunStatus = = LG_DRAW_GUNS & & Lara . gunType ! = WEAPON_FLARE & & Lara . gunType ! = WEAPON_TORCH ) )
2021-10-08 20:08:55 +11:00
{
item - > goalAnimState = LS_TURN_RIGHT_FAST ;
}
else [[likely]]
item - > goalAnimState = LS_TURN_RIGHT_SLOW ;
2021-09-28 01:22:47 +10:00
2021-10-04 22:02:02 +11:00
return ;
2021-09-28 01:22:47 +10:00
}
item - > goalAnimState = LS_STOP ;
}
2021-10-13 19:50:46 +11:00
// TODO: Future-proof for raising water.
// TODO: See if making these into true states would be beneficial. @Sezz 2021.10.13
// Pseudo-state for idling in wade-height water.
2021-09-28 01:22:47 +10:00
void LaraWadeStop ( ITEM_INFO * item , COLL_INFO * coll , COLL_RESULT fHeight , COLL_RESULT rHeight )
{
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_JUMP & &
! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) )
2021-09-28 01:22:47 +10:00
{
item - > goalAnimState = LS_JUMP_PREPARE ;
return ;
}
2021-10-13 19:50:46 +11:00
// TODO: Clean this.
2021-09-28 01:22:47 +10:00
if ( TrInput & IN_FORWARD )
{
bool wade = false ;
2021-10-13 19:50:46 +11:00
if ( ( fHeight . Position . Floor > - ( STEPUP_HEIGHT - 1 ) & &
g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) | |
( fHeight . Position . Floor < ( STEPUP_HEIGHT - 1 ) & &
fHeight . Position . Floor > - ( STEPUP_HEIGHT - 1 ) ) )
2021-09-28 01:22:47 +10:00
{
wade = true ;
item - > goalAnimState = LS_WADE_FORWARD ;
}
if ( ! wade )
{
Lara . moveAngle = item - > pos . yRot ;
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . Radius = LARA_RAD + 2 ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
GetCollisionInfo ( coll , item ) ;
if ( TestLaraVault ( item , coll ) )
return ;
coll - > Setup . Radius = LARA_RAD ;
}
return ;
}
2021-10-04 22:02:02 +11:00
2021-09-28 01:22:47 +10:00
if ( TrInput & IN_BACK )
{
2021-10-13 19:50:46 +11:00
item - > goalAnimState = LS_WALK_BACK ;
2021-09-28 01:22:47 +10:00
2021-10-13 19:50:46 +11:00
return ;
2021-09-28 01:22:47 +10:00
}
2021-10-14 21:11:59 +11:00
if ( TrInput & IN_LSTEP & &
TestLaraStepLeft ( item ) )
{
item - > goalAnimState = LS_STEP_LEFT ;
return ;
}
else if ( TrInput & IN_RSTEP & &
TestLaraStepRight ( item ) )
{
item - > goalAnimState = LS_STEP_RIGHT ;
return ;
}
2021-10-05 22:09:07 +11:00
if ( TrInput & IN_LEFT )
{
item - > goalAnimState = LS_TURN_LEFT_SLOW ;
return ;
}
else if ( TrInput & IN_RIGHT )
{
item - > goalAnimState = LS_TURN_RIGHT_SLOW ;
return ;
}
2021-09-28 01:22:47 +10:00
item - > goalAnimState = LS_STOP ;
}
// LEGACY
void old_lara_as_stop ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 05:06:08 +10:00
{
/*state 2*/
/*collision: lara_col_stop*/
2021-09-10 00:43:26 +03:00
COLL_RESULT fheight = { } ; fheight . Position . Floor = NO_HEIGHT ;
COLL_RESULT rheight = { } ; rheight . Position . Floor = NO_HEIGHT ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( item - > hitPoints < = 0 )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_DEATH ;
2020-08-14 17:54:25 -05:00
return ;
}
2020-09-26 03:28:30 +10:00
if ( item - > animNumber ! = LA_SPRINT_TO_STAND_RIGHT & & item - > animNumber ! = LA_SPRINT_TO_STAND_LEFT )
2021-05-26 06:04:32 +02:00
StopSoundEffect ( SFX_TR4_LARA_SLIPPING ) ;
2020-09-26 03:28:30 +10:00
2020-09-26 05:06:08 +10:00
// Handles waterskin and clockwork beetle
if ( UseSpecialItem ( item ) )
return ;
if ( TrInput & IN_ROLL & & Lara . waterStatus ! = LW_WADE )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
item - > animNumber = LA_ROLL_180_START ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase + 2 ;
item - > currentAnimState = LS_ROLL_FORWARD ;
item - > goalAnimState = LS_STOP ;
2020-08-14 17:54:25 -05:00
return ;
}
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_DUCK
2021-10-04 22:02:02 +11:00
& & Lara . waterStatus ! = LW_WADE
2020-09-26 05:06:08 +10:00
& & item - > currentAnimState = = LS_STOP
& & ( Lara . gunStatus = = LG_NO_ARMS
| | Lara . gunType = = WEAPON_NONE
| | Lara . gunType = = WEAPON_PISTOLS
2021-06-09 18:28:25 -04:00
| | ( Lara . gunType = = WEAPON_REVOLVER & & ! LaserSight )
2020-09-26 05:06:08 +10:00
| | Lara . gunType = = WEAPON_UZI
| | Lara . gunType = = WEAPON_FLARE ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_CROUCH_IDLE ;
2020-08-14 17:54:25 -05:00
return ;
}
item - > goalAnimState = LS_STOP ;
if ( TrInput & IN_LOOK )
LookUpDown ( ) ;
2021-09-18 00:36:28 +03:00
if ( TrInput & IN_LSTEP )
2020-09-26 03:28:30 +10:00
{
2021-09-18 00:36:28 +03:00
auto collFloorResult = LaraCollisionFront ( item , item - > pos . yRot - ANGLE ( 90.0f ) , LARA_RAD + 48 ) ;
auto collCeilingResult = LaraCeilingCollisionFront ( item , item - > pos . yRot - ANGLE ( 90.0f ) , LARA_RAD + 48 , LARA_HEIGHT ) ;
2021-10-04 22:02:02 +11:00
if ( ( collFloorResult . Position . Floor < 128 & & collFloorResult . Position . Floor > - 128 ) & & ! collFloorResult . Position . Slope & & collCeilingResult . Position . Ceiling < = 0 )
2021-09-18 00:36:28 +03:00
item - > goalAnimState = LS_STEP_LEFT ;
2020-09-26 03:28:30 +10:00
}
2021-09-18 00:36:28 +03:00
else if ( TrInput & IN_RSTEP )
2020-09-26 03:28:30 +10:00
{
2021-09-18 00:36:28 +03:00
auto collFloorResult = LaraCollisionFront ( item , item - > pos . yRot + ANGLE ( 90.0f ) , LARA_RAD + 48 ) ;
auto collCeilingResult = LaraCeilingCollisionFront ( item , item - > pos . yRot + ANGLE ( 90.0f ) , LARA_RAD + 48 , LARA_HEIGHT ) ;
2020-09-26 03:28:30 +10:00
2021-10-04 22:02:02 +11:00
if ( ( collFloorResult . Position . Floor < 128 & & collFloorResult . Position . Floor > - 128 ) & & ! collFloorResult . Position . Slope & & collCeilingResult . Position . Ceiling < = 0 )
2021-09-18 00:36:28 +03:00
item - > goalAnimState = LS_STEP_RIGHT ;
}
else if ( TrInput & IN_LEFT )
{
2021-10-02 15:44:34 +03:00
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_FAST_TURN )
Lara . turnRate = - LARA_FAST_TURN ;
2021-09-18 00:36:28 +03:00
item - > goalAnimState = LS_TURN_LEFT_SLOW ;
2020-08-14 17:54:25 -05:00
}
2021-09-18 00:36:28 +03:00
else if ( TrInput & IN_RIGHT )
{
2021-10-02 15:44:34 +03:00
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_FAST_TURN )
Lara . turnRate = LARA_FAST_TURN ;
2021-09-18 00:36:28 +03:00
item - > goalAnimState = LS_TURN_RIGHT_SLOW ;
}
if ( TrInput & IN_FORWARD )
fheight = LaraCollisionFront ( item , item - > pos . yRot , LARA_RAD + 4 ) ;
else if ( TrInput & IN_BACK )
rheight = LaraCollisionFront ( item , item - > pos . yRot - ANGLE ( 180.0f ) , LARA_RAD + 4 ) ; // TR3: item->pos.yRot + ANGLE(180)?
2020-08-14 17:54:25 -05:00
if ( Lara . waterStatus = = LW_WADE )
{
if ( TrInput & IN_JUMP & & ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) )
item - > goalAnimState = LS_JUMP_PREPARE ;
if ( TrInput & IN_FORWARD )
{
2021-10-02 15:44:34 +03:00
item - > goalAnimState = LS_WADE_FORWARD ;
2020-09-26 05:06:08 +10:00
bool wade = false ;
if ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP )
2020-08-14 17:54:25 -05:00
{
2021-09-10 00:43:26 +03:00
if ( fheight . Position . Floor > - ( STEPUP_HEIGHT - 1 ) )
2020-09-26 05:06:08 +10:00
wade = true ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else
2020-08-14 17:54:25 -05:00
{
2021-09-10 00:43:26 +03:00
if ( ( fheight . Position . Floor < ( STEPUP_HEIGHT - 1 ) ) & & ( fheight . Position . Floor > - ( STEPUP_HEIGHT - 1 ) ) )
2020-09-26 05:06:08 +10:00
wade = true ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
if ( ! wade )
2020-08-14 17:54:25 -05:00
{
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . Radius = LARA_RAD + 2 ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2020-09-26 05:06:08 +10:00
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-09-26 05:06:08 +10:00
if ( TestLaraVault ( item , coll ) )
return ;
2021-09-10 00:20:59 +03:00
coll - > Setup . Radius = LARA_RAD ;
2020-08-14 17:54:25 -05:00
}
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_BACK )
2020-08-14 17:54:25 -05:00
{
2021-10-02 15:44:34 +03:00
if ( TrInput & IN_WALK )
{
if ( ( rheight . Position . Floor < ( STEPUP_HEIGHT - 1 ) ) & & ( rheight . Position . Floor > - ( STEPUP_HEIGHT - 1 ) ) & & ! rheight . Position . Slope )
item - > goalAnimState = LS_WALK_BACK ;
}
else if ( rheight . Position . Floor > - ( STEPUP_HEIGHT - 1 ) )
{
item - > goalAnimState = LS_HOP_BACK ;
}
2020-08-14 17:54:25 -05:00
}
}
2020-09-26 05:06:08 +10:00
else
2020-08-14 17:54:25 -05:00
{
if ( TrInput & IN_JUMP )
{
2021-10-02 17:26:12 +03:00
if ( coll - > Middle . Ceiling < - LARA_HEADROOM * 0.7f )
2021-09-18 00:36:28 +03:00
item - > goalAnimState = LS_JUMP_PREPARE ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_FORWARD )
2020-09-26 03:28:30 +10:00
{
2021-09-18 00:36:28 +03:00
auto cheight = LaraCeilingCollisionFront ( item , item - > pos . yRot , LARA_RAD + 4 , LARA_HEIGHT ) ;
2021-10-04 22:02:02 +11:00
2021-09-25 13:35:10 +03:00
// Don't try to move if there is slope in front
2021-09-18 00:36:28 +03:00
if ( fheight . Position . Slope & & ( fheight . Position . Floor < 0 | | cheight . Position . Ceiling > 0 ) )
2021-09-17 22:55:09 +03:00
return ; // item->goalAnimState = LS_STOP was removed here because it prevented Lara from rotating while still holding forward. -- Lwmte, 17.09.2021
2021-10-02 15:44:34 +03:00
if ( TestLaraVault ( item , coll ) )
return ;
2021-09-25 13:35:10 +03:00
// Don't try to move if there is no headroom in front
if ( coll - > CollisionType = = CT_FRONT )
return ;
2021-09-18 03:06:21 +03:00
if ( TrInput & IN_WALK )
2021-10-02 15:44:34 +03:00
item - > goalAnimState = LS_WALK_FORWARD ;
2020-08-14 17:54:25 -05:00
else
2021-10-02 15:44:34 +03:00
item - > goalAnimState = LS_RUN_FORWARD ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_BACK )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_WALK )
2020-08-14 17:54:25 -05:00
{
2021-09-17 22:55:09 +03:00
if ( ( rheight . Position . Floor < ( STEPUP_HEIGHT - 1 ) ) & & ( rheight . Position . Floor > - ( STEPUP_HEIGHT - 1 ) ) & & ! rheight . Position . Slope )
2021-10-02 15:44:34 +03:00
item - > goalAnimState = LS_WALK_BACK ;
2020-08-14 17:54:25 -05:00
}
2021-09-10 00:43:26 +03:00
else if ( rheight . Position . Floor > - ( STEPUP_HEIGHT - 1 ) )
2020-08-14 17:54:25 -05:00
{
item - > goalAnimState = LS_HOP_BACK ;
}
}
}
}
2021-09-28 01:22:47 +10:00
// State: LS_STOP (2)
// Control: lara_as_stop()
2021-10-04 15:34:36 +11:00
void lara_col_stop ( ITEM_INFO * item , COLL_INFO * coll )
2021-09-28 01:22:47 +10:00
{
Lara . moveAngle = item - > pos . yRot ;
2021-10-10 00:58:30 +11:00
coll - > Setup . BadHeightDown = STEPUP_HEIGHT ; // TODO: Probe left/right floor instead for drop? Sprint-to-stop slide animation will not work as it should otherwise. @Sezz 2021.10.10
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-28 01:22:47 +10:00
coll - > Setup . BadCeilingHeight = 0 ;
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
coll - > Setup . SlopesArePits = true ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
GetCollisionInfo ( coll , item ) ;
// TODO: Test if Lara can get stuck here. Presumably, falling and sliding should have precedence instead. @Sezz 2021.09.28
if ( TestLaraHitCeiling ( coll ) )
{
SetLaraHitCeiling ( item , coll ) ;
return ;
}
if ( TestLaraFall ( coll ) )
{
SetLaraFallState ( item ) ;
return ;
}
if ( TestLaraSlideNew ( coll ) )
{
SetLaraSlideState ( item , coll ) ;
return ;
}
2021-10-15 00:46:15 +11:00
ShiftItem ( item , coll ) ;
2021-10-04 15:34:36 +11:00
// TODO: Valuting originally took priority, but it may have been allowing Lara to vault on slopes with a well-timed input. Investigate. @Sezz 2021.10.04
2021-09-28 01:22:47 +10:00
if ( TestLaraVault ( item , coll ) )
return ;
# if 1
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
# else
if ( ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) | | coll - > Middle . Floor < 0 )
item - > pos . yPos + = coll - > Middle . Floor ;
else if ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP & & coll - > Middle . Floor )
item - > pos . yPos + = SWAMP_GRAVITY ;
# endif
}
// LEGACY
void old_lara_col_stop ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 2*/
/*state code: lara_as_stop*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = STEPUP_HEIGHT ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
2020-09-26 05:06:08 +10:00
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
2021-09-10 00:20:59 +03:00
coll - > Setup . SlopesArePits = true ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( LaraHitCeiling ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
2020-09-26 05:06:08 +10:00
if ( LaraFallen ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
2020-09-26 05:06:08 +10:00
if ( TestLaraSlide ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
ShiftItem ( item , coll ) ;
# if 1
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
# else
2021-09-10 00:18:47 +03:00
if ( ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) | | coll - > Middle . Floor < 0 )
item - > pos . yPos + = coll - > Middle . Floor ;
else if ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP & & coll - > Middle . Floor )
2020-08-14 17:54:25 -05:00
item - > pos . yPos + = SWAMP_GRAVITY ;
# endif
}
2021-02-03 01:50:59 -03:00
void lara_as_forwardjump ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 3*/
/*collision: */
if ( item - > goalAnimState = = LS_SWANDIVE_START | |
item - > goalAnimState = = LS_REACH )
item - > goalAnimState = LS_JUMP_FORWARD ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( item - > goalAnimState ! = LS_DEATH & &
item - > goalAnimState ! = LS_STOP & &
item - > goalAnimState ! = LS_RUN_FORWARD )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( Lara . gunStatus = = LG_NO_ARMS & & TrInput & IN_ACTION )
item - > goalAnimState = LS_REACH ;
if ( TrInput & IN_BACK | | TrInput & IN_ROLL )
item - > goalAnimState = LS_JUMP_ROLL_180 ;
if ( Lara . gunStatus = = LG_NO_ARMS & & TrInput & IN_WALK )
item - > goalAnimState = LS_SWANDIVE_START ;
if ( item - > fallspeed > LARA_FREEFALL_SPEED )
item - > goalAnimState = LS_FREEFALL ;
2020-08-14 17:54:25 -05:00
}
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
2020-09-26 05:06:08 +10:00
2021-09-28 01:22:47 +10:00
if ( Lara . turnRate < - LARA_JUMP_TURN )
Lara . turnRate = - LARA_JUMP_TURN ;
2020-08-14 17:54:25 -05:00
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
2020-09-26 05:06:08 +10:00
2021-09-28 01:22:47 +10:00
if ( Lara . turnRate > LARA_JUMP_TURN )
Lara . turnRate = LARA_JUMP_TURN ;
2020-08-14 17:54:25 -05:00
}
}
2021-02-03 01:50:59 -03:00
void lara_col_forwardjump ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 3*/
/*state code: lara_as_forwardjump*/
2020-08-14 17:54:25 -05:00
if ( item - > speed < 0 )
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
2020-08-14 17:54:25 -05:00
else
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = BAD_JUMP_CEILING ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
LaraDeflectEdgeJump ( item , coll ) ;
2020-09-26 05:06:08 +10:00
if ( item - > speed < 0 )
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor < = 0 & & item - > fallspeed > 0 )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( LaraLandedBad ( item , coll ) )
2020-08-14 17:54:25 -05:00
{
item - > goalAnimState = LS_DEATH ;
}
else
{
if ( Lara . waterStatus = = LW_WADE )
{
item - > goalAnimState = LS_STOP ;
}
else
{
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_FORWARD & & ! ( TrInput & IN_STEPSHIFT ) )
2020-08-14 17:54:25 -05:00
item - > goalAnimState = LS_RUN_FORWARD ;
else
item - > goalAnimState = LS_STOP ;
}
}
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
item - > speed = 0 ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}
2021-10-13 19:50:46 +11:00
// State: LS_POSE (4)
// Control: lara_void_func()
2021-02-03 01:50:59 -03:00
void lara_col_pose ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
lara_col_stop ( item , coll ) ;
}
2021-10-09 20:19:34 +11:00
// State: LS_HOP_BACK (5)
// Collision: lara_col_fastback()
2021-02-03 01:50:59 -03:00
void lara_as_fastback ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-09 20:19:34 +11:00
{
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_MED_TURN )
Lara . turnRate = - LARA_MED_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX / 2 ) / 12 ;
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_MED_TURN )
Lara . turnRate = LARA_MED_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot + = ( LARA_LEAN_MAX / 2 - item - > pos . zRot ) / 12 ;
}
item - > goalAnimState = LS_STOP ;
}
// LEGACY
void old_lara_as_fastback ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state: 5*/
/*collision: lara_col_fastback*/
item - > goalAnimState = LS_STOP ;
2020-08-14 17:54:25 -05:00
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
2021-10-02 15:44:34 +03:00
if ( Lara . turnRate < - LARA_MED_TURN )
Lara . turnRate = - LARA_MED_TURN ;
2020-08-14 17:54:25 -05:00
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
2021-10-02 15:44:34 +03:00
if ( Lara . turnRate > LARA_MED_TURN )
Lara . turnRate = LARA_MED_TURN ;
2020-08-14 17:54:25 -05:00
}
}
2021-10-09 20:19:34 +11:00
// State: LS_HOP_BACK (5)
// Control: lara_as_fastback()
2021-02-03 01:50:59 -03:00
void lara_col_fastback ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-09 20:19:34 +11:00
{
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
item - > fallspeed = 0 ;
item - > gravityStatus = false ;
coll - > Setup . SlopesAreWalls = false ;
coll - > Setup . SlopesArePits = true ;
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
GetCollisionInfo ( coll , item ) ;
if ( TestLaraHitCeiling ( coll ) )
{
SetLaraHitCeiling ( item , coll ) ;
return ;
}
if ( LaraDeflectEdge ( item , coll ) )
LaraCollideStop ( item , coll ) ;
if ( coll - > Middle . Floor > STEPUP_HEIGHT / 2 )
{
2021-10-14 19:58:29 +11:00
SetLaraFallBackState ( item ) ;
2021-10-09 20:19:34 +11:00
return ;
}
if ( TestLaraSlide ( item , coll ) )
{
SetLaraSlideState ( item , coll ) ;
return ;
}
if ( TestLaraStep ( coll ) )
{
DoLaraStep ( item , coll ) ;
return ;
}
2021-10-09 23:00:26 +11:00
// LEGACY step
/*if (coll->Middle.Floor <= 200)
{
if ( LaraDeflectEdge ( item , coll ) )
LaraCollideStop ( item , coll ) ;
if ( ! TestLaraSlide ( item , coll ) & & coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
}
else
{
item - > fallspeed = 0 ;
item - > animNumber = LA_FALL_BACK ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > currentAnimState = LS_FALL_BACK ;
item - > goalAnimState = LS_FALL_BACK ;
item - > gravityStatus = true ;
} */
2021-10-09 20:19:34 +11:00
}
// LEGACY
void old_lara_col_fastback ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state: 5*/
/*state code: lara_as_fastback*/
2020-08-14 17:54:25 -05:00
item - > fallspeed = 0 ;
item - > gravityStatus = false ;
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
2020-09-26 05:06:08 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . SlopesAreWalls = false ;
coll - > Setup . SlopesArePits = true ;
2020-09-26 05:06:08 +10:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( ! LaraHitCeiling ( item , coll ) )
2020-09-26 03:28:30 +10:00
{
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor < = 200 )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
if ( LaraDeflectEdge ( item , coll ) )
LaraCollideStop ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( ! TestLaraSlide ( item , coll ) & & coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
else
{
2020-09-26 05:06:08 +10:00
item - > fallspeed = 0 ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
item - > animNumber = LA_FALL_BACK ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > currentAnimState = LS_FALL_BACK ;
item - > goalAnimState = LS_FALL_BACK ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
item - > gravityStatus = true ;
}
2020-09-26 03:28:30 +10:00
}
}
2021-10-05 22:09:07 +11:00
// State: LS_TURN_RIGHT_SLOW (6)
// Collision: lara_col_turn_r()
2021-02-03 01:50:59 -03:00
void lara_as_turn_r ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-05 22:09:07 +11:00
{
if ( item - > hitPoints < = 0 )
{
2021-10-08 15:47:54 +11:00
item - > goalAnimState = LS_DEATH ;
2021-10-05 22:09:07 +11:00
return ;
}
2021-10-08 15:47:54 +11:00
// TODO: This can't be anywhere below the run dispatch because tests to prevent forward/back movement currently don't exist.
Lara . turnRate + = LARA_TURN_RATE ;
2021-10-06 14:03:12 +11:00
2021-10-13 19:50:46 +11:00
if ( Lara . waterStatus = = LW_WADE )
2021-10-05 22:09:07 +11:00
{
2021-10-13 19:50:46 +11:00
LaraWadeTurnRight ( item , coll ) ;
2021-10-05 22:09:07 +11:00
return ;
}
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_JUMP )
2021-10-05 22:09:07 +11:00
{
2021-10-13 19:50:46 +11:00
item - > goalAnimState = LS_JUMP_PREPARE ;
2021-10-05 22:09:07 +11:00
return ;
}
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_ROLL )
2021-10-05 22:09:07 +11:00
{
item - > goalAnimState = LS_ROLL_FORWARD ;
return ;
}
2021-10-11 00:05:49 +11:00
if ( ( TrInput & IN_DUCK | | TestLaraStandUp ( coll ) ) & &
2021-10-13 19:50:46 +11:00
( Lara . gunStatus = = LG_NO_ARMS | | ! IsStandingWeapon ( Lara . gunType ) ) )
2021-10-05 22:09:07 +11:00
{
item - > goalAnimState = LS_CROUCH_IDLE ;
return ;
}
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_FORWARD )
2021-10-05 22:09:07 +11:00
{
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_WALK )
2021-10-08 15:47:54 +11:00
item - > goalAnimState = LS_WALK_FORWARD ; // TODO: This is a frame-perfect input.
2021-10-13 19:50:46 +11:00
else if ( TrInput & IN_SPRINT )
item - > goalAnimState = LS_SPRINT ;
2021-10-05 22:09:07 +11:00
else [[likely]]
item - > goalAnimState = LS_RUN_FORWARD ;
return ;
}
if ( TrInput & IN_BACK )
{
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_WALK )
2021-10-05 22:09:07 +11:00
item - > goalAnimState = LS_WALK_BACK ;
else [[likely]]
item - > goalAnimState = LS_HOP_BACK ;
return ;
}
2021-10-08 15:47:54 +11:00
if ( TrInput & IN_LSTEP & &
TestLaraStepLeft ( item ) )
{
item - > goalAnimState = LS_STEP_LEFT ;
return ;
}
else if ( TrInput & IN_RSTEP & &
TestLaraStepRight ( item ) )
{
item - > goalAnimState = LS_STEP_RIGHT ;
return ;
}
2021-10-05 22:09:07 +11:00
if ( TrInput & IN_RIGHT )
{
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_WALK ) // TODO: This hasn't worked since TR1.
2021-10-05 22:09:07 +11:00
{
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
item - > goalAnimState = LS_TURN_RIGHT_SLOW ;
}
2021-10-08 20:08:55 +11:00
else if ( Lara . turnRate > LARA_SLOW_TURN )
item - > goalAnimState = LS_TURN_RIGHT_FAST ;
2021-10-05 22:09:07 +11:00
else [[likely]]
item - > goalAnimState = LS_TURN_RIGHT_SLOW ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
2021-10-13 19:50:46 +11:00
// Pseudo-state for turning right in wade-height water.
void LaraWadeTurnRight ( ITEM_INFO * item , COLL_INFO * coll )
{
if ( TrInput & IN_JUMP & &
! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) )
{
item - > goalAnimState = LS_JUMP_PREPARE ;
return ;
}
if ( TrInput & IN_FORWARD )
{
item - > goalAnimState = LS_WADE_FORWARD ;
return ;
}
if ( TrInput & IN_BACK )
{
item - > goalAnimState = LS_WALK_BACK ;
return ;
}
if ( TrInput & IN_LSTEP & &
TestLaraStepLeft ( item ) )
{
item - > goalAnimState = LS_STEP_LEFT ;
return ;
}
else if ( TrInput & IN_RSTEP & &
TestLaraStepRight ( item ) )
{
item - > goalAnimState = LS_STEP_RIGHT ;
return ;
}
if ( TrInput & IN_RIGHT )
{
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
item - > goalAnimState = LS_TURN_RIGHT_SLOW ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
2021-10-05 22:09:07 +11:00
// LEGACY
void old_lara_as_turn_r ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
/*state: 6*/
/*collision: */
2020-09-26 03:28:30 +10:00
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
2020-09-26 05:06:08 +10:00
2020-09-26 03:28:30 +10:00
return ;
}
Lara . turnRate + = LARA_TURN_RATE ;
2020-09-26 05:06:08 +10:00
if ( Lara . gunStatus ! = LG_READY | | Lara . waterStatus = = LW_WADE )
2020-09-26 03:28:30 +10:00
{
2021-10-02 15:44:34 +03:00
if ( Lara . turnRate > LARA_SLOW_TURN )
2020-09-26 03:28:30 +10:00
{
2021-09-18 00:36:28 +03:00
if ( TrInput & IN_WALK | | Lara . waterStatus = = LW_WADE )
2021-10-02 15:44:34 +03:00
Lara . turnRate = LARA_SLOW_TURN ;
2020-09-26 05:06:08 +10:00
else
2021-10-08 20:08:55 +11:00
item - > goalAnimState ; // = LS_TURN_FAST;
2020-08-14 17:54:25 -05:00
}
}
else
{
2021-10-08 20:08:55 +11:00
item - > goalAnimState ; // = LS_TURN_FAST;
2020-08-14 17:54:25 -05:00
}
2021-09-25 13:35:10 +03:00
// Don't try to move forward if button isn't pressed or there's no headroom in front
2021-10-06 14:03:12 +11:00
if ( ! ( TrInput & IN_FORWARD ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( ! ( TrInput & IN_RIGHT ) )
item - > goalAnimState = LS_STOP ;
2020-09-26 03:28:30 +10:00
2020-08-14 17:54:25 -05:00
return ;
}
2020-09-26 05:06:08 +10:00
if ( Lara . waterStatus = = LW_WADE )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_WADE_FORWARD ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_WALK )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_WALK_FORWARD ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_RUN_FORWARD ;
2020-08-14 17:54:25 -05:00
}
}
2021-10-15 00:46:15 +11:00
// State: LS_TURN_RIGHT_SLOW (6)
// Control: lara_as_turn_r()
2021-02-03 01:50:59 -03:00
void lara_col_turn_r ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-15 00:46:15 +11:00
{
lara_col_stop ( item , coll ) ;
}
// LEGACY
void old_lara_col_turn_r ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state: 6*/
/*state code: lara_as_turn_r*/
2020-08-14 17:54:25 -05:00
item - > fallspeed = 0 ;
item - > gravityStatus = false ;
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = STEPUP_HEIGHT ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . SlopesArePits = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
# if 1
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > 100 )
2020-08-14 17:54:25 -05:00
# else
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > 100 & & ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) )
2020-08-14 17:54:25 -05:00
# endif
{
item - > fallspeed = 0 ;
2020-09-26 05:06:08 +10:00
item - > animNumber = LA_FALL_START ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > currentAnimState = LS_JUMP_FORWARD ;
item - > goalAnimState = LS_JUMP_FORWARD ;
2020-08-14 17:54:25 -05:00
item - > gravityStatus = true ;
return ;
}
2020-09-26 05:06:08 +10:00
if ( TestLaraSlide ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
# if 1
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
# else
2021-09-10 00:18:47 +03:00
if ( ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) | | coll - > Middle . Floor < 0 )
item - > pos . yPos + = coll - > Middle . Floor ;
else if ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP & & coll - > Middle . Floor )
2020-08-14 17:54:25 -05:00
item - > pos . yPos + = SWAMP_GRAVITY ;
# endif
}
2021-10-08 15:47:54 +11:00
// State: LS_TURN_LEFT_SLOW (7)
// Collision: lara_col_turn_l()
2021-02-03 01:50:59 -03:00
void lara_as_turn_l ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-08 15:47:54 +11:00
{
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_DEATH ;
return ;
}
Lara . turnRate - = LARA_TURN_RATE ;
2021-10-13 19:50:46 +11:00
if ( Lara . waterStatus = = LW_WADE )
2021-10-08 15:47:54 +11:00
{
2021-10-13 19:50:46 +11:00
LaraWadeTurnLeft ( item , coll ) ;
2021-10-08 15:47:54 +11:00
return ;
}
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_JUMP )
2021-10-08 15:47:54 +11:00
{
2021-10-13 19:50:46 +11:00
item - > goalAnimState = LS_JUMP_PREPARE ;
2021-10-08 15:47:54 +11:00
return ;
}
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_ROLL )
2021-10-08 15:47:54 +11:00
{
item - > goalAnimState = LS_ROLL_FORWARD ;
return ;
}
2021-10-11 00:05:49 +11:00
if ( ( TrInput & IN_DUCK | | TestLaraStandUp ( coll ) ) & &
2021-10-13 19:50:46 +11:00
( Lara . gunStatus = = LG_NO_ARMS | | ! IsStandingWeapon ( Lara . gunType ) ) )
2021-10-08 15:47:54 +11:00
{
item - > goalAnimState = LS_CROUCH_IDLE ;
return ;
}
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_FORWARD )
2021-10-08 15:47:54 +11:00
{
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_WALK )
2021-10-08 15:47:54 +11:00
item - > goalAnimState = LS_WALK_FORWARD ;
2021-10-13 19:50:46 +11:00
else if ( TrInput & IN_SPRINT )
item - > goalAnimState = LS_SPRINT ;
2021-10-08 15:47:54 +11:00
else [[likely]]
item - > goalAnimState = LS_RUN_FORWARD ;
return ;
}
if ( TrInput & IN_BACK )
{
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_WALK )
2021-10-08 15:47:54 +11:00
item - > goalAnimState = LS_WALK_BACK ;
else [[likely]]
item - > goalAnimState = LS_HOP_BACK ;
return ;
}
if ( TrInput & IN_LSTEP & &
TestLaraStepLeft ( item ) )
{
item - > goalAnimState = LS_STEP_LEFT ;
return ;
}
2021-10-08 20:08:55 +11:00
else if ( TrInput & IN_RSTEP & & // TODO: This fails. Lara steps left. Why?? @Sezz 2021.10.08
2021-10-08 15:47:54 +11:00
TestLaraStepRight ( item ) )
{
item - > goalAnimState = LS_STEP_RIGHT ;
return ;
}
if ( TrInput & IN_LEFT )
{
2021-10-13 19:50:46 +11:00
if ( TrInput & IN_WALK )
2021-10-08 15:47:54 +11:00
{
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
item - > goalAnimState = LS_TURN_LEFT_SLOW ;
}
2021-10-08 20:08:55 +11:00
else if ( Lara . turnRate < - LARA_SLOW_TURN )
item - > goalAnimState = LS_TURN_LEFT_FAST ;
2021-10-08 15:47:54 +11:00
else [[likely]]
item - > goalAnimState = LS_TURN_RIGHT_SLOW ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
2021-10-13 19:50:46 +11:00
// Pseudo-state for turning left in wade-height water.
void LaraWadeTurnLeft ( ITEM_INFO * item , COLL_INFO * coll )
{
if ( TrInput & IN_JUMP & &
! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) )
{
item - > goalAnimState = LS_JUMP_PREPARE ;
return ;
}
if ( TrInput & IN_FORWARD )
{
item - > goalAnimState = LS_WADE_FORWARD ;
return ;
}
if ( TrInput & IN_BACK )
{
item - > goalAnimState = LS_WALK_BACK ;
return ;
}
if ( TrInput & IN_LSTEP & &
TestLaraStepLeft ( item ) )
{
item - > goalAnimState = LS_STEP_LEFT ;
return ;
}
else if ( TrInput & IN_RSTEP & &
TestLaraStepRight ( item ) )
{
item - > goalAnimState = LS_STEP_RIGHT ;
return ;
}
if ( TrInput & IN_LEFT )
{
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
item - > goalAnimState = LS_TURN_LEFT_SLOW ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
2021-10-08 15:47:54 +11:00
// LEGACY
void old_lara_as_turn_l ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 7*/
/*collision: lara_col_turn_l*/
2020-08-14 17:54:25 -05:00
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
Lara . turnRate - = LARA_TURN_RATE ;
2020-09-26 05:06:08 +10:00
if ( Lara . gunStatus ! = LG_READY | | Lara . waterStatus = = LW_WADE )
2020-08-14 17:54:25 -05:00
{
2021-10-02 15:44:34 +03:00
if ( Lara . turnRate < - LARA_SLOW_TURN )
2020-08-14 17:54:25 -05:00
{
2021-09-18 00:36:28 +03:00
if ( TrInput & IN_WALK | | Lara . waterStatus = = LW_WADE )
2021-10-02 15:44:34 +03:00
Lara . turnRate = - LARA_SLOW_TURN ;
2020-09-26 05:06:08 +10:00
else
2021-10-13 19:50:46 +11:00
item - > goalAnimState ; // = LS_TURN_FAST; // Dead state.
2020-08-14 17:54:25 -05:00
}
}
else
{
2021-10-13 19:50:46 +11:00
item - > goalAnimState ; // = LS_TURN_FAST; // Dead state.
2020-08-14 17:54:25 -05:00
}
2021-09-25 13:35:10 +03:00
// Don't try to move forward if button isn't pressed or there's no headroom in front
if ( ! ( TrInput & IN_FORWARD ) | | coll - > CollisionType = = CT_FRONT )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( ! ( TrInput & IN_LEFT ) )
item - > goalAnimState = LS_STOP ;
2020-09-26 03:28:30 +10:00
2020-08-14 17:54:25 -05:00
return ;
}
2020-09-26 05:06:08 +10:00
if ( Lara . waterStatus = = LW_WADE )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_WADE_FORWARD ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_WALK )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_WALK_FORWARD ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_RUN_FORWARD ;
2020-08-14 17:54:25 -05:00
}
}
2021-10-15 00:46:15 +11:00
// State: LS_TURN_LEFT_SLOW (7)
// Control: lara_as_turn_l()
2021-02-03 01:50:59 -03:00
void lara_col_turn_l ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
lara_col_turn_r ( item , coll ) ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_as_death ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 8*/
/*collision: lara_col_death*/
2020-08-14 17:54:25 -05:00
Lara . look = false ;
2021-09-10 00:20:59 +03:00
coll - > Setup . EnableObjectPush = false ;
coll - > Setup . EnableSpaz = false ;
2020-08-14 17:54:25 -05:00
if ( BinocularRange )
{
BinocularRange = 0 ;
LaserSight = 0 ;
2020-09-26 05:06:08 +10:00
AlterFOV ( ANGLE ( 80.0f ) ) ;
2020-08-14 17:54:25 -05:00
LaraItem - > meshBits = - 1 ;
Lara . busy = false ;
}
}
2021-02-03 01:50:59 -03:00
void lara_col_death ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 8*/
/*state code: lara_as_death*/
2021-05-26 06:04:32 +02:00
StopSoundEffect ( SFX_TR4_LARA_FALL ) ;
2020-09-26 03:28:30 +10:00
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = STEPUP_HEIGHT ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
2021-09-10 01:19:15 +03:00
coll - > Setup . Radius = LARA_RAD_DEATH ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
ShiftItem ( item , coll ) ;
item - > hitPoints = - 1 ;
Lara . air = - 1 ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_as_fastfall ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 9*/
/*collision: lara_col_fastfall*/
2020-08-14 17:54:25 -05:00
item - > speed = ( item - > speed * 95 ) / 100 ;
if ( item - > fallspeed = = 154 )
2021-05-26 06:04:32 +02:00
SoundEffect ( SFX_TR4_LARA_FALL , & item - > pos , 0 ) ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_col_fastfall ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 9*/
/*state code: lara_as_fastfall*/
2020-08-14 17:54:25 -05:00
item - > gravityStatus = true ;
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = BAD_JUMP_CEILING ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-09-26 05:06:08 +10:00
LaraSlideEdgeJump ( item , coll ) ;
2020-08-14 17:54:25 -05:00
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor < = 0 )
2020-08-14 17:54:25 -05:00
{
if ( LaraLandedBad ( item , coll ) )
{
item - > goalAnimState = LS_DEATH ;
}
else
{
item - > goalAnimState = LS_STOP ;
2020-09-26 05:06:08 +10:00
item - > currentAnimState = LS_STOP ;
item - > animNumber = LA_FREEFALL_LAND ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
2020-08-14 17:54:25 -05:00
}
2021-05-26 06:04:32 +02:00
StopSoundEffect ( SFX_TR4_LARA_FALL ) ;
2020-09-26 05:06:08 +10:00
2020-08-14 17:54:25 -05:00
item - > fallspeed = 0 ;
item - > gravityStatus = false ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}
2021-02-03 01:50:59 -03:00
void lara_as_reach ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 11*/
/*collision: lara_col_reach*/
2020-08-14 17:54:25 -05:00
Camera . targetAngle = ANGLE ( 85.0f ) ;
if ( item - > fallspeed > LARA_FREEFALL_SPEED )
item - > goalAnimState = LS_FREEFALL ;
}
2021-02-03 01:50:59 -03:00
void lara_col_reach ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 11*/
/*state code: lara_as_reach*/
2020-08-14 17:54:25 -05:00
if ( Lara . ropePtr = = - 1 )
item - > gravityStatus = true ;
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-10-03 21:13:00 +03:00
coll - > Setup . Height = LARA_HEIGHT_STRETCH ;
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = 0 ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = BAD_JUMP_CEILING ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-10-03 21:13:00 +03:00
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
short angle ;
bool result = false ;
int edge = 0 ;
int edgeCatch = 0 ;
2021-09-10 00:18:47 +03:00
if ( TrInput & IN_ACTION & & Lara . gunStatus = = LG_NO_ARMS & & ! coll - > HitStatic )
2020-08-14 17:54:25 -05:00
{
2021-09-10 00:18:47 +03:00
if ( Lara . canMonkeySwing & & coll - > CollisionType = = CT_TOP )
2020-08-14 17:54:25 -05:00
{
Lara . headYrot = 0 ;
Lara . headXrot = 0 ;
Lara . torsoYrot = 0 ;
Lara . torsoXrot = 0 ;
Lara . gunStatus = LG_HANDS_BUSY ;
item - > animNumber = LA_REACH_TO_MONKEYSWING ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > goalAnimState = LS_MONKEYSWING_IDLE ;
item - > currentAnimState = LS_MONKEYSWING_IDLE ;
item - > gravityStatus = false ;
item - > speed = 0 ;
item - > fallspeed = 0 ;
return ;
}
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Ceiling < = - 384 & &
coll - > Middle . Floor > = 200 & &
coll - > CollisionType = = CT_FRONT )
2020-08-14 17:54:25 -05:00
{
2021-09-14 00:30:44 +03:00
edgeCatch = TestLaraEdgeCatch ( item , coll , & edge ) ;
2020-08-14 17:54:25 -05:00
2021-09-14 00:30:44 +03:00
if ( ! ( ! edgeCatch | | edgeCatch < 0 & & ! TestLaraHangOnClimbWall ( item , coll ) ) )
2020-08-14 17:54:25 -05:00
{
angle = item - > pos . yRot ;
2021-10-04 22:02:02 +11:00
2021-09-13 20:19:33 +02:00
result = SnapToQuadrant ( angle , 35 ) ;
2020-08-14 17:54:25 -05:00
}
}
}
if ( ! result )
{
2020-09-26 05:06:08 +10:00
LaraSlideEdgeJump ( item , coll ) ;
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
ShiftItem ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( item - > fallspeed > 0 & & coll - > Middle . Floor < = 0 )
2020-08-14 17:54:25 -05:00
{
if ( LaraLandedBad ( item , coll ) )
{
item - > goalAnimState = LS_DEATH ;
}
else
{
item - > goalAnimState = LS_STOP ;
item - > fallspeed = 0 ;
item - > gravityStatus = false ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}
}
else
{
if ( TestHangSwingIn ( item , angle ) )
{
2021-07-09 19:41:56 -05:00
if ( Lara . NewAnims . OscillateHanging )
{
Lara . headYrot = 0 ;
Lara . headXrot = 0 ;
Lara . torsoYrot = 0 ;
Lara . torsoXrot = 0 ;
item - > animNumber = LA_REACH_TO_HANG_OSCILLATE ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > currentAnimState = LS_HANG ;
item - > goalAnimState = LS_HANG ;
}
else
{
Lara . headYrot = 0 ;
Lara . headXrot = 0 ;
Lara . torsoYrot = 0 ;
Lara . torsoXrot = 0 ;
item - > animNumber = LA_REACH_TO_MONKEYSWING ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > currentAnimState = LS_MONKEYSWING_IDLE ;
item - > goalAnimState = LS_MONKEYSWING_IDLE ;
}
2020-08-14 17:54:25 -05:00
}
else
{
2021-07-09 19:41:56 -05:00
if ( TestHangFeet ( item , angle ) )
2020-08-14 17:54:25 -05:00
{
item - > animNumber = LA_REACH_TO_HANG ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > currentAnimState = LS_HANG ;
item - > goalAnimState = LS_HANG_FEET ;
}
2021-07-09 19:41:56 -05:00
else
2020-08-14 17:54:25 -05:00
{
item - > animNumber = LA_REACH_TO_HANG ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > currentAnimState = LS_HANG ;
item - > goalAnimState = LS_HANG ;
}
}
BOUNDING_BOX * bounds = GetBoundsAccurate ( item ) ;
if ( edgeCatch < = 0 )
{
item - > pos . yPos = edge - bounds - > Y1 - 22 ;
}
else
{
2021-09-10 00:18:47 +03:00
item - > pos . yPos + = coll - > Front . Floor - bounds - > Y1 ;
2020-08-14 17:54:25 -05:00
2021-09-13 20:19:33 +02:00
Vector2 v = GetOrthogonalIntersect ( item - > pos . xPos , item - > pos . zPos , LARA_RAD , angle ) ;
item - > pos . xPos = v . x ;
item - > pos . zPos = v . y ;
2020-08-14 17:54:25 -05:00
}
item - > pos . yRot = angle ;
2020-09-26 05:06:08 +10:00
2020-08-14 17:54:25 -05:00
item - > gravityStatus = true ;
item - > speed = 2 ;
item - > fallspeed = 1 ;
Lara . gunStatus = LG_HANDS_BUSY ;
}
}
2021-02-03 01:50:59 -03:00
void lara_as_splat ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
Lara . look = false ;
}
2021-02-03 01:50:59 -03:00
void lara_col_splat ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-10 00:20:59 +03:00
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . SlopesArePits = true ;
2020-09-26 05:06:08 +10:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = STEPUP_HEIGHT ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
ShiftItem ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > = - 256 & & coll - > Middle . Floor < = 256 )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_col_land ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 14*/
/*state code: lara_void_func*/
lara_col_stop ( item , coll ) ;
}
void lara_as_compress ( ITEM_INFO * item , COLL_INFO * coll )
{
/*state 15*/
/*collision: lara_col_compress*/
2020-08-14 17:54:25 -05:00
if ( Lara . waterStatus ! = LW_WADE )
{
2021-08-29 23:53:58 +03:00
if ( TrInput & IN_FORWARD & & ! LaraFacingCorner ( item , item - > pos . yRot , 256 ) & & LaraFloorFront ( item , item - > pos . yRot , 256 ) > = - 384 )
2020-08-14 17:54:25 -05:00
{
item - > goalAnimState = LS_JUMP_FORWARD ;
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
}
2021-08-29 23:53:58 +03:00
else if ( TrInput & IN_LEFT & & ! LaraFacingCorner ( item , item - > pos . yRot - ANGLE ( 90.0f ) , 256 ) & & LaraFloorFront ( item , item - > pos . yRot - ANGLE ( 90.0f ) , 256 ) > = - 384 )
2020-08-14 17:54:25 -05:00
{
2020-09-02 15:59:57 -05:00
item - > goalAnimState = LS_JUMP_LEFT ;
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot - ANGLE ( 90 ) ;
2020-08-14 17:54:25 -05:00
}
2021-08-29 23:53:58 +03:00
else if ( TrInput & IN_RIGHT & & ! LaraFacingCorner ( item , item - > pos . yRot + ANGLE ( 90.0f ) , 256 ) & & LaraFloorFront ( item , item - > pos . yRot + ANGLE ( 90.0f ) , 256 ) > = - 384 )
2020-08-14 17:54:25 -05:00
{
2020-09-02 15:59:57 -05:00
item - > goalAnimState = LS_JUMP_RIGHT ;
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 90 ) ;
2020-08-14 17:54:25 -05:00
}
2021-08-29 23:53:58 +03:00
else if ( TrInput & IN_BACK & & ! LaraFacingCorner ( item , item - > pos . yRot - ANGLE ( 180.0f ) , 256 ) & & LaraFloorFront ( item , item - > pos . yRot - ANGLE ( 180.0f ) , 256 ) > = - 384 )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_JUMP_BACK ;
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
2020-08-14 17:54:25 -05:00
}
}
if ( item - > fallspeed > LARA_FREEFALL_SPEED )
item - > goalAnimState = LS_FREEFALL ;
}
2021-02-03 01:50:59 -03:00
void lara_col_compress ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 15*/
/*state code: lara_as_compress*/
2020-08-14 17:54:25 -05:00
item - > fallspeed = 0 ;
item - > gravityStatus = false ;
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = NO_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( ! LaraFallen ( item , coll ) )
2020-09-26 03:28:30 +10:00
{
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Ceiling > - 100 )
2020-09-26 05:06:08 +10:00
{
item - > animNumber = LA_STAND_SOLID ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > goalAnimState = LS_STOP ;
item - > currentAnimState = LS_STOP ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
item - > speed = 0 ;
item - > fallspeed = 0 ;
item - > gravityStatus = false ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
item - > pos . xPos = coll - > Setup . OldPosition . x ;
item - > pos . yPos = coll - > Setup . OldPosition . y ;
item - > pos . zPos = coll - > Setup . OldPosition . z ;
2020-09-26 05:06:08 +10:00
}
2020-09-26 03:28:30 +10:00
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > - 256 & & coll - > Middle . Floor < 256 )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}
2021-10-09 23:00:26 +11:00
// State: LS_WALK_BACK (16)
// Collision: lara_col_back()
2021-02-03 01:50:59 -03:00
void lara_as_back ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-09 23:00:26 +11:00
{
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
2021-10-13 19:50:46 +11:00
// TODO: This seems unnecessary, but I'm leaving it in case something breaks. @Sezz 2021.10.13
/*if (Lara.isMoving)
return ; */
2021-10-09 23:00:26 +11:00
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX / 3 ) / 12 ;
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot + = ( LARA_LEAN_MAX / 3 - item - > pos . zRot ) / 12 ;
}
2021-10-14 01:17:21 +11:00
if ( TrInput & IN_BACK & &
( TrInput & IN_WALK | | Lara . waterStatus = = LW_WADE ) )
2021-10-09 23:00:26 +11:00
{
2021-10-14 01:17:21 +11:00
item - > goalAnimState = LS_WALK_BACK ;
2021-10-09 23:00:26 +11:00
return ;
}
item - > goalAnimState = LS_STOP ;
}
// LEGACY
void old_lara_as_back ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 16*/
/*collision: lara_col_back*/
2020-08-14 17:54:25 -05:00
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
2020-09-26 05:06:08 +10:00
if ( ! Lara . isMoving )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( ( TrInput & IN_BACK ) & & ( ( TrInput & IN_WALK ) | | Lara . waterStatus = = LW_WADE ) )
item - > goalAnimState = LS_WALK_BACK ;
else
item - > goalAnimState = LS_STOP ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_LEFT )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate - = LARA_TURN_RATE ;
2021-10-02 15:44:34 +03:00
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_RIGHT )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate + = LARA_TURN_RATE ;
2021-10-02 15:44:34 +03:00
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
2020-08-14 17:54:25 -05:00
}
}
}
2021-10-09 23:00:26 +11:00
// State: LS_WALK_BACK (16)
// Control: lara_as_back()
2021-02-03 01:50:59 -03:00
void lara_col_back ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-09 23:00:26 +11:00
{
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
coll - > Setup . BadHeightDown = Lara . waterStatus = = LW_WADE ? NO_BAD_POS : STEPUP_HEIGHT ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesArePits = true ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
GetCollisionInfo ( coll , item ) ;
if ( TestLaraHitCeiling ( coll ) )
{
SetLaraHitCeiling ( item , coll ) ;
return ;
}
if ( LaraDeflectEdge ( item , coll ) )
LaraCollideStop ( item , coll ) ;
if ( TestLaraFall ( coll ) )
{
SetLaraFallState ( item ) ;
return ;
}
if ( TestLaraSlide ( item , coll ) )
{
SetLaraSlideState ( item , coll ) ;
return ;
}
if ( TestLaraStep ( coll ) )
{
DoLaraStep ( item , coll ) ;
return ;
}
// LEGACY step
/*if (coll->Middle.Floor > STEP_SIZE / 2 && coll->Middle.Floor < STEPUP_HEIGHT)
{
item - > goalAnimState = LS_STEP_BACK_DOWN ;
GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) ;
} */
// TODO
#if 0
if ( ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) | | coll - > Middle . Floor < 0 )
item - > pos . yPos + = coll - > Middle . Floor ;
else if ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP & & coll - > Middle . Floor )
item - > pos . yPos + = SWAMP_GRAVITY ;
# else
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
# endif
}
// LEGACY
void old_lara_col_back ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 16*/
/*state code: lara_as_back*/
2020-08-14 17:54:25 -05:00
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
2020-08-14 17:54:25 -05:00
if ( Lara . waterStatus = = LW_WADE )
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
2020-08-14 17:54:25 -05:00
else
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = STEPUP_HEIGHT ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesArePits = true ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
if ( LaraHitCeiling ( item , coll ) )
return ;
if ( LaraDeflectEdge ( item , coll ) )
LaraCollideStop ( item , coll ) ;
2020-09-26 05:06:08 +10:00
if ( LaraFallen ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > STEP_SIZE / 2 & & coll - > Middle . Floor < STEPUP_HEIGHT )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_STEP_BACK_DOWN ;
GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
if ( TestLaraSlide ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
#if 0
2021-09-10 00:18:47 +03:00
if ( ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) | | coll - > Middle . Floor < 0 )
item - > pos . yPos + = coll - > Middle . Floor ;
else if ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP & & coll - > Middle . Floor )
2020-08-14 17:54:25 -05:00
item - > pos . yPos + = SWAMP_GRAVITY ;
# else
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
# endif
}
2021-10-08 20:08:55 +11:00
// State: LS_TURN_RIGHT_FAST (20)
// Collision: lara_col_turn_right_fast()
void lara_as_turn_right_fast ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-08 15:47:54 +11:00
{
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_DEATH ;
return ;
}
2021-10-13 19:50:46 +11:00
// TODO: Wade handling. @Sezz 2021.10.13
2021-10-08 15:47:54 +11:00
if ( TrInput & IN_JUMP )
{
item - > goalAnimState = LS_JUMP_PREPARE ;
return ;
}
if ( TrInput & IN_ROLL & &
Lara . waterStatus ! = LW_WADE )
{
item - > goalAnimState = LS_ROLL_FORWARD ;
return ;
}
2021-10-11 00:05:49 +11:00
if ( ( TrInput & IN_DUCK | | TestLaraStandUp ( coll ) ) & &
2021-10-08 15:47:54 +11:00
( Lara . gunStatus = = LG_NO_ARMS | | ! IsStandingWeapon ( Lara . gunType ) ) & &
Lara . waterStatus ! = LW_WADE )
{
item - > goalAnimState = LS_CROUCH_IDLE ;
return ;
}
if ( TrInput & IN_FORWARD & &
coll - > CollisionType ! = CT_FRONT )
{
if ( Lara . waterStatus = = LW_WADE )
item - > goalAnimState = LS_WADE_FORWARD ;
else if ( TrInput & IN_WALK )
item - > goalAnimState = LS_WALK_FORWARD ;
2021-10-13 19:50:46 +11:00
else if ( TrInput & IN_SPRINT )
item - > goalAnimState = LS_SPRINT ;
2021-10-08 15:47:54 +11:00
else [[likely]]
item - > goalAnimState = LS_RUN_FORWARD ;
return ;
}
if ( TrInput & IN_BACK )
{
if ( Lara . waterStatus = = LW_WADE )
item - > goalAnimState = LS_WALK_BACK ;
else if ( TrInput & IN_WALK )
item - > goalAnimState = LS_WALK_BACK ;
else [[likely]]
item - > goalAnimState = LS_HOP_BACK ;
return ;
}
if ( TrInput & IN_LSTEP & &
TestLaraStepLeft ( item ) )
{
item - > goalAnimState = LS_STEP_LEFT ;
return ;
}
2021-10-08 20:08:55 +11:00
else if ( TrInput & IN_RSTEP & & // TODO: This fails and Lara steps left. Why? @Sezz 2021.10.08
2021-10-08 15:47:54 +11:00
TestLaraStepRight ( item ) )
{
item - > goalAnimState = LS_STEP_RIGHT ;
return ;
}
// TODO: Hold WALK to slow down again.
if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
Lara . turnRate = clamp ( Lara . turnRate , LARA_MED_TURN , LARA_FAST_TURN ) ;
2021-10-08 20:08:55 +11:00
item - > goalAnimState = LS_TURN_RIGHT_FAST ;
2021-10-08 15:47:54 +11:00
return ;
}
item - > goalAnimState = LS_STOP ;
}
2021-10-08 20:08:55 +11:00
// State: LS_TURN_RIGHT_FAST (20)
// Control: lara_as_turn_right_fast()
void lara_col_turn_right_fast ( ITEM_INFO * item , COLL_INFO * coll )
{
lara_col_stop ( item , coll ) ;
}
// LEGACY
void lara_as_fastturn ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 20*/
/*collision: lara_col_fastturn*/
2020-08-14 17:54:25 -05:00
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
2020-09-26 05:06:08 +10:00
if ( Lara . turnRate < 0 )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate = - LARA_FAST_TURN ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( ! ( TrInput & IN_LEFT ) )
item - > goalAnimState = LS_STOP ;
}
else
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate = LARA_FAST_TURN ;
if ( ! ( TrInput & IN_RIGHT ) )
item - > goalAnimState = LS_STOP ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
}
2020-09-26 03:28:30 +10:00
2021-10-08 20:08:55 +11:00
// LEGACY
2021-02-03 01:50:59 -03:00
void lara_col_fastturn ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 20*/
/*state code: lara_as_fastturn*/
lara_col_stop ( item , coll ) ;
2020-09-26 03:28:30 +10:00
}
2021-10-08 20:08:55 +11:00
// State: LS_TURN_LEFT_FAST (152)
// Collision: lara_col_turn_left_fast()
void lara_as_turn_left_fast ( ITEM_INFO * item , COLL_INFO * coll )
{
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_DEATH ;
return ;
}
if ( TrInput & IN_JUMP )
{
item - > goalAnimState = LS_JUMP_PREPARE ;
return ;
}
if ( TrInput & IN_ROLL & &
Lara . waterStatus ! = LW_WADE )
{
item - > goalAnimState = LS_ROLL_FORWARD ;
return ;
}
2021-10-11 00:05:49 +11:00
if ( ( TrInput & IN_DUCK | | TestLaraStandUp ( coll ) ) & &
2021-10-08 20:08:55 +11:00
( Lara . gunStatus = = LG_NO_ARMS | | ! IsStandingWeapon ( Lara . gunType ) ) & &
Lara . waterStatus ! = LW_WADE )
{
item - > goalAnimState = LS_CROUCH_IDLE ;
return ;
}
if ( TrInput & IN_FORWARD & &
coll - > CollisionType ! = CT_FRONT )
{
if ( Lara . waterStatus = = LW_WADE )
item - > goalAnimState = LS_WADE_FORWARD ;
else if ( TrInput & IN_WALK )
item - > goalAnimState = LS_WALK_FORWARD ;
2021-10-13 19:50:46 +11:00
else if ( TrInput & IN_SPRINT )
item - > goalAnimState = LS_SPRINT ;
2021-10-08 20:08:55 +11:00
else [[likely]]
item - > goalAnimState = LS_RUN_FORWARD ;
return ;
}
if ( TrInput & IN_BACK )
{
if ( Lara . waterStatus = = LW_WADE )
item - > goalAnimState = LS_WALK_BACK ;
else if ( TrInput & IN_WALK )
item - > goalAnimState = LS_WALK_BACK ;
else [[likely]]
item - > goalAnimState = LS_HOP_BACK ;
return ;
}
if ( TrInput & IN_LSTEP & &
TestLaraStepLeft ( item ) )
{
item - > goalAnimState = LS_STEP_LEFT ;
return ;
}
else if ( TrInput & IN_RSTEP & &
TestLaraStepRight ( item ) )
{
item - > goalAnimState = LS_STEP_RIGHT ;
return ;
}
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
Lara . turnRate = clamp ( Lara . turnRate , ( short ) - LARA_FAST_TURN , ( short ) - LARA_MED_TURN ) ; // TODO: When rotations become floats, remove casts. @Sezz 2021.10.08
item - > goalAnimState = LS_TURN_LEFT_FAST ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
// State: LS_TURN_LEFT_FAST (152)
// Control: lara_as_turn_left_fast()
void lara_col_turn_left_fast ( ITEM_INFO * item , COLL_INFO * coll )
{
lara_col_stop ( item , coll ) ;
}
2021-10-14 17:19:38 +11:00
// State: LS_SIDESTEP_RIGHT (21)
// Collision: lara_col_stepright()
2021-02-03 01:50:59 -03:00
void lara_as_stepright ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-14 17:19:38 +11:00
{
Lara . look = false ;
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
// TODO: Check
/*if (Lara.isMoving)
return ; */
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
}
if ( TrInput & IN_RSTEP )
{
item - > goalAnimState = LS_STEP_RIGHT ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
// LEGACY
void old_lara_as_stepright ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
/*state 21*/
/*collision: lara_col_stepright*/
2020-09-26 03:28:30 +10:00
Lara . look = false ;
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
2020-09-26 05:06:08 +10:00
if ( ! Lara . isMoving )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
if ( ! ( TrInput & IN_RSTEP ) )
{
item - > goalAnimState = LS_STOP ;
}
2020-09-26 03:28:30 +10:00
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_LEFT )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate - = LARA_TURN_RATE ;
2021-10-02 15:44:34 +03:00
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_RIGHT )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate + = LARA_TURN_RATE ;
2021-10-02 15:44:34 +03:00
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
2020-08-14 17:54:25 -05:00
}
}
}
2021-10-10 14:03:38 +11:00
// State: LS_STEP_RIGHT (21)
// Control: lara_as_stepright()
2021-02-03 01:50:59 -03:00
void lara_col_stepright ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-10 14:03:38 +11:00
{
Lara . moveAngle = item - > pos . yRot + ANGLE ( 90 ) ;
coll - > Setup . BadHeightDown = ( Lara . waterStatus = = LW_WADE ) ? NO_BAD_POS : STEP_SIZE / 2 ;
coll - > Setup . BadHeightUp = - STEP_SIZE / 2 ;
coll - > Setup . BadCeilingHeight = 0 ;
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
coll - > Setup . SlopesArePits = true ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
GetCollisionInfo ( coll , item ) ;
if ( TestLaraHitCeiling ( coll ) )
{
SetLaraHitCeiling ( item , coll ) ;
return ;
}
if ( LaraDeflectEdge ( item , coll ) )
LaraCollideStop ( item , coll ) ;
if ( TestLaraFall ( coll ) )
{
SetLaraFallState ( item ) ;
return ;
}
2021-10-14 17:19:38 +11:00
if ( TestLaraSlideNew ( coll ) )
2021-10-10 14:03:38 +11:00
{
SetLaraSlideState ( item , coll ) ;
return ;
}
if ( TestLaraStep ( coll ) )
{
DoLaraStep ( item , coll ) ;
return ;
}
// LEGACY step
/*if (coll->Middle.Floor != NO_HEIGHT)
item - > pos . yPos + = coll - > Middle . Floor ; */
}
// LEGACY
void old_lara_col_stepright ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 21*/
/*state code: lara_as_stepright*/
if ( item - > currentAnimState = = LS_STEP_RIGHT )
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 90 ) ;
2020-09-26 05:06:08 +10:00
else
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot - ANGLE ( 90 ) ;
2020-08-14 17:54:25 -05:00
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
if ( Lara . waterStatus = = LW_WADE )
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
2020-08-14 17:54:25 -05:00
else
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = 128 ;
2020-08-14 17:54:25 -05:00
2021-09-10 00:20:59 +03:00
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . SlopesArePits = true ;
2020-09-26 05:06:08 +10:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightUp = - 128 ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( ! LaraHitCeiling ( item , coll ) )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
if ( LaraDeflectEdge ( item , coll ) )
LaraCollideStop ( item , coll ) ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:18:47 +03:00
if ( ! LaraFallen ( item , coll ) & & ! TestLaraSlide ( item , coll ) & & coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}
2021-10-14 17:19:38 +11:00
// State: LS_SIDESTEP_LEFT (22)
// Collision: lara_col_stepleft()
2021-02-03 01:50:59 -03:00
void lara_as_stepleft ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-14 17:19:38 +11:00
{
Lara . look = false ;
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
// TODO: Check
/*if (Lara.isMoving)
return ; */
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
}
if ( TrInput & IN_LSTEP )
{
item - > goalAnimState = LS_STEP_LEFT ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
// LEGACY
void old_lara_as_stepleft ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 22*/
/*collision: lara_col_stepleft*/
2020-08-14 17:54:25 -05:00
Lara . look = false ;
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
2020-09-26 05:06:08 +10:00
if ( ! Lara . isMoving )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
if ( ! ( TrInput & IN_LSTEP ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_STOP ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 03:28:30 +10:00
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_LEFT )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
2020-09-26 03:28:30 +10:00
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_RIGHT )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
2020-09-26 03:28:30 +10:00
}
}
2020-09-26 05:06:08 +10:00
}
2020-09-26 03:28:30 +10:00
2021-10-10 14:03:38 +11:00
// State: LS_STEP_LEFT (22)
// Control: lara_as_stepleft()
2021-02-03 01:50:59 -03:00
void lara_col_stepleft ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-10 14:03:38 +11:00
{
Lara . moveAngle = item - > pos . yRot - ANGLE ( 90 ) ;
coll - > Setup . BadHeightDown = ( Lara . waterStatus = = LW_WADE ) ? NO_BAD_POS : STEP_SIZE / 2 ;
coll - > Setup . BadHeightUp = - STEP_SIZE / 2 ;
coll - > Setup . BadCeilingHeight = 0 ;
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
coll - > Setup . SlopesArePits = true ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
GetCollisionInfo ( coll , item ) ;
if ( TestLaraHitCeiling ( coll ) )
{
SetLaraHitCeiling ( item , coll ) ;
return ;
}
if ( LaraDeflectEdge ( item , coll ) )
LaraCollideStop ( item , coll ) ;
if ( TestLaraFall ( coll ) )
{
SetLaraFallState ( item ) ;
return ;
}
2021-10-14 17:19:38 +11:00
if ( TestLaraSlideNew ( coll ) )
2021-10-10 14:03:38 +11:00
{
SetLaraSlideState ( item , coll ) ;
return ;
}
if ( TestLaraStep ( coll ) )
{
DoLaraStep ( item , coll ) ;
return ;
}
// LEGACY step
/*if (coll->Middle.Floor != NO_HEIGHT)
item - > pos . yPos + = coll - > Middle . Floor ; */
}
// LEGACY
void old_lara_col_stepleft ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 05:06:08 +10:00
{
/*state 22*/
/*state code: lara_as_stepleft*/
lara_col_stepright ( item , coll ) ;
2020-08-14 17:54:25 -05:00
}
2021-10-14 19:58:29 +11:00
// State: LS_ROLL_FORWARD (23)
// Control: lara_void_func()
2021-02-03 01:50:59 -03:00
void lara_col_roll2 ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-14 19:58:29 +11:00
{
Camera . laraNode = 0 ;
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
GetCollisionInfo ( coll , item ) ;
if ( TestLaraHitCeiling ( coll ) )
{
SetLaraHitCeiling ( item , coll ) ;
return ;
}
if ( TestLaraSlideNew ( coll ) )
{
SetLaraSlideState ( item , coll ) ;
return ;
}
if ( coll - > Middle . Floor > STEPUP_HEIGHT / 2 ) // Was 200.
{
SetLaraFallBackState ( item ) ;
return ;
}
ShiftItem ( item , coll ) ;
if ( TestLaraStep ( coll ) )
{
DoLaraStep ( item , coll ) ;
return ;
}
// LEGACY step
/*if (coll->Middle.Floor != NO_HEIGHT)
item - > pos . yPos + = coll - > Middle . Floor ; */
}
// LEGACY
void old_lara_col_roll2 ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 23*/
/*state code: lara_void_func*/
2020-08-14 17:54:25 -05:00
Camera . laraNode = 0 ;
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
2020-08-14 17:54:25 -05:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesAreWalls = true ;
2020-09-26 03:28:30 +10:00
2020-09-26 05:06:08 +10:00
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
if ( LaraHitCeiling ( item , coll ) )
return ;
2020-09-26 05:06:08 +10:00
if ( TestLaraSlide ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > 200 )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > animNumber = LA_FALL_BACK ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > currentAnimState = LS_FALL_BACK ;
2020-08-14 17:54:25 -05:00
item - > goalAnimState = LS_FALL_BACK ;
item - > fallspeed = 0 ;
item - > gravityStatus = true ;
return ;
}
ShiftItem ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_as_backjump ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 25*/
/*collision: lara_col_backjump*/
2020-08-14 17:54:25 -05:00
Camera . targetAngle = ANGLE ( 135.0f ) ;
2020-09-26 05:06:08 +10:00
if ( item - > fallspeed < = LARA_FREEFALL_SPEED )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( item - > goalAnimState = = LS_RUN_FORWARD )
{
item - > goalAnimState = LS_STOP ;
}
else if ( ( TrInput & IN_FORWARD | | TrInput & IN_ROLL ) & & item - > goalAnimState ! = LS_STOP )
{
item - > goalAnimState = LS_JUMP_ROLL_180 ;
}
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_FREEFALL ;
2020-08-14 17:54:25 -05:00
}
}
2021-02-03 01:50:59 -03:00
void lara_col_backjump ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 25*/
/*state code: lara_as_backjump*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
2020-09-26 05:06:08 +10:00
lara_col_jumper ( item , coll ) ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_as_rightjump ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 26*/
/*collision: lara_col_rightjump*/
2020-08-14 17:54:25 -05:00
Lara . look = false ;
if ( item - > fallspeed > LARA_FREEFALL_SPEED )
item - > goalAnimState = LS_FREEFALL ;
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_LEFT & & item - > goalAnimState ! = LS_STOP )
2020-08-14 17:54:25 -05:00
item - > goalAnimState = LS_JUMP_ROLL_180 ;
}
2021-02-03 01:50:59 -03:00
void lara_col_rightjump ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 26*/
/*state code: lara_as_rightjump*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 90 ) ;
2020-09-26 05:06:08 +10:00
lara_col_jumper ( item , coll ) ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_as_leftjump ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 27*/
/*collision: lara_col_leftjump*/
2020-08-14 17:54:25 -05:00
Lara . look = false ;
if ( item - > fallspeed > LARA_FREEFALL_SPEED )
item - > goalAnimState = LS_FREEFALL ;
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_RIGHT & & item - > goalAnimState ! = LS_STOP )
2020-08-14 17:54:25 -05:00
item - > goalAnimState = LS_JUMP_ROLL_180 ;
}
2021-02-03 01:50:59 -03:00
void lara_col_leftjump ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 27*/
/*state code: lara_as_leftjump*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot - ANGLE ( 90 ) ;
2020-09-26 05:06:08 +10:00
lara_col_jumper ( item , coll ) ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
void lara_col_jumper ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*states 25, 26, 27*/
/*state code: none, but is called in lara_col_backjump, lara_col_rightjump and lara_col_leftjump*/
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = BAD_JUMP_CEILING ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2020-08-14 17:54:25 -05:00
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
LaraDeflectEdgeJump ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( item - > fallspeed > 0 & & coll - > Middle . Floor < = 0 )
2020-08-14 17:54:25 -05:00
{
if ( LaraLandedBad ( item , coll ) )
item - > goalAnimState = LS_DEATH ;
else
item - > goalAnimState = LS_STOP ;
item - > fallspeed = 0 ;
item - > gravityStatus = 0 ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}
2021-02-03 01:50:59 -03:00
void lara_as_upjump ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 28*/
/*collision: lara_col_upjump*/
2020-09-26 03:28:30 +10:00
if ( item - > fallspeed > LARA_FREEFALL_SPEED )
2020-08-14 17:54:25 -05:00
{
2020-09-26 03:28:30 +10:00
item - > goalAnimState = LS_FREEFALL ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 03:28:30 +10:00
}
2021-02-03 01:50:59 -03:00
void lara_col_upjump ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
/*state 28*/
/*state code: lara_as_upjump*/
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-19 06:42:24 +03:00
coll - > Setup . Height = LARA_HEIGHT_STRETCH ;
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = BAD_JUMP_CEILING ;
coll - > Setup . ForwardAngle = item - > speed < 0 ? Lara . moveAngle + ANGLE ( 180.0f ) : Lara . moveAngle ;
2020-08-14 17:54:25 -05:00
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
2021-09-10 00:18:47 +03:00
if ( TrInput & IN_ACTION & & Lara . gunStatus = = LG_NO_ARMS & & ! coll - > HitStatic )
2020-08-14 17:54:25 -05:00
{
2021-09-10 00:18:47 +03:00
if ( Lara . canMonkeySwing & & coll - > CollisionType = = CT_TOP )
2020-08-14 17:54:25 -05:00
{
item - > goalAnimState = LS_MONKEYSWING_IDLE ;
2020-09-26 05:06:08 +10:00
item - > currentAnimState = LS_MONKEYSWING_IDLE ;
item - > animNumber = LA_JUMP_UP_TO_MONKEYSWING ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
2020-08-14 17:54:25 -05:00
item - > gravityStatus = false ;
item - > speed = 0 ;
item - > fallspeed = 0 ;
2020-09-26 05:06:08 +10:00
Lara . gunStatus = LG_HANDS_BUSY ;
2020-08-14 17:54:25 -05:00
MonkeySwingSnap ( item , coll ) ;
return ;
}
2021-09-10 00:18:47 +03:00
if ( coll - > CollisionType = = CT_FRONT & & coll - > Middle . Ceiling < = - STEPUP_HEIGHT )
2020-08-14 17:54:25 -05:00
{
int edge ;
2021-09-14 00:30:44 +03:00
int edgeCatch = TestLaraEdgeCatch ( item , coll , & edge ) ;
2020-08-14 17:54:25 -05:00
if ( edgeCatch )
{
2021-09-14 00:30:44 +03:00
if ( edgeCatch > = 0 | | TestLaraHangOnClimbWall ( item , coll ) )
2020-08-14 17:54:25 -05:00
{
short angle = item - > pos . yRot ;
2021-09-13 20:19:33 +02:00
bool result = SnapToQuadrant ( angle , 35 ) ;
2020-08-14 17:54:25 -05:00
if ( result )
{
BOUNDING_BOX * bounds ;
if ( TestHangSwingIn ( item , angle ) )
{
item - > animNumber = LA_JUMP_UP_TO_MONKEYSWING ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase ;
item - > goalAnimState = LS_MONKEYSWING_IDLE ;
item - > currentAnimState = LS_MONKEYSWING_IDLE ;
}
else
{
2021-07-09 19:41:56 -05:00
if ( TestHangFeet ( item , angle ) )
2020-08-14 17:54:25 -05:00
{
item - > animNumber = LA_REACH_TO_HANG ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase + 12 ;
item - > currentAnimState = LS_HANG ;
item - > goalAnimState = LS_HANG_FEET ;
}
2021-07-09 19:41:56 -05:00
else
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > animNumber = LA_REACH_TO_HANG ;
item - > frameNumber = g_Level . Anims [ item - > animNumber ] . frameBase + 12 ;
item - > currentAnimState = LS_HANG ;
2020-08-14 17:54:25 -05:00
item - > goalAnimState = LS_HANG ;
}
}
bounds = GetBoundsAccurate ( item ) ;
if ( edgeCatch < = 0 )
item - > pos . yPos = edge - bounds - > Y1 + 4 ;
else
2021-09-10 00:18:47 +03:00
item - > pos . yPos + = coll - > Front . Floor - bounds - > Y1 ;
2020-08-14 17:54:25 -05:00
2021-09-13 20:19:33 +02:00
Vector2 v = GetOrthogonalIntersect ( item - > pos . xPos , item - > pos . zPos , LARA_RAD , item - > pos . yRot ) ;
item - > pos . xPos = v . x ;
item - > pos . zPos = v . y ;
2020-08-14 17:54:25 -05:00
item - > pos . yRot = angle ;
item - > gravityStatus = false ;
item - > speed = 0 ;
item - > fallspeed = 0 ;
Lara . gunStatus = LG_HANDS_BUSY ;
Lara . torsoYrot = 0 ;
Lara . torsoXrot = 0 ;
return ;
}
}
}
}
}
ShiftItem ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( coll - > CollisionType = = CT_CLAMP | |
coll - > CollisionType = = CT_TOP | |
coll - > CollisionType = = CT_TOP_FRONT )
2020-08-14 17:54:25 -05:00
item - > fallspeed = 1 ;
2021-09-10 00:18:47 +03:00
if ( coll - > CollisionType = = CT_NONE )
2020-08-14 17:54:25 -05:00
{
if ( item - > fallspeed < - 70 )
{
if ( TrInput & IN_FORWARD & & item - > speed < 5 )
{
item - > speed + + ;
}
else if ( TrInput & IN_BACK & & item - > speed > - 5 )
{
item - > speed - = 2 ;
}
}
}
else
{
item - > speed = item - > speed < = 0 ? - 2 : 2 ;
}
2021-09-10 00:18:47 +03:00
if ( item - > fallspeed > 0 & & coll - > Middle . Floor < = 0 )
2020-08-14 17:54:25 -05:00
{
item - > goalAnimState = LaraLandedBad ( item , coll ) ? LS_DEATH : LS_STOP ;
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}
2021-02-03 01:50:59 -03:00
void lara_as_fallback ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 29*/
/*collision: lara_col_fallback*/
2020-08-14 17:54:25 -05:00
if ( item - > fallspeed > LARA_FREEFALL_SPEED )
item - > goalAnimState = LS_FREEFALL ;
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_ACTION )
if ( Lara . gunStatus = = LG_NO_ARMS )
item - > goalAnimState = LS_REACH ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_col_fallback ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 29*/
/*state code: lara_as_fallback*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
2020-08-14 17:54:25 -05:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = BAD_JUMP_CEILING ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
LaraDeflectEdgeJump ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( item - > fallspeed > 0 & & coll - > Middle . Floor < = 0 )
2020-08-14 17:54:25 -05:00
{
if ( LaraLandedBad ( item , coll ) )
item - > goalAnimState = LS_DEATH ;
else
item - > goalAnimState = LS_STOP ;
item - > fallspeed = 0 ;
item - > gravityStatus = 0 ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}
2021-02-03 01:50:59 -03:00
void lara_col_roll ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 45*/
/*state code: lara_void_func*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesArePits = false ;
coll - > Setup . SlopesAreWalls = true ;
2020-09-26 03:28:30 +10:00
2020-09-26 05:06:08 +10:00
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
if ( LaraHitCeiling ( item , coll ) )
return ;
2020-09-26 05:06:08 +10:00
if ( TestLaraSlide ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
2020-09-26 05:06:08 +10:00
if ( LaraFallen ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
2021-07-09 19:41:56 -05:00
//##LUA debug etc.
Lara . NewAnims . SwandiveRollRun = 1 ;
if ( TrInput & IN_FORWARD & & item - > animNumber = = LA_SWANDIVE_ROLL & & Lara . NewAnims . SwandiveRollRun )
2020-08-14 17:54:25 -05:00
{
item - > goalAnimState = LS_RUN_FORWARD ;
}
ShiftItem ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_as_swandive ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 52*/
/*collision: lara_col_swandive*/
2021-09-10 00:20:59 +03:00
coll - > Setup . EnableObjectPush = true ;
coll - > Setup . EnableSpaz = false ;
2020-09-26 05:06:08 +10:00
if ( item - > fallspeed > LARA_FREEFALL_SPEED & & item - > goalAnimState ! = LS_DIVE )
2020-08-14 17:54:25 -05:00
item - > goalAnimState = LS_SWANDIVE_END ;
}
2021-02-03 01:50:59 -03:00
void lara_col_swandive ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 52*/
/*state code: lara_as_swandive*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = BAD_JUMP_CEILING ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
LaraDeflectEdgeJump ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor < = 0 & & item - > fallspeed > 0 )
2020-08-14 17:54:25 -05:00
{
item - > goalAnimState = LS_STOP ;
item - > fallspeed = 0 ;
item - > gravityStatus = 0 ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}
2021-02-03 01:50:59 -03:00
void lara_as_fastdive ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 53*/
/*collision: lara_col_fastdive*/
if ( TrInput & IN_ROLL & & item - > goalAnimState = = LS_SWANDIVE_END )
item - > goalAnimState = LS_JUMP_ROLL_180 ;
2021-09-10 00:20:59 +03:00
coll - > Setup . EnableObjectPush = true ;
coll - > Setup . EnableSpaz = false ;
2020-09-26 05:06:08 +10:00
item - > speed = ( item - > speed * 95 ) / 100 ;
2020-08-14 17:54:25 -05:00
}
2021-02-03 01:50:59 -03:00
void lara_col_fastdive ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 53*/
/*state code: lara_as_fastdive*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = BAD_JUMP_CEILING ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
LaraDeflectEdgeJump ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor < = 0 & & item - > fallspeed > 0 )
2020-08-14 17:54:25 -05:00
{
if ( item - > fallspeed < = 133 )
item - > goalAnimState = LS_STOP ;
else
item - > goalAnimState = LS_DEATH ;
item - > fallspeed = 0 ;
item - > gravityStatus = 0 ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}
2021-02-03 01:50:59 -03:00
void lara_as_gymnast ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 05:06:08 +10:00
{
/*state 54*/
/*collision: lara_default_col*/
2021-09-10 00:20:59 +03:00
coll - > Setup . EnableObjectPush = false ;
coll - > Setup . EnableSpaz = false ;
2020-09-26 05:06:08 +10:00
}
2021-10-14 17:40:22 +11:00
// State: LS_WADE_FORWARD (65)
// Collision: lara_col_wade()
2021-02-03 01:50:59 -03:00
void lara_as_wade ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-14 17:40:22 +11:00
{
Camera . targetElevation = - ANGLE ( 22.0f ) ;
if ( item - > hitPoints < = 0 )
{
item - > goalAnimState = LS_STOP ;
return ;
}
if ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP )
{
LaraWadeSwamp ( item , coll ) ;
return ;
}
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_FAST_TURN )
Lara . turnRate = - LARA_FAST_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX ) / 16 ;
else
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX * 3 / 5 ) / 16 ;
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_FAST_TURN )
Lara . turnRate = LARA_FAST_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot + = ( LARA_LEAN_MAX - item - > pos . zRot ) / 16 ;
else
item - > pos . zRot + = ( LARA_LEAN_MAX * 3 / 6 - item - > pos . zRot ) / 16 ;
}
if ( TrInput & IN_FORWARD )
{
if ( Lara . waterStatus = = LW_ABOVE_WATER )
item - > goalAnimState = LS_RUN_FORWARD ;
else [[likely]]
item - > goalAnimState = LS_WADE_FORWARD ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
// Pseudo-state for wading in a swamp.
void LaraWadeSwamp ( ITEM_INFO * item , COLL_INFO * coll )
{
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX / 2 ) / 24 ;
else
item - > pos . zRot - = ( item - > pos . zRot + ( LARA_LEAN_MAX / 2 ) * 3 / 5 ) / 24 ;
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot + = ( LARA_LEAN_MAX / 2 - item - > pos . zRot ) / 24 ;
else
item - > pos . zRot + = ( ( LARA_LEAN_MAX / 2 ) * 3 / 5 - item - > pos . zRot ) / 24 ;
}
if ( TrInput & IN_FORWARD )
{
item - > goalAnimState = LS_WADE_FORWARD ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
// LEGACY
void old_lara_as_wade ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 65*/
/*collision: lara_col_wade*/
2020-08-14 17:54:25 -05:00
if ( item - > hitPoints < = 0 )
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_STOP ;
2020-08-14 17:54:25 -05:00
return ;
}
2020-09-26 05:06:08 +10:00
Camera . targetElevation = - ANGLE ( 22.0f ) ;
2020-09-26 03:28:30 +10:00
2020-09-26 05:06:08 +10:00
if ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_LEFT )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate - = LARA_TURN_RATE ;
2021-09-26 13:39:34 +10:00
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
2020-09-26 05:06:08 +10:00
2021-10-13 19:50:46 +11:00
// TODO: Some other state makes her lean?
2020-09-26 05:06:08 +10:00
if ( TestLaraLean ( item , coll ) )
2021-10-13 19:50:46 +11:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX / 2 ) / 16 ;
2021-09-26 13:39:34 +10:00
else
2021-10-13 19:50:46 +11:00
item - > pos . zRot - = ( item - > pos . zRot + ( LARA_LEAN_MAX / 2 ) * 3 / 5 ) / 16 ;
2021-09-26 13:39:34 +10:00
// OLD sample
/*if (TestLaraLean(item, coll))
2020-09-26 05:06:08 +10:00
{
item - > pos . zRot - = LARA_LEAN_RATE ;
2021-09-26 13:39:34 +10:00
if ( item - > pos . zRot < - ( LARA_LEAN_MAX / 2 ) )
item - > pos . zRot = - ( LARA_LEAN_MAX / 2 ) ;
2021-07-09 19:41:56 -05:00
}
else
{
item - > pos . zRot - = LARA_LEAN_RATE ;
if ( item - > pos . zRot < - LARA_LEAN_MAX * 3 / 5 )
item - > pos . zRot = - LARA_LEAN_MAX * 3 / 5 ;
2021-09-26 13:39:34 +10:00
} */
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
else if ( TrInput & IN_RIGHT )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
Lara . turnRate + = LARA_TURN_RATE ;
2021-09-26 13:39:34 +10:00
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
2020-09-26 05:06:08 +10:00
if ( TestLaraLean ( item , coll ) )
2021-10-13 19:50:46 +11:00
item - > pos . zRot + = ( LARA_LEAN_MAX / 2 - item - > pos . zRot ) / 16 ;
2021-09-26 13:39:34 +10:00
2021-07-09 19:41:56 -05:00
else
2021-10-13 19:50:46 +11:00
item - > pos . zRot + = ( ( LARA_LEAN_MAX / 2 ) * 3 / 5 - item - > pos . zRot ) / 16 ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_FORWARD )
item - > goalAnimState = LS_WADE_FORWARD ;
else
item - > goalAnimState = LS_STOP ;
2020-09-26 03:28:30 +10:00
}
2020-09-26 05:06:08 +10:00
else
2020-09-26 03:28:30 +10:00
{
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_FAST_TURN )
Lara . turnRate = - LARA_FAST_TURN ;
2020-09-26 03:28:30 +10:00
2020-09-26 05:06:08 +10:00
if ( TestLaraLean ( item , coll ) )
2021-09-26 13:39:34 +10:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX ) / 7 ;
2021-07-09 19:41:56 -05:00
else
2021-09-26 13:39:34 +10:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX * 3 / 5 ) / 7 ;
2020-09-26 05:06:08 +10:00
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_FAST_TURN )
Lara . turnRate = LARA_FAST_TURN ;
2020-09-26 03:28:30 +10:00
2020-09-26 05:06:08 +10:00
if ( TestLaraLean ( item , coll ) )
2021-09-26 13:39:34 +10:00
item - > pos . zRot + = ( LARA_LEAN_MAX - item - > pos . zRot ) / 7 ;
else
item - > pos . zRot + = ( LARA_LEAN_MAX * 3 / 6 - item - > pos . zRot ) / 7 ;
// OLD sample
/*if (TestLaraLean(item, coll))
2020-09-26 05:06:08 +10:00
{
item - > pos . zRot + = LARA_LEAN_RATE ;
if ( item - > pos . zRot > LARA_LEAN_MAX )
item - > pos . zRot = LARA_LEAN_MAX ;
}
2021-07-09 19:41:56 -05:00
else
{
item - > pos . zRot + = LARA_LEAN_RATE ;
if ( item - > pos . zRot > LARA_LEAN_MAX * 3 / 5 )
item - > pos . zRot = LARA_LEAN_MAX * 3 / 5 ;
2021-09-26 13:39:34 +10:00
} */
2020-09-26 05:06:08 +10:00
}
2020-09-26 03:28:30 +10:00
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_FORWARD )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( Lara . waterStatus = = LW_ABOVE_WATER )
item - > goalAnimState = LS_RUN_FORWARD ;
else
item - > goalAnimState = LS_WADE_FORWARD ;
2020-08-14 17:54:25 -05:00
}
else
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_STOP ;
2020-08-14 17:54:25 -05:00
}
}
}
2020-09-26 05:06:08 +10:00
void lara_col_wade ( ITEM_INFO * item , COLL_INFO * coll )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
/*state 65*/
/*state code: lara_as_wade*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . SlopesAreWalls = true ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( LaraHitCeiling ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
2020-09-26 05:06:08 +10:00
if ( TestLaraVault ( item , coll ) )
2020-08-14 17:54:25 -05:00
return ;
if ( LaraDeflectEdge ( item , coll ) )
{
item - > pos . zRot = 0 ;
2020-09-26 05:06:08 +10:00
2021-09-17 22:55:09 +03:00
if ( ! coll - > Front . Slope & & coll - > Front . Floor < - ( ( STEP_SIZE * 5 ) / 2 ) & & ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) )
2020-08-14 17:54:25 -05:00
{
item - > goalAnimState = LS_SPLAT ;
if ( GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) )
return ;
}
LaraCollideStop ( item , coll ) ;
}
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > = - STEPUP_HEIGHT & & coll - > Middle . Floor < - STEP_SIZE / 2 & & ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) )
2020-09-26 05:06:08 +10:00
{
item - > goalAnimState = LS_STEP_UP ;
GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) ;
2020-08-14 17:54:25 -05:00
}
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > = 50 & & ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > pos . yPos + = 50 ;
return ;
}
2020-08-14 17:54:25 -05:00
2021-09-10 00:18:47 +03:00
if ( ! ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP ) | | coll - > Middle . Floor < 0 )
item - > pos . yPos + = coll - > Middle . Floor ; // Enforce to floor height.. if not a swamp room.
else if ( g_Level . Rooms [ item - > roomNumber ] . flags & ENV_FLAG_SWAMP & & coll - > Middle . Floor )
2020-09-26 05:06:08 +10:00
item - > pos . yPos + = SWAMP_GRAVITY ;
}
2020-09-26 03:28:30 +10:00
2021-09-29 18:35:21 +10:00
// State: LS_SPRINT (73)
// Collision: lara_col_dash()
2021-02-03 01:50:59 -03:00
void lara_as_dash ( ITEM_INFO * item , COLL_INFO * coll )
2021-09-29 18:35:21 +10:00
{
DashTimer - - ; // TODO: Move global to LaraItem? health.cpp needs deglobalisation in general. @Sezz 2021.09.29
if ( item - > hitPoints < = 0 )
{
2021-10-13 19:50:46 +11:00
item - > goalAnimState = LS_DEATH ;
2021-09-29 18:35:21 +10:00
return ;
}
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
if ( TestLaraLean ( item , coll ) )
2021-10-09 23:53:39 +11:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX ) / 12 ;
2021-09-29 18:35:21 +10:00
else
2021-10-09 23:53:39 +11:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX * 3 / 6 ) / 12 ;
2021-09-29 18:35:21 +10:00
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
if ( TestLaraLean ( item , coll ) )
2021-10-09 23:53:39 +11:00
item - > pos . zRot + = ( LARA_LEAN_MAX - item - > pos . zRot ) / 12 ;
2021-09-29 18:35:21 +10:00
else
2021-10-09 23:53:39 +11:00
item - > pos . zRot + = ( LARA_LEAN_MAX - item - > pos . zRot * 3 / 6 ) / 12 ;
2021-09-29 18:35:21 +10:00
}
if ( TrInput & IN_JUMP )
{
item - > goalAnimState = LS_SPRINT_ROLL ;
return ;
}
2021-10-11 00:05:49 +11:00
if ( ( TrInput & IN_DUCK | | TestLaraStandUp ( coll ) ) & &
( Lara . gunStatus = = LG_NO_ARMS | | ! IsStandingWeapon ( Lara . gunType ) ) )
2021-09-29 18:35:21 +10:00
{
item - > goalAnimState = LS_CROUCH_IDLE ;
2021-10-13 19:50:46 +11:00
2021-09-29 18:35:21 +10:00
return ;
}
// TODO: Supposedly there is a bug wherein sprinting into the boundary between shallow and deep water
// under some condition allows Lara to run around in the water room. Investigate. @Sezz 2021.09.29
if ( TrInput & IN_FORWARD )
{
if ( Lara . waterStatus = = LW_WADE )
item - > goalAnimState = LS_RUN_FORWARD ; // TODO: Dispatch to wade forward state. @Sezz 2021.09.29
else if ( TrInput & IN_WALK )
item - > goalAnimState = LS_WALK_FORWARD ;
else if ( TrInput & IN_SPRINT & & DashTimer > 0 ) [[likely]]
item - > goalAnimState = LS_SPRINT ;
else
item - > goalAnimState = LS_RUN_FORWARD ;
return ;
}
item - > goalAnimState = LS_STOP ;
}
// LEGACY
void old_lara_as_dash ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 05:06:08 +10:00
{
/*state 73*/
/*collision: lara_col_dash*/
if ( item - > hitPoints < = 0 | | ! DashTimer | | ! ( TrInput & IN_SPRINT ) | | Lara . waterStatus = = LW_WADE )
{
item - > goalAnimState = LS_RUN_FORWARD ;
return ;
2020-09-26 03:28:30 +10:00
}
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
DashTimer - - ;
if ( TrInput & IN_DUCK
& & ( Lara . gunStatus = = LG_NO_ARMS
| | Lara . gunType = = WEAPON_NONE
| | Lara . gunType = = WEAPON_PISTOLS
| | Lara . gunType = = WEAPON_REVOLVER
| | Lara . gunType = = WEAPON_UZI
| | Lara . gunType = = WEAPON_FLARE ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_CROUCH_IDLE ;
2020-08-14 17:54:25 -05:00
return ;
}
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
2021-09-26 12:23:58 +10:00
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
2020-09-26 05:06:08 +10:00
2021-09-26 12:23:58 +10:00
if ( TestLaraLean ( item , coll ) )
2021-10-09 23:53:39 +11:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX ) / 7 ;
2021-09-26 12:23:58 +10:00
else
2021-10-09 23:53:39 +11:00
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX * 3 / 6 ) / 7 ;
2020-08-14 17:54:25 -05:00
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
2021-09-26 12:23:58 +10:00
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
2020-08-14 17:54:25 -05:00
2021-09-26 12:23:58 +10:00
if ( TestLaraLean ( item , coll ) )
2021-10-09 23:53:39 +11:00
item - > pos . zRot + = ( LARA_LEAN_MAX - item - > pos . zRot ) / 7 ;
2021-09-26 12:23:58 +10:00
else
2021-10-09 23:53:39 +11:00
item - > pos . zRot + = ( LARA_LEAN_MAX * 3 / 6 - item - > pos . zRot ) / 7 ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
if ( ! ( TrInput & IN_JUMP ) | | item - > gravityStatus )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( TrInput & IN_FORWARD )
{
if ( TrInput & IN_WALK )
item - > goalAnimState = LS_WALK_FORWARD ;
else
item - > goalAnimState = LS_SPRINT ;
}
else if ( ! ( TrInput & IN_LEFT ) & & ! ( TrInput & IN_RIGHT ) )
{
item - > goalAnimState = LS_STOP ;
}
2020-08-14 17:54:25 -05:00
}
else
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_SPRINT_ROLL ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
}
2021-10-09 23:53:39 +11:00
// State: LS_SPRINT (73)
// Control: lara_as_dash()
2021-02-03 01:50:59 -03:00
void lara_col_dash ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-09 23:53:39 +11:00
{
Lara . moveAngle = item - > pos . yRot ;
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
coll - > Setup . BadCeilingHeight = 0 ;
coll - > Setup . SlopesAreWalls = true ;
coll - > Setup . ForwardAngle = Lara . moveAngle ;
GetCollisionInfo ( coll , item ) ;
if ( TestLaraHitCeiling ( coll ) )
{
SetLaraHitCeiling ( item , coll ) ;
return ;
}
if ( TestLaraVault ( item , coll ) )
return ;
if ( LaraDeflectEdge ( item , coll ) )
{
item - > pos . zRot = 0 ;
2021-10-11 16:12:04 +11:00
if ( coll - > HitTallObject | | TestLaraWall ( item , 256 , 0 , - 640 ) )
2021-10-09 23:53:39 +11:00
{
item - > goalAnimState = LS_SPLAT ;
if ( GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) )
{
item - > currentAnimState = LS_SPLAT ;
return ;
}
}
LaraCollideStop ( item , coll ) ;
}
if ( TestLaraFall ( coll ) )
{
SetLaraFallState ( item ) ;
return ;
}
2021-10-14 17:40:22 +11:00
if ( TestLaraSlideNew ( coll ) )
2021-10-09 23:53:39 +11:00
{
SetLaraSlideState ( item , coll ) ;
return ;
}
if ( TestLaraStep ( coll ) )
{
DoLaraStep ( item , coll ) ;
return ;
}
// LEGACY step
//if (coll->Middle.Floor >= -STEPUP_HEIGHT && coll->Middle.Floor < -STEP_SIZE / 2)
//{
// item->goalAnimState = LS_STEP_UP;
// GetChange(item, &g_Level.Anims[item->animNumber]);
//}
//
//if (coll->Middle.Floor < 50)
//{
// if (coll->Middle.Floor != NO_HEIGHT)
// item->pos.yPos += coll->Middle.Floor;
//}
//else
//{
// item->goalAnimState = LS_STEP_DOWN; // for theoretical sprint stepdown anims, not in default anims
// if (GetChange(item, &g_Level.Anims[item->animNumber]))
// item->pos.yPos += coll->Middle.Floor; // move Lara to middle.Floor
// else
// item->pos.yPos += 50; // do the default aligment
//}
}
// LEGACY
void old_lara_col_dash ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 05:06:08 +10:00
{
/*state 73*/
/*state code: lara_as_dash*/
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = 0 ;
2020-09-26 05:06:08 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . SlopesAreWalls = true ;
2020-09-26 03:28:30 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( ! LaraHitCeiling ( item , coll ) & & ! TestLaraVault ( item , coll ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
if ( LaraDeflectEdge ( item , coll ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > pos . zRot = 0 ;
2021-10-07 11:01:39 +03:00
if ( coll - > HitTallObject | | TestLaraWall ( item , 256 , 0 , - 640 ) )
2020-08-14 17:54:25 -05:00
{
2020-09-26 05:06:08 +10:00
item - > goalAnimState = LS_SPLAT ;
if ( GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) )
{
item - > currentAnimState = LS_SPLAT ;
return ;
}
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
LaraCollideStop ( item , coll ) ;
2020-08-14 17:54:25 -05:00
}
2020-09-26 05:06:08 +10:00
if ( ! LaraFallen ( item , coll ) )
2020-08-14 17:54:25 -05:00
{
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor > = - STEPUP_HEIGHT & & coll - > Middle . Floor < - STEP_SIZE / 2 )
2020-09-26 05:06:08 +10:00
{
item - > goalAnimState = LS_STEP_UP ;
GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) ;
}
if ( ! TestLaraSlide ( item , coll ) )
{
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor < 50 )
2020-09-26 05:06:08 +10:00
{
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-09-26 05:06:08 +10:00
}
else
{
item - > goalAnimState = LS_STEP_DOWN ; // for theoretical sprint stepdown anims, not in default anims
if ( GetChange ( item , & g_Level . Anims [ item - > animNumber ] ) )
2021-09-10 00:18:47 +03:00
item - > pos . yPos + = coll - > Middle . Floor ; // move Lara to middle.Floor
2020-09-26 05:06:08 +10:00
else
item - > pos . yPos + = 50 ; // do the default aligment
}
}
2020-08-14 17:54:25 -05:00
}
}
2020-09-26 05:06:08 +10:00
}
2020-08-14 17:54:25 -05:00
2021-10-14 19:58:29 +11:00
// State: LS_SPRINT_ROLL (74)
// Collision: lara_col_dashdive()
2021-02-03 01:50:59 -03:00
void lara_as_dashdive ( ITEM_INFO * item , COLL_INFO * coll )
2021-10-14 19:58:29 +11:00
{
if ( TrInput & IN_LEFT )
{
Lara . turnRate - = LARA_TURN_RATE ;
if ( Lara . turnRate < - LARA_SLOW_TURN )
Lara . turnRate = - LARA_SLOW_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX ) / 12 ;
else
item - > pos . zRot - = ( item - > pos . zRot + LARA_LEAN_MAX * 3 / 6 ) / 12 ;
}
else if ( TrInput & IN_RIGHT )
{
Lara . turnRate + = LARA_TURN_RATE ;
if ( Lara . turnRate > LARA_SLOW_TURN )
Lara . turnRate = LARA_SLOW_TURN ;
if ( TestLaraLean ( item , coll ) )
item - > pos . zRot + = ( LARA_LEAN_MAX - item - > pos . zRot ) / 12 ;
else
item - > pos . zRot + = ( LARA_LEAN_MAX - item - > pos . zRot * 3 / 6 ) / 12 ;
}
// TODO: What?
if ( item - > goalAnimState ! = LS_DEATH & &
item - > goalAnimState ! = LS_STOP & &
item - > goalAnimState ! = LS_RUN_FORWARD & &
item - > fallspeed > LARA_FREEFALL_SPEED )
item - > goalAnimState = LS_FREEFALL ;
}
// LEGACY
void old_lara_as_dashdive ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 05:06:08 +10:00
{
/*state 74*/
/*collision: lara_col_dashdive*/
if ( item - > goalAnimState ! = LS_DEATH & &
item - > goalAnimState ! = LS_STOP & &
item - > goalAnimState ! = LS_RUN_FORWARD & &
item - > fallspeed > LARA_FREEFALL_SPEED )
item - > goalAnimState = LS_FREEFALL ;
}
2020-08-14 17:54:25 -05:00
2021-02-03 01:50:59 -03:00
void lara_col_dashdive ( ITEM_INFO * item , COLL_INFO * coll )
2020-09-26 05:06:08 +10:00
{
/*state 74*/
/*state code: lara_as_dashdive*/
if ( item - > speed < 0 )
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot + ANGLE ( 180 ) ;
2020-09-26 05:06:08 +10:00
else
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-09-26 05:06:08 +10:00
2021-09-19 17:48:32 +03:00
coll - > Setup . BadHeightDown = NO_BAD_POS ;
coll - > Setup . BadHeightUp = - STEPUP_HEIGHT ;
2021-09-10 00:20:59 +03:00
coll - > Setup . BadCeilingHeight = BAD_JUMP_CEILING ;
2020-09-26 05:06:08 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . SlopesAreWalls = true ;
2020-09-26 05:06:08 +10:00
2021-09-10 00:20:59 +03:00
coll - > Setup . ForwardAngle = Lara . moveAngle ;
2021-09-19 06:42:24 +03:00
GetCollisionInfo ( coll , item ) ;
2020-09-26 05:06:08 +10:00
LaraDeflectEdgeJump ( item , coll ) ;
2020-08-14 17:54:25 -05:00
2020-09-26 05:06:08 +10:00
if ( ! LaraFallen ( item , coll ) )
{
2020-08-14 17:54:25 -05:00
if ( item - > speed < 0 )
2020-12-19 23:34:52 -03:00
Lara . moveAngle = item - > pos . yRot ;
2020-08-14 17:54:25 -05:00
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor < = 0 & & item - > fallspeed > 0 )
2020-08-14 17:54:25 -05:00
{
if ( LaraLandedBad ( item , coll ) )
{
item - > goalAnimState = LS_DEATH ;
}
else if ( Lara . waterStatus = = LW_WADE | | ! ( TrInput & IN_FORWARD ) | | TrInput & IN_WALK )
{
item - > goalAnimState = LS_STOP ;
}
else
{
item - > goalAnimState = LS_RUN_FORWARD ;
}
2020-09-26 05:06:08 +10:00
item - > gravityStatus = false ;
item - > fallspeed = 0 ;
2021-09-10 00:18:47 +03:00
item - > pos . yPos + = coll - > Middle . Floor ;
2020-09-26 05:06:08 +10:00
item - > speed = 0 ;
2020-08-14 17:54:25 -05:00
AnimateLara ( item ) ;
}
ShiftItem ( item , coll ) ;
2021-09-10 00:18:47 +03:00
if ( coll - > Middle . Floor ! = NO_HEIGHT )
item - > pos . yPos + = coll - > Middle . Floor ;
2020-08-14 17:54:25 -05:00
}
}