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

Function Mafia2Control

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

Source from the content-addressed store, hash-verified

1140 }
1141
1142 void Mafia2Control(short itemNumber)
1143 {
1144 if (!CreatureActive(itemNumber))
1145 return;
1146
1147 auto* item = &g_Level.Items[itemNumber];
1148 auto* creature = GetCreatureInfo(item);
1149
1150 short angle = 0;
1151 short joint0 = 0;
1152 short joint1 = 0;
1153 short joint2 = 0;
1154
1155 // Can mafia jump? Check for a distances of 1 and 2 sectors.
1156 int x = item->Pose.Position.x;
1157 int y = item->Pose.Position.y;
1158 int z = item->Pose.Position.z;
1159
1160 int dx = 870 * phd_sin(item->Pose.Orientation.y);
1161 int dz = 870 * phd_cos(item->Pose.Orientation.y);
1162
1163 x += dx;
1164 z += dz;
1165 int height1 = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetFloorHeight();
1166
1167 x += dx;
1168 z += dz;
1169 int height2 = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetFloorHeight();
1170
1171 x += dx;
1172 z += dz;
1173 int height3 = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetFloorHeight();
1174
1175 int height = 0;
1176 bool canJump1Sector = true;
1177 if (item->BoxNumber == LaraItem->BoxNumber ||
1178 y >= (height1 - CLICK(1.5f)) ||
1179 y >= (height2 + CLICK(1)) ||
1180 y <= (height2 - CLICK(1)))
1181 {
1182 height = height2;
1183 canJump1Sector = false;
1184 }
1185
1186 bool canJump2Sectors = true;
1187 if (item->BoxNumber == LaraItem->BoxNumber ||
1188 y >= (height1 - CLICK(1.5f)) ||
1189 y >= (height - CLICK(1.5f)) ||
1190 y >= (height3 + CLICK(1)) ||
1191 y <= (height3 - CLICK(1)))
1192 {
1193 canJump2Sectors = false;
1194 }
1195
1196 if (creature->MuzzleFlash[0].Delay != 0)
1197 creature->MuzzleFlash[0].Delay--;
1198
1199 if (creature->MuzzleFlash[1].Delay != 0)

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
phd_atanFunction · 0.85
GetCreatureMoodFunction · 0.85
CreatureMoodFunction · 0.85
CreatureTurnFunction · 0.85
TargetVisibleFunction · 0.85

Tested by

no test coverage detected