Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 241 242 [243] 244 245 ... 373

Author Topic: DFHack 0.34.11 r3  (Read 1399861 times)

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3630 on: April 22, 2013, 10:28:13 pm »

you might need to change the were caste or the caste in the status section of the unit.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3631 on: April 22, 2013, 10:52:34 pm »

The status section?  You mean in the current soul, or is there a caste field elsewhere in the status section?  I'll check that again.  Where is the were caste stored?  I poked through the syndrome and curse structures using the Lua interface but didn't find anything obvious.
Logged
Through pain, I find wisdom.

drayath

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3632 on: April 23, 2013, 07:21:13 am »

Is there any way to show what syndromes are affected one/all dwarves?
Logged
Drayath's Gem Splitting Workshop - Split large gems and gem trinkets into numbers of small gems.
Drayath's Seed Brewery - Convert bags of spare seeds into useful booze.

drayath

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3633 on: April 23, 2013, 11:19:42 am »

I was bored so to answer my own question here is a script to show units affected by syndromes.

It assumes the syndrome has a sensible (any!) name to show which is not necessarly the case. If anyone is also feeling bored you could modify the script to also print out the details of each syndrome.

nb: This is my first ruby script and first usage of dfhack, so apologies in advance for the low quality.

Code: [Select]
# Show syndromes affecting units and the remaining and maximum duration. Call with help on the command line for further options.

print_syndromes = lambda { |unit, showrace, showall| 

if !unit.syndromes.active.empty? or showall
if showrace
puts "#{df.world.raws.creatures.all[unit.race].name[0]}#{unit.name == '' ? "" : ": "}#{unit.name}"
else
puts "#{unit.name}"
end
end

unit.syndromes.active.each { |s|
syndrome = df.world.raws.syndromes.all[s.type]
duration = syndrome.ce.minmax_by{ |ce| ce.end }

if duration[0].end == -1
durationStr = "Permanent"
else
if duration[0].end == duration[1].end
durationStr = "#{s.ticks} of #{duration[0].end}"
else
durationStr = "#{s.ticks} of #{duration[0].end}-#{duration[1].end}"
end
end

puts " - #{syndrome.syn_name} [#{durationStr}]"
}
}

showall = false
dwarves = false
livestock = false
wildanimals = false
hostile = false

if $script_args.any?{ |arg| arg == "help" or arg == "?" or arg == "-?" }
puts "Use one or more of the following options:"
puts "    showall: Show units even if not affected by any syndrome"
puts "    dwarves: Show dwarves"
puts "    livestock: Show livestock"
puts "    wildanimals: Show wild animals"
puts "    hostile: Show hostiles (e.g. invaders, thieves, forgeten beasts etc)"
puts ""
puts "Will show all syndromes affecting each units with the maximum and present duration."
elsif $script_args.empty?
dwarves = true
else
if $script_args.any?{ |arg| arg == "showall" } then showall=true end
if $script_args.any?{ |arg| arg == "dwarves" } then dwarves=true end
if $script_args.any?{ |arg| arg == "livestock" } then livestock=true end
if $script_args.any?{ |arg| arg == "wildanimals" } then wildanimals=true end
if $script_args.any?{ |arg| arg == "hostile" } then hostile=true end
end

if dwarves
puts "Dwarves"
df.unit_citizens.each { |unit|
print_syndromes[unit, false, showall]
}
puts "\n"
end

if livestock
puts "LiveStock"
df.world.units.active.find_all { |u| df.unit_category(u) == :Livestock }.each { |unit|
print_syndromes[unit, true, showall]
}
puts "\n"
end

if wildanimals
df.world.units.active.find_all { |u| df.unit_category(u) == :Other and  df.unit_other_category(u) == :Wild }.each { |unit|
print_syndromes[unit, true, showall]
}
puts "\n"
end

if hostile
puts "Hostile"
df.unit_hostiles.each { |unit|
print_syndromes[unit, true, showall]
}
puts "\n"
end

#puts "All Syndromes"
#df.world.raws.syndromes.all.each { |syndrome|
# puts "#{syndrome.syn_name}"
#}
usage: save into the dfhack folder as "scripts\showunitsyndromes.rb". Can then enter showunitsyndromes on the dfhack console to run it.
Logged
Drayath's Gem Splitting Workshop - Split large gems and gem trinkets into numbers of small gems.
Drayath's Seed Brewery - Convert bags of spare seeds into useful booze.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #3634 on: April 23, 2013, 11:33:01 am »

Thats neat. :)

It would be awesome if people could see this ingame directly, maybe in the units description somehow. I know I suggested this before at some place, but I still think its a good idea. ;)
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 :::

drayath

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3635 on: April 23, 2013, 12:42:36 pm »

If you ignore my (admittable unresearched) abject horror at writeing code that touchs the df ui, the major issue i see is that the names or all of the vanilla syndomes are not very descriptive (e.g. usally <creaturetype> sickness).

Would need to show the list of actal effects which i doubt there would be room to add to the existing unit screen.

Alternatives would be to add a new effects status screen to show all the details, or use the actual effects of the syndrome to programatically make up a name (e.g. if reduces strength calll it Weakening sickness) may be hard to do syndromes with multiple effects.

I playing arround with printing out effects in a human readable manner at the moment so we will see how it goes.

On that note does anyone know precisly how PEAK modifies things, e.g. if  +1000 strength, start 0, end 1000, peak 250. How much actual strength is added at 0, 250, 500, 1000 duration?
Can't check the unit stats to determine this as it look as though the unit aways stores just the base stats, and adds in syndrome effects every time a stat test is made (why stat bonuses show in the unit screen description, but the numberse dont change in dwarf therepist)
« Last Edit: April 23, 2013, 12:50:05 pm by drayath »
Logged
Drayath's Gem Splitting Workshop - Split large gems and gem trinkets into numbers of small gems.
Drayath's Seed Brewery - Convert bags of spare seeds into useful booze.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #3636 on: April 23, 2013, 01:57:11 pm »

ACtual effects dont matter, names are enough.. to quote myself from another thread:
Quote
the name does not have to be "poison", modders could simply rename it to "Desert Scorpion Sting; Very poisonous, affects lungs and heart, can cause paralysis. Resistable, Size dilutes."

Same trick I use for the rune coatings. I just called the materials "blablabla bonus given by the intricate runes coating", done.

Even all vanilla syndromes (at least those in creatures) can be given a more descriptive name, if so desired.

So yeah, I posted that as a Dwarf Therapist Suggestion, and its possible there as well. :)
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 :::

drayath

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3637 on: April 23, 2013, 06:43:10 pm »

Well its not ui intergration, but now
 - Shows all active effects assoiciated with a syndrome (incuding basic detailes of added interactions)
 - allows export to file
 - allows viewing all syndromes and their effects in your world (you see the odd amuzing FB syndrome). Note information about how these apply, application chance etc is not included.


