Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 331 332 [333] 334 335 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1004053 times)

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4980 on: December 17, 2013, 12:25:31 am »

The main source of "knowledge" about dfhack is not any readme, and will never be a readme. It can only tell you about the fixed part of dfhack i.e. the part we wrote, the part that has the infrastructure, the usage details of plugins etc... We can't (or at least i won't) write a guide/readme about the part thats from DF. The part that holds e.g. entity membership. The main reasons are: it will probably change with next df version, there is a ton of it, nobody (except Toady One) knows what does what exactly. Other than that the fastest way is either to dig through df-structures , join our irc channel and ask around, try using gui/gm-editor to get the feel for structures and inner working of df, analyze the other plugins and scripts. The best example is creature creation script. It was not made for so long because nobody knew how it works and some fields were unknown. After some playing around (and df crashing) we have a working creature spawning script. Though it still is missing a lot of details and customization (e.g. memberships, history, starting afflictions, event birth date(age), inventory, maybe appearance customization, beliefs and family relations and so on) my idea was to spawn a creature and then modify it to your liking.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4981 on: December 17, 2013, 12:26:07 am »

mmm I've got something that makes a unit an ally in adventure mode; it shouldn't be too difficult to edit it for fort mode.

Code: [Select]
local args={...}

local unit = args[1] and df.unit.find(args[1]) or dfhack.gui.getSelectedUnit()

local unitnem = dfhack.units.getNemesis(unit)

local unitfig = df.historical_figure.find(unit.hist_figure_id)

local adv = df.global.world.units.active[0]

local advnem = dfhack.units.getNemesis(adv)

unit.relations.group_leader_id=adv.id

if unitnem then
unitnem.group_leader_id=advnem.id
end
if advnem and unitnem then
advnem.companions:insert('#',unitnem.id)
end

if unitfig then
for i=1,#unitfig.entity_links do
unitfig.entity_links:erase(0)
end
end
unit.civ_id=(df.global.world.units.active[0].civ_id)

Thundercraft

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4982 on: December 17, 2013, 03:00:01 am »

The main source of "knowledge" about dfhack is not any readme, and will never be a readme. It can only tell you about the fixed part of dfhack i.e. the part we wrote, the part that has the infrastructure, the usage details of plugins etc... We can't (or at least i won't) write a guide/readme about the part thats from DF...

Understood. I knew there wasn't a comprehensive guide or anything. But I had no idea where to start.

Other than that the fastest way is either to dig through df-structures , join our irc channel and ask around, try using gui/gm-editor to get the feel for structures and inner working of df, analyze the other plugins and scripts. The best example is creature creation script...

:) Thank you for the tips.

mmm I've got something that makes a unit an ally in adventure mode; it shouldn't be too difficult to edit it for fort mode.

{code}

Oh, thanks! That looks like a good starting point.
Logged

Sutremaine

  • Bay Watcher
  • [ETHIC:ATROCITY: PERSONAL_MATTER]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4983 on: December 17, 2013, 10:24:31 am »

What's COMBATHARDNESS called for the purposes of DFHack scripts? Specifically, I'd like it to be able to examine how 'tragic' an individual effect is.
Logged
I am trying to make chickens lay bees as eggs. So far it only produces a single "Tame Small Creature" when a hen lays bees.
Honestly at the time, I didn't see what could go wrong with crowding 80 military Dwarves into a small room with a necromancer for the purpose of making bacon.

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.34.11 r3
« Reply #4984 on: December 17, 2013, 01:28:28 pm »

What's COMBATHARDNESS called for the purposes of DFHack scripts? Specifically, I'd like it to be able to examine how 'tragic' an individual effect is.
In Lua, you should be able to use "df.misc_trait_type.Hardened".
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

Sutremaine

  • Bay Watcher
  • [ETHIC:ATROCITY: PERSONAL_MATTER]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4985 on: December 17, 2013, 02:49:39 pm »

How do I use it? I've been using the getbloodcount script as a base and replacing unit.body.blood_count with whatever will make it give out the number I'm after, but it either gives me various errors or returns the number 15. I tried running that one on two dwarves with different descriptions of their combat hardiness, and should have gotten two different numbers.

The original getbloodcount script:

Spoiler (click to show/hide)
Logged
I am trying to make chickens lay bees as eggs. So far it only produces a single "Tame Small Creature" when a hen lays bees.
Honestly at the time, I didn't see what could go wrong with crowding 80 military Dwarves into a small room with a necromancer for the purpose of making bacon.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4986 on: December 17, 2013, 03:59:01 pm »

You should be using df.unit.find(num) there, not df.global.world.units.all[num].

Also, for combathardness you want dfhack.units.getMiscTrait(unit,df.misc_trait_type.Hardened,true)

