From f61707c6f930725935bbd4a29e983f30d3d57e98 Mon Sep 17 00:00:00 2001 From: Incoming Date: Mon, 15 Feb 2016 21:20:29 -0500 Subject: [PATCH] Pun Pun has gained a few persistence save file features Whatever Pun Pun is wearing on his/her head and face at round end will still be there at the start of the next round. Back and hands do not save for obvious balance reasons. If Pun Pun dies but leaves an intact corpses his/her successor will be named Pun Pun II and inherit the items his corpse was wearing at the end of the round. If Pun Pun gets gibbed the chain of monkeys is broken and the next round monkey will be a new progenitor with a potentially different name. Obviously their items won't be saved in this case. --- code/__HELPERS/type2type.dm | 13 +++- .../mob/living/carbon/monkey/monkey.dm | 3 +- .../mob/living/carbon/monkey/punpun.dm | 65 +++++++++++++++++++ tgstation.dme | 1 + 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 code/modules/mob/living/carbon/monkey/punpun.dm diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index 8e90ded8dd5..67bbf6d584c 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -574,4 +574,15 @@ for(var/t in test_times) var/B = hex2num(copytext(A,6,0)) return R+G+B - +//Converts a positive interger to its roman numeral equivilent. Ignores any decimals. +//Numbers over 3999 will display with extra "M"s (don't tell the Romans) and can get comically long, so be careful. +/proc/num2roman(A) + var/list/values = list("M" = 1000, "CM" = 900, "D" = 500, "CD" = 400, "C" = 100, "XC" = 90, "L" = 50, "XL" = 40, "X" = 10, "IX" = 9, "V" = 5, "IV" = 4, "I" = 1) + if(!A || !isnum(A)) + return 0 + while(A >= 1) + for(var/i in values) + if(A >= values[i]) + . += i + A -= values[i] + break \ No newline at end of file diff --git a/code/modules/mob/living/carbon/monkey/monkey.dm b/code/modules/mob/living/carbon/monkey/monkey.dm index b1e60e3e517..796ec8b805b 100644 --- a/code/modules/mob/living/carbon/monkey/monkey.dm +++ b/code/modules/mob/living/carbon/monkey/monkey.dm @@ -17,7 +17,8 @@ verbs += /mob/living/proc/mob_sleep verbs += /mob/living/proc/lay_down - gender = pick(MALE, FEMALE) + if(unique_name) //used to exclude pun pun + gender = pick(MALE, FEMALE) real_name = name if(good_mutations.len) //genetic mutations have been set up. initialize() diff --git a/code/modules/mob/living/carbon/monkey/punpun.dm b/code/modules/mob/living/carbon/monkey/punpun.dm new file mode 100644 index 00000000000..737351d8f27 --- /dev/null +++ b/code/modules/mob/living/carbon/monkey/punpun.dm @@ -0,0 +1,65 @@ +/mob/living/carbon/monkey/punpun //except for a few special persistence features, pun pun is just a normal monkey + name = "Pun Pun" //C A N O N + unique_name = 0 + var/ancestor_name + var/ancestor_chain = 1 + var/relic_hat //Note: these two are paths + var/relic_mask + var/memory_saved = 0 + var/list/pet_monkey_names = list("Pun Pun", "Bubbles", "Mojo", "Forever") + +/mob/living/carbon/monkey/punpun/New() + Read_Memory() + if(relic_hat) + equip_to_slot_or_del(new relic_hat, slot_head) + if(relic_mask) + equip_to_slot_or_del(new relic_mask, slot_wear_mask) + if(ancestor_name) + name = ancestor_name + if(ancestor_chain > 1) + name += " [num2roman(ancestor_chain)]" + else + name = pick(pet_monkey_names) + gender = pick(MALE, FEMALE) + ..() + +/mob/living/carbon/monkey/punpun/Life() + if(ticker.current_state == GAME_STATE_FINISHED && !memory_saved) + Write_Memory(0) + ..() + +/mob/living/carbon/monkey/punpun/death(gibbed) + if(!memory_saved || gibbed) + Write_Memory(1,gibbed) + ..() + +/mob/living/carbon/monkey/punpun/proc/Read_Memory() + var/savefile/S = new /savefile("data/npc_saves/Punpun.sav") + S["ancestor_name"] >> ancestor_name + S["ancestor_chain"] >> ancestor_chain + S["relic_hat"] >> relic_hat + S["relic_mask"] >> relic_mask + +/mob/living/carbon/monkey/punpun/proc/Write_Memory(dead, gibbed) + var/savefile/S = new /savefile("data/npc_saves/Punpun.sav") + if(gibbed) + S["ancestor_name"] << null + S["ancestor_chain"] << 1 + S["relic_hat"] << null + S["relic_mask"] << null + return + if(dead) + S["ancestor_name"] << ancestor_name + S["ancestor_chain"] << ancestor_chain + 1 + if(!ancestor_name) //new monkey name this round + S["ancestor_name"] << name + if(head) + S["relic_hat"] << head.type + else + S["relic_hat"] << null + if(wear_mask) + S["relic_mask"] << wear_mask.type + else + S["relic_mask"] << null + if(!dead) + memory_saved = 1 \ No newline at end of file diff --git a/tgstation.dme b/tgstation.dme index 2fb7c791662..9e0ff9b9de4 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1227,6 +1227,7 @@ #include "code\modules\mob\living\carbon\monkey\inventory.dm" #include "code\modules\mob\living\carbon\monkey\life.dm" #include "code\modules\mob\living\carbon\monkey\monkey.dm" +#include "code\modules\mob\living\carbon\monkey\punpun.dm" #include "code\modules\mob\living\carbon\monkey\update_icons.dm" #include "code\modules\mob\living\silicon\death.dm" #include "code\modules\mob\living\silicon\laws.dm"