Allows the antimagic component to react to spells, limits holymelon uses (#41739)

This commit is contained in:
XDTM
2018-12-18 01:09:35 +01:00
committed by yogstation13-bot
parent d6261fc615
commit 37c61983f4
22 changed files with 75 additions and 39 deletions

View File

@@ -131,7 +131,7 @@
#define COMSIG_MOB_CLICKON "mob_clickon" //from base of mob/clickon(): (atom/A, params)
#define COMSIG_MOB_CANCEL_CLICKON 1
#define COMSIG_MOB_ALLOWED "mob_allowed" //from base of obj/allowed(mob/M): (/obj) returns bool, if TRUE the mob has id access to the obj
#define COMSIG_MOB_RECEIVE_MAGIC "mob_receive_magic" //from base of mob/anti_magic_check(): (magic, holy, protection_sources)
#define COMSIG_MOB_RECEIVE_MAGIC "mob_receive_magic" //from base of mob/anti_magic_check(): (mob/user, magic, holy, major, self, protection_sources)
#define COMPONENT_BLOCK_MAGIC 1
#define COMSIG_MOB_HUD_CREATED "mob_hud_created" //from base of mob/create_mob_hud(): ()
#define COMSIG_MOB_ATTACK_HAND "mob_attack_hand" //from base of

View File

@@ -1,26 +1,44 @@
/datum/component/anti_magic
var/magic = FALSE
var/holy = FALSE
var/charges = INFINITY
var/blocks_self = TRUE
var/datum/callback/reaction
var/datum/callback/expire
/datum/component/anti_magic/Initialize(_magic = FALSE, _holy = FALSE)
/datum/component/anti_magic/Initialize(_magic = FALSE, _holy = FALSE, _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/can_protect)
RegisterSignal(parent, COMSIG_MOB_RECEIVE_MAGIC, .proc/protect)
else
return COMPONENT_INCOMPATIBLE
magic = _magic
holy = _holy
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)
RegisterSignal(equipper, COMSIG_MOB_RECEIVE_MAGIC, .proc/can_protect, TRUE)
if(slot == SLOT_IN_BACKPACK)
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)
UnregisterSignal(user, COMSIG_MOB_RECEIVE_MAGIC)
/datum/component/anti_magic/proc/can_protect(datum/source, _magic, _holy, list/protection_sources)
if((_magic && magic) || (_holy && holy))
/datum/component/anti_magic/proc/protect(datum/source, mob/user, _magic, _holy, major, self, list/protection_sources)
if(((_magic && magic) || (_holy && holy)) && (self && blocks_self))
protection_sources += parent
reaction.Invoke(user, major)
if(major)
charges--
if(charges <= 0)
expire.Invoke(user)
return COMPONENT_BLOCK_MAGIC

View File

@@ -5,7 +5,7 @@
text_gain_indication = "<span class='notice'>You can hear your own voice echoing in your mind!</span>"
text_lose_indication = "<span class='notice'>You don't hear your mind echo anymore.</span>"
difficulty = 12
power = /obj/effect/proc_holder/spell/targeted/telepathy/genetic
power = /obj/effect/proc_holder/spell/targeted/telepathy
instability = 10
/datum/mutation/human/telepathy/on_acquiring(mob/living/carbon/human/owner)
@@ -14,9 +14,6 @@
/datum/mutation/human/telepathy/on_losing(mob/living/carbon/human/owner)
. = ..()
/obj/effect/proc_holder/spell/targeted/telepathy/genetic
magic_check = FALSE
/datum/mutation/human/firebreath
name = "Fire Breath"
desc = "An ancient mutation that gives lizards breath of fire."

View File

@@ -146,7 +146,7 @@
/datum/status_effect/belligerent/proc/do_movement_toggle(force_damage)
var/number_legs = owner.get_num_legs(FALSE)
if(iscarbon(owner) && !is_servant_of_ratvar(owner) && !owner.anti_magic_check() && number_legs)
if(iscarbon(owner) && !is_servant_of_ratvar(owner) && !owner.anti_magic_check(major = FALSE) && number_legs)
if(force_damage || owner.m_intent != MOVE_INTENT_WALK)
if(GLOB.ratvar_awakens)
owner.Paralyze(20)
@@ -239,7 +239,7 @@
if(owner.confused)
owner.confused = 0
severity = 0
else if(!owner.anti_magic_check() && owner.stat != DEAD && severity)
else if(!owner.anti_magic_check(major = FALSE) && owner.stat != DEAD && severity)
var/static/hum = get_sfx('sound/effects/screech.ogg') //same sound for every proc call
if(owner.getToxLoss() > MANIA_DAMAGE_TO_CONVERT)
if(is_eligible_servant(owner))

View File

@@ -63,7 +63,10 @@
return
if(ismob(AM))
var/mob/M = AM
if(M.mind in immune_minds || M.anti_magic_check())
if(M.mind in immune_minds)
return
if(M.anti_magic_check())
flare()
return
if(charges <= 0)
return

View File

@@ -35,7 +35,7 @@
/obj/item/clockwork/weapon/ratvarian_spear/attack(mob/living/target, mob/living/carbon/human/user)
. = ..()
if(!QDELETED(target) && target.stat != DEAD && !target.anti_magic_check() && !is_servant_of_ratvar(target)) //we do bonus damage on attacks unless they're a servant, have a null rod, or are dead
if(!QDELETED(target) && target.stat != DEAD && !target.anti_magic_check(major = FALSE) && !is_servant_of_ratvar(target)) //we do bonus damage on attacks unless they're a servant, have a null rod, or are dead
var/bonus_damage = bonus_burn //normally a total of 20 damage, 30 with ratvar
if(issilicon(target))
target.visible_message("<span class='warning'>[target] shudders violently at [src]'s touch!</span>", "<span class='userdanger'>ERROR: Temperature rising!</span>")

View File

@@ -190,8 +190,8 @@
for(var/mob/living/L in range(1, src))
if(is_servant_of_ratvar(L))
continue
if(L.anti_magic_check())
var/atom/I = L.anti_magic_check()
var/atom/I = L.anti_magic_check()
if(I)
if(isitem(I))
L.visible_message("<span class='warning'>Strange energy flows into [L]'s [I.name]!</span>", \
"<span class='userdanger'>Your [I.name] shields you from [src]!</span>")

View File

@@ -60,7 +60,7 @@
else
if(isliving(target))
var/mob/living/L = target
if(!L.anti_magic_check())
if(!L.anti_magic_check(major = FALSE))
if(isrevenant(L))
var/mob/living/simple_animal/revenant/R = L
if(R.revealed)

View File

@@ -53,7 +53,7 @@
/obj/structure/destructible/clockwork/taunting_trail/proc/affect_mob(mob/living/L)
if(istype(L) && !is_servant_of_ratvar(L))
if(!L.anti_magic_check())
if(!L.anti_magic_check(major = FALSE))
L.confused = min(L.confused + 15, 50)
L.dizziness = min(L.dizziness + 15, 50)
if(L.confused >= 25)

View File

@@ -230,13 +230,14 @@ structure_check() searches for nearby cultist structures required for the invoca
addtimer(CALLBACK(src, /atom/proc/update_atom_colour), 5)
Cult_team.check_size() // Triggers the eye glow or aura effects if the cult has grown large enough relative to the crew
rune_in_use = FALSE
/obj/effect/rune/convert/proc/do_convert(mob/living/convertee, list/invokers)
if(invokers.len < 2)
for(var/M in invokers)
to_chat(M, "<span class='danger'>You need at least two invokers to convert [convertee]!</span>")
log_game("Offer rune failed - tried conversion with one invoker")
return 0
if(convertee.anti_magic_check(TRUE, TRUE))
if(convertee.anti_magic_check(TRUE, TRUE, major = FALSE)) //Not major because it can be spammed
for(var/M in invokers)
to_chat(M, "<span class='warning'>Something is shielding [convertee]'s mind!</span>")
log_game("Offer rune failed - convertee had anti-magic")
@@ -764,7 +765,7 @@ structure_check() searches for nearby cultist structures required for the invoca
set_light(6, 1, color)
for(var/mob/living/L in viewers(T))
if(!iscultist(L) && L.blood_volume)
var/atom/I = L.anti_magic_check()
var/atom/I = L.anti_magic_check(major = FALSE)
if(I)
if(isitem(I))
to_chat(L, "<span class='userdanger'>[I] suddenly burns hotly before returning to normal!</span>")
@@ -794,7 +795,7 @@ structure_check() searches for nearby cultist structures required for the invoca
set_light(6, 1, color)
for(var/mob/living/L in viewers(T))
if(!iscultist(L) && L.blood_volume)
if(L.anti_magic_check())
if(L.anti_magic_check(major = FALSE))
continue
L.take_overall_damage(tick_damage*multiplier, tick_damage*multiplier)
if(is_servant_of_ratvar(L))

