Update tr4_big_scorpion.cpp; name formatting cleanup

This commit is contained in:
Sezz 2022-05-26 18:44:53 +10:00
parent 155a754362
commit abc3f2e685
12 changed files with 104 additions and 92 deletions

View file

@ -815,10 +815,10 @@ void HitTarget(ItemInfo* laraItem, ItemInfo* target, GameVector* hitPos, int dam
target->HitPoints = 0; target->HitPoints = 0;
} }
} }
if (!target->luaCallbackOnHitName.empty()) if (!target->LuaCallbackOnHitName.empty())
{ {
short index = g_GameScriptEntities->GetIndexByName(target->LuaName); short index = g_GameScriptEntities->GetIndexByName(target->LuaName);
g_GameScript->ExecuteFunction(target->luaCallbackOnHitName, index); g_GameScript->ExecuteFunction(target->LuaCallbackOnHitName, index);
} }
} }

View file

@ -203,10 +203,10 @@ bool GetTargetOnLOS(GameVector* src, GameVector* dest, bool drawTarget, bool fir
if (!Objects[item->ObjectNumber].undead) if (!Objects[item->ObjectNumber].undead)
item->HitPoints -= Weapons[(int)Lara.Control.Weapon.GunType].Damage; item->HitPoints -= Weapons[(int)Lara.Control.Weapon.GunType].Damage;
if (!item->luaCallbackOnHitName.empty()) if (!item->LuaCallbackOnHitName.empty())
{ {
short index = g_GameScriptEntities->GetIndexByName(item->LuaName); short index = g_GameScriptEntities->GetIndexByName(item->LuaName);
g_GameScript->ExecuteFunction(item->luaCallbackOnHitName, index); g_GameScript->ExecuteFunction(item->LuaCallbackOnHitName, index);
} }
} }
} }

View file

@ -88,16 +88,16 @@ void KillItem(short const itemNumber)
g_GameScriptEntities->NotifyKilled(item); g_GameScriptEntities->NotifyKilled(item);
g_GameScriptEntities->TryRemoveColliding(itemNumber, true); g_GameScriptEntities->TryRemoveColliding(itemNumber, true);
if (!item->luaCallbackOnKilledName.empty()) if (!item->LuaCallbackOnKilledName.empty())
{ {
g_GameScript->ExecuteFunction(item->luaCallbackOnKilledName, itemNumber); g_GameScript->ExecuteFunction(item->LuaCallbackOnKilledName, itemNumber);
} }
item->LuaName.clear(); item->LuaName.clear();
item->luaCallbackOnKilledName.clear(); item->LuaCallbackOnKilledName.clear();
item->luaCallbackOnHitName.clear(); item->LuaCallbackOnHitName.clear();
item->luaCallbackOnCollidedWithObjectName.clear(); item->LuaCallbackOnCollidedWithObjectName.clear();
item->luaCallbackOnCollidedWithRoomName.clear(); item->LuaCallbackOnCollidedWithRoomName.clear();
} }
} }
@ -333,9 +333,9 @@ void RemoveActiveItem(short itemNumber)
} }
g_GameScriptEntities->NotifyKilled(&item); g_GameScriptEntities->NotifyKilled(&item);
if (!item.luaCallbackOnKilledName.empty()) if (!item.LuaCallbackOnKilledName.empty())
{ {
g_GameScript->ExecuteFunction(item.luaCallbackOnKilledName, itemNumber); g_GameScript->ExecuteFunction(item.LuaCallbackOnKilledName, itemNumber);
} }
} }
} }

View file

@ -70,7 +70,6 @@ struct EntityAnimationData
//todo we need to find good "default states" for a lot of these - squidshire 25/05/2022 //todo we need to find good "default states" for a lot of these - squidshire 25/05/2022
struct ItemInfo struct ItemInfo
{ {
std::string LuaName;
GAME_OBJECT_ID ObjectNumber; GAME_OBJECT_ID ObjectNumber;
int Status; // ItemStatus enum. int Status; // ItemStatus enum.
bool Active; bool Active;
@ -108,11 +107,12 @@ struct ItemInfo
short AfterDeath; short AfterDeath;
short CarriedItem; short CarriedItem;
// New LUA stuff // Lua
std::string luaCallbackOnKilledName; std::string LuaName;
std::string luaCallbackOnHitName; std::string LuaCallbackOnKilledName;
std::string luaCallbackOnCollidedWithObjectName; std::string LuaCallbackOnHitName;
std::string luaCallbackOnCollidedWithRoomName; std::string LuaCallbackOnCollidedWithObjectName;
std::string LuaCallbackOnCollidedWithRoomName;
}; };
void EffectNewRoom(short fxNumber, short roomNumber); void EffectNewRoom(short fxNumber, short roomNumber);

