dfhack icon indicating copy to clipboard operation
dfhack copied to clipboard

Script: pref-adjust and armoks-blessing: 'all' modes do not include non-dwarven residents

Open TheBloke opened this issue 3 years ago • 1 comments

Issue: The script pref-adjust supports three 'all' parameters: all, goth_all and clear_all

None of these modes target non-dwarven residents, such as Humans and Elves. This is in accordance with the help text, which refers to 'all dwarves', however it is likely not expected behaviour for the user who may have accepted non-dwarven residents via the Petition system.

Using pref-adjust to set the preferenes for a single non-dwarf works fine. So the problem is purely one of filtering.

Checking the code, this method is used to adjust all - it filters according to race. This might imply a second issue: if dwarven merchants or visitors were present for example, would they also be overwritten, despite not being residents or citizens?

function adjust_all_dwarves(profile)
    for _,unit in ipairs(df.global.world.units.active) do
        if unit.race == df.global.plotinfo.race_id then
            print("Adjusting "..unit_name_to_console(unit))
            brainwash_unit(unit,profile)
        end
    end
end

Suggestion: either the 'all' modes should select every resident, or a new option should be added to specify that non-dwarves should be included in the all filter.

TheBloke avatar Jan 14 '23 12:01 TheBloke

Identical problem exists in armoks-blessing - it uses the same code to find dwarves to change, thus missing non-dwarven residents

Code from Armok's Blessing:

function adjust_all_dwarves(skillname)
    for _,v in ipairs(df.global.world.units.all) do
        if v.race == df.global.plotinfo.race_id and v.status.current_soul then
            print("Adjusting "..dfhack.df2console(dfhack.TranslateName(dfhack.units.getVisibleName(v))))
            brainwash_unit(v)
            elevate_attributes(v)
            rejuvenate(v)
            if skillname then
                if df.job_skill_class[skillname] then
                    LegendaryByClass(skillname,v)
                elseif skillname=="all" then
                    BreathOfArmok(v)
                else
                    make_legendary(skillname,v)
                end
            end
        end
    end
end

TheBloke avatar Jan 15 '23 09:01 TheBloke