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

Function ObeliskControl

TombEngine/Objects/TR4/Object/tr4_obelisk.cpp:46–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void ObeliskControl(short itemNumber)
47{
48 auto* item = &g_Level.Items[itemNumber];
49
50 short someNumber = 0;
51 auto pos = Vector3::Zero;
52 auto pos2 = Vector3::Zero;
53
54 if (TriggerActive(item))
55 {
56 if (item->ItemFlags[3] > 346)
57 return;
58
59 item->ItemFlags[3]++;
60
61 byte r = (GetRandomControl() & 0x1F) + 224;
62 byte g = r - (GetRandomControl() & 0x1F) - 32;
63 byte b = g - (GetRandomControl() & 0x1F) - 128;
64
65 if (!(GlobalCounter & 1))
66 {
67 someNumber = 8192;
68 if (GetRandomControl() & 1)
69 {
70 if (item->ItemFlags[3] < 256
71 && (GetRandomControl() & 1)
72 && !(GlobalCounter & 3))
73 {
74 SoundEffect(SFX_TR4_ELECTRIC_ARCING_LOOP, &item->Pose);
75 someNumber = (GetRandomControl() & 0xFFF) + 3456;
76 }
77
78 pos.x = item->Pose.Position.x + (3456 * phd_sin(item->Pose.Orientation.y + ANGLE(90.0f)));
79 pos.y = item->Pose.Position.y - CLICK(1);
80 pos.z = item->Pose.Position.z + (3456 * phd_cos(item->Pose.Orientation.y + ANGLE(90.0f)));
81
82 pos2.x = item->Pose.Position.x + (someNumber * phd_sin(item->Pose.Orientation.y + ANGLE(90.0f)));
83 pos2.y = item->Pose.Position.y;
84 pos2.x = item->Pose.Position.z + (someNumber * phd_cos(item->Pose.Orientation.z + ANGLE(90.0f)));
85
86 if (abs(pos.x - LaraItem->Pose.Position.x) < BLOCK(20) &&
87 abs(pos.y - LaraItem->Pose.Position.y) < BLOCK(20) &&
88 abs(pos.z - LaraItem->Pose.Position.z) < BLOCK(20) &&
89 abs(pos2.x - LaraItem->Pose.Position.x) < BLOCK(20) &&
90 abs(pos2.y - LaraItem->Pose.Position.y) < BLOCK(20) &&
91 abs(pos2.z - LaraItem->Pose.Position.z) < BLOCK(20))
92 {
93 if (!(GlobalCounter & 3))
94 {
95 SpawnElectricity(
96 pos, pos2,
97 (GetRandomControl() & 0x1F) + 32,
98 r, g, b, 24, 1, 32, 5);
99 }
100
101 SpawnElectricityGlow(pos, 48, r, g, b);
102 }
103 }

Callers

nothing calls this directly

Calls 15

TriggerActiveFunction · 0.85
GetRandomControlFunction · 0.85
SoundEffectFunction · 0.85
phd_sinFunction · 0.85
ANGLEFunction · 0.85
phd_cosFunction · 0.85
SpawnElectricityFunction · 0.85
SpawnElectricityGlowFunction · 0.85
ExplodeItemNodeFunction · 0.85
KillItemFunction · 0.85
TriggerExplosionSparksFunction · 0.85
FindItemFunction · 0.85

Tested by

no test coverage detected