View file

@ -414,10 +414,10 @@ bool SaveGame::Save(int slot)
ObjectInfo* obj = &Objects[itemToSerialize.ObjectNumber]; ObjectInfo* obj = &Objects[itemToSerialize.ObjectNumber];
auto luaNameOffset = fbb.CreateString(itemToSerialize.LuaName); auto luaNameOffset = fbb.CreateString(itemToSerialize.LuaName);
auto luaOnKilledNameOffset = fbb.CreateString(itemToSerialize.luaCallbackOnKilledName); auto luaOnKilledNameOffset = fbb.CreateString(itemToSerialize.LuaCallbackOnKilledName);
auto luaOnHitNameOffset = fbb.CreateString(itemToSerialize.luaCallbackOnHitName); auto luaOnHitNameOffset = fbb.CreateString(itemToSerialize.LuaCallbackOnHitName);
auto luaOnCollidedObjectNameOffset = fbb.CreateString(itemToSerialize.luaCallbackOnCollidedWithObjectName); auto luaOnCollidedObjectNameOffset = fbb.CreateString(itemToSerialize.LuaCallbackOnCollidedWithObjectName);
auto luaOnCollidedRoomNameOffset = fbb.CreateString(itemToSerialize.luaCallbackOnCollidedWithRoomName); auto luaOnCollidedRoomNameOffset = fbb.CreateString(itemToSerialize.LuaCallbackOnCollidedWithRoomName);
std::vector<int> itemFlags; std::vector<int> itemFlags;
for (int i = 0; i < 7; i++) for (int i = 0; i < 7; i++)
@ -1050,10 +1050,10 @@ bool SaveGame::Load(int slot)
if (!item->LuaName.empty()) if (!item->LuaName.empty())
g_GameScriptEntities->AddName(item->LuaName, i); g_GameScriptEntities->AddName(item->LuaName, i);
item->luaCallbackOnKilledName = savedItem->lua_on_killed_name()->str(); item->LuaCallbackOnKilledName = savedItem->lua_on_killed_name()->str();
item->luaCallbackOnHitName = savedItem->lua_on_hit_name()->str(); item->LuaCallbackOnHitName = savedItem->lua_on_hit_name()->str();
item->luaCallbackOnCollidedWithObjectName = savedItem->lua_on_collided_with_object_name()->str(); item->LuaCallbackOnCollidedWithObjectName = savedItem->lua_on_collided_with_object_name()->str();
item->luaCallbackOnCollidedWithRoomName = savedItem->lua_on_collided_with_room_name()->str(); item->LuaCallbackOnCollidedWithRoomName = savedItem->lua_on_collided_with_room_name()->str();
g_GameScriptEntities->TryAddColliding(i); g_GameScriptEntities->TryAddColliding(i);

View file

