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

Function CrocgodControl

TombEngine/Objects/TR4/Entity/tr4_mutant.cpp:267–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265 }
266
267 void CrocgodControl(short itemNumber)
268 {
269 if (!CreatureActive(itemNumber))
270 return;
271
272 auto* item = &g_Level.Items[itemNumber];
273 auto* creature = GetCreatureInfo(item);
274
275 short headingAngle = 0;
276 auto extraHeadRot = EulerAngles::Identity;
277 auto extraTorsoRot = EulerAngles::Identity;
278
279 int frameNumber;
280
281 if (item->AIBits & ALL_AIOBJ)
282 {
283 GetAITarget(creature);
284 }
285 else if (creature->HurtByLara)
286 {
287 creature->Enemy = LaraItem;
288 }
289 else
290 {
291 TargetNearestEntity(*item);
292 }
293
294 AI_INFO ai;
295 MutantAIFix(item, &ai);
296
297 RotateHeadToTarget(item, creature, 9, extraHeadRot.y);
298 GetCreatureMood(item, &ai, true);
299 CreatureMood(item, &ai, true);
300
301 creature->MaxTurn = 0;
302 headingAngle = CreatureTurn(item, 0);
303
304 switch (item->Animation.ActiveState)
305 {
306 case MUTANT_STATE_IDLE:
307 if (ai.ahead)
308 {
309 if (Random::TestProbability(0.28f) && ai.distance <= MUTANT_PROJECTILE_ATTACK_RANGE)
310 item->Animation.TargetState = MUTANT_STATE_PROJECTILE_ATTACK;
311 else if (Random::TestProbability(0.28f) && ai.distance <= MUTANT_LOCUST_ATTACK_1_RANGE)
312 item->Animation.TargetState = MUTANT_STATE_LOCUST_ATTACK_1;
313 else if (Random::TestProbability(0.28f) && ai.distance <= MUTANT_LOCUST_ATTACK_2_RANGE)
314 item->Animation.TargetState = MUTANT_STATE_LOCUST_ATTACK_2;
315 }
316
317 break;
318
319 case MUTANT_STATE_PROJECTILE_ATTACK:
320 frameNumber = item->Animation.FrameNumber;
321 if (frameNumber >= 94 && frameNumber <= 96)
322 {
323 Pose src;
324 GetTargetPosition(item, &src);

Callers

nothing calls this directly

Calls 15

CreatureActiveFunction · 0.85
GetCreatureInfoFunction · 0.85
GetAITargetFunction · 0.85
TargetNearestEntityFunction · 0.85
MutantAIFixFunction · 0.85
RotateHeadToTargetFunction · 0.85
GetCreatureMoodFunction · 0.85
CreatureMoodFunction · 0.85
CreatureTurnFunction · 0.85
TestProbabilityFunction · 0.85
ShootFireballFunction · 0.85
SpawnLocustFunction · 0.85

Tested by

no test coverage detected