mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-30 08:47:58 +03:00
Fix doppelganger formatting
This commit is contained in:
parent
29a136b3e5
commit
68b51a1554
1 changed files with 35 additions and 15 deletions
|
@ -13,22 +13,21 @@
|
||||||
|
|
||||||
namespace TEN::Entities::Creatures::TR1
|
namespace TEN::Entities::Creatures::TR1
|
||||||
{
|
{
|
||||||
ItemInfo* FindReference(ItemInfo* item, short objectNumber)
|
std::optional<ItemInfo&> FindDoppelgangerReference(const ItemInfo& item, int objectNumber)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < g_Level.NumItems; i++)
|
for (int i = 0; i < g_Level.NumItems; i++)
|
||||||
{
|
{
|
||||||
auto* currentItem = &g_Level.Items[i];
|
auto& currentItem = g_Level.Items[i];
|
||||||
if (currentItem->ObjectNumber == objectNumber && item->TriggerFlags == currentItem->TriggerFlags)
|
if (currentItem.ObjectNumber == objectNumber && item.TriggerFlags == currentItem.TriggerFlags)
|
||||||
{
|
|
||||||
return currentItem;
|
return currentItem;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
|
||||||
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
short GetWeaponDamage(LaraWeaponType weaponType)
|
int GetWeaponDamage(LaraWeaponType weaponType)
|
||||||
{
|
{
|
||||||
return short(Weapons[(int)weaponType].Damage) * 10;
|
return (Weapons[(int)weaponType].Damage * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoppelgangerControl(short itemNumber)
|
void DoppelgangerControl(short itemNumber)
|
||||||
|
@ -43,10 +42,10 @@ namespace TEN::Entities::Creatures::TR1
|
||||||
DoDamage(LaraItem, GetWeaponDamage(Lara.Control.Weapon.GunType));
|
DoDamage(LaraItem, GetWeaponDamage(Lara.Control.Weapon.GunType));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* reference = FindReference(item, ID_BACON_REFERENCE);
|
auto reference = FindDoppelgangerReference(*item, ID_BACON_REFERENCE);
|
||||||
if (reference == nullptr)
|
if (!reference.has_value())
|
||||||
{
|
{
|
||||||
TENLog("Doppelganger require ID_BACON_REFERENCE to be placed on the center (on floor) of the room to be used !", LogLevel::Warning);
|
TENLog("Doppelganger requires ID_DOPPELGANGER_REFERENCE to be placed in room center.", LogLevel::Warning);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +56,13 @@ namespace TEN::Entities::Creatures::TR1
|
||||||
int laraFloorHeight = GetCollision(LaraItem).Position.Floor;
|
int laraFloorHeight = GetCollision(LaraItem).Position.Floor;
|
||||||
|
|
||||||
// Get floor heights for comparison.
|
// Get floor heights for comparison.
|
||||||
Vector3i pos(2 * reference->Pose.Position.x - LaraItem->Pose.Position.x, LaraItem->Pose.Position.y, 2 * reference->Pose.Position.z - LaraItem->Pose.Position.z);
|
auto pos = Vector3i(
|
||||||
|
(reference->Pose.Position.x * 2) - LaraItem->Pose.Position.x,
|
||||||
|
LaraItem->Pose.Position.y,
|
||||||
|
(reference->Pose.Position.z * 2) - LaraItem->Pose.Position.z);
|
||||||
item->Floor = GetCollision(pos.x, pos.y, pos.z, item->RoomNumber).Position.Floor;
|
item->Floor = GetCollision(pos.x, pos.y, pos.z, item->RoomNumber).Position.Floor;
|
||||||
|
|
||||||
// Animate bacon Lara, mirroring Lara's position.
|
// Animate doppelganger, mirroring player's position.
|
||||||
item->Animation.AnimNumber = LaraItem->Animation.AnimNumber;
|
item->Animation.AnimNumber = LaraItem->Animation.AnimNumber;
|
||||||
item->Animation.FrameNumber = LaraItem->Animation.FrameNumber;
|
item->Animation.FrameNumber = LaraItem->Animation.FrameNumber;
|
||||||
item->Pose.Position = pos;
|
item->Pose.Position = pos;
|
||||||
|
@ -77,40 +79,58 @@ namespace TEN::Entities::Creatures::TR1
|
||||||
item->Pose.Position.y += 64;
|
item->Pose.Position.y += 64;
|
||||||
item->ItemFlags[7] = 1;
|
item->ItemFlags[7] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
if (item->Animation.Velocity.x > 0.0f)
|
if (item->Animation.Velocity.x > 0.0f)
|
||||||
|
{
|
||||||
item->Animation.Velocity.x -= 2;
|
item->Animation.Velocity.x -= 2;
|
||||||
|
}
|
||||||
else if (item->Animation.Velocity.x < 0.0f)
|
else if (item->Animation.Velocity.x < 0.0f)
|
||||||
|
{
|
||||||
item->Animation.Velocity.x += 2;
|
item->Animation.Velocity.x += 2;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
item->Animation.Velocity.x = 0.0f;
|
item->Animation.Velocity.x = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
if (item->Animation.Velocity.z > 0.0f)
|
if (item->Animation.Velocity.z > 0.0f)
|
||||||
|
{
|
||||||
item->Animation.Velocity.z -= 2;
|
item->Animation.Velocity.z -= 2;
|
||||||
|
}
|
||||||
else if (item->Animation.Velocity.z < 0.0f)
|
else if (item->Animation.Velocity.z < 0.0f)
|
||||||
|
{
|
||||||
item->Animation.Velocity.z += 2;
|
item->Animation.Velocity.z += 2;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
item->Animation.Velocity.z = 0.0f;
|
item->Animation.Velocity.z = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
TestTriggers(item, true);
|
TestTriggers(item, true);
|
||||||
item->Floor = GetCollision(item).Position.Floor;
|
item->Floor = GetCollision(item).Position.Floor;
|
||||||
|
|
||||||
if (item->Pose.Position.y >= item->Floor)
|
if (item->Pose.Position.y >= item->Floor)
|
||||||
{
|
{
|
||||||
item->Pose.Position.y = item->Floor;
|
item->Pose.Position.y = item->Floor;
|
||||||
TestTriggers(item, true);
|
TestTriggers(item, true);
|
||||||
|
|
||||||
SetAnimation(item, LA_FREEFALL_DEATH);
|
SetAnimation(item, LA_FREEFALL_DEATH);
|
||||||
item->Animation.IsAirborne = false;
|
item->Animation.IsAirborne = false;
|
||||||
item->Animation.Velocity.y = 0.0f;
|
item->Animation.Velocity.y = 0.0f;
|
||||||
if (item->Animation.FrameNumber >= GetFrameCount(LA_FREEFALL_DEATH)-1)
|
|
||||||
|
if (item->Animation.FrameNumber >= GetFrameCount(LA_FREEFALL_DEATH) - 1)
|
||||||
item->ItemFlags[7] = 2;
|
item->ItemFlags[7] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
DisableEntityAI(itemNumber);
|
DisableEntityAI(itemNumber);
|
||||||
RemoveActiveItem(itemNumber);
|
RemoveActiveItem(itemNumber);
|
||||||
item->Collidable = FALSE;
|
item->Collidable = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue