Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 229 230 [231] 232 233 ... 243

Author Topic: DFHack 50.13-r1  (Read 812641 times)

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 50.08-r2
« Reply #3450 on: June 05, 2023, 01:59:05 pm »

ok so finished a big test on nomad and cut down on most of the crashes.


mostly found what usually make the game crash and plan to avoid it.
like I mostly think new civ zones might need to be cleared before leaving and also stockpiles but shrugs if that was tied to a different thing that align with me doing those two things.
edit: oh yeah you do need to rename the wagon to "Nomad" for these scripts to work to stop potential accidents from nomading onto other player forts that kept their wagon
Code: ("wagonmove3.lua") [Select]
function getxyz() -- this will return pointers x,y and z coordinates.
local x=df.global.cursor.x
local y=df.global.cursor.y
local z=df.global.cursor.z
return x,y,z -- return the coords
end
function movewagon(curx,cury,curz)
for de,oe in pairs(df.global.world.buildings.other.WAGON) do
if oe.name == 'Nomad' then
oe.centerx=curx
oe.x1=curx-1
oe.x2=curx+1
oe.centery=cury
oe.y1=cury-1
oe.y2=cury+1
oe.z=curz

for Del,ete in pairs(oe.contained_items) do
ete.item.pos.x=oe.centerx
ete.item.pos.y=oe.centery
ete.item.pos.z=oe.z
end
end
end
end

movewagon(getxyz())
this script requires the mining cursor to function and this new version of the wagon move will now update the positions of the items store on the wagon.
which I guess opens the research path on figuring out what causes the contents of items to spill out on unretire.

another script that's still currently in the works is this one Wagon store which copies and stores the contents of workshops(and now furnaces ) on to the wagon then attempts to remove said contents from the workshop and furnace.
this would take a few multiple attempts at emptying out the workshops and furnaces and I'm not sure this is perfectly save as it's mostly stable, if you craft way too much stuff it will take awhile to load it all onto the wagon and might look like a soft lock.
Code: ("wagon-store2.lua") [Select]
local contain={}
function stuffwagon(curx,cury,curz)
for k,v in pairs(df.global.world.buildings.other.WORKSHOP_ANY) do
for con,tain in pairs(v.contained_items) do
for de,oe in pairs(df.global.world.buildings.other.WAGON) do
if oe.name == 'Nomad' then
if tain.use_mode==0 then
oe.contained_items:insert("#",{new=true,item=v.contained_items[con].item,use_mode=0})
clearitems(oe,tain,v.contained_items)
end
end
end
end
end
for k,v in pairs(df.global.world.buildings.other.FURNACE_ANY) do
for con,tain in pairs(v.contained_items) do
for de,oe in pairs(df.global.world.buildings.other.WAGON) do
if oe.name == 'Nomad' then
if tain.use_mode==0 then
oe.contained_items:insert("#",{new=true,item=v.contained_items[con].item,use_mode=0})
clearitems(oe,tain,v.contained_items)
end
end
end
end
end

end
function clearitems(oe,tain,Vcon)
for Del,ete in pairs(oe.contained_items) do
for De2,ee in pairs(Vcon) do
if ete.item.id== ee.item.id then
Vcon:erase(De2)
end
end
end
end


stuffwagon()

Code: ("wagon-store-C.lua") [Select]
--this script uses old dfhack code to store items on to the wagon via keyboard cursors.
--probably more stable than the other scripts that store items onto the wagon but requires it to be on the floor.
local contain={}
 function getxyz() -- this will return pointers x,y and z coordinates.
local x=df.global.cursor.x
local y=df.global.cursor.y
local z=df.global.cursor.z
return x,y,z -- return the coords
end

function stuffwagon(curx,cury,curz)

for de,oe in pairs(df.global.world.buildings.other.WAGON) do
if oe.name == 'Nomad' then


