Skip to content

Conversation

@chdoc
Copy link
Member

@chdoc chdoc commented Jul 27, 2025

I have run the in-development autotraining for the better part of a season using this implementation, and I have not seen a single unit get stuck in a generic training session.

@ab9rf ab9rf merged commit be4d0a1 into DFHack:develop Jul 27, 2025
14 checks passed
@quietust
Copy link
Member

The original code is actually slightly different - rather than fetching the squad's global activity and removing the unit from ALL of its events, it should be fetching the unit's position within the squad and then removing the unit from each of the 3 activity/event IDs specified inside:

    auto squad = binsearch_in_vector(df::global::world->squads.all,&df::squad::id,unit->military.squad_id);
    auto position = squad->positions[unit->military.squad_position];
    for (int i = 0; i < 3; i++) { // iterate across possible values of enum "squad_event_type"
        auto activity = binsearch_in_vector(df::global::world->activities.all,&df::activity_entry::id,position->activities[i]);
        if (activity) {
            auto event = binsearch_in_vector(activity->events,&df::activity_event::id,position->events[i]);
            event->removeParticipant(unit->hist_figure_id, unit->id, false);
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants