** Mob Define Cleanup: Part 1 **

I'm currently working on moving all of the vars in mob_defines.dm and some procs in mob.dm into more fitting places. For example, ghosts and simple animals can not be cloned, so they do not need a cloneloss var. Cloneloss would be better fitting to /mob/living or even /mob/living/carbon. 

By moving these defines into proper children of /mob we lower the amount of resources that must be set aside every time a mob is created and we lower the amount of data that gets transfered between mobs when we combine, transfer or transform them. In theory, this should help free up some resources and combat lag.

Due to how integrated some of these defines are in the rest of the code, I'm going to be committing this cleanup in small batches. Doing it this way instead of one massive commit means that bugs will be easier to locate and identify. It is also less likely to overwhelm players with bugs, and if it still does, it will make it easier for us to revert only the section that is causing problems. Smaller commits also means merging with existing code will be less of a nightmare and has less potential for merging mistakes.

One of my goals in this cleanup is to add a description to every single variable in mob defines. While some of them are self explanatory, there are some there that are used in horribly obscure ways on top of having no comment to describe their use.

-----------------------

Mob defines moved to living:
- last_special*
- bruteloss
- oxyloss
- toxloss
- fireloss
- cloneloss
- brainloss
- halloss
- hallucination
- hallucinations(list)

*Note: I believe this variable is not needed, but the code it is used in (the resist verb) is cluttered and messy. That chunk of code probably use a re-write. I'll put it on my TODO list and if I survive mob_defines I'll try to get around to it but if anyone wants to do it for me, that would certainly help!

-----------------------

Mob procs moved to living:
- getBruteLoss()
- adjustBruteLoss()
- getOxyLoss()
- adjustOxyLoss()
- setOxyLoss()
- getToxLoss()
- adjustToxLoss()
- setToxLoss()
- getFireLoss()
- adjustFireLoss()
- getCloneLoss()
- adjustCloneLoss()
- setCloneLoss()
- getHalLoss()
- adjustHalLoss()
- setHalLoss()
- getBrainLoss()
- adjustBrainLoss()
- setBrainLoss

Mob procs moved to carbon:
getDNA()
setDNA()

-----------------------

Mob verbs moved to carbon:
- Sleep
- Lay down / Get up

-----------------------

The : operator...

The thing that has been killing me through this whole cleanup is people using or copy/pasting the : operator everywhere. 


*** Please use obj.var_or_procname. Do not use obj:var_or_procname ***


Using obj:procname will not throw a compiler error if obj does not have that specific var or proc. This means that the coder making changes will NOT be informed of an error which will result in a proc failing, potentially being completely unusable and definatly causing a runtime error.

With that said, I fully anticipate that most bugs (if any) caused by this mob define cleanup to be the result of : operators.

I've been replacing many : operators in favour of the . operator as I've been going, most noteably I went out of my way to remove almost every : operator from the 4000+ line Chemistry-Regents.dm
Exceptions:
- Water: Turf and Atmos related vars. I'm not familiar with the members and methods in those class' hierarchy.
- Silicate: because it's commented out and I honestly dont see it returning.
- Thermite: Turf and Atmos related vars.
- Corn Oil: Turf and Atmos related vars.

Final note: While this may be the source of some mob-related bugs, there are two other revisions that have been committed between now and the last time either of the the two tgstation servers have been updated. These revisions both touch mob-related files. I'm not blaming these other revisions for anything, especially since one of them is mine anyway, I'm just listing them here for refrence to help quickly identify any problems.
- My human/life() changes in r3925 
- Carn's life() standardizations in r3933