local vector=df.global.world.items.all -- load all items
for i = 0, #vector-1 do -- look into all items offsets
local curpos=vector[i].pos --get its coordinates
local cx=curpos.x
local cy=curpos.y
local cz=curpos.z
if cx==curx and cy==cury and cz==curz then --compare them
dfhack.items.moveToBuilding(vector[i],oe) --return index
end
end

end
end
end

stuffwagon(getxyz())

the test I done was seeing if I could cross the ocean to settle on an remote island and uhh going through the caverns in DF50 is adventurous one could say as you're at the mercy of the agitation system and if you say stay too long and or dig up too much stuff down in the cavern layer you might get swarmed by the other residents of the area and possibly make the trip harder.

edit: realize I already made a wagonmove2 so updated lua file name for consistency.

edit: ok so uhh made a cursor version of the wagon store script so now one could scoop up random items on the field to store back on the wagon. it probably more stable than the previous ones given it uses dfhack for the item placement but user be ware.
edit: it's also a modification of the wagon un-retire script after realizing moving the wagon over an item to scoop the item into itself was a bit silly to do.
« Last Edit: June 11, 2023, 03:07:02 am by Rumrusher »
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

myk

  • Bay Watcher
    • View Profile
Re: DFHack 50.08-r2
« Reply #3451 on: June 05, 2023, 03:21:45 pm »

In short, emigration.lua worked in past, but no longer works. I fixed it. Do you want it?

Please! Could you open a PR against the scripts repo? https://github.com/DFHack/scripts/pulls
We can discuss it over the code review.
Logged

myk

  • Bay Watcher
    • View Profile
Re: DFHack 50.08-r2
« Reply #3452 on: June 05, 2023, 09:04:17 pm »

Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 50.08-r3
« Reply #3453 on: June 07, 2023, 01:16:36 am »

Code: ("AnimalTokenCivPatch6.lua") [Select]
--old old script made to update the hist_fig_less migrants and second citizens gain from messing with animal entity tokens
--this script uses code from dfhack's spawn unit code mostly the histfig data stuff and I guess the nemesis record stuff looking at it now.
-- this is a run to patch citizens script and not automated
-- uhh stability warning on what it does to histfigs and any future issues that comes from it down the line.



ui=df.global.plotinfo

local function allocateNewChunk(hist_entity)
  hist_entity.save_file_id = df.global.unit_chunk_next_id
  df.global.unit_chunk_next_id = df.global.unit_chunk_next_id+1
  hist_entity.next_member_idx = 0
  print("allocating chunk:",hist_entity.save_file_id)
end

local function allocateIds(nemesis_record,hist_entity)
  if hist_entity.next_member_idx == 100 then
    allocateNewChunk(hist_entity)
  end
  nemesis_record.save_file_id = hist_entity.save_file_id
  nemesis_record.member_idx = hist_entity.next_member_idx
  hist_entity.next_member_idx = hist_entity.next_member_idx+1
end

