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

Function RotateHeadToTarget

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

Source from the content-addressed store, hash-verified

173 }
174
175 static void RotateHeadToTarget(ItemInfo* item, CreatureInfo* creature, int joint, short& headAngle)
176 {
177 if (creature->Enemy == nullptr)
178 {
179 headAngle = item->Pose.Orientation.y;
180 return;
181 }
182
183 auto* enemy = creature->Enemy;
184
185 auto pos = GetJointPosition(item,joint);
186 int x = enemy->Pose.Position.x - pos.x;
187 int z = enemy->Pose.Position.z - pos.z;
188 headAngle = (short)(phd_atan(z, x) - item->Pose.Orientation.y) / 2;
189 }
190
191 void GetTargetPosition(ItemInfo* originEntity, Pose* targetPose)
192 {

Callers 1

CrocgodControlFunction · 0.85

Calls 2

GetJointPositionFunction · 0.85
phd_atanFunction · 0.85

Tested by

no test coverage detected