Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 285 286 [287] 288 289 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1456522 times)

PeridexisErrant

  • Bay Watcher
  • Dai stihó, Hrasht.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4290 on: July 24, 2013, 08:24:46 pm »

Kurik (or anyone) - I'm trying to write a script based on soundsense-season that writes which region was loaded to the gamelog, so that it's possible to distinguish between fort logs when playing more than one at a time - important for eg DF Story Maker and /or manual parsing. 

If I'm right, all I need is the proper variable names to get the region number, dwarf name, and translated name.  If I've stuffed up somewhere else, what's gone wrong?

Code: [Select]
-- On map load writes information about the loaded region to gamelog.txt

local function write_gamelog(msg)
    local log = io.open('gamelog.txt', 'a')
    log:write(msg.."\n")
    log:close()
end

if args[1] == 'disable' then
    dfhack.onStateChange[_ENV] = nil
else
    dfhack.onStateChange[_ENV] = function(op)
        if op == SC_WORLD_LOADED then
            write_gamelog('Loaded Region'[X]', '[dwarfname]', '[translatedname]'.')
        end
    end
end

Logged
I maintain the DF Starter Pack - over a million downloads and still counting!
 Donations here.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4291 on: July 24, 2013, 09:18:22 pm »

@Kurik Amudnil: Thanks, that sounds like it would solve most things I did ask for. The script you posted is an example? And "site selector" is what I did mean when I said "embark screen before embark selection" I didnt knew there was a specific name for it. I dont know how much work all of this would be... a pop-up for startdwarf, maybe one for embark points like you suggested, (is there even a script for this?) and running the script that deletes access to specific materials/pets from civs.

That would be amazing, I could do fancy trees, even fancier pets, fix a bug with the embark profiles (DF deletes the pet entries for other races, so if I play Dwarf it deletes orc/kobold pets, and when I then play orc/kobolds the pets I selected for the embark profiles are gone), allow easier handling of embark dwarves and points, and I can give more specific pets to invaders and traders. No more endless lists, or random warbeasts that invaders shouldnt have. Makes balancing so much better, and lore-wise as well. Steampunk horses as mounts for the automatons, with steampunk spiders as warbeasts... Goblins ride war boars, bring trolls... Orcs ride Warghs and bring Ogres... yeah. :)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4292 on: July 24, 2013, 10:04:09 pm »

I'll look into the recent request. In the meantime, I'd refer people to the link in my sig for the "liquid barrel and blood barrel remover" http://www.bay12forums.com/smf/index.php?topic=91166.msg4246062#msg4246062 .

Note that I say:
Quote
If used before embark (at the screen where you choose your site location), it prevents you from being able to embark with barrels of blood, considerably shortening the extracts list.
But I meant that the script can be used anytime after embark to prevent future human caravans from bringing blood barrels etc. - it only makes embarking with milk easier if you use it at the site selector.

You only want to remove explosive trees at the site selector because there is a nonzero chance that your embark wagon will be very FUN if you don't!

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4293 on: July 24, 2013, 10:40:09 pm »

Ah, ok. I thought that there should have been a init.lua that hooks into something. I will have a go at it, see if I can get it to work. At least the automated start.

Edit: Cant get it to work. Top folder of the raws folder? That would be the DwarfFortress folder, next to the .exe.

init.lua looks like this:
Code: [Select]
--local my_entity=df.historical_entity.find(df.global.ui.civ_id)
local sText=" "
local k=0
local v=1

for x,y in pairs(df.global.world.entities.all) do
my_entity=y

k=0
while k < #my_entity.resources.organic.wood.mat_index do
v=my_entity.resources.organic.wood.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.organic.wood.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.organic.wood.mat_type:erase(k)
my_entity.resources.organic.wood.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.organic.wood.mat_type:erase(k)
my_entity.resources.organic.wood.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.crafts.mat_index do
v=my_entity.resources.misc_mat.crafts.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.crafts.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.misc_mat.crafts.mat_type:erase(k)
my_entity.resources.misc_mat.crafts.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.crafts.mat_type:erase(k)
my_entity.resources.misc_mat.crafts.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.barrels.mat_index do
v=my_entity.resources.misc_mat.barrels.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.barrels.mat_index[k])
if (sText==nil) then
--LIQUID barrels
my_entity.resources.misc_mat.barrels.mat_type:erase(k)
my_entity.resources.misc_mat.barrels.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.barrels.mat_type:erase(k)
my_entity.resources.misc_mat.barrels.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.wood2.mat_index do
v=my_entity.resources.misc_mat.wood2.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.wood2.mat_index[k])
if (sText==nil) then
--LIQUID wood2
my_entity.resources.misc_mat.wood2.mat_type:erase(k)
my_entity.resources.misc_mat.wood2.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.wood2.mat_type:erase(k)
my_entity.resources.misc_mat.wood2.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end

