TombEngine/TR5Main/Game/effects/lara_fx.cpp

109 lines
2.6 KiB
C++
Raw Normal View History

2021-11-22 18:55:29 +03:00
#include "framework.h"
#include "Game/effects/lara_fx.h"
2021-12-24 03:32:19 +03:00
2022-02-07 13:06:02 +11:00
#include "Game/collision/collide_room.h"
#include "Game/collision/floordata.h"
2021-11-22 18:55:29 +03:00
#include "Game/control/control.h"
2021-12-24 03:32:19 +03:00
#include "Game/effects/effects.h"
#include "Game/effects/smoke.h"
#include "Game/items.h"
#include "Game/Lara/lara.h"
#include "Specific/level.h"
2021-11-22 18:55:29 +03:00
using namespace TEN::Effects::Smoke;
namespace TEN::Effects::Lara
{
void LaraBurn(ITEM_INFO* item)
{
if (!item->Data.is<LaraInfo*>())
2021-11-22 18:55:29 +03:00
return;
auto lara = (LaraInfo*&)item->Data;
2021-11-22 18:55:29 +03:00
if (!lara->Burn && !lara->BurnSmoke)
2021-11-22 18:55:29 +03:00
{
short fxNum = CreateNewEffect(item->RoomNumber);
2021-11-22 18:55:29 +03:00
if (fxNum != NO_ITEM)
{
EffectList[fxNum].objectNumber = ID_FLAME;
lara->Burn = true;
2021-11-22 18:55:29 +03:00
}
}
}
void LavaBurn(ITEM_INFO* item)
{
if (!item->Data.is<LaraInfo*>())
2021-11-22 18:55:29 +03:00
return;
auto lara = (LaraInfo*&)item->Data;
2021-11-22 18:55:29 +03:00
if (item->HitPoints >= 0 && lara->Control.WaterStatus != WaterStatus::FlyCheat)
2021-11-22 18:55:29 +03:00
{
short roomNumber = item->RoomNumber;
FLOOR_INFO* floor = GetFloor(item->Position.xPos, 32000, item->Position.zPos, &roomNumber);
if (item->Floor == GetFloorHeight(floor, item->Position.xPos, 32000, item->Position.zPos))
2021-11-22 18:55:29 +03:00
{
// if (Objects[ID_KAYAK].loaded && Objects[ID_KAYAK_LARA_ANIMS].loaded) //TEMPORARILY ADDING THIS HACK FOR TESTING-// KayakLaraRapidsDrown works fine.
// KayakLaraRapidsDrown();
// else
// {
item->HitPoints = -1;
item->HitStatus = true;
2021-11-22 18:55:29 +03:00
LaraBurn(item);
// }
}
}
}
void LaraBreath(ITEM_INFO* item)
{
if (!item->Data.is<LaraInfo*>())
2021-11-22 18:55:29 +03:00
return;
auto lara = (LaraInfo*&)item->Data;
2021-11-22 18:55:29 +03:00
if (lara->Control.WaterStatus == WaterStatus::Underwater || item->HitPoints <= 0)
2021-11-22 18:55:29 +03:00
return;
2022-02-07 13:06:02 +11:00
if (!TestEnvironment(ENV_FLAG_COLD, item))
2021-11-22 18:55:29 +03:00
return;
switch (item->Animation.AnimNumber)
2021-11-22 18:55:29 +03:00
{
2021-11-22 19:19:48 +03:00
case LA_STAND_IDLE:
if (item->Animation.FrameNumber < GetFrameNumber((short)ID_LARA, LA_STAND_IDLE, 30))
2021-11-22 18:55:29 +03:00
return;
break;
2021-11-22 19:19:48 +03:00
case LA_CROUCH_IDLE:
if (item->Animation.FrameNumber < GetFrameNumber((short)ID_LARA, LA_CROUCH_IDLE, 30))
2021-11-22 18:55:29 +03:00
return;
break;
2021-11-22 19:19:48 +03:00
case LA_CRAWL_IDLE:
if (item->Animation.FrameNumber < GetFrameNumber((short)ID_LARA, LA_CRAWL_IDLE, 30))
2021-11-22 18:55:29 +03:00
return;
break;
default:
if (Wibble < 0x80 || Wibble > 0xC0)
return;
}
float z = std::sin(TO_RAD(item->Position.yRot)) * -64.0f;
float x = std::cos(TO_RAD(item->Position.yRot)) * -64.0f;
2021-11-22 18:55:29 +03:00
auto offset = PHD_VECTOR(0, -4, 64);
GetLaraJointPosition(&offset, LM_HEAD);
auto seed = PHD_VECTOR((GetRandomControl() & 7) - 4,
(GetRandomControl() & 7) - 8,
(GetRandomControl() & 7) - 4);
GetLaraJointPosition(&seed, LM_HEAD);
TriggerBreathSmoke(offset.x, offset.y, offset.z, item->Position.yRot);
2021-11-22 18:55:29 +03:00
}
2022-02-07 13:06:02 +11:00
}