Code: [Select]
# Show syndromes affecting units and the remaining and maximum duration (v2). Call with help on the command line for further options.

#TODO: When showing effects on a unit, show the actual change to the unit
#       E.g. if +150%, +500 strength show actual total bonus baed on the unit stats.
#TODO: for this also need to know
# how does size_delays affect the start/peak/end time
# how does size_diluts affect the Severity, does it also affect the phy/mental stat adjustments?
# how does peak affect the Severity, does it also affect the phy/mental stat adjustments?
#TODO: Add interaction infor needs to dispal a bit more data, but the required structures are not yet decoded

#TODO: Several of the unk_xxx fields have been identifed here, and can get some more by comparing the raws with the printed interaction and effect information


def print_help()
puts "Use one or more of the following options:"
puts "    showall: Show units even if not affected by any syndrome"
puts "    showeffects: shows detailed effects of each syndrome"
puts "    dwarves: Show dwarves"
puts "    livestock: Show livestock"
puts "    wildanimals: Show wild animals"
puts "    hostile: Show hostiles (e.g. invaders, thieves, forgeten beasts etc)"
puts "    world: Show all defined syndromes in the world"
puts "    export:<filename> Write the output to a file instead of the console."
puts ""
puts "Will show all syndromes affecting each units with the maximum and present duration."
end

class MyLogger
attr_accessor :fileLogger
 
def initialize(filename)
if filename==nil
@fileLogger = nil
else
@fileLogger = File.new(filename, "w")
end
end  

def close()
if @fileLogger != nil
@fileLogger.flush
@fileLogger.close
@fileLogger = nil
end
end

def log(text)
if @fileLogger == nil
puts(text)
else
@fileLogger.puts(text)
end
end
end

def get_mental_att(att_index)

# TODO: Surly i can use the names from MentalAttributeType somehow!!!!!
# case att_index
        # when "ANALYTICAL_ABILITY"
# return "Analytical Ability"
        # when "FOCUS"
# return "Focus"
# when "WILLPOWER"
# return "Willpower"
# when "CREATIVITY"
# return "Creativity"
# when "INTUITION"
# return "Intuition"
# when "PATIENCE"
# return "Patience"
# when "MEMORY"
# return "Memory"
# when "LINGUISTIC_ABILITY"
# return "Linguistics"
# when "SPATIAL_SENSE"
# return "Spacial Sense"
# when "MUSICALITY"
# return "Musicality"
# when "KINESTHETIC_SENSE"
# return "Kinestetic Sense"
# when "EMPATHY"
# return "Empathy"
# when "SOCIAL_AWARENESS"
# return "Social Awareness"
# end

case att_index
        when 0
return "Analytical Ability"
        when 1
return "Focus"
when 2
return "Willpower"
when 3
return "Creativity"
when 4
return "Intuition"
when 5
return "Patience"
when 6
return "Memory"
when 7
return "Linguistics"
when 8
return "Spacial Sense"
when 9
return "Musicality"
when 10
return "Kinestetic Sense"
when 11
return "Empathy"
when 12
return "Social Awareness"
else
return "Unknown"
end
end

def get_physical_att(att_index)

# TODO: Surly i can use the names from PhysicalAttributeType somehow!!!!!
# case att
        # when "STRENGTH"
# return "Strength"
# when "AGILITY"
# return "Agility"
# when "TOUGHNESS"
# return "Toughness"
# when "ENDURANCE"
# return "Endurance"
# when "RECUPERATION"
# return "Recuperation"
# when "DISEASE_RESISTANCE"
# return "Disease Resistance"
# end

case att_index
        when 0
return "Strength"
when 1
return "Agility"
when 2
return "Toughness"
when 3
return "Endurance"
when 4
return "Recuperation"
when 5
return "Disease Resistance"
else
return "Unknown"
end
end

def get_effect_target(target)

values = []

limit = target.key.length - 1
for i in (0..limit)

if(target.mode[i].to_s() != "")

case target.mode[i].to_s()
when "BY_TYPE"
item = "Type("
when "BY_TOKEN"
item = "Token("
when "BY_CATEGORY"
item = "Category("
end

if(target.key[i].to_s()!="")
item = item + target.key[i].to_s()
end

if(target.key[i].to_s()!="" and target.tissue[i].to_s()!="")
item = item + ":"
end

if(target.tissue[i].to_s()!="")
item = item + target.tissue[i].to_s()
end

item = item + ")"

values.push(item)
end

end

if values.length == 0
return ""
else
return " Target=" + values.join(", ")
end
end

def get_att_pairs(values, percents, physical)

items = []

limit = values.length - 1
for i in (0..limit)
if (values[i]!=0 or percents[i]!=100)

if physical
item = "#{get_physical_att(i)}("
else
item = "#{get_mental_att(i)}("
end

if(values[i]!=0)
item = item + "%+d" % values[i]
end

if (values[i]!=0 and percents[i]!=100)
item = item + ", "
end

if (percents[i]!=100)
item = item + "%+d" % percents[i] + "%"
end

item = item + ")"

items.push(item)
end
end

return items.join(", ") 
end

def get_interaction(interaction)

# name, USAGE_HINT, range, wait period are probally all we really want to show.

#result = "a=#{interaction.unk_6c} b=#{interaction.unk_7c} c=#{interaction.unk_8c} d=#{interaction.unk_a8} e=#{interaction.unk_c4} f=#{interaction.unk_e4} "
#result = result + "g=#{interaction.unk_e0} h=#{interaction.unk_e4} i=#{interaction.unk_100} j=#{interaction.unk_11c} k=#{interaction.unk_138} l=#{interaction.unk_154} "
#result = result + "m=#{interaction.unk_170} n=#{interaction.unk_18c} o=#{interaction.unk_1a8} p=#{interaction.unk_1c4} q=#{interaction.unk_1e8} r=#{interaction.unk_25c} "
#result = result + "s=#{interaction.unk_278}"

return "Ability=#{interaction.unk_25c}, Delay=#{interaction.unk_278}"
end

def get_effect_flags(flags)

values = []

if(flags.SIZE_DELAYS) then values.push("Size Delays") end
if(flags.SIZE_DILUTES) then values.push("Size Dilutes") end
if(flags.VASCULAR_ONLY) then values.push("Vascular Only") end
if(flags.MUSCULAR_ONLY) then values.push("Musles Only") end
if(flags.RESISTABLE) then values.push("Resistable") end
if(flags.LOCALIZED) then values.push("Localized") end

return values.join(",")
end

def get_tag1_flags(flags)
   