function createFigure(unit,he,he_group)
  local hf = df.historical_figure:new()
  hf.id = df.global.hist_figure_next_id
  df.global.hist_figure_next_id = df.global.hist_figure_next_id+1

  hf.unit_id = unit.id
  hf.nemesis_id = -1
  hf.race = unit.race
  hf.caste = unit.caste
  hf.profession = unit.profession
  hf.sex = unit.sex
  hf.name:assign(unit.name)

  hf.appeared_year = df.global.cur_year
  hf.born_year = unit.birth_year
  hf.born_seconds = unit.birth_time
  hf.curse_year = unit.curse_year
  hf.curse_seconds = unit.curse_time
  hf.birth_year_bias = unit.birth_year_bias
  hf.birth_time_bias = unit.birth_time_bias
  hf.old_year = unit.old_year
  hf.old_seconds = unit.old_time
  hf.died_year = -1
  hf.died_seconds = -1

  hf.civ_id = unit.civ_id
  hf.population_id = unit.population_id
  hf.breed_id = -1
  hf.cultural_identity = unit.cultural_identity
  hf.family_head_id = -1

  df.global.world.history.figures:insert("#", hf)

  hf.info = df.historical_figure_info:new()
  hf.info.whereabouts = df.historical_figure_info.T_whereabouts:new()
  hf.info.whereabouts.death_condition_parameter_1 = -1
  hf.info.whereabouts.death_condition_parameter_2 = -1
  -- set values that seem related to state and do event
  --change_state(hf, dfg.plotinfo.site_id, region_pos)


  --let's skip skills for now
  --local skills = df.historical_figure_info.T_skills:new() -- skills snap shot
  -- ...
  -- note that innate skills are automaticaly set by DF
  hf.info.skills = {new=true}

  if he then
    he.histfig_ids:insert('#', hf.id)
    he.hist_figures:insert('#', hf)
    hf.entity_links:insert("#",{new=df.histfig_entity_link_memberst,entity_id=unit.civ_id,link_strength=100})

    --add entity event
    local hf_event_id = df.global.hist_event_next_id
    df.global.hist_event_next_id = df.global.hist_event_next_id+1
    df.global.world.history.events:insert("#",{new=df.history_event_add_hf_entity_linkst,year=unit.birth_year,
    seconds=unit.birth_time,id=hf_event_id,civ=hf.civ_id,histfig=hf.id,link_type=0})
  end

  if he_group and he_group ~= he then
    he_group.histfig_ids:insert('#', hf.id)
    he_group.hist_figures:insert('#', hf)
    hf.entity_links:insert("#",{new=df.histfig_entity_link_memberst,entity_id=he_group.id,link_strength=100})
  end

  local soul = unit.status.current_soul
  if soul then
    hf.orientation_flags:assign(soul.orientation_flags)
  end

  unit.flags1.important_historical_figure = true
  unit.flags2.important_historical_figure = true
  unit.hist_figure_id = hf.id
  unit.hist_figure_id2 = hf.id

  return hf
end

function createNemesis(unit,civ_id,group_id)
  local id = df.global.nemesis_next_id
  local nem = df.nemesis_record:new()

  nem.id = id
  nem.unit_id = unit.id
  nem.unit = unit
  nem.flags:resize(31)
  nem.unk10 = -1
  nem.unk11 = -1
  nem.unk12 = -1
  df.global.world.nemesis.all:insert("#",nem)
  df.global.nemesis_next_id = id+1
  unit.general_refs:insert("#",{new = df.general_ref_is_nemesisst, nemesis_id = id})

  nem.save_file_id = -1

  local he
  if civ_id and civ_id ~= -1 then
    he = df.historical_entity.find(civ_id)
    he.nemesis_ids:insert("#",id)
    he.nemesis:insert("#",nem)
    allocateIds(nem,he)
  end
  local he_group
  if group_id and group_id ~= -1 then
    he_group = df.historical_entity.find(group_id)
  end
  if he_group then
    he_group.nemesis_ids:insert("#",id)
    he_group.nemesis:insert("#",nem)
  end
  nem.figure = unit.hist_figure_id ~= -1 and df.historical_figure.find(unit.hist_figure_id) or createFigure(unit,he,he_group) -- the histfig check is there just in case this function is called by another script to create nemesis data for a historical figure which somehow lacks it
  nem.figure.nemesis_id = id
  return nem
end
function sigh()
for k,v in pairs(df.global.world.units.active) do
local HF=df.global.world.history.figures
local HO=df.global.plotinfo.civ_id
local EN=df.global.world.entities.all[HO]
local HP=df.global.plotinfo.group_id
if v.hist_figure_id==-1 and v.civ_id==df.global.plotinfo.civ_id then
createNemesis(v,HO,HP)
--createFigure(v,EN,HP)
print(k)
end
end
end

for k,v in pairs(df.global.world.units.active) do
local HFN=df.global.world.history.figures
local HN=df.global.plotinfo.civ_id
sigh()
if v.hist_figure_id==-1 then break else
for c,q in pairs(HFN[v.hist_figure_id].entity_links) do
if q.entity_id==df.global.plotinfo.civ_id and v.population_id==-1 and q.entity_id~=df.global.plotinfo.group_id then
print(v.hist_figure_id)
HFN[v.hist_figure_id].entity_links:insert("#",{new=df.histfig_entity_link_memberst})
HFN[v.hist_figure_id].entity_links[c].entity_id=df.global.plotinfo.group_id
HFN[v.hist_figure_id].entity_links[c].link_strength=100
end
end
end
end

