From a04d570f9214c29e406b229cc191e1a5d494b8eb Mon Sep 17 00:00:00 2001 From: VerySoft Date: Sun, 8 Dec 2024 19:29:00 -0500 Subject: [PATCH] wip --- code/modules/mob/living/Magic/healing.dm | 50 +++++++++ code/modules/mob/living/Magic/magic.dm | 136 +++++++++++++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 code/modules/mob/living/Magic/healing.dm create mode 100644 code/modules/mob/living/Magic/magic.dm diff --git a/code/modules/mob/living/Magic/healing.dm b/code/modules/mob/living/Magic/healing.dm new file mode 100644 index 0000000000..af2c60f426 --- /dev/null +++ b/code/modules/mob/living/Magic/healing.dm @@ -0,0 +1,50 @@ +//RS FILE +/////HEALING MAGIC///// + +#define HEALING_MAGIC "healing" + +/mob/living/proc/regenerate_other() + set name = "Regenerate" + set desc = "Spend energy to heal physical wounds in another creature." + set category = "Magic" + + if(!etching) + to_chat("You can't do magic.") //:C + return FALSE + + var/spell_lv = 1 //Determines how many slots you need devoted to this magic + var/spell_class = HEALING_MAGIC //Used with above, this is the kind of magic you need + var/req_standing = TRUE //If true, must be on your feet and unrestrained + var/req_corporeal = TRUE //If true, must not be phased out or otherwise ghostly + var/req_visible = TRUE //If true, must not be invisible + var/cost = 0 //Automatically determined by a variety of factors + + if(!admin_magic) + cost = etching.calculate_magic_cost(spell_class,spell_lv) + + if(!consider_magic(cost,spell_class,spell_lv,req_standing,req_corporeal,req_visible)) + return FALSE + + //Unique stuff goes beween here! + + var/list/viewed = oviewers(1) + var/list/targets = list() + for(var/mob/living/L in viewed) + targets += L + if(!targets.len) + to_chat(src,"Nobody nearby to mend!") + return FALSE + + var/mob/living/target = tgui_input_list(src,"Pick someone to mend:","Mend Other", targets) + if(!target) + return FALSE + + target.add_modifier(/datum/modifier/shadekin/heal_boop,1 MINUTE) + playsound(src, 'sound/effects/EMPulse.ogg', 75, 1) + visible_message("\The [src] touches \the [target]...") + face_atom(target) + + //STOP BEING UNIQUE + + consume_mana(cost, spell_lv) + return TRUE diff --git a/code/modules/mob/living/Magic/magic.dm b/code/modules/mob/living/Magic/magic.dm new file mode 100644 index 0000000000..1499ae525d --- /dev/null +++ b/code/modules/mob/living/Magic/magic.dm @@ -0,0 +1,136 @@ +//RS FILE +/* +TO DO: +make sure multiple instances of grant xp are additive, and don't overwrite +*/ + +#define BASE_MAGIC_COOLDOWN 15 +#define BASE_MAGIC_COST 33 + +/mob/living/proc/consider_magic(cost,spell_class,spell_lv,req_standing,req_corporeal,req_visible) + if(!etching.consider_magic(cost,spell_class,spell_lv)) + return FALSE + if(req_standing && (resting||weakened||buckled)) //Buckled is assuming that we might be restrained. Not bothering with checking carbon handcuffs, since nets exist and I am pretty sure that's just a buckle + to_chat(src, "You need to be standing and free to move around to do that!") + return FALSE + if(req_corporeal && incorporeal_move) + to_chat(src, "Can't do that while phased out!") + return FALSE + if(req_visible && invisibility) + to_chat(src, "Can't do that without revealing yourself!") + return FALSE + return TRUE + +/mob/living/proc/consume_mana(cost,spell_lv) + if(cost <= 0) + return + etching.consume_mana(cost,spell_lv) + +/datum/etching + var/true_name //Magic bs + var/mana = 0 //How much you have + var/max_mana = 0 //How much you could have + var/mana_regen = 0 //How fast it comes back + var/mana_cooldown = 0 //How soon you can do it again + var/mana_efficiency = 1 //Multiplier for how efficiently you use your mana + var/core //Head/body + var/l_arm + var/r_arm + var/l_leg + var/r_leg + +/datum/etching/Destroy() + . = ..() + ourmob = null + +/datum/etching/process_etching() + . = ..() + if(mana < max_mana) + mana += mana_regen + if(mana_cooldown) + mana_cooldown -- + +/datum/etching/proc/consume_mana(cost,spell_lv) + var/howmuch = mana - cost + if(howmuch < 0) + return FALSE + mana = howmuch + mana_cooldown = (BASE_MAGIC_COOLDOWN * spell_lv) //life tick * lv = about 30 seconds per level + return TRUE + +///datum/etching/update_etching(mode,value) +// . = ..() + +/datum/etching/proc/report_magic() + var/extra = FALSE + if(core) + . += "Core: [core]\n" + extra = TRUE + if(l_arm) + . += "[l_arm]\n" + extra = TRUE + if(r_arm) + . += "[r_arm]\n" + extra = TRUE + if(l_arm) + . += "[l_leg]\n" + extra = TRUE + if(r_leg) + . += "[r_leg]\n" + extra = TRUE + + if(extra) + . += "\n" + + return . + +/datum/etching/proc/consider_magic(cost,spell_class,spell_lv) + if(ourmob.admin_magic) + return TRUE + if(mana_cooldown) + to_chat(ourmob, "You are still recovering! (([mana_cooldown]))") + return FALSE + if(cost > mana) + to_chat(ourmob, "You haven't got enough mana! (([mana]/[cost]))") + return FALSE + +// if(not some_kind_of_level_check()) +// return FALSE + + return TRUE + +/datum/etching/proc/calculate_magic_cost(spell_class,spell_lv) + return (BASE_MAGIC_COST * spell_lv) * mana_efficiency + +/datum/etching/proc/magic_load(var/list/load) + + if(!load) + return + + true_name = load["true_name"] + core = load["core"] + l_arm = load["l_arm"] + r_arm = load["r_arm"] + l_leg = load["l_leg"] + r_leg = load["r_leg"] + +/datum/etching/proc/magic_save() + var/list/to_save = list( + "true_name" = true_name, + "core" = core, + "l_arm" = l_arm, + "r_arm" = r_arm, + "l_leg" = l_leg, + "r_leg" = r_leg + ) + + return to_save + +/datum/etching/report_status() + . = ..() + + var/our_magic = report_magic() + if(our_magic) + if(.) + . += "\n" + . += our_magic