Advertisement
Guest User

Untitled

a guest
May 26th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. /obj/item/organ/liver/on_life()
  2. var/mob/living/carbon/C = owner
  3. var/processchem = FALSE //To process all chems when iecure is detected
  4. var/sendmessage = FALSE //To stop the liver damage message being sent if iecure is detected
  5.  
  6. if(istype(C))
  7. if(!failing) //can't process reagents with a failing liver - however process the one that heals the liver
  8. //slowly heal liver damage
  9. damage = max(0, damage - 0.1)
  10.  
  11. if(filterToxins && !owner.has_trait(TRAIT_TOXINLOVER))
  12. //handle liver toxin filtration
  13. var/static/list/toxinstypecache = typecacheof(/datum/reagent/toxin)
  14. for(var/I in C.reagents.reagent_list)
  15. var/datum/reagent/pickedreagent = I
  16. if(is_type_in_typecache(pickedreagent, toxinstypecache))
  17. var/thisamount = C.reagents.get_reagent_amount(initial(pickedreagent.id))
  18. if (thisamount <= toxTolerance && thisamount)
  19. C.reagents.remove_reagent(initial(pickedreagent.id), 1)
  20. else
  21. damage += (thisamount*toxLethality)
  22.  
  23. //metabolize reagents
  24. C.reagents.metabolize(C, can_overdose=TRUE)
  25. to_chat(world, "normal metabolise")
  26.  
  27. if(failing) //This special check only needs to be done on liver failure
  28. to_chat(world, "oh fug we dying")
  29. for(var/I in C.reagents.reagent_list) //Override for liver, if the liver fixing chem is detected we will process everything
  30. if(I == /datum/reagent/medicine/iecure)
  31. for(owner in GLOB.alive_mob_list)
  32. processchem = TRUE
  33. else
  34. for(owner in GLOB.alive_mob_list)
  35. processchem = FALSE
  36. if(processchem == TRUE)
  37. to_chat(world, "METABOLISE GOOOOOO")
  38. C.reagents.metabolize(C, can_overdose=TRUE)
  39.  
  40. if(damage > 10 && prob(damage/3)) //the higher the damage the higher the probability
  41. for(var/I in C.reagents.reagent_list)
  42. if(I == /datum/reagent/medicine/iecure)
  43. for(owner in GLOB.alive_mob_list)
  44. sendmessage = FALSE
  45. else
  46. for(owner in GLOB.alive_mob_list)
  47. sendmessage = TRUE
  48. if(sendmessage == TRUE)
  49. to_chat(C, "<span class='notice'>You feel [pick("nauseous", "a dull pain in your lower body", "confused")].</span>") //no liver damage message if they have the liver fixing chemical
  50.  
  51. if(damage > maxHealth)//cap liver damage
  52. damage = maxHealth
  53.  
  54. if(damage < maxHealth && failing) //if their liver is healed, stop killing them!!
  55. failing = FALSE
  56. to_chat(C, "<span class='notice'>You feel [pick("the pain in your lower body fading", "awake and alert again")].</span>")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement