Merge pull request #9812 from PsiOmegaDelta/150614-MakingYourLifeEvenEasierApplyDirectlyToForehead

Refactors Life() - Part II
This commit is contained in:
Zuhayr
2015-06-28 20:20:49 +09:30
18 changed files with 244 additions and 117 deletions
+8 -21
View File
@@ -10,26 +10,14 @@
..()
if (stat != DEAD) //still breathing
// GROW!
update_progression()
// Chemicals in the body
handle_chemicals_in_body()
blinded = null
//Status updates, death etc.
handle_regular_status_updates()
update_canmove()
update_icons()
if(client)
handle_regular_hud_updates()
/mob/living/carbon/alien/proc/handle_chemicals_in_body()
return // Nothing yet. Maybe check it out at a later date.
/mob/living/carbon/alien/handle_mutations_and_radiation()
// Currently both Dionaea and larvae like to eat radiation, so I'm defining the
@@ -46,7 +34,7 @@
adjustToxLoss(-(rads))
return
/mob/living/carbon/alien/proc/handle_regular_status_updates()
/mob/living/carbon/alien/handle_regular_status_updates()
if(status_flags & GODMODE) return 0
@@ -97,18 +85,11 @@
else if(eye_blurry)
eye_blurry = max(eye_blurry-1, 0)
//Ears
if(sdisabilities & DEAF) //disabled-deaf, doesn't get better on its own
ear_deaf = max(ear_deaf, 1)
else if(ear_deaf) //deafness, heals slowly over time
ear_deaf = max(ear_deaf-1, 0)
ear_damage = max(ear_damage-0.05, 0)
update_icons()
return 1
/mob/living/carbon/alien/proc/handle_regular_hud_updates()
/mob/living/carbon/alien/handle_regular_hud_updates()
if (stat == 2 || (XRAY in src.mutations))
sight |= SEE_TURFS
@@ -180,3 +161,9 @@
src << "\red You feel a searing heat!"
else
if (fire) fire.icon_state = "fire0"
/mob/living/carbon/alien/handle_fire()
if(..())
return
bodytemperature += BODYTEMP_HEATING_MAX //If you're on fire, you heat up!
return
+3 -25
View File
@@ -1,28 +1,6 @@
/mob/living/carbon/brain/handle_breathing()
return
/mob/living/carbon/brain/Life()
set invisibility = 0
set background = 1
..()
if(stat != DEAD)
//Chemicals in the body
handle_chemicals_in_body()
//Apparently, the person who wrote this code designed it so that
//blinded get reset each cycle and then get activated later in the
//code. Very ugly. I dont care. Moving this stuff here so its easy
//to find it.
blinded = null
//Status updates, death etc.
handle_regular_status_updates()
update_canmove()
if(client)
handle_regular_hud_updates()
/mob/living/carbon/brain/handle_mutations_and_radiation()
if (radiation)
if (radiation > 100)
@@ -91,7 +69,7 @@
adjustFireLoss(5.0*discomfort)
/mob/living/carbon/brain/proc/handle_chemicals_in_body()
/mob/living/carbon/brain/handle_chemicals_in_body()
chem_effects.Cut()
analgesic = 0
@@ -113,7 +91,7 @@
return //TODO: DEFERRED
/mob/living/carbon/brain/proc/handle_regular_status_updates() //TODO: comment out the unused bits >_>
/mob/living/carbon/brain/handle_regular_status_updates() //TODO: comment out the unused bits >_>
updatehealth()
if(stat == DEAD) //DEAD. BROWN BREAD. SWIMMING WITH THE SPESS CARP
@@ -183,7 +161,7 @@
handle_statuses()
return 1
/mob/living/carbon/brain/proc/handle_regular_hud_updates()
/mob/living/carbon/brain/handle_regular_hud_updates()
if (stat == 2 || (XRAY in src.mutations))
sight |= SEE_TURFS
sight |= SEE_MOBS
+22 -33
View File
@@ -47,7 +47,6 @@
//to find it.
blinded = null
fire_alert = 0 //Reset this here, because both breathe() and handle_environment() have a chance to set it.
..()
//TODO: seperate this out
// update the current life tick, can be used to e.g. only do something every 4 ticks
@@ -56,6 +55,8 @@
in_stasis = istype(loc, /obj/structure/closet/body_bag/cryobag) && loc:opened == 0
if(in_stasis) loc:used++
..()
if(life_tick%30==15)
hud_updateflag = 1022
@@ -66,23 +67,10 @@
//Updates the number of stored chemicals for powers
handle_changeling()
//Chemicals in the body
handle_chemicals_in_body()
//Disabilities
handle_disabilities()
//Organs and blood
handle_organs()
handle_blood()
stabilize_body_temperature() //Body temperature adjusts itself (self-regulation)
//Random events (vomiting etc)
handle_random_events()
//stuff in the stomach
handle_stomach()
handle_shock()
handle_pain()
@@ -96,26 +84,18 @@
handle_stasis_bag()
if(life_tick > 5 && timeofdeath && (timeofdeath < 5 || world.time - timeofdeath > 6000)) //We are long dead, or we're junk mobs spawned like the clowns on the clown shuttle
if(!handle_some_updates())
return //We go ahead and process them 5 times for HUD images and other stuff though.
//Check if we're on fire
handle_fire()
//Status updates, death etc.
handle_regular_status_updates() //Optimized a bit
update_canmove()
//Update our name based on whether our face is obscured/disfigured
name = get_visible_name()
handle_regular_hud_updates()
pulse = handle_pulse()
// Grabbing
for(var/obj/item/weapon/grab/G in src)
G.process()
/mob/living/carbon/human/proc/handle_some_updates()
if(life_tick > 5 && timeofdeath && (timeofdeath < 5 || world.time - timeofdeath > 6000)) //We are long dead, or we're junk mobs spawned like the clowns on the clown shuttle
return 0
return 1
/mob/living/carbon/human/breathe()
if(!in_stasis)
@@ -168,7 +148,7 @@
else
return ONE_ATMOSPHERE + pressure_difference
/mob/living/carbon/human/proc/handle_disabilities()
/mob/living/carbon/human/handle_disabilities()
if (disabilities & EPILEPSY)
if ((prob(1) && paralysis < 1))
src << "\red You have a seizure!"
@@ -845,7 +825,10 @@
return min(1,thermal_protection)
/mob/living/carbon/human/proc/handle_chemicals_in_body()
/mob/living/carbon/human/handle_chemicals_in_body()
if(in_stasis)
return
if(reagents)
chem_effects.Cut()
analgesic = 0
@@ -925,7 +908,10 @@
return //TODO: DEFERRED
/mob/living/carbon/human/proc/handle_regular_status_updates()
/mob/living/carbon/human/handle_regular_status_updates()
if(!handle_some_updates())
return 0
if(status_flags & GODMODE) return 0
//SSD check, if a logged player is awake put them back to sleep!
@@ -1098,7 +1084,7 @@
return 1
/mob/living/carbon/human/proc/handle_regular_hud_updates()
/mob/living/carbon/human/handle_regular_hud_updates()
if(!overlays_cache)
overlays_cache = list()
overlays_cache.len = 23
@@ -1424,7 +1410,10 @@
O.process_hud(src)
if(!druggy && !seer) see_invisible = SEE_INVISIBLE_LIVING
/mob/living/carbon/human/proc/handle_random_events()
/mob/living/carbon/human/handle_random_events()
if(in_stasis)
return
// Puke if toxloss is too high
if(!stat)
if (getToxLoss() >= 45 && nutrition > 20)
@@ -1437,7 +1426,7 @@
if(L && L.lum_r + L.lum_g + L.lum_b == 0)
playsound_local(src,pick(scarySounds),50, 1, -1)
/mob/living/carbon/human/proc/handle_stomach()
/mob/living/carbon/human/handle_stomach()
spawn(0)
for(var/mob/living/M in stomach_contents)
if(M.loc != src)
@@ -1,2 +1,2 @@
/mob/living/carbon/slime/regular_hud_updates()
/mob/living/carbon/slime/handle_regular_hud_updates()
return
@@ -8,7 +8,6 @@
..()
if(stat != DEAD)
handle_chemicals_in_body()
handle_nutrition()
if (!client)
@@ -18,10 +17,6 @@
handle_AI()
handle_speech_and_mood()
regular_hud_updates()
handle_regular_status_updates() // Status updates, death etc.
/mob/living/carbon/slime/handle_environment(datum/gas_mixture/environment)
if(!environment)
adjustToxLoss(rand(10,20))
@@ -74,7 +69,7 @@
temp_change = (temperature - current)
return temp_change
/mob/living/carbon/slime/proc/handle_chemicals_in_body()
/mob/living/carbon/slime/handle_chemicals_in_body()
chem_effects.Cut()
analgesic = 0
@@ -89,7 +84,7 @@
return //TODO: DEFERRED
/mob/living/carbon/slime/proc/handle_regular_status_updates()
/mob/living/carbon/slime/handle_regular_status_updates()
src.blinded = null
+116
View File
@@ -15,17 +15,133 @@
//Mutations and radiation
handle_mutations_and_radiation()
//Chemicals in the body
handle_chemicals_in_body()
//Blood
handle_blood()
//Random events (vomiting etc)
handle_random_events()
. = 1
//Handle temperature/pressure differences between body and environment
if(environment)
handle_environment(environment)
//Check if we're on fire
handle_fire()
//stuff in the stomach
handle_stomach()
update_gravity(mob_has_gravity())
update_pulling()
for(var/obj/item/weapon/grab/G in src)
G.process()
if(handle_regular_status_updates()) // Status & health update, are we dead or alive etc.
handle_disabilities() // eye, ear, brain damages
handle_status_effects() //all special effects, stunned, weakened, jitteryness, hallucination, sleeping, etc
handle_actions()
update_canmove()
if(client)
handle_regular_hud_updates()
/mob/living/proc/handle_breathing()
return
/mob/living/proc/handle_mutations_and_radiation()
return
/mob/living/proc/handle_chemicals_in_body()
return
/mob/living/proc/handle_blood()
return
/mob/living/proc/handle_random_events()
return
/mob/living/proc/handle_environment(var/datum/gas_mixture/environment)
return
/mob/living/proc/handle_stomach()
return
/mob/living/proc/update_pulling()
if(pulling)
if(incapacitated())
stop_pulling()
//This updates the health and status of the mob (conscious, unconscious, dead)
/mob/living/proc/handle_regular_status_updates()
updatehealth()
if(stat != DEAD)
if(paralysis)
stat = UNCONSCIOUS
else if (status_flags & FAKEDEATH)
stat = UNCONSCIOUS
else
stat = CONSCIOUS
return 1
//this updates all special effects: stunned, sleeping, weakened, druggy, stuttering, etc..
/mob/living/proc/handle_status_effects()
if(paralysis)
paralysis = max(paralysis-1,0)
if(stunned)
stunned = max(stunned-1,0)
if(!stunned)
update_icons()
if(weakened)
weakened = max(weakened-1,0)
if(!weakened)
update_icons()
/mob/living/proc/handle_disabilities()
//Eyes
if(disabilities & BLIND || stat) //blindness from disability or unconsciousness doesn't get better on its own
eye_blind = max(eye_blind, 1)
else if(eye_blind) //blindness, heals slowly over time
eye_blind = max(eye_blind-1,0)
else if(eye_blurry) //blurry eyes heal slowly
eye_blurry = max(eye_blurry-1, 0)
//Ears
if(disabilities & DEAF) //disabled-deaf, doesn't get better on its own
setEarDamage(-1, max(ear_deaf, 1))
else
// deafness heals slowly over time, unless ear_damage is over 100
if(ear_damage < 100)
adjustEarDamage(-0.05,-1)
//this handles hud updates. Calls update_vision() and handle_hud_icons()
/mob/living/handle_regular_hud_updates()
if(!client) return 0
..()
handle_vision()
handle_hud_icons()
return 1
/mob/living/proc/handle_vision()
return
/mob/living/proc/update_sight()
return
/mob/living/proc/handle_hud_icons()
handle_hud_icons_health()
return
/mob/living/proc/handle_hud_icons_health()
return
+12 -5
View File
@@ -1,8 +1,3 @@
/mob/living/Life()
..()
if(stat != DEAD)
handle_actions()
//mob verbs are faster than object verbs. See mob/verb/examine.
/mob/living/verb/pulled(atom/movable/AM as mob|obj in oview(1))
set name = "Pull"
@@ -800,3 +795,15 @@ default behaviour is:
return
..()
//damage/heal the mob ears and adjust the deaf amount
/mob/living/adjustEarDamage(var/damage, var/deaf)
ear_damage = max(0, ear_damage + damage)
ear_deaf = max(0, ear_deaf + deaf)
//pass a negative argument to skip one of the variable
/mob/living/setEarDamage(var/damage, var/deaf)
if(damage >= 0)
ear_damage = damage
if(deaf >= 0)
ear_deaf = deaf
+16 -16
View File
@@ -219,7 +219,7 @@
/mob/living/proc/handle_fire()
if(fire_stacks < 0)
fire_stacks = max(0, fire_stacks++) //If we've doused ourselves in water to avoid fire, dry off slowly
fire_stacks = min(0, fire_stacks++) //If we've doused ourselves in water to avoid fire, dry off slowly
if(!on_fire)
return 1
@@ -258,10 +258,6 @@
return 1
return round(FIRESUIT_MAX_HEAT_PROTECTION_TEMPERATURE*(fire_stacks/FIRE_MAX_FIRESUIT_STACKS)**2)
/mob/living/regular_hud_updates()
..()
update_action_buttons()
/mob/living/proc/handle_actions()
//Pretty bad, i'd use picked/dropped instead but the parent calls in these are nonexistent
for(var/datum/action/A in actions)
@@ -335,50 +331,54 @@
//If simple_animals are ever moved under carbon, then this can probably be moved to carbon as well
/mob/living/proc/attack_throat(obj/item/W, obj/item/weapon/grab/G, mob/user)
// Knifing
if(!W.edge || !W.force || W.damtype != BRUTE) return //unsuitable weapon
user.visible_message("<span class='danger'>\The [user] begins to slit [src]'s throat with \the [W]!</span>")
user.next_move = world.time + 20 //also should prevent user from triggering this repeatedly
if(!do_after(user, 20))
return
if(!(G && G.assailant == user && G.affecting == src)) //check that we still have a grab
return
var/damage_mod = 1
//presumably, if they are wearing a helmet that stops pressure effects, then it probably covers the throat as well
var/obj/item/clothing/head/helmet = get_equipped_item(slot_head)
if(istype(helmet) && (helmet.body_parts_covered & HEAD) && (helmet.flags & STOPPRESSUREDAMAGE))
//we don't do an armor_check here because this is not an impact effect like a weapon swung with momentum, that either penetrates or glances off.
damage_mod = 1.0 - (helmet.armor["melee"]/100)
var/total_damage = 0
for(var/i in 1 to 3)
var/damage = min(W.force*1.5, 20)*damage_mod
apply_damage(damage, W.damtype, "head", 0, sharp=W.sharp, edge=W.edge)
total_damage += damage
var/oxyloss = total_damage
if(total_damage >= 40) //threshold to make someone pass out
oxyloss = 60 // Brain lacks oxygen immediately, pass out
adjustOxyLoss(min(oxyloss, 100 - getOxyLoss())) //don't put them over 100 oxyloss
if(total_damage)
if(oxyloss >= 40)
user.visible_message("<span class='danger'>\The [user] slit [src]'s throat open with \the [W]!</span>")
else
user.visible_message("<span class='danger'>\The [user] cut [src]'s neck with \the [W]!</span>")
if(W.hitsound)
playsound(loc, W.hitsound, 50, 1, -1)
G.last_action = world.time
flick(G.hud.icon_state, G.hud)
user.attack_log += "\[[time_stamp()]\]<font color='red'> Knifed [name] ([ckey]) with [W.name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(W.damtype)])</font>"
src.attack_log += "\[[time_stamp()]\]<font color='orange'> Got knifed by [user.name] ([user.ckey]) with [W.name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(W.damtype)])</font>"
msg_admin_attack("[key_name(user)] knifed [key_name(src)] with [W.name] (INTENT: [uppertext(user.a_intent)]) (DAMTYE: [uppertext(W.damtype)])" )
return
/mob/living/incapacitated()
if(stat || paralysis || stunned || weakened || restrained())
return 1
+1 -1
View File
@@ -151,7 +151,7 @@
theAPC = null
process_queued_alarms()
regular_hud_updates()
handle_regular_hud_updates()
switch(src.sensor_mode)
if (SEC_HUD)
process_sec_hud(src,0,src.eyeobj)
+1 -1
View File
@@ -10,7 +10,7 @@
M.show_message("\red The data cable rapidly retracts back into its spool.", 3, "\red You hear a click and the sound of wire spooling rapidly.", 2)
qdel(src.cable)
regular_hud_updates()
handle_regular_hud_updates()
if(src.secHUD == 1)
process_sec_hud(src, 1)
+12 -3
View File
@@ -61,7 +61,7 @@
lights_on = 0
set_light(0)
/mob/living/silicon/robot/proc/handle_regular_status_updates()
/mob/living/silicon/robot/handle_regular_status_updates()
if(src.camera && !scrambledcodes)
if(src.stat == 2 || wires.IsIndexCut(BORG_WIRE_CAMERA))
@@ -144,7 +144,7 @@
return 1
/mob/living/silicon/robot/proc/handle_regular_hud_updates()
/mob/living/silicon/robot/handle_regular_hud_updates()
if (src.stat == 2 || XRAY in mutations || src.sight_mode & BORGXRAY)
src.sight |= SEE_TURFS
@@ -173,7 +173,7 @@
src.see_invisible = SEE_INVISIBLE_LIVING // This is normal vision (25), setting it lower for normal vision means you don't "see" things like darkness since darkness
// has a "invisible" value of 15
regular_hud_updates()
handle_regular_hud_updates()
var/obj/item/borg/sight/hud/hud = (locate(/obj/item/borg/sight/hud) in src)
if(hud && hud.hud)
@@ -331,3 +331,12 @@
if(paralysis || stunned || weakened || buckled || lockcharge || !is_component_functioning("actuator")) canmove = 0
else canmove = 1
return canmove
/mob/living/silicon/robot/update_fire()
overlays -= image("icon"='icons/mob/OnFire.dmi', "icon_state"="Standing")
if(on_fire)
overlays += image("icon"='icons/mob/OnFire.dmi', "icon_state"="Standing")
/mob/living/silicon/robot/fire_act()
if(!on_fire) //Silicons don't gain stacks from hotspots, but hotspots can ignite them
IgniteMob()
@@ -350,3 +350,9 @@
/mob/living/silicon/proc/is_malf_or_traitor()
return is_traitor() || is_malf()
/mob/living/silicon/adjustEarDamage()
return
/mob/living/silicon/setEarDamage()
return
@@ -307,7 +307,7 @@
else
usr << "<span class='danger>This weapon is ineffective, it does no damage.</span>"
visible_message("<span class='danger'>\The [src] has been attacked with the [O] by [user].</span>")
visible_message("<span class='danger'>\The [src] has been attacked with \the [O] by [user].</span>")
user.do_attack_animation(src)
/mob/living/simple_animal/movement_delay()
@@ -404,3 +404,13 @@
else
user.visible_message("<span class='danger'>[user] butchers \the [src] messily!</span>")
gib()
/mob/living/simple_animal/handle_fire()
return
/mob/living/simple_animal/update_fire()
return
/mob/living/simple_animal/IgniteMob()
return
/mob/living/simple_animal/ExtinguishMob()
return
+8
View File
@@ -118,6 +118,8 @@
//handle_typing_indicator() //You said the typing indicator would be fine. The test determined that was a lie.
return
/mob/proc/incapacitated()
return
/mob/proc/restrained()
return
@@ -1026,3 +1028,9 @@ mob/proc/yank_out_object()
/mob/verb/westfaceperm()
set hidden = 1
set_face_dir(WEST)
/mob/proc/adjustEarDamage()
return
/mob/proc/setEarDamage()
return
+6
View File
@@ -520,3 +520,9 @@
prob_slip = round(prob_slip)
return(prob_slip)
/mob/proc/mob_has_gravity(turf/T)
return has_gravity(src, T)
/mob/proc/update_gravity()
return
+3 -1
View File
@@ -35,7 +35,9 @@ var/const/BLOOD_VOLUME_SURVIVE = 122
B.color = B.data["blood_colour"]
// Takes care blood loss and regeneration
/mob/living/carbon/human/proc/handle_blood()
/mob/living/carbon/human/handle_blood()
if(in_stasis)
return
if(species && species.flags & NO_BLOOD)
return