View File

@@ -67,7 +67,7 @@
if(target.anti_magic_check(FALSE, TRUE))
to_chat(src, "<span class='revenminor'>Something's wrong! [target] seems to be resisting the siphoning, leaving you vulnerable!</span>")
target.visible_message("<span class='warning'>[target] slumps onto the ground.</span>", \
"<span class='revenwarning'>Violets lights, dancing in your vision, receding--</span>")
"<span class='revenwarning'>Violet lights, dancing in your vision, receding--</span>")
draining = FALSE
return
var/datum/beam/B = Beam(target,icon_state="drain_life",time=INFINITY)
@@ -114,6 +114,7 @@
action_background_icon_state = "bg_revenant"
notice = "revennotice"
boldnotice = "revenboldnotice"
holy_check = TRUE
/obj/effect/proc_holder/spell/aoe_turf/revenant
clothes_req = 0

View File

@@ -423,7 +423,7 @@
/obj/item/clothing/suit/space/hardsuit/wizard/Initialize()
. = ..()
AddComponent(/datum/component/anti_magic, TRUE, FALSE)
AddComponent(/datum/component/anti_magic, TRUE, FALSE, _blocks_self = FALSE)
//Medical hardsuit

View File

@@ -133,6 +133,7 @@
/datum/proximity_monitor/advanced/timestop/proc/freeze_mob(mob/living/L)
if(L.anti_magic_check(check_anti_magic, check_holy))
immune += L
return
L.Stun(20, 1, 1)
frozen_mobs[L] = L.anchored

View File

@@ -60,4 +60,16 @@
/obj/item/reagent_containers/food/snacks/grown/holymelon/Initialize()
. = ..()
AddComponent(/datum/component/anti_magic, TRUE, TRUE) //deliver us from evil o melon god
var/uses = 1
if(seed)
uses = round(seed.potency / 20)
AddComponent(/datum/component/anti_magic, TRUE, TRUE, uses, TRUE, CALLBACK(src, .proc/block_magic), CALLBACK(src, .proc/expire)) //deliver us from evil o melon god
/obj/item/reagent_containers/food/snacks/grown/holymelon/proc/block_magic(mob/user, major)
if(major)
to_chat(user, "<span class='warning'>[src] hums slightly, and seems to decay a bit.</span>")
/obj/item/reagent_containers/food/snacks/grown/holymelon/proc/expire(mob/user)
to_chat(user, "<span class='warning'>[src] rapidly turns into ash!</span>")
qdel(src)
new /obj/effect/decal/cleanable/ash(drop_location())

View File

@@ -90,7 +90,7 @@
to_chat(H, "<span class='notice'>[victim] doesn't have blood!</span>")
return
V.drain_cooldown = world.time + 30
if(victim.anti_magic_check(FALSE, TRUE))
if(victim.anti_magic_check(FALSE, TRUE, FALSE))
to_chat(victim, "<span class='warning'>[H] tries to bite you, but stops before touching you!</span>")
to_chat(H, "<span class='warning'>[victim] is blessed! You stop just in time to avoid catching fire.</span>")
return

View File

@@ -911,7 +911,7 @@
apply_effect((amount*RAD_MOB_COEFFICIENT)/max(1, (radiation**2)*RAD_OVERDOSE_REDUCTION), EFFECT_IRRADIATE, blocked)
/mob/living/anti_magic_check(magic = TRUE, holy = FALSE)
/mob/living/anti_magic_check(magic = TRUE, holy = FALSE, major = TRUE, self = FALSE)
. = ..()
if(.)
return

View File

