mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-23 03:57:13 +01:00
Refactors spell targeting to delegate it to a targeting datum (#16552)
Co-authored-by: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/datum/spell_handler/morph
|
||||
/// How much food it costs the morph to use this
|
||||
var/hunger_cost = 0
|
||||
|
||||
/datum/spell_handler/morph/can_cast(mob/living/simple_animal/hostile/morph/user, charge_check, show_message, obj/effect/proc_holder/spell/spell)
|
||||
if(!istype(user))
|
||||
if(show_message)
|
||||
to_chat(user, "<span class='warning'>You should not be able to use this abilty! Report this as a bug on github please.</span>")
|
||||
return FALSE
|
||||
|
||||
if(user.gathered_food < hunger_cost)
|
||||
if(show_message)
|
||||
to_chat(user, "<span class='warning'>You require at least [hunger_cost] stored food to use this ability!</span>")
|
||||
return FALSE
|
||||
|
||||
return TRUE
|
||||
|
||||
/datum/spell_handler/morph/spend_spell_cost(mob/living/simple_animal/hostile/morph/user, obj/effect/proc_holder/spell/spell)
|
||||
user.use_food(hunger_cost)
|
||||
|
||||
/datum/spell_handler/morph/before_cast(list/targets, mob/living/simple_animal/hostile/morph/user, obj/effect/proc_holder/spell/spell)
|
||||
if(hunger_cost)
|
||||
to_chat(user, "<span class='boldnotice'>You have [user.gathered_food] left to use.</span>")
|
||||
|
||||
/datum/spell_handler/morph/revert_cast(mob/living/simple_animal/hostile/morph/user, obj/effect/proc_holder/spell/spell)
|
||||
user.add_food(hunger_cost)
|
||||
to_chat(user, "<span class='boldnotice'>You have [user.gathered_food] left to use.</span>")
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* The base class for the handler systems spells use.
|
||||
* Subtypes of this class can be added to spells to modify their behaviour and change their can_cast.
|
||||
* Thus allowing for a more modular behaviour system. For example a vampire spell that jaunts can just add the vampire spell_handler to the jaunt spell
|
||||
*/
|
||||
|
||||
/datum/spell_handler
|
||||
|
||||
/datum/spell_handler/proc/can_cast(mob/user, charge_check, show_message, obj/effect/proc_holder/spell/spell)
|
||||
return TRUE
|
||||
|
||||
/datum/spell_handler/proc/spend_spell_cost(mob/user, obj/effect/proc_holder/spell/spell)
|
||||
return
|
||||
|
||||
/datum/spell_handler/proc/revert_cast(mob/user, obj/effect/proc_holder/spell/spell)
|
||||
return
|
||||
|
||||
/datum/spell_handler/proc/before_cast(list/targets, mob/user, obj/effect/proc_holder/spell/spell)
|
||||
return
|
||||
|
||||
/datum/spell_handler/proc/after_cast(list/targets, mob/user, obj/effect/proc_holder/spell/spell)
|
||||
return
|
||||
@@ -0,0 +1,53 @@
|
||||
/datum/spell_handler/vampire
|
||||
var/required_blood
|
||||
/// If the blood cost should be handled by this handler. Or if the spell will handle it itself
|
||||
var/deduct_blood_on_cast = TRUE
|
||||
|
||||
/datum/spell_handler/vampire/can_cast(mob/user, charge_check, show_message, obj/effect/proc_holder/spell/spell)
|
||||
var/datum/vampire/vampire = user.mind.vampire
|
||||
|
||||
if(!vampire)
|
||||
return FALSE
|
||||
|
||||
var/fullpower = vampire.get_ability(/datum/vampire_passive/full)
|
||||
|
||||
if(user.stat >= DEAD) // TODO check if needed
|
||||
if(show_message)
|
||||
to_chat(user, "<span class='warning'>Not while you're dead!</span>")
|
||||
return FALSE
|
||||
|
||||
if(vampire.nullified >= VAMPIRE_COMPLETE_NULLIFICATION && !fullpower) // above 100 nullification vampire powers are useless
|
||||
if(show_message)
|
||||
to_chat(user, "<span class='warning'>Something is blocking your powers!</span>")
|
||||
return FALSE
|
||||
if(vampire.bloodusable < required_blood)
|
||||
if(show_message)
|
||||
to_chat(user, "<span class='warning'>You require at least [required_blood] units of usable blood to do that!</span>")
|
||||
return FALSE
|
||||
//chapel check
|
||||
if(istype(get_area(user), /area/chapel) && !fullpower)
|
||||
if(show_message)
|
||||
to_chat(user, "<span class='warning'>Your powers are useless on this holy ground.</span>")
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
/datum/spell_handler/vampire/spend_spell_cost(mob/user, obj/effect/proc_holder/spell/spell)
|
||||
if(!required_blood || !deduct_blood_on_cast) //don't take the blood yet if this is false!
|
||||
return
|
||||
|
||||
var/datum/vampire/vampire = user.mind.vampire
|
||||
|
||||
vampire.bloodusable -= calculate_blood_cost(vampire)
|
||||
|
||||
/datum/spell_handler/vampire/proc/calculate_blood_cost(datum/vampire/vampire)
|
||||
var/blood_cost_modifier = 1 + vampire.nullified / 100
|
||||
var/blood_cost = round(required_blood * blood_cost_modifier)
|
||||
return blood_cost
|
||||
|
||||
/datum/spell_handler/vampire/after_cast(list/targets, mob/user, obj/effect/proc_holder/spell/spell)
|
||||
if(!required_blood)
|
||||
return
|
||||
var/datum/vampire/vampire = user.mind.vampire
|
||||
to_chat(user, "<span class='boldnotice'>You have [vampire.bloodusable] left to use.</span>")
|
||||
SSblackbox.record_feedback("tally", "vampire_powers_used", 1, "[spell]") // Only log abilities which require blood
|
||||
|
||||
Reference in New Issue
Block a user