values = []

        if(flags.EXTRAVISION) then values.push("Extravision") end
        if(flags.OPPOSED_TO_LIFE) then values.push("Attack the living") end
        if(flags.NOT_LIVING) then values.push("Undead") end
        if(flags.NOEXERT) then values.push("Does not tire") end
        if(flags.NOPAIN) then values.push("Does not feel pain") end
        if(flags.NOBREATHE) then values.push("Does not breathe") end
        if(flags.HAS_BLOOD) then values.push("Has blood") end
        if(flags.NOSTUN) then values.push("Can't be stunned") end
        if(flags.NONAUSEA) then values.push("Does not get nausea") end
        if(flags.NO_DIZZINESS) then values.push("Does not get dizzy") end
        if(flags.NO_FEVERS) then values.push("Does not get fever") end
        if(flags.TRANCES) then values.push("Can enter trance") end
        if(flags.NOEMOTION) then values.push("Feels no emotion") end
        if(flags.LIKES_FIGHTING) then values.push("Like fighting") end
        if(flags.PARALYZEIMMUNE) then values.push("Can't be paralazed") end
        if(flags.NOFEAR) then values.push("Does not feel fear") end
        if(flags.NO_EAT) then values.push("Does not eat") end
        if(flags.NO_DRINK) then values.push("Does not drink") end
        if(flags.NO_SLEEP) then values.push("Does not sleep") end
        if(flags.MISCHIEVOUS) then values.push("Mischievous") end
        if(flags.NO_PHYS_ATT_GAIN) then values.push("Physical stats cant improve") end
        if(flags.NO_PHYS_ATT_RUST) then values.push("Physical stats do not rust") end
        if(flags.NOTHOUGHT) then values.push("Stupid") end
        if(flags.NO_THOUGHT_CENTER_FOR_MOVEMENT) then values.push("No brain needed to move") end
        if(flags.CAN_SPEAK) then values.push("Can speak") end
        if(flags.CAN_LEARN) then values.push("Can learn") end
        if(flags.UTTERANCES) then values.push("Utterances") end
        if(flags.CRAZED) then values.push("Crazed") end
        if(flags.BLOODSUCKER) then values.push("Drinks Blood") end
        if(flags.NO_CONNECTIONS_FOR_MOVEMENT) then values.push("Can move without nerves") end
        if(flags.SUPERNATURAL) then values.push("Supernatural") end
return values.join(",")
end

def get_tag2_flags(flags)
values = []
        if(flags.NO_AGING) then values.push("Does not age") end
        if(flags.MORTAL) then values.push("Mortal") end
        if(flags.STERILE) then values.push("Can't have children") end
        if(flags.FIT_FOR_ANIMATION) then values.push("Can be animated") end
        if(flags.FIT_FOR_RESURRECTION) then values.push("Can be resurected") end
return values.join(",")
end

print_effect = lambda { |logger, ce, duration|

flags = get_effect_flags(ce.flags)
if flags != ""
flags = " (#{flags})"
end

if ce.end == -1
duration = " [Permanent]"
elsif ce.start >= ce.peak or ce.peak <= 1
duration = " [#{ce.start}-#{ce.end}]"
else
duration = " [#{ce.start}-#{ce.peak}-#{ce.end}]"
end

case ce.getType().to_s()
when "PAIN"
name = "Pain"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
when "SWELLING"
name = "Swelling"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
when "OOZING"
name = "Oozing"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
when "BRUISING"
name = "Bruising"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
when "BLISTERS"
name = "Blisters"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
when "NUMBNESS"
name = "Numbness"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
when "PARALYSIS"
name = "Paralysis"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
when "FEVER"
name = "Fever"
desc = "Power=#{ce.sev}"
when "BLEEDING"
name = "Bleeding"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
when "COUGH_BLOOD"
name = "Cough Blood"
desc = "Power=#{ce.sev}"
when "VOMIT_BLOOD"
name = "Vomit Blood"
desc = "Power=#{ce.sev}"
when "NAUSEA"
name = "Nausea"
desc = "Power=#{ce.sev}"
when "UNCONSCIOUSNESS"
name = "Unconsciousness"
desc = "Power=#{ce.sev}"
when "NECROSIS"
name = "Necrosis"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
when "IMPAIR_FUNCTION"
name = "Impairs"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
when "DROWSINESS"
name = "Drowsiness"
desc = "Power=#{ce.sev}"
when "DIZZINESS"
name = "Dizziness"
desc = "Power=#{ce.sev}"
when "ADD_TAG"
name = "Add"
desc = "#{get_tag1_flags(ce.tags1)},#{get_tag2_flags(ce.tags2)}"
when "REMOVE_TAG"
name = "Remove"
desc = "#{get_tag1_flags(ce.tags1)},#{get_tag2_flags(ce.tags2)}"
when "DISPLAY_TILE"
name = "Tile"
desc = "Tile=#{ce.unk_6c}, Colour=#{ce.unk_70}"
when "FLASH_TILE"
name = "Flash"
color = ce.sym_color >> 8
tile = ce.sym_color - (color * 256)
desc = "Tile = #{tile} Colour=#{color} Time=#{ce.period} Period=#{ce.time}"
when "SPEED_CHANGE"
name = "Physical"
desc = "Speed("

if(ce.unk_6c!=0)
desc = desc + "%+d" % ce.unk_6c
end

if (ce.unk_6c!=0 and ce.unk_70!=100)
desc = desc + ", "
end

if (ce.unk_70!=100)
desc = desc + "%+d" % ce.unk_70 + "%"
end

desc = desc + ")"
when "CAN_DO_INTERACTION"
name = "Add Interaction"
desc = "#{get_interaction(ce)}"
when "SKILL_ROLL_ADJUST"
name = "Skill Check"
desc = "Percent=#{ce.unk_6c}, Chance=#{ce.unk_70}%"
when "BODY_TRANSFORMATION"
name = "Transformation"
if ce.caste_str != "DEFAULT"
caste = ", Caste=#{ce.caste_str}"
else
caste = ""
end
desc = "Chance=#{ce.unk_6c} Race=#{ce.race_str}#{caste}"
when "PHYS_ATT_CHANGE"
name = "Physical"
desc = "#{get_att_pairs(ce.phys_att_unk, ce.phys_att_perc, true)}"
when "MENT_ATT_CHANGE"
name = "Mental"
desc = "#{get_att_pairs(ce.ment_att_unk, ce.ment_att_perc, false)}"
when "MATERIAL_FORCE_MULTIPLIER"
# Material reference + top/bottom number of a fraction
name = "Material Force Multiplier"
desc = "a=#{ce.unk_6c}, b=#{ce.unk_88}, c=#{ce.unk_a4}, d=#{ce.unk_c0}, e=#{ce.unk_c4}, f=#{ce.unk_c8}, g=#{ce.unk_cc}"
when "BODY_MAT_INTERACTION"
# interactionId, SundromeTriggerType
name = "Body Material Interaction"
desc = "a=#{ce.unk_6c}, b=#{ce.unk_88}, c=#{ce.unk_8c}, d=#{ce.unk_90}, e=#{ce.unk_94}"
when "BODY_APPEARANCE_MODIFIER"
# !!! seems to be missing info class !!!
# should be enum and value
name = "Body Appearence"
desc = "<TODO>"
when "BP_APPEARANCE_MODIFIER"
name = "Body Part Appearence"
desc = "Value=#{ce.value} change_type_enum?=#{ce.unk_6c}#{get_effect_target(ce.target)}"
when "DISPLAY_NAME"
name = "Set Display Name"
desc = "#{ce.name}"
else
name = "Unknown effect type"
end

logger.log " - + #{name}#{duration}#{flags} #{desc}"
}

