This repository has been archived by the owner on Sep 12, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
life.dm
160 lines (125 loc) · 5.21 KB
/
life.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/// This divisor controls how fast body temperature changes to match the environment
#define BODYTEMP_DIVISOR 8
/mob/living/proc/Life(seconds, times_fired)
set waitfor = FALSE
set invisibility = 0
if((movement_type & FLYING) && !(movement_type & FLOATING)) //TODO: Better floating
float(on = TRUE)
if (client)
var/turf/T = get_turf(src)
if(!T)
move_to_error_room()
var/msg = "[ADMIN_LOOKUPFLW(src)] was found to have no .loc with an attached client, if the cause is unknown it would be wise to ask how this was accomplished."
message_admins(msg)
send2tgs_adminless_only("Mob", msg, R_ADMIN)
log_game("[key_name(src)] was found to have no .loc with an attached client.")
// This is a temporary error tracker to make sure we've caught everything
else if (registered_z != T.z)
#ifdef TESTING
message_admins("[ADMIN_LOOKUPFLW(src)] has somehow ended up in Z-level [T.z] despite being registered in Z-level [registered_z]. If you could ask them how that happened and notify coderbus, it would be appreciated.")
#endif
log_game("Z-TRACKING: [src] has somehow ended up in Z-level [T.z] despite being registered in Z-level [registered_z].")
update_z(T.z)
else if (registered_z)
log_game("Z-TRACKING: [src] of type [src.type] has a Z-registration despite not having a client.")
update_z(null)
if (notransform)
return
if(!loc)
return
if(!IS_IN_STASIS(src))
if(stat != DEAD)
//Mutations and radiation
handle_mutations_and_radiation()
if(stat != DEAD)
//Breathing, if applicable
handle_breathing(times_fired)
handle_diseases()// DEAD check is in the proc itself; we want it to spread even if the mob is dead, but to handle its disease-y properties only if you're not.
handle_wounds()
if (QDELETED(src)) // diseases can qdel the mob via transformations
return
if(stat != DEAD)
//Random events (vomiting etc)
handle_random_events()
//Handle temperature/pressure differences between body and environment
var/datum/gas_mixture/environment = loc.return_air()
if(environment)
handle_environment(environment)
handle_gravity()
if(stat != DEAD)
handle_traits() // eye, ear, brain damages
handle_status_effects() //all special effects, stun, knockdown, jitteryness, hallucination, sleeping, etc
handle_fire()
if(machine)
machine.check_eye(src)
if(stat != DEAD)
return 1
/mob/living/proc/handle_breathing(times_fired)
return
/mob/living/proc/handle_mutations_and_radiation()
radiation = 0 //so radiation don't accumulate in simple animals
return
/mob/living/proc/handle_diseases()
return
/mob/living/proc/handle_wounds()
return
/mob/living/proc/handle_random_events()
return
// Base mob environment handler for body temperature
/mob/living/proc/handle_environment(datum/gas_mixture/environment)
var/loc_temp = get_temperature(environment)
if(loc_temp < bodytemperature) // it is cold here
if(!on_fire) // do not reduce body temp when on fire
adjust_bodytemperature(max((loc_temp - bodytemperature) / BODYTEMP_DIVISOR, BODYTEMP_COOLING_MAX))
else // this is a hot place
adjust_bodytemperature(min((loc_temp - bodytemperature) / BODYTEMP_DIVISOR, BODYTEMP_HEATING_MAX))
/mob/living/proc/handle_fire()
if(fire_stacks < 0) //If we've doused ourselves in water to avoid fire, dry off slowly
fire_stacks = min(0, fire_stacks + 1)//So we dry ourselves back to default, nonflammable.
if(!on_fire)
return TRUE //the mob is no longer on fire, no need to do the rest.
if(fire_stacks > 0)
adjust_fire_stacks(-0.1) //the fire is slowly consumed
else
ExtinguishMob()
return TRUE //mob was put out, on_fire = FALSE via ExtinguishMob(), no need to update everything down the chain.
var/datum/gas_mixture/G = loc.return_air() // Check if we're standing in an oxygenless environment
if(G.get_moles(/datum/gas/oxygen) < 1)
ExtinguishMob() //If there's no oxygen in the tile we're on, put out the fire
return TRUE
var/turf/location = get_turf(src)
location.hotspot_expose(700, 50, 1)
//this updates all special effects: knockdown, druggy, stuttering, etc..
/mob/living/proc/handle_status_effects()
if(confused)
confused = max(0, confused - 1)
/mob/living/proc/handle_traits()
//Eyes
if(eye_blind) //blindness, heals slowly over time
if(HAS_TRAIT_FROM(src, TRAIT_BLIND, EYES_COVERED)) //covering your eyes heals blurry eyes faster
adjust_blindness(-3)
else if(!stat && !(HAS_TRAIT(src, TRAIT_BLIND)))
adjust_blindness(-1)
else if(eye_blurry) //blurry eyes heal slowly
adjust_blurriness(-1)
/mob/living/proc/update_damage_hud()
return
/mob/living/proc/handle_gravity()
var/gravity = mob_has_gravity()
update_gravity(gravity)
if(gravity > STANDARD_GRAVITY)
gravity_animate()
handle_high_gravity(gravity)
/mob/living/proc/gravity_animate()
if(!get_filter("gravity"))
add_filter("gravity",1,list("type"="motion_blur", "x"=0, "y"=0))
INVOKE_ASYNC(src, .proc/gravity_pulse_animation)
/mob/living/proc/gravity_pulse_animation()
animate(get_filter("gravity"), y = 1, time = 10)
sleep(10)
animate(get_filter("gravity"), y = 0, time = 10)
/mob/living/proc/handle_high_gravity(gravity)
if(gravity >= GRAVITY_DAMAGE_TRESHOLD) //Aka gravity values of 3 or more
var/grav_stregth = gravity - GRAVITY_DAMAGE_TRESHOLD
adjustBruteLoss(min(grav_stregth,3))
#undef BODYTEMP_DIVISOR