Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 296 297 [298] 299 300 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1458973 times)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4455 on: August 28, 2013, 11:18:17 am »

When you say fresh copy, do you mean DF, or MasterworkDF? I somehow assumed that you meant to vanilla game. If you use the mod, then a few parts are different... custom written dfhack scripts, patched exe, things like that.
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 :::

ag

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4456 on: August 28, 2013, 11:22:56 am »

By fresh copy I do mean a vanilla copy.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4457 on: August 28, 2013, 11:41:01 am »

No wonder that you can reproduce the crash. ^^ But I am surprised, I did do "unload all" which should stop all dfhack shenanigans... I think if you load the save with the mod, then you would get the crash as well. And if only you can tell me the name of the script that crashes it, I would raise a monument to your name (ingame, of course) ;)

I will try the save again with a vanilla df exe, see if that changes anything. After that it can only be any of the custom scripts.
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 :::

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4458 on: August 28, 2013, 11:58:19 am »

Coincidentally, I do have a script that sets hunger to 0 lying around (for adventure mode only)

Code: [Select]
local player = df.global.world.units.active[0]

player.counters2.hunger_timer=0

That should give you a hint :V

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4459 on: August 28, 2013, 12:35:33 pm »

hunger_timer=0... hope I can find a way to add this to a creature.
EDIT: Looked at some scripts... no idea. ^^
« Last Edit: August 28, 2013, 12:37:42 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 :::

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4460 on: August 28, 2013, 12:51:53 pm »

What do you mean "add this"? Like, use a syndrome?

syndromeTrigger.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4461 on: August 28, 2013, 01:41:45 pm »

Putnam: Add it to a creature. I want a dwarf that runs a reaction that triggers autosyndrome with fovcommand (like hire-guard, targetting everything in field of view) that adds hunger_timer=0 to all nearby pets. Effectively feeding grazers :) But I am missing the script that adds the hunger_timer=0 to a selected creature. Thats all.

Ag: You magnificent son of a very nice lady. You kinda found it. Its the exe. It was the string dump replacements I did. A dog dies of infection and crashes the game, because the new death message for "succumbed to infection" was too long. I changed that back to default and it works. :) I was using this: |succumbed to infection.|succumbed to infection. After a long battle against sickness and necrosis, the corrupted flesh has found its way into the heart.| before, and the new sentence crashed the game.

YES!!! You can believe how happy I am, I am sure this (and the other long deathmessages, like frostbite) are the sources of the crashes people suddenly have since V.3d.
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 :::

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4462 on: August 28, 2013, 03:00:49 pm »

I have no idea how autosyndrome selects creatures that aren't the worker. If I did know, I could write it for you right now.

Also, Meph: yeah, don't use long strings and ESPECIALLY don't change the length of the strings that are noted.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4463 on: August 28, 2013, 03:21:03 pm »

fovcommand. It does it automatically. Any script that works on a selected unit with 'k', it can target by field of view of the worker.

For example make_legendary.lua. It needs a unit to be selected with 'k', so autosyndrome cant find it. But this would work:
Code: [Select]
[SYN_CLASS:\COMMAND]
[SYN_CLASS:fovcommand]
[SYN_CLASS:\WORKER_ID]
[SYN_CLASS:make_legendary]
[SYN_CLASS:DWARF]

So all I need is a script that works on the selected unit. :)
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 :::

uggi

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4464 on: August 28, 2013, 03:36:11 pm »

fovcommand. It does it automatically. Any script that works on a selected unit with 'k', it can target by field of view of the worker.

For example make_legendary.lua. It needs a unit to be selected with 'k', so autosyndrome cant find it. But this would work:
Code: [Select]
[SYN_CLASS:\COMMAND]
[SYN_CLASS:fovcommand]
[SYN_CLASS:\WORKER_ID]
[SYN_CLASS:make_legendary]
[SYN_CLASS:DWARF]

So all I need is a script that works on the selected unit. :)

