Merge pull request #5702 from Citadel-Station-13/upstream-merge-35639
[MIRROR] Refactors anti-magic into a component
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/datum/component/anti_magic
|
||||
var/magic = FALSE
|
||||
var/holy = FALSE
|
||||
|
||||
/datum/component/anti_magic/Initialize(_magic = FALSE, _holy = FALSE)
|
||||
magic = _magic
|
||||
holy = _holy
|
||||
|
||||
/datum/component/anti_magic/proc/can_protect(_magic = TRUE, _holy = FALSE)
|
||||
if(!enabled)
|
||||
return FALSE
|
||||
if((_magic && magic) || (_holy && holy))
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
/mob/proc/anti_magic_check(magic = TRUE, holy = FALSE)
|
||||
if(!magic && !holy)
|
||||
return
|
||||
var/list/obj/item/item_list = list()
|
||||
item_list |= held_items
|
||||
for(var/obj/O in item_list)
|
||||
GET_COMPONENT_FROM(anti_magic, /datum/component/anti_magic, O)
|
||||
if(!anti_magic)
|
||||
continue
|
||||
if(anti_magic.can_protect(magic, holy))
|
||||
return O
|
||||
|
||||
/mob/living/anti_magic_check(magic = TRUE, holy = FALSE)
|
||||
if(!magic && !holy)
|
||||
return
|
||||
|
||||
if((magic && has_trait(TRAIT_ANTIMAGIC)) || (holy && has_trait(TRAIT_HOLY)))
|
||||
return src
|
||||
|
||||
var/list/obj/item/item_list = list()
|
||||
item_list |= get_equipped_items(TRUE)
|
||||
item_list |= held_items
|
||||
for(var/obj/O in item_list)
|
||||
GET_COMPONENT_FROM(anti_magic, /datum/component/anti_magic, O)
|
||||
if(!anti_magic)
|
||||
continue
|
||||
if(anti_magic.can_protect(magic, holy))
|
||||
return O
|
||||
@@ -125,7 +125,7 @@
|
||||
|
||||
/datum/status_effect/belligerent/proc/do_movement_toggle(force_damage)
|
||||
var/number_legs = owner.get_num_legs()
|
||||
if(iscarbon(owner) && !is_servant_of_ratvar(owner) && !owner.null_rod_check() && number_legs)
|
||||
if(iscarbon(owner) && !is_servant_of_ratvar(owner) && !owner.anti_magic_check() && number_legs)
|
||||
if(force_damage || owner.m_intent != MOVE_INTENT_WALK)
|
||||
if(GLOB.ratvar_awakens)
|
||||
owner.Knockdown(20)
|
||||
@@ -218,7 +218,7 @@
|
||||
if(owner.confused)
|
||||
owner.confused = 0
|
||||
severity = 0
|
||||
else if(!owner.null_rod_check() && owner.stat != DEAD && severity)
|
||||
else if(!owner.anti_magic_check() && 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))
|
||||
|
||||
Reference in New Issue
Block a user