Skip to content

Commit c325bd3

Browse files
remove units who don't need training
1 parent 2250848 commit c325bd3

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

autotraining.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,22 @@ function check()
225225
local intraining_count = 0
226226
local inque_count = 0
227227
if ( squads == nil) then return end
228+
for _,squad in ipairs(squads) do
229+
for i=1,9,1 do
230+
if ( squad.positions[i].occupant ~= -1 ) then
231+
local hf = df.historical_figure.find(squad.positions[i].occupant)
232+
if hf ~= nil then
233+
local unit df.unit.find(hf.unit_id)
234+
local training_need = getTrainingNeed(unit)
235+
if ( training_need ~= nil ) then
236+
if ( training_need.focus_level >= state.threshold ) then
237+
dfhack.military.removeFromSquad(unit)
238+
end
239+
end
240+
end
241+
end
242+
end
243+
end
228244
for _, unit in ipairs(getTrainingCandidates()) do
229245
local need = getTrainingNeed(unit)
230246
if ( need ~= nil ) then

0 commit comments

Comments
 (0)