More work on living/life.dm(), simple_animal/life() and robot/life().

This commit is contained in:
phil235
2015-03-14 16:30:59 +01:00
parent 282d0231e0
commit 1e720ae033
10 changed files with 167 additions and 342 deletions
+2 -36
View File
@@ -41,15 +41,13 @@
/mob/living/carbon/alien/handle_vision()
client.screen.Remove(global_hud.blurry, global_hud.druggy, global_hud.vimpaired, global_hud.darkMask)
if (stat == 2)
if (stat == DEAD)
sight |= SEE_TURFS
sight |= SEE_MOBS
sight |= SEE_OBJS
see_in_dark = 8
see_invisible = SEE_INVISIBLE_LEVEL_TWO
else if (stat != 2)
else if (stat != DEAD)
sight |= SEE_MOBS
sight &= ~SEE_TURFS
sight &= ~SEE_OBJS
@@ -62,40 +60,8 @@
if(see_override)
see_invisible = see_override
if ((blind && stat != 2))
if((eye_blind))
blind.layer = 18
else
blind.layer = 0
if (disabilities & NEARSIGHT)
client.screen += global_hud.vimpaired
if (eye_blurry)
client.screen += global_hud.blurry
if (druggy)
client.screen += global_hud.druggy
if (stat != 2)
if(machine)
if (!( machine.check_eye(src) ))
reset_view(null)
else
if(!client.adminobs)
reset_view(null)
/mob/living/carbon/alien/handle_hud_icons()
handle_hud_icons_health()
if(pullin)
if(pulling)
pullin.icon_state = "pull"
else
pullin.icon_state = "pull0"
return 1
+6 -78
View File
@@ -14,54 +14,12 @@
return
if(!loc)
return
var/datum/gas_mixture/environment = loc.return_air()
if(stat != DEAD)
//Breathing, if applicable
handle_breathing()
if(..())
//Updates the number of stored chemicals for powers
handle_changeling()
//Mutations and radiation
handle_mutations_and_radiation()
//Chemicals in the body
handle_chemicals_in_body()
//Blud
handle_blood()
//Random events (vomiting etc)
handle_random_events()
. = 1
//Handle temperature/pressure differences between body and environment
handle_environment(environment)
handle_fire()
//stuff in the stomach
handle_stomach()
update_canmove()
update_gravity(mob_has_gravity())
for(var/obj/item/weapon/grab/G in src)
G.process()
handle_regular_status_updates() // Status updates, death etc.
if(client)
handle_regular_hud_updates()
return .
///////////////
// BREATHING //
///////////////
@@ -253,7 +211,7 @@
return
/mob/living/carbon/handle_changeling()
/mob/living/carbon/proc/handle_changeling()
return
/mob/living/carbon/handle_mutations_and_radiation()
@@ -341,6 +299,7 @@
if(getOxyLoss() > 50 || health <= config.health_threshold_crit)
Paralyse(3)
stat = UNCONSCIOUS
..()
@@ -503,15 +462,11 @@
damageoverlay.overlays += I
damageoverlay.overlays += black
handle_vision()
handle_hud_icons()
..()
return 1
/mob/living/carbon/handle_vision()
client.screen.Remove(global_hud.blurry, global_hud.druggy, global_hud.vimpaired, global_hud.darkMask)
/mob/living/carbon/update_sight()
if(stat == DEAD)
sight |= SEE_TURFS
@@ -528,38 +483,11 @@
if(see_override)
see_invisible = see_override
if(blind)
if(eye_blind)
blind.layer = 18
else
blind.layer = 0
if (disabilities & NEARSIGHT)
client.screen += global_hud.vimpaired
if (eye_blurry)
client.screen += global_hud.blurry
if (druggy)
client.screen += global_hud.druggy
if(eye_stat > 20)
if(eye_stat > 30)
client.screen += global_hud.darkMask
else
client.screen += global_hud.vimpaired
if(machine)
if (!( machine.check_eye(src) ))
reset_view(null)
else
if(!client.adminobs)
reset_view(null)
/mob/living/carbon/handle_hud_icons()
return
/mob/living/carbon/proc/handle_hud_icons_health()
/mob/living/carbon/handle_hud_icons_health()
if(healths)
if (stat != DEAD)
switch(health)
+23 -40
View File
@@ -13,9 +13,6 @@
//Breathing, if applicable
handle_breathing()
//Updates the number of stored chemicals for powers
handle_changeling()
//Mutations and radiation
handle_mutations_and_radiation()
@@ -28,10 +25,16 @@
//Random events (vomiting etc)
handle_random_events()
if(!client && !stat)
handle_automated_movement()
handle_automated_speech()
. = 1
//Handle temperature/pressure differences between body and environment
handle_environment(environment)
if(environment)
handle_environment(environment)
handle_fire()
@@ -56,9 +59,6 @@
/mob/living/proc/handle_breathing()
/mob/living/proc/handle_changeling()
return
/mob/living/proc/handle_mutations_and_radiation()
if(radiation)
@@ -88,23 +88,6 @@
if(reagents)
reagents.metabolize(src)
if(drowsyness)
drowsyness--
eye_blurry = max(2, eye_blurry)
if(prob(5))
sleeping += 1
Paralyse(5)
confused = max(0, confused - 1)
// decrement dizziness counter, clamped to 0
if(resting)
dizziness = max(0, dizziness - 5)
jitteriness = max(0, jitteriness - 5)
else
dizziness = max(0, dizziness - 1)
jitteriness = max(0, jitteriness - 1)
updatehealth()
return
/mob/living/proc/handle_blood()
@@ -121,8 +104,9 @@
/mob/living/proc/handle_regular_status_updates()
updatehealth()
if(stat != DEAD)
updatehealth()
if(paralysis)
AdjustParalysis(-1)
@@ -148,6 +132,12 @@
return 1
/mob/living/proc/handle_automated_movement()
return
/mob/living/proc/handle_automated_speech()
return
/mob/living/proc/handle_disabilities()
//Eyes
if(disabilities & BLIND || stat) //blindness from disability or unconsciousness doesn't get better on its own
@@ -179,21 +169,9 @@
client.screen.Remove(global_hud.blurry, global_hud.druggy, global_hud.vimpaired, global_hud.darkMask)
if(stat == DEAD)
sight |= SEE_TURFS
sight |= SEE_MOBS
sight |= SEE_OBJS
see_in_dark = 8
see_invisible = SEE_INVISIBLE_LEVEL_TWO
else
sight &= ~SEE_TURFS
sight &= ~SEE_MOBS
sight &= ~SEE_OBJS
see_in_dark = 2
see_invisible = SEE_INVISIBLE_LIVING
if(see_override)
see_invisible = see_override
update_sight()
if(stat != DEAD)
if(blind)
if(eye_blind)
blind.layer = 18
@@ -222,7 +200,12 @@
if(!client.adminobs)
reset_view(null)
/mob/living/proc/handle_hud_icons()
/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
+2 -2
View File
@@ -1,11 +1,11 @@
/mob/living/silicon/ai/Life()
if (src.stat == 2)
if (src.stat == DEAD)
return
else //I'm not removing that shitton of tabs, unneeded as they are. -- Urist
//Being dead doesn't mean your temperature never changes
var/turf/T = get_turf(src)
if (src.stat!=0)
if (src.stat!= CONSCIOUS)
src.cameraFollow = null
src.reset_view(null)
src.unset_machine()
+1 -1
View File
@@ -1,5 +1,5 @@
/mob/living/silicon/pai/Life()
if (src.stat == 2)
if (src.stat == DEAD)
return
if(src.cable)
if(get_dist(src, src.cable) > 1)
@@ -19,7 +19,8 @@
..(animate, "dust-r")
/mob/living/silicon/robot/death(gibbed)
if(stat == DEAD) return
if(stat == DEAD)
return
if(!gibbed)
emote("deathgasp")
stat = DEAD
@@ -29,7 +30,8 @@
uneq_all() // particularly to ensure sight modes are cleared
if(blind) blind.layer = 0
if(blind)
blind.layer = 0
sight |= SEE_TURFS|SEE_MOBS|SEE_OBJS
see_in_dark = 8
see_invisible = SEE_INVISIBLE_LEVEL_TWO
+92 -145
View File
@@ -5,23 +5,8 @@
if (src.notransform)
return
//Status updates, death etc.
clamp_values()
handle_regular_status_updates()
if(client)
handle_regular_hud_updates()
update_items()
if (src.stat != DEAD) //still using power
use_power()
update_canmove()
update_gravity(mob_has_gravity())
handle_fire()
..()
/mob/living/silicon/robot/proc/clamp_values()
@@ -36,51 +21,40 @@
/mob/living/silicon/robot/proc/use_power()
if (src.cell)
if(src.cell.charge <= 0)
if(cell)
if(cell.charge <= 0)
uneq_all()
src.stat = 1
else if (src.cell.charge <= 100)
stat = UNCONSCIOUS
else if (cell.charge <= 100)
uneq_all()
src.cell.use(1)
cell.use(1)
else
if(src.module_state_1)
src.cell.use(5)
if(src.module_state_2)
src.cell.use(5)
if(src.module_state_3)
src.cell.use(5)
src.cell.use(1)
src.eye_blind = 0
src.stat = 0
if(module_state_1)
cell.use(5)
if(module_state_2)
cell.use(5)
if(module_state_3)
cell.use(5)
cell.use(1)
else
uneq_all()
src.stat = 1
stat = UNCONSCIOUS
/mob/living/silicon/robot/handle_regular_status_updates()
if(src.camera && !scrambledcodes)
if(src.stat == 2 || wires.IsCameraCut())
src.camera.status = 0
if(camera && !scrambledcodes)
if(stat == DEAD || wires.IsCameraCut())
camera.status = 0
else
src.camera.status = 1
camera.status = 1
health = maxHealth - (getOxyLoss() + getFireLoss() + getBruteLoss())
updatehealth()
if(getOxyLoss() > 50) Paralyse(3)
if(src.sleeping)
Paralyse(3)
src.sleeping--
if(src.resting)
Weaken(5)
if(health <= config.health_threshold_dead && src.stat != 2) //die only once
if(health <= config.health_threshold_dead && stat != DEAD) //die only once
death()
if (src.stat != 2) //Alive.
if (stat != DEAD) //Alive.
if(health < 50) //Gradual break down of modules as more damage is sustained
if(uneq_module(module_state_3))
src << "<span class='warning'>SYSTEM ERROR: Module 3 OFFLINE.</span>"
@@ -91,47 +65,58 @@
if(uneq_module(module_state_1))
src << "<span class='warning'>CRITICAL ERROR: All modules OFFLINE.</span>"
if (src.paralysis || src.stunned || src.weakened) //Stunned etc.
src.stat = 1
if (src.stunned > 0)
if(getOxyLoss() > 50)
Paralyse(3)
if (paralysis || stunned || weakened) //Stunned etc.
stat = UNCONSCIOUS
if (stunned > 0)
AdjustStunned(-1)
if (src.weakened > 0)
if (weakened > 0)
AdjustWeakened(-1)
if (src.paralysis > 0)
if (paralysis > 0)
AdjustParalysis(-1)
src.eye_blind = max(eye_blind, 1)
else
src.eye_blind = 0
eye_blind = max(eye_blind, 1)
else //Not stunned.
src.stat = 0
src.stat = CONSCIOUS
else //Dead.
src.eye_blind = 1
if (stuttering)
stuttering--
if (src.stuttering) src.stuttering--
if (druggy)
druggy = max(0, druggy-1)
if (src.eye_blind)
src.eye_blind--
handle_disabilities()
src.density = !( src.lying )
use_power()
if (src.disabilities & BLIND)
src.eye_blind = max(1, eye_blind)
if (src.eye_blurry > 0)
src.eye_blurry--
src.eye_blurry = max(0, src.eye_blurry)
if (src.druggy > 0)
src.druggy--
src.druggy = max(0, src.druggy)
return 1
return 1
/mob/living/silicon/robot/handle_regular_hud_updates()
if (src.stat == 2 || src.sight_mode & BORGXRAY)
if(!client)
return
if (syndicate)
if(ticker.mode.name == "traitor")
for(var/datum/mind/tra in ticker.mode.traitors)
if(tra.current)
var/I = image('icons/mob/mob.dmi', loc = tra.current, icon_state = "traitor") //no traitor sprite in that dmi!
src.client.images += I
if(connected_ai)
connected_ai.connected_robots -= src
connected_ai = null
if(mind)
if(!mind.special_role)
mind.special_role = "traitor"
ticker.mode.traitors += mind
..()
return 1
/mob/living/silicon/robot/update_sight()
if (stat == DEAD || src.sight_mode & BORGXRAY)
src.sight |= SEE_TURFS
src.sight |= SEE_MOBS
src.sight |= SEE_OBJS
@@ -150,7 +135,7 @@
else if (src.sight_mode & BORGTHERM)
src.sight |= SEE_MOBS
src.see_invisible = SEE_INVISIBLE_LEVEL_TWO
else if (src.stat != 2)
else if (src.stat != DEAD)
src.sight &= ~SEE_MOBS
src.sight &= ~SEE_TURFS
src.sight &= ~SEE_OBJS
@@ -158,39 +143,32 @@
if(see_override)
see_invisible = see_override
if (src.healths)
if (src.stat != 2)
/mob/living/silicon/robot/handle_hud_icons()
update_items()
update_cell()
..()
/mob/living/silicon/robot/handle_hud_icons_health()
if (healths)
if (stat != DEAD)
switch(health)
if(100 to INFINITY)
src.healths.icon_state = "health0"
healths.icon_state = "health0"
if(50 to 100)
src.healths.icon_state = "health2"
healths.icon_state = "health2"
if(0 to 50)
src.healths.icon_state = "health3"
healths.icon_state = "health3"
if(-50 to 0)
src.healths.icon_state = "health4"
healths.icon_state = "health4"
if(config.health_threshold_dead to -50)
src.healths.icon_state = "health5"
healths.icon_state = "health5"
else
src.healths.icon_state = "health6"
healths.icon_state = "health6"
else
src.healths.icon_state = "health7"
healths.icon_state = "health7"
if (src.syndicate && src.client)
if(ticker.mode.name == "traitor")
for(var/datum/mind/tra in ticker.mode.traitors)
if(tra.current)
var/I = image('icons/mob/mob.dmi', loc = tra.current, icon_state = "traitor")
src.client.images += I
if(src.connected_ai)
src.connected_ai.connected_robots -= src
src.connected_ai = null
if(src.mind)
if(!src.mind.special_role)
src.mind.special_role = "traitor"
ticker.mode.traitors += src.mind
if (src.cell)
/mob/living/silicon/robot/proc/update_cell()
if (cell)
var/cellcharge = src.cell.charge/src.cell.maxcharge
switch(cellcharge)
if(0.75 to INFINITY)
@@ -206,51 +184,18 @@
else
throw_alert("charge","nocell")
if(pullin)
if(pulling)
pullin.icon_state = "pull"
else
pullin.icon_state = "pull0"
client.screen.Remove(global_hud.blurry,global_hud.druggy,global_hud.vimpaired)
if ((src.blind && src.stat != 2))
if(src.eye_blind)
src.blind.layer = 18
else
src.blind.layer = 0
if (src.disabilities & NEARSIGHT)
src.client.screen += global_hud.vimpaired
if (src.eye_blurry)
src.client.screen += global_hud.blurry
if (src.druggy)
src.client.screen += global_hud.druggy
if (src.stat != 2)
if (src.machine)
if (!( src.machine.check_eye(src) ))
src.reset_view(null)
else
if(!client.adminobs)
reset_view(null)
return 1
/mob/living/silicon/robot/proc/update_items()
if (src.client)
src.client.screen -= src.contents
for(var/obj/I in src.contents)
if (client)
client.screen -= contents
for(var/obj/I in contents)
if(I && !(istype(I,/obj/item/weapon/stock_parts/cell) || istype(I,/obj/item/device/radio) || istype(I,/obj/machinery/camera) || istype(I,/obj/item/device/mmi)))
src.client.screen += I
if(src.module_state_1)
src.module_state_1:screen_loc = ui_inv1
if(src.module_state_2)
src.module_state_2:screen_loc = ui_inv2
if(src.module_state_3)
src.module_state_3:screen_loc = ui_inv3
client.screen += I
if(module_state_1)
module_state_1:screen_loc = ui_inv1
if(module_state_2)
module_state_2:screen_loc = ui_inv2
if(module_state_3)
module_state_3:screen_loc = ui_inv3
//Robots on fire
@@ -276,6 +221,8 @@
IgniteMob()
/mob/living/silicon/robot/update_canmove()
if(paralysis || stunned || weakened || buckled || lockcharge) canmove = 0
else canmove = 1
if(paralysis || stunned || weakened || buckled || lockcharge)
canmove = 0
else
canmove = 1
return canmove
@@ -347,25 +347,21 @@
/mob/living/simple_animal/parrot/Life()
..()
//Sprite and AI update for when a parrot gets pulled
//Sprite update for when a parrot gets pulled
if(pulledby && stat == CONSCIOUS)
icon_state = "parrot_fly"
if(!client)
parrot_state = PARROT_WANDER
return
if(client || stat)
return //Lets not force players or dead/incap parrots to move
if(!isturf(src.loc) || !canmove || buckled)
return //If it can't move, dont let it move. (The buckled check probably isn't necessary thanks to canmove)
//-----SPEECH
/* Parrot speech mimickry!
Phrases that the parrot Hear()s get added to speach_buffer.
Every once in a while, the parrot picks one of the lines from the buffer and replaces an element of the 'speech' list.
Then it clears the buffer to make sure they dont magically remember something from hours ago. */
/mob/living/simple_animal/parrot/handle_automated_speech()
..()
if(speech_buffer.len && prob(10))
if(speak.len)
speak.Remove(pick(speak))
@@ -374,6 +370,10 @@
clearlist(speech_buffer)
/mob/living/simple_animal/parrot/handle_automated_movement()
if(!..())
return //If it can't or shouldn't move, dont let it move.
//-----SLEEPING
if(parrot_state == PARROT_PERCH)
if(parrot_perch && parrot_perch.loc != src.loc) //Make sure someone hasnt moved our perch on us
@@ -28,14 +28,12 @@
status_flags = CANPUSH
/mob/living/simple_animal/shade/Life()
..()
if(stat == 2)
new /obj/item/weapon/ectoplasm (src.loc)
visible_message("<span class='warning'>[src] lets out a contented sigh as their form unwinds.</span>")
ghostize()
qdel(src)
return
/mob/living/simple_animal/shade/death()
new /obj/item/weapon/ectoplasm (src.loc)
visible_message("<span class='warning'>[src] lets out a contented sigh as their form unwinds.</span>")
ghostize()
qdel(src)
return
/mob/living/simple_animal/shade/attackby(var/obj/item/O as obj, var/mob/user as mob, params) //Marker -Agouri
@@ -85,27 +85,24 @@
health = maxHealth
return
/mob/living/simple_animal/Life()
/mob/living/simple_animal/handle_regular_status_updates()
if(!..())
auto_revive()
if(stat == DEAD)
if(health > 0)
icon_state = icon_living
dead_mob_list -= src
living_mob_list += src
stat = CONSCIOUS
density = 1
update_canmove()
return 0
updatehealth()
if(health < 1)
else if(health < 1)
death()
else
handle_regular_status_updates()
//Movement
if(!client && !stop_automated_movement && wander)
/mob/living/simple_animal/proc/auto_revive()
if(stat == DEAD && health > 0)
icon_state = icon_living
dead_mob_list -= src
living_mob_list += src
stat = CONSCIOUS
density = 1
update_canmove()
/mob/living/simple_animal/handle_automated_movement()
if(!stop_automated_movement && wander)
if(isturf(src.loc) && !resting && !buckled && canmove) //This is so it only moves if it's not inside a closet, gentics machine, etc.
turns_since_move++
if(turns_since_move >= turns_per_move)
@@ -114,9 +111,10 @@
if(Process_Spacemove(anydir))
Move(get_step(src, anydir), anydir)
turns_since_move = 0
return 1
//Speaking
if(!client && speak_chance)
/mob/living/simple_animal/handle_automated_speech()
if(speak_chance)
if(rand(0,200) < speak_chance)
if(speak && speak.len)
if((emote_hear && emote_hear.len) || (emote_see && emote_see.len))
@@ -150,7 +148,7 @@
emote("me", 2, pick(emote_hear))
//Atmos
/mob/living/simple_animal/handle_environment()
var/atmos_suitable = 1
var/atom/A = src.loc
@@ -204,7 +202,8 @@
if(!atmos_suitable)
adjustBruteLoss(unsuitable_atmos_damage)
return 1
/mob/living/simple_animal/gib(var/animation = 0)
if(icon_gib)
@@ -383,7 +382,7 @@
stat(null, "Health: [round((health / maxHealth) * 100)]%")
/mob/living/simple_animal/death(gibbed)
health = 0 // so /mob/living/simple_animal/Life() doesn't magically revive them
health = 0 // so /mob/living/simple_animal/handle_regular_status_updates() doesn't magically revive them
icon_state = icon_dead
stat = DEAD
density = 0
@@ -423,6 +422,8 @@
return 0
return 1
/mob/living/simple_animal/handle_fire()
return
/mob/living/simple_animal/update_fire()
return