2020-08-13 19:53:13 -05:00
|
|
|
#include "framework.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Game/Lara/lara_objects.h"
|
|
|
|
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Game/animation.h"
|
|
|
|
#include "Game/camera.h"
|
|
|
|
#include "Game/collision/collide_room.h"
|
|
|
|
#include "Game/control/control.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Game/items.h"
|
|
|
|
#include "Game/Lara/lara.h"
|
2021-12-09 12:48:54 +03:00
|
|
|
#include "Game/Lara/lara_tests.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Objects/Generic/Object/rope.h"
|
|
|
|
#include "Sound/sound.h"
|
|
|
|
#include "Specific/input.h"
|
|
|
|
#include "Specific/level.h"
|
2021-09-28 13:01:28 +02:00
|
|
|
|
2021-09-30 12:03:39 +02:00
|
|
|
using namespace TEN::Entities::Generic;
|
2021-09-09 11:10:25 +03:00
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
// -----------------------------------
|
|
|
|
// MISCELLANEOUS INTERACTABLE OBJECTS
|
|
|
|
// State Control & Collision Functions
|
|
|
|
// -----------------------------------
|
|
|
|
|
|
|
|
// ------
|
|
|
|
// PICKUP
|
|
|
|
// ------
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_pickup(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 39, 98*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-11-22 22:47:34 +11:00
|
|
|
info->look = false;
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.targetAngle = -ANGLE(130.0f);
|
|
|
|
Camera.targetElevation = -ANGLE(15.0f);
|
2021-11-22 22:47:34 +11:00
|
|
|
Camera.targetDistance = WALL_SIZE;
|
2021-12-10 11:04:28 +03:00
|
|
|
|
|
|
|
if (TestLastFrame(item))
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = GetNextAnimState(item);
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_pickupflare(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 67*/
|
|
|
|
/*collison: lara_default_col*/
|
2021-11-22 22:47:34 +11:00
|
|
|
info->look = false;
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.targetAngle = ANGLE(130.0f);
|
|
|
|
Camera.targetElevation = -ANGLE(15.0f);
|
2021-11-22 22:47:34 +11:00
|
|
|
Camera.targetDistance = WALL_SIZE;
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->FrameNumber == g_Level.Anims[item->AnimNumber].frameEnd - 1)
|
2021-11-25 23:38:59 +11:00
|
|
|
info->gunStatus = LG_HANDS_FREE;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
// ------
|
|
|
|
// SWITCH
|
|
|
|
// ------
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_switchon(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
/*states 40, 126*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-11-22 22:47:34 +11:00
|
|
|
info->look = false;
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2020-08-13 19:53:13 -05:00
|
|
|
Camera.targetAngle = ANGLE(80.0f);
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.targetElevation = -ANGLE(25.0f);
|
2021-11-22 22:47:34 +11:00
|
|
|
Camera.targetDistance = WALL_SIZE;
|
2020-08-13 19:53:13 -05:00
|
|
|
Camera.speed = 6;
|
2020-09-26 05:06:08 +10:00
|
|
|
}
|
2020-09-26 03:28:30 +10:00
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_switchoff(ITEM_INFO* item, COLL_INFO* coll)
|
2020-09-26 05:06:08 +10:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 41*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-11-22 22:47:34 +11:00
|
|
|
info->look = false;
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.targetAngle = ANGLE(80.0f);
|
|
|
|
Camera.targetElevation = -ANGLE(25.0f);
|
2021-11-22 22:47:34 +11:00
|
|
|
Camera.targetDistance = WALL_SIZE;
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.speed = 6;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_col_turnswitch(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 95*/
|
2021-12-10 22:31:34 +11:00
|
|
|
/*state code: lara_as_controlled_no_look*/
|
2022-02-09 16:55:46 +11:00
|
|
|
if (coll->Setup.OldPosition.x != item->Position.xPos || coll->Setup.OldPosition.z != item->Position.zPos)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_TURNSWITCH_PUSH_COUNTER_CLOCKWISE_CONTINUE)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.yRot -= ANGLE(90.0f);
|
2020-09-26 05:06:08 +10:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->AnimNumber = LA_TURNSWITCH_PUSH_COUNTER_CLOCKWISE_END;
|
|
|
|
item->FrameNumber = g_Level.Anims[item->AnimNumber].frameBase;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_TURNSWITCH_PUSH_CLOCKWISE_CONTINUE)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.yRot += ANGLE(90.0f);
|
2020-09-26 05:06:08 +10:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->AnimNumber = LA_TURNSWITCH_PUSH_CLOCKWISE_END;
|
|
|
|
item->FrameNumber = g_Level.Anims[item->AnimNumber].frameBase;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// RECEPTACLE
|
|
|
|
// ----------
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_usekey(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 42*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-11-22 22:47:34 +11:00
|
|
|
info->look = false;
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.targetAngle = -ANGLE(80.0f);
|
2021-11-22 22:47:34 +11:00
|
|
|
Camera.targetElevation = -ANGLE(25.0f);
|
|
|
|
Camera.targetDistance = WALL_SIZE;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_usepuzzle(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 43*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-11-22 22:47:34 +11:00
|
|
|
info->look = false;
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.targetAngle = -ANGLE(80.0f);
|
|
|
|
Camera.targetElevation = -ANGLE(25.0f);
|
2021-11-22 22:47:34 +11:00
|
|
|
Camera.targetDistance = WALL_SIZE;
|
2020-09-26 05:06:08 +10:00
|
|
|
|
2021-11-30 03:24:50 +03:00
|
|
|
if (TestLastFrame(item))
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->ItemFlags[0])
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->AnimNumber = item->ItemFlags[0];
|
|
|
|
item->ActiveState = LS_MISC_CONTROL;
|
|
|
|
item->FrameNumber = g_Level.Anims[item->AnimNumber].frameBase;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
// --------
|
|
|
|
// PUSHABLE
|
|
|
|
// --------
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_pushblock(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 36*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-11-22 22:47:34 +11:00
|
|
|
info->look = false;
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.flags = CF_FOLLOW_CENTER;
|
2021-08-16 18:05:38 -05:00
|
|
|
Camera.targetAngle = ANGLE(35.0f);
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.targetElevation = -ANGLE(25.0f);
|
2021-08-16 18:05:38 -05:00
|
|
|
Camera.laraNode = LM_TORSO;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_pullblock(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 37*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-11-22 22:47:34 +11:00
|
|
|
info->look = false;
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.flags = CF_FOLLOW_CENTER;
|
|
|
|
Camera.targetAngle = ANGLE(35.0f);
|
|
|
|
Camera.targetElevation = -ANGLE(25.0f);
|
2021-08-16 18:05:38 -05:00
|
|
|
Camera.laraNode = LM_TORSO;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_ppready(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 38*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.targetAngle = ANGLE(75.0f);
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2020-08-13 19:53:13 -05:00
|
|
|
if (!(TrInput & IN_ACTION))
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_IDLE;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
// ------
|
|
|
|
// PULLEY
|
|
|
|
// ------
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_pulley(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 104*/
|
|
|
|
/*collision: lara_default_col*/
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-22 22:47:34 +11:00
|
|
|
ITEM_INFO* pulley = &g_Level.Items[info->interactedItem];
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2021-11-22 22:47:34 +11:00
|
|
|
info->look = false;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (TrInput & IN_ACTION && pulley->TriggerFlags)
|
|
|
|
item->TargetState = LS_PULLEY;
|
2020-08-13 19:53:13 -05:00
|
|
|
else
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_IDLE;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_PULLEY_PULL &&
|
|
|
|
item->FrameNumber == g_Level.Anims[item->AnimNumber].frameBase + 44)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (pulley->TriggerFlags)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (!pulley->ItemFlags[1])
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
pulley->TriggerFlags--;
|
|
|
|
if (pulley->TriggerFlags)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (pulley->ItemFlags[2])
|
2021-06-08 06:32:51 +02:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
pulley->ItemFlags[2] = 0;
|
|
|
|
pulley->Status = ITEM_DEACTIVATED;
|
2021-06-08 06:32:51 +02:00
|
|
|
}
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
else
|
2021-06-08 06:32:51 +02:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
pulley->Status = ITEM_DEACTIVATED;
|
|
|
|
pulley->ItemFlags[2] = 1;
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (pulley->ItemFlags[3] >= 0)
|
|
|
|
pulley->TriggerFlags = abs(pulley->ItemFlags[3]);
|
2021-06-08 06:32:51 +02:00
|
|
|
else
|
2022-02-09 16:55:46 +11:00
|
|
|
pulley->ItemFlags[0] = 1;
|
2021-06-08 06:32:51 +02:00
|
|
|
}
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_PULLEY_RELEASE &&
|
|
|
|
item->FrameNumber == g_Level.Anims[item->AnimNumber].frameEnd - 1)
|
2021-11-22 22:47:34 +11:00
|
|
|
{
|
2021-11-25 23:38:59 +11:00
|
|
|
info->gunStatus = LG_HANDS_FREE;
|
2021-11-22 22:47:34 +11:00
|
|
|
}
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
// --------------
|
|
|
|
// HORIZONTAL BAR
|
|
|
|
// --------------
|
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
void lara_as_parallelbars(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 128*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-11-22 22:47:34 +11:00
|
|
|
if (!(TrInput & IN_ACTION) || TrInput & IN_JUMP)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_BARS_JUMP;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_pbleapoff(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 129*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-11-22 22:47:34 +11:00
|
|
|
ITEM_INFO* barItem = &g_Level.Items[Lara.interactedItem];
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 13:20:57 +11:00
|
|
|
item->Airborne = true;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->FrameNumber == g_Level.Anims[item->AnimNumber].frameBase)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
|
|
|
int dist;
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->Position.yRot == barItem->Position.yRot)
|
|
|
|
dist = barItem->TriggerFlags / 100 - 2;
|
2020-08-13 19:53:13 -05:00
|
|
|
else
|
2022-02-09 16:55:46 +11:00
|
|
|
dist = barItem->TriggerFlags % 100 - 2;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 13:20:57 +11:00
|
|
|
item->VerticalVelocity = -(20 * dist + 64);
|
|
|
|
item->Velocity = 20 * dist + 58;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-11-30 03:24:50 +03:00
|
|
|
if (TestLastFrame(item))
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2021-11-22 22:47:34 +11:00
|
|
|
SetAnimation(item, LA_REACH);
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.xPos += 700 * phd_sin(item->Position.yRot);
|
|
|
|
item->Position.yPos -= 361;
|
|
|
|
item->Position.zPos += 700 * phd_cos(item->Position.yRot);
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
// ---------
|
|
|
|
// TIGHTROPE
|
|
|
|
// ---------
|
|
|
|
|
2021-09-05 14:49:00 +02:00
|
|
|
#ifdef NEW_TIGHTROPE
|
|
|
|
|
2021-11-21 00:04:28 +11:00
|
|
|
void lara_trbalance_mesh(ITEM_INFO* item)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-21 00:04:28 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.zRot = info->tightrope.balance / 4;
|
2022-02-08 20:45:21 +11:00
|
|
|
info->extraTorsoRot.z = -info->tightrope.balance;
|
2021-09-05 14:49:00 +02:00
|
|
|
}
|
|
|
|
|
2021-11-21 00:04:28 +11:00
|
|
|
void lara_trbalance_regen(ITEM_INFO* item)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-21 00:04:28 +11:00
|
|
|
|
|
|
|
if (info->tightrope.timeOnTightrope <= 32)
|
|
|
|
info->tightrope.timeOnTightrope = 0;
|
2021-09-05 14:49:00 +02:00
|
|
|
else
|
2021-11-21 00:04:28 +11:00
|
|
|
info->tightrope.timeOnTightrope -= 32;
|
|
|
|
|
|
|
|
if (info->tightrope.balance > 0)
|
2021-09-05 14:49:00 +02:00
|
|
|
{
|
2021-11-22 22:47:34 +11:00
|
|
|
if (info->tightrope.balance <= ANGLE(0.75f))
|
2021-11-21 00:04:28 +11:00
|
|
|
info->tightrope.balance = 0;
|
|
|
|
else
|
2021-11-22 22:47:34 +11:00
|
|
|
info->tightrope.balance -= ANGLE(0.75f);
|
2021-09-05 14:49:00 +02:00
|
|
|
}
|
2021-11-21 00:04:28 +11:00
|
|
|
|
|
|
|
if (info->tightrope.balance < 0)
|
2021-09-05 14:49:00 +02:00
|
|
|
{
|
2021-11-22 22:47:34 +11:00
|
|
|
if (info->tightrope.balance >= -ANGLE(0.75f))
|
2021-11-21 00:04:28 +11:00
|
|
|
info->tightrope.balance = 0;
|
|
|
|
else
|
2021-11-22 22:47:34 +11:00
|
|
|
info->tightrope.balance += ANGLE(0.75f);
|
2021-09-05 14:49:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-21 00:04:28 +11:00
|
|
|
void lara_trbalance(ITEM_INFO* item)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-21 00:04:28 +11:00
|
|
|
const int factor = ((info->tightrope.timeOnTightrope >> 7) & 0xFF) * 128;
|
|
|
|
|
|
|
|
if (TrInput & IN_LEFT)
|
2021-11-22 22:47:34 +11:00
|
|
|
info->tightrope.balance += ANGLE(1.4f);
|
2021-11-21 00:04:28 +11:00
|
|
|
if (TrInput & IN_RIGHT)
|
2021-11-22 22:47:34 +11:00
|
|
|
info->tightrope.balance -= ANGLE(1.4f);
|
2021-11-21 00:04:28 +11:00
|
|
|
|
|
|
|
if (info->tightrope.balance < 0)
|
2021-09-05 14:49:00 +02:00
|
|
|
{
|
2021-11-21 00:04:28 +11:00
|
|
|
info->tightrope.balance -= factor;
|
2021-11-22 22:47:34 +11:00
|
|
|
if (info->tightrope.balance <= -ANGLE(45.0f))
|
|
|
|
info->tightrope.balance = ANGLE(45.0f);
|
2021-09-05 14:49:00 +02:00
|
|
|
|
2021-11-21 00:04:28 +11:00
|
|
|
}
|
|
|
|
else if (info->tightrope.balance > 0)
|
|
|
|
{
|
|
|
|
info->tightrope.balance += factor;
|
2021-11-22 22:47:34 +11:00
|
|
|
if (info->tightrope.balance >= ANGLE(45.0f))
|
|
|
|
info->tightrope.balance = ANGLE(45.0f);
|
2021-11-21 00:04:28 +11:00
|
|
|
}
|
|
|
|
else
|
|
|
|
info->tightrope.balance = GetRandomControl() & 1 ? -1 : 1;
|
2021-09-05 14:49:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void lara_as_trpose(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2021-11-21 00:04:28 +11:00
|
|
|
if (TrInput & IN_LOOK)
|
2021-09-05 14:49:00 +02:00
|
|
|
LookUpDown();
|
2021-11-21 00:04:28 +11:00
|
|
|
|
|
|
|
lara_trbalance_regen(item);
|
|
|
|
lara_trbalance_mesh(item);
|
|
|
|
|
|
|
|
if (TrInput & IN_FORWARD)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_TIGHTROPE_FORWARD;
|
2021-11-21 00:04:28 +11:00
|
|
|
else if (TrInput & (IN_ROLL | IN_BACK))
|
2021-09-05 14:49:00 +02:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_TIGHTROPE_IDLE)
|
2021-09-05 14:49:00 +02:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->ActiveState = LS_TIGHTROPE_TURN_180;
|
|
|
|
item->AnimNumber = LA_TIGHTROPE_TURN_180;
|
|
|
|
item->FrameNumber = g_Level.Anims[item->AnimNumber].frameBase;
|
2021-09-05 14:49:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-21 00:04:28 +11:00
|
|
|
void lara_as_trexit(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-21 00:04:28 +11:00
|
|
|
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2021-11-21 00:04:28 +11:00
|
|
|
|
|
|
|
lara_trbalance_regen(item);
|
|
|
|
lara_trbalance_mesh(item);
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_TIGHTROPE_END &&
|
2021-11-30 03:24:50 +03:00
|
|
|
TestLastFrame(item))
|
2021-09-05 14:49:00 +02:00
|
|
|
{
|
2022-02-08 20:45:21 +11:00
|
|
|
info->extraTorsoRot.z = 0;
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.zRot = 0;
|
2021-09-05 14:49:00 +02:00
|
|
|
}
|
|
|
|
}
|
2021-11-21 00:04:28 +11:00
|
|
|
|
2021-09-05 14:49:00 +02:00
|
|
|
void lara_as_trwalk(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-21 00:04:28 +11:00
|
|
|
|
|
|
|
auto probe = GetCollisionResult(item);
|
2022-02-09 16:55:46 +11:00
|
|
|
if (probe.Position.Floor == item->Position.yPos &&
|
2021-11-21 00:04:28 +11:00
|
|
|
info->tightrope.canGoOff)
|
2021-09-05 14:49:00 +02:00
|
|
|
{
|
2021-11-21 00:04:28 +11:00
|
|
|
lara_trbalance_regen(item);
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_TIGHTROPE_EXIT;
|
2021-09-05 14:49:00 +02:00
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->TargetState != LS_TIGHTROPE_EXIT &&
|
2021-11-21 00:04:28 +11:00
|
|
|
(TrInput & (IN_BACK | IN_ROLL) || !(TrInput & IN_FORWARD)))
|
2021-09-05 14:49:00 +02:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_TIGHTROPE_IDLE;
|
2021-09-05 14:49:00 +02:00
|
|
|
}
|
|
|
|
|
2021-11-21 00:04:28 +11:00
|
|
|
info->tightrope.timeOnTightrope++;
|
|
|
|
lara_trbalance(item);
|
|
|
|
lara_trbalance_mesh(item);
|
2021-09-05 14:49:00 +02:00
|
|
|
|
2021-11-21 00:04:28 +11:00
|
|
|
if (info->tightrope.balance >= 8000)
|
|
|
|
SetAnimation(item, LA_TIGHTROPE_FALL_RIGHT);
|
|
|
|
else if (info->tightrope.balance <= -8000)
|
|
|
|
SetAnimation(item, LA_TIGHTROPE_FALL_LEFT);
|
|
|
|
}
|
2021-09-05 14:49:00 +02:00
|
|
|
|
2021-11-21 00:04:28 +11:00
|
|
|
void lara_as_trfall(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2021-09-05 14:49:00 +02:00
|
|
|
/*states 122, 123*/
|
|
|
|
/*collision: lara_default_col*/
|
2021-11-21 00:04:28 +11:00
|
|
|
lara_trbalance_regen(item);
|
|
|
|
lara_trbalance_mesh(item);
|
2021-09-05 14:49:00 +02:00
|
|
|
|
2021-11-30 03:24:50 +03:00
|
|
|
if (TestLastFrame(item))
|
2021-11-21 00:04:28 +11:00
|
|
|
{
|
|
|
|
PHD_VECTOR pos{ 0, 75, 0 };
|
2021-09-05 14:49:00 +02:00
|
|
|
GetLaraJointPosition(&pos, LM_RFOOT);
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.xPos = pos.x;
|
|
|
|
item->Position.yPos = pos.y;
|
|
|
|
item->Position.zPos = pos.z;
|
2021-09-05 14:49:00 +02:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_FREEFALL;
|
|
|
|
item->ActiveState = LS_FREEFALL;
|
|
|
|
item->AnimNumber = LA_FREEFALL;
|
|
|
|
item->FrameNumber = g_Level.Anims[item->AnimNumber].frameBase;
|
2021-09-05 14:49:00 +02:00
|
|
|
|
2022-02-09 13:20:57 +11:00
|
|
|
item->VerticalVelocity = 81;
|
2021-09-05 14:49:00 +02:00
|
|
|
Camera.targetspeed = 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
2020-09-26 05:06:08 +10:00
|
|
|
void lara_as_trpose(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 119*/
|
|
|
|
/*collision: lara_default_col*/
|
2020-08-13 19:53:13 -05:00
|
|
|
if (TrInput & IN_LOOK)
|
|
|
|
LookUpDown();
|
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
GetTighRopeFallOff(127);
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (LaraItem->ActiveState != LS_TIGHTROPE_UNBALANCE_LEFT)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
|
|
|
if (Lara.tightRopeFall)
|
|
|
|
{
|
|
|
|
if (GetRandomControl() & 1)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_TIGHTROPE_UNBALANCE_RIGHT;
|
2020-08-13 19:53:13 -05:00
|
|
|
else
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_TIGHTROPE_UNBALANCE_LEFT;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (TrInput & IN_FORWARD)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_TIGHTROPE_FORWARD;
|
2021-11-22 22:47:34 +11:00
|
|
|
else if (TrInput & (IN_ROLL | IN_BACK))
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_TIGHTROPE_IDLE)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->ActiveState = LS_TIGHTROPE_TURN_180;
|
|
|
|
item->AnimNumber = LA_TIGHTROPE_TURN_180;
|
|
|
|
item->FrameNumber = g_Level.Anims[item->AnimNumber].frameBase;
|
2020-09-26 05:06:08 +10:00
|
|
|
GetTighRopeFallOff(1);
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
void lara_as_trwalk(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 121*/
|
|
|
|
/*collision: lara_default_col*/
|
2020-08-13 19:53:13 -05:00
|
|
|
if (Lara.tightRopeOnCount)
|
|
|
|
Lara.tightRopeOnCount--;
|
|
|
|
else if (Lara.tightRopeOff)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
short roomNumber = item->RoomNumber;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (GetFloorHeight(GetFloor(item->Position.xPos, item->Position.yPos, item->Position.zPos, &roomNumber),
|
|
|
|
item->Position.xPos, item->Position.yPos, item->Position.zPos) == item->Position.yPos)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
|
|
|
Lara.tightRopeOff = 0;
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_TIGHTROPE_EXIT;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2020-09-26 05:06:08 +10:00
|
|
|
GetTighRopeFallOff(127);
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->ActiveState != LS_TIGHTROPE_UNBALANCE_LEFT)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
|
|
|
if (TrInput & IN_LOOK)
|
|
|
|
LookUpDown();
|
|
|
|
|
2021-11-22 22:47:34 +11:00
|
|
|
if ((Lara.tightRopeFall || (TrInput & (IN_BACK | IN_ROLL) || !(TrInput & IN_FORWARD)) && !Lara.tightRopeOnCount && !Lara.tightRopeOff) &&
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState != LS_TIGHTROPE_EXIT)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_TIGHTROPE_IDLE;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
void lara_as_trfall(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*states 122, 123*/
|
|
|
|
/*collision: lara_default_col*/
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_TIGHTROPE_FALL_LEFT || item->AnimNumber == LA_TIGHTROPE_FALL_RIGHT)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->FrameNumber == g_Level.Anims[item->AnimNumber].frameEnd)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
PHD_VECTOR pos;
|
|
|
|
pos.x = 0;
|
|
|
|
pos.y = 0;
|
|
|
|
pos.z = 0;
|
|
|
|
|
|
|
|
GetLaraJointPosition(&pos, LM_RFOOT);
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.xPos = pos.x;
|
|
|
|
item->Position.yPos = pos.y + 75;
|
|
|
|
item->Position.zPos = pos.z;
|
2020-09-26 05:06:08 +10:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_FREEFALL;
|
|
|
|
item->ActiveState = LS_FREEFALL;
|
|
|
|
item->AnimNumber = LA_FREEFALL;
|
|
|
|
item->FrameNumber = g_Level.Anims[item->AnimNumber].frameBase;
|
2020-09-26 05:06:08 +10:00
|
|
|
|
2022-02-09 13:20:57 +11:00
|
|
|
item->VerticalVelocity = 81;
|
2020-08-13 19:53:13 -05:00
|
|
|
Camera.targetspeed = 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
int undoInp, wrongInput;
|
2020-08-13 19:53:13 -05:00
|
|
|
int undoAnim, undoFrame;
|
|
|
|
|
|
|
|
if (Lara.tightRopeOnCount > 0)
|
|
|
|
Lara.tightRopeOnCount--;
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_TIGHTROPE_UNBALANCE_LEFT)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
undoInp = IN_RIGHT;
|
2020-08-13 19:53:13 -05:00
|
|
|
wrongInput = IN_LEFT;
|
|
|
|
undoAnim = LA_TIGHTROPE_RECOVER_LEFT;
|
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
else if (item->AnimNumber == LA_TIGHTROPE_UNBALANCE_RIGHT)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
undoInp = IN_LEFT;
|
2020-08-13 19:53:13 -05:00
|
|
|
wrongInput = IN_RIGHT;
|
|
|
|
undoAnim = LA_TIGHTROPE_RECOVER_RIGHT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
undoFrame = g_Level.Anims[item->AnimNumber].frameEnd + g_Level.Anims[undoAnim].frameBase - item->FrameNumber;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
if (TrInput & undoInp && Lara.tightRopeOnCount == 0)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->ActiveState = LS_TIGHTROPE_RECOVER_BALANCE;
|
|
|
|
item->TargetState = LS_TIGHTROPE_IDLE;
|
|
|
|
item->AnimNumber = undoAnim;
|
|
|
|
item->FrameNumber = undoFrame;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
|
|
|
Lara.tightRopeFall--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (TrInput & wrongInput)
|
|
|
|
{
|
|
|
|
if (Lara.tightRopeOnCount < 10)
|
|
|
|
Lara.tightRopeOnCount += (GetRandomControl() & 3) + 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// ----
|
|
|
|
// ROPE
|
|
|
|
// ----
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_ropel(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 90*/
|
|
|
|
/*collision: lara_void_func*/
|
|
|
|
if (TrInput & IN_ACTION)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
|
|
|
if (TrInput & IN_LEFT)
|
2022-02-08 20:45:21 +11:00
|
|
|
Lara.ropeParameters.Y += ANGLE(1.4f);
|
2020-08-13 19:53:13 -05:00
|
|
|
else
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_ROPE_IDLE;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
2020-09-26 05:06:08 +10:00
|
|
|
else
|
2020-08-13 19:53:13 -05:00
|
|
|
FallFromRope(item);
|
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_roper(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
if (TrInput & IN_ACTION)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
|
|
|
if (TrInput & IN_RIGHT)
|
2022-02-08 20:45:21 +11:00
|
|
|
Lara.ropeParameters.Y -= ANGLE(1.4f);
|
2020-08-13 19:53:13 -05:00
|
|
|
else
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_ROPE_IDLE;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
2020-09-26 05:06:08 +10:00
|
|
|
else
|
2020-08-13 19:53:13 -05:00
|
|
|
FallFromRope(item);
|
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_rope(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*states 111, 114, 115*/
|
|
|
|
/*collison: lara_col_rope(111), lara_col_ropefwd(114, 115)*/
|
|
|
|
if (!(TrInput & IN_ACTION))
|
2020-08-13 19:53:13 -05:00
|
|
|
FallFromRope(item);
|
|
|
|
|
|
|
|
if (TrInput & IN_LOOK)
|
|
|
|
LookUpDown();
|
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_col_rope(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state: 111*/
|
|
|
|
/*state code: lara_as_rope*/
|
|
|
|
if (TrInput & IN_ACTION)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
|
|
|
UpdateRopeSwing(item);
|
|
|
|
|
|
|
|
if (TrInput & IN_SPRINT)
|
|
|
|
{
|
2022-02-08 20:45:21 +11:00
|
|
|
Lara.ropeParameters.DFrame = (g_Level.Anims[LA_ROPE_SWING].frameBase + 32) << 8;
|
|
|
|
Lara.ropeParameters.Frame = Lara.ropeParameters.DFrame;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_ROPE_SWING;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
2022-02-08 20:45:21 +11:00
|
|
|
else if (TrInput & IN_FORWARD && Lara.ropeParameters.Segment > 4)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_ROPE_UP;
|
2022-02-08 20:45:21 +11:00
|
|
|
else if (TrInput & IN_BACK && Lara.ropeParameters.Segment < 21)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_ROPE_DOWN;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-08 20:45:21 +11:00
|
|
|
Lara.ropeParameters.Flag = 0;
|
|
|
|
Lara.ropeParameters.Count = 0;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
else if (TrInput & IN_LEFT)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_ROPE_TURN_CLOCKWISE;
|
2020-08-13 19:53:13 -05:00
|
|
|
else if (TrInput & IN_RIGHT)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_ROPE_TURN_COUNTER_CLOCKWISE;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
2020-09-26 05:06:08 +10:00
|
|
|
else
|
2020-08-13 19:53:13 -05:00
|
|
|
FallFromRope(item);
|
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_col_ropefwd(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*states 114, 115*/
|
|
|
|
/*state code: lara_as_rope(for both)*/
|
2020-08-13 19:53:13 -05:00
|
|
|
Camera.targetDistance = SECTOR(2);
|
|
|
|
|
|
|
|
UpdateRopeSwing(item);
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_ROPE_SWING)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
|
|
|
if (TrInput & IN_SPRINT)
|
|
|
|
{
|
|
|
|
int vel;
|
|
|
|
|
2022-02-08 20:45:21 +11:00
|
|
|
if (abs(Lara.ropeParameters.LastX) < 9000)
|
|
|
|
vel = 192 * (9000 - abs(Lara.ropeParameters.LastX)) / 9000;
|
2020-08-13 19:53:13 -05:00
|
|
|
else
|
|
|
|
vel = 0;
|
|
|
|
|
2022-02-08 20:45:21 +11:00
|
|
|
ApplyVelocityToRope(Lara.ropeParameters.Segment - 2,
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.yRot + (Lara.ropeParameters.Direction ? ANGLE(0.0f) : ANGLE(180.0f)),
|
2021-08-30 15:13:18 -05:00
|
|
|
vel >> 5);
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2022-02-08 20:45:21 +11:00
|
|
|
if (Lara.ropeParameters.Frame > Lara.ropeParameters.DFrame)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-08 20:45:21 +11:00
|
|
|
Lara.ropeParameters.Frame -= (unsigned short)Lara.ropeParameters.FrameRate;
|
|
|
|
if (Lara.ropeParameters.Frame < Lara.ropeParameters.DFrame)
|
|
|
|
Lara.ropeParameters.Frame = Lara.ropeParameters.DFrame;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
2022-02-08 20:45:21 +11:00
|
|
|
else if (Lara.ropeParameters.Frame < Lara.ropeParameters.DFrame)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-08 20:45:21 +11:00
|
|
|
Lara.ropeParameters.Frame += (unsigned short)Lara.ropeParameters.FrameRate;
|
|
|
|
if (Lara.ropeParameters.Frame > Lara.ropeParameters.DFrame)
|
|
|
|
Lara.ropeParameters.Frame = Lara.ropeParameters.DFrame;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->FrameNumber = Lara.ropeParameters.Frame >> 8;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
|
|
|
if (!(TrInput & IN_SPRINT) &&
|
2022-02-09 16:55:46 +11:00
|
|
|
item->FrameNumber == g_Level.Anims[LA_ROPE_SWING].frameBase + 32 &&
|
2022-02-08 20:45:21 +11:00
|
|
|
Lara.ropeParameters.MaxXBackward < 6750 &&
|
|
|
|
Lara.ropeParameters.MaxXForward < 6750)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->AnimNumber = LA_JUMP_UP_TO_ROPE_END;
|
|
|
|
item->FrameNumber = g_Level.Anims[item->AnimNumber].frameBase;
|
2020-09-26 05:06:08 +10:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->ActiveState = LS_ROPE_IDLE;
|
|
|
|
item->TargetState = LS_ROPE_IDLE;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (TrInput & IN_JUMP)
|
|
|
|
JumpOffRope(item);
|
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
else if (item->FrameNumber == g_Level.Anims[LA_ROPE_IDLE_TO_SWING].frameBase + 15)
|
|
|
|
ApplyVelocityToRope(Lara.ropeParameters.Segment, item->Position.yRot, 128);
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_climbrope(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 112*/
|
|
|
|
/*collision: lara_void_func*/
|
|
|
|
if (TrInput & IN_ROLL)
|
|
|
|
FallFromRope(item);
|
|
|
|
else
|
2020-09-26 03:28:30 +10:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
Camera.targetAngle = ANGLE(30.0f);
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (g_Level.Anims[item->AnimNumber].frameEnd == item->FrameNumber)
|
2020-09-26 05:06:08 +10:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->FrameNumber = g_Level.Anims[item->AnimNumber].frameBase;
|
2022-02-08 20:45:21 +11:00
|
|
|
Lara.ropeParameters.Segment -= 2;
|
2020-09-26 05:06:08 +10:00
|
|
|
}
|
|
|
|
|
2022-02-08 20:45:21 +11:00
|
|
|
if (!(TrInput & IN_FORWARD) || Lara.ropeParameters.Segment <= 4)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_ROPE_IDLE;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_climbroped(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 113*/
|
|
|
|
/*collision: lara_void_func*/
|
2020-08-13 19:53:13 -05:00
|
|
|
LaraClimbRope(item, coll);
|
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
// -------------
|
|
|
|
// VERTICAL POLE
|
|
|
|
// -------------
|
|
|
|
|
|
|
|
// State: LS_POLE_IDLE (99)
|
|
|
|
// Collision: lara_col_pole_idle()
|
|
|
|
void lara_as_pole_idle(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->HitPoints <= 0)
|
2020-09-26 05:06:08 +10:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_FREEFALL; // TODO: Death state dispatch.
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
if (TrInput & IN_LOOK)
|
|
|
|
LookUpDown();
|
2020-09-26 03:28:30 +10:00
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
if (TrInput & IN_ACTION)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->ActiveState == LA_POLE_IDLE) // Hack.
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2020-09-26 05:06:08 +10:00
|
|
|
if (TrInput & IN_LEFT)
|
2020-09-26 03:28:30 +10:00
|
|
|
{
|
2021-11-27 20:47:57 +11:00
|
|
|
info->turnRate += LARA_POLE_TURN_RATE;
|
|
|
|
if (info->turnRate > LARA_POLE_TURN_MAX)
|
|
|
|
info->turnRate = LARA_POLE_TURN_MAX;
|
2020-09-26 05:06:08 +10:00
|
|
|
}
|
|
|
|
else if (TrInput & IN_RIGHT)
|
|
|
|
{
|
2021-11-27 20:47:57 +11:00
|
|
|
info->turnRate -= LARA_POLE_TURN_RATE;
|
|
|
|
if (info->turnRate < -LARA_POLE_TURN_MAX)
|
|
|
|
info->turnRate = -LARA_POLE_TURN_MAX;
|
2020-09-26 03:28:30 +10:00
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
}
|
2020-09-26 03:28:30 +10:00
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
// TODO: Add forward jump.
|
|
|
|
if (TrInput & IN_JUMP)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_JUMP_BACK;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2021-12-01 20:04:32 +03:00
|
|
|
if (TrInput & IN_FORWARD && TestLaraPoleUp(item, coll))
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_UP;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
2020-09-26 05:06:08 +10:00
|
|
|
}
|
2021-12-01 19:54:52 +03:00
|
|
|
else if (TrInput & IN_BACK && TestLaraPoleDown(item, coll))
|
2020-09-26 05:06:08 +10:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_DOWN;
|
|
|
|
item->ItemFlags[2] = 0; // Doesn't seem necessary?
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
2020-09-26 05:06:08 +10:00
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
if (TrInput & IN_LEFT)
|
2020-09-26 05:06:08 +10:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_TURN_CLOCKWISE;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (TrInput & IN_RIGHT)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_TURN_COUNTER_CLOCKWISE;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
2020-09-26 05:06:08 +10:00
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
2020-09-26 05:06:08 +10:00
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2021-11-24 22:17:20 +11:00
|
|
|
GetCollisionInfo(coll, item); // HACK: Lara may step off poles in mid-air upon reload without this.
|
2021-11-26 13:58:35 +11:00
|
|
|
if (coll->Middle.Floor <= 0 &&
|
2022-02-09 16:55:46 +11:00
|
|
|
item->AnimNumber != LA_POLE_JUMP_BACK) // Hack.
|
2021-11-26 13:58:35 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_IDLE;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
2021-11-26 13:58:35 +11:00
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
else if (item->AnimNumber == LA_POLE_IDLE)
|
2021-11-23 22:35:15 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_FREEFALL;
|
2021-11-24 22:17:20 +11:00
|
|
|
|
|
|
|
// TODO: This shouldn't be required, but the set position command doesn't move Lara correctly.
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.xPos -= phd_sin(item->Position.yRot) * 64;
|
|
|
|
item->Position.zPos -= phd_cos(item->Position.yRot) * 64;
|
2021-11-23 22:35:15 +11:00
|
|
|
}
|
2020-09-26 03:28:30 +10:00
|
|
|
}
|
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
// State: LS_POLE_IDLE (99)
|
|
|
|
// Control: lara_as_pole_idle()
|
|
|
|
void lara_col_pole_idle(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
info->moveAngle = item->Position.yRot;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.LowerFloorBound = NO_LOWER_BOUND;
|
|
|
|
coll->Setup.UpperFloorBound = -STEPUP_HEIGHT;
|
|
|
|
coll->Setup.LowerCeilingBound = BAD_JUMP_CEILING;
|
2021-11-21 20:50:17 +11:00
|
|
|
coll->Setup.ForwardAngle = info->moveAngle;
|
|
|
|
coll->Setup.Radius = LARA_RAD;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.FloorSlopeIsWall = true;
|
2021-11-21 20:50:17 +11:00
|
|
|
GetCollisionInfo(coll, item);
|
|
|
|
|
2021-11-25 21:08:51 +11:00
|
|
|
// TODO: There's a visible snap if Lara hits the ground at a high velocity.
|
2021-11-21 20:50:17 +11:00
|
|
|
if (coll->Middle.Floor < 0)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.yPos += coll->Middle.Floor;
|
2021-11-21 20:50:17 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// State: LS_POLE_UP (100)
|
|
|
|
// Collision: lara_col_pole_up()
|
|
|
|
void lara_as_pole_up(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->HitPoints <= 0)
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Death state dispatch.
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
if (TrInput & IN_ACTION)
|
|
|
|
{
|
|
|
|
if (TrInput & IN_LEFT)
|
|
|
|
{
|
2021-11-27 20:47:57 +11:00
|
|
|
info->turnRate += LARA_POLE_TURN_RATE;
|
|
|
|
if (info->turnRate > LARA_POLE_TURN_MAX)
|
|
|
|
info->turnRate = LARA_POLE_TURN_MAX;
|
2021-11-21 20:50:17 +11:00
|
|
|
}
|
|
|
|
else if (TrInput & IN_RIGHT)
|
|
|
|
{
|
2021-11-27 20:47:57 +11:00
|
|
|
info->turnRate -= LARA_POLE_TURN_RATE;
|
|
|
|
if (info->turnRate < -LARA_POLE_TURN_MAX)
|
|
|
|
info->turnRate = -LARA_POLE_TURN_MAX;
|
2021-11-21 20:50:17 +11:00
|
|
|
}
|
|
|
|
|
2021-11-23 00:08:28 +11:00
|
|
|
if (TrInput & IN_JUMP)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE;
|
2021-11-23 00:08:28 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-01 19:54:52 +03:00
|
|
|
if (TrInput & IN_FORWARD && TestLaraPoleUp(item, coll))
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_UP;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Dispatch to freefall?
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
// State: LS_POLE_UP (100)
|
|
|
|
// Control: lara_as_pole_up()
|
|
|
|
void lara_col_pole_up(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2021-11-21 20:50:17 +11:00
|
|
|
lara_col_pole_idle(item, coll);
|
|
|
|
}
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
// State: LS_POLE_DOWN (101)
|
|
|
|
// Collision: lara_col_pole_down()
|
|
|
|
void lara_as_pole_down(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2020-09-26 05:06:08 +10:00
|
|
|
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2021-11-21 20:50:17 +11:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2020-09-26 05:06:08 +10:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->HitPoints <= 0)
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Death state dispatch.
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
2020-09-26 03:28:30 +10:00
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
// TODO: In WAD.
|
2022-02-09 16:55:46 +11:00
|
|
|
SoundEffect(SFX_TR4_LARA_POLE_LOOP, &item->Position, 0);
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
if (TrInput & IN_ACTION)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2021-11-21 20:50:17 +11:00
|
|
|
if (TrInput & IN_LEFT)
|
|
|
|
{
|
2021-11-27 20:47:57 +11:00
|
|
|
info->turnRate += LARA_POLE_TURN_RATE;
|
|
|
|
if (info->turnRate > LARA_POLE_TURN_MAX)
|
|
|
|
info->turnRate = LARA_POLE_TURN_MAX;
|
2021-11-21 20:50:17 +11:00
|
|
|
}
|
|
|
|
else if (TrInput & IN_RIGHT)
|
|
|
|
{
|
2021-11-27 20:47:57 +11:00
|
|
|
info->turnRate -= LARA_POLE_TURN_RATE;
|
|
|
|
if (info->turnRate < -LARA_POLE_TURN_MAX)
|
|
|
|
info->turnRate = -LARA_POLE_TURN_MAX;
|
2021-11-21 20:50:17 +11:00
|
|
|
}
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2021-11-23 00:08:28 +11:00
|
|
|
if (TrInput & IN_JUMP)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE;
|
2021-11-23 00:08:28 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-02 01:22:41 +03:00
|
|
|
if (TrInput & IN_BACK && TestLaraPoleDown(item, coll))
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_DOWN;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->ItemFlags[2] = 0; // Vertical velocity.
|
|
|
|
item->TargetState = LS_POLE_IDLE;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Dispatch to freefall?
|
2021-11-21 20:50:17 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
// State: LS_POLE_DOWN (101)
|
|
|
|
// Control: lara_as_pole_down()
|
|
|
|
void lara_col_pole_down(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
info->moveAngle = item->Position.yRot;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.LowerFloorBound = NO_LOWER_BOUND;
|
|
|
|
coll->Setup.UpperFloorBound = -STEPUP_HEIGHT;
|
|
|
|
coll->Setup.LowerCeilingBound = 0;
|
|
|
|
coll->Setup.FloorSlopeIsWall = true;
|
2021-11-21 20:50:17 +11:00
|
|
|
coll->Setup.ForwardAngle = info->moveAngle;
|
|
|
|
coll->Setup.Radius = LARA_RAD;
|
|
|
|
GetCollisionInfo(coll, item);
|
|
|
|
|
|
|
|
// Translate Lara down.
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->AnimNumber == LA_POLE_DOWN_END)
|
|
|
|
item->ItemFlags[2] -= WALL_SIZE;
|
2020-08-13 19:53:13 -05:00
|
|
|
else
|
2022-02-09 16:55:46 +11:00
|
|
|
item->ItemFlags[2] += STEP_SIZE;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
// Clamp speed.
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->ItemFlags[2] < 0)
|
|
|
|
item->ItemFlags[2] = 0;
|
|
|
|
else if (item->ItemFlags[2] > SHRT_MAX / 2)
|
|
|
|
item->ItemFlags[2] = SHRT_MAX / 2;
|
2020-08-13 19:53:13 -05:00
|
|
|
|
2021-12-01 19:54:52 +03:00
|
|
|
if (TestLaraPoleCollision(item, coll, false))
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.yPos += item->ItemFlags[2] >> 8;
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
if (coll->Middle.Floor < 0)
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.yPos += coll->Middle.Floor;
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
// State: LS_POLE_TURN_CLOCKWISE (102)
|
|
|
|
// Collision: lara_col_pole_turn_clockwise()
|
|
|
|
void lara_as_pole_turn_clockwise(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->HitPoints <= 0)
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Death state dispatch.
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TrInput & IN_LOOK)
|
|
|
|
LookUpDown();
|
|
|
|
|
|
|
|
if (TrInput & IN_ACTION)
|
|
|
|
{
|
2021-12-01 19:54:52 +03:00
|
|
|
if (TrInput & IN_FORWARD && TestLaraPoleUp(item, coll))
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Dispatch to climp up.
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
2021-12-01 19:54:52 +03:00
|
|
|
else if (TrInput & IN_BACK && TestLaraPoleDown(item, coll))
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Dispatch to climb down.
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TrInput & IN_LEFT)
|
|
|
|
{
|
2021-11-27 20:47:57 +11:00
|
|
|
info->turnRate += LARA_POLE_TURN_RATE;
|
|
|
|
if (info->turnRate > LARA_POLE_TURN_MAX)
|
|
|
|
info->turnRate = LARA_POLE_TURN_MAX;
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_TURN_CLOCKWISE;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Dispatch to freefall.
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
|
|
|
|
2021-11-21 20:50:17 +11:00
|
|
|
// State: LS_POLE_TURN_CLOCKWISE (102)
|
|
|
|
// Control: lara_as_pole_turn_clockwise()
|
|
|
|
void lara_col_pole_turn_clockwise(ITEM_INFO* item, COLL_INFO* coll)
|
2020-08-13 19:53:13 -05:00
|
|
|
{
|
2021-11-21 20:50:17 +11:00
|
|
|
lara_col_pole_idle(item, coll);
|
|
|
|
}
|
|
|
|
|
|
|
|
// State: LS_POLE_TURN_COUNTER_CLOCKWISE (103)
|
|
|
|
// Collision: lara_col_pole_turn_counter_clockwise()
|
|
|
|
void lara_as_pole_turn_counter_clockwise(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2021-09-10 00:20:59 +03:00
|
|
|
coll->Setup.EnableObjectPush = false;
|
2022-01-30 14:43:33 +11:00
|
|
|
coll->Setup.EnableSpasm = false;
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->HitPoints <= 0)
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Death state dispatch.
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TrInput & IN_LOOK)
|
|
|
|
LookUpDown();
|
|
|
|
|
|
|
|
if (TrInput & IN_ACTION)
|
|
|
|
{
|
2021-12-01 19:54:52 +03:00
|
|
|
if (TrInput & IN_FORWARD && TestLaraPoleUp(item, coll))
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Dispatch to climb up.
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
2021-12-01 19:54:52 +03:00
|
|
|
else if (TrInput & IN_BACK && TestLaraPoleDown(item, coll))
|
2021-11-21 20:50:17 +11:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Dispatch to climb down.
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TrInput & IN_RIGHT)
|
|
|
|
{
|
2021-11-27 20:47:57 +11:00
|
|
|
info->turnRate -= LARA_POLE_TURN_RATE;
|
|
|
|
if (info->turnRate < -LARA_POLE_TURN_MAX)
|
|
|
|
info->turnRate = -LARA_POLE_TURN_MAX;
|
2021-11-21 20:50:17 +11:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_TURN_COUNTER_CLOCKWISE;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE;
|
2021-11-21 20:50:17 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_POLE_IDLE; // TODO: Dispatch to freefall.
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
// State: LS_POLE_TURN_COUNTER_CLOCKWISE (103)
|
|
|
|
// Control: lara_col_pole_turn_counter_clockwise()
|
|
|
|
void lara_col_pole_turn_counter_clockwise(ITEM_INFO* item, COLL_INFO* coll)
|
|
|
|
{
|
|
|
|
lara_col_pole_idle(item, coll);
|
2020-08-13 19:53:13 -05:00
|
|
|
}
|
2021-11-21 20:50:17 +11:00
|
|
|
|
|
|
|
// --------
|
|
|
|
// ZIP-LINE
|
|
|
|
// --------
|
|
|
|
|
2021-02-03 01:50:59 -03:00
|
|
|
void lara_as_deathslide(ITEM_INFO* item, COLL_INFO* coll)
|
2020-09-26 03:28:30 +10:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
LaraInfo*& info = item->Data;
|
2021-11-22 22:47:34 +11:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
/*state 70*/
|
|
|
|
/*collision: lara_void_func*/
|
2020-09-26 03:28:30 +10:00
|
|
|
Camera.targetAngle = ANGLE(70.0f);
|
2020-08-14 04:08:10 -05:00
|
|
|
|
2020-09-26 05:06:08 +10:00
|
|
|
if (!(TrInput & IN_ACTION))
|
2020-08-14 04:08:10 -05:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->TargetState = LS_JUMP_FORWARD;
|
2020-08-14 04:08:10 -05:00
|
|
|
|
|
|
|
AnimateLara(item);
|
2020-09-26 03:28:30 +10:00
|
|
|
|
2022-02-09 13:20:57 +11:00
|
|
|
item->Airborne = true;
|
|
|
|
item->Velocity = 100;
|
|
|
|
item->VerticalVelocity = 40;
|
2022-02-09 16:55:46 +11:00
|
|
|
info->moveAngle = item->Position.yRot;
|
2020-08-14 04:08:10 -05:00
|
|
|
}
|
|
|
|
}
|