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

Function InitializeGuard

TombEngine/Objects/TR5/Entity/tr5_guard.cpp:204–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202 };
203
204 void InitializeGuard(short itemNum)
205 {
206 auto* item = &g_Level.Items[itemNum];
207 short roomItemNumber;
208
209 InitializeCreature(itemNum);
210
211 switch ((GuardOcb)item->TriggerFlags)
212 {
213 default:
214 case GuardOcb::Idle:
215 SetAnimation(item, GUARD_ANIM_IDLE);
216 break;
217
218 case GuardOcb::Reload:
219 SetAnimation(item, GUARD_ANIM_RELOAD);
220 break;
221
222 case GuardOcb::DoorKick:
223 SetAnimation(item, GUARD_ANIM_OPEN_DOOR_KICK);
224 item->Animation.TargetState = GUARD_STATE_CROUCH;
225 // TODO: item->flags2 ^= (item->flags2 ^ ((item->flags2 & 0xFE) + 2)) & 6;
226 break;
227
228 case GuardOcb::RopeDown:
229 SetAnimation(item, GUARD_ANIM_ROPE_DOWN);
230 item->SetMeshSwapFlags(9216);
231
232 roomItemNumber = g_Level.Rooms[item->RoomNumber].itemNumber;
233 if (roomItemNumber != NO_VALUE)
234 {
235 ItemInfo* item2 = nullptr;
236 while (true)
237 {
238 item2 = &g_Level.Items[roomItemNumber];
239 if (item2->ObjectNumber >= ID_ANIMATING1 &&
240 item2->ObjectNumber <= ID_ANIMATING15 &&
241 item2->RoomNumber == item->RoomNumber &&
242 item2->TriggerFlags == (int)GuardOcb::RopeDown)
243 {
244 break;
245 }
246
247 roomItemNumber = item2->NextItem;
248 if (roomItemNumber == NO_VALUE)
249 {
250 item->Animation.FrameNumber = 0;
251 item->Animation.ActiveState = item->Animation.TargetState;
252 break;
253 }
254 }
255
256 item2->MeshBits = -5;
257 }
258
259 break;
260
261 case GuardOcb::Sleeping:

Callers

nothing calls this directly

Calls 7

InitializeCreatureFunction · 0.85
SetAnimationFunction · 0.85
GetPointCollisionFunction · 0.85
phd_sinFunction · 0.85
phd_cosFunction · 0.85
SetMeshSwapFlagsMethod · 0.80
GetCeilingHeightMethod · 0.45

Tested by

no test coverage detected