Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 184 185 [186] 187 188 ... 360

Author Topic: DFHack 0.43.03-r1  (Read 1113068 times)

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2775 on: June 12, 2015, 03:28:13 pm »

Nope - that change only affects compiling plugins. Essentially, instead of each plugin needing to be recompiled when the DFHack version is changed, a separate static library containing only the DFHack version is compiled and linked to (or embedded in, since it's a static library) the core DFHack library and all plugins.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2776 on: June 13, 2015, 12:57:30 am »

How often is DFHack updated? Like if I update a plugin, would it be more reasonable to provide a download of just the plugin, or hope that a new DFhack release comes out before the plugin is needed?

It usually doesn't update all that often. It's been a while though so maybe we're due.
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2777 on: June 13, 2015, 01:21:03 am »

...Does it just not doing anything with the wound, or am I misunderstanding something?

Yeah, that version just adds the wound to the correct body part and layer depending on the inputs you give it. I was just using it as a proof of concept. The version I am playing with now has options for all of the various numbers (bleeding, pain, nausea, dizziness, paralysis, numbness, swelling, impaired, contact_area, surface_area, and strain) along with options for various flags, and if you want it to be a bruise/burn/frostbite/blister/necrosis. I will upload a full version with all the bells and whistles when I get everything working well. I still have a few more ideas to add to it, like the ability to add wounds that simulate getting a body part chopped off.
Oh god I just realized this is like the basis for making eye lasers of limbsplosion (via eventful trickery or something similar), targeted flesh searing, plus custom scarification, isn't it?
Logged

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2778 on: June 13, 2015, 01:36:59 am »

In that case, I'll try to get as many changes to RemoteFortressReader as I can before then.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2779 on: June 13, 2015, 03:50:47 am »

Oh god I just realized this is like the basis for making eye lasers of limbsplosion (via eventful trickery or something similar), targeted flesh searing, plus custom scarification, isn't it?

Sure. You could even do crazier things like a sword that transfers wounds from the wielder to the target as long as they're the same race.
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2780 on: June 13, 2015, 06:40:13 am »

Oh dear, that's kinda amazing.

In semi-amazing news, I've almost got names.lua fully working:
Spoiler: old ver (click to show/hide)
Still, you can target an artifact and names -item will give it the name shown on the selection screen when it first loads up (hmmm, I need to reverse that so it shows the current name there... ) and hitting it again after playing with the options will apply that name. Adding the -first flag lets you set a first name, names -unit lets you rename units as well.

I'm pretty sure things like renaming sites and forts and such will also be possible with appropriate flags, and later I'm going to damn well clean up the language_words[0] ~[6] crap, just easier to debug it when it is laid out like that.

Ok it's almost there, I gotta walk the dog and then I'm gonna work out what's happening.

Right now if you use "names -item -first Buttscratcher" and pass it those args it will load up the prompt and then rename the displayed first name in the selection screen, running names -item after that will then apply it correctly. :D
Code: (names.lua) [Select]
local dlg=require 'gui.dialogs'
local utils = require 'utils'

validArgs = validArgs or utils.invert({
 'help',
 'item',
 'unit',
 'first'
})

local args = utils.processArgs({...}, validArgs)

if args.help then
 print(
[[names.lua
arguments:
    -help
        print this help message
    -item
if currently targeting an item
    -unit
if currently targeting a unit
    -first
if a first name is desired
]])
 return
end

if not df.viewscreen_layer_choose_language_namest:is_instance(dfhack.gui.getCurViewscreen()) then
choices = df.new(df.viewscreen_setupadventurest) ; choices.subscreen = 3 ; gui = require 'gui' ; gui.simulateInput(choices, 'A_RANDOM_NAME') ; gui.simulateInput(choices, 'A_CUST_NAME')
end

if args.item then
fact = dfhack.gui.getCurViewscreen().parent.item.general_refs[0].artifact_id
trg = df.artifact_record.find(fact)
end

if args.unit then
trg = dfhack.gui.getCurViewscreen().parent.unit
end

if args.first then do
  trg.name.first_name = args.first
end

function newName()
  newn = dfhack.gui.getCurViewscreen().name
oldn = trg.name
  oldn.words[0] = newn.words[0]
  oldn.words[1] = newn.words[1]
  oldn.words[2] = newn.words[2]
  oldn.words[3] = newn.words[3]
  oldn.words[4] = newn.words[4]
  oldn.words[5] = newn.words[5]
  oldn.words[6] = newn.words[6]
  oldn.parts_of_speech[0] = newn.parts_of_speech[0]
  oldn.parts_of_speech[1] = newn.parts_of_speech[1]
  oldn.parts_of_speech[2] = newn.parts_of_speech[2]
  oldn.parts_of_speech[3] = newn.parts_of_speech[3]
  oldn.parts_of_speech[4] = newn.parts_of_speech[4]
  oldn.parts_of_speech[5] = newn.parts_of_speech[5]
  oldn.parts_of_speech[6] = newn.parts_of_speech[6]
  oldn.language = newn.language
  oldn.has_name = newn.has_name
 end
end
newName()

function firstName()
  newn.first_name = args.first
end

dlg.showInputPrompt(
  'Rename Target',
  'Enter a new name for the target:', COLOR_GREEN,
  newn.first_name,
  curry(firstName, first)
)
« Last Edit: June 13, 2015, 07:20:07 pm by Max™ »
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2781 on: June 13, 2015, 07:22:22 pm »

How would I make it do the curry(newName, args.etc) when you select a new entry from the name choosing screen? Isn't that where the function screen:oninput(keys) stuff goes or is there a slicker trick I haven't found?
Logged

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2782 on: June 13, 2015, 07:58:04 pm »

So here is the script to add a wound. It has all the values, flags, and other options I could think of. It works fairly well but there is still a decent amount of work that should be done (and will be done when I have time) to fix certain weird things. For example, you can sever someones right upper arm but they will still have their right lower arm and right hand. These wounds also ignore any type of armor and such. The numbers are all directly what get put into the wound.

Code: [Select]
local utils = require 'utils'

function checkbodycategory(unit,bp)
 local parts = {}
 local body = unit.body.body_plan.body_parts
 for i,x in ipairs(bp) do
  local a = 1
  for j,y in ipairs(body) do
   if y.category == x and not unit.body.components.body_part_status[j].missing then
    parts[a] = j
    a = a + 1
   end
  end
 end
 return parts
end
function checkbodytoken(unit,bp)
 local parts = {}
 local body = unit.body.body_plan.body_parts
 for i,x in ipairs(bp) do
  local a = 1
  for j,y in ipairs(body) do
   if y.token == x and not unit.body.components.body_part_status[j].missing then
    parts[a] = j
    a = a + 1
   end
  end
 end
 return parts
end
function checkbodyflag(unit,bp)
 local parts = {}
 local body = unit.body.body_plan.body_parts
 for i,x in ipairs(bp) do
  local a = 1
  for j,y in ipairs(body) do
   if y.flags[x] and not unit.body.components.body_part_status[j].missing then
    parts[a] = j
    a = a + 1
   end
  end
 end
 return parts
end
function checkbodylayer(unit,parts,layers)
 local a = 1
 local array = {}
 for i,x in pairs(parts) do
  local part = unit.body.body_plan.body_parts[x]
  for j,y in pairs(layers) do
   for k,z in pairs(part.layers) do
    if z.layer_name == y or y == 'ALL' then
array[a] = {x,k,z.layer_id}
a = a+1
end
   end
  end
 end
 return array
end

function addwound(unit,array,numbers,effect,flags,attacker,args)
 local body = unit.body
 local wound = df.unit_wound:new()
 wound.id = body.wound_next_id
 body.wound_next_id = body.wound_next_id + 1
 if attacker and tonumber(attacker) then wound.attacker_unit_id = tonumber(attacker) end
 if args.severed then -- For applying wounds that remove body parts (doesn't produce severed body part)
  wound.flags.severed_part = true
  for i,x in pairs(array) do
   part = df.unit_wound.T_parts:new()
   part.global_layer_idx = x[3]
   part.layer_idx = x[2]
   part.body_part_id = x[1]
   for j,y in pairs(numbers) do
    if y and tonumber(y) then part[j] = tonumber(y) end
   end
   part.contact_area = 1
   part.surface_perc = 0
   part.strain = 0
   part.cur_penetration_perc = 0
   part.max_penetration_perc = 0 
   wound.parts:insert('#',part)
   body.components.body_part_status[x[1]].missing = true
   body.components.body_part_status[x[1]].muscle_damage = true
   body.components.body_part_status[x[1]].muscle_loss = true
   body.components.body_part_status[x[1]].bone_damage = true
   body.components.body_part_status[x[1]].bone_loss = true
   body.components.body_part_status[x[1]].skin_damage = true
   body.components.body_part_status[x[1]].severed_or_jammed = true
   body.components.layer_status[x[3]].gone = true
   body.components.layer_cut_fraction[x[3]] = 10000
   body.components.layer_dent_fraction[x[3]] = 10000
  end
 elseif args.mortal then -- For applying wounds that kill unit (not really useful, mortal wounds are all so different)
  wound.flags.mortal_wound = true
  body.blood_count = 0
 else -- For applying all other types of wounds
  for i,x in pairs(array) do
   part = df.unit_wound.T_parts:new()
   part.global_layer_idx = x[3]
   part.layer_idx = x[2]
   part.body_part_id = x[1]
   for j,y in pairs(numbers) do
    if y and tonumber(y) then part[j] = tonumber(y) end
   end
   if effect then
    part.effect_type:insert('#',tonumber(df.wound_effect_type[effect[1]]))
    part.effect_perc1:insert('#',tonumber(effect[2]))
    part.effect_perc2:insert('#',tonumber(effect[3]))
   end
   if args.surface_perc >= 100 then part.flags2.entire_surface = true end
   for j,y in pairs(flags) do
    part.flags1[y] = true
   end
   wound.parts:insert('#',part)
   if part.strain >= 50000 then
    body.components.layer_dent_fraction[x[3]] = body.components.layer_dent_fraction[x[3]] + part.aurface_perc*part.cur_penetration_perc
body.components.layer_cut_fraction[x[3]] = body.components.layer_cut_fraction[x[3]] + part.aurface_perc*part.cur_penetration_per
   elseif part.strain > 0 then
    body.components.layer_cut_fraction[x[3]] = body.components.layer_cut_fraction[x[3]] + part.aurface_perc*part.cur_penetration_perc
   elseif part.strain == 0 and effect then
    body.components.layer_effect_fraction[x[3]] = body.components.layer_effect_fraction[x[3]] + part.aurface_perc*part.effect_perc1[0]
   end
   if part.strain >= 50000 and part.cur_penetration_per >= 100 then
    body.components.layer_wound_area[x[3]] = body.components.layer_wound_area[x[3]] + part.contact_area
   end
   end
  end
  body.wounds:insert('#',wound)
 end
end

validArgs = validArgs or utils.invert({
 'help',
 'category',
 'token',
 'flag',
 'all',
 'layer',
 'unit',
 'bleeding',
 'pain',
 'nausea',
 'dizziness',
 'paralysis',
 'numbness',
 'swelling',
 'impaired',
 'strain',
 'contact_area',
 'surface_perc',
 'penetration',
 'effect',
 'attacker',
 'flags',
 'mortal',
 'severed',
 'infection',
})
local args = utils.processArgs({...}, validArgs)

if args.help then -- Help declaration
 print([[wound-add.lua
  Assign a wound to a specific body part and layer of a unit
  arguments:
   -help
     print this help message
   -unit id
     REQUIRED
     id of the target unit
   -attacker id
   -all                       \
     target all body parts    |
   -category TYPE             |
     examples:                |
      TENTACLE                |
      HOOF_REAR               |
      HEAD                    |
   -token TYPE                | Must have at least one of these
     examples:                |
      UB                      |
      LB                      |
      REYE                    |
   -flag FLAG                 |
     examples:                |
      SIGHT                   |
      LIMB                    |
      SMALL                   /
   -layer TYPE
     examples:
      SKIN
  FAT
  MUSCLE
  ALL
   -bleeding #
    set bleeding amount for all layers
   -pain #
    set pain amount for all layers
   -nausea #
    set nausea amount for all layers
   -dizziness #
    set dizziness amount for all layers
   -paralysis #
    set paralysis amount for all layers
   -numbness #
    set numbness amount for all layers
   -swelling #
    set swelling amount for all layers
   -impaired #
    set impaired amount for all layers
   -strain #
    set strain level for all layers
   -contact_area #
    set contact area of wound for all layers
   -surface_perc #
    set surface area affected percentage for all layers
   -penetration #
    set penetration depth percentage for all layers
   -effect [ type # # ]
    set what type of wound it is, numbers are percentages, unknown their exact affect
valid types
Bruise
Burn
Frostbite
Melting
Boiling
Freezing
Condensation
Necrosis
Blister
   -flags [ flags ]
    set which flags are toggled for the wound
valid flags
cut
smashed
scar_cut
scar_smashed
tendon_bruised
tendon_strained
tendon_torn
ligament_bruised
ligament_sprained
ligament_torn
motor_nerve_severed
sensory_nerve_severed
edged_damage
smashed_apart
major_artery
guts_spilled
edged_shake1
scar_edged_shake1
edged_shake2
broken
scar_broken
gouged
blunt_shake1
scar_blunt_shake1
blunt_shake2
joint_bend1
scar_joint_bend1
joint_bend2
compound_fracture
overlapping_fracture
artery
   -mortal
    sets the wound as a mortal wound (kills the unit by lack of blood)
   -severed
    sets the body part as severed and removes it (severed body part is not created)
  examples:
   unit/wound-add -unit \\UNIT_ID -all -layer SKIN -pain 20 -surface_perc 100 -effect [ Burn 100 100 ]
   unit/wound-add -unit \\UNIT_ID -token UB -layer ALL -bleeding 10 -penetration 100 -contact_area 25 -surface_perc 30 -flags [ cut edged_damage ]
 ]])
 return
end

if args.unit and tonumber(args.unit) then -- Check for unit declaration !REQUIRED
 unit = df.unit.find(tonumber(args.unit))
else
 print('No unit selected')
 return
end

dur = tonumber(args.dur) or 0 -- Check if there is a duration (default 0)

parts = {}
recall = ''
tokens = args.all or args.category or args.token or args.flag
layers = args.layer or ''
if type(layers) == 'string' then layers = {layers} end
if type(tokens) == 'string' then tokens = {tokens} end
if args.all then -- Check for the all body parts flag. !!RUN EFFECT!!
 body = unit.body.body_plan.body_parts
 for k,v in ipairs(body) do
  parts[k] = k
 end
 recall = 'all'
elseif args.category then -- Check for category body parts. !!RUN CHECKBODYCATEGORY!!. !!RUN EFFECT!!
 parts = checkbodycategory(unit,tokens)
 recall = 'category'
elseif args.token then -- Check for token body parts. !!RUN CHECKBODYTOKEN!!. !!RUN EFFECT!!
 parts = checkbodytoken(unit,tokens)
 recall = 'token'
elseif args.flag then -- Check for flag body parts. !!RUN CHECKBODYFLAG!!. !!RUN EFFECT!!
 parts = checkbodyflag(unit,tokens)
 recall = 'flag'
end

local numbers = {}
numbers.bleeding = args.bleeding
numbers.pain = args.pain
numbers.nausea = args.nausea
numbers.dizziness = args.dizziness
numbers.paralysis = args.paralysis
numbers.numbness = args.numbness
numbers.swelling = args.swelling
numbers.impaired = args.impaired
numbers.strain = args.strain
numbers.contact_area = args.contact_area
numbers.surface_perc = args.surface_perc
numbers.cur_penetration_perc = args.penetration
numbers.max_penetration_perc = args.penetration

if args.severed then layers = {'ALL'} end
parts_and_layers = checkbodylayer(unit,parts,layers)

if #parts_and_layers >= 1 then
 addwound(unit,parts_and_layers,numbers,args.effect,args.flags,args.attacker,args)
end

An option would be to create a higher level script and add Urist Da Vinci's work (http://www.bay12forums.com/smf/index.php?topic=142372.0) into it and then call the above script to add wounds. You could then say something like
Code: [Select]
attack -defender id -attacker -id -target RUA -weapon EQUIPPEDAnd the correct numbers for the wound would get calculated and applied to the defender.
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2783 on: June 13, 2015, 08:03:29 pm »

Is there a way to make it check for the linked parts? Through the connects links or something?
Logged

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2784 on: June 13, 2015, 08:24:31 pm »

Yeah, the check for connected body parts shouldn't be too hard. Just ran out of time today.
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2785 on: June 13, 2015, 08:39:21 pm »

Oh I feel ya, I got stuck on the names thing for a while until I bumped into the little prompt trick posted in the gladiator challenge thread.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2786 on: June 13, 2015, 08:42:34 pm »

Very cool!
Logged

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2787 on: June 13, 2015, 09:04:45 pm »

I actually did have a chance to fix the severed issue. This will now properly sever everything connected to a severed body part.

Code: [Select]
local utils = require 'utils'

function checkconnectedparts(unit,parts)
 for i,x in pairs(parts) do
  for j,y in pairs(unit.body.body_plan.body_parts) do
   if y.con_part_id == x then
    table.insert(parts,j)
   end
  end
 end
 return parts
end
function checkbodycategory(unit,bp)
 local parts = {}
 local body = unit.body.body_plan.body_parts
 for i,x in ipairs(bp) do
  local a = 1
  for j,y in ipairs(body) do
   if y.category == x and not unit.body.components.body_part_status[j].missing then
    parts[a] = j
    a = a + 1
   end
  end
 end
 return parts
end
function checkbodytoken(unit,bp)
 local parts = {}
 local body = unit.body.body_plan.body_parts
 for i,x in ipairs(bp) do
  local a = 1
  for j,y in ipairs(body) do
   if y.token == x and not unit.body.components.body_part_status[j].missing then
    parts[a] = j
    a = a + 1
   end
  end
 end
 return parts
end
function checkbodyflag(unit,bp)
 local parts = {}
 local body = unit.body.body_plan.body_parts
 for i,x in ipairs(bp) do
  local a = 1
  for j,y in ipairs(body) do
   if y.flags[x] and not unit.body.components.body_part_status[j].missing then
    parts[a] = j
    a = a + 1
   end
  end
 end
 return parts
end
function checkbodylayer(unit,parts,layers)
 local a = 1
 local array = {}
 for i,x in pairs(parts) do
  local part = unit.body.body_plan.body_parts[x]
  for j,y in pairs(layers) do
   for k,z in pairs(part.layers) do
    if z.layer_name == y or y == 'ALL' then
array[a] = {x,k,z.layer_id}
a = a+1
end
   end
  end
 end
 return array
end

function addwound(unit,array,numbers,effect,flags,attacker,args)
 local body = unit.body
 local wound = df.unit_wound:new()
 wound.id = body.wound_next_id
 body.wound_next_id = body.wound_next_id + 1
 if attacker and tonumber(attacker) then wound.attacker_unit_id = tonumber(attacker) end
 if args.severed then -- For applying wounds that remove body parts (doesn't produce severed body part)
  wound.flags.severed_part = true
  for i,x in pairs(array) do
   part = df.unit_wound.T_parts:new()
   part.global_layer_idx = x[3]
   part.layer_idx = x[2]
   part.body_part_id = x[1]
   for j,y in pairs(numbers) do
    if y and tonumber(y) then part[j] = tonumber(y) end
   end
   part.contact_area = 1
   part.surface_perc = 0
   part.strain = 0
   part.cur_penetration_perc = 0
   part.max_penetration_perc = 0 
   wound.parts:insert('#',part)
   body.components.body_part_status[x[1]].missing = true
   body.components.body_part_status[x[1]].muscle_damage = true
   body.components.body_part_status[x[1]].muscle_loss = true
   body.components.body_part_status[x[1]].bone_damage = true
   body.components.body_part_status[x[1]].bone_loss = true
   body.components.body_part_status[x[1]].skin_damage = true
   body.components.body_part_status[x[1]].severed_or_jammed = true
   body.components.layer_status[x[3]].gone = true
   body.components.layer_cut_fraction[x[3]] = 10000
   body.components.layer_dent_fraction[x[3]] = 10000
  end
 elseif args.mortal then -- For applying wounds that kill unit (not really useful, mortal wounds are all so different)
  wound.flags.mortal_wound = true
  body.blood_count = 0
 else -- For applying all other types of wounds
  for i,x in pairs(array) do
   part = df.unit_wound.T_parts:new()
   part.global_layer_idx = x[3]
   part.layer_idx = x[2]
   part.body_part_id = x[1]
   for j,y in pairs(numbers) do
    if y and tonumber(y) then part[j] = tonumber(y) end
   end
   if effect then
    part.effect_type:insert('#',tonumber(df.wound_effect_type[effect[1]]))
    part.effect_perc1:insert('#',tonumber(effect[2]))
    part.effect_perc2:insert('#',tonumber(effect[3]))
   end
   if args.surface_perc >= 100 then part.flags2.entire_surface = true end
   for j,y in pairs(flags) do
    part.flags1[y] = true
   end
   wound.parts:insert('#',part)
   if part.strain >= 50000 then
    body.components.layer_dent_fraction[x[3]] = body.components.layer_dent_fraction[x[3]] + part.aurface_perc*part.cur_penetration_perc
body.components.layer_cut_fraction[x[3]] = body.components.layer_cut_fraction[x[3]] + part.aurface_perc*part.cur_penetration_per
   elseif part.strain > 0 then
    body.components.layer_cut_fraction[x[3]] = body.components.layer_cut_fraction[x[3]] + part.aurface_perc*part.cur_penetration_perc
   elseif part.strain == 0 and effect then
    body.components.layer_effect_fraction[x[3]] = body.components.layer_effect_fraction[x[3]] + part.aurface_perc*part.effect_perc1[0]
   end
   if part.strain >= 50000 and part.cur_penetration_per >= 100 then
    body.components.layer_wound_area[x[3]] = body.components.layer_wound_area[x[3]] + part.contact_area
   end
  end
  body.wounds:insert('#',wound)
 end
end

validArgs = validArgs or utils.invert({
 'help',
 'category',
 'token',
 'flag',
 'all',
 'layer',
 'unit',
 'bleeding',
 'pain',
 'nausea',
 'dizziness',
 'paralysis',
 'numbness',
 'swelling',
 'impaired',
 'strain',
 'contact_area',
 'surface_perc',
 'penetration',
 'effect',
 'attacker',
 'flags',
 'mortal',
 'severed',
 'infection',
})
local args = utils.processArgs({...}, validArgs)

if args.help then -- Help declaration
 print([[wound-add.lua
  Assign a wound to a specific body part and layer of a unit
  arguments:
   -help
     print this help message
   -unit id
     REQUIRED
     id of the target unit
   -attacker id
   -all                       \
     target all body parts    |
   -category TYPE             |
     examples:                |
      TENTACLE                |
      HOOF_REAR               |
      HEAD                    |
   -token TYPE                | Must have at least one of these
     examples:                |
      UB                      |
      LB                      |
      REYE                    |
   -flag FLAG                 |
     examples:                |
      SIGHT                   |
      LIMB                    |
      SMALL                   /
   -layer TYPE
     examples:
      SKIN
  FAT
  MUSCLE
  ALL
   -bleeding #
    set bleeding amount for all layers
   -pain #
    set pain amount for all layers
   -nausea #
    set nausea amount for all layers
   -dizziness #
    set dizziness amount for all layers
   -paralysis #
    set paralysis amount for all layers
   -numbness #
    set numbness amount for all layers
   -swelling #
    set swelling amount for all layers
   -impaired #
    set impaired amount for all layers
   -strain #
    set strain level for all layers
   -contact_area #
    set contact area of wound for all layers
   -surface_perc #
    set surface area affected percentage for all layers
   -penetration #
    set penetration depth percentage for all layers
   -effect [ type # # ]
    set what type of wound it is, numbers are percentages, unknown their exact affect
valid types
Bruise
Burn
Frostbite
Melting
Boiling
Freezing
Condensation
Necrosis
Blister
   -flags [ flags ]
    set which flags are toggled for the wound
valid flags
cut
smashed
scar_cut
scar_smashed
tendon_bruised
tendon_strained
tendon_torn
ligament_bruised
ligament_sprained
ligament_torn
motor_nerve_severed
sensory_nerve_severed
edged_damage
smashed_apart
major_artery
guts_spilled
edged_shake1
scar_edged_shake1
edged_shake2
broken
scar_broken
gouged
blunt_shake1
scar_blunt_shake1
blunt_shake2
joint_bend1
scar_joint_bend1
joint_bend2
compound_fracture
overlapping_fracture
artery
   -mortal
    sets the wound as a mortal wound (kills the unit by lack of blood)
   -severed
    sets the body part as severed and removes it (severed body part is not created)
  examples:
   unit/wound-add -unit \\UNIT_ID -all -layer SKIN -pain 20 -surface_perc 100 -effect [ Burn 100 100 ]
   unit/wound-add -unit \\UNIT_ID -token UB -layer ALL -bleeding 10 -penetration 100 -contact_area 25 -surface_perc 30 -flags [ cut edged_damage ]
 ]])
 return
end

if args.unit and tonumber(args.unit) then -- Check for unit declaration !REQUIRED
 unit = df.unit.find(tonumber(args.unit))
else
 print('No unit selected')
 return
end

dur = tonumber(args.dur) or 0 -- Check if there is a duration (default 0)

parts = {}
recall = ''
tokens = args.all or args.category or args.token or args.flag
layers = args.layer or ''
if type(layers) == 'string' then layers = {layers} end
if type(tokens) == 'string' then tokens = {tokens} end
if args.all then -- Check for the all body parts flag. !!RUN EFFECT!!
 body = unit.body.body_plan.body_parts
 for k,v in ipairs(body) do
  parts[k] = k
 end
 recall = 'all'
elseif args.category then -- Check for category body parts. !!RUN CHECKBODYCATEGORY!!. !!RUN EFFECT!!
 parts = checkbodycategory(unit,tokens)
 recall = 'category'
elseif args.token then -- Check for token body parts. !!RUN CHECKBODYTOKEN!!. !!RUN EFFECT!!
 parts = checkbodytoken(unit,tokens)
 recall = 'token'
elseif args.flag then -- Check for flag body parts. !!RUN CHECKBODYFLAG!!. !!RUN EFFECT!!
 parts = checkbodyflag(unit,tokens)
 recall = 'flag'
end

local numbers = {}
numbers.bleeding = args.bleeding
numbers.pain = args.pain
numbers.nausea = args.nausea
numbers.dizziness = args.dizziness
numbers.paralysis = args.paralysis
numbers.numbness = args.numbness
numbers.swelling = args.swelling
numbers.impaired = args.impaired
numbers.strain = args.strain
numbers.contact_area = args.contact_area
numbers.surface_perc = args.surface_perc
numbers.cur_penetration_perc = args.penetration
numbers.max_penetration_perc = args.penetration

if args.severed then parts = checkconnectedparts(unit,parts) end
if args.severed then layers = {'ALL'} end
parts_and_layers = checkbodylayer(unit,parts,layers)

if #parts_and_layers >= 1 then
 addwound(unit,parts_and_layers,numbers,args.effect,args.flags,args.attacker,args)
end
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2788 on: June 13, 2015, 09:40:21 pm »

Nice, I got names working well enough to put it up, I still have to learn a bit more about the input events I think as right now you have to run it again with the screen open to finalize the changes.

Did artifake -item WEAPON:ITEM_WEAPON_AXE_BATTLE -material ADAMANTINE twice, once for me, once for a dorflet:
Spoiler (click to show/hide)
Pulled up said dorflet I'm rescuing, did names -first Bob:
Spoiler (click to show/hide)
Selected the axe I spawned under him, did names -item -first "Bob's axe":
Spoiler (click to show/hide)
Selected my axe, did names -item -first "My axe":
Spoiler (click to show/hide)
Selected a war hammer I had made earlier, did names -first, changed the name and ran names -item -first before closing the name choice screen:
Spoiler (click to show/hide)
Aight, it works now and by hitting random a few times it gives access to all the languages. https://github.com/maxthyme/dfstuff/blob/master/names.lua

I knew I was missing something with artifake and I just found it!
Code: (artifake.lua) [Select]
local utils = require 'utils'

validArgs = validArgs or utils.invert({
 'help',
 'material',
 'item',
 'name',
 'r',
 'l'
})

local args = utils.processArgs({...}, validArgs)

if args.help then
 print(
[[artifake.lua
arguments:
    -help
        print this help message
    -material matstring
        specify the material of the item to be created
        examples:
            INORGANIC:IRON
            CREATURE_MAT:DWARF:BRAIN
            PLANT_MAT:MUSHROOM_HELMET_PLUMP:DRINK
    -item itemstring
        specify the itemdef of the item to be created
        examples:
            WEAPON:ITEM_WEAPON_PICK
    -name namestring
    specify a first name if desired
    -r
for right handed gloves
    -l
for left handed gloves
]])
 return
end

if dfhack.gui.getSelectedUnit(true) then
 args.creator = dfhack.gui.getSelectedUnit()
 else args.creator = df.global.world.units.active[0]
end
if not args.item then
 error 'Invalid item.'
end
local itemType = dfhack.items.findType(args.item)
if itemType == -1 then
 error 'Invalid item.'
end
local itemSubtype = dfhack.items.findSubtype(args.item)

args.material = dfhack.matinfo.find(args.material)
if not args.material then
 error 'Invalid material.'
end


local item = dfhack.items.createItem(itemType, itemSubtype, args.material['type'], args.material.index, args.creator)

 local base=df.item.find(df.global.item_next_id-1)
 df.global.world.artifacts.all:new()
 df.global.world.artifacts.all:insert('#',{new=df.artifact_record})
local facts = df.global.world.artifacts.all
 for _,k in ipairs(facts) do
  if k.id==0 then
   local fake=k
   fake.id=df.global.artifact_next_id
   fake.item = {new=base}
fake.item.flags.artifact = true
fake.item.flags.artifact_mood = true
fake.item.id = base.id
fake.item.general_refs:insert('#',{new =  df.general_ref_is_artifactst})
fake.item.general_refs[0].artifact_id = fake.id
fake.item.spec_heat = base.spec_heat
fake.item.ignite_point = base.ignite_point
fake.item.heatdam_point = base.heatdam_point
fake.item.colddam_point = base.colddam_point
fake.item.boiling_point = base.boiling_point
fake.item.fixed_temp = base.fixed_temp
fake.item.weight = base.weight
fake.item.weight_fraction = base.weight_fraction
fake.item.improvements:insert('#',{new = df.itemimprovement_spikesst,mat_type=25,mat_index=474,quality=0,skill_rating=15})
fake.item.improvements:insert('#',{new = df.itemimprovement_spikesst,mat_type=25,mat_index=493,quality=0,skill_rating=15})
fake.item.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=22,mat_index=474,quality=5,skill_rating=15})
fake.item.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=42,mat_index=480,quality=5,skill_rating=15})
fake.item.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=22,mat_index=497,quality=5,skill_rating=15})
   fake.anon_1 = -1000000
   fake.anon_2 = -1000000
   fake.anon_3 = -1000000
     base.flags.artifact = true
     base.flags.artifact_mood = true
     base.general_refs = fake.item.general_refs
     base.improvements = fake.item.improvements
     fake.item:setQuality(5)
     base:setQuality(5)
     if fake.item == 'WEAPON' then item:setSharpness(1,0) end
     if base == 'WEAPON' then item:setSharpness(1,0) end
     df.global.artifact_next_id=df.global.artifact_next_id+1
 df.global.world.history.events:new()
 df.global.world.history.events:insert('#',{new=df.history_event_artifact_createdst,
year = df.global.cur_year,
seconds = df.global.cur_year_tick_advmode,
id = df.global.hist_event_next_id,
artifact_id = fake.id,
unit_id = args.creator.id,
hfid = args.creator.hist_figure_id,
}
)
   df.global.hist_event_next_id = df.global.hist_event_next_id+1
if args.r then
base.handedness[0] = true
fake.item.handedness[0] = true
end
if args.l then
base.handedness[1] = true
fake.item.handedness[1] = true
end
 if args.name then do
  fake.name.first_name = args.name
  fake.name.language = 0
  fake.name.has_name = true
         end
      end
   end
end
I remembered I never put in the -r and -l args for gauntlet handedness as well as fixing them so they properly show up in legends mode:
Spoiler (click to show/hide)
Ok, unless I find a new trick to get names to activate on exit it looks like it's easiest to just call it to get the screen and call it again to set the current name to your target, works for me, unless anyone knows a better way to have it like apply the function on exiting the df.viewscreen_layer_name_choosest screen?
« Last Edit: June 14, 2015, 08:58:07 am by Max™ »
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #2789 on: June 14, 2015, 09:25:38 am »

O.o

I just realized you could make a flaming weapon which can add burns and burning type wounds to targeted areas with some hackery, but I can't remember if the on_fire tag is under wounds or not...
Logged
Pages: 1 ... 184 185 [186] 187 188 ... 360