print_syndromes = lambda { |logger, unit, showrace, showall, showeffects| 

if !unit.syndromes.active.empty? or showall
if showrace
logger.log "#{df.world.raws.creatures.all[unit.race].name[0]}#{unit.name == '' ? "" : ": "}#{unit.name}"
else
logger.log "#{unit.name}"
end
end

unit.syndromes.active.each { |s|
syndrome = df.world.raws.syndromes.all[s.type]
duration = syndrome.ce.minmax_by{ |ce| ce.end }

if duration[0].end == -1
durationStr = "Permanent"
else
if duration[0].end == duration[1].end
durationStr = "#{s.ticks} of #{duration[0].end}"
else
durationStr = "#{s.ticks} of #{duration[0].end}-#{duration[1].end}"
end
end

logger.log " - #{syndrome.syn_name} [#{durationStr}]"

if showeffects
syndrome.ce.each { |effect| print_effect[logger, effect, s.ticks] }
end
}
}

def starts_with?(str, prefix)
  prefix = prefix.to_s
  str[0, prefix.length] == prefix
end

showall = false
showeffects = false
dwarves = false
livestock = false
wildanimals = false
hostile = false
world = false

if $script_args.any?{ |arg| arg == "help" or arg == "?" or arg == "-?" }
print_help()
elsif $script_args.empty?
dwarves = true
showeffects = true
else
if $script_args.any?{ |arg| arg == "showall" } then showall=true end
if $script_args.any?{ |arg| arg == "showeffects" } then showeffects=true end
if $script_args.any?{ |arg| arg == "dwarves" } then dwarves=true end
if $script_args.any?{ |arg| arg == "livestock" } then livestock=true end
if $script_args.any?{ |arg| arg == "wildanimals" } then wildanimals=true end
if $script_args.any?{ |arg| arg == "hostile" } then hostile=true end
if $script_args.any?{ |arg| arg == "world" } then world=true end
if $script_args.any?{ |arg| starts_with?(arg, "export:") } 
exportfile = $script_args.find{ |arg| starts_with?(arg, "export:") }.gsub("export:", "")
export=true
end
end

if export
logger = MyLogger.new(exportfile)
else
logger = MyLogger.new(nil)
end

if dwarves
logger.log "Dwarves"
df.unit_citizens.each { |unit|
print_syndromes[logger, unit, false, showall, showeffects]
}
logger.log"\n"
end

if livestock
logger.log "LiveStock"
df.world.units.active.find_all { |u| df.unit_category(u) == :Livestock }.each { |unit|
print_syndromes[logger, unit, true, showall, showeffects]
}
logger.log"\n"
end

if wildanimals
logger.log "Wild Animals"
df.world.units.active.find_all { |u| df.unit_category(u) == :Other and  df.unit_other_category(u) == :Wild }.each { |unit|
print_syndromes[logger, unit, true, showall, showeffects]
}
logger.log"\n"
end

if hostile
logger.log "Hostile Units"
df.unit_hostiles.each { |unit|
print_syndromes[logger, unit, true, showall, showeffects]
}
logger.log"\n"
end

if world
logger.log "All Syndromes"
df.world.raws.syndromes.all.each { |syndrome|
logger.log " - #{syndrome.syn_name == "" ? "mystery" : syndrome.syn_name}"
if showeffects
syndrome.ce.each { |effect| print_effect[logger, effect, 0] }
end
}
end

logger.close
Logged
Drayath's Gem Splitting Workshop - Split large gems and gem trinkets into numbers of small gems.
Drayath's Seed Brewery - Convert bags of spare seeds into useful booze.

Eldrick Tobin

  • Bay Watcher
  • [ETHIC: MODDING_UNDWARFY: PERSONAL_MATTER]
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3638 on: April 23, 2013, 11:03:51 pm »

Alternatives would be to add a new effects status screen to show all the details, or use the actual effects of the syndrome to programatically make up a name (e.g. if reduces strength calll it Weakening sickness) may be hard to do syndromes with multiple effects.

"This is a masterwork syndrome. It nauseates, makes you crazy, and husks."

Or alternatively go blizzard style "Vomitous Insanity Syndrome of Husking" but that would be messier. And silly.  :D
Logged
--
Eldrick Tobin
Behold the unimpressive Aspectus Lolin mod. || My Little Arachnid Fortress attempt...
I mumble to myself on tumblr... Sometimes about DF Modding.

drayath

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3639 on: April 24, 2013, 04:06:20 pm »

Had a look at showing the data in the a window in df, but it looks like this requires LUA and i have no intension of converting the script. If you bind the script to a hotkey as "showunitsyndrome dwarves showall showeffects export:<file>", can hit the hotkey and refresh your browser to see a formatted list of the present status of all your dwarves which is good enough for me at the moment.

New: Can show details on a selected unit (showunitsyndrome selected showeffects). Work with friendly and enemy units.
New: Export now generates formatted html file, including color coding for good/bad syndromes and effects.

Know Issue: It may well indicate which dwarves that have hidden curses (e.g. vampires), need to actually get a vampire in my fort to correct this.
Know Issue: error Bad File Descriptor, cause: file trying to export to is locked by you web browser. Usally just wait a second and run the script again.
Know Issue: Following effects are not fully decoded: Material Force Multiplier, Body Material Interaction, Body Appearence, Body Part Appearence

Code: [Select]
# Show syndromes affecting units and the remaining and maximum duration (v3). Call with help on the command line for further options.

def print_help()
puts "Use one or more of the following options:"
puts "    showall: Show units even if not affected by any syndrome"
puts "    showeffects: shows detailed effects of each syndrome"
puts "    showdisplayeffects: show effects that only change the look of the unit"
puts "    ignorehiddencurse: Hides syndomes the user should not be able to know about (TODO)"
puts "    selected: Show selected unit"
puts "    dwarves: Show dwarves"
puts "    livestock: Show livestock"
puts "    wildanimals: Show wild animals"
puts "    hostile: Show hostiles (e.g. invaders, thieves, forgeten beasts etc)"
puts "    world: Show all defined syndromes in the world"
puts "    export:<filename> Write the output to a file instead of the console."
puts ""
puts "Will show all syndromes affecting each units with the maximum and present duration."
end

class Output
attr_accessor :fileLogger, :indent_level
 
def initialize(filename)
indent_level = ""
if filename==nil
@fileLogger = nil
else
@fileLogger = File.new(filename + ".html", "w")
@fileLogger.puts("<html><body>")
end
end  

RED = "red"
GREEN = "green"
DEFAULT = "black"
HIGHLIGHT = "black\" size=\"+1"

def colorize(text, color_code)
  "<font color=\"#{color_code}\">#{text}</font>"
end

def indent()
if @fileLogger == nil
@indent_level = "#{@indent_level} - "
else
@fileLogger.puts("<ul>")
end
end

def unindent()
if @fileLogger == nil
@indent_level = @indent_level.chomp(" - ")
else
@fileLogger.puts("</ul>")
end
end

def break()
if @fileLogger == nil
puts("\n")
else
@fileLogger.puts("</br>")
end
end

def close()
if @fileLogger != nil
@fileLogger.puts("</body></html>")
@fileLogger.flush
@fileLogger.close
@fileLogger = nil
end
end

def log(text, color=nil)
if @fileLogger == nil
puts("#{@indent_level}#{text}")
elsif color==nil
@fileLogger.puts(text+"<br/>")
elsif @indent_level == ""
@fileLogger.puts(colorize(text, color))
else
@fileLogger.puts("<li>" + colorize(text, color)+"</li>")
end
end
end

def colorize(text, color_code)
  "<font color=\"#{color_code}\">#{text}</font>"
end

def get_mental_att(att_index)

# TODO: Surly i can use the names from MentalAttributeType somehow!!!!!
# case att_index
        # when "ANALYTICAL_ABILITY"
# return "Analytical Ability"
        # when "FOCUS"
# return "Focus"
# when "WILLPOWER"
# return "Willpower"
# when "CREATIVITY"
# return "Creativity"
# when "INTUITION"
# return "Intuition"
# when "PATIENCE"
# return "Patience"
# when "MEMORY"
# return "Memory"
# when "LINGUISTIC_ABILITY"
# return "Linguistics"
# when "SPATIAL_SENSE"
# return "Spacial Sense"
# when "MUSICALITY"
# return "Musicality"
# when "KINESTHETIC_SENSE"
# return "Kinestetic Sense"
# when "EMPATHY"
# return "Empathy"
# when "SOCIAL_AWARENESS"
# return "Social Awareness"
# end

case att_index
        when 0
return "Analytical Ability"
        when 1
return "Focus"
when 2
return "Willpower"
when 3
return "Creativity"
when 4
return "Intuition"
when 5
return "Patience"
when 6
return "Memory"
when 7
return "Linguistics"
when 8
return "Spacial Sense"
when 9
return "Musicality"
when 10
return "Kinestetic Sense"
when 11
return "Empathy"
when 12
return "Social Awareness"
else
return "Unknown"
end
end

def get_physical_att(att_index)

# TODO: Surly i can use the names from PhysicalAttributeType somehow!!!!!
# case att
        # when "STRENGTH"
# return "Strength"
# when "AGILITY"
# return "Agility"
# when "TOUGHNESS"
# return "Toughness"
# when "ENDURANCE"
# return "Endurance"
# when "RECUPERATION"
# return "Recuperation"
# when "DISEASE_RESISTANCE"
# return "Disease Resistance"
# end

case att_index
        when 0
return "Strength"
when 1
return "Agility"
when 2
return "Toughness"
when 3
return "Endurance"
when 4
return "Recuperation"
when 5
return "Disease Resistance"
else
return "Unknown"
end
end

def get_effect_target(target)

values = []

limit = target.key.length - 1
for i in (0..limit)

if(target.mode[i].to_s() != "")

case target.mode[i].to_s()
when "BY_TYPE"
item = "Type("
when "BY_TOKEN"
item = "Token("
when "BY_CATEGORY"
item = "Category("
end

if(target.key[i].to_s()!="")
item = item + target.key[i].to_s()
end

if(target.key[i].to_s()!="" and target.tissue[i].to_s()!="")
item = item + ":"
end

if(target.tissue[i].to_s()!="")
item = item + target.tissue[i].to_s()
end

item = item + ")"

values.push(item)
end

end

if values.length == 0
return ""
else
return " Target=" + values.join(", ")
end
end

def get_att_pairs(values, percents, physical)

items = []

color = Output::DEFAULT

limit = values.length - 1
for i in (0..limit)
if (values[i]!=0 or percents[i]!=100)

if physical
item = "#{get_physical_att(i)}("
else
item = "#{get_mental_att(i)}("
end

if(values[i]!=0)
item = item + "%+d" % values[i]
end

if (values[i]!=0 and percents[i]!=100)
item = item + ", "
end

if (percents[i]!=100)
item = item + "%d" % percents[i] + "%"
end

item = item + ")"

if values[i] >0 && percents[i] >100
color = Output::GREEN
elsif values[i] <0 || percents[i] <100
color = Output::RED
end

items.push(item)
end
end

return items.join(", "), color
end

def get_interaction(interaction)

# name, USAGE_HINT, range, wait period are probally all we really want to show.

#result = "a=#{interaction.unk_6c} b=#{interaction.unk_7c} c=#{interaction.unk_8c} d=#{interaction.unk_a8} e=#{interaction.unk_c4} f=#{interaction.unk_e4} "
#result = result + "g=#{interaction.unk_e0} h=#{interaction.unk_e4} i=#{interaction.unk_100} j=#{interaction.unk_11c} k=#{interaction.unk_138} l=#{interaction.unk_154} "
#result = result + "m=#{interaction.unk_170} n=#{interaction.unk_18c} o=#{interaction.unk_1a8} p=#{interaction.unk_1c4} q=#{interaction.unk_1e8} r=#{interaction.unk_25c} "
#result = result + "s=#{interaction.unk_278}"

return "Ability=#{interaction.unk_25c}, Delay=#{interaction.unk_278}"
end

def get_effect_flags(flags)

values = []

if(flags.SIZE_DELAYS) then values.push("Size Delays") end
if(flags.SIZE_DILUTES) then values.push("Size Dilutes") end
if(flags.VASCULAR_ONLY) then values.push("Vascular Only") end
if(flags.MUSCULAR_ONLY) then values.push("Musles Only") end
if(flags.RESISTABLE) then values.push("Resistable") end
if(flags.LOCALIZED) then values.push("Localized") end

return values.join(",")
end

def get_tag1_flags(flags, add)
   
values = []

good = false
bad = false

if add
good_color = Output::GREEN
bad_color = Output::RED
else
good_color = Output::RED
bad_color = Output::GREEN
end

if(flags.EXTRAVISION)
values.push(colorize("Extravision", good_color))
good = true
end

