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

Function TigerControl

TombEngine/Objects/TR3/Entity/tr3_tiger.cpp:71–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69 };
70
71 void TigerControl(short itemNumber)
72 {
73 if (!CreatureActive(itemNumber))
74 return;
75
76 auto* item = &g_Level.Items[itemNumber];
77 auto* object = &Objects[item->ObjectNumber];
78 auto* creature = GetCreatureInfo(item);
79
80 short headingAngle = 0;
81 short tiltAngle = 0;
82 auto extraHeadRot = EulerAngles::Identity;
83
84 if (item->HitPoints <= 0)
85 {
86 if (item->Animation.ActiveState != TIGER_STATE_DEATH)
87 SetAnimation(item, TIGER_ANIM_DEATH);
88 }
89 else
90 {
91 AI_INFO ai;
92 CreatureAIInfo(item, &ai);
93
94 if (ai.ahead)
95 extraHeadRot.y = ai.angle;
96
97 GetCreatureMood(item, &ai, true);
98
99 if (creature->Alerted && ai.zoneNumber != ai.enemyZone)
100 creature->Mood = MoodType::Escape;
101
102 CreatureMood(item, &ai, true);
103
104 headingAngle = CreatureTurn(item, creature->MaxTurn);
105
106 switch (item->Animation.ActiveState)
107 {
108 case TIGER_STATE_IDLE:
109 creature->MaxTurn = 0;
110 creature->Flags = 0;
111
112 if (item->Animation.RequiredState != NO_VALUE)
113 {
114 item->Animation.TargetState = item->Animation.RequiredState;
115 }
116 else if (creature->Mood == MoodType::Escape)
117 {
118 if (Lara.TargetEntity != item && ai.ahead)
119 item->Animation.TargetState = TIGER_STATE_IDLE;
120 else
121 item->Animation.TargetState = TIGER_STATE_RUN_FORWARD;
122 }
123 else if (creature->Mood == MoodType::Bored)
124 {
125 if (Random::TestProbability(TIGER_ROAR_CHANCE))
126 {
127 item->Animation.TargetState = TIGER_STATE_ROAR;
128 }

Callers

nothing calls this directly

Calls 15

CreatureActiveFunction · 0.85
GetCreatureInfoFunction · 0.85
SetAnimationFunction · 0.85
CreatureAIInfoFunction · 0.85
GetCreatureMoodFunction · 0.85
CreatureMoodFunction · 0.85
CreatureTurnFunction · 0.85
TestProbabilityFunction · 0.85
DoDamageFunction · 0.85
CreatureEffectFunction · 0.85
TestAnimFrameRangeFunction · 0.85
CreatureTiltFunction · 0.85

Tested by

no test coverage detected