Files
Bubberstation/code/datums/components/happiness.dm
Ben10Omintrix 761b14ef7c lavaland raptors (#82537)
## About The Pull Request
adds raptors to lavaland. these are creatures that have been created
through countless xenobiological experiments by nanotrasen to breed an
animal that can withstand the harsh conditions of lavaland and aid
miners. theres now a new ranch miners can access bottom right to the
mining base

![ranch](https://github.com/tgstation/tgstation/assets/138636438/20d9e358-15a5-48e2-aee3-9364ca139e43)
this ranch starts somewhat empty as most raptors have escaped
containment and are now scattered all across lavaland, u can find them
and return them to ur ranch.

in order to tame a raptor, u first need to prove to it that ur a capable
master. when u try to ride it, a little minigame prompt will pop up

![minigame](https://github.com/tgstation/tgstation/assets/138636438/dcc13102-7100-40c8-ae7a-089cd4daf868)
in this game, the bird's icon rapidly changes direction and u have to
quickly click the arrow thats OPPOSITE to the direction its facing
several times before the direction changes. if you fail 3 times itll
knock you off and run away, however if u win it will deem u a suitable
master and listen to your orders.

There's many different breeds of raptors you can find across lavaland,
all with different capabilities:
red raptors: these excel at combat and can be very useful for dealing
with lavaland mobs or defending the node drone
yellow raptors: are very speedy mounts, theyll get u from point A to
point B in record time
green raptors: they are the tankiest type of raptor and are very good
miners. while mounted, they will clear any rock walls in their path
purple raptors: can store items in them. they have a decent storage size
allowing players to carry more items across trips
white raptors: are able to heal other injured raptors. having one in ur
party would be very useful as they can nurse the combat raptors back to
full health when they need it
blue raptors: produce very nutritious milk with healing capabilities.
having 1 or 2 of these back at ur ranch would be very useful
black raptors: by far the rarest breed, its very unlikely that ull be
able to get one of these, but in the case u do, they have the combat
capabilities of the red raptor, speed of the yellow raptor, and
tankiness of the green raptor.

Breeding different colored raptors together can net u an entirely new
colored raptor. each breed has atleast 1 guaranteed combination of
parents that it will result out of.

you will also need to maintain a good friendship bond with ur raptors,
this is done by feeding them, grooming them, and petting them. u can see
the strength of ur bond by SHIFT clicking them. more hearts indicate a
stronger bond

![hearts](https://github.com/tgstation/tgstation/assets/138636438/5662c5a7-2df3-4f98-99f4-a11faa17b569)
having higher friendship bonds means ur raptors will perform better in
combat, and in the case of blue raptors, they will produce more milk.
Maintaining friendship bonds with baby raptors and keeping them happy
will also encourage them to grow faster

U can also analyze raptors using the new raptor-dex device available at
ur ranch

![pokedex](https://github.com/tgstation/tgstation/assets/138636438/82b92c0c-b7db-4a0d-997e-384a69c0ecbe)
the inherit modifiers indicate how strong this raptor's offspring will
be. raptors inherit attack and health stats from both their parents,
breeding raptors with higher inherit modifiers means the offspring will
be stronger.

raptors will also inherit some traits from their parents that will
change how they will act around u and around other raptors, some of them
being:
Playful: raptors will play with their masters and tease them
motherly: raptors will care for baby raptors, this will encourage baby
raptors to grow quicker
depressed: means its hard to keep this raptor happy and friendship bonds
will deteriorate faster if not given enough care.
coward: makes them flee combat if severly injured, ditching u to the
wolves
trouble maker: makes them attack other raptors at the ranch. however,
trouble maker raptors will not attack other trouble maker raptors,
instead they will form posses and bully raptors together. it might be a
good idea to isolate them from the other raptors

raptors primarily consume ores. to feed raptors, you need to place ore
into the food troughs at the ranch. they are too civilized to eat ores
off the ground or directly from ur hand, they will only eat it if its in
their trough

![trough](https://github.com/tgstation/tgstation/assets/138636438/70723cc7-5743-4ace-9955-4307879e7a83)

beautiful raptor sprites by spessmenart! (rest are codersprites)

## Why It's Good For The Game
adds a new layer to lavaland mobs, and gives miners new interesting
tools and ways to tackle the challenges of lavaland.

## Changelog
🆑 sheets, spacemenart, ben10omintrix, goofball, infrared baron, aofie
add: adds lavaland raptors and the raptor ranch
/🆑

---------

Co-authored-by: Iamgoofball <iamgoofball@gmail.com>
2024-05-16 19:54:00 -07:00

160 lines
5.7 KiB
Plaintext

#define INSPECT_TIMER 10 SECONDS
#define PET_COOLDOWN 10 SECONDS
#define GROOM_COOLDOWN 30 SECONDS
/*
* A component that allows mobs to have happiness levels
*/
/datum/component/happiness
///our current happiness level
var/happiness_level
///our maximum happiness level
var/maximum_happiness
///happiness AI blackboard key
var/blackboard_key
///happiness when we get groomed
var/on_groom_change
///happiness when we get petted
var/on_petted_change
///happiness when we eat
var/on_eat_change
///percentages we should be calling back on
var/list/callback_percentages
///callback when our happiness changes
var/datum/callback/happiness_callback
///how long till we can inspect happiness again?
COOLDOWN_DECLARE(happiness_inspect)
///how long till we can pet it again?
COOLDOWN_DECLARE(pet_cooldown)
///how long till we can groom it again
COOLDOWN_DECLARE(groom_cooldown)
/datum/component/happiness/Initialize(maximum_happiness = 400, blackboard_key = BB_BASIC_HAPPINESS, on_groom_change = 200, on_eat_change = 300, on_petted_change = 30, callback_percentages = list(0, 25, 50, 75, 100), happiness_callback)
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
src.maximum_happiness = maximum_happiness
src.blackboard_key = blackboard_key
src.on_groom_change = on_groom_change
src.on_petted_change = on_petted_change
src.on_eat_change = on_eat_change
src.happiness_callback = happiness_callback
src.callback_percentages = callback_percentages
ADD_TRAIT(parent, TRAIT_SUBTREE_REQUIRED_OPERATIONAL_DATUM, type)
/datum/component/happiness/RegisterWithParent()
if(on_petted_change)
RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_petted))
if(on_groom_change)
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, PROC_REF(on_clean))
if(on_eat_change)
RegisterSignal(parent, COMSIG_MOB_ATE, PROC_REF(on_eat))
RegisterSignal(parent, COMSIG_SHIFT_CLICKED_ON, PROC_REF(view_happiness))
ADD_TRAIT(parent, TRAIT_MOB_RELAY_HAPPINESS, REF(src))
/datum/component/happiness/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_HOSTILE_PRE_ATTACKINGTARGET, COMSIG_COMPONENT_CLEAN_ACT, COMSIG_MOB_ATE))
REMOVE_TRAIT(parent, TRAIT_MOB_RELAY_HAPPINESS, REF(src))
happiness_callback = null
/datum/component/happiness/proc/on_eat(datum/source)
SIGNAL_HANDLER
increase_happiness_level(on_eat_change)
/datum/component/happiness/proc/on_clean(mob/living/source)
SIGNAL_HANDLER
if(!COOLDOWN_FINISHED(src, groom_cooldown))
return
COOLDOWN_START(src, groom_cooldown, GROOM_COOLDOWN)
increase_happiness_level(on_groom_change)
/datum/component/happiness/proc/on_petted(datum/source, mob/living/petter, list/modifiers)
SIGNAL_HANDLER
if(!LAZYACCESS(modifiers, LEFT_CLICK) || petter.combat_mode)
return
pet_animal()
/datum/component/happiness/proc/on_animal_petted(datum/source, mob/living/petter)
SIGNAL_HANDLER
if(petter.combat_mode)
return
pet_animal()
return COMSIG_BASIC_ATTACK_CANCEL_CHAIN
/datum/component/happiness/proc/pet_animal()
if(!COOLDOWN_FINISHED(src, pet_cooldown))
return
increase_happiness_level(on_petted_change)
COOLDOWN_START(src, pet_cooldown, PET_COOLDOWN)
/datum/component/happiness/proc/increase_happiness_level(amount)
happiness_level = min(happiness_level + amount, maximum_happiness)
var/mob/living/living_parent = parent
new /obj/effect/temp_visual/heart(living_parent.loc)
living_parent.spin(spintime = 2 SECONDS, speed = 1)
START_PROCESSING(SSprocessing, src)
/datum/component/happiness/proc/view_happiness(mob/living/source, mob/living/clicker)
if(!istype(clicker) || !COOLDOWN_FINISHED(src, happiness_inspect) || !clicker.CanReach(source))
return
var/list/offset_to_add = get_icon_dimensions(source.icon)
var/y_position = offset_to_add["height"] + 1
var/obj/effect/overlay/happiness_overlay/hearts = new
hearts.pixel_y = y_position
hearts.set_hearts(happiness_level/maximum_happiness)
source.vis_contents += hearts
COOLDOWN_START(src, happiness_inspect, INSPECT_TIMER)
/datum/component/happiness/process()
var/mob/living/living_parent = parent
var/happiness_percentage = happiness_level/maximum_happiness
living_parent.ai_controller?.set_blackboard_key(blackboard_key, happiness_percentage)
var/check_percentage_in_list = round(happiness_percentage * 100, 1)
if(check_percentage_in_list in callback_percentages)
SEND_SIGNAL(parent, COMSIG_MOB_HAPPINESS_CHANGE, happiness_percentage)
happiness_callback?.Invoke(happiness_percentage)
if(happiness_level <= 0)
return PROCESS_KILL
var/modifier = living_parent.ai_controller?.blackboard[BB_BASIC_DEPRESSED] ? 2 : 1
happiness_level = max(0, happiness_level - modifier)
/obj/effect/overlay/happiness_overlay
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
anchored = TRUE
vis_flags = VIS_INHERIT_DIR | VIS_INHERIT_PLANE
layer = ABOVE_HUD_PLANE
///how many hearts should we display
VAR_PRIVATE/hearts_percentage
///icon of our heart
var/heart_icon = 'icons/effects/effects.dmi'
/obj/effect/overlay/happiness_overlay/Initialize(mapload)
. = ..()
QDEL_IN(src, 5 SECONDS)
/obj/effect/overlay/happiness_overlay/proc/set_hearts(happiness_percentage)
hearts_percentage = happiness_percentage
update_appearance(UPDATE_OVERLAYS)
/obj/effect/overlay/happiness_overlay/update_overlays()
. = ..()
var/static/list/heart_positions = list(-13, -5, 3, 11)
var/display_amount = round(length(heart_positions) * hearts_percentage, 1)
for(var/index in 1 to length(heart_positions))
var/heart_icon_state = display_amount >= index ? "full_heart" : "empty_heart"
var/mutable_appearance/display_icon = mutable_appearance(icon = heart_icon, icon_state = heart_icon_state, layer = ABOVE_HUD_PLANE)
display_icon.pixel_x = heart_positions[index]
. += display_icon
#undef INSPECT_TIMER
#undef PET_COOLDOWN
#undef GROOM_COOLDOWN