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

Function ImpControl

TombEngine/Objects/TR5/Entity/tr5_imp.cpp:189–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187 }
188
189 void ImpControl(short itemNumber)
190 {
191 if (!CreatureActive(itemNumber))
192 return;
193
194 auto* item = &g_Level.Items[itemNumber];
195 auto* creature = GetCreatureInfo(item);
196
197 short headingAngle = 0;
198
199 auto extraHeadRot = EulerAngles::Identity;
200 auto extraTorsoRot = EulerAngles::Identity;
201
202 AI_INFO ai;
203 if (item->HitPoints <= 0)
204 {
205 if (item->Animation.ActiveState != IMP_STATE_DEATH)
206 {
207 CreatureAIInfo(item, &ai);
208
209 if (ai.angle > -ANGLE(67.5f) && ai.angle < ANGLE(67.5f))
210 SetAnimation(item, IMP_ANIM_BACKWARD_DEATH);
211 else
212 SetAnimation(item, IMP_ANIM_FORWARD_DEATH);
213 }
214 }
215 else
216 {
217 if (item->AIBits)
218 {
219 GetAITarget(creature);
220 }
221 else if (creature->HurtByLara)
222 {
223 creature->Enemy = LaraItem;
224 }
225
226 CreatureAIInfo(item, &ai);
227
228 int elevation = (item->Pose.Position.y - creature->Enemy->Pose.Position.y) + CLICK(1.5f);
229 if (creature->Enemy->IsLara())
230 {
231 if (creature->Enemy->Animation.ActiveState == LS_CROUCH_IDLE ||
232 creature->Enemy->Animation.ActiveState == LS_CROUCH_ROLL ||
233 creature->Enemy->Animation.ActiveState > LS_MONKEY_TURN_180 &&
234 creature->Enemy->Animation.ActiveState < LS_HANG_TO_CRAWL ||
235 creature->Enemy->Animation.ActiveState == LS_CROUCH_TURN_LEFT ||
236 creature->Enemy->Animation.ActiveState == LS_CROUCH_TURN_RIGHT)
237 {
238 elevation = item->Pose.Position.y - creature->Enemy->Pose.Position.y;
239 }
240 }
241
242 ai.xAngle = phd_atan(sqrt(ai.distance), elevation);
243
244 GetCreatureMood(item, &ai, true);
245 if (item->Animation.ActiveState == IMP_STATE_SCARED)
246 creature->Mood = MoodType::Escape;

Callers

nothing calls this directly

Calls 15

CreatureActiveFunction · 0.85
GetCreatureInfoFunction · 0.85
CreatureAIInfoFunction · 0.85
ANGLEFunction · 0.85
SetAnimationFunction · 0.85
GetAITargetFunction · 0.85
phd_atanFunction · 0.85
GetCreatureMoodFunction · 0.85
CreatureMoodFunction · 0.85
CreatureTurnFunction · 0.85
IsTorchLitNearbyFunction · 0.85
TestProbabilityFunction · 0.85

Tested by

no test coverage detected