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

Function SethControl

TombEngine/Objects/TR4/Entity/tr4_setha.cpp:120–491  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118 }
119
120 void SethControl(short itemNumber)
121 {
122 if (!CreatureActive(itemNumber))
123 return;
124
125 auto* item = &g_Level.Items[itemNumber];
126 auto& creature = *GetCreatureInfo(item);
127
128 int x = item->Pose.Position.x;
129 int y = item->Pose.Position.y;
130 int z = item->Pose.Position.z;
131
132 int dx = 870 * phd_sin(item->Pose.Orientation.y);
133 int dz = 870 * phd_cos(item->Pose.Orientation.y);
134
135 int ceiling = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetCeilingHeight();
136
137 x += dx;
138 z += dz;
139 int height1 = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetFloorHeight();
140
141 x += dx;
142 z += dz;
143 int height2 = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetFloorHeight();
144
145 x += dx;
146 z += dz;
147 int height3 = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetFloorHeight();
148
149 bool canJump = false;
150 if ((y < (height1 - CLICK(1.5f)) || y < (height2 - CLICK(1.5f))) &&
151 (y < (height3 + CLICK(1)) && y >(height3 - CLICK(1)) || height3 == NO_HEIGHT))
152 {
153 canJump = true;
154 }
155
156 x = item->Pose.Position.x - dx;
157 z = item->Pose.Position.z - dz;
158 int height4 = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetFloorHeight();
159
160 AI_INFO AI;
161 short angle = 0;
162
163 if (item->HitPoints <= 0)
164 {
165 item->HitPoints = 0;
166 }
167 else
168 {
169 if (item->AIBits & AMBUSH)
170 GetAITarget(&creature);
171 else
172 creature.Enemy = LaraItem;
173
174 CreatureAIInfo(item, &AI);
175
176 GetCreatureMood(item, &AI, true);
177 CreatureMood(item, &AI, true);

Callers

nothing calls this directly

Calls 15

CreatureActiveFunction · 0.85
GetCreatureInfoFunction · 0.85
phd_sinFunction · 0.85
phd_cosFunction · 0.85
GetPointCollisionFunction · 0.85
GetAITargetFunction · 0.85
CreatureAIInfoFunction · 0.85
GetCreatureMoodFunction · 0.85
CreatureMoodFunction · 0.85
CreatureTurnFunction · 0.85
TargetableFunction · 0.85
TestProbabilityFunction · 0.85

Tested by

no test coverage detected