diff --git a/advtools.lua b/advtools.lua index 9f4d2ec3b3..6b2b0d09af 100644 --- a/advtools.lua +++ b/advtools.lua @@ -1,12 +1,10 @@ --@ module=true local convo = reqscript('internal/advtools/convo') -local fastcombat = reqscript('internal/advtools/fastcombat') local party = reqscript('internal/advtools/party') OVERLAY_WIDGETS = { conversation=convo.AdvRumorsOverlay, - fastcombat=fastcombat.AdvCombatOverlay, } if dfhack_flags.module then diff --git a/autocheese.lua b/autocheese.lua deleted file mode 100644 index b365f3f7b1..0000000000 --- a/autocheese.lua +++ /dev/null @@ -1,187 +0,0 @@ ---@module = true - -local ic = reqscript('idle-crafting') - ----make cheese using a specific barrel and workshop ----@param barrel df.item ----@param workshop df.building_workshopst ----@return df.job -function makeCheese(barrel, workshop) - ---@type df.job - local job = ic.make_job() - job.job_type = df.job_type.MakeCheese - - local jitem = df.job_item:new() - jitem.quantity = 0 - jitem.vector_id = df.job_item_vector_id.ANY_COOKABLE - jitem.flags1.unrotten = true - jitem.flags1.milk = true - job.job_items.elements:insert('#', jitem) - - if not dfhack.job.attachJobItem(job, barrel, df.job_item_ref.T_role.Reagent, 0, -1) then - dfhack.error('could not attach item') - end - - ic.assignToWorkshop(job, workshop) - return job -end - - - ----unit is ready to take jobs ----@param unit df.unit ----@return boolean -function unitIsAvailable(unit) - if unit.job.current_job then - return false - elseif #unit.individual_drills > 0 then - return false - elseif unit.flags1.caged or unit.flags1.chained then - return false - elseif unit.military.squad_id ~= -1 then - local squad = df.squad.find(unit.military.squad_id) - -- this lookup should never fail - ---@diagnostic disable-next-line: need-check-nil - return #squad.orders == 0 and squad.activity == -1 - end - return true -end - ----check if unit can perform labor at workshop ----@param unit df.unit ----@param unit_labor df.unit_labor ----@param workshop df.building ----@return boolean -function availableLaborer(unit, unit_labor, workshop) - return unit.status.labors[unit_labor] - and unitIsAvailable(unit) - and ic.canAccessWorkshop(unit, workshop) -end - ----find unit with a particular labor enabled ----@param unit_labor df.unit_labor ----@param job_skill df.job_skill ----@param workshop df.building ----@return df.unit|nil ----@return integer|nil - function findAvailableLaborer(unit_labor, job_skill, workshop) - local max_unit = nil - local max_skill = -1 - for _, unit in ipairs(dfhack.units.getCitizens(true, false)) do - if - availableLaborer(unit, unit_labor, workshop) - then - local unit_skill = dfhack.units.getNominalSkill(unit, job_skill, true) - if unit_skill > max_skill then - max_unit = unit - max_skill = unit_skill - end - end - end - return max_unit, max_skill -end - -local function findMilkBarrel(min_liquids) - for _, container in ipairs(df.global.world.items.other.FOOD_STORAGE) do - if - not (container.flags.in_job or container.flags.forbid) and - container.flags.container and #container.general_refs >= min_liquids - then - local content_reference = dfhack.items.getGeneralRef(container, df.general_ref_type.CONTAINS_ITEM) - local contained_item = df.item.find(content_reference and content_reference.item_id or -1) - if contained_item then - local mat_info = dfhack.matinfo.decode(contained_item) - if mat_info:matches { milk = true } then - return container - end - end - end - end -end - ----find a workshop to which the barrel can be brought ----if the workshop has a master, only return workshop and master if the master is available ----@param pos df.coord ----@return df.building_workshopst? ----@return df.unit? -function findWorkshop(pos) - for _,workshop in ipairs(df.global.world.buildings.other.WORKSHOP_FARMER) do - if - dfhack.maps.canWalkBetween(pos, xyz2pos(workshop.centerx, workshop.centery, workshop.z)) and - not workshop.profile.blocked_labors[df.unit_labor.MAKE_CHEESE] and - #workshop.jobs == 0 - then - if #workshop.profile.permitted_workers == 0 then - -- immediately return workshop without master - return workshop, nil - else - unit = df.unit.find(workshop.profile.permitted_workers[0]) - if - unit and availableLaborer(unit, df.unit_labor.MAKE_CHEESE, workshop) - then - -- return workshop and master, if master is available - return workshop, unit - else - print("autocheese: Skipping farmer's workshop with unavailable master") - end - end - end - end -end - -if dfhack_flags.module then - return -end - --- actual script action - -local argparse = require('argparse') - -local min_number = 50 - -local _ = argparse.processArgsGetopt({...}, -{ - { 'm', 'min-milk', hasArg = true, - handler = function(min) - min_number = argparse.nonnegativeInt(min, 'min-milk') - end } -}) - - -local reagent = findMilkBarrel(min_number) - -if not reagent then - -- print('autocheese: no sufficiently full barrel found') - return -end - -local workshop, worker = findWorkshop(xyz2pos(dfhack.items.getPosition(reagent))) - -if not workshop then - print("autocheese: no Farmer's Workshop available") - return -end - --- try to find laborer for workshop without master -if not worker then - worker, _ = findAvailableLaborer(df.unit_labor.MAKE_CHEESE, df.job_skill.CHEESEMAKING, workshop) -end - -if not worker then - print('autocheese: no cheesemaker available') - return -end -local job = makeCheese(reagent, workshop) - -print(('autocheese: dispatching cheesemaking job for %s (%d milk) to %s'):format( - dfhack.df2console(dfhack.items.getReadableDescription(reagent)), - #reagent.general_refs, - dfhack.df2console(dfhack.units.getReadableName(worker)) -)) - - --- assign a worker and send it to fetch the barrel -dfhack.job.addWorker(job, worker) -dfhack.units.setPathGoal(worker, reagent.pos, df.unit_path_goal.GrabJobResources) -job.items[0].flags.is_fetching = true -job.flags.fetching = true diff --git a/changelog.txt b/changelog.txt index 1de9ccde64..a3155dcd2c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -27,10 +27,8 @@ Template for new versions: # Future ## New Tools -- `autocheese`: automatically make cheese using barrels that have accumulated sufficient milk ## New Features -- `advtools`: new overlay ``advtools.fastcombat``; allows you to skip combat animations and the announcement "More" button ## Fixes - `advtools`: fix dfhack-added conversation options not appearing in the ask whereabouts conversation tree @@ -39,8 +37,6 @@ Template for new versions: ## Misc Improvements - `assign-preferences`: new ``--show`` option to display the preferences of the selected unit - `pref-adjust`: new ``show`` command to display the preferences of the selected unit -- `hide-tutorials`: if enabled, also hide tutorial popups for adventure mode -- `hide-tutorials`: new ``reset`` command that will re-enable popups in the current game ## Removed - `gui/control-panel`: removed ``craft-age-wear`` tweak for Windows users; the tweak doesn't currently load on Windows diff --git a/docs/advtools.rst b/docs/advtools.rst index 113d6c969a..c62cdb1f83 100644 --- a/docs/advtools.rst +++ b/docs/advtools.rst @@ -35,16 +35,3 @@ enemies will gain the ``slay`` and ``kill`` keywords. It will also add additional conversation options for asking whereabouts of your relationships -- in vanilla, you can only ask whereabouts of historical figures involved in rumors you personally witnessed or heard about. - -``advtools.fastcombat`` -~~~~~~~~~~~~~~~~~~~~~~~ - -When enabled, this overlay will allow you to skip most combat animations, -including the whooshes and projectiles travelling through the screen. It will -also let you skip the announcements window when the "More" button is active, -scrolling you to the very bottom with the first press, and skipping the window -entirely with the second press. This drastically speeds up combat while still -giving you the option not to skip the announcements. Skip keys are left mouse click, -the SELECT button, the movement keys and combat-related keys that don't bring up a -menu (such as bump attack). If clicking to skip past combat, it will only skip the -announcements if you're clicking outside the announcements panel. diff --git a/docs/autocheese.rst b/docs/autocheese.rst deleted file mode 100644 index fb92874df5..0000000000 --- a/docs/autocheese.rst +++ /dev/null @@ -1,39 +0,0 @@ -autocheese -========== - -.. dfhack-tool:: - :summary: Schedule cheese making jobs based on milk reserves. - :tags: fort auto - -Cheese making is difficult to automate using work orders. A single job -can consume anything from a bucket with a single unit of milk to a barrel -with 100 units of milk. This makes it hard to predict how much cheese will -actually be produced by an automated order. - -The script will scan your fort for barrels with a certain minimum amount of milk -(default: 50), create a cheese making job specifically for that barrel, and -assign this job to one of your idle dwarves (giving preference to skilled cheese -makers). - -When enabled using `gui/control-panel`, the script will run automatically, with -default options, twice a month. - -Usage ------ - -:: - - autocheese [] - -Examples --------- - -``autocheese -m 100`` - Only create a job if there is a barrel that is filled to the maximum. - -Options -------- - -``-m``, ``--min-milk`` - Set the minimum number of milk items in a barrel for the barrel to be - considered for cheese making. diff --git a/docs/hide-tutorials.rst b/docs/hide-tutorials.rst index 94b2a27a28..417d5e278c 100644 --- a/docs/hide-tutorials.rst +++ b/docs/hide-tutorials.rst @@ -3,12 +3,12 @@ hide-tutorials .. dfhack-tool:: :summary: Hide new fort tutorial popups. - :tags: adventure fort interface + :tags: fort interface If you've played the game before and don't need to see the tutorial popups that show up on every new fort, ``hide-tutorials`` can hide them for you. You can enable this tool as a system service in the "Services" tab of -`gui/control-panel` so it takes effect for all forts and adventures. +`gui/control-panel` so it takes effect for all new or loaded forts. Specifically, this tool hides: @@ -16,8 +16,6 @@ Specifically, this tool hides: - The "Do you want to start a tutorial embark" popup - Popups displayed the first time you open the labor, burrows, justice, and other similar screens in a new fort -- Popups displayed when you perform certain actions for the first time in an - adventure Note that only unsolicited tutorial popups are hidden. If you directly request a tutorial page from the help, then it will still function normally. @@ -29,10 +27,6 @@ Usage enable hide-tutorials hide-tutorials - hide-tutorials reset -If you haven't enabled the tool, but you run the command while a fort or -adventure is loaded, all future popups for the loaded game will be hidden. - -If you run the command with the ``reset`` option, all popups will be re-enabled -as if they had never been seen or dismissed. +If you haven't enabled the tool, but you run the command while a fort is +loaded, all future popups for the loaded fort will be hidden. diff --git a/hide-tutorials.lua b/hide-tutorials.lua index e6124de0de..2ca950e3bf 100644 --- a/hide-tutorials.lua +++ b/hide-tutorials.lua @@ -12,6 +12,10 @@ function isEnabled() return enabled end +local function is_fort_map_loaded() + return df.global.gamemode == df.game_mode.DWARF and dfhack.isMapLoaded() +end + local help = df.global.game.main_interface.help local function close_help() @@ -39,36 +43,15 @@ function skip_tutorial_prompt() end end -local function get_prefix() - if dfhack.world.isFortressMode() then - return 'POPUP_' - elseif dfhack.world.isAdventureMode() then - return 'ADVENTURE_POPUP_' - end -end - local function hide_all_popups() - local prefix = get_prefix() - if not prefix then return end for i,name in ipairs(df.help_context_type) do - if not name:startswith(prefix) then goto continue end + if not name:startswith('POPUP_') then goto continue end utils.insert_sorted(df.global.plotinfo.tutorial_seen, i) utils.insert_sorted(df.global.plotinfo.tutorial_hide, i) ::continue:: end end -local function show_all_popups() - local prefix = get_prefix() - if not prefix then return end - for i,name in ipairs(df.help_context_type) do - if not name:startswith(prefix) then goto continue end - utils.erase_sorted(df.global.plotinfo.tutorial_seen, i) - utils.erase_sorted(df.global.plotinfo.tutorial_hide, i) - ::continue:: - end -end - dfhack.onStateChange[GLOBAL_KEY] = function(sc) if not enabled then return end @@ -82,7 +65,7 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc) dfhack.timeout(100, 'frames', skip_tutorial_prompt) dfhack.timeout(1000, 'frames', skip_tutorial_prompt) end - elseif sc == SC_MAP_LOADED then + elseif sc == SC_MAP_LOADED and df.global.gamemode == df.game_mode.DWARF then hide_all_popups() end end @@ -98,15 +81,13 @@ end if args[1] == "enable" then enabled = true - if dfhack.isMapLoaded() then + if is_fort_map_loaded() then hide_all_popups() end elseif args[1] == "disable" then enabled = false -elseif args[1] == "reset" then - show_all_popups() -elseif dfhack.isMapLoaded() then +elseif is_fort_map_loaded() then hide_all_popups() else - qerror('hide-tutorials needs a loaded fortress or adventure map to work') + qerror('hide-tutorials needs a loaded fortress map to work') end diff --git a/internal/control-panel/registry.lua b/internal/control-panel/registry.lua index 37cd56c4e2..b0e6eee753 100644 --- a/internal/control-panel/registry.lua +++ b/internal/control-panel/registry.lua @@ -18,8 +18,6 @@ COMMANDS_BY_IDX = { {command='autobutcher target 10 10 14 2 BIRD_PEAFOWL_BLUE', group='automation', mode='run', desc='Enable if you usually want to raise peafowl.'}, {command='autochop', group='automation', mode='enable'}, - {command='autocheese', group='automation', mode='repeat', - params={'--time', '14', '--timeUnits', 'days', '--command', '[', 'autocheese', ']'}}, {command='autoclothing', group='automation', mode='enable'}, {command='autofarm', group='automation', mode='enable'}, {command='autofarm threshold 150 grass_tail_pig', group='automation', mode='run',