@ -1,5 +1,5 @@
#include "framework.h" #include "framework.h"
#include "tr4_bigscorpion.h" #include "tr4_big_scorpion.h"
#include "Game/collision/collide_room.h" #include "Game/collision/collide_room.h"
#include "Game/control/box.h" #include "Game/control/box.h"
#include "Game/effects/effects.h" #include "Game/effects/effects.h"
@ -17,22 +17,33 @@ int CutSeqNum;
BITE_INFO BigScorpionBite1 = { 0, 0, 0, 8 }; BITE_INFO BigScorpionBite1 = { 0, 0, 0, 8 };
BITE_INFO BigScorpionBite2 = { 0, 0, 0, 23 }; BITE_INFO BigScorpionBite2 = { 0, 0, 0, 23 };
constexpr auto BIG_SCORPION_POISON_POTENCY = 8;
constexpr auto BIG_SCORPION_DAMAGE = 120;
constexpr auto BIG_SCORPION_TROOP_DAMAGE = 15;
enum BigScorpionState enum BigScorpionState
{ {
BSCORPION_STATE_NONE = 0,
BSCORPION_STATE_IDLE = 1, BSCORPION_STATE_IDLE = 1,
BSCORPION_STATE_WALK = 2, BSCORPION_STATE_WALK_FORWARD = 2,
BSCORPION_STATE_RUN = 3, BSCORPION_STATE_RUN_FORWARD = 3,
BSCORPION_STATE_ATTACK_1 = 4, BSCORPION_STATE_PINCER_ATTACK = 4,
BSCORPION_STATE_ATTACK_2 = 5, BSCORPION_STATE_STINGER_ATTACK = 5,
BSCORPION_STATE_DEATH = 6, BSCORPION_STATE_DEATH = 6,
BSCORPION_STATE_SPECIAL_DEATH = 7, BSCORPION_STATE_KILL = 7,
BSCORPION_STATE_TROOPS_ATTACK = 8 BSCORPION_STATE_KILL_TROOP = 8
}; };
// TODO
enum BigScorpionAnim enum BigScorpionAnim
{ {
BSCORPION_ANIM_WALK_FORWARD = 0,
BSCORPION_ANIM_RUN_FORWARD = 1,
BSCORPION_ANIM_IDLE = 2,
BSCORPION_ANIM_PINCER_ATTACK = 3,
BSCORPION_ANIM_STINGER_ATTACK = 4,
BSCORPION_ANIM_DEATH = 5,
BSCORPION_ANIM_KILL = 6,
BSCORPION_ANIM_KILL_TROOP = 7
}; };
void InitialiseScorpion(short itemNumber) void InitialiseScorpion(short itemNumber)
@ -43,15 +54,15 @@ void InitialiseScorpion(short itemNumber)
if (item->TriggerFlags == 1) if (item->TriggerFlags == 1)
{ {
item->Animation.TargetState = BSCORPION_STATE_TROOPS_ATTACK; item->Animation.TargetState = BSCORPION_STATE_KILL_TROOP;
item->Animation.ActiveState = BSCORPION_STATE_TROOPS_ATTACK; item->Animation.ActiveState = BSCORPION_STATE_KILL_TROOP;
item->Animation.AnimNumber = Objects[ID_BIG_SCORPION].animIndex + 7; item->Animation.AnimNumber = Objects[ID_BIG_SCORPION].animIndex + BSCORPION_ANIM_KILL_TROOP;
} }
else else
{ {
item->Animation.TargetState = BSCORPION_STATE_IDLE; item->Animation.TargetState = BSCORPION_STATE_IDLE;
item->Animation.ActiveState = BSCORPION_STATE_IDLE; item->Animation.ActiveState = BSCORPION_STATE_IDLE;
item->Animation.AnimNumber = Objects[ID_BIG_SCORPION].animIndex + 2; item->Animation.AnimNumber = Objects[ID_BIG_SCORPION].animIndex + BSCORPION_ANIM_IDLE;
} }
item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase; item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase;
@ -115,11 +126,12 @@ void ScorpionControl(short itemNumber)
item->HitPoints = 0; item->HitPoints = 0;
if (item->Animation.ActiveState != BSCORPION_STATE_DEATH) if (item->Animation.ActiveState != BSCORPION_STATE_DEATH)
{ {
if (item->TriggerFlags > 0 && item->TriggerFlags < 7) if (item->TriggerFlags > 0 &&
item->TriggerFlags < 7)
{ {
CutSeqNum = 4; CutSeqNum = 4;
item->Animation.AnimNumber = Objects[item->Animation.AnimNumber].animIndex + 5; item->Animation.AnimNumber = Objects[item->Animation.AnimNumber].animIndex + BSCORPION_ANIM_DEATH;
item->Animation.ActiveState = BSCORPION_STATE_DEATH; item->Animation.ActiveState = BSCORPION_STATE_DEATH;
item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase; item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase;
item->Status = ITEM_INVISIBLE; item->Status = ITEM_INVISIBLE;
@ -142,9 +154,9 @@ void ScorpionControl(short itemNumber)
} }
} }
} }
else if (item->Animation.ActiveState != BSCORPION_STATE_DEATH && item->Animation.ActiveState != BSCORPION_STATE_SPECIAL_DEATH) else if (item->Animation.ActiveState != BSCORPION_STATE_DEATH && item->Animation.ActiveState != BSCORPION_STATE_KILL)
{ {
item->Animation.AnimNumber = Objects[item->ObjectNumber].animIndex + 5; item->Animation.AnimNumber = Objects[item->ObjectNumber].animIndex + BSCORPION_ANIM_DEATH;
item->Animation.ActiveState = BSCORPION_STATE_DEATH; item->Animation.ActiveState = BSCORPION_STATE_DEATH;
item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase; item->Animation.FrameNumber = g_Level.Anims[item->Animation.AnimNumber].frameBase;
} }
@ -166,11 +178,11 @@ void ScorpionControl(short itemNumber)
GetAITarget(creature); GetAITarget(creature);
else else
{ {
if (creature->HurtByLara && item->Animation.ActiveState != BSCORPION_STATE_TROOPS_ATTACK) if (creature->HurtByLara && item->Animation.ActiveState != BSCORPION_STATE_KILL_TROOP)
creature->Enemy = LaraItem; creature->Enemy = LaraItem;
else else
{ {
creature->Enemy = NULL; creature->Enemy = nullptr;
int minDistance = INT_MAX; int minDistance = INT_MAX;
for (int i = 0; i < ActiveCreatures.size(); i++) for (int i = 0; i < ActiveCreatures.size(); i++)
@ -204,11 +216,11 @@ void ScorpionControl(short itemNumber)
} }
} }
AI_INFO info; AI_INFO AI;
CreatureAIInfo(item, &info); CreatureAIInfo(item, &AI);
GetCreatureMood(item, &info, VIOLENT); GetCreatureMood(item, &AI, VIOLENT);
CreatureMood(item, &info, VIOLENT); CreatureMood(item, &AI, VIOLENT);
angle = CreatureTurn(item, creature->MaxTurn); angle = CreatureTurn(item, creature->MaxTurn);
@ -218,13 +230,13 @@ void ScorpionControl(short itemNumber)
creature->MaxTurn = 0; creature->MaxTurn = 0;
creature->Flags = 0; creature->Flags = 0;
if (info.distance > pow(1365, 2)) if (AI.distance > pow(1365, 2))
{ {
item->Animation.TargetState = BSCORPION_STATE_WALK; item->Animation.TargetState = BSCORPION_STATE_WALK_FORWARD;
break; break;
} }
if (info.bite) if (AI.bite)
{ {
creature->MaxTurn = ANGLE(2.0f); creature->MaxTurn = ANGLE(2.0f);
@ -232,59 +244,59 @@ void ScorpionControl(short itemNumber)
creature->Enemy->HitPoints <= 15 && creature->Enemy->HitPoints <= 15 &&
creature->Enemy->ObjectNumber == ID_TROOPS) creature->Enemy->ObjectNumber == ID_TROOPS)
{ {
item->Animation.TargetState = BSCORPION_STATE_ATTACK_1; item->Animation.TargetState = BSCORPION_STATE_PINCER_ATTACK;
} }
else else
item->Animation.TargetState = BSCORPION_STATE_ATTACK_2; item->Animation.TargetState = BSCORPION_STATE_STINGER_ATTACK;
} }
else if (!info.ahead) else if (!AI.ahead)
item->Animation.TargetState = BSCORPION_STATE_WALK; item->Animation.TargetState = BSCORPION_STATE_WALK_FORWARD;
break; break;
case BSCORPION_STATE_WALK: case BSCORPION_STATE_WALK_FORWARD:
creature->MaxTurn = ANGLE(2.0f); creature->MaxTurn = ANGLE(2.0f);
if (info.distance < pow(1365, 2)) if (AI.distance < pow(1365, 2))
item->Animation.TargetState = BSCORPION_STATE_IDLE; item->Animation.TargetState = BSCORPION_STATE_IDLE;
else if (info.distance > pow(853, 2)) else if (AI.distance > pow(853, 2))
item->Animation.TargetState = BSCORPION_STATE_RUN; item->Animation.TargetState = BSCORPION_STATE_RUN_FORWARD;
break; break;
case BSCORPION_STATE_RUN: case BSCORPION_STATE_RUN_FORWARD:
creature->MaxTurn = ANGLE(3.0f); creature->MaxTurn = ANGLE(3.0f);
if (info.distance < pow(1365, 2)) if (AI.distance < pow(1365, 2))
item->Animation.TargetState = BSCORPION_STATE_IDLE; item->Animation.TargetState = BSCORPION_STATE_IDLE;
break; break;
case BSCORPION_STATE_ATTACK_1: case BSCORPION_STATE_PINCER_ATTACK:
case BSCORPION_STATE_ATTACK_2: case BSCORPION_STATE_STINGER_ATTACK:
creature->MaxTurn = 0; creature->MaxTurn = 0;
if (abs(info.angle) >= ANGLE(2.0f)) if (abs(AI.angle) >= ANGLE(2.0f))
{ {
if (info.angle >= 0) if (AI.angle >= 0)
item->Pose.Orientation.y += ANGLE(2.0f); item->Pose.Orientation.y += ANGLE(2.0f);
else else
item->Pose.Orientation.y -= ANGLE(2.0f); item->Pose.Orientation.y -= ANGLE(2.0f);
} }
else else
item->Pose.Orientation.y += info.angle; item->Pose.Orientation.y += AI.angle;
if (creature->Flags) if (creature->Flags)
break; break;
if (creature->Enemy && if (creature->Enemy &&
creature->Enemy != LaraItem && creature->Enemy != LaraItem &&
info.distance < pow(1365, 2)) AI.distance < pow(1365, 2))
{ {
creature->Enemy->HitPoints -= 15; creature->Enemy->HitPoints -= BIG_SCORPION_TROOP_DAMAGE;
if (creature->Enemy->HitPoints <= 0) if (creature->Enemy->HitPoints <= 0)
{ {
item->Animation.TargetState = BSCORPION_STATE_SPECIAL_DEATH; item->Animation.TargetState = BSCORPION_STATE_KILL;
creature->MaxTurn = 0; creature->MaxTurn = 0;
} }
@ -300,12 +312,12 @@ void ScorpionControl(short itemNumber)
} }
else if (item->TouchBits & 0x1B00100) else if (item->TouchBits & 0x1B00100)
{ {
LaraItem->HitPoints -= 120; LaraItem->HitPoints -= BIG_SCORPION_DAMAGE;
LaraItem->HitStatus = true; LaraItem->HitStatus = true;
if (item->Animation.ActiveState == 5) if (item->Animation.ActiveState == BSCORPION_STATE_STINGER_ATTACK)
{ {
Lara.PoisonPotency += 8; Lara.PoisonPotency += BIG_SCORPION_POISON_POTENCY;
CreatureEffect2( CreatureEffect2(
item, item,
@ -335,7 +347,7 @@ void ScorpionControl(short itemNumber)
break; break;
case BSCORPION_STATE_TROOPS_ATTACK: case BSCORPION_STATE_KILL_TROOP:
creature->MaxTurn = 0; creature->MaxTurn = 0;
if (item->Animation.FrameNumber == g_Level.Anims[item->Animation.AnimNumber].frameEnd) if (item->Animation.FrameNumber == g_Level.Anims[item->Animation.AnimNumber].frameEnd)
@ -346,7 +358,7 @@ void ScorpionControl(short itemNumber)
creature->Enemy->HitPoints <= 0 || creature->Enemy->HitPoints <= 0 ||
item->TriggerFlags > 6) item->TriggerFlags > 6)
{ {
item->Animation.TargetState = BSCORPION_STATE_SPECIAL_DEATH; item->Animation.TargetState = BSCORPION_STATE_KILL;
creature->Enemy->HitPoints = 0; creature->Enemy->HitPoints = 0;
} }

View file

@ -5,7 +5,7 @@
#include "tr4_ahmet.h" // OK #include "tr4_ahmet.h" // OK
#include "tr4_baddy.h" // OK #include "tr4_baddy.h" // OK
#include "tr4_bat.h" // OK #include "tr4_bat.h" // OK
#include "tr4_bigscorpion.h" // OK #include "tr4_big_scorpion.h" // OK
#include "tr4_crocodile.h" // OK #include "tr4_crocodile.h" // OK
#include "tr4_demigod.h" // OK #include "tr4_demigod.h" // OK
#include "tr4_guide.h" // OK #include "tr4_guide.h" // OK

View file

@ -395,17 +395,17 @@ void Moveable::SetObjectID(GAME_OBJECT_ID id)
void Moveable::SetOnHit(std::string const & cbName) void Moveable::SetOnHit(std::string const & cbName)
{ {
m_item->luaCallbackOnHitName = cbName; m_item->LuaCallbackOnHitName = cbName;
} }
void Moveable::SetOnKilled(std::string const & cbName) void Moveable::SetOnKilled(std::string const & cbName)
{ {
m_item->luaCallbackOnKilledName = cbName; m_item->LuaCallbackOnKilledName = cbName;
} }
void Moveable::SetOnCollidedWithObject(std::string const & cbName) void Moveable::SetOnCollidedWithObject(std::string const & cbName)
{ {
m_item->luaCallbackOnCollidedWithObjectName = cbName; m_item->LuaCallbackOnCollidedWithObjectName = cbName;
if(cbName.empty()) if(cbName.empty())
dynamic_cast<ObjectsHandler*>(g_GameScriptEntities)->TryRemoveColliding(m_num); dynamic_cast<ObjectsHandler*>(g_GameScriptEntities)->TryRemoveColliding(m_num);
@ -415,7 +415,7 @@ void Moveable::SetOnCollidedWithObject(std::string const & cbName)
void Moveable::SetOnCollidedWithRoom(std::string const & cbName) void Moveable::SetOnCollidedWithRoom(std::string const & cbName)
{ {
m_item->luaCallbackOnCollidedWithRoomName = cbName; m_item->LuaCallbackOnCollidedWithRoomName = cbName;
if(cbName.empty()) if(cbName.empty())
dynamic_cast<ObjectsHandler*>(g_GameScriptEntities)->TryRemoveColliding(m_num); dynamic_cast<ObjectsHandler*>(g_GameScriptEntities)->TryRemoveColliding(m_num);
@ -425,22 +425,22 @@ void Moveable::SetOnCollidedWithRoom(std::string const & cbName)
std::string Moveable::GetOnHit() const std::string Moveable::GetOnHit() const
{ {
return m_item->luaCallbackOnHitName; return m_item->LuaCallbackOnHitName;
} }
std::string Moveable::GetOnKilled() const std::string Moveable::GetOnKilled() const
{ {
return m_item->luaCallbackOnKilledName; return m_item->LuaCallbackOnKilledName;
} }
std::string Moveable::GetOnCollidedWithObject() const std::string Moveable::GetOnCollidedWithObject() const
{ {
return m_item->luaCallbackOnCollidedWithObjectName; return m_item->LuaCallbackOnCollidedWithObjectName;
} }
std::string Moveable::GetOnCollidedWithRoom() const std::string Moveable::GetOnCollidedWithRoom() const
{ {
return m_item->luaCallbackOnCollidedWithRoomName; return m_item->LuaCallbackOnCollidedWithRoomName;
} }
std::string Moveable::GetName() const std::string Moveable::GetName() const

View file

@ -123,7 +123,7 @@ void ObjectsHandler::TestCollidingObjects()
for (const auto idOne : m_collidingItems) for (const auto idOne : m_collidingItems)
{ {
auto item = &g_Level.Items[idOne]; auto item = &g_Level.Items[idOne];
if (!item->luaCallbackOnCollidedWithObjectName.empty()) if (!item->LuaCallbackOnCollidedWithObjectName.empty())
{ {
//test against other moveables //test against other moveables
GetCollidedObjects(item, 0, true, CollidedItems, nullptr, 0); GetCollidedObjects(item, 0, true, CollidedItems, nullptr, 0);
@ -131,17 +131,17 @@ void ObjectsHandler::TestCollidingObjects()
while (CollidedItems[i]) while (CollidedItems[i])
{ {
short idTwo = CollidedItems[i] - &g_Level.Items[0]; short idTwo = CollidedItems[i] - &g_Level.Items[0];
g_GameScript->ExecuteFunction(item->luaCallbackOnCollidedWithObjectName, idOne, idTwo); g_GameScript->ExecuteFunction(item->LuaCallbackOnCollidedWithObjectName, idOne, idTwo);
++i; ++i;
} }
} }
if (!item->luaCallbackOnCollidedWithRoomName.empty()) if (!item->LuaCallbackOnCollidedWithRoomName.empty())
{ {
//test against room geometry //test against room geometry
if (TestItemRoomCollisionAABB(item)) if (TestItemRoomCollisionAABB(item))
{ {
g_GameScript->ExecuteFunction(item->luaCallbackOnCollidedWithRoomName, idOne); g_GameScript->ExecuteFunction(item->LuaCallbackOnCollidedWithRoomName, idOne);
} }
} }
} }

View file

@ -20,7 +20,7 @@ public:
bool TryAddColliding(short id) override bool TryAddColliding(short id) override
{ {
ItemInfo* item = &g_Level.Items[id]; ItemInfo* item = &g_Level.Items[id];
bool hasName = !(item->luaCallbackOnCollidedWithObjectName.empty() && item->luaCallbackOnCollidedWithRoomName.empty()); bool hasName = !(item->LuaCallbackOnCollidedWithObjectName.empty() && item->LuaCallbackOnCollidedWithRoomName.empty());
if(hasName && item->Collidable && (item->Status != ITEM_INVISIBLE)) if(hasName && item->Collidable && (item->Status != ITEM_INVISIBLE))
return m_collidingItems.insert(id).second; return m_collidingItems.insert(id).second;
@ -30,7 +30,7 @@ public:
bool TryRemoveColliding(short id, bool force = false) override bool TryRemoveColliding(short id, bool force = false) override
{ {
ItemInfo* item = &g_Level.Items[id]; ItemInfo* item = &g_Level.Items[id];
bool hasName = !(item->luaCallbackOnCollidedWithObjectName.empty() && item->luaCallbackOnCollidedWithRoomName.empty()); bool hasName = !(item->LuaCallbackOnCollidedWithObjectName.empty() && item->LuaCallbackOnCollidedWithRoomName.empty());
if(!force && hasName && item->Collidable && (item->Status != ITEM_INVISIBLE)) if(!force && hasName && item->Collidable && (item->Status != ITEM_INVISIBLE))
return false; return false;

View file

@ -446,7 +446,7 @@ CALL gen.bat</Command>
<ClInclude Include="Objects\TR4\Entity\tr4_ahmet.h" /> <ClInclude Include="Objects\TR4\Entity\tr4_ahmet.h" />
<ClInclude Include="Objects\TR4\Entity\tr4_baddy.h" /> <ClInclude Include="Objects\TR4\Entity\tr4_baddy.h" />
<ClInclude Include="Objects\TR4\Entity\tr4_bat.h" /> <ClInclude Include="Objects\TR4\Entity\tr4_bat.h" />
<ClInclude Include="Objects\TR4\Entity\tr4_bigscorpion.h" /> <ClInclude Include="Objects\TR4\Entity\tr4_big_scorpion.h" />
<ClInclude Include="Objects\TR4\Entity\tr4_crocodile.h" /> <ClInclude Include="Objects\TR4\Entity\tr4_crocodile.h" />
<ClInclude Include="Objects\TR4\Entity\tr4_demigod.h" /> <ClInclude Include="Objects\TR4\Entity\tr4_demigod.h" />
<ClInclude Include="Objects\TR4\Entity\tr4_guide.h" /> <ClInclude Include="Objects\TR4\Entity\tr4_guide.h" />
@ -824,7 +824,7 @@ CALL gen.bat</Command>
<ClCompile Include="Objects\TR3\Entity\tr3_tiger.cpp" /> <ClCompile Include="Objects\TR3\Entity\tr3_tiger.cpp" />
<ClCompile Include="Objects\TR3\Entity\tr3_trex.cpp" /> <ClCompile Include="Objects\TR3\Entity\tr3_trex.cpp" />
<ClCompile Include="Objects\TR4\Entity\tr4_bat.cpp" /> <ClCompile Include="Objects\TR4\Entity\tr4_bat.cpp" />
<ClCompile Include="Objects\TR4\Entity\tr4_bigscorpion.cpp" /> <ClCompile Include="Objects\TR4\Entity\tr4_big_scorpion.cpp" />
<ClCompile Include="Objects\TR4\Entity\tr4_crocodile.cpp" /> <ClCompile Include="Objects\TR4\Entity\tr4_crocodile.cpp" />
<ClCompile Include="Objects\TR4\Entity\tr4_harpy.cpp" /> <ClCompile Include="Objects\TR4\Entity\tr4_harpy.cpp" />
<ClCompile Include="Objects\TR4\Entity\tr4_beetle_swarm.cpp" /> <ClCompile Include="Objects\TR4\Entity\tr4_beetle_swarm.cpp" />