Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion docs/holy-war.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ Usage
When run without options, wars are declared immediately on all
qualifying civilizations and an announcement is displayed. With
``--dry-run``, the tool only reports which civilizations would be
affected without actually changing diplomacy.
affected without actually changing diplomacy. Each message also notes
whether the conflict arises from disjoint spheres of influence or a
religious persecution grudge and lists the conflicting spheres when
appropriate.
30 changes: 26 additions & 4 deletions holy-war.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ local function merge(dst, src)
for k in pairs(src) do dst[k] = true end
end

local function spheres_to_str(spheres)
local names = {}
for sph in pairs(spheres) do
table.insert(names, df.sphere_type[sph])
end
table.sort(names)
return table.concat(names, ', ')
end

local function get_deity_spheres(hfid)
local spheres = {}
local hf = df.historical_figure.find(hfid)
Expand Down Expand Up @@ -145,15 +154,28 @@ local function main(...)
if p_status ~= 1 or c_status ~= 1 then -- not already mutually at war
local civ_spheres = get_civ_spheres(civ)
local civ_hfs = get_civ_hists(civ)
if not share(player_spheres, civ_spheres) or
has_religious_grudge(player_hfs, civ_hfs) then
local divine_conflict = not share(player_spheres, civ_spheres)
local persecution = has_religious_grudge(player_hfs, civ_hfs)
if divine_conflict or persecution then
local name = dfhack.translation.translateName(civ.name, true)
local reason_parts = {}
if divine_conflict then
table.insert(reason_parts,
('conflicting spheres (%s vs %s)'):format(
spheres_to_str(player_spheres),
spheres_to_str(civ_spheres)))
end
if persecution then
table.insert(reason_parts, 'religious persecution')
end
local reason = table.concat(reason_parts, ' and ')
if dry_run then
print(('Would declare war on %s over divine conflict.'):format(name))
print(('Would declare war on %s due to %s.'):format(name, reason))
else
change_relation(civ, 1) -- war
dfhack.gui.showAnnouncement(
('Religious persecution sparks war with %s!'):format(name),
('%s sparks war with %s!'):format(
reason:gsub('^.', string.upper), name),
COLOR_RED, true)
end
end
Expand Down