Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Can you get rid of holdings, or prevent sites from linking economically?  (Read 1183 times)

xzaxza

  • Bay Watcher
    • View Profile

It's bit funny that a site might link to your fortress even if it's closer to the mountainhome than you. And that's an entirely one-sided process that you can't influence?

Doesn't seem that beneficial either. The burden of having to deal with a baron outweighs the theoretically positive thing that you can request specific workers from a holding, which I don't expect to ever use with this fort.
Logged
Known issues
You may get a dwarf that likes bugged stockpiles.

knutor

  • Bay Watcher
  • ..to hear the lamentation of the elves!
    • View Profile

Without cheating, or leaving fortress mode, I wanna say, no.

However, I've flipped one back, tho, by requesting all, especially new Mayor, of my troops with a messenger. But I regretted it, because they got lost travelling back.

What gets my goat, is that donut, showing if its ours, theirs, or neutral, which is around the places on Civ map, hides important stuff. Maybe it'll get repaired in intrigue patch.
Logged
"I don't often drink Mead, but when I do... I prefer Dee Eef's.  -The most interesting Dwarf in the World.  Stay thirsty, my friend.
Shark Dentistry, looking in the Raws.

xzaxza

  • Bay Watcher
    • View Profile

Yep. It bugged me enough that I went and made a script that is capable of removing these links. I'll post it here in case someone else dislikes this.

Instructions:
 - save in hack/scripts/ and use file name economiclinks.lua
 - type `economiclinks help` in dfhack window
 - back up your save in case something goes wrong

Code: [Select]
-- show and sever economic links, by xzaxza
local help = [====[
economiclinks
======================
Displays the economic links of a site, or optionally severs them.

Usage:
economiclinks [sever] [site_id]

Both options are optional. If absent, site_id defaults to the current site.

Examples:
Running `economiclinks` without arguments displays the economic links of the current site.
Running `economiclinks 7` displays the economic links of the site with id 7.
Running `economiclinks sever` severs the economic links of the current site.
Running `economiclinks sever 7` severs the economic links of the site with id 7.
]====]
function fullname(item) --lifted from modtools/extra-gamelog
    return dfhack.TranslateName(item.name)..' ('..dfhack.TranslateName(item.name ,true)..')'
end
function CountLinks(site_id)
    if df.world_site.find(site_id) == nil then
        print "Error: site not found."
        return nil
    end
    local site = df.world_site.find(site_id)
    local local_markets = {}

    for k,v in pairs(site.entity_links) do
        if v.flags.local_market then
            local_markets[#local_markets+1] = v.entity_id
        end
    end
    return #local_markets
end
function ShowLinks(site_id)
    if df.world_site.find(site_id) == nil then
        print "Error: site not found."
        return
    end
    local site = df.world_site.find(site_id)
    local local_markets = {}
    print(dfhack.df2console('Site '..site_id..': '..fullname(site)..' at coordinates ('..site.pos.x..','..site.pos.y..')'))

    for k,v in pairs(site.entity_links) do
        if v.flags.local_market then
            local_markets[#local_markets+1] = v.entity_id
        end
    end
    if #local_markets > 0 then
        print(dfhack.df2console('The site has the following economic links:'))
        for k,v in pairs(local_markets) do
            tmp_ent = df.historical_entity.find(v)
            if tmp_ent ~= nil then
                print(dfhack.df2console('  Entity '..v..', '..fullname(tmp_ent)))
            else
                print('  Entity '..v..', <unknown entity>')
            end
        end
    else
        print(dfhack.df2console('The site has no economic links.'))
    end
end
function SeverLinks(site_id)
    if df.world_site.find(site_id) == nil then
        print "Error: site not found."
        return
    end

    local site = df.world_site.find(site_id)
    local tmp_ent
    local tmp_ent_id

    for k,v in pairs(site.entity_links) do
        tmp_size1 = #site.entity_links
        if v.flags.local_market then
            tmp_ent_id = v.entity_id
            tmp_ent = df.historical_entity.find(tmp_ent_id)

            for k2,v2 in pairs(tmp_ent.site_links) do
                if v2.target == site_id and v2.flags.local_market then
                    tmp_ent.site_links:erase(k2)
                    break
                end
            end
            site.entity_links:erase(k)
            return
        end
    end
end
-- main script
local opt = ...
local args = {...}
local site_id = df.global.ui.site_id
local link_count

if opt and opt ~= "" then
    if opt=="sever" then
        if tonumber(args[2]) then
            site_id = math.floor(tonumber(args[2]))
        end
        link_count = CountLinks(site_id)
        for i = 1,link_count,1 do
            SeverLinks(site_id)
        end
        return
    elseif tonumber(opt) then
        site_id = math.floor(tonumber(opt))
        ShowLinks(site_id)
        return
    else
        print(help)
    end
else
    ShowLinks(site_id)
end
Logged
Known issues
You may get a dwarf that likes bugged stockpiles.

knutor

  • Bay Watcher
  • ..to hear the lamentation of the elves!
    • View Profile

Would be nice if DF allowed us to send out only the messenger, to establish foreigner contact. Instead of a raid party. I guess I could toss messenger in a no uniform 1 man squad and do it.
Logged
"I don't often drink Mead, but when I do... I prefer Dee Eef's.  -The most interesting Dwarf in the World.  Stay thirsty, my friend.
Shark Dentistry, looking in the Raws.