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 1036319 times)

Sutremaine

  • Bay Watcher
  • [ETHIC:ATROCITY: PERSONAL_MATTER]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4980 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 #4981 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 #4982 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 #4983 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 #4984 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 #4985 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 #4986 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 #4987 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 :::

Quietust

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

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. ;)
It is almost definitely the BLOODSUCKER tag that triggers that behavior. Stuff like SYN_CLASS is typically arbitrary, assigned by the game for procedurally generated creatures but never specifically checked for by in-game logic (i.e. if you were to rename every SYN_CLASS consistently, it wouldn't have any effect on gameplay).

Necromancers are also "friendly to undead", and the one notable tag they get is NO_AGING - have you tried using that one?
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.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4989 on: December 18, 2013, 01:56:18 pm »

This is what I used on my last test. Without the BLOODSUCKER. I think you are right and its the NO_AGING. Wouldnt have guessed, to be honest. NOT_LIVING would have made a lot more sense, but I am just happy that it works. :)

Since NO_AGING is not a valid creature token (I think), I give each civ member a self-targetted interaction. The first 1 second ingame there is a bit of infighting between opposed to life civ-members and alive civ-members, but if I cant get the opposed to life dudes to actually do work, I will get rid of them anyway.

Code: [Select]
[INTERACTION:MAKE_VAMPIRE]
   [I_SOURCE:CREATURE_ACTION]
   [I_TARGET:A:CREATURE]
   [IT_LOCATION:CONTEXT_CREATURE]
[IT_CANNOT_TARGET_IF_ALREADY_AFFECTED]
   [I_EFFECT:ADD_SYNDROME]
[IE_TARGET:A]
[IE_IMMEDIATE]
[IE_ARENA_NAME:Test undead behaviour]
[SYNDROME]
[SYN_CLASS:VAMPCURSE]
[CE_ADD_TAG:NO_AGING:STERILE:NOT_LIVING:START:0]

Now I just have to figure out a nice way to make the Warlocks/Mages look differently from the Skeleton/Undead civ part. I want skeletons as workers, but currently they look the same. ALT_TILE doesnt work, because the creatures use sprites.
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 #4990 on: December 19, 2013, 03:17:33 am »

I've made this fun script that allows you to get rid of specific units in creative manners:

Code: (killitwith.lua) [Select]
--causes targeted unit to die in several possible manners
unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor!  Aborting!")
return
end

if unit.flags1.dead==true then
print ("Dead unit!  Aborting!")
return
end

--fire heat cold gravity thirst hunger time(age)
--blood violence(berserk) water(drown) sabotage(scuttle)

args={...}

if #args ~= 1 then
print ("Use one of the following arguments when calling the script (all lowercase!):")
print ("fire")
print ("heat")
print ("cold")
print ("gravity")
print ("thirst")
print ("hunger")
print ("time")
print ("blood")
print ("violence")
print ("water")
print ("sabotage")
return
end

if args[1]=="fire" then
for k,v in pairs(unit.body.components.body_part_status) do
unit.body.components.body_part_status[k].on_fire=true
end
unit.flags3.body_temp_in_range=false
return
end


if args[1]=="heat" then
for k,v in pairs(unit.status2.body_part_temperature) do
unit.status2.body_part_temperature[k].whole=12000
end
return
end


if args[1]=="cold" then
for k,v in pairs(unit.status2.body_part_temperature) do
unit.status2.body_part_temperature[k].whole=0
end
return
end


if args[1]=="gravity" then
if unit.flags1.projectile==true then
print ("Already a projectile!  Aborting!")
return
end
if unit.flags1.rider==true or unit.flags1.caged==true or unit.flags2.swimming==true or unit.flags3.exit_vehicle1==true or

unit.flags3.exit_vehicle2==true then
print ("Not eligible (rider, caged, swimming, minecart)!  Aborting!")
return
end
local count=0
local l = df.global.world.proj_list
local lastlist=l
l=l.next
    while l do
      count=count+1
if l.next==nil then
lastlist=l
end
      l = l.next
    end