k=0
while k < #my_entity.resources.misc_mat.cages.mat_index do
v=my_entity.resources.misc_mat.cages.mat_type[k]
sText=dfhack.matinfo.decode(v,my_entity.resources.misc_mat.cages.mat_index[k])
if (sText==nil) then
--LIQUID cages
my_entity.resources.misc_mat.cages.mat_type:erase(k)
my_entity.resources.misc_mat.cages.mat_index:erase(k)
k=k-1
else
if(sText.material.id=="WOOD") then
if(sText.plant.id=="SPORE_TREE") then
my_entity.resources.misc_mat.cages.mat_type:erase(k)
my_entity.resources.misc_mat.cages.mat_index:erase(k)
k=k-1
end
end
end
k=k+1
end


end

Anything I have to add to the dfhack.init?

The top of the raws folder is the raws folder, right above objects, which is one of the two folders in the raws folder.

Dwarf Fortress/raw is where you put it.

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4294 on: July 25, 2013, 12:06:16 am »

....

something like this?
Code: (lua) [Select]
-- On map load writes information about the loaded region to gamelog.txt

local function write_gamelog(msg)
    local log = io.open('gamelog.txt', 'a')
    log:write(msg.."\n")
    log:close()
end

local args = {...}
if args[1] == 'disable' then
    dfhack.onStateChange[_ENV] = nil
else
    dfhack.onStateChange[_ENV] = function(op)
        if op == SC_WORLD_LOADED then
            local site = df.world_site.find(df.global.ui.site_id)
            local fort_ent = df.global.ui.main.fortress_entity
            local civ_ent = df.historical_entity.find(df.global.ui.civ_id)
            -- site positions
            -- site  .pos.x  .pos.y
            -- site  .rgn_min_x  .rgn_min_y  .rgn_max_x  .rgn_max.y
            -- site  .global_min_x  .global_min_y  .global_max_x  .global_max_y
            --site.name
            --fort_ent.name
            --civ_ent.name
           
            write_gamelog('Loaded Region ('..site.pos.x..','..site.pos.y..'), '..dfhack.TranslateName(site.name)..' ('..dfhack.TranslateName(site.name, true)..')'..NEWLINE..
                          '    colonized by the group '..dfhack.TranslateName(fort_ent.name)..' ('..dfhack.TranslateName(fort_ent.name,true)..
                              ') of the civilization '..dfhack.TranslateName(civ_ent.name)..' ('..dfhack.TranslateName(civ_ent.name,true)..').'..NEWLINE)
        end
    end
end

might want to use SC_MAP_LOADED instead of world but it seems to be working with world so it might be irrelevant.

** added local to the 3 variables I set
« Last Edit: July 25, 2013, 01:17:17 am by Kurik Amudnil »
Logged

PeridexisErrant

  • Bay Watcher
  • Dai stihó, Hrasht.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4295 on: July 25, 2013, 12:40:06 am »

Brilliant, thanks so much. 

My brief findings so far:  SC_WORLD_LOADED puts this before the announcement for soundsense-season, which is better for parsing so I've left it like that.  I've called the script "log-region.lua" in my LNP (up as soon as it uploads...), and it triggers with just the name "log-region" in dfhack.init

Now off to let the_gazelle know that this is available, so DF Story Maker can take advantage of it and do history per-fort...
Logged
I maintain the DF Starter Pack - over a million downloads and still counting!
 Donations here.

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4296 on: July 25, 2013, 02:53:23 am »

@PeridexisErrant

I forgot to declare those 3 variables local, not that important here but they should be declared local.  Reformat the text as needed.  I am not sure which of the various position variables would be the most relevant or useful.  I think site.pos is the map block and according to comments in the world_site.xml, the rgn_min_x etc are embark blocks within the map block, and the global_min_x etc are the same embark blocks but in global coords rather than local to the map block.

This also should be tested with the different game modes to make sure it behaves.



@Meph
yes, that is an example script.  When we have example scripts for the other stuff it can be updated to plug that in.

I was also thinking about looking into making a compiled c++ plugin to intercept the (e)mbark button to export a lua event so that the script stuff could be done before the embark profiles come up but after a site and civ are chosen.  I am not yet sure how well that would work but it is a thought.