if(flags.OPPOSED_TO_LIFE)
values.push(colorize("Attack the living", bad_color))
bad = true
end

if(flags.NOT_LIVING)
values.push(colorize("Undead", Output::DEFAULT))
end 

if(flags.NOEXERT)
values.push(colorize("Does not tire", good_color))
good = true
end

if(flags.NOPAIN)
values.push(colorize("Does not feel pain", good_color))
good = true
end

if(flags.NOBREATHE)
values.push(colorize("Does not breathe", good_color))
good = true
end

if(flags.HAS_BLOOD)
values.push(colorize("Has blood", Output::DEFAULT))
end

if(flags.NOSTUN)
values.push(colorize("Can't be stunned", good_color))
good = true 
end

if(flags.NONAUSEA)
values.push(colorize("Does not get nausea", good_color))
good = true
end

if(flags.NO_DIZZINESS)
values.push(colorize("Does not get dizzy", good_color))
good = true
end

if(flags.NO_FEVERS)
values.push(colorize("Does not get fever", good_color))
good = true
end

if(flags.TRANCES)
values.push(colorize("Can enter trance", good_color))
good = true
end

if(flags.NOEMOTION)
values.push(colorize("Feels no emotion", good_color))
good = true
end

if(flags.LIKES_FIGHTING)
values.push(colorize("Like fighting", Output::DEFAULT))
end

if(flags.PARALYZEIMMUNE)
values.push(colorize("Can't be paralazed", good_color))
good = true
end
if(flags.NOFEAR)
values.push(colorize("Does not feel fear", good_color))
good = true
end

if(flags.NO_EAT)
values.push(colorize("Does not eat", good_color))
good = true
end

if(flags.NO_DRINK)
values.push(colorize("Does not drink", good_color))
good = true 
end

if(flags.NO_SLEEP)
values.push(colorize("Does not sleep", good_color))
good = true
end
if(flags.MISCHIEVOUS)
values.push(colorize("Mischievous", Output::DEFAULT))
end

if(flags.NO_PHYS_ATT_GAIN)
values.push(colorize("Physical stats cant improve", good_color))
good = true
end

if(flags.NO_PHYS_ATT_RUST)
values.push(colorize("Physical stats do not rust", good_color))
good = true
end

if(flags.NOTHOUGHT)
values.push(colorize("Stupid", bad_color))
bad = true
end

if(flags.NO_THOUGHT_CENTER_FOR_MOVEMENT)
values.push(colorize("No brain needed to move", good_color))
good = true
end

if(flags.CAN_SPEAK)
values.push(colorize("Can speak", good_color))
good = true
end

if(flags.CAN_LEARN)
values.push(colorize("Can learn", good_color))
good = true
end

if(flags.UTTERANCES)
values.push(colorize("Utterances", Output::DEFAULT))
end

if(flags.CRAZED)
values.push(colorize("Crazed", bad_color))
bad = true
end

if(flags.BLOODSUCKER)
values.push(colorize("Drinks Blood", bad_color))
bad = true
end

if(flags.NO_CONNECTIONS_FOR_MOVEMENT)
values.push(colorize("Can move without nerves", good_color))
good = true
end

if(flags.SUPERNATURAL)
values.push(colorize("Supernatural", good_color))
good = true
end

if add
if bad
color = Output::RED
elsif good
color = Output::GREEN
else
color = Output::DEFAULT
end
else
if good
color = Output::RED
elsif bad
color = Output::GREEN
else
color = Output::DEFAULT
end
end

return values.join(","), color
end

def get_tag2_flags(flags, add)
values = []

good = false
bad = false

if add
good_color = Output::GREEN
bad_color = Output::RED
else
good_color = Output::RED
bad_color = Output::GREEN
end

if(flags.NO_AGING)
good = true
values.push(colorize("Does not age", good_color)) 
end

if(flags.MORTAL)
bad = true
values.push(colorize("Mortal", bad_color))
end

if(flags.STERILE)
values.push(colorize("Can't have children", Output::DEFAULT)) 
end

if(flags.FIT_FOR_ANIMATION)
values.push(colorize("Can be animated", Output::DEFAULT))
end

if(flags.FIT_FOR_RESURRECTION)
good = true
values.push(colorize("Can be resurected", Output::DEFAULT))
end

if add
if bad
color = Output::RED
elsif good
color = Output::GREEN
else
color = Output::DEFAULT
end
else
if good
color = Output::RED
elsif bad
color = Output::GREEN
else
color = Output::DEFAULT
end
end

return values.join(","), color
end

def get_effect(ce, duration, showdisplayeffects)

flags = get_effect_flags(ce.flags)
if flags != ""
flags = " (#{flags})"
end

if ce.end == -1
duration = " [Permanent]"
elsif ce.start >= ce.peak or ce.peak <= 1
duration = " [#{ce.start}-#{ce.end}]"
else
duration = " [#{ce.start}-#{ce.peak}-#{ce.end}]"
end

case ce.getType().to_s()
when "PAIN"
name = "Pain"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "SWELLING"
name = "Swelling"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "OOZING"
name = "Oozing"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "BRUISING"
name = "Bruising"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "BLISTERS"
name = "Blisters"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "NUMBNESS"
name = "Numbness"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::GREEN
when "PARALYSIS"
name = "Paralysis"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "FEVER"
name = "Fever"
desc = "Power=#{ce.sev}"
color = Output::RED
when "BLEEDING"
name = "Bleeding"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "COUGH_BLOOD"
name = "Cough Blood"
desc = "Power=#{ce.sev}"
color = Output::RED
when "VOMIT_BLOOD"
name = "Vomit Blood"
desc = "Power=#{ce.sev}"
color = Output::RED
when "NAUSEA"
name = "Nausea"
desc = "Power=#{ce.sev}"
color = Output::RED
when "UNCONSCIOUSNESS"
name = "Unconsciousness"
desc = "Power=#{ce.sev}"
color = Output::RED
when "NECROSIS"
name = "Necrosis"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "IMPAIR_FUNCTION"
name = "Impairs"
desc = "Power=#{ce.sev}#{get_effect_target(ce.target)}"
color = Output::RED
when "DROWSINESS"
name = "Drowsiness"
desc = "Power=#{ce.sev}"
color = Output::RED
when "DIZZINESS"
name = "Dizziness"
desc = "Power=#{ce.sev}"
color = Output::RED
when "ADD_TAG"
name = "Add"
tags1 = get_tag1_flags(ce.tags1, true)
tags2 = get_tag2_flags(ce.tags2, true)
desc = "#{tags1[0]},#{tags2[0]}"

