Files
Bubberstation/code/datums/components/growth_and_differentiation.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

159 lines
6.8 KiB
Plaintext

/**
* ### Growth and Differentiation Component: Used to randomly "grow" a creature into a new entity over its lifespan.
*
* If we are passed a typepath, we will 100% grow into that type. However, if we are not passed a typepath, we will pick one from a subtype of the parent we were applied to!
*/
/datum/component/growth_and_differentiation
/// What this mob turns into when fully grown.
var/growth_path
/// Failover for how much time we have until we fully grow. If passed as null, we eschew setting up the timer.
/// Remember: We can grow earlier than this if the randomness rolls turn out to be in our favor though!
var/growth_time
/// Integer - Probability we grow per SPT_PROB
var/growth_probability
/// Integer - The lower bound for the percentage we have to grow before we can differentiate.
var/lower_growth_value
/// Integer - The upper bound for the percentage we have to grow before we can differentiate.
var/upper_growth_value
/// List of signals we kill on ourselves when we grow.
var/list/signals_to_kill_on
/// Optional callback for checks to see if we're okay to grow.
var/datum/callback/optional_checks
/// Optional callback in case we wish to override the default grow() behavior. Assume we supersede the change_mob_type() call if we have this set.
var/datum/callback/optional_grow_behavior
/// ID for the failover timer.
var/timer_id
/// Percentage we have grown.
var/percent_grown = 0
/// Are we ready to grow? This is just in case we fail our checks and need to wait until the next tick.
/// We only really need this because we have two competing systems, the timer and the probability-based growth. When one succeeds, this component is considered successful in growth,
/// and will actively try to grow the mob (only barred by optional checks).
var/ready_to_grow = FALSE
/datum/component/growth_and_differentiation/Initialize(
growth_time,
growth_path,
growth_probability,
lower_growth_value,
upper_growth_value,
scale_with_happiness,
list/signals_to_kill_on,
datum/callback/optional_checks,
datum/callback/optional_grow_behavior,
)
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
src.growth_path = growth_path
src.growth_time = growth_time
src.growth_probability = growth_probability
src.lower_growth_value = lower_growth_value
src.upper_growth_value = upper_growth_value
src.optional_checks = optional_checks
src.optional_grow_behavior = optional_grow_behavior
if(islist(signals_to_kill_on))
src.signals_to_kill_on = signals_to_kill_on
RegisterSignals(parent, src.signals_to_kill_on, PROC_REF(stop_component_processing_entirely))
if(scale_with_happiness)
if(!HAS_TRAIT(parent, TRAIT_MOB_RELAY_HAPPINESS))
AddComponent(/datum/component/happiness)
RegisterSignal(parent, COMSIG_MOB_HAPPINESS_CHANGE, PROC_REF(on_happiness_change))
// If we haven't started the round, we can't do timer stuff. Let's wait in case we're mapped in or something.
if(!SSticker.HasRoundStarted() && !isnull(growth_time))
RegisterSignal(SSticker, COMSIG_TICKER_ROUND_STARTING, PROC_REF(comp_on_round_start))
return
return setup_growth_tracking()
/datum/component/growth_and_differentiation/Destroy(force)
STOP_PROCESSING(SSdcs, src)
deltimer(timer_id)
optional_checks = null
optional_grow_behavior = null
return ..()
/// Wrapper for qdel() so we can pass it in RegisterSignals(). I hate it here too.
/datum/component/growth_and_differentiation/proc/stop_component_processing_entirely()
SIGNAL_HANDLER
qdel(src)
/// What we invoke when the round starts so we can set up our timer.
/datum/component/growth_and_differentiation/proc/comp_on_round_start()
SIGNAL_HANDLER
setup_growth_tracking()
UnregisterSignal(SSticker, COMSIG_TICKER_ROUND_STARTING)
/// Sets up the two different systems for growth: the timer and the probability based one. Both can coexist. Return COMPONENT_INCOMPATIBLE if we fail to set up either.
/datum/component/growth_and_differentiation/proc/setup_growth_tracking()
var/did_we_add_at_least_one_thing = FALSE
if(!isnull(growth_time))
timer_id = addtimer(CALLBACK(src, PROC_REF(grow), FALSE), growth_time, TIMER_STOPPABLE)
if(!isnull(timer_id)) // realistically shouldn't happen considering how hardy addtimer() is but you can never be too sure
did_we_add_at_least_one_thing = TRUE
if(!isnull(growth_probability))
START_PROCESSING(SSdcs, src)
did_we_add_at_least_one_thing = TRUE
if(!did_we_add_at_least_one_thing)
stack_trace("Growth and Differentiation Component: Neither growth time nor probability were set! This component is useless!")
return COMPONENT_INCOMPATIBLE // if we're invoked via COMSIG_TICKER_ROUND_STARTING this won't do anything (and shouldn't be invoked since we nullcheck growth_time before adding that signal anyways)
return null // just for explicitness's sake, if they ever change Component's Initialize to have more return values make sure this is the one for "Success!"
/datum/component/growth_and_differentiation/process(seconds_per_tick) // check the prob we were passed in, and if we're lucky, grow!
if(ready_to_grow)
INVOKE_ASYNC(src, PROC_REF(grow), FALSE)
return
if(percent_grown >= 100)
ready_to_grow = TRUE
INVOKE_ASYNC(src, PROC_REF(grow), FALSE) // lets not waste any more of SSmobs time this tick.
return
if(SPT_PROB(growth_probability, seconds_per_tick))
percent_grown += rand(lower_growth_value, upper_growth_value)
/datum/component/growth_and_differentiation/proc/on_happiness_change(datum/source, happiness_percentage)
SIGNAL_HANDLER
var/probability_to_add = initial(growth_probability) * happiness_percentage
growth_probability = min(initial(growth_probability) + probability_to_add, 100)
/// Grows the mob into its new form.
/datum/component/growth_and_differentiation/proc/grow(silent)
if(!isnull(optional_checks) && !optional_checks.Invoke()) // we failed our checks somehow, but we're still ready to grow. Let's wait until next tick to see if our circumstances have changed.
ready_to_grow = TRUE
return
var/mob/living/old_mob = parent
if (old_mob.stat == DEAD)
qdel(src) // assume that we are priced out of growth once dead
return
STOP_PROCESSING(SSdcs, src)
if(!isnull(optional_grow_behavior)) // basically growth_path is OK to be null but only if we have an optional grow behavior.
optional_grow_behavior.Invoke()
return
if(!ispath(growth_path, /mob/living))
CRASH("Growth and Differentiation Component: Growth path was not a mob type! If you wanted to do something special, please put it in the optional_grow_behavior callback instead!")
var/mob/living/new_mob = growth_path
var/new_mob_name = initial(new_mob.name)
if(!silent)
old_mob.visible_message(span_warning("[old_mob] grows into \a [new_mob_name]!"))
var/mob/living/transformed_mob = old_mob.change_mob_type(growth_path, old_mob.loc, new_name = new_mob_name, delete_old_mob = TRUE)
if(initial(new_mob.unique_name))
transformed_mob.set_name()
ADD_TRAIT(transformed_mob, TRAIT_MOB_HATCHED, INNATE_TRAIT)