Files
Bubberstation/code/modules/mob/living/basic/pets/cat/runtime.dm
Ben10Omintrix ce6f2724cd basic cats and mini kitchen helpers (#79800)
## About The Pull Request
this pr transforms cats into basic pets! cats now have some new
behavior. they can carry fish and hunted mice in their mouths to deliver
it to kittens, and kittens will eat them.


![catmouse](https://github.com/tgstation/tgstation/assets/138636438/8f146be4-c7b2-41d3-8301-734be49b5efc)

![catfish](https://github.com/tgstation/tgstation/assets/138636438/f8df54f2-9183-406d-afbd-f90f415f7f3d)

if a kitten sees you holding food, it will point at you and meow loudly
until u give it the food.
becareful when putting male cats near each other, there is a small
chance they get into a heated argument and meow loudly at each other
until one of them flees.
also added a new small cat house for cats. cats will use these homes if
u build one near them (using 5 wood planks)


![cathouse](https://github.com/tgstation/tgstation/assets/138636438/9515a78c-fdfe-461b-bad2-6b497117c694)

Chefs can craft the cake cat and breadcat. these are useful cats because
they can help the chef around in the kitchen. they will turn stoves and
grills off when food is ready, so they dont burn. and the cake cat will
help the chef decorate his donuts

## Why It's Good For The Game
refactors cats into basic mobs and gives them a deeper ai

## Changelog
🆑
refactor: cats are now basic pets. please report any bugs.
add: the cake cat and bread cat can now help the chef around in the
kitchen
/🆑
2023-11-28 21:51:37 -07:00

100 lines
2.6 KiB
Plaintext

#define RUNTIME_SAVE_DATA "data/npc_saves/Runtime.sav"
#define RUNTIME_JSON_DATA "data/npc_saves/Runtime.json"
#define MAX_CAT_DEPLOY 50
/mob/living/basic/pet/cat/runtime
name = "Runtime"
desc = "GCAT"
icon_state = "cat"
icon_living = "cat"
icon_dead = "cat_dead"
gender = FEMALE
gold_core_spawnable = NO_SPAWN
unique_pet = TRUE
///the family we will bring in when a round starts
var/list/family = null
///saved list of kids
var/list/children = null
/// have we deployed the cats?
var/cats_deployed = FALSE
/// have we saved memory?
var/memory_saved = FALSE
///callback we use to register our family
var/datum/callback/register_family
/mob/living/basic/pet/cat/runtime/Initialize(mapload)
. = ..()
register_family = CALLBACK(src, PROC_REF(Write_Memory))
SSticker.OnRoundend(register_family)
if(mapload)
read_memory()
deploy_the_cats()
if(!prob(5))
return
icon_state = "original"
icon_living = "original"
icon_dead = "original_dead"
update_appearance()
/mob/living/basic/pet/cat/runtime/add_breeding_component()
AddComponent(\
/datum/component/breed,\
can_breed_with = typecacheof(list(/mob/living/basic/pet/cat)),\
baby_path = /mob/living/basic/pet/cat/kitten,\
post_birth = CALLBACK(src, PROC_REF(after_birth)),\
)
/mob/living/basic/pet/cat/runtime/proc/after_birth(mob/living/baby)
if(isnull(baby))
return
LAZYADD(children, baby)
/mob/living/basic/pet/cat/runtime/proc/read_memory()
if(fexists(RUNTIME_SAVE_DATA))
var/savefile/save_data = new(RUNTIME_SAVE_DATA)
save_data["family"] >> family
fdel(RUNTIME_SAVE_DATA)
return
var/json_file = file(RUNTIME_JSON_DATA)
if(!fexists(json_file))
return
var/list/json_list = json_decode(file2text(json_file))
family = json_list["family"]
/mob/living/basic/pet/cat/runtime/Destroy()
LAZYREMOVE(SSticker.round_end_events, register_family)
register_family = null
return ..()
/mob/living/basic/pet/cat/runtime/Write_Memory(dead, gibbed)
. = ..()
if(!.)
return
var/json_file = file(RUNTIME_JSON_DATA)
var/list/file_data = list()
if(!dead)
for(var/mob/living/basic/pet/cat/kitten/kitten in children)
if(kitten.stat == DEAD)
continue
if(kitten.type in family)
family[kitten.type] += 1
continue
family[kitten.type] = 1
file_data["family"] = family
fdel(json_file)
WRITE_FILE(json_file, json_encode(file_data, JSON_PRETTY_PRINT))
/mob/living/basic/pet/cat/runtime/proc/deploy_the_cats()
cats_deployed = TRUE
for(var/cat_type in family)
if(isnull(family[cat_type]))
return
for(var/index in 1 to min(family[cat_type], MAX_CAT_DEPLOY))
new cat_type(loc)
#undef RUNTIME_SAVE_DATA
#undef RUNTIME_JSON_DATA
#undef MAX_CAT_DEPLOY