ok so this script is an update to the 3 year old version that probably doesn't work well in DF50 due to the ui to plotinfo change said script also been updated to include uhh 3 year old spawn unit coding for making histfigs and nemesis records as that's a good source to draw from.
this is mostly a modder tool to help with sapient historical-figureless citizen scenario that animal entity tokens do with multi-cultural forts. This script for df50 mostly gives them noble access and means to join squads as I think df50 already gives them labor access.

should note this will not help the 'oops main civ is cats and now no one a noble' issue that one would require a separate custom script for appointing a civ unit to a noble position.


Code: ("wagon-unretire2.lua") [Select]
local contain={}
function unretirewagon(curx,cury,curz)

for de,oe in pairs(df.global.world.buildings.other.WAGON) do
if oe.name == 'Nomad' then


local vector=df.global.world.items.all -- load all items
for i = 0, #vector-1 do -- look into all items offsets
local curpos=vector[i].pos --get its coordinates
local cx=curpos.x
local cy=curpos.y
local cz=curpos.z
if cx==oe.centerx and cy==oe.centery and cz==oe.z then --compare them
dfhack.items.moveToBuilding(vector[i],oe) --return index
end
end

end
end
end

unretirewagon()


here's another wagon script that stores items directly in the center of the wagon back into the wagon for events of retiring and unretiring while nomading, it works with void forts and normal stationary forts ... as so long you name the wagon 'Nomad' ... or delete the if line of code checking if a wagon is named nomad.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

xzaxza

  • Bay Watcher
    • View Profile
Re: DFHack 50.08-r2
« Reply #3454 on: June 08, 2023, 07:28:18 am »

In short, emigration.lua worked in past, but no longer works. I fixed it. Do you want it?

Please! Could you open a PR against the scripts repo? https://github.com/DFHack/scripts/pulls
We can discuss it over the code review.

Took a while, but I got around to do it. https://github.com/DFHack/scripts/pull/735 for 0.47.05 branch, https://github.com/DFHack/scripts/pull/736 for current version. The latter will require some changes, dunno about the former.
Logged
Known issues
You may get a dwarf that likes bugged stockpiles.

Boltgun

  • Bay Watcher
  • [UTTERANCES]
    • View Profile
Re: DFHack 50.08-r3
« Reply #3455 on: June 13, 2023, 01:17:41 pm »

What's the best way to add an announcement on the last version ? For example, I'm trying to add a cancellation message with this line
Code: [Select]
dfhack.gui.autoDFAnnouncement(df.announcement_type.cancel_job, unit.pos, message, COLOR_YELLOW)But it opens the embark "Strike the earth" message. Maybe I got the type wrong.
Logged

myk

  • Bay Watcher
    • View Profile
Re: DFHack 50.08-r3
« Reply #3456 on: June 13, 2023, 02:14:25 pm »

Looking at a real cancellation announcement, it looks like you have the type correct and the enum value is correct. The internal announcement behavior mapping (the data read from prefs/announcements.txt) looks rational as well.

In short, I'm not sure what's going on here. Could you file an issue at https://github.com/DFHack/dfhack/issues ? This appears to be some sort of bug, though I'm not sure where.
Logged

Boltgun

  • Bay Watcher
  • [UTTERANCES]
    • View Profile
Re: DFHack 50.08-r3
« Reply #3457 on: June 15, 2023, 02:55:30 am »

Thanks will do.
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 50.08-r3
« Reply #3458 on: June 19, 2023, 12:48:45 am »