if tags1[1] == Output::RED || tags2[1] == Output::RED
color = Output::RED
elsif tags1[1] == Output::GREEN || tags2[1] == Output::GREEN
color = Output::GREEN
else
color = Output::DEFAULT
end
when "REMOVE_TAG"
name = "Remove"
tags1 = get_tag1_flags(ce.tags1, true)
tags2 = get_tag2_flags(ce.tags2, true)
desc = "#{tags1[0]},#{tags2[0]}"

if tags1[1] == Output::RED || tags2[1] == Output::RED
color = Output::RED
elsif tags1[1] == Output::GREEN || tags2[1] == Output::GREEN
color = Output::GREEN
else
color = Output::DEFAULT
end
when "DISPLAY_TILE"
if !showdisplayeffects then return "", Output::DEFAULT end
name = "Tile"
desc = "Tile=#{ce.unk_6c}, Colour=#{ce.unk_70}"
color = Output::DEFAULT
when "FLASH_TILE"
if !showdisplayeffects then return "", Output::DEFAULT end
name = "Flash"
color = ce.sym_color >> 8
tile = ce.sym_color - (color * 256)
desc = "Tile = #{tile} Colour=#{color} Time=#{ce.period} Period=#{ce.time}"
color = Output::DEFAULT
when "SPEED_CHANGE"
name = "Physical"
desc = "Speed("

if(ce.unk_6c!=0)
desc = desc + "%+d" % ce.unk_6c
end

if (ce.unk_6c!=0 and ce.unk_70!=100)
desc = desc + ", "
end

if (ce.unk_70!=100)
desc = desc + "%d" % ce.unk_70 + "%"
end

desc = desc + ")"

if ce.unk_6c >=0 && ce.unk_70 >=100
color = Output::GREEN
else
color = Output::RED
end

when "CAN_DO_INTERACTION"
name = "Add Interaction"
desc = "#{get_interaction(ce)}"
color = Output::GREEN
when "SKILL_ROLL_ADJUST"
name = "Skill Check"
desc = "Percent=#{ce.unk_6c}, Chance=#{ce.unk_70}%"

if ce.unk_6c >=100
color = Output::GREEN
else
color = Output::RED
end

when "BODY_TRANSFORMATION"
name = "Transformation"
if ce.caste_str != "DEFAULT"
caste = ", Caste=#{ce.caste_str}"
else
caste = ""
end

if ce.unk_6c > 0
chance = "Chance=#{ce.unk_6c} "
else
chance = ""
end

desc = "#{chance}Race=#{ce.race_str}#{caste}"
color = Output::DEFAULT
when "PHYS_ATT_CHANGE"
name = "Physical"
data = get_att_pairs(ce.phys_att_unk, ce.phys_att_perc, true)
desc = data[0]
color = data[1]
when "MENT_ATT_CHANGE"
name = "Mental"
data = get_att_pairs(ce.ment_att_unk, ce.ment_att_perc, false)
desc = data[0]
color = data[1]
when "MATERIAL_FORCE_MULTIPLIER"
# Material reference + top/bottom number of a fraction
name = "Material Force Multiplier"
desc = "a=#{ce.unk_6c}, b=#{ce.unk_88}, c=#{ce.unk_a4}, d=#{ce.unk_c0}, e=#{ce.unk_c4}, f=#{ce.unk_c8}, g=#{ce.unk_cc}"
color = Output::DEFAULT
when "BODY_MAT_INTERACTION"
# interactionId, SundromeTriggerType
name = "Body Material Interaction"
desc = "a=#{ce.unk_6c}, b=#{ce.unk_88}, c=#{ce.unk_8c}, d=#{ce.unk_90}, e=#{ce.unk_94}"
color = Output::DEFAULT
when "BODY_APPEARANCE_MODIFIER"
if !showdisplayeffects then return "", Output::DEFAULT end
# !!! seems to be missing info class !!!
# should be enum and value
name = "Body Appearence"
desc = "<TODO>"
color = Output::DEFAULT
when "BP_APPEARANCE_MODIFIER"
if !showdisplayeffects then return "", Output::DEFAULT end
name = "Body Part Appearence"
desc = "Value=#{ce.value} change_type_enum?=#{ce.unk_6c}#{get_effect_target(ce.target)}"
color = Output::DEFAULT
when "DISPLAY_NAME"
if !showdisplayeffects then return "", Output::DEFAULT end
name = "Set Display Name"
desc = "#{ce.name}"
color = Output::DEFAULT
else
name = "Unknown effect type"
color = Output::HIGHLIGHT
end

return "#{name}#{duration}#{flags} #{desc}", color
end


print_syndromes = lambda { |logger, unit, showrace, showall, showeffects, showhiddencurse, showdisplayeffects|

if showhiddencurse
syndromes = unit.syndromes.active
else
syndromes = unit.syndromes.active
# TODO: syndromes = unit.syndromes.active.select{ |s| visible_syndrome?(unit, s) }
end

if !syndromes.empty? or showall
if showrace
logger.log "#{df.world.raws.creatures.all[unit.race].name[0]}#{unit.name == '' ? "" : ": "}#{unit.name}", Output::HIGHLIGHT
else
logger.log "#{unit.name}", Output::HIGHLIGHT
end
end

syndromes.each { |syndrome| print_syndrome[logger, syndrome, showeffects, showdisplayeffects] }
}


print_syndrome = lambda { |logger, syndrome, showeffects, showdisplayeffects| 
rawsyndrome = df.world.raws.syndromes.all[syndrome.type]
duration = rawsyndrome.ce.minmax_by{ |ce| ce.end }

if duration[0].end == -1
durationStr = "Permanent"
else
if duration[0].end == duration[1].end
durationStr = "#{syndrome.ticks} of #{duration[0].end}"
else
durationStr = "#{syndrome.ticks} of #{duration[0].end}-#{duration[1].end}"
end
end

effects = rawsyndrome.ce.collect { |effect| get_effect(effect, syndrome.ticks, showdisplayeffects) }

if effects.any?{ |text, color| color==Output::RED }
color = Output::RED
elsif effects.any?{|text, color| color==Output::GREEN }
color = Output::GREEN
else
color = Output::DEFAULT
end

name = rawsyndrome.syn_name == "" ? "mystery" : rawsyndrome.syn_name

logger.indent()
logger.log "#{name} [#{durationStr}]", color

if showeffects
logger.indent()
effects.each{ |text, color| if text!="" then logger.log text, color end }
logger.unindent()
end
logger.unindent()
}

print_raw_syndrome = lambda { |logger, rawsyndrome, showeffects, showdisplayeffects| 

effects = rawsyndrome.ce.collect { |effect| get_effect(effect, 0, showdisplayeffects) }

if effects.any?{ |item| item[1]==Output::RED }
color = Output::RED
elsif effects.any?{|item| item[1]==Output::GREEN }
color = Output::GREEN
else
color = Output::DEFAULT
end

name = rawsyndrome.syn_name == "" ? "mystery" : rawsyndrome.syn_name

logger.indent()
logger.log name, color

if showeffects
logger.indent()
effects.each{ |text, color| if text!="" then logger.log text, color end }
logger.unindent()
end
logger.unindent()
}

