-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converting damage types to a decl system.
Initial coarse conversion of damage types to decls. Removing adjust/set/get loss procs. Coarse take_damage/apply_damage/etc proc unification. Converting older apply_damage() code to new damage handlers. Replacing species mod getters with damage modifier list/getter. Disambiguating various damage procs. Blob damage now uses a shared take_damage() proc on /atom. Structures now use shared take_damage() proc. Walls now use shared take_damage proc. Shields now use shared take_damage proc. Organs now use shared damage procs. Mech components now use shared damage proc. Items and machines use shared damage proc. Post-rebase compile updates. Replacing decl paths for damage handlers with old single-word defines.
- Loading branch information
1 parent
f096d40
commit 71c9b15
Showing
364 changed files
with
2,199 additions
and
2,344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
///The decimal precision for health values. Health will be rounded against this value. | ||
#define HEALTH_ROUNDING 0.01 | ||
|
||
#define BRUTE /decl/damage_handler/brute | ||
#define BURN /decl/damage_handler/burn | ||
#define TOX /decl/damage_handler/organ | ||
#define CLONE /decl/damage_handler/genetic | ||
#define ELECTROCUTE /decl/damage_handler/electrocute | ||
#define PAIN /decl/damage_handler/pain | ||
#define OXY /decl/damage_handler/suffocation | ||
#define IRRADIATE /decl/damage_handler/radiation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/decl/damage_handler | ||
abstract_type = /decl/damage_handler | ||
var/name | ||
var/color = COLOR_GUNMETAL | ||
var/applies_to_machinery = FALSE | ||
var/machinery_hit_sound = 'sound/weapons/smash.ogg' | ||
var/blocked_by_ablative = FALSE | ||
var/can_ignite_reagents = FALSE | ||
var/damage_verb = "shatters" | ||
var/allow_modification_in_vv = TRUE | ||
var/usable_with_backstab = FALSE | ||
var/causes_limb_damage = FALSE | ||
var/projectile_damage_divisor = 1 | ||
var/projectile_damages_assembly_casing = TRUE | ||
var/barrier_damage_multiplier = 0 | ||
var/item_damage_flags = 0 | ||
var/category_type | ||
var/expected_type = /mob/living | ||
|
||
/decl/damage_handler/validate() | ||
. = ..() | ||
if(!name) | ||
. += "no name set" | ||
if(!category_type) | ||
. += "no category type set" | ||
|
||
/decl/damage_handler/proc/set_mob_damage(var/mob/living/target, var/damage, var/skip_update_health = FALSE) | ||
if(!(category_type in target._damage_values)) | ||
return FALSE | ||
var/oldval = target._damage_values[category_type] | ||
var/newval = clamp(oldval + damage, 0, target.get_max_health()) | ||
if(oldval == newval) | ||
return FALSE | ||
target._damage_values[category_type] = newval | ||
if(!skip_update_health) | ||
target.update_health() | ||
return TRUE | ||
|
||
/decl/damage_handler/proc/heal_mob_damage(var/mob/living/target, var/damage, var/skip_update_health = FALSE) | ||
return set_mob_damage(target, target.get_damage(category_type)-damage, skip_update_health = skip_update_health) | ||
|
||
/decl/damage_handler/proc/apply_damage_to_mob(var/mob/living/target, var/damage, var/def_zone, var/damage_flags = 0, var/used_weapon, var/silent = FALSE, var/skip_update_health = FALSE) | ||
return set_mob_damage(target, target.get_damage(category_type)+damage, skip_update_health = skip_update_health) | ||
|
||
// There is a disconnect between legacy damage and armor code. This here helps bridge the gap. | ||
/decl/damage_handler/proc/get_armor_key(var/damage_flags = 0) | ||
return null | ||
|
||
/decl/damage_handler/proc/get_damage_for_mob(var/mob/living/target) | ||
return LAZYACCESS(target._damage_values, category_type) || 0 | ||
|
||
/decl/damage_handler/proc/damage_limb(var/obj/item/organ/external/organ, var/damage, var/damage_flags = 0, var/used_weapon, var/skip_update_health = FALSE) | ||
return organ?.take_damage(damage, category_type, damage_flags = damage_flags, used_weapon = used_weapon, skip_update_health = skip_update_health) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/decl/damage_handler/brute | ||
name = "brute" | ||
blocked_by_ablative = TRUE | ||
can_ignite_reagents = TRUE // Why? | ||
usable_with_backstab = TRUE | ||
causes_limb_damage = TRUE | ||
projectile_damage_divisor = 2 | ||
barrier_damage_multiplier = 0.5 | ||
category_type = /decl/damage_handler/brute | ||
|
||
/decl/damage_handler/brute/get_armor_key(var/damage_flags) | ||
if(damage_flags & DAM_BULLET) | ||
return ARMOR_BULLET | ||
if(damage_flags & DAM_EXPLODE) | ||
return ARMOR_BOMB | ||
return ARMOR_MELEE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/decl/damage_handler/burn | ||
name = "burn" | ||
applies_to_machinery = TRUE | ||
blocked_by_ablative = TRUE | ||
can_ignite_reagents = TRUE | ||
damage_verb = "sizzles" | ||
usable_with_backstab = TRUE | ||
causes_limb_damage = TRUE | ||
projectile_damage_divisor = 1.5 | ||
barrier_damage_multiplier = 0.75 | ||
item_damage_flags = DAM_LASER | ||
category_type = /decl/damage_handler/burn | ||
|
||
/decl/damage_handler/burn/get_armor_key(var/damage_flags) | ||
if(damage_flags & DAM_LASER) | ||
return ARMOR_LASER | ||
if(damage_flags & DAM_EXPLODE) | ||
return ARMOR_BOMB | ||
return ARMOR_ENERGY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/decl/damage_handler/electrocute | ||
name = "electrocution" | ||
can_ignite_reagents = TRUE | ||
damage_verb = "sparks" | ||
category_type = /decl/damage_handler/electrocute | ||
|
||
/decl/damage_handler/electrocute/get_armor_key(var/damage_flags) | ||
return ARMOR_ENERGY | ||
|
||
/decl/damage_handler/electrocute/apply_damage_to_mob(var/mob/living/target, var/damage, var/def_zone, var/damage_flags = 0, var/used_weapon, var/silent = FALSE, var/skip_update_health = FALSE) | ||
target.electrocute_act(damage) // todo | ||
return TRUE | ||
|
||
/decl/damage_handler/electrocute/set_mob_damage(var/mob/living/target, var/damage, var/skip_update_health = FALSE) | ||
return FALSE | ||
|
||
/decl/damage_handler/electrocute/heal_mob_damage(var/mob/living/target, var/damage, var/skip_update_health = FALSE) | ||
return FALSE | ||
|
||
/decl/damage_handler/electrocute/get_damage_for_mob(var/mob/living/target) | ||
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/decl/damage_handler/genetic | ||
name = "genetic" | ||
usable_with_backstab = TRUE | ||
causes_limb_damage = TRUE | ||
category_type = /decl/damage_handler/genetic | ||
|
||
/decl/damage_handler/genetic/damage_limb(var/obj/item/organ/external/organ, var/damage, var/damage_flags = 0, used_weapon) | ||
organ.add_genetic_damage(damage) | ||
return TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/decl/damage_handler/organ | ||
name = "organ" | ||
usable_with_backstab = TRUE | ||
category_type = /decl/damage_handler/organ | ||
|
||
|
||
/decl/damage_handler/organ/get_armor_key(var/damage_flags) | ||
if(damage_flags & DAM_BIO) | ||
return ARMOR_BIO | ||
// Otherwise just not blocked by default. | ||
return null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/decl/damage_handler/pain | ||
name = "pain" | ||
usable_with_backstab = TRUE | ||
causes_limb_damage = TRUE | ||
projectile_damage_divisor = 3 | ||
projectile_damages_assembly_casing = FALSE | ||
category_type = /decl/damage_handler/pain | ||
|
||
|
||
/decl/damage_handler/pain/damage_limb(var/obj/item/organ/external/organ, var/damage, var/damage_flags = 0, used_weapon) | ||
organ.add_pain(damage) | ||
return TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/decl/damage_handler/radiation | ||
name = "radiation" | ||
category_type = /decl/damage_handler/radiation | ||
|
||
/decl/damage_handler/radiation/apply_damage_to_mob(var/mob/living/target, var/damage, var/def_zone, var/damage_flags = 0, var/used_weapon, var/silent = FALSE) | ||
. = ..() | ||
if(. && iscarbon(target) && !target.isSynthetic()) | ||
var/mob/living/carbon/target_carbon = target | ||
if(!target_carbon.ignore_rads) | ||
target.take_damage(0.25 * damage * target.get_damage_modifier(category_type), /decl/damage_handler/burn) | ||
|
||
/decl/damage_handler/radiation/get_armor_key(var/damage_flags) | ||
return ARMOR_RAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/decl/damage_handler/suffocation | ||
name = "suffocation" | ||
usable_with_backstab = TRUE | ||
category_type = /decl/damage_handler/suffocation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.