Files
Paradise/code/datums/spells/genetic.dm
Charlie ded049a902 Spell cooldown refactor (#18327)
* Squashed commit of the following:

commit 979fe5287c3dd33cd5d69bdd968beae245984f2e
Author: hal9000PR <charliesteeples@outlook.com>
Date:   Sat Jul 9 23:40:53 2022 +0100

    guts the old system

* refactors spell cooldowns into a handler

* charge datum

* garbage collection

* cleanup, renames cooldown var

* review changes

* boo cooldown fix

* styling

Co-authored-by: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>

Co-authored-by: Sirryan2002 <80364400+Sirryan2002@users.noreply.github.com>
2022-07-23 00:00:42 +02:00

37 lines
1.2 KiB
Plaintext

/obj/effect/proc_holder/spell/genetic
desc = "This spell inflicts a set of mutations and disabilities upon the target."
var/list/active_on = list()
var/list/traits = list() // traits
var/list/mutations = list() // mutation defines. Set these in Initialize. Refactor this nonsense one day
var/duration = 100 // deciseconds
/obj/effect/proc_holder/spell/genetic/cast(list/targets, mob/user = usr)
for(var/mob/living/target in targets)
if(!target.dna)
continue
for(var/A in mutations)
target.dna.SetSEState(A, TRUE)
singlemutcheck(target, A, MUTCHK_FORCED)
for(var/A in traits)
ADD_TRAIT(target, A, MAGIC_TRAIT)
active_on += target
target.regenerate_icons()
if(duration < base_cooldown)
addtimer(CALLBACK(src, .proc/remove, target), duration, TIMER_OVERRIDE|TIMER_UNIQUE)
/obj/effect/proc_holder/spell/genetic/Destroy()
for(var/V in active_on)
remove(V)
return ..()
/obj/effect/proc_holder/spell/genetic/proc/remove(mob/living/carbon/target)
active_on -= target
if(!QDELETED(target))
for(var/A in mutations)
target.dna.SetSEState(A, FALSE)
singlemutcheck(target, A, MUTCHK_FORCED)
for(var/A in traits)
REMOVE_TRAIT(target, A, MAGIC_TRAIT)
target.regenerate_icons()