-
Notifications
You must be signed in to change notification settings - Fork 40
Description
Problem
The current implementation of the vehicle recovery system in obj_pnunit/Alarm_5.gml processes each unit column separately at the end of battle. This means that the priority queue for vehicle recovery is created and processed independently for each column, rather than for all player forces together.
Current implementation
// In obj_pnunit/Alarm_5.gml
// Techmarines saving vehicles
if (obj_ncombat.techmarines_alive > 0) {
var _dead_vehicles_pq = ds_priority_create();
var _vehicles_priority = {
"Land Raider": 10,
"Predator": 5,
"Whirlwind": 4,
"Rhino": 3,
"Land Speeder": 3,
"Bike": 1
}
for (var i = 0; i < array_length(veh_dead); i++) {
if (struct_exists(_vehicles_priority, veh_type[i])) && (veh_dead[i]) && (!veh_ally[i] ) {
ds_priority_add(_dead_vehicles_pq, i, _vehicles_priority[$ veh_type[i]]);
}
}
// Process priority queue for this column only
// ...
}Impact
This leads to suboptimal recovery decisions, as the system might recover a low-priority vehicle (e.g., a Bike with priority 1) in one column while failing to recover a high-priority vehicle (e.g., a Land Raider with priority 10) in another column.
Proposed Solution
The priority queue logic should be moved to the obj_ncombat combat end alarm, which would allow processing all vehicles from all columns together in a single priority queue.
Implementation Challenges
- Need to create a mechanism to reference vehicles from different columns in a unified priority queue
- Need to maintain references to the original array indices for each vehicle to update them after processing
- May require a data structure to store {column_id, vehicle_index, priority} for each vehicle
Suggested Approach
- At combat end, collect references to all dead vehicles from all unit columns
- Process them in a single priority queue based on their type/priority
- Update the original vehicle arrays in their respective columns
cc: @EttyKitty (found during review of PR #580)