Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds chaplain mechanic 'faith'. Uses it for healing #17597

Merged
merged 11 commits into from Jan 17, 2024
1 change: 1 addition & 0 deletions _std/__std.dme
Expand Up @@ -55,6 +55,7 @@
#include "defines\economy.dm"
#include "defines\ephemeral.dm"
#include "defines\events.dm"
#include "defines\faith.dm"
#include "defines\floors.dm"
#include "defines\fluid.dm"
#include "defines\food.dm"
Expand Down
11 changes: 11 additions & 0 deletions _std/defines/faith.dm
@@ -0,0 +1,11 @@
#define FAITH_STARTING 1000

//lifeprocess faith generation
#define FAITH_GEN_BASE 5

// bible healing
#define FAITH_HEAL_CHANCE 40
#define FAITH_HEAL_CHANCE_MOD 0.02 // multiplied by faith, then added to the base
#define FAITH_HEAL_USE_FRACTION 0.025
#define FAITH_HEAL_CAP 125 // in used faith
#define FAITH_HEAL_BONUS 0.2 // multiplied by used faith
10 changes: 10 additions & 0 deletions code/datums/traits.dm
Expand Up @@ -538,6 +538,16 @@ ABSTRACT_TYPE(/datum/trait/job)
desc = "Subject is trained in cultural and psychological matters."
id = "training_chaplain"

var/faith = FAITH_STARTING

New()
..()
START_TRACKING

disposing()
STOP_TRACKING
..()

/datum/trait/job/medical
name = "Medical Training"
desc = "Subject is a proficient surgeon."
Expand Down
3 changes: 3 additions & 0 deletions code/mob/living/life/Life.dm
Expand Up @@ -174,6 +174,7 @@
add_lifeprocess(/datum/lifeprocess/viruses)
add_lifeprocess(/datum/lifeprocess/blindness)
add_lifeprocess(/datum/lifeprocess/radiation)
add_lifeprocess(/datum/lifeprocess/faith)

/mob/living/carbon/cube/restore_life_processes()
..()
Expand All @@ -193,6 +194,7 @@
add_lifeprocess(/datum/lifeprocess/sight)
add_lifeprocess(/datum/lifeprocess/blindness)
add_lifeprocess(/datum/lifeprocess/disability)
add_lifeprocess(/datum/lifeprocess/faith)

/mob/living/silicon/hivebot/restore_life_processes()
..()
Expand All @@ -216,6 +218,7 @@
add_lifeprocess(/datum/lifeprocess/robot_oil)
add_lifeprocess(/datum/lifeprocess/robot_locks)
add_lifeprocess(/datum/lifeprocess/disability)
add_lifeprocess(/datum/lifeprocess/faith)


/mob/living/silicon/drone/restore_life_processes()
Expand Down
43 changes: 43 additions & 0 deletions code/mob/living/life/faith.dm
@@ -0,0 +1,43 @@

/datum/lifeprocess/faith

process(var/datum/gas_mixture/environment)
var/mult = get_multiplier()

if (isunconscious(owner) || isdead(owner) || !owner.mind || isghostcritter(owner))
// do nothing
else if (owner.traitHolder.hasTrait("training_chaplain"))
modify_chaplain_faith(owner, min(FAITH_STARTING / max(1, get_chaplain_faith(owner)), 5) * mult) // helps chaplains get back to normal
else if (!istype(get_area(owner), /area/station/chapel))
// others need to be in the chapel
else if (isvampire(owner) || isvampiricthrall(owner) || iswraith(owner) || owner.bioHolder.HasEffect("revenant"))
// vampires are unholy and will not produce faith unless they are a chaplain
else if (owner.traitHolder.hasTrait("atheist"))
else
add_faith(FAITH_GEN_BASE * mult)
..()

/proc/add_faith(amount)
for (var/datum/trait/job/chaplain/chap in by_type[/datum/trait/job/chaplain])
chap.faith += amount

/proc/get_chaplain_trait(mob/target)
var/datum/traitHolder/TH = target.traitHolder
for(var/id in TH.traits)
var/datum/trait/T = TH.traits[id]
if (istype(T, /datum/trait/job/chaplain))
var/datum/trait/job/chaplain/chap = T
return chap

/proc/get_chaplain_faith(mob/target)
var/datum/trait/job/chaplain/chap_trait = get_chaplain_trait(target)
if (chap_trait)
return chap_trait.faith

/proc/modify_chaplain_faith(mob/target, amount)
var/datum/trait/job/chaplain/chap_trait = get_chaplain_trait(target)
if (chap_trait)
chap_trait.faith += amount
return chap_trait.faith


