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

Function MPStickControl

TombEngine/Objects/TR3/Entity/tr3_mp_stick.cpp:67–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65 }
66
67 void MPStickControl(short itemNumber)
68 {
69 if (!CreatureActive(itemNumber))
70 return;
71
72 auto* item = &g_Level.Items[itemNumber];
73 auto* creature = GetCreatureInfo(item);
74
75 short angle = 0;
76 short tilt = 0;
77 short head = 0;
78 auto extraTorsoRot = EulerAngles::Identity;
79
80 if (item->BoxNumber != NO_VALUE && (g_Level.PathfindingBoxes[item->BoxNumber].flags & BLOCKED))
81 {
82 DoDamage(item, 20);
83 DoLotsOfBlood(item->Pose.Position.x, item->Pose.Position.y - (GetRandomControl() & 255) - 32, item->Pose.Position.z, (GetRandomControl() & 127) + 128, GetRandomControl() * 2, item->RoomNumber, 3);
84 }
85
86 AI_INFO laraAI;
87 if (item->HitPoints <= 0)
88 {
89 if (item->Animation.ActiveState != MPSTICK_STATE_DEATH)
90 {
91 SetAnimation(item, 26);
92 creature->LOT.Step = 256;
93 }
94 }
95 else
96 {
97 if (item->AIBits)
98 GetAITarget(creature);
99 else
100 {
101 creature->Enemy = LaraItem;
102
103 int dx = LaraItem->Pose.Position.x - item->Pose.Position.x;
104 int dz = LaraItem->Pose.Position.z - item->Pose.Position.z;
105 laraAI.distance = pow(dx, 2) + pow(dx, 2);
106
107 int bestDistance = INT_MAX;
108 for (auto creatureIndex : ActiveCreatures)
109 {
110 auto* currentCreature = GetCreatureInfo(&g_Level.Items[creatureIndex]);
111
112 if (currentCreature->ItemNumber == NO_VALUE || currentCreature->ItemNumber == itemNumber)
113 continue;
114
115 auto* target = &g_Level.Items[currentCreature->ItemNumber];
116 if (target->ObjectNumber != ID_LARA)
117 continue;
118
119 dx = target->Pose.Position.x - item->Pose.Position.x;
120 dz = target->Pose.Position.z - item->Pose.Position.z;
121
122 if (dz > BLOCK(31.25f) || dz < -BLOCK(31.25f) ||
123 dx > BLOCK(31.25f) || dx < -BLOCK(31.25f))
124 {

Callers

nothing calls this directly

Calls 15

CreatureActiveFunction · 0.85
GetCreatureInfoFunction · 0.85
DoDamageFunction · 0.85
DoLotsOfBloodFunction · 0.85
GetRandomControlFunction · 0.85
SetAnimationFunction · 0.85
GetAITargetFunction · 0.85
CreatureAIInfoFunction · 0.85
phd_atanFunction · 0.85
GetCreatureMoodFunction · 0.85
CreatureMoodFunction · 0.85
CreatureTurnFunction · 0.85

Tested by

no test coverage detected