/
living_health.dm
136 lines (104 loc) · 3.25 KB
/
living_health.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
/mob/living/health_resistances = null // Not currently supported in health passthrough
/mob/living/use_weapon_hitsound = TRUE
/mob/living/get_current_health()
if (maxHealth)
return health
return ..()
/mob/living/get_max_health()
if (maxHealth)
return getMaxHealth()
return ..()
/mob/living/health_dead()
if (stat == DEAD)
return TRUE
return ..()
/mob/living/mod_health(health_mod, damage_type, skip_death_state_change)
if (maxHealth)
crash_with("Living mob using legacy health attempted to call mod_health. This is not currently supported and should not be possible.")
return FALSE
return ..()
/mob/living/set_health(new_health, skip_death_state_change)
if (maxHealth)
crash_with("Living mob using legacy health attempted to call set_health. This is not currently supported and should not be possible.")
return FALSE
return ..()
/mob/living/proc/general_health_adjustment(damage, damage_type, damage_flags = EMPTY_BITFIELD, def_zone, obj/item/used_weapon = null)
var/prior_death_state = health_dead()
// Convert damage types to types recognized by legacy mob health
switch (damage_type)
if (DAMAGE_EMP, DAMAGE_FIRE)
return FALSE // These damages are handled separately by existing legacy code
if (DAMAGE_SHOCK)
damage_type = DAMAGE_BURN
if (DAMAGE_BIO)
damage_type = DAMAGE_TOXIN
if (DAMAGE_EXPLODE, DAMAGE_PSIONIC)
damage_type = DAMAGE_BRUTE
// Apply damage
switch (damage_type)
if (DAMAGE_RADIATION)
apply_radiation(damage)
if (DAMAGE_STUN, DAMAGE_PAIN)
adjustHalLoss(damage)
if (DAMAGE_BRAIN)
adjustBrainLoss(damage)
else
if (used_weapon)
apply_damage(damage, damage_type, def_zone, damage_flags, used_weapon, used_weapon.armor_penetration, TRUE)
else
apply_damage(damage, damage_type, def_zone, damage_flags, silent = TRUE)
return prior_death_state != health_dead()
/mob/living/restore_health(damage, damage_type, skip_death_state_change, skip_can_restore_check)
if (maxHealth)
if (!can_restore_health(damage, damage_type))
return FALSE
return general_health_adjustment(-damage, damage_type)
return ..()
/mob/living/damage_health(damage, damage_type, damage_flags, severity, skip_can_damage_check)
if (maxHealth)
if (!can_damage_health(damage, damage_type, damage_flags))
return FALSE
return general_health_adjustment(damage, damage_type, damage_flags)
return ..()
/mob/living/kill_health()
if (maxHealth)
if (health_dead())
return FALSE
death()
return TRUE
return ..()
/mob/living/revive_health()
if (maxHealth)
var/prior_death_state = health_dead()
rejuvenate()
return prior_death_state != health_dead()
return ..()
/mob/living/set_max_health(new_max_health, set_current_health, use_standardized_health = FALSE)
if (use_standardized_health)
if (maxHealth)
maxHealth = 0
health_current = health
health = 0
..()
return
setMaxHealth(new_max_health)
if (set_current_health)
rejuvenate()
else
updatehealth()
/mob/living/set_damage_resistance(damage_type, resistance_value)
if (maxHealth)
return
..()
/mob/living/remove_damage_resistance(damage_type)
if (maxHealth)
return
..()
/mob/living/get_damage_resistance(damage_type)
if (maxHealth)
return 1
return ..()
/mob/living/is_damage_immune(damage_type)
if (maxHealth)
return FALSE
return ..()