Raptor Rework - Ranching and Companionship (#93564)

This commit is contained in:
SmArtKar
2025-11-01 22:13:29 +11:00
committed by GitHub
parent 30151ccc20
commit 1c6c506936
58 changed files with 2608 additions and 1621 deletions
+43 -15
View File
@@ -16,10 +16,12 @@
var/drinking
/// If true, we put food in our tummy instead of deleting it
var/add_to_contents
/// Types the animal can eat.
/// If true, when add_to_contents would put the item into contents but when used for healing, the item is consumed instead
var/consume_healing
/// Types the animal can eat. Can be an assoc list with amount to heal/damage the mob by
var/list/food_types
/datum/element/basic_eating/Attach(datum/target, heal_amt = 0, damage_amount = 0, damage_type = null, drinking = FALSE, add_to_contents = FALSE, food_types = list())
/datum/element/basic_eating/Attach(datum/target, heal_amt = 0, damage_amount = 0, damage_type = null, drinking = FALSE, add_to_contents = FALSE, consume_healing = TRUE, food_types = list())
. = ..()
if(!isliving(target))
@@ -31,6 +33,7 @@
src.damage_type = damage_type
src.drinking = drinking
src.add_to_contents = add_to_contents
src.consume_healing = consume_healing
src.food_types = food_types
RegisterSignal(target, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(try_feed))
@@ -66,7 +69,8 @@
/datum/element/basic_eating/proc/try_eating(mob/living/eater, atom/target, mob/living/feeder)
if(!is_type_in_list(target, food_types))
return FALSE
if(SEND_SIGNAL(eater, COMSIG_MOB_PRE_EAT, target, feeder) & COMSIG_MOB_CANCEL_EAT)
var/list/effect_mult = list()
if(SEND_SIGNAL(eater, COMSIG_MOB_PRE_EAT, target, feeder, effect_mult) & COMSIG_MOB_CANCEL_EAT)
return FALSE
if(add_to_contents && !ismovable(target))
return FALSE
@@ -76,22 +80,44 @@
else
eat_verb = pick("bite","chew","nibble","gnaw","gobble","chomp")
if (heal_amt > 0)
var/healed = heal_amt && eater.health < eater.maxHealth
eater.heal_overall_damage(heal_amt)
var/best_match = null
var/best_value = 0
for (var/food_path in food_types)
// Not an assoc list
if (isnull(food_types[food_path]))
break
if (istype(target, food_path) && (!best_match || ispath(food_path, best_match)))
best_match = food_path
best_value = food_types[food_path]
var/to_heal = heal_amt
var/to_damage = damage_amount
if (best_match)
to_heal = 0
to_damage = 0
if (best_value > 0)
to_heal = best_value
else if (best_value < 0)
to_damage = -best_value
for (var/mult in effect_mult)
to_heal *= mult
to_damage *= mult
if (to_heal > 0)
var/healed = eater.heal_overall_damage(to_heal)
eater.visible_message(span_notice("[eater] [eat_verb]s [target]."), span_notice("You [eat_verb] [target][healed ? ", restoring some health" : ""]."))
else if (damage_amount > 0 && damage_type)
eater.apply_damage(damage_amount, damage_type)
eater.visible_message(span_notice("[eater] [eat_verb]s [target], and seems to hurt itself."), span_notice("You [eat_verb] [target], hurting yourself in the process."))
else if (to_damage > 0 && damage_type)
var/damaged = eater.apply_damage(to_damage, damage_type)
eater.visible_message(span_notice("[eater] [eat_verb]s [target][damaged ? ", and seems to hurt [eater.p_themselves()]!" : "."]"), span_notice("You [eat_verb] [target][damaged ? ", hurting yourself in the process" : ""]."))
else
eater.visible_message(span_notice("[eater] [eat_verb]s [target]."), span_notice("You [eat_verb] [target]."))
finish_eating(eater, target, feeder)
finish_eating(eater, target, feeder, to_heal)
return TRUE
/datum/element/basic_eating/proc/finish_eating(mob/living/eater, atom/target, mob/living/feeder)
/datum/element/basic_eating/proc/finish_eating(mob/living/eater, atom/target, mob/living/feeder, to_heal)
set waitfor = FALSE
if(drinking)
playsound(eater.loc,'sound/items/drink.ogg', rand(10,50), TRUE)
@@ -104,10 +130,12 @@
var/obj/item/stack/food_stack = target
final_target = food_stack.split_stack(1)
eater.log_message("has eaten [target], [add_to_contents ? "swallowing it" : "destroying it"]!", LOG_ATTACK)
var/devour = add_to_contents && !to_heal
eater.log_message("has eaten [target], [devour ? "swallowing it" : "destroying it"]!", LOG_ATTACK)
if (add_to_contents)
if (devour)
var/atom/movable/movable_target = final_target
movable_target.forceMove(eater)
else
qdel(final_target)
+87
View File
@@ -0,0 +1,87 @@
/// Element which influences raptor children upon owner's consumption as food
/datum/element/raptor_food
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// Flat damage modifier
var/attack_modifier = null
/// Flat health modifier
var/health_modifier = null
/// Speed modifier
var/speed_modifier = null
/// Primary ability stat modifier
/// Multiplier equates to 1 + this
var/ability_modifier = null
/// Growth rate modifier
/// Multiplier equates to 1 + this
var/growth_modifier = null
/// Personality traits the child may get
var/list/personality_traits = null
/// Offspring color probability modifiers
var/list/color_chances = null
/datum/element/raptor_food/Attach(obj/item/target, attack_modifier, health_modifier, speed_modifier, ability_modifier, growth_modifier, list/personality_traits, list/color_chances)
. = ..()
if (!isitem(target))
return ELEMENT_INCOMPATIBLE
src.attack_modifier = attack_modifier
src.health_modifier = health_modifier
src.speed_modifier = speed_modifier
src.ability_modifier = ability_modifier
src.growth_modifier = growth_modifier
src.personality_traits = personality_traits
src.color_chances = color_chances
RegisterSignal(target, COMSIG_ITEM_EATEN_BY_BASIC_MOB, PROC_REF(on_eaten))
RegisterSignal(target, COMSIG_ATOM_EXAMINE_MORE, PROC_REF(on_examine_more))
/datum/element/raptor_food/Detach(datum/source, ...)
UnregisterSignal(source, list(COMSIG_ITEM_EATEN_BY_BASIC_MOB, COMSIG_ATOM_EXAMINE_MORE))
return ..()
/datum/element/raptor_food/proc/on_examine_more(obj/item/source, mob/examiner, list/examine_list)
SIGNAL_HANDLER
if (!istype(examiner.buckled, /mob/living/basic/raptor))
return
// Just to check for priority
var/strognest_effect = max(attack_modifier, health_modifier, speed_modifier, ability_modifier, growth_modifier, 0)
// Only personality or color probability effects, or just pure negatives
if (strognest_effect == 0)
examine_list += span_notice("You reckon this would have unique effects on your raptor's offspring if you fed it to them...")
return
if (strognest_effect == attack_modifier)
examine_list += span_notice("You reckon this would have make your raptor's offspring stronger if you fed it to them...")
else if (strognest_effect == health_modifier)
examine_list += span_notice("You reckon this would have make your raptor's offspring tougher if you fed it to them...")
else if (strognest_effect == speed_modifier)
examine_list += span_notice("You reckon this would have make your raptor's offspring faster if you fed it to them...")
else if (strognest_effect == ability_modifier)
examine_list += span_notice("You reckon this would have make your raptor's offspring more capable if you fed it to them...")
else if (strognest_effect == growth_modifier)
examine_list += span_notice("You reckon this would have make your raptor's offspring grow faster if you fed it to them...")
/datum/element/raptor_food/proc/on_eaten(obj/item/source, mob/living/eater, mob/living/feeder)
SIGNAL_HANDLER
if (!istype(eater, /mob/living/basic/raptor))
return
var/mob/living/basic/raptor/raptor = eater
var/list/our_food = raptor.inherited_stats.foods_eaten[source.type]
if (our_food)
our_food["amount"] += 1
return
raptor.inherited_stats.foods_eaten[source.type] = list(
"amount" = 1,
"attack" = attack_modifier,
"health" = health_modifier,
"speed" = speed_modifier,
"ability" = ability_modifier,
"growth" = growth_modifier,
"traits" = personality_traits?.Copy(),
"color_chances" = color_chances?.Copy(),
)