34 changes: 28 additions & 6 deletions code/obj/item/storage/bible.dm
Expand Up @@ -13,7 +13,7 @@
flags = FPRINT | TABLEPASS | NOSPLASH
event_handler_flags = USE_FLUID_ENTER | IS_FARTABLE
var/mob/affecting = null
var/heal_amt = 10
var/heal_amt = 5

New()
..()
Expand All @@ -29,13 +29,30 @@
..()
STOP_TRACKING

proc/do_heal_amt(mob/user) // also handles using faith
var/faith = get_chaplain_faith(user)
var/used_faith = min(faith * FAITH_HEAL_USE_FRACTION, FAITH_HEAL_CAP)
modify_chaplain_faith(user, -used_faith)
return heal_amt + used_faith * FAITH_HEAL_BONUS + rand(-3, 3)

proc/do_heal_message(var/mob/user, var/mob/target, amount)
switch(amount)
if (1 to 8)
target.visible_message(SPAN_ALERT("<B>[user] heals [target] mending [his_or_her(target)] wounds!</B>"))
if (9 to 15)
target.visible_message(SPAN_ALERT("<B>[user] heals [target] with the power of Christ!</B>"))
if (16 to 24)
target.visible_message(SPAN_ALERT("<B>[user] heals [target] by the will of the LORD!</B>"))
if (25 to INFINITY)
target.visible_message(SPAN_ALERT("<B>[user] heals [target] in service of heaven!</B>"))

proc/bless(mob/M as mob, var/mob/user)
if (isvampire(M) || isvampiricthrall(M) || iswraith(M) || M.bioHolder.HasEffect("revenant"))
M.visible_message(SPAN_ALERT("<B>[M] burns!"))
var/zone = "chest"
if (user.zone_sel)
zone = user.zone_sel.selecting
M.TakeDamage(zone, 0, heal_amt)
M.TakeDamage(zone, 0, do_heal_amt(user))
JOB_XP(user, "Chaplain", 2)
else
var/mob/living/H = M
Expand All @@ -62,8 +79,13 @@
if (S)
S.set_up(5, 0, T, null, "#000000")
S.start()
M.HealDamage("All", heal_amt, heal_amt)
if(prob(40))
var/heal = do_heal_amt(user)
M.HealDamage("All", heal, heal)
do_heal_message(user, M, heal)
if (!ON_COOLDOWN(src, "faith_sound", 1.5 SECONDS))
SPAWN(1 DECI SECOND)
playsound(src.loc, 'sound/effects/faithbiblewhack.ogg', 10, FALSE, -1, (rand(94,108)/100))
if(prob(30 + heal))
JOB_XP(user, "Chaplain", 1)

attackby(var/obj/item/W, var/mob/user)
Expand All @@ -80,6 +102,7 @@
boutput(user, SPAN_ALERT("The book sizzles in your hands."))
user.TakeDamage(user.hand == LEFT_HAND ? "l_arm" : "r_arm", 0, 10)
return
var/faith = get_chaplain_faith(user)
if (user.bioHolder && user.bioHolder.HasEffect("clumsy") && prob(50))
user.visible_message(SPAN_ALERT("<b>[user]</b> fumbles and drops [src] on [his_or_her(user)] foot."))
random_brute_damage(user, 10)
Expand All @@ -97,9 +120,8 @@
// ******* Check
var/is_undead = isvampire(target) || iswraith(target) || target.bioHolder.HasEffect("revenant")
var/is_atheist = target.traitHolder?.hasTrait("atheist")
if (ishuman(target) && prob(60) && !(is_atheist && !is_undead))
if (ishuman(target) && prob(FAITH_HEAL_CHANCE + faith * FAITH_HEAL_CHANCE_MOD) && !(is_atheist && !is_undead))
bless(target, user)
target.visible_message(SPAN_ALERT("<B>[user] heals [target] with the power of Christ!</B>"))
var/deity = is_atheist ? "a god you don't believe in" : "Christ"
boutput(target, SPAN_ALERT("May the power of [deity] compel you to be healed!"))
var/healed = is_undead ? "damaged undead" : "healed"
Expand Down
1 change: 1 addition & 0 deletions goonstation.dme
Expand Up @@ -569,6 +569,7 @@ var/datum/preMapLoad/preMapLoad = new
#include "code\mob\living\life\critical.dm"
#include "code\mob\living\life\decomposition.dm"
#include "code\mob\living\life\disability.dm"
#include "code\mob\living\life\faith.dm"
#include "code\mob\living\life\fire.dm"
#include "code\mob\living\life\health_mon.dm"
#include "code\mob\living\life\hud.dm"
Expand Down
Binary file added sound/effects/faithbiblewhack.ogg
Binary file not shown.