Files
Aurora.3/code/modules/organs/pain.dm
Alberyk 00ba1282c3 Changes how pain checks works in game (#5978)
This pr creates a new check, can_feel_pain, it checks for the NO_PAIN flag, if the target is under influence of mind altering drugs or strong painkillers. This check replaces all the species procs and fixes somethings, like people under the influence of pain killers still getting knocked out from pain and etc.
2019-01-27 13:48:12 +02:00

132 lines
3.9 KiB
Plaintext

mob/proc/flash_pain()
flick("pain",pain)
mob/var/list/pain_stored = list()
mob/var/last_pain_message = ""
mob/var/next_pain_time = 0
// partname is the name of a body part
// amount is a num from 1 to 100
mob/living/carbon/proc/pain(var/partname, var/amount, var/force, var/burning = 0)
if(stat >= 1)
return
if(!can_feel_pain())
return
if(analgesic > 40)
return
if(world.time < next_pain_time && !force)
return
if(amount > 10 && istype(src,/mob/living/carbon/human))
if(src:paralysis)
src:paralysis = max(0, src:paralysis-round(amount/10))
if(amount > 50 && prob(amount / 5))
src:drop_item()
var/msg
if(burning)
switch(amount)
if(1 to 10)
msg = "<span class='danger'>Your [partname] burns.</span>"
if(11 to 90)
flash_weak_pain()
msg = "<span class='danger'><font size=2>Your [partname] burns horribly!</font></span>"
if(91 to 10000)
flash_pain()
msg = "<span class='danger'><font size=3>Your [partname] feels like it's on fire!</font></span>"
else
switch(amount)
if(1 to 10)
msg = "<b>Your [partname] hurts.</b>"
if(11 to 90)
flash_weak_pain()
msg = "<b><font size=2>Your [partname] hurts badly!</font></b>"
if(91 to 10000)
flash_pain()
msg = "<b><font size=3>Your [partname] is screaming out in pain!</font></b>"
if(msg && (msg != last_pain_message || prob(10)))
last_pain_message = msg
src << msg
next_pain_time = world.time + (100 - amount)
// message is the custom message to be displayed
// flash_strength is 0 for weak pain flash, 1 for strong pain flash
mob/living/carbon/human/proc/custom_pain(var/message, var/flash_strength)
if(stat >= 1)
return
if(!can_feel_pain())
return
if(reagents.has_reagent("tramadol"))
return
if(reagents.has_reagent("oxycodone"))
return
if(analgesic)
return
var/msg = "<span class='danger'>[message]</span>"
if(flash_strength >= 1)
msg = "<span class='danger'><font size=3>[message]</font></span>"
// Anti message spam checks
if(msg && ((msg != last_pain_message) || (world.time >= next_pain_time)))
last_pain_message = msg
src << msg
next_pain_time = world.time + 100
mob/living/carbon/human/proc/handle_pain()
// not when sleeping
if(!can_feel_pain()) return
if(stat >= 2) return
if(analgesic > 70)
return
var/maxdam = 0
var/obj/item/organ/external/damaged_organ = null
for(var/obj/item/organ/external/E in organs)
if(E.status & (ORGAN_DEAD|ORGAN_ROBOT)) continue
var/dam = E.get_damage()
// make the choice of the organ depend on damage,
// but also sometimes use one of the less damaged ones
if(dam > maxdam && (maxdam == 0 || prob(70)) )
damaged_organ = E
maxdam = dam
if(damaged_organ)
pain(damaged_organ.name, maxdam, 0)
// Damage to internal organs hurts a lot.
for(var/obj/item/organ/I in internal_organs)
if(I.status & (ORGAN_DEAD|ORGAN_ROBOT))
continue
if(prob(2))
var/obj/item/organ/external/parent = get_organ(I.parent_organ)
var/painmessage
if(I.is_broken())
painmessage = "You feel an excrutiating pain in your [parent.name]!"
else if (I.is_bruised())
painmessage = "You feel a sharp pain in your [parent.name]..."
else if (I.is_damaged())
painmessage = "You feel discomfort in your [parent.name]."
if(painmessage)
src.custom_pain(painmessage, I.is_bruised())
//The less hardcoded values, the better.
var/toxDamageMessage = null
var/toxMessageProb = 1
switch(getToxLoss())
if(1 to 5)
toxMessageProb = 1
toxDamageMessage = "Your body stings slightly."
if(6 to 10)
toxMessageProb = 2
toxDamageMessage = "Your whole body hurts a little."
if(11 to 15)
toxMessageProb = 2
toxDamageMessage = "Your whole body hurts."
if(15 to 25)
toxMessageProb = 3
toxDamageMessage = "Your whole body hurts badly!"
if(26 to INFINITY)
toxMessageProb = 5
toxDamageMessage = "Your body aches all over, it's driving you mad!"
if(toxDamageMessage && prob(toxMessageProb))
src.custom_pain(toxDamageMessage, getToxLoss() >= 15)