Adopt new GetLaraJointPosition()

This commit is contained in:
Sezz 2022-09-08 17:02:50 +10:00
parent 157511b839
commit 9fdf1be1ca
36 changed files with 468 additions and 631 deletions

View file

@ -1054,6 +1054,7 @@ void LaraGetNewTarget(ItemInfo* laraItem, WeaponInfo* weaponInfo)
int x = item->Pose.Position.x - origin.x;
int y = item->Pose.Position.y - origin.y;
int z = item->Pose.Position.z - origin.z;
if (abs(x) <= maxDistance &&
abs(y) <= maxDistance &&
abs(z) <= maxDistance)
@ -1063,6 +1064,7 @@ void LaraGetNewTarget(ItemInfo* laraItem, WeaponInfo* weaponInfo)
{
auto target = GameVector::Zero;
FindTargetPoint(item, &target);
if (LOS(&origin, &target))
{
auto orient = Geometry::GetOrientTowardPoint(origin.ToVector3(), target.ToVector3());

View file

@ -296,8 +296,7 @@ void CreateFlare(ItemInfo* laraItem, GAME_OBJECT_ID objectNumber, bool thrown)
flareItem->ObjectNumber = objectNumber;
flareItem->RoomNumber = laraItem->RoomNumber;
auto pos = Vector3i(-16, 32, 42);
GetLaraJointPosition(&pos, LM_LHAND);
auto pos = GetLaraJointPosition(LM_LHAND, Vector3i(-16, 32, 42));
flareItem->Pose.Position = pos;
@ -368,8 +367,7 @@ void DoFlareInHand(ItemInfo* laraItem, int flareLife)
{
auto* lara = GetLaraInfo(laraItem);
auto pos = Vector3i(11, 32, 41);
GetLaraJointPosition(&pos, LM_LHAND);
auto pos = GetLaraJointPosition(LM_LHAND, Vector3i(11, 32, 41));
if (DoFlareLight(&pos, flareLife))
TriggerChaffEffects(flareLife);
@ -391,10 +389,10 @@ void DoFlareInHand(ItemInfo* laraItem, int flareLife)
lara->Flare.Life++;
}
int DoFlareLight(Vector3i* pos, int flareLife)
bool DoFlareLight(Vector3i* pos, int flareLife)
{
if (flareLife >= FLARE_LIFE_MAX || flareLife == 0)
return 0;
return false;
float random = GenerateFloat();
@ -443,5 +441,5 @@ int DoFlareLight(Vector3i* pos, int flareLife)
result = (random < 0.3f);
}
return (dying || ending ? result : true);
return ((dying || ending) ? result : true);
}

View file

@ -16,4 +16,4 @@ void SetFlareArm(ItemInfo* laraItem, int armFrame);
void CreateFlare(ItemInfo* laraItem, GAME_OBJECT_ID objectNumber, bool thrown);
void DrawFlareInAir(ItemInfo* flareItem);
void DoFlareInHand(ItemInfo* laraItem, int flareLife);
int DoFlareLight(Vector3i* pos, int flareLife);
bool DoFlareLight(Vector3i* pos, int flareLife);

View file

@ -56,7 +56,7 @@ void AnimateShotgun(ItemInfo* laraItem, LaraWeaponType weaponType)
else if (weaponType == LaraWeaponType::RocketLauncher)
pos = Vector3i(0, 84, 72);
GetLaraJointPosition(&pos, LM_RHAND);
pos = GetLaraJointPosition(LM_RHAND, pos);
if (laraItem->MeshBits)
TriggerGunSmoke(pos.x, pos.y, pos.z, 0, 0, 0, 0, weaponType, lara->LeftArm.GunSmoke);
@ -296,28 +296,23 @@ void FireShotgun(ItemInfo* laraItem)
}
int value = (lara->Weapons[(int)LaraWeaponType::Shotgun].SelectedAmmo == WeaponAmmoType::Ammo1 ? 1820 : 5460);
bool fired = false;
bool hasFired = false;
for (int i = 0; i < 6; i++)
{
auto wobbleArmOrient = EulerAngles(
auto wobbledArmOrient = EulerAngles(
armOrient.x + value * (GetRandomControl() - ANGLE(90.0f)) / 65536,
armOrient.y + value * (GetRandomControl() - ANGLE(90.0f)) / 65536,
0
);
if (FireWeapon(LaraWeaponType::Shotgun, lara->TargetEntity, laraItem, wobbleArmOrient) != FireWeaponType::NoAmmo)
fired = true;
if (FireWeapon(LaraWeaponType::Shotgun, lara->TargetEntity, laraItem, wobbledArmOrient) != FireWeaponType::NoAmmo)
hasFired = true;
}
if (fired)
if (hasFired)
{
auto pos = Vector3i(0, 228, 32);
GetLaraJointPosition(&pos, LM_RHAND);
auto pos2 = pos;
pos = Vector3i(0, 1508, 32);
GetLaraJointPosition(&pos, LM_RHAND);
auto pos = GetLaraJointPosition(LM_RHAND, Vector3i(0, 1508, 32));
auto pos2 = GetLaraJointPosition(LM_RHAND, Vector3i(0, 228, 32));
lara->LeftArm.GunSmoke = 32;
@ -450,7 +445,7 @@ void FireHarpoon(ItemInfo* laraItem)
lara->Control.Weapon.HasFired = true;
// Create a new item for harpoon
// Create a new item for harpoon.
short itemNumber = CreateItem();
if (itemNumber != NO_ITEM)
{
@ -463,8 +458,7 @@ void FireHarpoon(ItemInfo* laraItem)
item->ObjectNumber = ID_HARPOON;
item->RoomNumber = laraItem->RoomNumber;
auto jointPos = Vector3i(-2, 373, 77);
GetLaraJointPosition(&jointPos, LM_RHAND);
auto jointPos = GetLaraJointPosition(LM_RHAND, Vector3i(-2, 373, 77));
int floorHeight = GetCollision(jointPos.x, jointPos.y, jointPos.z, item->RoomNumber).Position.Floor;
if (floorHeight >= jointPos.y)
@ -656,7 +650,7 @@ void FireGrenade(ItemInfo* laraItem)
int y = 0;
int z = 0;
Ammo& ammo = GetAmmo(laraItem, LaraWeaponType::GrenadeLauncher);
auto& ammo = GetAmmo(laraItem, LaraWeaponType::GrenadeLauncher);
if (!ammo)
return;
@ -671,8 +665,7 @@ void FireGrenade(ItemInfo* laraItem)
item->ObjectNumber = ID_GRENADE;
item->RoomNumber = laraItem->RoomNumber;
auto jointPos = Vector3i(0, 276, 80);
GetLaraJointPosition(&jointPos, LM_RHAND);
auto jointPos = GetLaraJointPosition(LM_RHAND, Vector3i(0, 276, 80));
item->Pose.Position.x = x = jointPos.x;
item->Pose.Position.y = y = jointPos.y;
@ -687,8 +680,7 @@ void FireGrenade(ItemInfo* laraItem)
item->RoomNumber = laraItem->RoomNumber;
}
jointPos = Vector3i(0, 1204, 5);
GetLaraJointPosition(&jointPos, LM_RHAND);
jointPos = GetLaraJointPosition(LM_RHAND, Vector3i(0, 1204, 5));
lara->LeftArm.GunSmoke = 32;
@ -1100,24 +1092,21 @@ void FireRocket(ItemInfo* laraItem)
if (!ammos.hasInfinite())
(ammos)--;
auto jointPos = Vector3i(0, 180, 72);
GetLaraJointPosition(&jointPos, LM_RHAND);
auto jointPos = GetLaraJointPosition(LM_RHAND, Vector3i(0, 180, 72));
int x, y, z;
item->Pose.Position.x = x = jointPos.x;
item->Pose.Position.y = y = jointPos.y;
item->Pose.Position.z = z = jointPos.z;
jointPos = Vector3i(0, 2004, 72);
GetLaraJointPosition(&jointPos, LM_RHAND);
jointPos = GetLaraJointPosition(LM_RHAND, Vector3i(0, 2004, 72));
lara->LeftArm.GunSmoke = 32;
for (int i = 0; i < 5; i++)
TriggerGunSmoke(x, y, z, jointPos.x - x, jointPos.y - y, jointPos.z - z, 1, LaraWeaponType::RocketLauncher, lara->LeftArm.GunSmoke);
jointPos = Vector3i(0, -256, 0);
GetLaraJointPosition(&jointPos, LM_RHAND);
jointPos = GetLaraJointPosition(LM_RHAND, Vector3i(0, -CLICK(1), 0));
for (int i = 0; i < 10; i++)
TriggerGunSmoke(jointPos.x, jointPos.y, jointPos.z, jointPos.x - x, jointPos.y - y, jointPos.z - z, 2, LaraWeaponType::RocketLauncher, 32);
@ -1397,8 +1386,7 @@ void FireCrossbow(ItemInfo* laraItem, PoseData* pos)
}
else
{
auto jointPos = Vector3i(0, 228, 32);
GetLaraJointPosition(&jointPos, LM_RHAND);
auto jointPos = GetLaraJointPosition(LM_RHAND, Vector3i(0, 228, 32));
item->RoomNumber = laraItem->RoomNumber;
@ -1736,9 +1724,7 @@ void RifleHandler(ItemInfo* laraItem, LaraWeaponType weaponType)
{
if (weaponType == LaraWeaponType::Shotgun || weaponType == LaraWeaponType::HK)
{
auto pos = Vector3i::Zero;
pos.y = -64;
GetLaraJointPosition(&pos, LM_RHAND);
auto pos = GetLaraJointPosition(LM_RHAND, Vector3i(0, -64, 0));
TriggerDynamicLight(
pos.x, pos.y, pos.z,
12,
@ -1749,9 +1735,7 @@ void RifleHandler(ItemInfo* laraItem, LaraWeaponType weaponType)
}
else if (weaponType == LaraWeaponType::Revolver)
{
auto pos = Vector3i::Zero;
pos.y = -32;
GetLaraJointPosition(&pos, LM_RHAND);
auto pos = GetLaraJointPosition(LM_RHAND, Vector3i(0, -32, 0));
TriggerDynamicLight(pos.x, pos.y, pos.z, 12, (GetRandomControl() & 0x3F) + 192, (GetRandomControl() & 0x1F) + 128, (GetRandomControl() & 0x3F));
}
}

View file

@ -48,46 +48,45 @@ void AnimatePistols(ItemInfo* laraItem, LaraWeaponType weaponType)
{
if (lara->LeftArm.GunSmoke)
{
Vector3i pos;
auto offset = Vector3i::Zero;
switch (weaponType)
{
case LaraWeaponType::Pistol:
pos = { 4, 128, 40 };
offset = Vector3i(4, 128, 40);
break;
case LaraWeaponType::Revolver:
pos = { 16, 160, 56 };
offset = Vector3i(16, 160, 56);
break;
case LaraWeaponType::Uzi:
pos = { 8, 140, 48 };
offset = Vector3i(8, 140, 48);
break;
}
GetLaraJointPosition(&pos, LM_LHAND);
auto pos = GetLaraJointPosition(LM_LHAND, offset);
TriggerGunSmoke(pos.x, pos.y, pos.z, 0, 0, 0, 0, weaponType, lara->LeftArm.GunSmoke);
}
if (lara->RightArm.GunSmoke)
{
Vector3i pos;
auto offset = Vector3i::Zero;
switch (weaponType)
{
case LaraWeaponType::Pistol:
pos = { -16, 128, 40 };
offset = Vector3i(-16, 128, 40);
break;
case LaraWeaponType::Revolver:
pos = { -32, 160, 56 };
offset = Vector3i(-32, 160, 56);
break;
case LaraWeaponType::Uzi:
pos = { -16, 140, 48 };
offset = Vector3i(-16, 140, 48);
break;
}
GetLaraJointPosition(&pos, LM_RHAND);
auto pos = GetLaraJointPosition(LM_RHAND, offset);
TriggerGunSmoke(pos.x, pos.y, pos.z, 0, 0, 0, 0, weaponType, lara->RightArm.GunSmoke);
}
}
@ -315,12 +314,13 @@ void PistolHandler(ItemInfo* laraItem, LaraWeaponType weaponType)
if (lara->LeftArm.GunFlash || lara->RightArm.GunFlash)
{
Vector3i pos;
pos.x = (byte)GetRandomControl() - 128;
pos.y = (GetRandomControl() & 0x7F) - 63;
pos.z = (byte)GetRandomControl() - 128;
GetLaraJointPosition(&pos, lara->LeftArm.GunFlash != 0 ? LM_LHAND : LM_RHAND);
auto pos = GetLaraJointPosition(
(lara->LeftArm.GunFlash != 0) ? LM_LHAND : LM_RHAND,
Vector3i(
(byte)GetRandomControl() - 128,
(GetRandomControl() & 0x7F) - 63,
(byte)GetRandomControl() - 128
));
TriggerDynamicLight(pos.x+GenerateFloat(-128,128), pos.y + GenerateFloat(-128, 128), pos.z + GenerateFloat(-128, 128), GenerateFloat(8,11), (GetRandomControl() & 0x3F) + 192, (GetRandomControl() & 0x1F) + 128, GetRandomControl() & 0x3F);
}
}

View file

@ -575,21 +575,13 @@ void ClampRotation(PoseData* pose, short angle, short rotation)
}
Vector3i GetLaraJointPosition(int jointIndex, const Vector3i& offset)
{
auto pos = offset;
GetLaraJointPosition(&pos, jointIndex);
return pos;
}
void GetLaraJointPosition(Vector3i* offset, int jointIndex)
{
if (jointIndex >= NUM_LARA_MESHES)
jointIndex = LM_HEAD;
auto pos = offset->ToVector3();
auto pos = offset.ToVector3();
g_Renderer.GetLaraAbsBonePosition(&pos, jointIndex);
*offset = Vector3i(pos);
return Vector3i(pos);
}
Vector3i GetJointAbsPosition(ItemInfo* item, int jointIndex, Vector3i offset)

View file

@ -98,6 +98,5 @@ void ClampRotation(PoseData* pose, short angle, short rotation);
void DrawAnimatingItem(ItemInfo* item);
Vector3i GetLaraJointPosition(int jointIndex, const Vector3i& offset = Vector3i::Zero);
void GetLaraJointPosition(Vector3i* offset, int jointIndex);
Vector3i GetJointAbsPosition(ItemInfo* item, int jointIndex, Vector3i offset = Vector3i::Zero);
void GetJointAbsPosition(ItemInfo* item, Vector3i* vec, int jointIndex);
void GetJointAbsPosition(ItemInfo* item, Vector3i* offset, int jointIndex);

View file

@ -460,14 +460,9 @@ void UpdateCameraElevation()
if (Camera.laraNode != -1)
{
auto pos = Vector3i::Zero;
GetLaraJointPosition(&pos, Camera.laraNode);
auto pos1 = Vector3i(0, -CLICK(1), SECTOR(2));
GetLaraJointPosition(&pos1, Camera.laraNode);
pos.x = pos1.x - pos.x;
pos.z = pos1.z - pos.z;
auto pos = GetLaraJointPosition(Camera.laraNode, Vector3i::Zero);
auto pos1 = GetLaraJointPosition(Camera.laraNode, Vector3i(0, -CLICK(1), SECTOR(2)));
pos = pos1 - pos;
Camera.actualAngle = Camera.targetAngle + phd_atan(pos.z, pos.x);
}
else
@ -779,7 +774,7 @@ void FixedCamera(ItemInfo* item)
}
else
{
LEVEL_CAMERA_INFO* camera = &g_Level.Cameras[Camera.number];
auto* camera = &g_Level.Cameras[Camera.number];
from.x = camera->x;
from.y = camera->y;
@ -834,8 +829,7 @@ void LookCamera(ItemInfo* item)
else
OldCam.pos.Orientation.y = lara->ExtraHeadRot.y;
Vector3i pos = { 0, (int)CLICK(0.25f) / 4, (int)CLICK(0.25f) };
GetLaraJointPosition(&pos, LM_HEAD);
auto pos = GetLaraJointPosition(LM_HEAD, Vector3i(0, CLICK(0.25f) / 4, CLICK(0.25f)));
auto probe = GetCollision(pos.x, pos.y, pos.z, item->RoomNumber);
if (probe.Position.Floor == NO_HEIGHT ||
@ -844,8 +838,7 @@ void LookCamera(ItemInfo* item)
pos.y > probe.Position.Floor ||
pos.y < probe.Position.Ceiling)
{
pos = { 0, (int)CLICK(0.25f) / 4 , 0 };
GetLaraJointPosition(&pos, LM_HEAD);
pos = GetLaraJointPosition(LM_HEAD, Vector3i(0, CLICK(0.25f) / 4, 0));
probe = GetCollision(pos.x, pos.y + CLICK(1), pos.z, item->RoomNumber);
if (TestEnvironment(ENV_FLAG_SWAMP, probe.RoomNumber))
@ -862,18 +855,12 @@ void LookCamera(ItemInfo* item)
pos.y > probe.Position.Floor ||
pos.y < probe.Position.Ceiling)
{
pos.x = 0;
pos.y = CLICK(0.25f) / 4;
pos.z = -CLICK(0.25f);
GetLaraJointPosition(&pos, LM_HEAD);
pos = GetLaraJointPosition(LM_HEAD, Vector3i(0, CLICK(0.25f) / 4, -CLICK(0.25f)));
}
}
Vector3i pos2 = { 0, 0, -SECTOR(1) };
GetLaraJointPosition(&pos2, LM_HEAD);
Vector3i pos3 = { 0, 0, CLICK(8) };
GetLaraJointPosition(&pos3, LM_HEAD);
auto pos2 = GetLaraJointPosition(LM_HEAD, Vector3i(0, 0, -SECTOR(1)));
auto pos3 = GetLaraJointPosition(LM_HEAD, Vector3i(0, 0, CLICK(8)));
int dx = (pos2.x - pos.x) >> 3;
int dy = (pos2.y - pos.y) >> 3;
@ -882,12 +869,12 @@ void LookCamera(ItemInfo* item)
int y = pos.y;
int z = pos.z;
int roomNum;
int roomNumber;
probe.RoomNumber = item->RoomNumber;
int i = 0;
for (i = 0; i < 8; i++)
{
roomNum = probe.RoomNumber;
roomNumber = probe.RoomNumber;
probe = GetCollision(x, y + CLICK(1), z, probe.RoomNumber);
if (TestEnvironment(ENV_FLAG_SWAMP, probe.RoomNumber))
{
@ -918,8 +905,7 @@ void LookCamera(ItemInfo* item)
z -= dz;
}
GameVector ideal = { x, y, z };
ideal.roomNumber = roomNum;
auto ideal = GameVector(x, y, z, roomNumber);
if (OldCam.pos.Orientation.x == lara->ExtraHeadRot.x &&
OldCam.pos.Orientation.y == lara->ExtraHeadRot.y &&
@ -1382,8 +1368,7 @@ void BinocularCamera(ItemInfo* item)
void ConfirmCameraTargetPos()
{
auto pos = Vector3i::Zero;
GetLaraJointPosition(&pos, LM_TORSO);
auto pos = GetLaraJointPosition(LM_TORSO);
if (Camera.laraNode != -1)
{

View file

@ -1445,6 +1445,11 @@ bool TestEnvironment(RoomEnvFlags environmentType, int x, int y, int z, int room
return TestEnvironment(environmentType, GetCollision(x, y, z, roomNumber).RoomNumber);
}
bool TestEnvironment(RoomEnvFlags environmentType, Vector3i pos, int roomNumber)
{
return TestEnvironment(environmentType, GetCollision(pos.x, pos.y, pos.z, roomNumber).RoomNumber);
}
bool TestEnvironment(RoomEnvFlags environmentType, ItemInfo* item)
{
return TestEnvironment(environmentType, item->RoomNumber);

View file

@ -155,6 +155,7 @@ void SnapItemToGrid(ItemInfo* item, CollisionInfo* coll);
void AlignEntityToSurface(ItemInfo* item, Vector2 radius, float tiltConstraintAngle = 45.0f, EulerAngles tiltOffset = EulerAngles::Zero);
bool TestEnvironment(RoomEnvFlags environmentType, int x, int y, int z, int roomNumber);
bool TestEnvironment(RoomEnvFlags environmentType, Vector3i pos, int roomNumber);
bool TestEnvironment(RoomEnvFlags environmentType, ItemInfo* item);
bool TestEnvironment(RoomEnvFlags environmentType, int roomNumber);
bool TestEnvironment(RoomEnvFlags environmentType, ROOM_INFO* room);

View file

@ -16,57 +16,33 @@
#include "Renderer/Renderer11Enums.h"
#include "Sound/sound.h"
#define MAX_TRIGGER_RANGE 0x4000
using namespace TEN::Math::Random;
#define MAX_TRIGGER_RANGE 0x4000
void TriggerChaffEffects(int flareAge)
{
Vector3i vect;
vect.x = 8;
vect.y = 36;
vect.z = 32;
GetLaraJointPosition(&vect, LM_LHAND);
Vector3i pos;
pos.x = vect.x;
pos.y = vect.y;
pos.z = vect.z;
vect.x = 8;
vect.y = 36;
vect.z = 1024 + (GetRandomDraw() & 255);
GetLaraJointPosition(&vect, LM_LHAND);
Vector3i vel;
vel.x = vect.x - pos.x;
vel.y = vect.y - pos.y;
vel.z = vect.z - pos.z;
auto pos = GetLaraJointPosition(LM_LHAND, Vector3i(8, 36, 32));
auto vect = GetLaraJointPosition(LM_LHAND, Vector3i(8, 36, 1024 + (GetRandomDraw() & 255)));
auto vel = vect - pos;
TriggerChaffEffects(LaraItem, &pos, &vel, LaraItem->Animation.Velocity.z, (bool)(g_Level.Rooms[LaraItem->RoomNumber].flags & ENV_FLAG_WATER), flareAge);
}
void TriggerChaffEffects(ItemInfo* Item, int age)
void TriggerChaffEffects(ItemInfo* item, int age)
{
Matrix world
= Matrix::CreateTranslation(-6, 6, 32)
* Matrix::CreateFromYawPitchRoll(TO_RAD(Item->Pose.Orientation.y), TO_RAD(Item->Pose.Orientation.x), TO_RAD(Item->Pose.Orientation.z));
Matrix world =
Matrix::CreateTranslation(-6, 6, 32) *
Matrix::CreateFromYawPitchRoll(TO_RAD(item->Pose.Orientation.y), TO_RAD(item->Pose.Orientation.x), TO_RAD(item->Pose.Orientation.z));
Vector3i pos;
pos.x = Item->Pose.Position.x + world.Translation().x;
pos.y = Item->Pose.Position.y + world.Translation().y;
pos.z = Item->Pose.Position.z + world.Translation().z;
auto pos = item->Pose.Position + Vector3i(world.Translation());
world
= Matrix::CreateTranslation(-6, 6, 32)
* Matrix::CreateTranslation((GetRandomDraw() & 127) - 64, (GetRandomDraw() & 127) - 64, (GetRandomDraw() & 511) + 512)
* Matrix::CreateFromYawPitchRoll(TO_RAD(Item->Pose.Orientation.y), TO_RAD(Item->Pose.Orientation.x), TO_RAD(Item->Pose.Orientation.z));
world =
Matrix::CreateTranslation(-6, 6, 32) *
Matrix::CreateTranslation((GetRandomDraw() & 127) - 64, (GetRandomDraw() & 127) - 64, (GetRandomDraw() & 511) + 512) *
Matrix::CreateFromYawPitchRoll(TO_RAD(item->Pose.Orientation.y), TO_RAD(item->Pose.Orientation.x), TO_RAD(item->Pose.Orientation.z));
Vector3i vel;
vel.x = world.Translation().x;
vel.y = world.Translation().y;
vel.z = world.Translation().z;
TriggerChaffEffects(Item, &pos, &vel, Item->Animation.Velocity.z, (bool)(g_Level.Rooms[Item->RoomNumber].flags & ENV_FLAG_WATER), age);
auto vel = Vector3i(world.Translation());
TriggerChaffEffects(item, &pos, &vel, item->Animation.Velocity.z, TestEnvironment(ENV_FLAG_WATER, item), age);
}
void TriggerChaffEffects(ItemInfo* item, Vector3i* pos, Vector3i* vel, int speed, bool isUnderwater, int age)
@ -92,24 +68,24 @@ void TriggerChaffEffects(ItemInfo* item, Vector3i* pos, Vector3i* vel, int speed
TriggerChaffBubbles(pos, item->RoomNumber);
else
{
Vector3 position = Vector3(pos->x,pos->y,pos->z);
auto position = Vector3(pos->x, pos->y, pos->z);
Vector3 direction = Vector3(vel->x, vel->y, vel->z);
direction.Normalize();
TEN::Effects::Smoke::TriggerFlareSmoke(position+(direction*20), direction,age,item->RoomNumber);
TEN::Effects::Smoke::TriggerFlareSmoke(position + direction * 20, direction, age, item->RoomNumber);
}
}
PoseData position = item->Pose;
auto pose = item->Pose;
if (item->IsLara())
{
Vector3i handPos = {};
auto handPos = Vector3i::Zero;
GetJointAbsPosition(item, &handPos, LM_RHAND);
position.Position = handPos;
position.Position.y -= 64;
pose.Position = handPos;
pose.Position.y -= 64;
}
auto cond = TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, position.Position.x, position.Position.y, position.Position.z, item->RoomNumber);
SoundEffect(cond ? SFX_TR4_FLARE_BURN_UNDERWATER : SFX_TR4_FLARE_BURN_DRY, &position, SoundEnvironment::Always, 1.0f, 0.5f);
auto cond = TestEnvironment(RoomEnvFlags::ENV_FLAG_WATER, pose.Position, item->RoomNumber);
SoundEffect(cond ? SFX_TR4_FLARE_BURN_UNDERWATER : SFX_TR4_FLARE_BURN_DRY, &pose, SoundEnvironment::Always, 1.0f, 0.5f);
}
void TriggerChaffSparkles(Vector3i* pos, Vector3i* vel, CVECTOR* color, int age, ItemInfo* item)

View file

@ -3,15 +3,10 @@
#include "Game/items.h"
void TriggerChaffEffects(int age);
void TriggerChaffEffects(ItemInfo* Item,int age);
void TriggerChaffEffects(ItemInfo* Item, Vector3i* pos, Vector3i* vel, int speed, bool isUnderwater,int age);
void TriggerChaffSparkles(Vector3i* pos, Vector3i* vel, CVECTOR* color,int age,ItemInfo* item);
void TriggerChaffEffects(ItemInfo* item, int age);
void TriggerChaffEffects(ItemInfo* item, Vector3i* pos, Vector3i* vel, int speed, bool isUnderwater, int age);
void TriggerChaffSparkles(Vector3i* pos, Vector3i* vel, CVECTOR* color, int age, ItemInfo* item);
void TriggerChaffSmoke(Vector3i* pos, Vector3i* vel, int speed, bool moving, bool wind);
void TriggerChaffBubbles(Vector3i* pos, int FlareRoomNumber);
/* void TriggerChaffEffects(ItemInfo* item, PoseData pos, short angle, int speed, bool underwater);

View file

@ -1046,12 +1046,12 @@ void TriggerLaraBlood()
{
if (node & LaraItem->TouchBits)
{
Vector3i vec;
vec.x = (GetRandomControl() & 31) - 16;
vec.y = (GetRandomControl() & 31) - 16;
vec.z = (GetRandomControl() & 31) - 16;
GetLaraJointPosition(&vec, (LARA_MESHES)i);
auto vec = GetLaraJointPosition(
i,
Vector3i(
(GetRandomControl() & 31) - 16,
(GetRandomControl() & 31) - 16,
(GetRandomControl() & 31) - 16));
DoBloodSplat(vec.x, vec.y, vec.z, (GetRandomControl() & 7) + 8, 2 * GetRandomControl(), LaraItem->RoomNumber);
}

View file

@ -13,7 +13,7 @@ namespace TEN::Effects::Footprints
{
std::deque<FOOTPRINT_STRUCT> footprints = std::deque<FOOTPRINT_STRUCT>();
bool CheckFootOnFloor(ItemInfo const & item, int mesh, Vector3& outFootprintPosition)
bool CheckFootOnFloor(const ItemInfo& item, int mesh, Vector3& outFootprintPosition)
{
int x = item.Pose.Position.x;
int y = item.Pose.Position.y;
@ -21,10 +21,8 @@ namespace TEN::Effects::Footprints
short roomNumber = item.RoomNumber;
auto floor = GetFloor(x, y, z, &roomNumber);
auto pos = Vector3i(0, FOOT_HEIGHT_OFFSET, 0);
GetLaraJointPosition(&pos, mesh);
int height = GetFloorHeight(floor, pos.x, pos.y - STEP_SIZE, pos.z);
auto pos = GetLaraJointPosition(mesh, Vector3i(0, FOOT_HEIGHT_OFFSET, 0));
int height = GetFloorHeight(floor, pos.x, pos.y - CLICK(1), pos.z);
outFootprintPosition.x = pos.x;
outFootprintPosition.y = height - 8;

View file

@ -22,7 +22,7 @@ namespace TEN::Effects::Footprints
};
extern std::deque<FOOTPRINT_STRUCT> footprints;
bool CheckFootOnFloor(ItemInfo const & item, int mesh, Vector3& outFootprintPosition);
bool CheckFootOnFloor(const ItemInfo& item, int mesh, Vector3& outFootprintPosition);
void AddFootprint(ItemInfo* item, bool rightFoot);
void UpdateFootprints();
}

View file

@ -100,22 +100,18 @@ void HairControl(ItemInfo* item, int ponytail, ANIM_FRAME* framePtr)
frame = GetBestFrame(item);
}
else
{
frame = framePtr;
}
// Get Lara's spheres in absolute coords, for head, torso, hips and upper arms
MESH* mesh = &g_Level.Meshes[lara->MeshPtrs[LM_HIPS]];
Vector3i pos = { (int)mesh->sphere.Center.x, (int)mesh->sphere.Center.y, (int)mesh->sphere.Center.z };
GetLaraJointPosition(&pos, LM_HIPS);
// Get Lara's spheres in absolute coordinates for head, torso, hips, and upper arms.
auto* mesh = &g_Level.Meshes[lara->MeshPtrs[LM_HIPS]];
auto pos = GetLaraJointPosition(LM_HIPS, Vector3i(mesh->sphere.Center.x, mesh->sphere.Center.y, mesh->sphere.Center.z));
sphere[0].x = pos.x;
sphere[0].y = pos.y;
sphere[0].z = pos.z;
sphere[0].r = (int)mesh->sphere.Radius;
mesh = &g_Level.Meshes[lara->MeshPtrs[LM_TORSO]];
pos = { (int)mesh->sphere.Center.x - 10, (int)mesh->sphere.Center.y, (int)mesh->sphere.Center.z + 25 }; // Repositioning sphere - from tomb5
GetLaraJointPosition(&pos, LM_TORSO);
pos = GetLaraJointPosition(LM_TORSO, Vector3i(mesh->sphere.Center.x - 10, mesh->sphere.Center.y, mesh->sphere.Center.z + 25));
sphere[1].x = pos.x;
sphere[1].y = pos.y;
sphere[1].z = pos.z;
@ -124,28 +120,25 @@ void HairControl(ItemInfo* item, int ponytail, ANIM_FRAME* framePtr)
sphere[1].r = sphere[1].r - ((sphere[1].r >> 2) + (sphere[1].r >> 3));
mesh = &g_Level.Meshes[lara->MeshPtrs[LM_HEAD]];
pos = { (int)mesh->sphere.Center.x - 2, (int)mesh->sphere.Center.y, (int)mesh->sphere.Center.z }; // Repositioning sphere - from tomb5
GetLaraJointPosition(&pos, LM_HEAD);
pos = GetLaraJointPosition(LM_HEAD, Vector3i(mesh->sphere.Center.x - 2, mesh->sphere.Center.y, mesh->sphere.Center.z));
sphere[2].x = pos.x;
sphere[2].y = pos.y;
sphere[2].z = pos.z;
sphere[2].r = (int)mesh->sphere.Radius;
mesh = &g_Level.Meshes[lara->MeshPtrs[LM_RINARM]];
pos = { (int)mesh->sphere.Center.x, (int)mesh->sphere.Center.y, (int)mesh->sphere.Center.z };
GetLaraJointPosition(&pos, LM_RINARM);
pos = GetLaraJointPosition(LM_RINARM, Vector3i(mesh->sphere.Center.x, mesh->sphere.Center.y, mesh->sphere.Center.z));
sphere[3].x = pos.x;
sphere[3].y = pos.y;
sphere[3].z = pos.z;
sphere[3].r = (int)(4.0f * mesh->sphere.Radius / 3.0f); // Resizing sphere - from tomb5
sphere[3].r = int(4.0f * mesh->sphere.Radius / 3.0f); // Resizing sphere - from tomb5
mesh = &g_Level.Meshes[lara->MeshPtrs[LM_LINARM]];
pos = { (int)mesh->sphere.Center.x, (int)mesh->sphere.Center.y, (int)mesh->sphere.Center.z };
GetLaraJointPosition(&pos, LM_LINARM);
pos = GetLaraJointPosition(LM_LINARM, Vector3i(mesh->sphere.Center.x, mesh->sphere.Center.y, mesh->sphere.Center.z));
sphere[4].x = pos.x;
sphere[4].y = pos.y;
sphere[4].z = pos.z;
sphere[4].r = (int)(4.0f * mesh->sphere.Radius / 3.0f); // Resizing sphere - from tomb5
sphere[4].r = int(4.0f * mesh->sphere.Radius / 3.0f); // Resizing sphere - from tomb5
if (youngLara)
{
@ -158,23 +151,17 @@ void HairControl(ItemInfo* item, int ponytail, ANIM_FRAME* framePtr)
sphere[5].x = (2 * sphere[2].x + sphere[1].x) / 3;
sphere[5].y = (2 * sphere[2].y + sphere[1].y) / 3;
sphere[5].z = (2 * sphere[2].z + sphere[1].z) / 3;
sphere[5].r = youngLara ? 0 : (int)(3.0f * (float)sphere[2].r / 4.0f);
sphere[5].r = youngLara ? 0 : int(3.0f * (float)sphere[2].r / 4.0f);
Matrix world;
g_Renderer.GetBoneMatrix(lara->ItemNumber, LM_HEAD, &world);
if (ponytail)
{
world = Matrix::CreateTranslation(44, -48, -50) * world;
}
else if (youngLara)
{
world = Matrix::CreateTranslation(-52, -48, -50) * world;
}
else
{
world = Matrix::CreateTranslation(-4, -4, -48) * world;
}
pos.x = world.Translation().x;
pos.y = world.Translation().y;
@ -232,7 +219,7 @@ void HairControl(ItemInfo* item, int ponytail, ANIM_FRAME* framePtr)
if (dryMode)
{
if (g_Level.Rooms[roomNumber].flags & ENV_FLAG_WIND)
if (TestEnvironment(ENV_FLAG_WIND, roomNumber))
{
Hairs[ponytail][i].pos.Position.x += Weather.Wind().x * 2.0f;
Hairs[ponytail][i].pos.Position.z += Weather.Wind().z * 2.0f;
@ -241,9 +228,7 @@ void HairControl(ItemInfo* item, int ponytail, ANIM_FRAME* framePtr)
Hairs[ponytail][i].pos.Position.y += 10;
if (wh != NO_HEIGHT && Hairs[ponytail][i].pos.Position.y > wh)
{
Hairs[ponytail][i].pos.Position.y = wh;
}
else if (Hairs[ponytail][i].pos.Position.y > height)
{
Hairs[ponytail][i].pos.Position.x = Hairs[ponytail][0].hvel.x;

View file

@ -87,15 +87,14 @@ namespace TEN::Effects::Lara
float z = std::sin(TO_RAD(item->Pose.Orientation.y)) * -64.0f;
float x = std::cos(TO_RAD(item->Pose.Orientation.y)) * -64.0f;
auto offset = Vector3i(0, -4, 64);
auto offset = GetLaraJointPosition(LM_HEAD, Vector3i(0, -4, 64));
GetLaraJointPosition(&offset, LM_HEAD);
auto seed = GetLaraJointPosition(
LM_HEAD,
Vector3i((GetRandomControl() & 7) - 4,
(GetRandomControl() & 7) - 8,
(GetRandomControl() & 7) - 4));
auto seed = Vector3i((GetRandomControl() & 7) - 4,
(GetRandomControl() & 7) - 8,
(GetRandomControl() & 7) - 4);
GetLaraJointPosition(&seed, LM_HEAD);
TriggerBreathSmoke(offset.x, offset.y, offset.z, item->Pose.Orientation.y);
}
}

View file

@ -933,63 +933,45 @@ int GetFreeGunshell()
void TriggerGunShell(short hand, short objNum, LaraWeaponType weaponType)
{
Vector3i pos;
auto pos = Vector3i::Zero;
if (hand)
{
auto offset = Vector3i::Zero;
switch (weaponType)
{
case LaraWeaponType::Pistol:
pos.x = 8;
pos.y = 48;
pos.z = 40;
offset = Vector3i(8, 48, 40);
break;
case LaraWeaponType::Uzi:
pos.x = 8;
pos.y = 35;
pos.z = 48;
offset = Vector3i(8, 35, 48);
break;
case LaraWeaponType::Shotgun:
pos.x = 16;
pos.y = 114;
pos.z = 32;
offset = Vector3i(16, 114, 32);
break;
case LaraWeaponType::HK:
pos.x = 16;
pos.y = 114;
pos.z = 96;
offset = Vector3i(16, 114, 96);
break;
default:
break;
}
GetLaraJointPosition(&pos, LM_RHAND);
pos = GetLaraJointPosition(LM_RHAND, offset);
}
else
{
if (weaponType == LaraWeaponType::Pistol)
{
pos.x = -12;
pos.y = 48;
pos.z = 40;
GetLaraJointPosition(&pos, LM_LHAND);
}
pos = GetLaraJointPosition(LM_LHAND, Vector3i(-12, 48, 40));
else if (weaponType == LaraWeaponType::Uzi)
{
pos.x = -16;
pos.y = 35;
pos.z = 48;
GetLaraJointPosition(&pos, LM_LHAND);
}
pos = GetLaraJointPosition(LM_LHAND, Vector3i(-16, 35, 48));
}
GUNSHELL_STRUCT* gshell = &Gunshells[GetFreeGunshell()];
auto* gshell = &Gunshells[GetFreeGunshell()];
gshell->pos.Position.x = pos.x;
gshell->pos.Position.y = pos.y;
gshell->pos.Position.z = pos.z;
gshell->pos.Position = pos;
gshell->pos.Orientation.x = 0;
gshell->pos.Orientation.y = 0;
gshell->pos.Orientation.z = GetRandomControl();
@ -1003,31 +985,36 @@ void TriggerGunShell(short hand, short objNum, LaraWeaponType weaponType)
{
if (weaponType == LaraWeaponType::Shotgun)
{
gshell->dirXrot = Lara.LeftArm.Orientation.y
+ Lara.ExtraTorsoRot.y
+ LaraItem->Pose.Orientation.y
- (GetRandomControl() & 0xFFF)
+ 10240;
gshell->pos.Orientation.y += Lara.LeftArm.Orientation.y
+ Lara.ExtraTorsoRot.y
+ LaraItem->Pose.Orientation.y;
gshell->dirXrot =
Lara.LeftArm.Orientation.y +
Lara.ExtraTorsoRot.y +
LaraItem->Pose.Orientation.y -
(GetRandomControl() & 0xFFF) +
10240;
gshell->pos.Orientation.y +=
Lara.LeftArm.Orientation.y +
Lara.ExtraTorsoRot.y +
LaraItem->Pose.Orientation.y;
if (gshell->speed < 24)
gshell->speed += 24;
}
else
{
gshell->dirXrot = Lara.LeftArm.Orientation.y
+ LaraItem->Pose.Orientation.y
- (GetRandomControl() & 0xFFF)
+ 18432;
gshell->dirXrot =
Lara.LeftArm.Orientation.y +
LaraItem->Pose.Orientation.y -
(GetRandomControl() & 0xFFF) +
18432;
}
}
else
{
gshell->dirXrot = Lara.LeftArm.Orientation.y
+ LaraItem->Pose.Orientation.y
+ (GetRandomControl() & 0xFFF)
- 18432;
gshell->dirXrot =
Lara.LeftArm.Orientation.y +
LaraItem->Pose.Orientation.y +
(GetRandomControl() & 0xFFF) -
18432;
}
if (LaraItem->MeshBits)
@ -1043,97 +1030,88 @@ void UpdateGunShells()
{
for (int i = 0; i < MAX_GUNSHELL; i++)
{
GUNSHELL_STRUCT* gs = &Gunshells[i];
auto* gunshell = &Gunshells[i];
if (gs->counter)
if (gunshell->counter)
{
int oldX = gs->pos.Position.x;
int oldY = gs->pos.Position.y;
int oldZ = gs->pos.Position.z;
auto prevPos = gunshell->pos.Position;
gs->counter--;
gunshell->counter--;
short oldRoomNumber = gs->roomNumber;
short prevRoomNumber = gunshell->roomNumber;
if (g_Level.Rooms[gs->roomNumber].flags & ENV_FLAG_WATER)
if (TestEnvironment(ENV_FLAG_WATER, gunshell->roomNumber))
{
gs->fallspeed++;
gunshell->fallspeed++;
if (gs->fallspeed <= 8)
if (gunshell->fallspeed <= 8)
{
if (gs->fallspeed < 0)
gs->fallspeed >>= 1;
if (gunshell->fallspeed < 0)
gunshell->fallspeed >>= 1;
}
else
{
gs->fallspeed = 8;
}
gs->speed -= gs->speed >> 1;
gunshell->fallspeed = 8;
gunshell->speed -= gunshell->speed >> 1;
}
else
{
gs->fallspeed += 6;
}
gunshell->fallspeed += 6;
gs->pos.Orientation.x += (gs->speed >> 1 + 7) * ANGLE(1);
gs->pos.Orientation.y += gs->speed * ANGLE(1);
gs->pos.Orientation.z += ANGLE(23);
gunshell->pos.Orientation.x += (gunshell->speed >> 1 + 7) * ANGLE(1.0f);
gunshell->pos.Orientation.y += gunshell->speed * ANGLE(1.0f);
gunshell->pos.Orientation.z += ANGLE(23.0f);
gs->pos.Position.x += gs->speed * phd_sin(gs->dirXrot);
gs->pos.Position.y += gs->fallspeed;
gs->pos.Position.z += gs->speed * phd_cos(gs->dirXrot);
gunshell->pos.Position.x += gunshell->speed * phd_sin(gunshell->dirXrot);
gunshell->pos.Position.y += gunshell->fallspeed;
gunshell->pos.Position.z += gunshell->speed * phd_cos(gunshell->dirXrot);
FloorInfo* floor = GetFloor(gs->pos.Position.x, gs->pos.Position.y, gs->pos.Position.z, &gs->roomNumber);
if (g_Level.Rooms[gs->roomNumber].flags & ENV_FLAG_WATER
&& !(g_Level.Rooms[oldRoomNumber].flags & ENV_FLAG_WATER))
FloorInfo* floor = GetFloor(gunshell->pos.Position.x, gunshell->pos.Position.y, gunshell->pos.Position.z, &gunshell->roomNumber);
if (g_Level.Rooms[gunshell->roomNumber].flags & ENV_FLAG_WATER
&& !(g_Level.Rooms[prevRoomNumber].flags & ENV_FLAG_WATER))
{
TEN::Effects::Drip::SpawnGunshellDrips(Vector3(gs->pos.Position.x, g_Level.Rooms[gs->roomNumber].maxceiling, gs->pos.Position.z), gs->roomNumber);
TEN::Effects::Drip::SpawnGunshellDrips(Vector3(gunshell->pos.Position.x, g_Level.Rooms[gunshell->roomNumber].maxceiling, gunshell->pos.Position.z), gunshell->roomNumber);
//AddWaterSparks(gs->pos.Position.x, g_Level.Rooms[gs->roomNumber].maxceiling, gs->pos.Position.z, 8);
SetupRipple(gs->pos.Position.x, g_Level.Rooms[gs->roomNumber].maxceiling, gs->pos.Position.z, (GetRandomControl() & 3) + 8, RIPPLE_FLAG_SHORT_INIT);
gs->fallspeed >>= 5;
SetupRipple(gunshell->pos.Position.x, g_Level.Rooms[gunshell->roomNumber].maxceiling, gunshell->pos.Position.z, (GetRandomControl() & 3) + 8, RIPPLE_FLAG_SHORT_INIT);
gunshell->fallspeed >>= 5;
continue;
}
int ceiling = GetCeiling(floor, gs->pos.Position.x, gs->pos.Position.y, gs->pos.Position.z);
if (gs->pos.Position.y < ceiling)
int ceiling = GetCeiling(floor, gunshell->pos.Position.x, gunshell->pos.Position.y, gunshell->pos.Position.z);
if (gunshell->pos.Position.y < ceiling)
{
SoundEffect(SFX_TR4_SHOTGUN_SHELL, &gs->pos);
gs->speed -= 4;
SoundEffect(SFX_TR4_SHOTGUN_SHELL, &gunshell->pos);
gunshell->speed -= 4;
if (gs->speed < 8)
if (gunshell->speed < 8)
{
gs->counter = 0;
gunshell->counter = 0;
continue;
}
gs->pos.Position.y = ceiling;
gs->fallspeed = -gs->fallspeed;
gunshell->pos.Position.y = ceiling;
gunshell->fallspeed = -gunshell->fallspeed;
}
int height = GetFloorHeight(floor, gs->pos.Position.x, gs->pos.Position.y, gs->pos.Position.z);
if (gs->pos.Position.y >= height)
int height = GetFloorHeight(floor, gunshell->pos.Position.x, gunshell->pos.Position.y, gunshell->pos.Position.z);
if (gunshell->pos.Position.y >= height)
{
SoundEffect(SFX_TR4_SHOTGUN_SHELL, &gs->pos);
gs->speed -= 8;
if (gs->speed >= 8)
SoundEffect(SFX_TR4_SHOTGUN_SHELL, &gunshell->pos);
gunshell->speed -= 8;
if (gunshell->speed >= 8)
{
if (oldY <= height)
{
gs->fallspeed = -gs->fallspeed >> 1;
}
if (prevPos.y <= height)
gunshell->fallspeed = -gunshell->fallspeed >> 1;
else
{
gs->dirXrot += -ANGLE(180);
gs->pos.Position.x = oldX;
gs->pos.Position.z = oldZ;
gunshell->dirXrot += ANGLE(-180.0f);
gunshell->pos.Position.x = prevPos.x;
gunshell->pos.Position.z = prevPos.z;
}
gs->pos.Position.y = oldY;
gunshell->pos.Position.y = prevPos.y;
}
else
{
gs->counter = 0;
}
gunshell->counter = 0;
}
}
}
@ -1176,42 +1154,24 @@ void AddWaterSparks(int x, int y, int z, int num)
void LaraBubbles(ItemInfo* item)
{
Vector3i pos;
int num, i;
SoundEffect(SFX_TR4_LARA_BUBBLES, &item->Pose, SoundEnvironment::Water);
pos.x = 0;
auto level = g_GameFlow->GetLevel(CurrentLevel);
auto pos = Vector3i::Zero;
if (level->GetLaraType() == LaraType::Divesuit)
{
pos.y = -192;
pos.z = -160;
GetLaraJointPosition(&pos, LM_TORSO);
}
pos = GetLaraJointPosition(LM_TORSO, Vector3i(0, -192, -160));
else
{
pos.y = -4;
pos.z = 64;
GetLaraJointPosition(LM_HEAD, Vector3i(0, -4, -64));
GetLaraJointPosition(&pos, LM_HEAD);
}
num = (GetRandomControl() & 1) + 2;
for (i = 0; i < num; i++)
{
int numBubbles = (GetRandomControl() & 1) + 2;
for (int i = 0; i < numBubbles; i++)
CreateBubble(&pos, item->RoomNumber, 8, 7, 0, 0, 0, 0);
}
}
int GetFreeDrip()
{
DRIP_STRUCT* drip = &Drips[NextDrip];
auto* drip = &Drips[NextDrip];
int dripNum = NextDrip;
short minLife = 4095;
short minIndex = 0;
@ -1301,42 +1261,41 @@ void TriggerLaraDrips(ItemInfo* item)
{
for (int i = 0; i < NUM_LARA_MESHES; i++)
{
auto pos = Vector3i::Zero;
GetLaraJointPosition(&pos, (LARA_MESHES)i);
auto pos = GetLaraJointPosition(i);
auto room = GetRoom(item->Location, pos.x, pos.y, pos.z).roomNumber;
if (g_Level.Rooms[room].flags & ENV_FLAG_WATER)
Lara.Wet[i] = UCHAR_MAX;
if (Lara.Wet[i]
&& !LaraNodeUnderwater[i]
&& (GetRandomControl() & 0x1FF) < Lara.Wet[i])
if (Lara.Wet[i] &&
!LaraNodeUnderwater[i] &&
(GetRandomControl() & 0x1FF) < Lara.Wet[i])
{
auto* drip = &Drips[GetFreeDrip()];
pos.x = (GetRandomControl() & 0x1F) - 16;
pos.y = (GetRandomControl() & 0xF) + 16;
pos.z = (GetRandomControl() & 0x1F) - 16;
DRIP_STRUCT* dptr = &Drips[GetFreeDrip()];
GetLaraJointPosition(&pos, i);
dptr->x = pos.x;
dptr->y = pos.y;
dptr->z = pos.z;
dptr->on = 1;
dptr->r = (GetRandomControl() & 7) + 64;
dptr->g = (GetRandomControl() & 7) + 96;
dptr->b = (GetRandomControl() & 7) + 128;
dptr->yVel = (GetRandomControl() & 0x1F) + 32;
dptr->gravity = (GetRandomControl() & 0x1F) + 32;
dptr->life = (GetRandomControl() & 0x1F) + 8;
dptr->roomNumber = LaraItem->RoomNumber;
auto pos = GetLaraJointPosition(
i,
Vector3i(
(GetRandomControl() & 0x1F) - 16,
(GetRandomControl() & 0xF) + 16,
(GetRandomControl() & 0x1F) - 16
));
drip->x = pos.x;
drip->y = pos.y;
drip->z = pos.z;
drip->on = 1;
drip->r = (GetRandomControl() & 7) + 64;
drip->g = (GetRandomControl() & 7) + 96;
drip->b = (GetRandomControl() & 7) + 128;
drip->yVel = (GetRandomControl() & 0x1F) + 32;
drip->gravity = (GetRandomControl() & 0x1F) + 32;
drip->life = (GetRandomControl() & 0x1F) + 8;
drip->roomNumber = LaraItem->RoomNumber;
if (Lara.Wet[i] >= 4)
Lara.Wet[i] -= 4;
else
Lara.Wet[i] = 0;
}
}
}

View file

@ -92,9 +92,7 @@ short GunMiss(int x, int y, int z, short velocity, short yRot, short roomNumber)
short GunHit(int x, int y, int z, short velocity, short yRot, short roomNumber)
{
auto pos = Vector3i::Zero;
GetLaraJointPosition(&pos, (25 * GetRandomControl()) >> 15);
auto pos = GetLaraJointPosition((25 * GetRandomControl()) >> 15);
DoBloodSplat(pos.x, pos.y, pos.z, (GetRandomControl() & 3) + 3, LaraItem->Pose.Orientation.y, LaraItem->RoomNumber);
return GunShot(x, y, z, velocity, yRot, roomNumber);
}

View file

@ -274,11 +274,7 @@ namespace TEN::Entities::Effects
{
if (!(Wibble & 0xC))
{
fx->pos.Position.x = 0;
fx->pos.Position.y = 0;
fx->pos.Position.z = 0;
GetLaraJointPosition((Vector3i*)&fx->pos, i);
fx->pos.Position = GetLaraJointPosition(i);
// TR5 code?
if (Lara.BurnCount)
@ -295,8 +291,7 @@ namespace TEN::Entities::Effects
byte r = (GetRandomControl() & 0x3F) + 192;
byte g = (GetRandomControl() & 0x1F) + 96;
auto pos = Vector3i::Zero;
GetLaraJointPosition(&pos, LM_HIPS);
auto pos = GetLaraJointPosition(LM_HIPS);
if (!Lara.BurnSmoke)
{

View file

@ -21,7 +21,7 @@ using namespace TEN::Entities::Effects;
namespace TEN::Entities::Generic
{
void TriggerTorchFlame(char fxObj, char node)
void TriggerTorchFlame(char fxObject, char node)
{
auto* spark = GetFreeParticle();
@ -61,7 +61,7 @@ namespace TEN::Entities::Generic
spark->gravity = -16 - (GetRandomControl() & 0x1F);
spark->nodeNumber = node;
spark->maxYvel = -16 - (GetRandomControl() & 7);
spark->fxObj = fxObj;
spark->fxObj = fxObject;
spark->scalar = 1;
spark->sSize = spark->size = (GetRandomControl() & 0x1F) + 80;
spark->dSize = spark->size / 8;
@ -69,114 +69,115 @@ namespace TEN::Entities::Generic
void DoFlameTorch()
{
int const holdAnimNumber = Objects[ID_LARA_TORCH_ANIM].animIndex;
int const throwAnimNumber = Objects[ID_LARA_TORCH_ANIM].animIndex + 1;
int const dropAnimNumber = Objects[ID_LARA_TORCH_ANIM].animIndex + 2;
const int holdAnimNumber = Objects[ID_LARA_TORCH_ANIM].animIndex;
const int throwAnimNumber = Objects[ID_LARA_TORCH_ANIM].animIndex + 1;
const int dropAnimNumber = Objects[ID_LARA_TORCH_ANIM].animIndex + 2;
if (Lara.Torch.State == TorchState::Holding)
auto* laraItem = LaraItem;
auto* lara = GetLaraInfo(laraItem);
if (lara->Torch.State == TorchState::Holding)
{
if (Lara.Control.Weapon.RequestGunType != Lara.Control.Weapon.GunType)
if (lara->Control.Weapon.RequestGunType != lara->Control.Weapon.GunType)
{
Lara.LeftArm.Locked = true;
Lara.LeftArm.FrameNumber = 31;
Lara.LeftArm.AnimNumber = dropAnimNumber;
Lara.Torch.State = TorchState::Dropping;
lara->LeftArm.Locked = true;
lara->LeftArm.FrameNumber = 31;
lara->LeftArm.AnimNumber = dropAnimNumber;
lara->Torch.State = TorchState::Dropping;
}
else if (TrInput & IN_DRAW &&
!LaraItem->Animation.IsAirborne &&
!LaraItem->Animation.Velocity.y &&
LaraItem->Animation.ActiveState != LS_JUMP_PREPARE &&
LaraItem->Animation.ActiveState != LS_JUMP_UP &&
LaraItem->Animation.ActiveState != LS_JUMP_FORWARD &&
LaraItem->Animation.ActiveState != LS_JUMP_BACK &&
LaraItem->Animation.ActiveState != LS_JUMP_LEFT &&
LaraItem->Animation.ActiveState != LS_JUMP_RIGHT ||
Lara.Control.WaterStatus == WaterStatus::Underwater)
!laraItem->Animation.IsAirborne &&
laraItem->Animation.Velocity.y == 0.0f &&
laraItem->Animation.ActiveState != LS_JUMP_PREPARE &&
laraItem->Animation.ActiveState != LS_JUMP_UP &&
laraItem->Animation.ActiveState != LS_JUMP_FORWARD &&
laraItem->Animation.ActiveState != LS_JUMP_BACK &&
laraItem->Animation.ActiveState != LS_JUMP_LEFT &&
laraItem->Animation.ActiveState != LS_JUMP_RIGHT ||
lara->Control.WaterStatus == WaterStatus::Underwater)
{
Lara.LeftArm.Locked = true;
Lara.LeftArm.FrameNumber = 1;
Lara.LeftArm.AnimNumber = throwAnimNumber;
Lara.Torch.State = TorchState::Throwing;
lara->LeftArm.Locked = true;
lara->LeftArm.FrameNumber = 1;
lara->LeftArm.AnimNumber = throwAnimNumber;
lara->Torch.State = TorchState::Throwing;
if (Lara.Control.WaterStatus == WaterStatus::Underwater)
Lara.Torch.IsLit = false;
if (lara->Control.WaterStatus == WaterStatus::Underwater)
lara->Torch.IsLit = false;
}
}
else if (Lara.Torch.State == TorchState::Throwing)
else if (lara->Torch.State == TorchState::Throwing)
{
if (Lara.LeftArm.FrameNumber < 12 && LaraItem->Animation.IsAirborne)
if (lara->LeftArm.FrameNumber < 12 && laraItem->Animation.IsAirborne)
{
Lara.LeftArm.Locked = false;
Lara.LeftArm.FrameNumber = 0;
Lara.LeftArm.AnimNumber = holdAnimNumber;
Lara.Torch.State = TorchState::Holding;
lara->LeftArm.Locked = false;
lara->LeftArm.FrameNumber = 0;
lara->LeftArm.AnimNumber = holdAnimNumber;
lara->Torch.State = TorchState::Holding;
}
else
{
Lara.LeftArm.FrameNumber++;
if (Lara.LeftArm.FrameNumber == 27)
lara->LeftArm.FrameNumber++;
if (lara->LeftArm.FrameNumber == 27)
{
Lara.Torch.IsLit = false;
Lara.Flare.ControlLeft = false;
Lara.LeftArm.Locked = false;
Lara.Torch.State = TorchState::Holding;
Lara.Control.Weapon.GunType = Lara.Control.Weapon.LastGunType;
Lara.Control.Weapon.RequestGunType = LaraWeaponType::None;
Lara.Control.HandStatus = HandStatus::Free;
lara->Torch.IsLit = false;
lara->Flare.ControlLeft = false;
lara->LeftArm.Locked = false;
lara->Torch.State = TorchState::Holding;
lara->Control.Weapon.GunType = lara->Control.Weapon.LastGunType;
lara->Control.Weapon.RequestGunType = LaraWeaponType::None;
lara->Control.HandStatus = HandStatus::Free;
}
else if (Lara.LeftArm.FrameNumber == 12)
else if (lara->LeftArm.FrameNumber == 12)
{
Lara.MeshPtrs[LM_LHAND] = Objects[ID_LARA_SKIN].meshIndex + LM_LHAND;
CreateFlare(LaraItem, ID_BURNING_TORCH_ITEM, true);
lara->MeshPtrs[LM_LHAND] = Objects[ID_LARA_SKIN].meshIndex + LM_LHAND;
CreateFlare(laraItem, ID_BURNING_TORCH_ITEM, true);
}
}
}
else if (Lara.Torch.State == TorchState::Dropping)
else if (lara->Torch.State == TorchState::Dropping)
{
Lara.LeftArm.FrameNumber++;
if (Lara.LeftArm.FrameNumber == 41)
lara->LeftArm.FrameNumber++;
if (lara->LeftArm.FrameNumber == 41)
{
Lara.Torch.IsLit = false;
Lara.Flare.ControlLeft = false;
Lara.LeftArm.Locked = false;
Lara.Torch.State = TorchState::Holding;
Lara.Control.Weapon.LastGunType = LaraWeaponType::None;
Lara.Control.Weapon.GunType = LaraWeaponType::None;
Lara.Control.HandStatus = HandStatus::Free;
lara->Torch.IsLit = false;
lara->Flare.ControlLeft = false;
lara->LeftArm.Locked = false;
lara->Torch.State = TorchState::Holding;
lara->Control.Weapon.LastGunType = LaraWeaponType::None;
lara->Control.Weapon.GunType = LaraWeaponType::None;
lara->Control.HandStatus = HandStatus::Free;
}
else if (Lara.LeftArm.FrameNumber == 36)
else if (lara->LeftArm.FrameNumber == 36)
{
Lara.MeshPtrs[LM_LHAND] = Objects[ID_LARA_SKIN].meshIndex + LM_LHAND;
CreateFlare(LaraItem, ID_BURNING_TORCH_ITEM, false);
lara->MeshPtrs[LM_LHAND] = Objects[ID_LARA_SKIN].meshIndex + LM_LHAND;
CreateFlare(laraItem, ID_BURNING_TORCH_ITEM, false);
}
}
else if (Lara.Torch.State == TorchState::JustLit)
else if (lara->Torch.State == TorchState::JustLit)
{
if (LaraItem->Animation.ActiveState != LS_MISC_CONTROL)
if (laraItem->Animation.ActiveState != LS_MISC_CONTROL)
{
Lara.LeftArm.Locked = false;
Lara.Torch.State = TorchState::Holding;
Lara.LeftArm.FrameNumber = 0;
Lara.Flare.ControlLeft = true;
Lara.Torch.IsLit = LaraItem->ItemFlags[3] & 1;
Lara.LeftArm.AnimNumber = holdAnimNumber;
lara->LeftArm.Locked = false;
lara->Torch.State = TorchState::Holding;
lara->LeftArm.FrameNumber = 0;
lara->Flare.ControlLeft = true;
lara->Torch.IsLit = laraItem->ItemFlags[3] & 1;
lara->LeftArm.AnimNumber = holdAnimNumber;
}
}
if (Lara.Flare.ControlLeft)
Lara.Control.HandStatus = HandStatus::WeaponReady;
if (lara->Flare.ControlLeft)
lara->Control.HandStatus = HandStatus::WeaponReady;
Lara.LeftArm.FrameBase = g_Level.Anims[Lara.LeftArm.AnimNumber].framePtr;
lara->LeftArm.FrameBase = g_Level.Anims[lara->LeftArm.AnimNumber].framePtr;
if (Lara.Torch.IsLit)
if (lara->Torch.IsLit)
{
auto pos = Vector3i(-32, 64, 256);
GetLaraJointPosition(&pos, LM_LHAND);
auto pos = GetLaraJointPosition(LM_LHAND, Vector3i(-32, 64, 256));
TriggerDynamicLight(pos.x, pos.y, pos.z, 12 - (GetRandomControl() & 1), (GetRandomControl() & 0x3F) + 192, (GetRandomControl() & 0x1F) + 96, 0);
if (!(Wibble & 7))
TriggerTorchFlame(LaraItem - g_Level.Items.data(), 0);
TriggerTorchFlame(laraItem - g_Level.Items.data(), 0);
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, (PoseData*)&pos);
}
@ -184,19 +185,22 @@ namespace TEN::Entities::Generic
void GetFlameTorch()
{
if (Lara.Control.Weapon.GunType == LaraWeaponType::Flare)
CreateFlare(LaraItem, ID_FLARE_ITEM, false);
auto* laraItem = LaraItem;
auto* lara = GetLaraInfo(laraItem);
Lara.Control.HandStatus = HandStatus::WeaponReady;
Lara.Control.Weapon.RequestGunType = LaraWeaponType::Torch;
Lara.Control.Weapon.GunType = LaraWeaponType::Torch;
Lara.Flare.ControlLeft = true;
Lara.LeftArm.AnimNumber = Objects[ID_LARA_TORCH_ANIM].animIndex;
Lara.LeftArm.Locked = false;
Lara.LeftArm.FrameNumber = 0;
Lara.LeftArm.FrameBase = g_Level.Anims[Lara.LeftArm.AnimNumber].framePtr;
if (lara->Control.Weapon.GunType == LaraWeaponType::Flare)
CreateFlare(laraItem, ID_FLARE_ITEM, false);
Lara.MeshPtrs[LM_LHAND] = Objects[ID_LARA_TORCH_ANIM].meshIndex + LM_LHAND;
lara->Control.HandStatus = HandStatus::WeaponReady;
lara->Control.Weapon.RequestGunType = LaraWeaponType::Torch;
lara->Control.Weapon.GunType = LaraWeaponType::Torch;
lara->Flare.ControlLeft = true;
lara->LeftArm.AnimNumber = Objects[ID_LARA_TORCH_ANIM].animIndex;
lara->LeftArm.Locked = false;
lara->LeftArm.FrameNumber = 0;
lara->LeftArm.FrameBase = g_Level.Anims[lara->LeftArm.AnimNumber].framePtr;
lara->MeshPtrs[LM_LHAND] = Objects[ID_LARA_TORCH_ANIM].meshIndex + LM_LHAND;
}
void TorchControl(short itemNumber)
@ -220,7 +224,7 @@ namespace TEN::Entities::Generic
item->Animation.Velocity.z * phd_cos(item->Pose.Orientation.y)
);
auto oldPos = item->Pose.Position;
auto prevPos = item->Pose.Position;
item->Pose.Position += Vector3i(velocity.x, 0, velocity.z);
if (TestEnvironment(ENV_FLAG_WATER, item) ||
@ -236,7 +240,7 @@ namespace TEN::Entities::Generic
item->Animation.Velocity.y += 6;
item->Pose.Position.y += item->Animation.Velocity.y;
DoProjectileDynamics(itemNumber, oldPos.x, oldPos.y, oldPos.z, velocity.x, velocity.y, velocity.z);
DoProjectileDynamics(itemNumber, prevPos.x, prevPos.y, prevPos.z, velocity.x, velocity.y, velocity.z);
// Collide with entities.
if (GetCollidedObjects(item, 0, true, CollidedItems, CollidedMeshes, true))
@ -251,9 +255,7 @@ namespace TEN::Entities::Generic
}
}
else if (CollidedMeshes[0])
{
ItemPushStatic(item, CollidedMeshes[0], &LaraCollision);
}
item->Animation.Velocity.z = -int(item->Animation.Velocity.z / 1.5f);
}
@ -269,20 +271,10 @@ namespace TEN::Entities::Generic
}
}
void LaraTorch(Vector3i* src, Vector3i* target, int rot, int color)
void LaraTorch(Vector3i* origin, Vector3i* target, int rot, int color)
{
auto pos1 = GameVector(
src->x,
src->y,
src->z,
LaraItem->RoomNumber
);
auto pos2 = GameVector(
target->x,
target->y,
target->z
);
auto pos1 = GameVector(*origin, LaraItem->RoomNumber);
auto pos2 = GameVector(*target);
TriggerDynamicLight(pos1.x, pos1.y, pos1.z, 12, color, color, color >> 1);
@ -300,17 +292,17 @@ namespace TEN::Entities::Generic
void FireCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* coll)
{
auto* laraInfo = GetLaraInfo(laraItem);
auto* torchItem = &g_Level.Items[itemNumber];
auto* lara = GetLaraInfo(laraItem);
if (!(TrInput & IN_ACTION) ||
laraItem->Animation.ActiveState != LS_IDLE ||
laraItem->Animation.AnimNumber != LA_STAND_IDLE ||
laraItem->Animation.IsAirborne ||
laraInfo->Control.Weapon.GunType != LaraWeaponType::Torch ||
laraInfo->Control.HandStatus != HandStatus::WeaponReady ||
laraInfo->LeftArm.Locked ||
laraInfo->Torch.IsLit == (torchItem->Status == ITEM_ACTIVE) ||
lara->Control.Weapon.GunType != LaraWeaponType::Torch ||
lara->Control.HandStatus != HandStatus::WeaponReady ||
lara->LeftArm.Locked ||
lara->Torch.IsLit == (torchItem->Status == ITEM_ACTIVE) ||
torchItem->Timer == -1)
{
if (torchItem->ObjectNumber == ID_BURNING_ROOTS)
@ -318,7 +310,7 @@ namespace TEN::Entities::Generic
}
else
{
short rot = torchItem->Pose.Orientation.y;
short yOrient = torchItem->Pose.Orientation.y;
switch (torchItem->ObjectNumber)
{
@ -365,21 +357,21 @@ namespace TEN::Entities::Generic
laraItem->Animation.ActiveState = LS_MISC_CONTROL;
laraItem->Animation.FrameNumber = g_Level.Anims[laraItem->Animation.AnimNumber].frameBase;
laraInfo->Flare.ControlLeft = false;
laraInfo->LeftArm.Locked = true;
laraInfo->InteractedItem = itemNumber;
lara->Flare.ControlLeft = false;
lara->LeftArm.Locked = true;
lara->InteractedItem = itemNumber;
}
torchItem->Pose.Orientation.y = rot;
torchItem->Pose.Orientation.y = yOrient;
}
if (laraItem->Animation.ActiveState == LS_MISC_CONTROL &&
laraInfo->InteractedItem == itemNumber &&
lara->InteractedItem == itemNumber &&
torchItem->Status != ITEM_ACTIVE)
{
if (laraItem->Animation.AnimNumber >= LA_TORCH_LIGHT_1 &&
laraItem->Animation.AnimNumber <= LA_TORCH_LIGHT_5)
{
if (laraItem->Animation.FrameNumber - g_Level.Anims[laraItem->Animation.AnimNumber].frameBase == 40)
if ((laraItem->Animation.FrameNumber - g_Level.Anims[laraItem->Animation.AnimNumber].frameBase) == 40)
{
TestTriggers(torchItem, true, torchItem->Flags & IFLAG_ACTIVATION_MASK);
torchItem->Flags |= 0x3E00;

View file

@ -1,15 +1,15 @@
#pragma once
#include "Math/Math.h"
struct ItemInfo;
struct CollisionInfo;
struct ItemInfo;
namespace TEN::Entities::Generic
{
void TriggerTorchFlame(char fxObj, char node);
void TriggerTorchFlame(char fxObject, char node);
void DoFlameTorch();
void GetFlameTorch();
void TorchControl(short itemNumber);
void LaraTorch(Vector3i* src, Vector3i* target, int rot, int color);
void LaraTorch(Vector3i* origin, Vector3i* target, int rot, int color);
void FireCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* coll);
}

View file

@ -194,13 +194,10 @@ void HorizontalBarCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo*
if (test1)
laraItem->Pose.Orientation.y = barItem->Pose.Orientation.y;
else
laraItem->Pose.Orientation.y = barItem->Pose.Orientation.y + -ANGLE(180.0f);
laraItem->Pose.Orientation.y = barItem->Pose.Orientation.y - ANGLE(180.0f);
Vector3i pos1 = { 0, -128, 512 };
GetLaraJointPosition(&pos1, LM_LHAND);
Vector3i pos2 = { 0, -128, 512 };
GetLaraJointPosition(&pos2, LM_RHAND);
auto pos1 = GetLaraJointPosition(LM_LHAND, Vector3i(0, -128, 512));
auto pos2 = GetLaraJointPosition(LM_RHAND, Vector3i(0, -128, 512));
if (laraItem->Pose.Orientation.y & 0x4000)
laraItem->Pose.Position.x += barItem->Pose.Position.x - ((pos1.x + pos2.x) >> 1);
@ -239,7 +236,7 @@ void CutsceneRopeControl(short itemNumber)
ropeItem->Pose.Orientation.x = -4869;
}
void HybridCollision(short itemNumber, ItemInfo* laraitem, CollisionInfo* coll)
void HybridCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* coll)
{
auto* item = &g_Level.Items[itemNumber];
@ -259,13 +256,13 @@ void InitialiseTightrope(short itemNumber)
if (tightropeItem->Pose.Orientation.y > 0)
{
if (tightropeItem->Pose.Orientation.y == ANGLE(90.0f))
tightropeItem->Pose.Position.x -= 256;
tightropeItem->Pose.Position.x -= CLICK(1);
}
else if (tightropeItem->Pose.Orientation.y)
{
if (tightropeItem->Pose.Orientation.y == -ANGLE(180.0f))
if (tightropeItem->Pose.Orientation.y == ANGLE(-180.0f))
tightropeItem->Pose.Position.z += CLICK(1);
else if (tightropeItem->Pose.Orientation.y == -ANGLE(90.0f))
else if (tightropeItem->Pose.Orientation.y == ANGLE(-90.0f))
tightropeItem->Pose.Position.x += CLICK(1);
}
else

View file

@ -1049,8 +1049,7 @@ namespace TEN::Entities::Vehicles
if (laraItem->Animation.AnimNumber == Objects[ID_KAYAK_LARA_ANIMS].animIndex + KAYAK_ANIM_DISMOUNT_LEFT &&
frame == 83)
{
Vector3i vec = { 0, 350, 500 };
GetLaraJointPosition(&vec, LM_HIPS);
auto vec = GetLaraJointPosition(LM_HIPS, Vector3i(0, 350, 500));
SetAnimation(laraItem, LA_JUMP_FORWARD);
laraItem->Pose.Position = vec;
@ -1071,8 +1070,7 @@ namespace TEN::Entities::Vehicles
if (laraItem->Animation.AnimNumber == Objects[ID_KAYAK_LARA_ANIMS].animIndex + KAYAK_ANIM_DISMOUNT_RIGHT &&
frame == 83)
{
Vector3i vec = { 0, 350, 500 };
GetLaraJointPosition(&vec, LM_HIPS);
auto vec = GetLaraJointPosition(LM_HIPS, Vector3i(0, 350, 500));
SetAnimation(laraItem, LA_JUMP_FORWARD);
laraItem->Pose.Position = vec;

View file

@ -758,9 +758,7 @@ namespace TEN::Entities::Vehicles
if (laraItem->Animation.AnimNumber == Objects[ID_MINECART_LARA_ANIMS].animIndex + MINECART_ANIM_DISMOUNT_LEFT &&
laraItem->Animation.FrameNumber == g_Level.Anims[laraItem->Animation.AnimNumber].frameEnd)
{
auto pos = Vector3i(0, 640, 0);
GetLaraJointPosition(&pos, LM_HIPS);
auto pos = GetLaraJointPosition(LM_HIPS, Vector3i(0, 640, 0));
laraItem->Pose.Position = pos;
laraItem->Pose.Orientation = EulerAngles(0, minecartItem->Pose.Orientation.y + ANGLE(90.0f), 0);
@ -775,9 +773,7 @@ namespace TEN::Entities::Vehicles
if (laraItem->Animation.AnimNumber == Objects[ID_MINECART_LARA_ANIMS].animIndex + MINECART_ANIM_DISMOUNT_RIGHT &&
laraItem->Animation.FrameNumber == g_Level.Anims[laraItem->Animation.AnimNumber].frameEnd)
{
auto pos = Vector3i(0, 640, 0);
GetLaraJointPosition(&pos, LM_HIPS);
auto pos = GetLaraJointPosition(LM_HIPS, Vector3i(0, 640, 0));
laraItem->Pose.Position = pos;
laraItem->Pose.Orientation = EulerAngles(0, minecartItem->Pose.Orientation.y - ANGLE(90.0f), 0);

View file

@ -721,8 +721,7 @@ namespace TEN::Entities::Vehicles
{
UPV->Flags &= ~UPV_FLAG_CONTROL;
Vector3i vec = { 0, 0, 0 };
GetLaraJointPosition(&vec, LM_HIPS);
auto vec = GetLaraJointPosition(LM_HIPS);
auto LPos = GameVector(
vec.x,
@ -771,8 +770,7 @@ namespace TEN::Entities::Vehicles
else
heightFromWater = NO_HEIGHT;
auto vec = Vector3i::Zero;
GetLaraJointPosition(&vec, LM_HIPS);
auto vec = GetLaraJointPosition(LM_HIPS);
laraItem->Pose.Position.x = vec.x;
//laraItem->Pose.Position.y += -heightFromWater + 1; // Doesn't work as intended.
@ -808,9 +806,7 @@ namespace TEN::Entities::Vehicles
if ((anim == UPV_ANIM_IDLE_DEATH || anim == UPV_ANIM_MOVING_DEATH) &&
(frame == UPV_DEATH_FRAME_1 || frame == UPV_DEATH_FRAME_2))
{
auto vec = Vector3i::Zero;
GetLaraJointPosition(&vec, LM_HIPS);
auto vec = GetLaraJointPosition(LM_HIPS);
laraItem->Pose.Position = vec;
laraItem->Pose.Orientation.x = 0;
laraItem->Pose.Orientation.z = 0;

View file

@ -26,8 +26,7 @@ void ClockworkBeetleControl(short itemNumber)
if (LaraItem->Animation.FrameNumber < fb + 104)
{
auto pos = Vector3i(0, 0, -32);
GetLaraJointPosition(&pos, LM_RHAND);
auto pos = GetLaraJointPosition(LM_RHAND, Vector3i(0, 0, -32));
beetle->Pose.Position = pos;
beetle->Status = ITEM_ACTIVE;

View file

@ -163,8 +163,7 @@ void ScalesCollision(short itemNumber, ItemInfo* laraItem, CollisionInfo* coll)
laraItem->Animation.FrameNumber >= g_Level.Anims[LA_WATERSKIN_POUR_HIGH].frameBase + 51 &&
laraItem->Animation.FrameNumber <= g_Level.Anims[LA_WATERSKIN_POUR_HIGH].frameBase + 74)
{
Vector3i pos = { 0, 0, 0 };
GetLaraJointPosition(&pos, LM_LHAND);
auto pos = GetLaraJointPosition(LM_LHAND);
auto* drip = &Drips[GetFreeDrip()];
drip->x = pos.x;

View file

@ -67,28 +67,27 @@ namespace TEN::Entities::TR5
item->MeshBits = 1664;
GameVector pos1 = { 0, 0, -64 };
auto pos1 = GameVector(0, 0, -64);
GetJointAbsPosition(item, (Vector3i*)&pos1, 8);
GameVector pos2 = { 0, 0, 0 };
GetLaraJointPosition((Vector3i*)&pos2, 0);
auto pos2 = GameVector(GetLaraJointPosition(LM_HIPS));
pos1.roomNumber = item->RoomNumber;
int los = LOS(&pos1, &pos2);
EulerAngles orient;
// FIXME:
if (los)
{
orient = Geometry::GetOrientTowardPoint(pos1.ToVector3(), pos2.ToVector3());
orient.y -= item->Pose.Orientation.y;
}
else
{
orient.x = item->ItemFlags[1];
orient.y = item->ItemFlags[0];
}
// FIXME:
if (los)
{
orient = Geometry::GetOrientTowardPoint(pos1.ToVector3(), pos2.ToVector3());
orient.y -= item->Pose.Orientation.y;
}
else
{
orient.x = item->ItemFlags[1];
orient.y = item->ItemFlags[0];
}
short angle1, angle2;
InterpolateAngle(orient.x, &item->ItemFlags[1], &angle2, 4);
@ -110,8 +109,7 @@ namespace TEN::Entities::TR5
if (GetRandomControl() & 3)
{
auto pos2 = Vector3i::Zero;
GetLaraJointPosition((Vector3i*)&pos2, GetRandomControl() % 15);
auto pos2 = GetLaraJointPosition(GetRandomControl() % 15);
DoBloodSplat(pos2.x, pos2.y, pos2.z, (GetRandomControl() & 3) + 3, 2 * GetRandomControl(), LaraItem->RoomNumber);
DoDamage(LaraItem, 20);

View file

@ -607,15 +607,12 @@ namespace TEN::Entities::TR5
}
else if (item->Animation.ActiveState == 43 && !Lara.Burn)
{
auto pos = Vector3i(0, 0, 0);
GetLaraJointPosition(&pos, LM_LFOOT);
auto pos = GetLaraJointPosition(LM_LFOOT);
short roomNumberLeft = LaraItem->RoomNumber;
GetFloor(pos.x, pos.y, pos.z, &roomNumberLeft);
pos = Vector3i::Zero;
GetLaraJointPosition(&pos, LM_RFOOT);
pos = GetLaraJointPosition(LM_RFOOT);
short roomNumberRight = LaraItem->RoomNumber;
GetFloor(pos.x, pos.y, pos.z, &roomNumberRight);

View file

@ -24,13 +24,14 @@ namespace TEN::Entities::TR5
{
SoundEffect(SFX_TR4_HELICOPTER_LOOP, &item->Pose);
GameVector pos;
pos.x = ((GetRandomControl() & 0x1FF) - 255);
pos.y = (GetRandomControl() & 0x1FF) - 255;
pos.z = (GetRandomControl() & 0x1FF) - 255;
GetLaraJointPosition((Vector3i*)&pos, LM_TORSO);
auto pos = GameVector(GetLaraJointPosition(
LM_TORSO,
Vector3i(
(GetRandomControl() & 0x1FF) - 255,
(GetRandomControl() & 0x1FF) - 255,
(GetRandomControl() & 0x1FF) - 255)));
GameVector end = pos;
auto target = pos;
if (!item->ItemFlags[0] && !item->ItemFlags[1] && !item->ItemFlags[2])
{
@ -53,17 +54,17 @@ namespace TEN::Entities::TR5
item->Pose.Position.x += (pos.x - item->Pose.Position.x) / 32;
item->Pose.Position.y += (pos.y - item->Pose.Position.y - 256) / 32;
GameVector start;
start.x = GetRandomControl() + item->Pose.Position.x - 128;
start.y = GetRandomControl() + item->Pose.Position.y - 128;
start.z = GetRandomControl() + item->Pose.Position.z - 128;
start.roomNumber = item->RoomNumber;
bool los = LOS(&start, &end);
GameVector origin;
origin.x = GetRandomControl() + item->Pose.Position.x - 128;
origin.y = GetRandomControl() + item->Pose.Position.y - 128;
origin.z = GetRandomControl() + item->Pose.Position.z - 128;
origin.roomNumber = item->RoomNumber;
bool los = LOS(&origin, &target);
end.x = 3 * pos.x - 2 * start.x;
end.y = 3 * pos.y - 2 * start.y;
end.z = 3 * pos.z - 2 * start.z;
bool los2 = LOS(&start, &end);
target.x = 3 * pos.x - 2 * origin.x;
target.y = 3 * pos.y - 2 * origin.y;
target.z = 3 * pos.z - 2 * origin.z;
bool los2 = LOS(&origin, &target);
if (los)
GunShipCounter = 1;
@ -83,7 +84,7 @@ namespace TEN::Entities::TR5
Vector3i hitPos;
MESH_INFO* hitMesh = nullptr;
int objOnLos = ObjectOnLOS2(&start, &end, &hitPos, &hitMesh, GAME_OBJECT_ID::ID_LARA);
int objOnLos = ObjectOnLOS2(&origin, &target, &hitPos, &hitMesh, GAME_OBJECT_ID::ID_LARA);
if (objOnLos == NO_LOS_ITEM || objOnLos < 0)
{
@ -91,24 +92,24 @@ namespace TEN::Entities::TR5
return AnimateItem(item);
TriggerDynamicLight(
start.x, start.y, start.z, 16,
origin.x, origin.y, origin.z, 16,
(GetRandomControl() & 0x3F) + 96,
(GetRandomControl() & 0x1F) + 64,
0);
if (!los2)
{
TriggerRicochetSpark(&end, 2 * GetRandomControl(), 3, 0);
TriggerRicochetSpark(&end, 2 * GetRandomControl(), 3, 0);
TriggerRicochetSpark(&target, 2 * GetRandomControl(), 3, 0);
TriggerRicochetSpark(&target, 2 * GetRandomControl(), 3, 0);
}
if (objOnLos < 0 && GetRandomControl() & 1)
{
if (StaticObjects[hitMesh->staticNumber].shatterType != SHT_NONE)
{
ShatterObject(0, hitMesh, 64, end.roomNumber, 0);
ShatterObject(0, hitMesh, 64, target.roomNumber, 0);
hitMesh->flags &= ~StaticMeshFlags::SM_VISIBLE;
TestTriggers(hitMesh->pos.Position.x, hitMesh->pos.Position.y, hitMesh->pos.Position.z, end.roomNumber, true);
TestTriggers(hitMesh->pos.Position.x, hitMesh->pos.Position.y, hitMesh->pos.Position.z, target.roomNumber, true);
SoundEffect(GetShatterSound(hitMesh->staticNumber), &hitMesh->pos);
}
@ -133,14 +134,14 @@ namespace TEN::Entities::TR5
else
{
TriggerDynamicLight(
start.x, start.y, start.z,
origin.x, origin.y, origin.z,
16,
(GetRandomControl() & 0x3F) + 96,
(GetRandomControl() & 0x1F) + 64,
0);
DoBloodSplat(
start.x, start.y, start.z,
origin.x, origin.y, origin.z,
(GetRandomControl() & 1) + 2,
2 * GetRandomControl(),
LaraItem->RoomNumber);
@ -169,12 +170,12 @@ namespace TEN::Entities::TR5
spark->fadeToBlack = 0;
spark->life = 12;
spark->sLife = 12;
spark->x = start.x;
spark->y = start.y;
spark->z = start.z;
spark->xVel = 4 * (end.x - start.x);
spark->yVel = 4 * (end.y - start.y);
spark->zVel = 4 * (end.z - start.z);
spark->x = origin.x;
spark->y = origin.y;
spark->z = origin.z;
spark->xVel = 4 * (target.x - origin.x);
spark->yVel = 4 * (target.y - origin.y);
spark->zVel = 4 * (target.z - origin.z);
spark->friction = 0;
spark->maxYvel = 0;
spark->flags = SP_NONE;

View file

@ -69,23 +69,22 @@ namespace TEN::Entities::TR5
item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase;
}
static void ImpThrowStones(ItemInfo* item)
{
auto pos1 = Vector3i::Zero;
GetJointAbsPosition(item, &pos1, 9);
static void ImpThrowStones(ItemInfo* item)
{
auto pos1 = Vector3i::Zero;
GetJointAbsPosition(item, &pos1, 9);
auto pos2 = Vector3i::Zero;
GetLaraJointPosition(&pos2, LM_HEAD);
auto pos2 = GetLaraJointPosition(LM_HEAD);
int dx = pos1.x - pos2.x;
int dy = pos1.y - pos2.y;
int dz = pos1.z - pos2.z;
auto orient = Geometry::GetOrientTowardPoint(pos1.ToVector3(), pos2.ToVector3());
auto orient = Geometry::GetOrientTowardPoint(pos1.ToVector3(), pos2.ToVector3());
int distance = sqrt(pow(dx, 2) + pow(dy, 2) + pow(dz, 2));
if (distance < 8)
distance = 8;
int distance = sqrt(pow(dx, 2) + pow(dy, 2) + pow(dz, 2));
if (distance < 8)
distance = 8;
orient.x += GetRandomControl() % (distance / 2) - (distance / 4);
orient.y += GetRandomControl() % (distance / 4) - (distance / 8);
@ -99,11 +98,7 @@ static void ImpThrowStones(ItemInfo* item)
fx->roomNumber = item->RoomNumber;
fx->speed = 4 * sqrt(distance);
fx->pos.Orientation = EulerAngles(
(orient.x + distance) / 2,
orient.y,
0
);
fx->pos.Orientation = EulerAngles((orient.x + distance) / 2, orient.y, 0);
if (fx->speed < 256)
fx->speed = 256;

View file

@ -46,9 +46,7 @@ void GenSlot1Control(short itemNumber)
{
for (int i = 0; i < 8; i++)
{
Vector3i pos = { 0, 0, 0 };
GetLaraJointPosition(&pos, i + 7);
auto pos = GetLaraJointPosition(i + 7);
int x = pos.x + (GetRandomControl() & 0xFF) - 128;
int y = pos.y + (GetRandomControl() & 0xFF) - 128;
int z = pos.z + (GetRandomControl() & 0xFF) - 128;

View file

@ -91,8 +91,7 @@ void ExplosionControl(short itemNumber)
}
else if (flag == 2)
{
Vector3i vec = { 0, 0, 0 };
GetLaraJointPosition(&vec, 0);
auto vec = GetLaraJointPosition(LM_HIPS);
int dx = vec.x - item->Pose.Position.x;
int dy = vec.y - item->Pose.Position.y;

View file

@ -46,18 +46,18 @@ namespace TEN::Renderer
std::vector<Sphere> nearestSpheres;
nearestSpheres.reserve(g_Configuration.ShadowMaxBlobs);
// Collect Lara spheres
// Collect Lara spheres.
static const std::array<LARA_MESHES, 4> sphereMeshes = { LM_HIPS, LM_TORSO, LM_LFOOT, LM_RFOOT };
static const std::array<float, 4> sphereScaleFactors = { 6.0f, 3.2f, 2.8f, 2.8f };
for (auto& r : renderView.roomsToDraw)
for (auto& room : renderView.roomsToDraw)
{
for (auto& i : r->ItemsToDraw)
for (auto& i : room->ItemsToDraw)
{
auto& nativeItem = g_Level.Items[i->ItemNumber];
//Skip everything thats not "alive" or is not a vehicle
// Skip everything that's not "alive" or not a vehicle.
if (Objects[nativeItem.ObjectNumber].shadowType == ShadowMode::None)
continue;
@ -69,26 +69,26 @@ namespace TEN::Renderer
if (!nativeItem.TestBits(JointBitType::Mesh, sphereMeshes[i]))
continue;
MESH& m = g_Level.Meshes[Lara.MeshPtrs[sphereMeshes[i]]];
Vector3i pos = { (int)m.sphere.Center.x, (int)m.sphere.Center.y, (int)m.sphere.Center.z };
auto& mesh = g_Level.Meshes[Lara.MeshPtrs[sphereMeshes[i]]];
auto offset = Vector3i(mesh.sphere.Center.x, mesh.sphere.Center.y, mesh.sphere.Center.z);
// Push feet spheres a little bit down
// Push foot spheres a little lower.
if (sphereMeshes[i] == LM_LFOOT || sphereMeshes[i] == LM_RFOOT)
pos.y += 8;
GetLaraJointPosition(&pos, sphereMeshes[i]);
offset.y += 8;
auto pos = GetLaraJointPosition(sphereMeshes[i], offset);
auto& newSphere = nearestSpheres.emplace_back();
newSphere.position = Vector3(pos.x, pos.y, pos.z);
newSphere.radius = m.sphere.Radius * sphereScaleFactors[i];
newSphere.radius = mesh.sphere.Radius * sphereScaleFactors[i];
}
}
else
{
auto bb = GetBoundsAccurate(&nativeItem);
Vector3 center = ((Vector3(bb->X1, bb->Y1, bb->Z1) + Vector3(bb->X2, bb->Y2, bb->Z2)) / 2) +
auto bBox = GetBoundsAccurate(&nativeItem);
auto center = ((Vector3(bBox->X1, bBox->Y1, bBox->Z1) + Vector3(bBox->X2, bBox->Y2, bBox->Z2)) / 2) +
Vector3(nativeItem.Pose.Position.x, nativeItem.Pose.Position.y, nativeItem.Pose.Position.z);
center.y = nativeItem.Pose.Position.y;
float maxExtent = std::max(bb->X2 - bb->X1, bb->Z2 - bb->Z1);
float maxExtent = std::max(bBox->X2 - bBox->X1, bBox->Z2 - bBox->Z1);
auto& newSphere = nearestSpheres.emplace_back();
newSphere.position = center;
@ -102,8 +102,7 @@ namespace TEN::Renderer
std::sort(nearestSpheres.begin(), nearestSpheres.end(), [](const Sphere& a, const Sphere& b)
{
auto& laraPos = LaraItem->Pose.Position;
auto laraPosition = Vector3(laraPos.x, laraPos.y, laraPos.z);
return Vector3::Distance(laraPosition, a.position) < Vector3::Distance(laraPosition, b.position);
return Vector3::Distance(laraPos.ToVector3(), a.position) < Vector3::Distance(laraPos.ToVector3(), b.position);
});
std::copy(nearestSpheres.begin(), nearestSpheres.begin() + g_Configuration.ShadowMaxBlobs, m_stShadowMap.Spheres);

View file

@ -165,20 +165,24 @@ namespace TEN::Renderer
{
for (int k = 0; k < MAX_FIRE_LIST; k++)
{
FIRE_LIST* fire = &Fires[k];
auto* fire = &Fires[k];
if (fire->on)
{
auto fade = fire->on == 1 ? 1.0f : (float)(255 - fire->on) / 255.0f;
for (int i = 0; i < MAX_SPARKS_FIRE; i++)
{
FIRE_SPARKS* spark = &FireSparks[i];
auto* spark = &FireSparks[i];
if (spark->on)
AddSpriteBillboard(&m_sprites[spark->def], Vector3(fire->x + spark->x * fire->size / 2, fire->y + spark->y * fire->size / 2, fire->z + spark->z * fire->size / 2),
Vector4(spark->r / 255.0f * fade, spark->g / 255.0f * fade, spark->b / 255.0f * fade, 1.0f),
TO_RAD(spark->rotAng << 4),
spark->scalar,
{ spark->size * fire->size, spark->size * fire->size }, BLENDMODE_ADDITIVE, view);
{
AddSpriteBillboard(
&m_sprites[spark->def],
Vector3(fire->x + spark->x * fire->size / 2, fire->y + spark->y * fire->size / 2, fire->z + spark->z * fire->size / 2),
Vector4(spark->r / 255.0f * fade, spark->g / 255.0f * fade, spark->b / 255.0f * fade, 1.0f),
TO_RAD(spark->rotAng << 4),
spark->scalar,
Vector2(spark->size * fire->size, spark->size * fire->size), BLENDMODE_ADDITIVE, view);
}
}
}
}
@ -186,8 +190,6 @@ namespace TEN::Renderer
void Renderer11::DrawParticles(RenderView& view)
{
Vector3i nodePos;
for (int i = 0; i < MAX_NODE; i++)
NodeOffsets[i].gotIt = false;
@ -198,11 +200,11 @@ namespace TEN::Renderer
{
if (particle->flags & SP_DEF)
{
Vector3 pos = Vector3(particle->x, particle->y, particle->z);
auto pos = Vector3(particle->x, particle->y, particle->z);
if (particle->flags & SP_FX)
{
FX_INFO* fx = &EffectList[particle->fxObj];
auto* fx = &EffectList[particle->fxObj];
pos.x += fx->pos.Position.x;
pos.y += fx->pos.Position.y;
@ -224,24 +226,28 @@ namespace TEN::Renderer
}
else
{
ItemInfo* item = &g_Level.Items[particle->fxObj];
auto* item = &g_Level.Items[particle->fxObj];
if (particle->flags & SP_NODEATTACH) {
if (NodeOffsets[particle->nodeNumber].gotIt) {
auto nodePos = Vector3i::Zero;
if (particle->flags & SP_NODEATTACH)
{
if (NodeOffsets[particle->nodeNumber].gotIt)
{
nodePos.x = NodeVectors[particle->nodeNumber].x;
nodePos.y = NodeVectors[particle->nodeNumber].y;
nodePos.z = NodeVectors[particle->nodeNumber].z;
}
else {
else
{
nodePos.x = NodeOffsets[particle->nodeNumber].x;
nodePos.y = NodeOffsets[particle->nodeNumber].y;
nodePos.z = NodeOffsets[particle->nodeNumber].z;
int meshNum = NodeOffsets[particle->nodeNumber].meshNum;
if (meshNum >= 0)
GetJointAbsPosition(item, &nodePos, meshNum);
int meshIndex = NodeOffsets[particle->nodeNumber].meshNum;
if (meshIndex >= 0)
GetJointAbsPosition(item, &nodePos, meshIndex);
else
GetLaraJointPosition(&nodePos, -meshNum);
nodePos = GetLaraJointPosition(-meshIndex, nodePos);
NodeOffsets[particle->nodeNumber].gotIt = true;
@ -250,11 +256,9 @@ namespace TEN::Renderer
NodeVectors[particle->nodeNumber].z = nodePos.z;
}
pos.x += nodePos.x;
pos.y += nodePos.y;
pos.z += nodePos.z;
pos += nodePos.ToVector3();
if (particle->sLife - particle->life > (rand() & 3) + 8)
if ((particle->sLife - particle->life) > ((rand() & 3) + 8))
{
particle->flags &= ~SP_ITEM;
particle->x = pos.x;
@ -263,29 +267,27 @@ namespace TEN::Renderer
}
}
else
{
pos.x += item->Pose.Position.x;
pos.y += item->Pose.Position.y;
pos.z += item->Pose.Position.z;
}
pos += item->Pose.Position.ToVector3();
}
// Don't allow sprites out of bounds
// Don't allow sprites out of bounds.
int spriteIndex = std::clamp(int(particle->spriteIndex), 0, int(m_sprites.size()));
AddSpriteBillboard(&m_sprites[spriteIndex],
AddSpriteBillboard(
&m_sprites[spriteIndex],
pos,
Vector4(particle->r / 255.0f, particle->g / 255.0f, particle->b / 255.0f, 1.0f),
TO_RAD(particle->rotAng << 4), particle->scalar,
{ particle->size, particle->size },
Vector2(particle->size, particle->size),
particle->blendMode, view);
}
else
{
Vector3 pos = Vector3(particle->x, particle->y, particle->z);
Vector3 v = Vector3(particle->xVel, particle->yVel, particle->zVel);
auto pos = Vector3(particle->x, particle->y, particle->z);
auto v = Vector3(particle->xVel, particle->yVel, particle->zVel);
v.Normalize();
AddSpriteBillboardConstrained(&m_sprites[Objects[ID_SPARK_SPRITE].meshIndex],
AddSpriteBillboardConstrained(
&m_sprites[Objects[ID_SPARK_SPRITE].meshIndex],
pos,
Vector4(particle->r / 255.0f, particle->g / 255.0f, particle->b / 255.0f, 1.0f),
TO_RAD(particle->rotAng << 4),
@ -302,7 +304,7 @@ namespace TEN::Renderer
for (int i = 0; i < MAX_SPLASHES; i++)
{
SPLASH_STRUCT& splash = Splashes[i];
auto& splash = Splashes[i];
if (splash.isActive)
{