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

Function BaddyControl

TombEngine/Objects/TR4/Entity/tr4_baddy.cpp:313–1285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311 }
312
313 void BaddyControl(short itemNumber)
314 {
315 if (!CreatureActive(itemNumber))
316 return;
317
318 auto* item = &g_Level.Items[itemNumber];
319 auto* creature = GetCreatureInfo(item);
320
321 // Don't focus on disabled items
322 if (creature->Enemy && (creature->Enemy->Flags & IFLAG_KILLED))
323 creature->Enemy = nullptr;
324
325 auto* enemyItem = creature->Enemy;
326
327 short angle = 0;
328 short tilt = 0;
329 short joint1 = 0;
330 short joint2 = 0;
331 short joint3 = 0;
332
333 // TODO: better add a second control routine for baddy 2 instead of mixing them?
334 short objectNumber = (Objects[ID_BADDY2].loaded ? ID_BADDY2 : ID_BADDY1);
335
336 if (creature->MuzzleFlash[0].Delay != 0)
337 creature->MuzzleFlash[0].Delay--;
338
339 bool roll = false;
340 bool jump = false;
341
342 short ocb = item->TriggerFlags % 1000;
343
344 if (ocb)
345 {
346 creature->MaxTurn = 0;
347 creature->LOT.IsJumping = true;
348
349 if (ocb > 100)
350 {
351 item->ItemFlags[0] = -80;
352 FindAITargetObject(creature, ID_AI_X1);
353 }
354
355 item->TriggerFlags = 1000 * (item->TriggerFlags / 1000);
356 }
357
358 // Can baddy jump? Check for a distance of 1 and 2 sectors
359 int x = item->Pose.Position.x;
360 int y = item->Pose.Position.y;
361 int z = item->Pose.Position.z;
362
363 int dx = 942 * phd_sin(item->Pose.Orientation.y);
364 int dz = 942 * phd_cos(item->Pose.Orientation.y);
365
366 x += dx;
367 z += dz;
368 int height1 = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetFloorHeight();
369
370 x += dx;

Callers

nothing calls this directly

Calls 15

CreatureActiveFunction · 0.85
GetCreatureInfoFunction · 0.85
FindAITargetObjectFunction · 0.85
phd_sinFunction · 0.85
phd_cosFunction · 0.85
GetPointCollisionFunction · 0.85
SameZoneFunction · 0.85
EnableEntityAIFunction · 0.85
AddActiveItemFunction · 0.85
GetAITargetFunction · 0.85
CreatureAIInfoFunction · 0.85
phd_atanFunction · 0.85

Tested by

no test coverage detected