Files
Paradise/code/game/objects/items/weapons/surgery_tools.dm
elly1989@rocketmail.com 8961bd96d0 WARNING: This has been thoroughly tested and I'm happy that it's -stable- (it shouldn't runtime). However, it might have a few niggly bugs caused by specific items using no-standard or weird code. Most bugs will be stuff like it not updating overlays and such and can be fixed simply by dropping the item. That being said, if you're not comfortable with this, I'd suggest waiting to update past this revision.
update_clothing() has been broken up into it's key parts. A full explanation can be found in code/modules/mob/living/carbon/human/update_icons.dm
the tl;dr of it is that overlay updates are no longer called by the gameticker. Instead they are called by procs such as u_equip db_cick etc. This means faster updates (although admittedly, more of them can be called per tick). This however is offset by the fact that specific overlays can be updated now, vastly improving its efficiency. This will especially help when there are large numbers of dead mobs.

Fixed the throw code for TKgrab so it can be toggled.

Cloaking for aliens/humans/ninjas was changed. It's very crude at the moment and for that I apologise. But it works and is very efficient.It also stops cloaked individuals becomming invincible due to people being unable to hit them (even when they know exactly where  they are)

Fixed a bunch of bugs with damage-overlays. They  were updating FAR FAR to frequently. They were also horribly inefficient. They should now be virtually seamless when updating and only use cached icons, so they aren't affected by lag as badly. This may help with explosions lag a little.

There's still a tonne of stuff I need to refine with this. I'll be refining it down into some helper procs to reduce on code duplication and such

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3811 316c924e-a436-60f5-8080-3fe189b3f50e
2012-06-13 19:03:25 +00:00

580 lines
20 KiB
Plaintext

/*
CONTAINS:
RETRACTOR
HEMOSTAT
CAUTERY
SURGICAL DRILL
SCALPEL
CIRCULAR SAW
*/
/////////////
//RETRACTOR//
/////////////
/obj/item/weapon/retractor/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
if(!istype(M))
return
if(!((locate(/obj/machinery/optable, M.loc) && M.resting) || (locate(/obj/structure/table/, M.loc) && (M.lying || M.weakened || M.stunned || M.paralysis || M.sleeping || M.stat) && prob(50))))
return ..()
if(user.zone_sel.selecting == "groin")
if(istype(M, /mob/living/carbon/human))
switch(M:appendix_op_stage)
if(2.0)
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [user] retracts the flap in [M]'s abdomen cut open with [src].", 1)
M << "\red [user] begins to retract the flap in your abdomen with [src]!"
user << "\red You retract the flap in [M]'s abdomen with [src]!"
M:appendix_op_stage = 3.0
return
if (user.zone_sel.selecting == "eyes")
var/mob/living/carbon/human/H = M
if(istype(H) && ( \
(H.head && H.head.flags & HEADCOVERSEYES) || \
(H.wear_mask && H.wear_mask.flags & MASKCOVERSEYES) || \
(H.glasses && H.glasses.flags & GLASSESCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
var/mob/living/carbon/monkey/Mo = M
if(istype(Mo) && ( \
(Mo.wear_mask && Mo.wear_mask.flags & MASKCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
if(istype(M, /mob/living/carbon/alien) || istype(M, /mob/living/carbon/metroid))//Aliens don't have eyes./N
user << "\red You cannot locate any eyes on this creature!"
return
switch(M.eye_op_stage)
if(1.0)
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M] is having his eyes retracted by [user].", 1)
M << "\red [user] begins to seperate your eyes with [src]!"
user << "\red You seperate [M]'s eyes with [src]!"
else
user.visible_message( \
"\red [user] begins to have his eyes retracted.", \
"\red You begin to pry open your eyes with [src]!" \
)
if(M == user && prob(25))
user << "\red You mess up!"
if(istype(M, /mob/living/carbon/human))
var/datum/organ/external/affecting = M:get_organ("head")
if(affecting.take_damage(15))
M:UpdateDamageIcon()
M.updatehealth()
else
M.take_organ_damage(15)
M:eye_op_stage = 2.0
else if((!(user.zone_sel.selecting == "head")) || (!(user.zone_sel.selecting == "groin")) || (!(istype(M, /mob/living/carbon/human))))
return ..()
return
////////////
//Hemostat//
////////////
/obj/item/weapon/hemostat/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
if(!istype(M))
return
if(!((locate(/obj/machinery/optable, M.loc) && M.resting) || (locate(/obj/structure/table/, M.loc) && M.lying && prob(50))))
return ..()
if(user.zone_sel.selecting == "groin")
if(istype(M, /mob/living/carbon/human))
switch(M:appendix_op_stage)
if(1.0)
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [user] is beginning to clamp bleeders in [M]'s abdomen cut open with [src].", 1)
M << "\red [user] begins to clamp bleeders in your abdomen with [src]!"
user << "\red You clamp bleeders in [M]'s abdomen with [src]!"
M:appendix_op_stage = 2.0
if(4.0)
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [user] is removing [M]'s appendix with [src].", 1)
M << "\red [user] begins to remove your appendix with [src]!"
user << "\red You remove [M]'s appendix with [src]!"
for(var/datum/disease/D in M.viruses)
if(istype(D, /datum/disease/appendicitis))
new /obj/item/weapon/reagent_containers/food/snacks/appendixinflamed(get_turf(M))
M:appendix_op_stage = 5.0
return
new /obj/item/weapon/reagent_containers/food/snacks/appendix(get_turf(M))
M:appendix_op_stage = 5.0
return
if (user.zone_sel.selecting == "eyes")
var/mob/living/carbon/human/H = M
if(istype(H) && ( \
(H.head && H.head.flags & HEADCOVERSEYES) || \
(H.wear_mask && H.wear_mask.flags & MASKCOVERSEYES) || \
(H.glasses && H.glasses.flags & GLASSESCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
var/mob/living/carbon/monkey/Mo = M
if(istype(Mo) && ( \
(Mo.wear_mask && Mo.wear_mask.flags & MASKCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
if(istype(M, /mob/living/carbon/alien))//Aliens don't have eyes./N
user << "\red You cannot locate any eyes on this creature!"
return
switch(M.eye_op_stage)
if(2.0)
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M] is having his eyes mended by [user].", 1)
M << "\red [user] begins to mend your eyes with [src]!"
user << "\red You mend [M]'s eyes with [src]!"
else
user.visible_message( \
"\red [user] begins to have his eyes mended.", \
"\red You begin to mend your eyes with [src]!" \
)
if(M == user && prob(25))
user << "\red You mess up!"
if(istype(M, /mob/living/carbon/human))
var/datum/organ/external/affecting = M:get_organ("head")
if(affecting.take_damage(15))
M:UpdateDamageIcon()
M.updatehealth()
else
M.take_organ_damage(15)
M:eye_op_stage = 3.0
else if((!(user.zone_sel.selecting == "head")) || (!(user.zone_sel.selecting == "groin")) || (!(istype(M, /mob/living/carbon/human))))
return ..()
return
///////////
//Cautery//
///////////
/obj/item/weapon/cautery/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
if(!istype(M))
return
if(!((locate(/obj/machinery/optable, M.loc) && M.resting) || (locate(/obj/structure/table/, M.loc) && M.lying && prob(50))))
return ..()
if(user.zone_sel.selecting == "groin")
if(istype(M, /mob/living/carbon/human))
switch(M:appendix_op_stage)
if(5.0)
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [user] is beginning to cauterize the incision in [M]'s abdomen with [src].", 1)
M << "\red [user] begins to cauterize the incision in your abdomen with [src]!"
user << "\red You cauterize the incision in [M]'s abdomen with [src]!"
M:appendix_op_stage = 6.0
for(var/datum/disease/appendicitis in M.viruses)
appendicitis.cure()
M.resistances += appendicitis
return
if (user.zone_sel.selecting == "eyes")
var/mob/living/carbon/human/H = M
if(istype(H) && ( \
(H.head && H.head.flags & HEADCOVERSEYES) || \
(H.wear_mask && H.wear_mask.flags & MASKCOVERSEYES) || \
(H.glasses && H.glasses.flags & GLASSESCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
var/mob/living/carbon/monkey/Mo = M
if(istype(Mo) && ( \
(Mo.wear_mask && Mo.wear_mask.flags & MASKCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
if(istype(M, /mob/living/carbon/alien))//Aliens don't have eyes./N
user << "\red You cannot locate any eyes on this creature!"
return
switch(M.eye_op_stage)
if(3.0)
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M] is having his eyes cauterized by [user].", 1)
M << "\red [user] begins to cauterize your eyes!"
user << "\red You cauterize [M]'s eyes with [src]!"
else
user.visible_message( \
"\red [user] begins to have his eyes cauterized.", \
"\red You begin to cauterize your eyes!" \
)
if(M == user && prob(25))
user << "\red You mess up!"
if(istype(M, /mob/living/carbon/human))
var/datum/organ/external/affecting = M:get_organ("head")
if(affecting.take_damage(15))
M:UpdateDamageIcon()
M.updatehealth()
else
M.take_organ_damage(15)
M.sdisabilities &= ~1
M.eye_stat = 0
M:eye_op_stage = 0.0
else if((!(user.zone_sel.selecting == "head")) || (!(user.zone_sel.selecting == "groin")) || (!(istype(M, /mob/living/carbon/human))))
return ..()
return
//obj/item/weapon/surgicaldrill
///////////
//SCALPEL//
///////////
/obj/item/weapon/scalpel/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
if(!istype(M))
return ..()
//if(M.mutations & HUSK) return ..()
if((CLUMSY in user.mutations) && prob(50))
M = user
return eyestab(M,user)
if(!((locate(/obj/machinery/optable, M.loc) && M.resting) || (locate(/obj/structure/table/, M.loc) && M.lying && prob(50))))
return ..()
src.add_fingerprint(user)
if(user.zone_sel.selecting == "groin")
if(istype(M, /mob/living/carbon/human))
switch(M:appendix_op_stage)
if(0.0)
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M] is beginning to have his abdomen cut open with [src] by [user].", 1)
M << "\red [user] begins to cut open your abdomen with [src]!"
user << "\red You cut [M]'s abdomen open with [src]!"
M:appendix_op_stage = 1.0
if(3.0)
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M] is beginning to have his appendix seperated with [src] by [user].", 1)
M << "\red [user] begins to seperate your appendix with [src]!"
user << "\red You seperate [M]'s appendix with [src]!"
M:appendix_op_stage = 4.0
return
if(user.zone_sel.selecting == "head" || istype(M, /mob/living/carbon/metroid))
var/mob/living/carbon/human/H = M
if(istype(H) && ( \
(H.head && H.head.flags & HEADCOVERSEYES) || \
(H.wear_mask && H.wear_mask.flags & MASKCOVERSEYES) || \
(H.glasses && H.glasses.flags & GLASSESCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
var/mob/living/carbon/monkey/Mo = M
if(istype(Mo) && ( \
(Mo.wear_mask && Mo.wear_mask.flags & MASKCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
switch(M:brain_op_stage)
if(0.0)
if(istype(M, /mob/living/carbon/metroid))
if(M.stat == 2)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M.name] is beginning to have its flesh cut open with [src] by [user].", 1)
M << "\red [user] begins to cut open your flesh with [src]!"
user << "\red You cut [M]'s flesh open with [src]!"
M:brain_op_stage = 1.0
return
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M] is beginning to have his head cut open with [src] by [user].", 1)
M << "\red [user] begins to cut open your head with [src]!"
user << "\red You cut [M]'s head open with [src]!"
else
user.visible_message( \
"\red [user] begins to cut open his skull with [src]!", \
"\red You begin to cut open your head with [src]!" \
)
if(M == user && prob(25))
user << "\red You mess up!"
if(istype(M, /mob/living/carbon/human))
var/datum/organ/external/affecting = M:get_organ("head")
if(affecting.take_damage(15))
M:UpdateDamageIcon()
else
M.take_organ_damage(15)
if(istype(M, /mob/living/carbon/human))
var/datum/organ/external/affecting = M:get_organ("head")
affecting.take_damage(7)
else
M.take_organ_damage(7)
M.updatehealth()
M:brain_op_stage = 1.0
if(1)
if(istype(M, /mob/living/carbon/metroid))
if(M.stat == 2)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M.name] is having its silky inndards cut apart with [src] by [user].", 1)
M << "\red [user] begins to cut apart your innards with [src]!"
user << "\red You cut [M]'s silky innards apart with [src]!"
M:brain_op_stage = 2.0
return
if(2.0)
if(istype(M, /mob/living/carbon/metroid))
if(M.stat == 2)
var/mob/living/carbon/metroid/Metroid = M
if(Metroid.cores > 0)
if(istype(M, /mob/living/carbon/metroid))
user << "\red You attempt to remove [M]'s core, but [src] is ineffective!"
return
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M] is having his connections to the brain delicately severed with [src] by [user].", 1)
M << "\red [user] begins to cut open your head with [src]!"
user << "\red You cut [M]'s head open with [src]!"
else
user.visible_message( \
"\red [user] begin to delicately remove the connections to his brain with [src]!", \
"\red You begin to cut open your head with [src]!" \
)
if(M == user && prob(25))
user << "\red You nick an artery!"
if(istype(M, /mob/living/carbon/human))
var/datum/organ/external/affecting = M:get_organ("head")
if(affecting.take_damage(75))
M:UpdateDamageIcon()
else
M.take_organ_damage(75)
if(istype(M, /mob/living/carbon/human))
var/datum/organ/external/affecting = M:get_organ("head")
affecting.take_damage(7)
else
M.take_organ_damage(7)
M.updatehealth()
M:brain_op_stage = 3.0
else
..()
return
else if(user.zone_sel.selecting == "eyes")
user << "\blue So far so good."
var/mob/living/carbon/human/H = M
if(istype(H) && ( \
(H.head && H.head.flags & HEADCOVERSEYES) || \
(H.wear_mask && H.wear_mask.flags & MASKCOVERSEYES) || \
(H.glasses && H.glasses.flags & GLASSESCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
var/mob/living/carbon/monkey/Mo = M
if(istype(Mo) && ( \
(Mo.wear_mask && Mo.wear_mask.flags & MASKCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
if(istype(M, /mob/living/carbon/alien) || istype(M, /mob/living/carbon/metroid))//Aliens don't have eyes./N
user << "\red You cannot locate any eyes on this creature!"
return
switch(M:eye_op_stage)
if(0.0)
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M] is beginning to have his eyes incised with [src] by [user].", 1)
M << "\red [user] begins to cut open your eyes with [src]!"
user << "\red You make an incision around [M]'s eyes with [src]!"
else
user.visible_message( \
"\red [user] begins to cut around his eyes with [src]!", \
"\red You begin to cut open your eyes with [src]!" \
)
if(M == user && prob(25))
user << "\red You mess up!"
if(istype(M, /mob/living/carbon/human))
var/datum/organ/external/affecting = M:get_organ("head")
if(affecting.take_damage(15))
M:UpdateDamageIcon()
else
M.take_organ_damage(15)
user << "\blue So far so good before."
M.updatehealth()
M:eye_op_stage = 1.0
user << "\blue So far so good after."
else
return ..()
/* wat
else if((!(user.zone_sel.selecting == "head")) || (!(user.zone_sel.selecting == "groin")) || (!(istype(M, /mob/living/carbon/human))))
return ..()
*/
return
////////////////
//CIRCULAR SAW//
////////////////
/obj/item/weapon/circular_saw/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
if(!istype(M))
return ..()
if((CLUMSY in user.mutations) && prob(50))
M = user
return eyestab(M,user)
if(!((locate(/obj/machinery/optable, M.loc) && M.resting) || (locate(/obj/structure/table/, M.loc) && M.lying && prob(50))))
return ..()
src.add_fingerprint(user)
if(user.zone_sel.selecting == "head" || istype(M, /mob/living/carbon/metroid))
var/mob/living/carbon/human/H = M
if(istype(H) && ( \
(H.head && H.head.flags & HEADCOVERSEYES) || \
(H.wear_mask && H.wear_mask.flags & MASKCOVERSEYES) || \
(H.glasses && H.glasses.flags & GLASSESCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
var/mob/living/carbon/monkey/Mo = M
if(istype(Mo) && ( \
(Mo.wear_mask && Mo.wear_mask.flags & MASKCOVERSEYES) \
))
user << "\red You're going to need to remove that mask/helmet/glasses first."
return
switch(M:brain_op_stage)
if(1.0)
if(istype(M, /mob/living/carbon/metroid))
return
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M] has his skull sawed open with [src] by [user].", 1)
M << "\red [user] begins to saw open your head with [src]!"
user << "\red You saw [M]'s head open with [src]!"
else
user.visible_message( \
"\red [user] saws open his skull with [src]!", \
"\red You begin to saw open your head with [src]!" \
)
if(M == user && prob(25))
user << "\red You mess up!"
if(istype(M, /mob/living/carbon/human))
var/datum/organ/external/affecting = M:get_organ("head")
if(affecting.take_damage(40))
M:UpdateDamageIcon()
M.updatehealth()
else
M.take_organ_damage(40)
if(istype(M, /mob/living/carbon/human))
var/datum/organ/external/affecting = M:get_organ("head")
affecting.take_damage(7)
else
M.take_organ_damage(7)
M.updatehealth()
M:brain_op_stage = 2.0
if(2.0)
if(istype(M, /mob/living/carbon/metroid))
if(M.stat == 2)
var/mob/living/carbon/metroid/Metroid = M
if(Metroid.cores > 0)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M.name] is having one of its cores sawed out with [src] by [user].", 1)
Metroid.cores--
M << "\red [user] begins to remove one of your cores with [src]! ([Metroid.cores] cores remaining)"
user << "\red You cut one of [M]'s cores out with [src]! ([Metroid.cores] cores remaining)"
new/obj/item/metroid_core(M.loc)
if(Metroid.cores <= 0)
M.icon_state = "baby metroid dead-nocore"
return
if(3.0)
if(M.changeling && M.changeling.changeling_fakedeath)
user << "\red The neural tissue regrows before your eyes as you cut it."
return
if(M != user)
for(var/mob/O in (viewers(M) - user - M))
O.show_message("\red [M] has his spine's connection to the brain severed with [src] by [user].", 1)
M << "\red [user] severs your brain's connection to the spine with [src]!"
user << "\red You sever [M]'s brain's connection to the spine with [src]!"
else
user.visible_message( \
"\red [user] severs his brain's connection to the spine with [src]!", \
"\red You sever your brain's connection to the spine with [src]!" \
)
user.attack_log += "\[[time_stamp()]\]<font color='red'> Debrained [M.name] ([M.ckey]) with [src.name] (INTENT: [uppertext(user.a_intent)])</font>"
M.attack_log += "\[[time_stamp()]\]<font color='orange'> Debrained by [user.name] ([user.ckey]) with [src.name] (INTENT: [uppertext(user.a_intent)])</font>"
log_attack("<font color='red'>[user.name] ([user.ckey]) debrained [M.name] ([M.ckey]) with [src.name] (INTENT: [uppertext(user.a_intent)])</font>")
var/obj/item/brain/B = new(M.loc)
B.transfer_identity(M)
M:brain_op_stage = 4.0
M.death()//You want them to die after the brain was transferred, so not to trigger client death() twice.
else
..()
return
else
return ..()
/*
else if((!(user.zone_sel.selecting == "head")) || (!(user.zone_sel.selecting == "groin")) || (!(istype(M, /mob/living/carbon/human))))
return ..()
*/
return