PeridexisErrant

  • Bay Watcher
  • Dai stihó, Hrasht.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4297 on: July 25, 2013, 03:47:16 am »

@Kurik Amudnil

I've updated it for the next version, again many thanks.  From my quick calculations, the site.pos bit returns the region tile from the world map that your fort is within, which is potentially pretty useful for finding a fort given that you can't embark across the edges, or even just scrolling to embark there on a copy of someone's save.  Only thing I can think of to add is if it's possible to append the number to region (eg region2), and maybe reshuffle the first line to scan a little better? (I've put in '..#..' as a placeholder for whatever that variable should be called...

Code: [Select]
write_gamelog('Loaded Region'..#..', '..dfhack.TranslateName(site.name)..' ('..dfhack.TranslateName(site.name, true)..'), at coordinates ('..site.pos.x..','..site.pos.y..')'..NEWLINE..
This would give
Quote
Loaded Region2, Datangikut (Irondabbled), at coordinates (11,12)
    colonized by the group Sarvesh Kudust (The Furnace of Princes) of the civilization Alath Teskom (The Bolt of Jails).
Logged
I maintain the DF Starter Pack - over a million downloads and still counting!
 Donations here.

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4298 on: July 25, 2013, 04:49:09 am »

<...> if it's possible to append the number to region (eg region2) <...>
Actually it can be any string if you rename your region folder. It can be got from df.global.(?world.?).cur_savegame.save_dir

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4299 on: July 25, 2013, 01:00:30 pm »

yes, what warmist said

Code: [Select]
write_gamelog('Loaded '..df.global.world.cur_savegame.save_dir..', '..

Mohreb el Yasim

  • Bay Watcher
  • ♫♪♫♫♪♫♪♪♫♪
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4300 on: July 25, 2013, 05:41:49 pm »

i think i found an error in prospect command:
it says:

[DFHack]# prospect
Could not find magma sea.


when i am in the before embark screen.
the particularity of this world is that there is no magma sea (but i do not see the need of a magma see for the command can give me the layer types.)
Logged
Mohreb el Yasim


GENERATION 24:The first time you see this, copy it into your sig on any forum and add 1 to the generation. Social experime

PeridexisErrant

  • Bay Watcher
  • Dai stihó, Hrasht.
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4301 on: July 25, 2013, 07:47:45 pm »

Kurik, Warmist, thanks again.  The script I'm going to call final (if nothing else comes up) is: 

Code: (log-region.lua) [Select]
-- On map load writes information about the loaded region to gamelog.txt

local function write_gamelog(msg)
    local log = io.open('gamelog.txt', 'a')
    log:write(msg.."\n")
    log:close()
end

local args = {...}
if args[1] == 'disable' then
    dfhack.onStateChange[_ENV] = nil
else
    dfhack.onStateChange[_ENV] = function(op)
        if op == SC_WORLD_LOADED then
            local site = df.world_site.find(df.global.ui.site_id)
            local fort_ent = df.global.ui.main.fortress_entity
            local civ_ent = df.historical_entity.find(df.global.ui.civ_id)
            -- site positions
            -- site  .pos.x  .pos.y
            -- site  .rgn_min_x  .rgn_min_y  .rgn_max_x  .rgn_max.y
            -- site  .global_min_x  .global_min_y  .global_max_x  .global_max_y
            --site.name
            --fort_ent.name
            --civ_ent.name
           
            write_gamelog('Loaded '..df.global.world.cur_savegame.save_dir..', '..dfhack.TranslateName(site.name)..' ('..dfhack.TranslateName(site.name, true)..'), at coordinates ('..site.pos.x..','..site.pos.y..')'..NEWLINE..
                          '    colonized by the group '..dfhack.TranslateName(fort_ent.name)..' ('..dfhack.TranslateName(fort_ent.name,true)..
                              ') of the civilization '..dfhack.TranslateName(civ_ent.name)..' ('..dfhack.TranslateName(civ_ent.name,true)..').'..NEWLINE)
        end
    end
end

And is activated by putting "log-region" as it's own line in dfhack.init
Logged
I maintain the DF Starter Pack - over a million downloads and still counting!
 Donations here.

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4302 on: July 26, 2013, 12:22:41 am »

This script displays all the creatures that are stored in entity.resources.animals for all entities in the world. I recommend generating a pocket world to use the script on for the first time, because normal worlds seem to have thousands of entities.

Note that adding or erasing creatures from this list won't change the meat, blood, milk, leather, etc. that civs bring. It will only affect the live creatures that they bring.

You can do silly stuff like make elves pull caravan wagons without having to change the elf creature tokens by editing the appropriate lists.

Code: [Select]
print("Type y to print ",#df.global.world.entities.all," entity creature lists")
test=dfhack.lineedit("")
if test=="y" or test=="Y" then

for x,my_entity in pairs(df.global.world.entities.all) do
anmlz=my_entity.resources.animals

print(" ")
print("******************************************************************************")
print("entity:",my_entity.entity_raw.code, df.global.world.raws.creatures.all[my_entity.race].creature_id)
if my_entity==df.historical_entity.find(df.global.ui.civ_id) then
print("Player's Civilization")
end
print(" ")

for k,v in pairs(anmlz.pet_races) do
critter=df.global.world.raws.creatures.all[v]
print("PET",k, critter.creature_id, critter.caste[anmlz.pet_castes[k]].caste_id)
end

for k,v in pairs(anmlz.wagon_races) do
critter=df.global.world.raws.creatures.all[v]
print("WAGON",k, critter.creature_id, critter.caste[anmlz.wagon_castes[k]].caste_id)
end

for k,v in pairs(anmlz.pack_animal_races) do
critter=df.global.world.raws.creatures.all[v]
print("PACK_ANIMAL",k, critter.creature_id, critter.caste[anmlz.pack_animal_castes[k]].caste_id)
end

for k,v in pairs(anmlz.wagon_puller_races) do
critter=df.global.world.raws.creatures.all[v]
print("WAGON_PULLER",k, critter.creature_id, critter.caste[anmlz.wagon_puller_castes[k]].caste_id)
end

for k,v in pairs(anmlz.mount_races) do
critter=df.global.world.raws.creatures.all[v]
print("MOUNT",k, critter.creature_id, critter.caste[anmlz.mount_castes[k]].caste_id)
end

for k,v in pairs(anmlz.minion_races) do
critter=df.global.world.raws.creatures.all[v]
print("MINION",k, critter.creature_id, critter.caste[anmlz.minion_castes[k]].caste_id)
end

for k,v in pairs(anmlz.exotic_pet_races) do
critter=df.global.world.raws.creatures.all[v]
print("EXOTIC_PET",k, critter.creature_id, critter.caste[anmlz.exotic_pet_castes[k]].caste_id)
end

--test=dfhack.lineedit("continue...")
end

end

print(" ")
print("done!")

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4303 on: July 26, 2013, 01:24:31 am »

Does anyone know how exactly deities are linked to specific entities (Urist Stylesuitor is a deity of The Glad Helms....)?

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4304 on: July 26, 2013, 01:28:37 am »

As well as my earlier findings here:
http://www.bay12forums.com/smf/index.php?topic=91166.msg4332174#msg4332174
http://www.bay12forums.com/smf/index.php?topic=91166.msg4341092#msg4341092
http://www.bay12forums.com/smf/index.php?topic=91166.msg4356227#msg4356227
I have yet another submission to the df structures:

https://github.com/angavrilov/df-structures/blob/master/df.units.xml#L1025
wound_damage_flags1
Spoiler (click to show/hide)

https://github.com/angavrilov/df-structures/blob/master/df.units.xml#L1012
wound_effect_type
Spoiler (click to show/hide)

https://github.com/angavrilov/df-structures/blob/master/df.items.xml#L709
body_part_status
Spoiler (click to show/hide)

https://github.com/angavrilov/df-structures/blob/master/df.units.xml#L940
unit_inventory_item mode Unk7 is used to identify a bitten part held in a mouth:
You bite Dwarf 2 in the fourth toe, right foot, tearing apart the fat!
You latch on firmly!
You shake Dwarf 2 around by the fourth toe, right foot and the severed part sails off in an arc!
The fourth toe, right foot is ripped away and remains in Your grip!
You let the Dwarf 2's fourth toe, right foot drop away as You attack.

https://github.com/angavrilov/df-structures/blob/master/df.units.xml#L659
This curse integer, default 100, is the luck percentage.
200 means that your luck-affected skill rolls are multiplied by 2.
50 means that your skill rolls are divided by 2.
Valid values are from 0 (cursed by a mummy) to 10000 (100x or {1% becomes 100%} auto-success). Yes, you can use a syndrome to bless people with random bursts of awesome.

Also just for interest:
IMPACT material properties are used in blunt damage calculation
SHEAR is used with edged damage
TENSILE is used with shaking a creature after a bite latched
COMPRESSIVE is used with pinching/gouging
BENDING is used with joint locks
TORSION may also be used with joint locks (verify)
Pages: 1 ... 285 286 [287] 288 289 ... 373