diff --git a/code/modules/mob/living/simple_animal/friendly/cat.dm b/code/modules/mob/living/simple_animal/friendly/cat.dm index 95a1d100161..5f977bfd508 100644 --- a/code/modules/mob/living/simple_animal/friendly/cat.dm +++ b/code/modules/mob/living/simple_animal/friendly/cat.dm @@ -37,12 +37,85 @@ icon_resting = "cat_rest" gender = FEMALE gold_core_spawnable = CHEM_MOB_SPAWN_INVALID + var/list/family = list() + var/memory_saved = 0 + var/list/children = list() //Actual mob instances of children + var/cats_deployed = 0 + +/mob/living/simple_animal/pet/cat/Runtime/New() + Read_Memory() + ..() + +/mob/living/simple_animal/pet/cat/Runtime/Life() + if(!cats_deployed && ticker.current_state >= GAME_STATE_SETTING_UP) + Deploy_The_Cats() + if(!stat && ticker.current_state == GAME_STATE_FINISHED && !memory_saved) + Write_Memory() + ..() + +/mob/living/simple_animal/pet/cat/Runtime/make_babies() + var/mob/baby = ..() + if(baby) + children += baby + return baby + +/mob/living/simple_animal/pet/cat/Runtime/death() + if(!memory_saved) + Write_Memory(1) + ..() + +/mob/living/simple_animal/pet/cat/Runtime/proc/Read_Memory() + var/savefile/S = new /savefile("data/npc_saves/Runtime.sav") + S["family"] >> family + + if(isnull(family)) + family = list() + +/mob/living/simple_animal/pet/cat/Runtime/proc/Write_Memory(dead) + var/savefile/S = new /savefile("data/npc_saves/Runtime.sav") + family = list() + if(!dead) + for(var/mob/living/simple_animal/pet/cat/kitten/C in children) + if(istype(C,type) || C.stat || !C.z || !C.butcher_results) + continue + if(C.type in family) + family[C.type] += 1 + else + family[C.type] = 1 + S["family"] << family + memory_saved = 1 + +/mob/living/simple_animal/pet/cat/Runtime/proc/Deploy_The_Cats() + cats_deployed = 1 + for(var/cat_type in family) + if(family[cat_type] > 0) + for(var/i in 1 to min(family[cat_type],100)) //Limits to about 500 cats, you wouldn't think this would be needed (BUT IT IS) + new cat_type(loc) + /mob/living/simple_animal/pet/cat/handle_automated_action() ..() + if(prob(1)) + custom_emote(1, pick("stretches out for a belly rub.", "wags its tail.", "lies down.")) + icon_state = "[icon_living]_rest" + resting = 1 + update_canmove() + else if (prob(1)) + custom_emote(1, pick("sits down.", "crouches on its hind legs.", "looks alert.")) + icon_state = "[icon_living]_sit" + resting = 1 + update_canmove() + else if (prob(1)) + if (resting) + custom_emote(1, pick("gets up and meows.", "walks around.", "stops resting.")) + icon_state = "[icon_living]" + resting = 0 + update_canmove() + else + custom_emote(1, pick("grooms its fur.", "twitches its whiskers.", "shakes out its coat.")) //MICE! - if(eats_mice && loc && isturf(loc) && !incapacitated()) + if(eats_mice && isturf(loc) && !incapacitated()) for(var/mob/living/simple_animal/mouse/M in view(1,src)) if(!M.stat && Adjacent(M)) custom_emote(1, "splats \the [M]!") @@ -50,13 +123,11 @@ movement_target = null stop_automated_movement = 0 break - - //attempt to mate make_babies() /mob/living/simple_animal/pet/cat/handle_automated_movement() ..() - if(eats_mice && !incapacitated()) + if(!stat && !resting && !buckled) turns_since_scan++ if(turns_since_scan > 5) walk_to(src,0) @@ -75,6 +146,7 @@ stop_automated_movement = 1 walk_to(src,movement_target,0,3) + /mob/living/simple_animal/pet/cat/Proc name = "Proc" @@ -102,4 +174,4 @@ gold_core_spawnable = CHEM_MOB_SPAWN_INVALID eats_mice = 0 atmos_requirements = list("min_oxy" = 0, "max_oxy" = 0, "min_tox" = 0, "max_tox" = 0, "min_co2" = 0, "max_co2" = 0, "min_n2" = 0, "max_n2" = 0) - minbodytemp = 0 \ No newline at end of file + minbodytemp = 0 diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 1aa6c82b4a8..f24068bf35d 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -592,7 +592,7 @@ alone = 0 continue if(alone && partner && children < 3) - new childtype(loc) + return new childtype(loc) /mob/living/simple_animal/say_quote(var/message) var/verb = "says"