MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / GetAITarget

Function GetAITarget

TombEngine/Game/control/box.cpp:2230–2320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2228}
2229
2230void GetAITarget(CreatureInfo* creature)
2231{
2232 auto* enemy = creature->Enemy;
2233
2234 short enemyObjectNumber;
2235 if (enemy)
2236 enemyObjectNumber = enemy->ObjectNumber;
2237 else
2238 enemyObjectNumber = NO_VALUE;
2239
2240 auto* item = &g_Level.Items[creature->ItemNumber];
2241
2242 if (item->AIBits & GUARD)
2243 {
2244 creature->Enemy = LaraItem;
2245 if (creature->Alerted)
2246 {
2247 item->AIBits &= ~GUARD;
2248 if (item->AIBits & AMBUSH)
2249 item->AIBits |= MODIFY;
2250 }
2251 }
2252 else if (item->AIBits & PATROL1)
2253 {
2254 if (creature->Alerted || creature->HurtByLara)
2255 {
2256 item->AIBits &= ~PATROL1;
2257 if (item->AIBits & AMBUSH)
2258 item->AIBits |= MODIFY;
2259 }
2260 else if (!creature->Patrol)
2261 {
2262 if (enemyObjectNumber != ID_AI_PATROL1)
2263 FindAITargetObject(creature, ID_AI_PATROL1);
2264 }
2265 else
2266 {
2267 if (enemyObjectNumber != ID_AI_PATROL2)
2268 FindAITargetObject(creature, ID_AI_PATROL2);
2269 }
2270
2271 if ((enemyObjectNumber == ID_AI_PATROL1 || enemyObjectNumber == ID_AI_PATROL2) &&
2272 Vector3i::Distance(enemy->Pose.Position, item->Pose.Position) < REACHED_GOAL_RADIUS)
2273 {
2274 TestTriggers(enemy, true);
2275 creature->Patrol = !creature->Patrol;
2276 }
2277 }
2278 else if (item->AIBits & AMBUSH)
2279 {
2280 if (enemyObjectNumber != ID_AI_AMBUSH)
2281 {
2282 FindAITargetObject(creature, ID_AI_AMBUSH);
2283 }
2284 else if (Vector3i::Distance(enemy->Pose.Position, item->Pose.Position) < REACHED_GOAL_RADIUS)
2285 {
2286 TestTriggers(enemy, true);
2287 creature->ReachedGoal = true;

Callers 15

MPGunControlFunction · 0.85
CivvyControlFunction · 0.85
RaptorControlFunction · 0.85
SophiaLeighTowerControlFunction · 0.85
FlameThrowerControlFunction · 0.85
MPStickControlFunction · 0.85
MonkeyControlFunction · 0.85
WaspMutantControlFunction · 0.85
TribemanDartsControlFunction · 0.85
CompsognathusControlFunction · 0.85
ClawMutantControlFunction · 0.85
ControlSealMutantFunction · 0.85

Calls 2

FindAITargetObjectFunction · 0.85
TestTriggersFunction · 0.85

Tested by

no test coverage detected