2020-05-27 09:21:20 +02:00
|
|
|
#include "framework.h"
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Game/misc.h"
|
|
|
|
#include "Specific/setup.h"
|
|
|
|
#include "Specific/level.h"
|
|
|
|
#include "Game/Lara/lara.h"
|
|
|
|
#include "Game/animation.h"
|
|
|
|
#include "Game/itemdata/creature_info.h"
|
|
|
|
#include "Game/items.h"
|
2021-09-25 11:27:47 +02:00
|
|
|
|
2021-09-19 18:32:41 +03:00
|
|
|
using std::vector;
|
2021-12-19 05:24:12 +03:00
|
|
|
|
2020-05-19 19:01:11 +02:00
|
|
|
CREATURE_INFO* GetCreatureInfo(ITEM_INFO* item)
|
|
|
|
{
|
|
|
|
return (CREATURE_INFO*)item->data;
|
|
|
|
}
|
|
|
|
|
2020-06-10 21:38:25 +02:00
|
|
|
void TargetNearestEntity(ITEM_INFO* item, CREATURE_INFO* creature)
|
|
|
|
{
|
|
|
|
ITEM_INFO* target;
|
|
|
|
int bestdistance;
|
|
|
|
int distance;
|
|
|
|
int x, z;
|
|
|
|
|
|
|
|
bestdistance = MAXINT;
|
2020-07-21 09:56:47 +02:00
|
|
|
for (int i = 0; i < g_Level.NumItems; i++)
|
2020-06-10 21:38:25 +02:00
|
|
|
{
|
2020-07-21 09:56:47 +02:00
|
|
|
target = &g_Level.Items[i];
|
2020-06-26 07:06:18 +02:00
|
|
|
|
2021-12-19 05:24:12 +03:00
|
|
|
if (target == nullptr)
|
|
|
|
continue;
|
2019-12-17 17:37:53 +01:00
|
|
|
|
2021-12-19 05:24:12 +03:00
|
|
|
if (target != item && target->hitPoints > 0 && target->status != ITEM_INVISIBLE)
|
2019-12-17 17:37:53 +01:00
|
|
|
{
|
2021-12-19 05:24:12 +03:00
|
|
|
x = target->pos.xPos - item->pos.xPos;
|
|
|
|
z = target->pos.zPos - item->pos.zPos;
|
|
|
|
distance = SQUARE(z) + SQUARE(x);
|
|
|
|
if (distance < bestdistance)
|
2019-12-17 17:37:53 +01:00
|
|
|
{
|
2021-12-19 05:24:12 +03:00
|
|
|
creature->enemy = target;
|
|
|
|
bestdistance = distance;
|
2019-12-17 17:37:53 +01:00
|
|
|
}
|
2020-06-26 07:06:18 +02:00
|
|
|
}
|
2019-12-17 17:37:53 +01:00
|
|
|
}
|
2019-12-16 19:04:28 +01:00
|
|
|
}
|