* @brief Disables AI processing for a creature. * * Cleans up the creature's AI state, destroys its AI target item if any, * removes it from the ActiveCreatures list, and clears its CreatureInfo data. * Called when a creature dies, is deactivated, or leaves the active area. * * @param itemNumber Index of the creature item. */
| 101 | * @param itemNumber Index of the creature item. |
| 102 | */ |
| 103 | void DisableEntityAI(short itemNumber) |
| 104 | { |
| 105 | auto* item = &g_Level.Items[itemNumber]; |
| 106 | |
| 107 | if (!item->IsCreature()) |
| 108 | return; |
| 109 | |
| 110 | auto* creature = GetCreatureInfo(item); |
| 111 | creature->ItemNumber = NO_VALUE; |
| 112 | KillItem(creature->AITargetNumber); |
| 113 | ActiveCreatures.erase(std::find(ActiveCreatures.begin(), ActiveCreatures.end(), item->Index)); |
| 114 | item->Data = nullptr; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * @brief Initializes a creature's AI slot with movement capabilities based on its LotType. |
no test coverage detected