Stuff unrelated to mob defines:
- Fixed borgs and such being able to go into DNA modifiers.
- Changelog updated and I added Sieve to the list of coders.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3934 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
johnsonmt88@gmail.com
2012-06-28 17:06:19 +00:00
parent ea333ff216
commit 80b15df54b
36 changed files with 727 additions and 673 deletions
+13 -3
View File
@@ -1152,7 +1152,11 @@ var/global/BSACooldown = 0
special_role_description = "Role: <i>Mind datum missing</i> Antagonist: <i>Mind datum missing</i>; Has been rev: <i>Mind datum missing</i>;"
//Health
health_description = "Oxy: [M.oxyloss] - Tox: [M.toxloss] - Fire: [M.fireloss] - Brute: [M.bruteloss] - Clone: [M.cloneloss] - Brain: [M.brainloss]"
if(isliving(M))
var/mob/living/L
health_description = "Oxy: [L.oxyloss] - Tox: [L.toxloss] - Fire: [L.fireloss] - Brute: [L.bruteloss] - Clone: [L.cloneloss] - Brain: [L.brainloss]"
else
health_description = "This mob type has no health to speak of."
src.owner << "<b>Info about [M.name]:</b> "
src.owner << "Mob type = [M.type]; Damage = [health_description]"
@@ -1191,10 +1195,16 @@ var/global/BSACooldown = 0
show_traitor_panel(M)
if (href_list["BlueSpaceArtillery"])
var/mob/M = locate(href_list["BlueSpaceArtillery"])
if(!M)
var/mob/target = locate(href_list["BlueSpaceArtillery"])
if(!target)
return
if(!isliving(target))
src.owner << "That is not a valid target."
return
var/mob/living/M = target
var/choice = alert(src.owner, "Are you sure you wish to hit [key_name(M)] with Blue Space Artillery?", "Confirm Firing?" , "Yes" , "No")
if (choice == "No")
return
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -194,13 +194,14 @@
var/damage = rand(melee_damage_lower, melee_damage_upper)
if(istype(target, /mob/living/carbon/human))
if(ishuman(target))
var/mob/living/carbon/human/H = target
var/dam_zone = pick("chest", "l_hand", "r_hand", "l_leg", "r_leg")
var/datum/organ/external/affecting = H.get_organ(ran_zone(dam_zone))
H.apply_damage(damage, BRUTE, affecting, H.run_armor_check(affecting, "melee"))
else
target:adjustBruteLoss(damage)
else if(isliving(target))
var/mob/living/L = target
L.adjustBruteLoss(damage)
if(attack_sound)
playsound(loc, attack_sound, 50, 1, -1)
+1 -1
View File
@@ -346,7 +346,7 @@ var/list/non_fakeattack_weapons = list(/obj/item/weapon/gun/projectile, /obj/ite
/obj/item/clothing/shoes/magboots, /obj/item/blueprints, /obj/item/weapon/disk/nuclear,\
/obj/item/clothing/suit/space/nasavoid, /obj/item/weapon/tank)
/proc/fake_attack(var/mob/target)
/proc/fake_attack(var/mob/living/target)
// var/list/possible_clones = new/list()
var/mob/living/carbon/human/clone = null
var/clone_weapon = null
@@ -528,7 +528,7 @@
proc/handle_stomach()
spawn(0)
for(var/mob/M in stomach_contents)
for(var/mob/living/M in stomach_contents)
if(M.loc != src)
stomach_contents.Remove(M)
continue
@@ -459,7 +459,7 @@
proc/handle_stomach()
spawn(0)
for(var/mob/M in stomach_contents)
for(var/mob/living/M in stomach_contents)
if(M.loc != src)
stomach_contents.Remove(M)
continue
+10
View File
@@ -235,3 +235,13 @@
/mob/living/carbon/proc/eyecheck()
return 0
// ++++ROCKDTBEN++++ MOB PROCS -- Ask me before touching.
// Stop! ... Hammertime! ~Carn
/mob/living/carbon/proc/getDNA()
return dna
/mob/living/carbon/proc/setDNA(var/datum/dna/newDNA)
dna = newDNA
// ++++ROCKDTBEN++++ MOB PROCS //END
@@ -310,7 +310,7 @@
var/t7 = 1
if (restrained())
for(var/mob/M in range(src, 1))
for(var/mob/living/M in range(src, 1))
if ((M.pulling == src && M.stat == 0 && !( M.restrained() )))
t7 = null
if ((t7 && (pulling && ((get_dist(src, pulling) <= 1 || pulling.loc == loc) && (client && client.moving)))))
@@ -337,8 +337,8 @@
else
diag = null
if ((get_dist(src, pulling) > 1 || diag))
if (ismob(pulling))
var/mob/M = pulling
if (isliving(pulling))
var/mob/living/M = pulling
var/ok = 1
if (locate(/obj/item/weapon/grab, M.grabbed_by))
if (prob(75))
+1 -1
View File
@@ -1102,7 +1102,7 @@
proc/handle_stomach()
spawn(0)
for(var/mob/M in stomach_contents)
for(var/mob/living/M in stomach_contents)
if(M.loc != src)
stomach_contents.Remove(M)
continue
+64
View File
@@ -81,6 +81,70 @@
// world << "[src] ~ [src.bodytemperature] ~ [temperature]"
return temperature
// ++++ROCKDTBEN++++ MOB PROCS -- Ask me before touching.
// Stop! ... Hammertime! ~Carn
/mob/living/proc/getBruteLoss()
return bruteloss
/mob/living/proc/adjustBruteLoss(var/amount)
bruteloss = max(bruteloss + amount, 0)
/mob/living/proc/getOxyLoss()
return oxyloss
/mob/living/proc/adjustOxyLoss(var/amount)
oxyloss = max(oxyloss + amount, 0)
/mob/living/proc/setOxyLoss(var/amount)
oxyloss = amount
/mob/living/proc/getToxLoss()
return toxloss
/mob/living/proc/adjustToxLoss(var/amount)
toxloss = max(toxloss + amount, 0)
/mob/living/proc/setToxLoss(var/amount)
toxloss = amount
/mob/living/proc/getFireLoss()
return fireloss
/mob/living/proc/adjustFireLoss(var/amount)
fireloss = max(fireloss + amount, 0)
/mob/living/proc/getCloneLoss()
return cloneloss
/mob/living/proc/adjustCloneLoss(var/amount)
cloneloss = max(cloneloss + amount, 0)
/mob/living/proc/setCloneLoss(var/amount)
cloneloss = amount
/mob/living/proc/getBrainLoss()
return brainloss
/mob/living/proc/adjustBrainLoss(var/amount)
brainloss = max(brainloss + amount, 0)
/mob/living/proc/setBrainLoss(var/amount)
brainloss = amount
/mob/living/proc/getHalLoss()
return halloss
/mob/living/proc/adjustHalLoss(var/amount)
halloss = max(halloss + amount, 0)
/mob/living/proc/setHalLoss(var/amount)
halloss = amount
// ++++ROCKDTBEN++++ MOB PROCS //END
/mob/proc/get_contents()
/mob/living/get_contents()
+17
View File
@@ -0,0 +1,17 @@
/mob/living
//Vars that should only be accessed via procs
var/bruteloss = 0.0 //Brutal damage caused by brute force (punching, being clubbed by a toolbox ect... this also accounts for pressure damage)
var/oxyloss = 0.0 //Oxygen depravation damage (no air in lungs)
var/toxloss = 0.0 //Toxic damage caused by being poisoned or radiated
var/fireloss = 0.0 //Burn damage caused by being way too hot, too cold or burnt.
var/cloneloss = 0 //Damage caused by being cloned or ejected from the cloner early. Metroids also deal cloneloss damage to victims
var/brainloss = 0 //'Retardation' damage caused by someone hitting you in the head with a bible or being infected with brainrot.
var/halloss = 0 //Hallucination damage. 'Fake' damage obtained through hallucinating or the holodeck. Sleeping should cause it to wear off.
//Vars that should only be accessed via procs ++END
var/hallucination = 0 //Directly affects how long a mob will hallucinate for
var/list/atom/hallucinations = list() //A list of hallucinated people that try to attack the mob. See /obj/effect/fake_attacker in hallucinations.dm
var/last_special = 0 //Used by the resist verb, likely used to prevent players from bypassing next_move by logging in/out.
-70
View File
@@ -812,82 +812,12 @@ note dizziness decrements automatically in the mob's Life() proc.
resting = max(resting + amount,0)
return
// ++++ROCKDTBEN++++ MOB PROCS -- Ask me before touching.
// Stop! ... Hammertime! ~Carn
/mob/proc/getBruteLoss()
return bruteloss
/mob/proc/adjustBruteLoss(var/amount)
bruteloss = max(bruteloss + amount, 0)
/mob/proc/getOxyLoss()
return oxyloss
/mob/proc/adjustOxyLoss(var/amount)
oxyloss = max(oxyloss + amount, 0)
/mob/proc/setOxyLoss(var/amount)
oxyloss = amount
/mob/proc/getToxLoss()
return toxloss
/mob/proc/adjustToxLoss(var/amount)
toxloss = max(toxloss + amount, 0)
/mob/proc/setToxLoss(var/amount)
toxloss = amount
/mob/proc/getFireLoss()
return fireloss
/mob/proc/adjustFireLoss(var/amount)
fireloss = max(fireloss + amount, 0)
/mob/proc/getCloneLoss()
return cloneloss
/mob/proc/adjustCloneLoss(var/amount)
cloneloss = max(cloneloss + amount, 0)
/mob/proc/setCloneLoss(var/amount)
cloneloss = amount
/mob/proc/getHalLoss()
return halloss
/mob/proc/adjustHalLoss(var/amount)
halloss = max(halloss + amount, 0)
/mob/proc/setHalLoss(var/amount)
halloss = amount
/mob/proc/getBrainLoss()
return brainloss
/mob/proc/adjustBrainLoss(var/amount)
brainloss = max(brainloss + amount, 0)
/mob/proc/setBrainLoss(var/amount)
brainloss = amount
/mob/proc/getDNA()
return dna
/mob/proc/setDNA(var/datum/dna/newDNA)
dna = newDNA
/mob/proc/getMaxHealth()
return maxHealth
/mob/proc/setMaxHealth(var/newMaxHealth)
maxHealth = newMaxHealth
// ++++ROCKDTBEN++++ MOB PROCS //END
/*
* Sends resource files to client cache
*/
+1 -22
View File
@@ -5,25 +5,10 @@
flags = NOREACT
var/datum/mind/mind
//MOB overhaul
//Not in use yet
var/obj/effect/organstructure/organStructure = null
//Vars that have been relocated to organStructure
//Vars that have been relocated to organStructure ++END
//Vars that should only be accessed via procs
var/bruteloss = 0.0//Living
var/oxyloss = 0.0//Living
var/toxloss = 0.0//Living
var/fireloss = 0.0//Living
var/cloneloss = 0//Carbon
var/brainloss = 0//Carbon
var/maxHealth = 100 //Living
//Vars that should only be accessed via procs ++END
var/maxHealth = 100 //Maximum health that should be possible. Used by living, organ and simple_mobs
// var/uses_hud = 0
@@ -57,7 +42,6 @@
*/
//var/midis = 1 //Check if midis should be played for someone - no, this is something that is tied to clients, not mobs.
var/alien_egg_flag = 0//Have you been infected?
var/last_special = 0
var/obj/screen/zone_sel/zone_sel = null
var/emote_allowed = 1
@@ -238,11 +222,6 @@
var/robot_talk_understand = 0
var/alien_talk_understand = 0
//You can guess what these are for. --SkyMarshal
var/list/atom/hallucinations = list()
var/halloss = 0
var/hallucination = 0
/*For ninjas and others. This variable is checked when a mob moves and I guess it was supposed to allow the mob to move
through dense areas, such as walls. Setting density to 0 does the same thing. The difference here is that
the mob is also allowed to move without any sort of restriction. For instance, in space or out of holder objects.*/
+4 -2
View File
@@ -57,8 +57,10 @@
var/ending = copytext(text, length(text))
if (src.stuttering)
return "stammers, \"[text]\"";
if (src.getBrainLoss() >= 60)
return "gibbers, \"[text]\"";
if(isliving(src))
var/mob/living/L = src
if (L.getBrainLoss() >= 60)
return "gibbers, \"[text]\"";
if (ending == "?")
return "asks, \"[text]\"";
if (ending == "!")
+77 -74
View File
@@ -521,7 +521,7 @@
return
/mob/living/verb/mob_sleep()
/mob/living/carbon/verb/mob_sleep()
set name = "Sleep"
set category = "IC"
@@ -531,7 +531,7 @@
else
usr.sleeping = 20 //Short nap
/mob/living/verb/lay_down()
/mob/living/carbon/verb/lay_down()
set name = "Lay down / Get up"
set category = "IC"
@@ -543,14 +543,16 @@
set name = "Resist"
set category = "IC"
if(usr.next_move > world.time)
if(!isliving(usr) || usr.next_move > world.time)
return
usr.next_move = world.time + 20
var/mob/living/L = usr
//resisting grabs (as if it helps anyone...)
if ((!( usr.stat ) && usr.canmove && !( usr.restrained() )))
if ((!( L.stat ) && L.canmove && !( L.restrained() )))
var/resisting = 0
for(var/obj/O in usr.requests)
for(var/obj/O in L.requests)
del(O)
resisting++
for(var/obj/item/weapon/grab/G in usr.grabbed_by)
@@ -560,86 +562,46 @@
else
if (G.state == 2)
if (prob(25))
for(var/mob/O in viewers(usr, null))
O.show_message(text("\red [] has broken free of []'s grip!", usr, G.assailant), 1)
for(var/mob/O in viewers(L, null))
O.show_message(text("\red [] has broken free of []'s grip!", L, G.assailant), 1)
del(G)
else
if (G.state == 3)
if (prob(5))
for(var/mob/O in viewers(usr, null))
O.show_message(text("\red [] has broken free of []'s headlock!", usr, G.assailant), 1)
O.show_message(text("\red [] has broken free of []'s headlock!", L, G.assailant), 1)
del(G)
if(resisting)
for(var/mob/O in viewers(usr, null))
O.show_message(text("\red <B>[] resists!</B>", usr), 1)
O.show_message(text("\red <B>[] resists!</B>", L), 1)
//breaking out of handcuffs
if(usr:handcuffed && usr:canmove && (usr.last_special <= world.time))
usr.next_move = world.time + 100
usr.last_special = world.time + 100
if(isalienadult(usr) || (HULK in usr.mutations) || (SUPRSTR in usr.augmentations))//Don't want to do a lot of logic gating here.
usr << "\green You attempt to break your handcuffs. (This will take around 5 seconds and you need to stand still)"
for(var/mob/O in viewers(usr))
O.show_message(text("\red <B>[] is trying to break the handcuffs!</B>", usr), 1)
spawn(0)
if(do_after(usr, 50))
if(!usr:handcuffed || usr:buckled)
return
for(var/mob/O in viewers(usr))
O.show_message(text("\red <B>[] manages to break the handcuffs!</B>", usr), 1)
usr << "\green You successfully break your handcuffs."
del(usr:handcuffed)
usr:handcuffed = null
usr.update_inv_handcuffed()
else
var/obj/item/weapon/handcuffs/HC = usr:handcuffed
var/breakouttime = 1200 //A default in case you are somehow handcuffed with something that isn't an obj/item/weapon/handcuffs type
var/displaytime = 2 //Minutes to display in the "this will take X minutes."
if(istype(HC)) //If you are handcuffed with actual handcuffs... Well what do I know, maybe someone will want to handcuff you with toilet paper in the future...
breakouttime = HC.breakouttime
displaytime = breakouttime / 600 //Minutes
usr << "\red You attempt to remove \the [HC]. (This will take around [displaytime] minutes and you need to stand still)"
for(var/mob/O in viewers(usr))
O.show_message( "\red <B>[usr] attempts to remove \the [HC]!</B>", 1)
spawn(0)
if(do_after(usr, breakouttime))
if(!usr:handcuffed || usr:buckled)
return // time leniency for lag which also might make this whole thing pointless but the server
for(var/mob/O in viewers(usr))// lags so hard that 40s isn't lenient enough - Quarxink
O.show_message("\red <B>[usr] manages to remove the handcuffs!</B>", 1)
usr << "\blue You successfully remove \the [usr:handcuffed]."
usr:handcuffed.loc = usr.loc
usr:handcuffed = null
usr.update_inv_handcuffed()
//unbuckling yourself
else if( usr:buckled && (usr.last_special <= world.time) )
if( usr:handcuffed )
usr.next_move = world.time + 100
usr.last_special = world.time + 100
usr << "\red You attempt to unbuckle yourself. (This will take around 2 minutes and you need to stand still)"
for(var/mob/O in viewers(usr))
if( L.buckled && (L.last_special <= world.time) )
if( L.handcuffed )
L.next_move = world.time + 100
L.last_special = world.time + 100
L << "\red You attempt to unbuckle yourself. (This will take around 2 minutes and you need to stand still)"
for(var/mob/O in viewers(L))
O.show_message("\red <B>[usr] attempts to unbuckle themself!</B>", 1)
spawn(0)
if(do_after(usr, 1200))
if(!usr:buckled)
if(!L.buckled)
return
for(var/mob/O in viewers(usr))
for(var/mob/O in viewers(L))
O.show_message("\red <B>[usr] manages to unbuckle themself!</B>", 1)
usr << "\blue You successfully unbuckle yourself."
usr:buckled.manual_unbuckle(usr)
L << "\blue You successfully unbuckle yourself."
L.buckled.manual_unbuckle(L)
else
usr:buckled.manual_unbuckle(usr)
L.buckled.manual_unbuckle(L)
//Breaking out of a locker?
else if( src.loc && (istype(src.loc, /obj/structure/closet)) )
var/obj/structure/closet/C = usr.loc
var/obj/structure/closet/C = L.loc
if(C.opened)
return //Door's open... wait, why are you in it's contents then?
if(istype(usr.loc, /obj/structure/closet/secure_closet))
var/obj/structure/closet/secure_closet/SC = usr.loc
if(istype(L.loc, /obj/structure/closet/secure_closet))
var/obj/structure/closet/secure_closet/SC = L.loc
if(!SC.locked && !SC.welded)
return //It's a secure closet, but isn't locked. Easily escapable from, no need to 'resist'
else
@@ -648,18 +610,18 @@
//okay, so the closet is either welded or locked... resist!!!
usr.next_move = world.time + 100
usr.last_special = world.time + 100
usr << "\red You lean on the back of \the [C] and start pushing the door open. (this will take about 2 minutes)"
L.last_special = world.time + 100
L << "\red You lean on the back of \the [C] and start pushing the door open. (this will take about 2 minutes)"
for(var/mob/O in viewers(usr.loc))
O.show_message("\red <B>The [usr.loc] begins to shake violently!</B>", 1)
O.show_message("\red <B>The [L.loc] begins to shake violently!</B>", 1)
spawn(0)
if(do_after(usr, 50))
if(!C || !usr || usr.loc != C || C.opened) //User, closet destroyed OR user no longer in closet OR closet opened
if(!C || !L || L.loc != C || C.opened) //User, closet destroyed OR user no longer in closet OR closet opened
return
//Perform the same set of checks as above for weld and lock status to determine if there is even still a point in 'resisting'...
if(istype(usr.loc, /obj/structure/closet/secure_closet))
var/obj/structure/closet/secure_closet/SC = usr.loc
if(istype(L.loc, /obj/structure/closet/secure_closet))
var/obj/structure/closet/secure_closet/SC = L.loc
if(!SC.locked && !SC.welded)
return
else
@@ -668,7 +630,7 @@
//Well then break it!
if(istype(usr.loc, /obj/structure/closet/secure_closet))
var/obj/structure/closet/secure_closet/SC = usr.loc
var/obj/structure/closet/secure_closet/SC = L.loc
SC.desc = "It appears to be broken."
SC.icon_state = SC.icon_off
flick(SC.icon_broken, SC)
@@ -678,12 +640,53 @@
SC.broken = 1
SC.locked = 0
usr << "\red You successfully break out!"
for(var/mob/O in viewers(usr.loc))
for(var/mob/O in viewers(L.loc))
O.show_message("\red <B>\the [usr] successfully broke out of \the [SC]!</B>", 1)
SC.open()
else
C.welded = 0
usr << "\red You successfully break out!"
for(var/mob/O in viewers(usr.loc))
for(var/mob/O in viewers(L.loc))
O.show_message("\red <B>\the [usr] successfully broke out of \the [C]!</B>", 1)
C.open()
C.open()
//breaking out of handcuffs
else if(iscarbon(L))
var/mob/living/carbon/CM = L
if(CM.handcuffed && CM.canmove && (CM.last_special <= world.time))
CM.next_move = world.time + 100
CM.last_special = world.time + 100
if(isalienadult(CM) || (HULK in usr.mutations) || (SUPRSTR in CM.augmentations))//Don't want to do a lot of logic gating here.
usr << "\green You attempt to break your handcuffs. (This will take around 5 seconds and you need to stand still)"
for(var/mob/O in viewers(CM))
O.show_message(text("\red <B>[] is trying to break the handcuffs!</B>", CM), 1)
spawn(0)
if(do_after(CM, 50))
if(!CM.handcuffed || CM.buckled)
return
for(var/mob/O in viewers(CM))
O.show_message(text("\red <B>[] manages to break the handcuffs!</B>", CM), 1)
CM << "\green You successfully break your handcuffs."
del(CM.handcuffed)
CM.handcuffed = null
CM.update_inv_handcuffed()
else
var/obj/item/weapon/handcuffs/HC = CM.handcuffed
var/breakouttime = 1200 //A default in case you are somehow handcuffed with something that isn't an obj/item/weapon/handcuffs type
var/displaytime = 2 //Minutes to display in the "this will take X minutes."
if(istype(HC)) //If you are handcuffed with actual handcuffs... Well what do I know, maybe someone will want to handcuff you with toilet paper in the future...
breakouttime = HC.breakouttime
displaytime = breakouttime / 600 //Minutes
CM << "\red You attempt to remove \the [HC]. (This will take around [displaytime] minutes and you need to stand still)"
for(var/mob/O in viewers(CM))
O.show_message( "\red <B>[usr] attempts to remove \the [HC]!</B>", 1)
spawn(0)
if(do_after(CM, breakouttime))
if(!CM.handcuffed || CM.buckled)
return // time leniency for lag which also might make this whole thing pointless but the server
for(var/mob/O in viewers(CM))// lags so hard that 40s isn't lenient enough - Quarxink
O.show_message("\red <B>[CM] manages to remove the handcuffs!</B>", 1)
CM << "\blue You successfully remove \the [CM.handcuffed]."
CM.handcuffed.loc = usr.loc
CM.handcuffed = null
CM.update_inv_handcuffed()
@@ -48,7 +48,7 @@
flag = "energy"
on_hit(var/atom/target, var/blocked = 0)
var/mob/M = target
var/mob/living/M = target
if(istype(target, /mob/living) && M:mutantrace == "plant") //Plantmen possibly get mutated and damaged by the rays.
var/mob/living/L as mob
if(prob(15))