Skip to content

Commit

Permalink
regexes damage and wound types (#6735)
Browse files Browse the repository at this point in the history
Different semantics demand different defines. It's hard to tell what's
being used where and for what reason right now.

Staging for combat PR.
  • Loading branch information
silicons authored Sep 9, 2024
1 parent 40ddbc3 commit e6f9726
Show file tree
Hide file tree
Showing 163 changed files with 607 additions and 641 deletions.
2 changes: 2 additions & 0 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
#include "code\__DEFINES\fishing\aquarium.dm"
#include "code\__DEFINES\fishing\fish.dm"
#include "code\__DEFINES\fishing\fishing.dm"
#include "code\__DEFINES\hardsuits\breaches.dm"
#include "code\__DEFINES\interface\skin.dm"
#include "code\__DEFINES\interface\verbs.dm"
#include "code\__DEFINES\inventory\accessories.dm"
Expand Down Expand Up @@ -273,6 +274,7 @@
#include "code\__DEFINES\mobs\silicon_privileges.dm"
#include "code\__DEFINES\mobs\sprite_accessories.dm"
#include "code\__DEFINES\mobs\stat.dm"
#include "code\__DEFINES\mobs\wounds.dm"
#include "code\__DEFINES\objects\objects.dm"
#include "code\__DEFINES\objects\type_generation.dm"
#include "code\__DEFINES\overmaps\misc.dm"
Expand Down
63 changes: 50 additions & 13 deletions code/__DEFINES/combat/damage.dm
Original file line number Diff line number Diff line change
@@ -1,18 +1,55 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2023 Citadel Station developers. *//
//* Copyright (c) 2024 Citadel Station Developers *//

//? damage types
//? damage types

// todo: refactor damage types
//* direct damage types; maps to most systems in the game *//

//? damage_mode bitfield
#define DAMAGE_TYPE_BRUTE "brute"
#define DAMAGE_TYPE_BURN "burn"

#define DAMAGE_MODE_SHARP (1<<0) //! sharp weapons like knives, spears, etc
#define DAMAGE_MODE_EDGE (1<<1) //! weapons with an edge, like knives, being used as such. without this, sharp = pierce
#define DAMAGE_MODE_ABLATING (1<<2) //! pulse lasers, etc, basically blows a crater
#define DAMAGE_MODE_PIERCE (1<<3) //! specifically highly-piercing weapons like bullets, even worse than sharp.
#define DAMAGE_MODE_SHRED (1<<4) //! messy, shredded wounds instead of a clean cut / pierce. strong.
#define DAMAGE_MODE_GRADUAL (1<<5) //! disallow bone breaks, ablation, etc; used for gradual sources like depressurization
#define DAMAGE_MODE_INTERNAL (1<<6) //! coming from internal; used to flag that something isn't coming through the skin. certain defenses don't work if this is set.
#define DAMAGE_MODE_REDIRECT (1<<7) //! if zone doesn't exist / etc, allow redirection
#define DAMAGE_MODE_NO_OVERFLOW (1<<8)//! temporary - re-evaluate when health is reworked. prevents damage from overflowing caps.
//* special damage types; only relevant for certain biologies *//
//* most of these will be reworked in brainmed update *//

/// body toxins / systems instability
#define DAMAGE_TYPE_TOX "tox"
/// oxygen deprivation
#define DAMAGE_TYPE_OXY "oxy"
/// dna damage
#define DAMAGE_TYPE_CLONE "clone"
/// pain
/// todo: stamina vs pain
#define DAMAGE_TYPE_HALLOSS "halloss"

//* special hybrid types; processed specially depending on type *//

/// passed to electrocute_act()
/// todo: remove
#define DAMAGE_TYPE_ELECTROCUTE "electrocute"
/// bioacid ; toxins for organics, acid for synthetics
/// todo: better hybrid type handling
#define DAMAGE_TYPE_BIOACID "bioacid"
/// searing; half brute, half bur
/// todo: better hybrid type handling
#define DAMAGE_TYPE_SEARING "searing"

//? damage_mode bitfield ?//

/// sharp weapons like knives, spears, etc
#define DAMAGE_MODE_SHARP (1<<0)
/// weapons with an edge, like knives, being used as such. without this, sharp = pierce
#define DAMAGE_MODE_EDGE (1<<1)
/// pulse lasers, etc, basically blows a crater
#define DAMAGE_MODE_ABLATING (1<<2)
/// specifically highly-piercing weapons like bullets, even worse than sharp.
#define DAMAGE_MODE_PIERCE (1<<3)
/// messy, shredded wounds instead of a clean cut / pierce. strong.
#define DAMAGE_MODE_SHRED (1<<4)
/// disallow bone breaks, ablation, etc; used for gradual sources like depressurization
#define DAMAGE_MODE_GRADUAL (1<<5)
/// coming from internal; used to flag that something isn't coming through the skin. certain defenses don't work if this is set.
#define DAMAGE_MODE_INTERNAL (1<<6)
/// if zone doesn't exist / etc, allow redirection
#define DAMAGE_MODE_REDIRECT (1<<7)
/// temporary - re-evaluate when health is reworked. prevents damage from overflowing caps.
#define DAMAGE_MODE_NO_OVERFLOW (1<<8)
16 changes: 0 additions & 16 deletions code/__DEFINES/damage_organs.dm
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
// Damage things. //TODO: Merge these down to reduce on defines.
// Way to waste perfectly good damage-type names (BRUTE) on this... If you were really worried about case sensitivity, you could have just used lowertext(damagetype) in the proc.
#define BRUTE "brute"
#define BURN "fire"
#define TOX "tox"
#define OXY "oxy"
#define CLONE "clone"
#define HALLOSS "halloss"
#define ELECTROCUTE "electrocute"
#define BIOACID "bioacid"
#define SEARING "searing"

// todo: these things should be damage modes / flags

#define CUT "cut"
#define BRUISE "bruise"
#define PIERCE "pierce"

#define STUN "stun"
#define WEAKEN "weaken"
#define PARALYZE "paralize"
Expand Down
7 changes: 7 additions & 0 deletions code/__DEFINES/hardsuits/breaches.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

//* /datum/hardsuit_breach breach_type's *//

#define HARDSUIT_BREACH_TYPE_BRUTE "brute"
#define HARDSUIT_BREACH_TYPE_BURN "burn"
10 changes: 10 additions & 0 deletions code/__DEFINES/mobs/wounds.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

//* Wound types *//

#define WOUND_TYPE_CUT "cut"
#define WOUND_TYPE_PIERCE "pierce"
#define WOUND_TYPE_BRUISE "bruise"
#define WOUND_TYPE_BURN "burn"
#define WOUND_TYPE_OTHER "other"
2 changes: 1 addition & 1 deletion code/datums/components/jousting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
var/mob/living/L = target
if(damage)
msg += "[user] [sharp? "impales" : "slams into"] [target] [sharp? "on" : "with"] their [parent]"
target.apply_damage(damage, BRUTE, user.zone_sel, 0)
target.apply_damage(damage, DAMAGE_TYPE_BRUTE, user.zone_sel, 0)
if(prob(knockdown_chance))
msg += " and knocks [target] [target_buckled? "off of [target.buckled]" : "down"]"
if(target_buckled)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/mobs/block_frame.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
/// ratio [0, INFINITY] of inbound damage to convert to another type
var/block_transmute = 0
/// damage type to transmute to
var/block_transmute_type = HALLOSS
var/block_transmute_type = DAMAGE_TYPE_HALLOSS
/// damage flag the transmuted damage counts as; null = inherit from attack
///
/// * only used if block_transmute_simulation is on
Expand Down
4 changes: 2 additions & 2 deletions code/datums/unarmed_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GLOBAL_LIST_EMPTY(unarmed_attack_cache)
/// damage tier
var/damage_tier = MELEE_TIER_UNARMED_DEFAULT
/// damage type
var/damage_type = BRUTE
var/damage_type = DAMAGE_TYPE_BRUTE
/// damage flag
var/damage_flag = ARMOR_MELEE
/// flat damage buff when attacking structures
Expand Down Expand Up @@ -327,4 +327,4 @@ GLOBAL_LIST_EMPTY(unarmed_attack_cache)
attack_verb_legacy = list("tapped", "lightly struck")
damage = 5
damage_mode = NONE
damage_type = AGONY
damage_type = DAMAGE_TYPE_HALLOSS
4 changes: 2 additions & 2 deletions code/game/atoms/atom-damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
if(inflict_damage_type_special(args))
return
switch(damage_type)
if(BRUTE)
if(BURN)
if(DAMAGE_TYPE_BRUTE)
if(DAMAGE_TYPE_BURN)
else
return // normal atoms can't take non brute-burn damage
// default atom damage handling
Expand Down
14 changes: 7 additions & 7 deletions code/game/atoms/atom-defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@
. = hitsound_override(I.damtype, I.damage_mode, ATTACK_TYPE_MELEE, I)
if(.)
return
. = (I.damtype == BURN? hit_sound_burn : hit_sound_brute) || I.attack_sound
. = (I.damtype == DAMAGE_TYPE_BURN? hit_sound_burn : hit_sound_brute) || I.attack_sound
if(.)
return
switch(I.damtype)
if(BRUTE)
if(DAMAGE_TYPE_BRUTE)
return "swing_hit"
if(BURN)
if(DAMAGE_TYPE_BURN)
return "'sound/items/welder.ogg"
else
return "swing_hit"
Expand All @@ -185,13 +185,13 @@
. = hitsound_override(I.damtype, I.damage_mode, ATTACK_TYPE_THROWN, I)
if(.)
return
. = (I.damtype == BURN? hit_sound_burn : hit_sound_brute) || I.attack_sound
. = (I.damtype == DAMAGE_TYPE_BURN? hit_sound_burn : hit_sound_brute) || I.attack_sound
if(.)
return
switch(I.damtype)
if(BRUTE)
if(DAMAGE_TYPE_BRUTE)
return "swing_hit"
if(BURN)
if(DAMAGE_TYPE_BURN)
return 'sound/items/welder.ogg'
else
return "swing_hit"
Expand All @@ -202,7 +202,7 @@
if(.)
return
// todo: way to override this from style side? we don't just want hitsound brute/burn.
. = (style.damage_type == BURN? hit_sound_burn : hit_sound_brute) || style.attack_sound
. = (style.damage_type == DAMAGE_TYPE_BURN? hit_sound_burn : hit_sound_brute) || style.attack_sound


//* Armor *//
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/cult/construct_spells.dm
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@
icon_state = "invert"
fire_sound = 'sound/weapons/spiderlunge.ogg'
damage_force = 15
damage_type = BURN
damage_type = DAMAGE_TYPE_BURN
damage_flag = ARMOR_LASER
armor_penetration = 60
light_range = 2
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/cult/cult_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
var/obj/item/organ/external/affecting = H.get_organ(zone)
to_chat(user, "<span class='danger'>An inexplicable force rips through your [affecting.name], tearing the sword from your grasp!</span>")
//random amount of damage between half of the blade's force and the full force of the blade.
H.apply_damage(rand(damage_force/2, damage_force), BRUTE, zone, 0, sharp=1, edge=1)
H.apply_damage(rand(damage_force/2, damage_force), DAMAGE_TYPE_BRUTE, zone, 0, sharp=1, edge=1)
H.afflict_paralyze(20 * 5)
else if(!istype(user, /mob/living/simple_mob/construct))
to_chat(user, "<span class='danger'>An inexplicable force rips through you, tearing the sword from your grasp!</span>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
name = "lightning"
icon_state = "lightning"
nodamage = 1
damage_type = HALLOSS
damage_type = DAMAGE_TYPE_HALLOSS

muzzle_type = /obj/effect/projectile/muzzle/lightning
tracer_type = /obj/effect/projectile/tracer/lightning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
name = "force missile"
icon_state = "force_missile"
damage_force = 25
damage_type = BRUTE
damage_type = DAMAGE_TYPE_BRUTE
damage_flag = ARMOR_MELEE
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
name = "lightning"
icon_state = "lightning"
nodamage = 1
damage_type = HALLOSS
damage_type = DAMAGE_TYPE_HALLOSS

muzzle_type = /obj/effect/projectile/muzzle/lightning
tracer_type = /obj/effect/projectile/tracer/lightning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/obj/projectile/overload
name = "overloaded bolt"
icon_state = "bluespace"
damage_type = BURN
damage_type = DAMAGE_TYPE_BURN
armor_penetration = 100

/obj/item/spell/projectile/overload/make_projectile(obj/projectile/projectile_type, mob/living/user)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/iv_drip.dm
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
damage_mode = DAMAGE_MODE_SHARP,
weapon_descriptor = "a needle",
)
chosen_limb.create_wound(CUT, 5)
chosen_limb.create_wound(WOUND_TYPE_CUT, 5)
detach_iv()
return PROCESS_KILL

Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/effects/spiders.dm
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@
src.loc = O.owner ? O.owner.loc : O.loc
src.visible_message("<span class='warning'>\A [src] makes its way out of [O.owner ? "[O.owner]'s [O.name]" : "\the [O]"]!</span>")
if(O.owner)
O.owner.apply_damage(1, BRUTE, O.organ_tag)
O.owner.apply_damage(1, DAMAGE_TYPE_BRUTE, O.organ_tag)
else if(prob(1))
O.owner.apply_damage(1, TOX, O.organ_tag)
O.owner.apply_damage(1, DAMAGE_TYPE_TOX, O.organ_tag)
if(world.time > last_itch + 30 SECONDS)
last_itch = world.time
to_chat(O.owner, "<span class='notice'>Your [O.name] itches...</span>")
Expand Down
16 changes: 8 additions & 8 deletions code/game/objects/effects/traps.dm
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Add those other swinging traps you mentioned above!
else if(istype(AM, /mob/living))
var/mob/living/M = AM
var/damage = rand(min_damage, max_damage)
M.apply_damage(damage, BRUTE)
M.apply_damage(damage, DAMAGE_TYPE_BRUTE)
M.visible_message("<span class='danger'>[M] falls onto a punji stake!</span>", \
"<span class='userdanger'>You slide onto a punji stake!</span>")

Expand Down Expand Up @@ -282,7 +282,7 @@ Add those other swinging traps you mentioned above!
else if(istype(AM, /mob/living))
var/mob/living/M = AM
var/damage = rand(min_damage, max_damage)
M.apply_damage(damage, TOX)
M.apply_damage(damage, DAMAGE_TYPE_TOX)
M.set_stunned(20 * 15)
M.visible_message("<span class='danger'>[M] falls into a writhing mass of tentacles!</span>", \
"<span class='userdanger'>You are entwined by a writhing mass of tentacles!</span>")
Expand Down Expand Up @@ -509,7 +509,7 @@ Add those other swinging traps you mentioned above!
else if(istype(AM, /mob/living))
var/mob/living/M = AM
var/damage = rand(min_damage, max_damage)
M.apply_damage(damage, BRUTE)
M.apply_damage(damage, DAMAGE_TYPE_BRUTE)
M.visible_message("<span class='danger'>[M] is stabbed by the rising spears!</span>", \
"<span class='userdanger'>You are impaled by a thrusting spear!</span>")

Expand Down Expand Up @@ -546,7 +546,7 @@ Add those other swinging traps you mentioned above!
var/list/target_limbs = list(BP_L_LEG, BP_R_LEG, BP_L_FOOT, BP_R_FOOT)
var/selected = pick(target_limbs)
var/obj/item/organ/external/target = M.get_organ(selected)
M.apply_damage(damage, BRUTE)
M.apply_damage(damage, DAMAGE_TYPE_BRUTE)
target.droplimb()
M.visible_message("<span class='danger'>[M] is slashed by the spinning blades!</span>", \
"<span class='userdanger'>You are slashed by the spinning blades!</span>")
Expand All @@ -562,7 +562,7 @@ if (istype(AM, /mob/living))
/obj/effect/trap/pop_up/pillar/process(atom/AM as mob|obj)
var/mob/living/M = AM
var/damage = rand(min_damage, max_damage)
M.apply_damage(damage, BRUTE)
M.apply_damage(damage, DAMAGE_TYPE_BRUTE)
/obj/effect/trap/pop_up/pillar/Destroy()
STOP_PROCESSING(SSprocess_5fps, src)
Expand Down Expand Up @@ -602,7 +602,7 @@ if (istype(AM, /mob/living))
var/list/target_limbs = list(BP_L_LEG, BP_R_LEG, BP_L_FOOT, BP_R_FOOT)
var/selected = pick(target_limbs)
var/obj/item/organ/external/target = M.get_organ(selected)
M.apply_damage(damage, BRUTE)
M.apply_damage(damage, DAMAGE_TYPE_BRUTE)
target.droplimb()
M.visible_message("<span class='danger'>[M] is ripped by the whirling sawblades!</span>", \
"<span class='userdanger'>You are ripped open by the whirling sawblades!</span>")
Expand Down Expand Up @@ -637,7 +637,7 @@ if (istype(AM, /mob/living))
else if(istype(AM, /mob/living))
var/mob/living/M = AM
var/damage = rand(min_damage, max_damage)
M.apply_damage(damage, BURN)
M.apply_damage(damage, DAMAGE_TYPE_BURN)
M.adjust_fire_stacks(2)
M.IgniteMob()
M.visible_message("<span class='danger'>[M] is engulfed in flames!</span>", \
Expand Down Expand Up @@ -789,7 +789,7 @@ if (istype(AM, /mob/living))
var/selected = pick(bone_sites)
var/obj/item/organ/external/target = M.get_organ(selected)
var/head_slot = SLOT_HEAD
M.apply_damage(damage, BRUTE)
M.apply_damage(damage, DAMAGE_TYPE_BRUTE)
target.fracture()
M.throw_at_old(T2, 1, 1, src)
if(!head_slot || !(istype(head_slot,/obj/item/clothing/head/helmet) || istype(head_slot,/obj/item/clothing/head/hardhat)))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/PDA/PDA.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ GLOBAL_LIST_EMPTY(PDAs)
if(i>=10 && i<= 20) //The PDA burns a hole in the holder.
j=1
if(M && isliving(M))
M.apply_damage( rand(30,60) , BURN)
M.apply_damage( rand(30,60) , DAMAGE_TYPE_BURN)
message += "You feel a searing heat! Your [P] is burning!"
if(i>=20 && i<=25) //EMP
empulse(P.loc, 1, 2, 4, 6, 1)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/defib.dm
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
playsound(get_turf(src), 'sound/machines/defib_failed.ogg', 50, 0)
return

H.apply_damage(burn_damage_amt, BURN, BP_TORSO)
H.apply_damage(burn_damage_amt, DAMAGE_TYPE_BURN, BP_TORSO)

//set oxyloss so that the patient is just barely in crit, if possible
var/barely_in_crit = config_legacy.health_threshold_crit - 1
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/devices/flash.dm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
H.eye_blurry = max(H.eye_blurry, flash_strength + 5)
H.flash_eyes()
H.adjustHalLoss(halloss_per_flash * (flash_strength / 5)) // Should take four flashes to stun.
H.apply_damage(10 * (H.species.flash_burn / 5), BURN, BP_HEAD, 0, 0, "Photon burns")
H.apply_damage(10 * (H.species.flash_burn / 5), DAMAGE_TYPE_BURN, BP_HEAD, 0, 0, "Photon burns")

else
flashfail = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
active_damage_force = 60
active_throw_force = 35
active_weight_class = WEIGHT_CLASS_HUGE
active_damage_type = SEARING
active_damage_type = DAMAGE_TYPE_SEARING

/obj/item/melee/transforming/energy/axe/on_activate(datum/event_args/actor/actor, silent)
. = ..()
Expand Down
Loading

0 comments on commit e6f9726

Please sign in to comment.