| 122 | } |
| 123 | |
| 124 | void UpdateLocusts() |
| 125 | { |
| 126 | int closestDist = INT_MAX; |
| 127 | int closestNumber = NO_VALUE; |
| 128 | |
| 129 | for (int i = 0; i < MAX_LOCUSTS; i++) |
| 130 | { |
| 131 | auto* locust = &Locusts[i]; |
| 132 | |
| 133 | if (!locust->On) |
| 134 | continue; |
| 135 | |
| 136 | locust->StoreInterpolationData(); |
| 137 | |
| 138 | auto* targetItem = &g_Level.Items[locust->Target]; |
| 139 | |
| 140 | if ((targetItem->Effect.Type != EffectType::None || targetItem->HitPoints <= 0) && |
| 141 | locust->Counter > LOCUST_FLYOFF_TIMEOUT && !(GetRandomControl() & 7)) |
| 142 | { |
| 143 | locust->Counter = LOCUST_FLYOFF_TIMEOUT; |
| 144 | } |
| 145 | |
| 146 | locust->Counter--; |
| 147 | |
| 148 | if (locust->Counter == 0) |
| 149 | { |
| 150 | locust->On = false; |
| 151 | continue; |
| 152 | } |
| 153 | |
| 154 | if (!(GetRandomControl() & 7)) |
| 155 | { |
| 156 | locust->Offset.x = (GetRandomControl() & 0x7F) - 64; |
| 157 | locust->Offset.y = GetRandomControl() % 640 + 128; |
| 158 | locust->Offset.z = (GetRandomControl() & 0x7F) - 64; |
| 159 | } |
| 160 | |
| 161 | auto angles = Geometry::GetOrientToPoint( |
| 162 | locust->Pose.Position.ToVector3(), |
| 163 | Vector3( |
| 164 | targetItem->Pose.Position.x + locust->Offset.x * 8, |
| 165 | targetItem->Pose.Position.y - locust->Offset.y, |
| 166 | targetItem->Pose.Position.z + locust->Offset.z * 8 |
| 167 | )); |
| 168 | |
| 169 | int distance = Vector3i::Distance(targetItem->Pose.Position, locust->Pose.Position); |
| 170 | |
| 171 | if (distance < closestDist && targetItem->IsLara()) |
| 172 | { |
| 173 | closestDist = distance; |
| 174 | closestNumber = i; |
| 175 | } |
| 176 | |
| 177 | if (distance > BLOCK(1)) |
| 178 | distance = BLOCK(1); |
| 179 | else if (distance < BLOCK(2.5f)) |
| 180 | distance = BLOCK(2.5f); |
| 181 |
no test coverage detected