I used this script to keep an injured and starving dwarf alive, to see how long it would take for anyone to bother rescuing him. 40 idle dorfs and no-one paid attention to him until shortly after I reset his hunger/thirst timers back to 0. Seems to work with grazers too.

Code: (hunger.lua) [Select]
-- Shows/resets hunger and thirst counters

function run(cmd)
local unit=dfhack.gui.getSelectedUnit()
if unit then
local name = dfhack.units.getVisibleName(unit)
if name and name.has_name then
unitname = dfhack.TranslateName(name)
else
unitname = "unit"
end


if cmd == 'status' then
print("Status for "..unitname..":")
print("Hunger:", unit.counters2.hunger_timer)
print("Thirst:", unit.counters2.thirst_timer)
elseif cmd == 'reset' then
print("Resetting hunger and thirst counters for "..unitname)
unit.counters2.hunger_timer=0
unit.counters2.thirst_timer=0
end
end
end

local cmd = ...
if not cmd then
qerror('Usage: hunger status/reset')
end
run(cmd)
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4465 on: August 28, 2013, 03:47:11 pm »

...can someone point to me the code for fovcommand?

EDIT: Derp, pretty sure I used it for slavery in drow.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4466 on: August 28, 2013, 05:23:11 pm »

fovcommand.lua
Code: [Select]
-- Will execute a command over the field of view for the selected unit in a radius of 10.
--[[

This script requires the fov plugin from the Hire guard reaction mods :
http://dffd.wimbli.com/file.php?id=7785
 
It will calculate the field of view of the source unit and will run a dfhack command for every
unit found within this field of view. This is used, for example, as an effect from a workshop
reaction that will affect nearby creatures.
 
If no source unit is provided
 
This will unfortunatly only support lua scripts.
 
Usage : fovcommand <source_unit> <command> [<target_raw>] [<arg>]
- command : The name of the script that will run on the targets.
- source_unit : The id of the unit whose field of view will be checked.
- target_raw (optional) : A creature raw's ID, this will limit the effect to this creature only.
- arg (optional) : An additional argument to give to the command.
 
The target script will be run as "myscript <target> <arg>".
 
Usage with autosyndrome :
This script works with autosyndrome, here's an example.
 
[SYN_CLASS:\COMMAND]
[SYN_CLASS:fovcommand]
[SYN_CLASS:\WORKER_ID]
[SYN_CLASS:myscript]
[SYN_CLASS:DOG]
[SYN_CLASS:BITING]
 
This will run "myscript <id> BITING" for every dog in the vinicity of the worker.
@version 1.0
@author Boltgun
 
]]
local fov = require 'fov'
 
-- Checks
if not dfhack.isMapLoaded() then qerror('Map is not loaded.') end
if not ... then qerror('No arguments provided, please provide the source\'s id and a script name') end
 
local args = {...}
local radius = 10
local unitList = df.global.world.units.active
local unit = nil
local target_raw = nil
local view, i, unitTarget
 
-- Checking args
if not args[2] then qerror('Please enter the command you wish to run on the target units') end
 
-- Finding the source unit
function findUnit(searchId)
local k, _
 
for k, _ in ipairs(unitList) do
if unitList[k].id == searchId then
return unitList[k]
end
end
 
return nil
end
 
-- Check if the unit is seen and valid
function isSelected(unit, view)
local unitRaw = df.global.world.raws.creatures.all[unitTarget.race]
 
if not dfhack.units.isDead(unit) and not dfhack.units.isOpposedToLife(unit) then
if not target_raw or unitRaw.creature_id == target_raw then
return validateCoords(unit.pos, view)
end
end
 
return false
end
 
-- Check boundaries and field of view
function validateCoords(pos, view)
 
if pos.x < view.xmin or pos.x > view.xmax then
return false
end
 
if pos.y < view.ymin or pos.y > view.ymax then
return false
end
 
return view.z == pos.z and view[pos.y][pos.x] > 0
 
end
 
 
-- action
unit = findUnit(tonumber(args[1]))
if not unit then qerror('Source unit not found') end
 
if args[3] then target_raw = args[3] end
view = fov.get_fov(radius, unit.pos)
 