@@ -694,15 +694,17 @@
mob_spell_list -= S
qdel(S)
/mob/proc/anti_magic_check(magic = TRUE, holy = FALSE)
/mob/proc/anti_magic_check(magic = TRUE, holy = FALSE, major = TRUE, self = FALSE)
if(!magic && !holy)
return
var/list/protection_sources = list()
if(SEND_SIGNAL(src, COMSIG_MOB_RECEIVE_MAGIC, magic, holy, protection_sources) & COMPONENT_BLOCK_MAGIC)
if(SEND_SIGNAL(src, COMSIG_MOB_RECEIVE_MAGIC, src, magic, holy, major, self, protection_sources) & COMPONENT_BLOCK_MAGIC)
if(protection_sources.len)
return pick(protection_sources)
else
return src
if((magic && has_trait(TRAIT_ANTIMAGIC)) || (holy && has_trait(TRAIT_HOLY)))
return src
//You can buckle on mobs if you're next to them since most are dense
/mob/buckle_mob(mob/living/M, force = FALSE, check_loc = TRUE)

View File

@@ -32,7 +32,7 @@
return
else
no_den_usage = 0
if(checks_antimagic && user.anti_magic_check(TRUE, FALSE))
if(checks_antimagic && user.anti_magic_check(TRUE, FALSE, major = FALSE, self = TRUE))
to_chat(user, "<span class='warning'>Something is interfering with [src].</span>")
return
. = ..()

View File

@@ -165,16 +165,16 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) //needed for th
if(user.stat && !stat_allowed)
to_chat(user, "<span class='notice'>Not when you're incapacitated.</span>")
return FALSE
if(!antimagic_allowed)
var/antimagic = user.anti_magic_check(TRUE, FALSE)
var/antimagic = user.anti_magic_check(TRUE, FALSE, major = FALSE, self = TRUE)
if(antimagic)
if(isitem(antimagic))
to_chat(user, "<span class='notice'>[antimagic] is interfering with your magic.</span>")
else
else
to_chat(user, "<span class='notice'>Magic seems to flee from you, you can't gather enough power to cast this spell.</span>")
return FALSE
if(!phase_allowed && istype(user.loc, /obj/effect/dummy))
to_chat(user, "<span class='notice'>[name] cannot be cast unless you are completely manifested in the material plane.</span>")
return FALSE
@@ -512,8 +512,8 @@ GLOBAL_LIST_INIT(spells, typesof(/obj/effect/proc_holder/spell)) //needed for th
if(user.stat && !stat_allowed)
return FALSE
if(!antimagic_allowed && user.anti_magic_check(TRUE, FALSE))
if(!antimagic_allowed && user.anti_magic_check(TRUE, FALSE, major = FALSE, self = TRUE))
return FALSE
if(!ishuman(user))

View File

@@ -35,6 +35,6 @@
return TRUE
if(ismob(mover))
var/mob/M = mover
if(M.anti_magic_check())
if(M.anti_magic_check(major = FALSE))
return TRUE
return FALSE

View File

@@ -86,7 +86,7 @@
/obj/effect/cross_action/spacetime_dist/proc/walk_link(atom/movable/AM)
if(ismob(AM))
var/mob/M = AM
if(M.anti_magic_check())
if(M.anti_magic_check(major = FALSE))
return
if(linked_dist && walks_left > 0)
flick("purplesparkles", src)

View File

@@ -10,7 +10,8 @@
action_background_icon_state = "bg_spell"
var/notice = "notice"
var/boldnotice = "boldnotice"
var/magic_check = TRUE
var/magic_check = FALSE
var/holy_check = FALSE
/obj/effect/proc_holder/spell/targeted/telepathy/cast(list/targets, mob/living/simple_animal/revenant/user = usr)
for(var/mob/living/M in targets)
@@ -20,7 +21,7 @@
return
log_directed_talk(user, M, msg, LOG_SAY, "[name]")
to_chat(user, "<span class='[boldnotice]'>You transmit to [M]:</span> <span class='[notice]'>[msg]</span>")
if(!magic_check || !M.anti_magic_check(FALSE, TRUE)) //hear no evil
if(!M.anti_magic_check(magic_check, holy_check)) //hear no evil
to_chat(M, "<span class='[boldnotice]'>You hear something behind you talking...</span> <span class='[notice]'>[msg]</span>")
for(var/ded in GLOB.dead_mob_list)
if(!isobserver(ded))