Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New script - add to core party #1146

Merged
merged 14 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions add-to-core-party.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
local dialogs = require 'gui.dialogs'
local utils = require 'utils'
local viewscreen = dfhack.gui.getDFViewscreen(true)
if viewscreen._type ~= df.viewscreen_dungeonmodest then
qerror("This script can only be used during adventure mode!")
end

local function addToCoreParty(nemesis)
-- Adds them to the party core members list
local party = df.global.adventure.interactions
-- problem: the "brain" icon deciding on manual/automatic control is somewhat broken.
-- research leads me to believe the data is stored per-unit or unit ID, need to figure out
-- where that data is stored exactly. Might be one of the unknown variables?
party.party_core_members:insert('#', nemesis.figure.id)
local extra_member_idx, _ = utils.linear_index(party.party_extra_members, nemesis.figure.id)
if extra_member_idx then
party.party_extra_members:erase(extra_member_idx)
end
-- Adds them to unretire list
nemesis.flags.ADVENTURER = true
nemesis.flags.ACTIVE_ADVENTURER = true
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
end

local function showExtraPartyPrompt(advSetUpScreen)
local choices = {}
for _, figure_id in ipairs(df.global.adventure.interactions.party_extra_members) do
-- shamelessly copy-pasted from unretire-anyone.lua
local histFig = df.historical_figure.find(figure_id)
local nemesis = df.nemesis_record.find(histFig.nemesis_id)
local histFlags = histFig.flags
local creature = df.creature_raw.find(histFig.race).caste[histFig.caste]
local name = creature.caste_name[0]
if histFig.died_year >= -1 then
histFig.died_year = -1
histFig.died_seconds = -1
end
if histFig.info and histFig.info.curse then
local curse = histFig.info.curse
if curse.name ~= '' then
name = name .. ' ' .. curse.name
end
if curse.undead_name ~= '' then
name = curse.undead_name .. " - reanimated " .. name
end
end
if histFlags.ghost then
name = name .. " ghost"
end
local sym = df.pronoun_type.attrs[creature.sex].symbol
if sym then
name = name .. ' (' .. sym .. ')'
end
if histFig.name.has_name then
name = dfhack.TranslateName(histFig.name) ..
" - (" .. dfhack.TranslateName(histFig.name, true) .. ") - " .. name
end
table.insert(choices, { text = name, nemesis = nemesis, search_key = name:lower() })
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
end
dialogs.showListPrompt('add-to-core-party', "Select someone to add to your \"Core Party\" (able to assume control, able to unretire):", COLOR_WHITE,
choices, function(id, choice)
addToCoreParty(choice.nemesis)
end, nil, nil, true)
end

showExtraPartyPrompt(viewscreen)
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Template for new versions:
- `gui/tiletypes`: interface for modifying map tiles and tile properties
- `fix/population-cap`: fixes the situation where you continue to get migrant waves even when you are above your configured population cap
- `fix/occupancy`: fixes issues where you can't build somewhere because the game tells you an item/unit/building is in the way but there's nothing there
- `add-to-core-party`: promotes one of your companions to become a controllable adventurer

## New Features
- `buildingplan`: dimension tooltip is now displayed for constructions and buildings that are designated over an area
Expand Down
17 changes: 17 additions & 0 deletions docs/add-to-core-party.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
add-to-core-party
==========

.. dfhack-tool::
:summary: Promotes one of your companions to become a controllable adventurer.
:tags: adventure gameplay units

When you run this script, it will show you a list of your extra party and let you choose
who to promote into your "core party", aka let you control them in the tactics mode, not
dissimilar to what you get if you create a group of adventurers during character creation.

Usage
-----

::

add-to-core-party
Loading