Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conceivable sizes #1119

Merged
merged 10 commits into from
May 16, 2024
35 changes: 33 additions & 2 deletions gui/unit-info-viewer.lua
myk002 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,42 @@ local function get_size_in_cc(unit)
return unit.body.size_info.size_cur * 10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this function now unused? if so, you can remove it

end

local function get_conceivable_comparison(unit, comparison_unit)
--the objective here is to get a (resaonably) small number to help concieve how large a thing is. "83 dwarves" doesn't really help convey the size of an elephant much better than 5m cc, so at certain breakpoints we will use different animals
myk002 marked this conversation as resolved.
Show resolved Hide resolved
local size = unit.body.size_info.size_cur
local base_comparison_size = 6000
if size > base_comparison_size*20 then
return string.format('%.3f average elephants', size/500000)
elseif size > base_comparison_size*0.25 then
return string.format('%.3f average dwarves', size/6000)
else
return string.format('%.3f average cats', size/500)
myk002 marked this conversation as resolved.
Show resolved Hide resolved
end

end

local function get_size_compared_to_median(unit)
local size_normal = unit.body.size_info.size_base
myk002 marked this conversation as resolved.
Show resolved Hide resolved
local size_modifier = unit.appearance.size_modifier
if size_modifier >= 110 then
return "larger than average"
elseif size_modifier <= 90 then
return "smaller than average"
else
return "about average"
end
end

local function get_body_chunk(unit)
local blurb = ('%s appears to be about %d cubic centimeters in size.'):format(
get_pronoun(unit), get_size_in_cc(unit))
local blurb = ('%s weighs about as much as %s'):format(get_pronoun(unit), get_conceivable_comparison(unit, comparison_unit))
return {text=blurb, pen=COLOR_LIGHTBLUE}
end

local function get_average_size(unit)
local blurb = ('%s is %s in size'):format(get_pronoun(unit), get_size_compared_to_median(unit))
return{text=blurb, pen=COLOR_LIGHTCYAN}
end

local function get_grazer_chunk(unit)
if not dfhack.units.isGrazer(unit) then return end
local caste = get_caste_data(unit)
Expand Down Expand Up @@ -451,6 +481,7 @@ function UnitInfo:refresh(unit, width)
add_chunk(chunks, get_ghostly_chunk(unit), width)
add_chunk(chunks, get_dead_chunk(unit), width)
add_chunk(chunks, get_body_chunk(unit), width)
add_chunk(chunks, get_average_size(unit), width)
myk002 marked this conversation as resolved.
Show resolved Hide resolved
add_chunk(chunks, get_grazer_chunk(unit), width)
add_chunk(chunks, get_milkable_chunk(unit), width)
add_chunk(chunks, get_shearable_chunk(unit), width)
Expand Down