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

Function GuideControl

TombEngine/Objects/TR4/Entity/tr4_guide.cpp:106–830  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104 }
105
106 void GuideControl(short itemNumber)
107 {
108 if (!CreatureActive(itemNumber))
109 return;
110
111 auto* item = &g_Level.Items[itemNumber];
112 auto* creature = GetCreatureInfo(item);
113 auto* object = &Objects[item->ObjectNumber];
114
115 short angle = 0;
116 short tilt = 0;
117 short joint0 = 0;
118 short joint1 = 0;
119 short joint2 = 0;
120
121 // Ignite torch.
122 if (item->ItemFlags[1] == 2)
123 {
124 auto pos = GetJointPosition(item, GuideBite1);
125 TriggerFireFlame(pos.x, pos.y - 20, pos.z, FlameType::Trail);
126 SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->Pose);
127
128 short random = GetRandomControl();
129 SpawnDynamicLight(
130 pos.x, pos.y, pos.z,
131 15,
132 255 - ((random >> 4) & 0x1F),
133 192 - ((random >> 6) & 0x1F),
134 random & 0x3F);
135
136 if (item->Animation.AnimNumber == GUIDE_ANIM_LIGHTING_TORCH)
137 {
138 if (item->Animation.FrameNumber > 32 &&
139 item->Animation.FrameNumber < 42)
140 {
141 TriggerFireFlame(
142 (random & 0x3F) + pos.x - 32,
143 ((random / 8) & 0x3F) + pos.y - 128,
144 pos.z + ((random / 64) & 0x3F) - 32,
145 FlameType::Trail);
146 }
147 }
148 }
149
150 item->AIBits = FOLLOW;
151 item->HitPoints = NOT_TARGETABLE;
152
153 GetAITarget(creature);
154
155 AI_INFO AI;
156 AI_INFO laraAI;
157
158 int dx = LaraItem->Pose.Position.x - item->Pose.Position.x;
159 int dz = LaraItem->Pose.Position.z - item->Pose.Position.z;
160
161 laraAI.angle = phd_atan(dz, dx) - item->Pose.Orientation.y;
162
163 laraAI.ahead = true;

Callers

nothing calls this directly

Calls 15

CreatureActiveFunction · 0.85
GetCreatureInfoFunction · 0.85
GetJointPositionFunction · 0.85
TriggerFireFlameFunction · 0.85
SoundEffectFunction · 0.85
GetRandomControlFunction · 0.85
SpawnDynamicLightFunction · 0.85
GetAITargetFunction · 0.85
phd_atanFunction · 0.85
ANGLEFunction · 0.85
CreatureAIInfoFunction · 0.85
GetCreatureMoodFunction · 0.85

Tested by

no test coverage detected