Files
Bubberstation/code/datums/components/anti_magic.dm
SkyratBot 6dde124398 The nth grown food refactor: Changes MOST unique plant effects into special plant genes/traits! Plant Genes+ (#59107) (#6307)
* Auto doc'd much of grown botany food and plant traits and renamed a buncha variables and parameters to match modern contribution guidelines.
* Cleaned up a good bit of plant gene code left over from the prior refactor and modernized some of it.

All plant effects that were once unique to a plant are now un-graftable, un-mutatable, un-shearable plant traits - called IMMUTABLE traits.
The ultimate goal of this PR was to make all of the hidden, arcane traits that are spread through botany's various plants and add a way to figure out they exist in game. Take omega-weed, for example, which has a maximum volume of 420 units.


What does this mean for the enterprising botanist?

In most cases, all the plants should act the same way. None of the immutable traits are graftable from any of the plants, they cannot be sheared off of the plant, and they cannot be mutated randomly from strange seeds or high instability mutations.

Though, in refactoring these traits, two things have been fixed: Novaflower's on hit and Deathnettle's on hit now proc again. If you aren't aware, Novaflowers apply firestacks and Deathnettles paralyze on hit. They've been in an unreachable code segment for a few years now and i'm not sure if they should be "fixed" or not, since I think they don't need any buffs.


A few other things have changed:
* Liquid Contents can no longer be applied to plants with Hypodermic Prickles, and visa-versa. They already didn't work together, but this means you need to go through an extra step to make LC-deathnettles.
* Killer Tomatos no longer have liquid contents. Didn't really make sense, anyways.

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
2021-06-16 22:40:14 +12:00

55 lines
1.7 KiB
Plaintext

/datum/component/anti_magic
var/magic = FALSE
var/holy = FALSE
var/psychic = FALSE
var/allowed_slots = ~ITEM_SLOT_BACKPACK
var/charges = INFINITY
var/blocks_self = TRUE
var/datum/callback/reaction
var/datum/callback/expire
/datum/component/anti_magic/Initialize(_magic = FALSE, _holy = FALSE, _psychic = FALSE, _allowed_slots, _charges, _blocks_self = TRUE, datum/callback/_reaction, datum/callback/_expire)
if(isitem(parent))
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, .proc/on_equip)
RegisterSignal(parent, COMSIG_ITEM_DROPPED, .proc/on_drop)
else if(ismob(parent))
RegisterSignal(parent, COMSIG_MOB_RECEIVE_MAGIC, .proc/protect)
else
return COMPONENT_INCOMPATIBLE
magic = _magic
holy = _holy
psychic = _psychic
if(_allowed_slots)
allowed_slots = _allowed_slots
if(!isnull(_charges))
charges = _charges
blocks_self = _blocks_self
reaction = _reaction
expire = _expire
/datum/component/anti_magic/proc/on_equip(datum/source, mob/equipper, slot)
SIGNAL_HANDLER
if(!(allowed_slots & slot)) //Check that the slot is valid for antimagic
UnregisterSignal(equipper, COMSIG_MOB_RECEIVE_MAGIC)
return
RegisterSignal(equipper, COMSIG_MOB_RECEIVE_MAGIC, .proc/protect, TRUE)
/datum/component/anti_magic/proc/on_drop(datum/source, mob/user)
SIGNAL_HANDLER
UnregisterSignal(user, COMSIG_MOB_RECEIVE_MAGIC)
/datum/component/anti_magic/proc/protect(datum/source, mob/user, _magic, _holy, _psychic, chargecost, self, list/protection_sources)
SIGNAL_HANDLER
if(((_magic && magic) || (_holy && holy) || (_psychic && psychic)) && (!self || blocks_self))
protection_sources += parent
reaction?.Invoke(user, chargecost, parent)
charges -= chargecost
if(charges <= 0)
expire?.Invoke(user, parent)
qdel(src)
return COMPONENT_BLOCK_MAGIC