Code: ("recruitorder.lua") [Select]
--this is a script that is a modified version of the recruit script as this doesn't randomly select a historical figure but choose one out of a list.
--for this to work you need to send someone off on a mission probably a safe one like exploring ruins and in the middle of the mission run this script.
-- it might take a few tries to see if it works but if you see two printed out messages showcasing the army id and the mission report info then it might have worked.
--oh it also reuses the campboat script for list gui functions   
local dlg=require("gui.dialogs")
function teleportboatnames2()
local Ark={}
for k,v in pairs(df.global.world.nemesis.all) do
BoaName=dfhack.TranslateName(v.figure.name)
table.insert (Ark,{dfhack.TranslateName(v.figure.name).." "..v.figure.name.nickname,nil,v,search_key = BoaName:lower()})
end
local f=function(Name,C)
  OrderRecruit(C[3])
end
dlg.showListPrompt("list of Nemesis havers","Select Being(s) to settle here",COLOR_WHITE,Ark,f,nil,nil,true)
end

function OrderRecruit(Nemes)
for de,oe in pairs(df.global.world.army_controllers.all) do
if oe.mission_report == nil then else
print ( de,oe.mission_report.title)
for e,o in pairs(df.global.world.armies.all) do
if oe.id == o.controller_id then
print (e)
local forv=df.global.world.armies.all[e].members[0]
df.global.world.armies.all[e].members:insert("#",{new=true,nemesis_id=Nemes.id,
stored_fat = forv.stored_fat,
unk_2c= forv.unk_2c,
unk_28= forv.unk_28,
unk_1= forv.unk_1,
unk_30= forv.unk_30,
unk_34= forv.unk_34})
end
end
end
end
end

teleportboatnames2()
ok so here's a modified version of the old recruit script for targeting one nemesis having hist fig in the world.
hmm ok it seems this script will just shove the historical figure into any squad in an active mission so I don't know if this would dupe the being if you have 2 armies out or insert them into a conquer attempt and accidentally migrated someone to a new site?  still don't know if this is stable so user beware on save stability.

Code: ("recruit-inhabitants.lua") [Select]
--modification of the recruit script that uses the squad option in armies to pad out your army troops and to summon 30 unknown no name units at your enemies and possibly sending them back to you.
--these are inhabitants beings with no historical figures so if you got a script that could give them one or retire you're probably going to have some troubles getting them army ready.
--this script requires the squad to be mid mission to work if you don't see 2 printed info then it didn't stick.
function RecruitInhabit(Nemes)
for de,oe in pairs(df.global.world.army_controllers.all) do
if oe.mission_report == nil then else
print ( de,oe.mission_report.title)
for e,o in pairs(df.global.world.armies.all) do
if oe.id == o.controller_id then
print (e)
local forv=df.global.world.armies.all[e].members[0]
local long=df.global.world.nemesis.all[forv.nemesis_id].unit.population_id
df.global.world.armies.all[e].squads:insert("#",{new=true,count=30,race=df.global.plotinfo.race_id,population_id=long,entity_id=df.global.plotinfo.civ_id})
end
end
end
end
end