The true is optional (it creates the misc trait if the creature doesn't have one) but I don't think it'll hurt anything.

Sutremaine

  • Bay Watcher
  • [ETHIC:ATROCITY: PERSONAL_MATTER]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4987 on: December 17, 2013, 06:40:09 pm »

Okay, here's what I've got now.

Spoiler (click to show/hide)

What it's outputting now is <unit_misc_trait: 0x1C71a220> , with a different memory address for each unit.

I assume I need to connect the 'get_misc_trait' part of the script to the 'print(getTraumaCount(traumaCountUnit))' part, but I don't know how.
Logged
I am trying to make chickens lay bees as eggs. So far it only produces a single "Tame Small Creature" when a hen lays bees.
Honestly at the time, I didn't see what could go wrong with crowding 80 military Dwarves into a small room with a necromancer for the purpose of making bacon.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4988 on: December 17, 2013, 06:42:43 pm »

You want to add a .value at the end of your getTraumaCount(traumaCountUnit) thing:

print(getTraumaCount(traumaCountUnit).value)

Sutremaine

  • Bay Watcher
  • [ETHIC:ATROCITY: PERSONAL_MATTER]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4989 on: December 17, 2013, 08:58:29 pm »

Excellent! It works now, thanks.

One odd result I've noticed is that a child who lost his father when he was a baby has 0 hardiness.
Logged
I am trying to make chickens lay bees as eggs. So far it only produces a single "Tame Small Creature" when a hen lays bees.
Honestly at the time, I didn't see what could go wrong with crowding 80 military Dwarves into a small room with a necromancer for the purpose of making bacon.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4990 on: December 17, 2013, 09:01:10 pm »

It's called COMBATHARDNESS in the raws; it's mostly increased by combat, as far as I can tell. Give that child a good beating and it should go up.

Sutremaine

  • Bay Watcher
  • [ETHIC:ATROCITY: PERSONAL_MATTER]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4991 on: December 17, 2013, 10:32:16 pm »

Ah, I've got it the wrong way round. I thought that thoughts marked as tragedies would make the dwarf become more resistant to future tragic events.
Logged
I am trying to make chickens lay bees as eggs. So far it only produces a single "Tame Small Creature" when a hen lays bees.
Honestly at the time, I didn't see what could go wrong with crowding 80 military Dwarves into a small room with a necromancer for the purpose of making bacon.

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4992 on: December 18, 2013, 12:08:09 am »

Ah, I've got it the wrong way round. I thought that thoughts marked as tragedies would make the dwarf become more resistant to future tragic events.

Babies are insane and are also prohibited from many things, such as learning skills or using skills (even if natural). Wouldn't surprise me if they are immune to hardening.

Sutremaine

  • Bay Watcher
  • [ETHIC:ATROCITY: PERSONAL_MATTER]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4993 on: December 18, 2013, 11:09:27 am »

Just used DFHack to kill somebody's wife. He was unhappy about it, but not hardened by it.
Logged
I am trying to make chickens lay bees as eggs. So far it only produces a single "Tame Small Creature" when a hen lays bees.
Honestly at the time, I didn't see what could go wrong with crowding 80 military Dwarves into a small room with a necromancer for the purpose of making bacon.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4994 on: December 18, 2013, 12:17:58 pm »

Hello everyone,

I am currently trying a undead race, but the game says "your settlement has crumbled", if all civ members are opposed to life. Not-Living is not enough to make civ-members friendly to undeads, but I remembered that vampires act neutral, and not even invading necromancer armies do attack them. At least I read forum posts about this.

My current plan it to set the vampire flag for all civ members with an automated dfhack script. It doesnt have to add any tags, like bloodsucker, it just needs to help the game identify the civ-members as vampires. (even if they are none)

I found this related post by Grewon:
I modified warmist's syndrome script from here so that it searches for the vampire syndrome id by checking the syndrome's displayed name(in this case vampire), and then infects the selected unit with the vampire syndrome, effectively making him a vampire. It also seems to work with necromancers.
Code: [Select]
function assignSyndrome(target,syn_id)
    if target==nil then
        qerror("Not a valid target")
    end
    local ns=df.unit_syndrome:new()
    local trg_syn=df.syndrome.find(syn_id)
    ns.type=trg_syn.id
    --ns.year=
    --ns.year_time=
    ns.ticks=1
    ns.unk1=1
    for k,v in ipairs(trg_syn.ce) do
        local sympt=df.unit_syndrome.T_symptoms:new()
        sympt.ticks=1
        sympt.flags=2
        ns.symptoms:insert("#",sympt)
    end
    target.syndromes.active:insert("#",ns)
end
function makeVampire(unit)
for i=0,#df.global.world.raws.syndromes.all-1 do
for j=0,#df.global.world.raws.syndromes.all[i].ce-1 do
for k,v in pairs(df.global.world.raws.syndromes.all[i].ce[j]) do
if k=="name" then
if v=="vampire" then --this can be changed to necromancer
print("Found vampire syndrome id:"..i)
assignSyndrome(unit,i)
print("Infected unit with vampire syndrome.")
return
end
end
end
end
end
end
local unit=dfhack.gui.getSelectedUnit()
makeVampire(unit)


P.S. this simple cure script removes all syndromes in case you want to undo the effects of the first script, or even if you want to cure genuinely infected units.
Code: [Select]
local unit=dfhack.gui.getSelectedUnit()
while #unit.syndromes.active > 0 do
unit.syndromes.active:erase(0)
end
while #unit.body.wounds > 0 do
unit.body.wounds:erase(0)
end
unit.body.wound_next_id=1

Unfortunately I dont know exactly how to get from this code to a lua-script that runs on each civ-member. I know how to run a script with SyndromeTrigger. I could write an interaction for the civ that targets themselves and runs a script, but I would need a script that adds the vampire-flag without any other syndromes. OR whatever else would lead to an undead civ, which is friendly to zombies, but does not end the game automatically.

I tried pretty much everything thats possible with modding, and it did not work. I have to ask for your assisstance (again ;) ). If anyone knows how to make civ-members friendly to undeads, please let me know. :)

EDIT: After more tests it seems to be possible with modding alone. SYN_CLASS:VAMPCURSE and/or the BLOODSUCKER tag allow allying with undeads. So please dont mind about this script anymore, I found a solution. Make all civ members bloodsuckers, but have no civ members with blood. ;)
« Last Edit: December 18, 2013, 01:11:14 pm by Meph »
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 :::
Pages: 1 ... 331 332 [333] 334 335 ... 373