|
|
@ -467,21 +467,23 @@ local function get_unit_disposition(unit)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function get_item_disposition(item)
|
|
|
|
local function get_item_disposition(item)
|
|
|
|
local disposition = DISPOSITION.NONE
|
|
|
|
|
|
|
|
if dfhack.units.casteFlagSet(item.race, item.caste, df.caste_raw_flags.OPPOSED_TO_LIFE) then
|
|
|
|
if dfhack.units.casteFlagSet(item.race, item.caste, df.caste_raw_flags.OPPOSED_TO_LIFE) then
|
|
|
|
disposition = DISPOSITION.HOSTILE
|
|
|
|
return DISPOSITION.HOSTILE.value
|
|
|
|
-- elseif dfhack.units.isPet(unit) then
|
|
|
|
end
|
|
|
|
-- disposition = DISPOSITION.PET
|
|
|
|
|
|
|
|
-- elseif dfhack.units.isDomesticated(unit) then
|
|
|
|
if df.item_petst:is_instance(item) then
|
|
|
|
-- disposition = DISPOSITION.TAME
|
|
|
|
if item.owner_id > -1 then
|
|
|
|
elseif dfhack.units.casteFlagSet(item.race, item.caste, df.caste_raw_flags.PET) or
|
|
|
|
return DISPOSITION.PET.value
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return DISPOSITION.TAME.value
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if dfhack.units.casteFlagSet(item.race, item.caste, df.caste_raw_flags.PET) or
|
|
|
|
dfhack.units.casteFlagSet(item.race, item.caste, df.caste_raw_flags.PET_EXOTIC)
|
|
|
|
dfhack.units.casteFlagSet(item.race, item.caste, df.caste_raw_flags.PET_EXOTIC)
|
|
|
|
then
|
|
|
|
then
|
|
|
|
disposition = DISPOSITION.WILD_TRAINABLE
|
|
|
|
return DISPOSITION.WILD_TRAINABLE.value
|
|
|
|
else
|
|
|
|
|
|
|
|
disposition = DISPOSITION.WILD_UNTRAINABLE
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return disposition.value
|
|
|
|
return DISPOSITION.WILD_UNTRAINABLE.value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function is_assignable_unit(unit)
|
|
|
|
local function is_assignable_unit(unit)
|
|
|
@ -493,13 +495,16 @@ local function is_assignable_unit(unit)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function is_assignable_item(item)
|
|
|
|
local function is_assignable_item(item)
|
|
|
|
-- TODO are there unassignable vermin/small pets?
|
|
|
|
-- all vermin/small pets are assignable
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function get_vermin_desc(vermin, raw)
|
|
|
|
local function get_vermin_desc(vermin, raw)
|
|
|
|
if not raw then return 'Unknown vermin' end
|
|
|
|
if not raw then return 'Unknown vermin' end
|
|
|
|
return ('%s [%d]'):format(raw.name[1], vermin.stack_size)
|
|
|
|
if vermin.stack_size > 1 then
|
|
|
|
|
|
|
|
return ('%s [%d]'):format(raw.name[1], vermin.stack_size)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return ('%s'):format(raw.name[0])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function get_small_pet_desc(raw)
|
|
|
|
local function get_small_pet_desc(raw)
|
|
|
@ -519,7 +524,7 @@ function AssignAnimal:cache_choices()
|
|
|
|
unit=unit,
|
|
|
|
unit=unit,
|
|
|
|
desc=dfhack.units.getReadableName(unit),
|
|
|
|
desc=dfhack.units.getReadableName(unit),
|
|
|
|
gender=unit.sex,
|
|
|
|
gender=unit.sex,
|
|
|
|
race=raw and raw.creature_id or -1,
|
|
|
|
race=raw and raw.creature_id or '',
|
|
|
|
status=self.get_status(unit, bld_assignments),
|
|
|
|
status=self.get_status(unit, bld_assignments),
|
|
|
|
disposition=get_unit_disposition(unit),
|
|
|
|
disposition=get_unit_disposition(unit),
|
|
|
|
egg=dfhack.units.isEggLayerRace(unit),
|
|
|
|
egg=dfhack.units.isEggLayerRace(unit),
|
|
|
@ -540,7 +545,7 @@ function AssignAnimal:cache_choices()
|
|
|
|
vermin=vermin,
|
|
|
|
vermin=vermin,
|
|
|
|
desc=get_vermin_desc(vermin, raw),
|
|
|
|
desc=get_vermin_desc(vermin, raw),
|
|
|
|
gender=df.pronoun_type.it,
|
|
|
|
gender=df.pronoun_type.it,
|
|
|
|
race=raw and raw.creature_id or -1,
|
|
|
|
race=raw and raw.creature_id or '',
|
|
|
|
status=self.get_status(vermin, bld_assignments),
|
|
|
|
status=self.get_status(vermin, bld_assignments),
|
|
|
|
disposition=get_item_disposition(vermin),
|
|
|
|
disposition=get_item_disposition(vermin),
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -559,7 +564,7 @@ function AssignAnimal:cache_choices()
|
|
|
|
vermin=small_pet,
|
|
|
|
vermin=small_pet,
|
|
|
|
desc=get_small_pet_desc(raw),
|
|
|
|
desc=get_small_pet_desc(raw),
|
|
|
|
gender=df.pronoun_type.it,
|
|
|
|
gender=df.pronoun_type.it,
|
|
|
|
race=raw and raw.creature_id or -1,
|
|
|
|
race=raw and raw.creature_id or '',
|
|
|
|
status=self.get_status(small_pet, bld_assignments),
|
|
|
|
status=self.get_status(small_pet, bld_assignments),
|
|
|
|
disposition=get_item_disposition(small_pet),
|
|
|
|
disposition=get_item_disposition(small_pet),
|
|
|
|
}
|
|
|
|
}
|
|
|
|