RecruitInhabit()
edit ok so here's another script that uses a modified recruit script to instead fill out the army's squad data with inhabitants... this holds potential for putting any creature in the game and any creature with any interaction.
so someone could return to the fort with like an army of necromancers or revenants/intel undead... or zombies/werebeasts (and just ruin your fort's day.)
this messes with the inhabitant mechanic that towns uses to pad out the place so these beings returning to the site will be historical figureless citizens that would require figuring out a way to get them historical figures either by having them kill a historical figure in self defense or retiring and unretiring the place... which may or may not also require them to petition to join the fort which also takes like 2 in-game years to pull off. or use a script that speeds up that process.
« Last Edit: June 19, 2023, 04:58:47 am by Rumrusher »
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

myk

  • Bay Watcher
    • View Profile
Re: DFHack 50.08-r3
« Reply #3459 on: June 23, 2023, 09:36:54 pm »

DFHack 50.08-r4 released!

Get it here: https://github.com/DFHack/dfhack/releases/tag/50.08-r4

Or install from Steam: https://store.steampowered.com/app/2346660/DFHack

If you're on the DF beta branch on Steam, subscribe to the DFHack beta_experimental_sdl2 branch
« Last Edit: June 23, 2023, 09:39:57 pm by myk »
Logged

myk

  • Bay Watcher
    • View Profile
Re: DFHack 50.08-r4
« Reply #3460 on: June 29, 2023, 12:22:53 am »

Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 50.08-r4
« Reply #3461 on: June 29, 2023, 05:44:02 am »

poppin in here to say the current Dfhack release does not respect classic build's settings of having ascii mode turn on.
some how the build just forces it self to check it off on start up... even though premium mode would load no art assets and have everything on screen be invisible.
outside of strangely enough some art assets like the grass and some floor tiles... the ui is also hidden outside of the text.


edit: ok so this some how is a vanilla issue which probably being look at... though this does open the door to figuring out a way to patch this with dfhack.
« Last Edit: June 29, 2023, 06:41:15 am by Rumrusher »
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

myk

  • Bay Watcher
    • View Profile
Re: DFHack 50.09-r1
« Reply #3462 on: July 05, 2023, 10:29:05 pm »

We're working on some screens to help with trading:



Selecting multiple items is very simple. You can click on an item to toggle whether it will be brought to the depot, or you can use the arrow keys and hit Enter to toggle the highlighted item.

You can also shift-click on an item, and all items from the previously-selected item to the one you shift-click on will be toggled.

Some common workflows:

Sell all damaged items
  • Move the "Max condition" slider down from "Pristine" to "xWornx"
  • Click on the "Select all" button or hit Ctrl-a
  • Right click or hit Esc to close the window

Sell all items that the caravan requested in last year's trade agreement
  • Click on "Show only requested items" or hit A to toggle
  • Click on the "Select all" button or hit Ctrl-a
  • Right click or hit Esc to close the window

Sell high-value pots of food
  • Move the "Min value" slider up from "1" to "1000"
  • Type "prepared"
  • Scroll down to the last prepared food pot you want to sell
  • Shift-click on that item to mark it and the ones above it
  • Right click or hit Esc to close the window

Here's the current feature list:

- item condition slider
- quality slider
- item value slider
- toggle for whether to include forbidden items (if you mark a forbidden item for trade, it will be automatically unforbidden)
- information on export agreements with the civilizations of the visiting caravan(s)
- option for filtering items by whether they were requested by the export agreement
- information on the ethical restrictions of the visiting caravan(s)
- option for filtering items by ethical acceptability
- information on current export mandates
- option for filtering out items banned for export
- option for additionally filtering out items that your nobles might ban *as the caravan is leaving* (which they do uncomfortably often) which would cause your dwarves to be punished just the same as if they brought a banned item to the depot for sale
- info on value of items brought/to be brought to the depot
- items that are not reachable from the trade depot or are otherwise not tradable (e.g. the item is on fire) are filtered out of the list

Do you have more thoughts/suggestions? What do you think of the screen layout? There is a lot of space given to the informational/filter widgets, but I'm not sure if that can be helped. The alternative is to show them dynamically, but I don't know if that's a better or worse user experience. You can always resize the window or maximize it by double-clicking on the "Select trade goods" header.
Logged

A_Curious_Cat

  • Bay Watcher
    • View Profile
Re: DFHack 50.09-r1
« Reply #3463 on: July 05, 2023, 11:52:17 pm »

Looks good to me! 👍

Btw, are you caught up on issue #3366?  I got AtomicChicken to reply to it.

Also, are you telling me that I can’t trade an item if it’s on fire?!  What if I use a minecart delivery service?
Logged
Really hoping somebody puts this in their signature.

Clatch

  • Bay Watcher
    • View Profile
Re: DFHack 50.09-r1
« Reply #3464 on: July 06, 2023, 06:44:14 pm »

OMG! I just found toggle-kbd-cursor....

Thank you!!!!!
Pages: 1 ... 229 230 [231] 232 233 ... 243