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

Function ShootAtEnemy

TombEngine/Game/missile.cpp:35–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33constexpr auto KNIFE_DAMAGE = 50;
34
35void ShootAtEnemy(Vector3i target, ItemInfo* item, int index)
36{
37 constexpr auto RANDOM_ORIENT = 1.4f;
38
39 if (item == nullptr || index <= NO_VALUE)
40 return;
41
42 // If target deviated too much from the item position, prefer item's own position.
43 if (Vector3i::Distance(item->Pose.Position, target) > TARGET_DEVIATION_THRESHOLD)
44 target = item->Pose.Position;
45
46 auto bounds = GameBoundingBox(item);
47 auto yOffset = bounds.Y2 - (bounds.GetHeight() * 0.75f);
48 auto targetWithOffset = Vector3(target.x, item->Pose.Position.y + yOffset, target.z);
49
50 // Apply slight random scatter.
51 auto randomOrient = EulerAngles(
52 Random::GenerateAngle(ANGLE(-RANDOM_ORIENT), ANGLE(RANDOM_ORIENT)),
53 Random::GenerateAngle(ANGLE(-RANDOM_ORIENT), ANGLE(RANDOM_ORIENT)),
54 0);
55
56 auto& fx = EffectList[index];
57 fx.pos.Orientation = Geometry::GetOrientToPoint(fx.pos.Position.ToVector3(), targetWithOffset);
58 fx.pos.Orientation += randomOrient;
59}
60
61// TODO: Make ControlMissile() not use LaraItem global. -- TokyoSU 5/8/2022
62void ControlMissile(short fxNumber)

Callers 5

KnifeThrowerControlFunction · 0.85
ScubaControlFunction · 0.85
NatlaControlFunction · 0.85
ControlCentaurFunction · 0.85
ControlWingedMutantFunction · 0.85

Calls 8

GenerateAngleFunction · 0.85
ANGLEFunction · 0.85
GetOrientToPointFunction · 0.85
GetHeightMethod · 0.80
GameBoundingBoxClass · 0.70
Vector3Function · 0.50
EulerAnglesClass · 0.50
ToVector3Method · 0.45

Tested by

no test coverage detected