| 311 | } |
| 312 | |
| 313 | void BaddyControl(short itemNumber) |
| 314 | { |
| 315 | if (!CreatureActive(itemNumber)) |
| 316 | return; |
| 317 | |
| 318 | auto* item = &g_Level.Items[itemNumber]; |
| 319 | auto* creature = GetCreatureInfo(item); |
| 320 | |
| 321 | // Don't focus on disabled items |
| 322 | if (creature->Enemy && (creature->Enemy->Flags & IFLAG_KILLED)) |
| 323 | creature->Enemy = nullptr; |
| 324 | |
| 325 | auto* enemyItem = creature->Enemy; |
| 326 | |
| 327 | short angle = 0; |
| 328 | short tilt = 0; |
| 329 | short joint1 = 0; |
| 330 | short joint2 = 0; |
| 331 | short joint3 = 0; |
| 332 | |
| 333 | // TODO: better add a second control routine for baddy 2 instead of mixing them? |
| 334 | short objectNumber = (Objects[ID_BADDY2].loaded ? ID_BADDY2 : ID_BADDY1); |
| 335 | |
| 336 | if (creature->MuzzleFlash[0].Delay != 0) |
| 337 | creature->MuzzleFlash[0].Delay--; |
| 338 | |
| 339 | bool roll = false; |
| 340 | bool jump = false; |
| 341 | |
| 342 | short ocb = item->TriggerFlags % 1000; |
| 343 | |
| 344 | if (ocb) |
| 345 | { |
| 346 | creature->MaxTurn = 0; |
| 347 | creature->LOT.IsJumping = true; |
| 348 | |
| 349 | if (ocb > 100) |
| 350 | { |
| 351 | item->ItemFlags[0] = -80; |
| 352 | FindAITargetObject(creature, ID_AI_X1); |
| 353 | } |
| 354 | |
| 355 | item->TriggerFlags = 1000 * (item->TriggerFlags / 1000); |
| 356 | } |
| 357 | |
| 358 | // Can baddy jump? Check for a distance of 1 and 2 sectors |
| 359 | int x = item->Pose.Position.x; |
| 360 | int y = item->Pose.Position.y; |
| 361 | int z = item->Pose.Position.z; |
| 362 | |
| 363 | int dx = 942 * phd_sin(item->Pose.Orientation.y); |
| 364 | int dz = 942 * phd_cos(item->Pose.Orientation.y); |
| 365 | |
| 366 | x += dx; |
| 367 | z += dz; |
| 368 | int height1 = GetPointCollision(Vector3i(x, y, z), item->RoomNumber).GetFloorHeight(); |
| 369 | |
| 370 | x += dx; |
nothing calls this directly
no test coverage detected