newlist = df.proj_list_link:new()
lastlist.next=newlist
newlist.prev=lastlist
proj = df.proj_unitst:new()
newlist.item=proj
proj.link=newlist
proj.id=df.global.proj_next_id
df.global.proj_next_id=df.global.proj_next_id+1
proj.unit=unit
proj.origin_pos.x=unit.pos.x
proj.origin_pos.y=unit.pos.y
proj.origin_pos.z=unit.pos.z
proj.prev_pos.x=unit.pos.x
proj.prev_pos.y=unit.pos.y
proj.prev_pos.z=unit.pos.z
proj.cur_pos.x=unit.pos.x
proj.cur_pos.y=unit.pos.y
proj.cur_pos.z=unit.pos.z
proj.flags.no_impact_destroy=true
proj.flags.piercing=true
proj.flags.parabolic=true
proj.flags.unk9=true
proj.speed_z=-200000
unitoccupancy = dfhack.maps.getTileBlock(unit.pos).occupancy[unit.pos.x%16][unit.pos.y%16]
if not unit.flags1.on_ground then
unitoccupancy.unit = false
else
unitoccupancy.unit_grounded = false
end
unit.flags1.projectile=true
unit.flags1.on_ground=false
return
end


if args[1]=="thirst" then
unit.counters2.thirst_timer=6000000
return
end


if args[1]=="hunger" then
unit.counters2.hunger_timer=9000000
unit.counters2.stored_fat=0
unit.counters2.stomach_food=0
return
end


if args[1]=="time" then
print("old age placeholder")
return
end


if args[1]=="blood" then
unit.body.blood_count=0
return
end


if args[1]=="violence" then
if unit.status.current_soul==nil then
print ("Soulless unit!  Aborting!")
return
end
unit.status.happiness=0
unit.status.insanity_chance=100
unit.status.current_soul.traits.ANGER=100
unit.status.current_soul.traits.VULNERABILITY=80
--eventually makes the unit go berserk
return
end


if args[1]=="water" then
print("drowning placeholder")
return
end


if args[1]=="sabotage" then
unit.flags3.scuttle=true
return
end


--none of the above
print ("Use one of the following arguments when calling the script (all lowercase!):")
print ("fire")
print ("heat")
print ("cold")
print ("gravity")
print ("thirst")
print ("hunger")
print ("time")
print ("blood")
print ("violence")
print ("water")
print ("sabotage")
--done

1. Any suggestions for other death types, if possible? The game doesn't allow me to create wounds and decapitate people via code, for example, because that needs certain combat functions to run. They just walk around without a head until they realize that they should suffocate. I could probably just provide a "lobotomy" option that removes/damages the brain.

2. I need to make the drowning and old age deaths work. I don't exactly understand how these are determined.

3. People probably want to check out the "gravity" option, since I discovered how to turn units into valid projectiles by studying dfhack.items.makeProjectile(item) and a disassembly of the code that runs when a creature steps off a cliff and falls under gravity. You could change the speed values to shoot creatures up or sideways, slowly or fast.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4991 on: December 19, 2013, 03:28:06 am »

You could make it case insensitive with args[1]:lower()

You could also make it run faster by having a lookup table instead of going through all the arguments:

Code: [Select]
This:
    function hello() print('hello') end
    function world() print('world') end
    if args[1]=='hello' then hello() end
    if args[1]=='world' then world() end
Vs this:
    options={
        hello=function() print('hello') end --will make "options['hello']()" or "options.hello()" print "hello"
        world=function() print('world') end
    }
    options[args[1]]=options[args[1]] or function() print('invalid!') end --makes it so that it prints "invalid!" if options does not actually exist; if it does exist, this line in essence does nothing
    options[args[1]]()

But that's all Lua stuff :V

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4992 on: December 19, 2013, 02:46:28 pm »

Just checking: Can the catsplosion.plug.dll be changed for another creature, like civ-members? Lets say a civ that is otherwise sterile? So you never have kids, but do a magic ritual and the workshop triggers catsplosion once, and all your civ-members pop out a kid?
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 :::

Ravendarksky

  • Bay Watcher
    • View Profile
    • DFMon.exe - Get rid of DF SPAM
Re: DFHack 0.34.11 r3
« Reply #4993 on: December 19, 2013, 05:58:10 pm »

Is it possible to tell how dehydrated a dwarf is using dfhack?
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4994 on: December 19, 2013, 06:03:05 pm »

Is it possible to tell how dehydrated a dwarf is using dfhack?

Yes. unit.counters2.thirst_timer
Pages: 1 ... 331 332 [333] 334 335 ... 373