Files
S.P.L.U.R.T-Station-13/code/datums/components/caltrop.dm
DeltaFire 4146566af0 hoo boy
replaces all mentions of bodypart_robotic with is_robotic_limb() where possible, adds BODYPART_HYBRID, adds helpers for organic / robotic limbs (is_robotic_limb() / is_organic_limb(), with a arg to override it accepting hybrid limbs)
Also makes the the surgery to heal robotic limbs work if the torso isn't a robot, but rather if there are robotic bodyparts, makes the IPC brain repair.. only accept IPC brains (obviously), makes the damage threshholds for robo-limbs vars instead of a fix 25 with hybrid ones predefined at 25 / 15 (trigger / mindamage), adds an error message to fixing them if already at theshhold, etc. Now just for replacing BODYPART_ORGANIC with is_organic_limb aswell where applicable.. also actual values for the other robo limbs. Fun!
2020-10-06 17:34:13 +02:00

63 lines
1.8 KiB
Plaintext

/datum/component/caltrop
var/min_damage
var/max_damage
var/probability
var/flags
var/cooldown = 0
/datum/component/caltrop/Initialize(_min_damage = 0, _max_damage = 0, _probability = 100, _flags = NONE)
min_damage = _min_damage
max_damage = max(_min_damage, _max_damage)
probability = _probability
flags = _flags
RegisterSignal(parent, list(COMSIG_MOVABLE_CROSSED), .proc/Crossed)
/datum/component/caltrop/proc/Crossed(datum/source, atom/movable/AM)
var/atom/A = parent
if(!A.has_gravity())
return
if(!prob(probability))
return
if(ishuman(AM))
var/mob/living/carbon/human/H = AM
if(HAS_TRAIT(H, TRAIT_PIERCEIMMUNE))
return
if((flags & CALTROP_IGNORE_WALKERS) && H.m_intent == MOVE_INTENT_WALK)
return
var/picked_def_zone = pick(BODY_ZONE_L_LEG, BODY_ZONE_R_LEG)
var/obj/item/bodypart/O = H.get_bodypart(picked_def_zone)
if(!istype(O))
return
if(O.is_robotic_limb())
return
var/feetCover = (H.wear_suit && (H.wear_suit.body_parts_covered & FEET)) || (H.w_uniform && (H.w_uniform.body_parts_covered & FEET) || (H.shoes && (H.shoes.body_parts_covered & FEET)))
if(!(flags & CALTROP_BYPASS_SHOES) && feetCover)
return
if((H.movement_type & FLYING) || H.buckled)
return
var/damage = rand(min_damage, max_damage)
if(HAS_TRAIT(H, TRAIT_LIGHT_STEP))
damage *= 0.75
H.apply_damage(damage, BRUTE, picked_def_zone, wound_bonus = CANT_WOUND)
if(cooldown < world.time - 10) //cooldown to avoid message spam.
if(!H.incapacitated(ignore_restraints = TRUE))
H.visible_message("<span class='danger'>[H] steps on [A].</span>", \
"<span class='userdanger'>You step on [A]!</span>")
else
H.visible_message("<span class='danger'>[H] slides on [A]!</span>", \
"<span class='userdanger'>You slide on [A]!</span>")
cooldown = world.time
H.DefaultCombatKnockdown(60)