-- Check through the list for the right units
for i = #unitList - 1, 0, -1 do
unitTarget = unitList[i]
if isSelected(unitTarget, view) then
 
if args[4] then
dfhack.run_script(args[2], unitTarget.id, args[4])
else
dfhack.run_script(args[2], unitTarget.id)
end
 
end
end

feed.lue
Code: [Select]
-- Shows/resets hunger and thirst counters

function run(cmd)
local unit=dfhack.gui.getSelectedUnit()
if unit then
local name = dfhack.units.getVisibleName(unit)
if name and name.has_name then
unitname = dfhack.TranslateName(name)
else
unitname = "unit"
end


if cmd == 'status' then
print("Status for "..unitname..":")
print("Hunger:", unit.counters2.hunger_timer)
elseif cmd == 'reset' then
print("Resetting hunger and thirst counters for "..unitname)
unit.counters2.hunger_timer=0
end
end
end

local cmd = ...
if not cmd then
qerror('Usage: hunger status/reset')
end
run(cmd)

inorganic mat:
Code: [Select]
[INORGANIC:PET_FEEDING]
[USE_MATERIAL_TEMPLATE:STONE_VAPOR_TEMPLATE] => boils away, triggers autosyndrome
[STATE_NAME_ADJ:ALL:Feed a nearby grazer]
[MATERIAL_VALUE:0]
[SYNDROME]
[SYN_CLASS:\COMMAND]
[SYN_CLASS:fovcommand]
[SYN_CLASS:\WORKER_ID]
[SYN_CLASS:feed]
[SYN_AFFECTED_CLASS:PET_HEALING] => only works on pets

Sadly, this results in 5 messages of "No Unit is selected in the UI." in the dfhack window. Anyone got a clue why?

EDIT:If I use
   [SYN_CLASS:\COMMAND]
   [SYN_CLASS:fovcommand]
   [SYN_CLASS:\WORKER_ID]
   [SYN_CLASS:feed]
   [SYN_CLASS:hunger]

then nothing at all happens, not even the error message.
« Last Edit: August 28, 2013, 05:27:28 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 :::

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4467 on: August 28, 2013, 06:05:14 pm »

Because it's using dfhack.gui.getSelectedUnit() instead of using an argument from fovcommand. Here's a simple script for you:

Code: [Select]
local unit = df.global.world.units.all[tonumber(...)] --assuming that fovcommand uses the unit's position in the "all units" list, which it seems to

unit.counters2.hunger_timer=0

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #4468 on: August 28, 2013, 06:38:24 pm »

Thanks, but again, I only get error messages. I think I wait for boltgun to say something, he gave me the fovcommand. ^^

Code: [Select]
...terworkDF v3g\Dwarf Fortress\hack\scripts/feedsimple.lua:1: Cannot read field vector<unit*>.193: index out of bounds.
stack traceback:
        [C]: in function '__index'
        ...terworkDF v3g\Dwarf Fortress\hack\scripts/feedsimple.lua:1: in main chunk
        (...tail calls...)
        ...terworkDF v3g\Dwarf Fortress\hack\scripts/fovcommand.lua:111: in main chunk
        (...tail calls...)
...terworkDF v3g\Dwarf Fortress\hack\scripts/feedsimple.lua:1: Cannot read field vector<unit*>.177: index out of bounds.
stack traceback:
        [C]: in function '__index'
        ...terworkDF v3g\Dwarf Fortress\hack\scripts/feedsimple.lua:1: in main chunk
        (...tail calls...)
        ...terworkDF v3g\Dwarf Fortress\hack\scripts/fovcommand.lua:111: in main chunk
        (...tail calls...)
[DFHack]#
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 :::

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #4469 on: August 28, 2013, 06:42:43 pm »

Those errors mean that there aren't that many units in the loaded area of the world (i'm trying to teach you here meph :P). That means that fovcommand doesn't do what I thought it did and I have no idea how to select units based on ID >_>
Pages: 1 ... 296 297 [298] 299 300 ... 373