def starts_with?(str, prefix)
  prefix = prefix.to_s
  str[0, prefix.length] == prefix
end

showall = false
showeffects = false
selected = false
dwarves = false
livestock = false
wildanimals = false
hostile = false
world = false
showhiddencurse = false
showdisplayeffects = false

if $script_args.any?{ |arg| arg == "help" or arg == "?" or arg == "-?" }
print_help()
elsif $script_args.empty?
dwarves = true
showeffects = true
else
if $script_args.any?{ |arg| arg == "showall" } then showall=true end
if $script_args.any?{ |arg| arg == "showeffects" } then showeffects=true end
if $script_args.any?{ |arg| arg == "ignorehiddencurse" } then showhiddencurse=true end
if $script_args.any?{ |arg| arg == "showdisplayeffects" } then showdisplayeffects=true end
if $script_args.any?{ |arg| arg == "selected" } then selected=true end
if $script_args.any?{ |arg| arg == "dwarves" } then dwarves=true end
if $script_args.any?{ |arg| arg == "livestock" } then livestock=true end
if $script_args.any?{ |arg| arg == "wildanimals" } then wildanimals=true end
if $script_args.any?{ |arg| arg == "hostile" } then hostile=true end
if $script_args.any?{ |arg| arg == "world" } then world=true end
if $script_args.any?{ |arg| starts_with?(arg, "export:") } 
exportfile = $script_args.find{ |arg| starts_with?(arg, "export:") }.gsub("export:", "")
export=true
end
end

if export
logger = Output.new(exportfile)
else
logger = Output.new(nil)
end

if selected
print_syndromes[logger, df.unit_find(), true, showall, showeffects, showhiddencurse, showdisplayeffects]
logger.break()
end

if dwarves
logger.log "Dwarves", Output::HIGHLIGHT
df.unit_citizens.each { |unit|
print_syndromes[logger, unit, false, showall, showeffects, showhiddencurse, showdisplayeffects]
}
logger.break()
end

if livestock
logger.log "LiveStock", Output::HIGHLIGHT
df.world.units.active.find_all { |u| df.unit_category(u) == :Livestock }.each { |unit|
print_syndromes[logger, unit, true, showall, showeffects, showhiddencurse, showdisplayeffects]
}
logger.break()
end

if wildanimals
logger.log "Wild Animals", Output::HIGHLIGHT
df.world.units.active.find_all { |u| df.unit_category(u) == :Other and  df.unit_other_category(u) == :Wild }.each { |unit|
print_syndromes[logger, unit, true, showall, showeffects, showhiddencurse, showdisplayeffects]
}
logger.break()
end

if hostile
logger.log "Hostile Units", Output::HIGHLIGHT
df.unit_hostiles.each { |unit|
print_syndromes[logger, unit, true, showall, showeffects, showhiddencurse, showdisplayeffects]
}
logger.break()
end

if world
logger.log "All Syndromes", Output::HIGHLIGHT
df.world.raws.syndromes.all.each { |syndrome| print_raw_syndrome[logger, syndrome, showeffects, showdisplayeffects] }
end

logger.close()
Logged
Drayath's Gem Splitting Workshop - Split large gems and gem trinkets into numbers of small gems.
Drayath's Seed Brewery - Convert bags of spare seeds into useful booze.

falconne

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3640 on: April 25, 2013, 05:21:49 am »

I was wondering if whoever added the mouse tracking functionality to enabler.h knows if it's possible to detect a "mouse button up" event? There are currently mouse_rbut_lift and mouse_lbut_lift variables, but these aren't set when either button is lifted (and lifting a button doesn't generate an input event). I was going to try adding "click and drag to move the viewport" functionality to my mouse plugin, but it looks like it's currently not possible to detect mouse up events in DF.
Logged
Utility plugins for DFHack, for improving Dwarf Fortress' user interface.

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3641 on: April 25, 2013, 06:19:00 am »

good news I figure out that rider_mount_id controls which unit the rider is on. so changing that will lead to the rider to warp to who ever you set it to. this proves that mounts don't have that much code to be set unlike their rider counterparts and I'm one foot closer to teaching dwarfs how to ride carp into battle.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3642 on: April 25, 2013, 02:51:15 pm »

I have made an adaptation of unsuspend.rb and autounsuspend.rb for the purposes of fixing handedness on gloves created through custom reactions.

fixhandedness.rb
Spoiler (click to show/hide)

autofixhandedness.rb
Spoiler (click to show/hide)

I set the auto check to 100 ticks and I think it can be set longer 2400 ticks for once every 2 dwarf days as I don't expect custom reaction gloves to be created frequently. 

I updated my scripts to increase the auto ticks, to give start and stop feedback, to have a help string in the dfhack console's script listing, and improve the comments.

Also, looking at the how I am using the onupdate_register function, I am thinking that if someone issued the auto script to start twice, then it might have 2 versions of itself registered, and only the most recent would be stopped with the scripts stop command.  Therefore I am thinking about adding a check so that the script doesn't onupdate_register twice.  Alternatively we might want to consider making sure the onupdate_register function doesn't add duplicate description keys (perhaps updated the existing one when it happens).  I haven't taken a deep look into that so I don't know if it is an issue.



Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.34.11 r3
« Reply #3643 on: April 25, 2013, 02:56:47 pm »

Kurik Amudnil, sorry to be so blunt, but could you repeat this in plain english please? You made an update, and something improved. I am just not entirely sure what. Auto ticks, start and stop feedback?
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 :::

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: DFHack 0.34.11 r3
« Reply #3644 on: April 25, 2013, 04:28:03 pm »

The update adds feedback to the dfhack console when starting and stopping.  So issuing
Code: [Select]
autofixhandedness startin the dfhack console or by way of the dfhack.init will print a nice message about having been successfully started, or stopped in the case of the stop argument.  This way if starting by way of the dfhack.init, there is an identifiable message from autofixhandedness with the other startup messages.

I set the auto script to run every 2400 ticks rather than the 100 I had previously, 2400 being once every 2 dwarf days

when issuing the ls command to the dfhack console, at the bottom of the listing of commands is a list of scripts with an associated message acquired from a comment on the first line of the script so I added a comment on the first line to show up in the dfhack ls listing

I reorganized and updated/added the other comments in a hope to improve clarity.

Overall, it is functionally identical, other than changing the default frequency to 2400 ticks, the changes are cosmetic so that it would be more appropriate for inclusion with provided scripts in future releases of dfhack.  On that note, I don't yet know what the procedure is for adding scripts to the repository.
Pages: 1 ... 241 242 [243] 244 245 ... 373