Skip to content

Commit

Permalink
Damtype regex (#6742)
Browse files Browse the repository at this point in the history
Atomized codebase reorganization
  • Loading branch information
silicons authored Sep 11, 2024
1 parent 87083b1 commit e3b936f
Show file tree
Hide file tree
Showing 35 changed files with 99 additions and 87 deletions.
22 changes: 11 additions & 11 deletions code/game/atoms/atom-defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@
. = I.attacksound_override(src, ATTACK_TYPE_MELEE)
if(!isnull(.))
return
. = hitsound_override(I.damtype, I.damage_mode, ATTACK_TYPE_MELEE, I)
. = hitsound_override(I.damage_type, I.damage_mode, ATTACK_TYPE_MELEE, I)
if(.)
return
. = (I.damtype == DAMAGE_TYPE_BURN? hit_sound_burn : hit_sound_brute) || I.attack_sound
. = (I.damage_type == DAMAGE_TYPE_BURN? hit_sound_burn : hit_sound_brute) || I.attack_sound
if(.)
return
switch(I.damtype)
switch(I.damage_type)
if(DAMAGE_TYPE_BRUTE)
return "swing_hit"
if(DAMAGE_TYPE_BURN)
Expand All @@ -173,7 +173,7 @@

/atom/proc/hitsound_projectile(obj/projectile/P)
//? todo: projectile gets final say
. = hitsound_override(P.damtype, P.damage_mode, ATTACK_TYPE_PROJECTILE, P)
. = hitsound_override(P.damage_type, P.damage_mode, ATTACK_TYPE_PROJECTILE, P)
if(.)
return
return islist(P.impact_sounds)? pick(P.impact_sounds) : P.impact_sounds
Expand All @@ -182,13 +182,13 @@
. = I.attacksound_override(src, ATTACK_TYPE_THROWN)
if(!isnull(.))
return
. = hitsound_override(I.damtype, I.damage_mode, ATTACK_TYPE_THROWN, I)
. = hitsound_override(I.damage_type, I.damage_mode, ATTACK_TYPE_THROWN, I)
if(.)
return
. = (I.damtype == DAMAGE_TYPE_BURN? hit_sound_burn : hit_sound_brute) || I.attack_sound
. = (I.damage_type == DAMAGE_TYPE_BURN? hit_sound_burn : hit_sound_brute) || I.attack_sound
if(.)
return
switch(I.damtype)
switch(I.damage_type)
if(DAMAGE_TYPE_BRUTE)
return "swing_hit"
if(DAMAGE_TYPE_BURN)
Expand Down Expand Up @@ -248,7 +248,7 @@
*
* @params
* * damage - raw damage
* * damtype - damage type
* * damage_type - damage type
* * tier - penetration / attack tier
* * flag - armor flag as seen in [code/__DEFINES/combat/armor.dm]
* * mode - damage_mode
Expand Down Expand Up @@ -278,7 +278,7 @@
*
* @params
* * damage - raw damage
* * damtype - damage type
* * damage_type - damage type
* * tier - penetration / attack tier
* * flag - armor flag as seen in [code/__DEFINES/combat/armor.dm]
* * mode - damage_mode
Expand Down Expand Up @@ -315,7 +315,7 @@
*
* @params
* * damage - raw damage
* * damtype - damage type
* * damage_type - damage type
* * damage_tier - penetration / attack tier
* * damage_flag - armor flag as seen in [code/__DEFINES/combat/armor.dm]
* * damage_mode - damage_mode
Expand Down Expand Up @@ -350,7 +350,7 @@
*
* @params
* * damage - raw damage
* * damtype - damage type
* * damage_type - damage type
* * damage_tier - penetration / attack tier
* * damage_flag - armor flag as seen in [code/__DEFINES/combat/armor.dm]
* * damage_mode - damage_mode
Expand Down
8 changes: 4 additions & 4 deletions code/game/click/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@
if(!hit_zone)
// missed
// log
add_attack_logs(user, L, "missed with [src] DT [damtype] F [damage_force] I [user.a_intent]")
add_attack_logs(user, L, "missed with [src] DT [damage_type] F [damage_force] I [user.a_intent]")
return melee_mob_miss(L, user, clickchain_flags, params, mult, target_zone, intent)
// log
add_attack_logs(user, L, "attacked with [src] DT [damtype] F [damage_force] I [user.a_intent]")
add_attack_logs(user, L, "attacked with [src] DT [damage_type] F [damage_force] I [user.a_intent]")
// hit
return melee_mob_hit(L, user, clickchain_flags, params, mult, target_zone, intent)

Expand Down Expand Up @@ -298,7 +298,7 @@
if(isliving(target))
var/mob/living/casted = target
newhp = casted.health
log_attack(key_name(src), key_name(target), "attacked with [src] [src.damtype]-[src.damage_force]=[src.damage_tier] newhp ~[newhp || "unknown"]")
log_attack(key_name(src), key_name(target), "attacked with [src] [src.damage_type]-[src.damage_force]=[src.damage_tier] newhp ~[newhp || "unknown"]")

return NONE

Expand Down Expand Up @@ -430,7 +430,7 @@
// todo: better logging
// todo: entity ids?
var/newhp = target.integrity
log_attack(key_name(src), "[target] ([ref(target)])", "attacked with [src] [src.damtype]-[src.damage_force]=[src.damage_tier] newhp ~[newhp || "unknown"]")
log_attack(key_name(src), "[target] ([ref(target)])", "attacked with [src] [src.damage_type]-[src.damage_force]=[src.damage_tier] newhp ~[newhp || "unknown"]")

return NONE

Expand Down
5 changes: 4 additions & 1 deletion code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@
var/damage_tier = MELEE_TIER_MEDIUM
/// damage_mode bitfield - see [code/__DEFINES/combat/damage.dm]
var/damage_mode = NONE
// todo: port over damtype
/// DAMAGE_TYPE_* enum
///
/// * This is the primary damage type this object does on usage as a melee / thrown weapon.
var/damage_type = DAMAGE_TYPE_BRUTE

//* Storage *//
/// storage cost for volumetric storage
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/devices/flashlight.dm
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@
/obj/item/flashlight/flare/proc/turn_off()
on = FALSE
src.damage_force = initial(src.damage_force)
src.damtype = initial(src.damtype)
src.damage_type = initial(src.damage_type)
update_appearance()

/obj/item/flashlight/flare/attack_self(mob/user)
Expand All @@ -368,14 +368,14 @@
if(.)
user.visible_message(SPAN_NOTICE("[user] activates the flare."), SPAN_NOTICE("You pull the cord on the flare, activating it!"))
src.damage_force = on_damage
src.damtype = "fire"
src.damage_type = DAMAGE_TYPE_BURN
START_PROCESSING(SSobj, src)

/obj/item/flashlight/flare/proc/ignite() //Used for flare launchers.
on = !on
update_appearance()
damage_force = on_damage
damtype = "fire"
damage_type = DAMAGE_TYPE_BURN
START_PROCESSING(SSobj, src)
return TRUE

Expand Down
8 changes: 4 additions & 4 deletions code/game/objects/items/melee/types/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
to_chat(user, "<span class='notice'>You ignite the [src]'s sacred flame.</span>")
playsound(loc, 'sound/weapons/gun_flamethrower3.ogg', 50, 1)
src.damage_force = 20
src.damtype = "fire"
src.damage_type = DAMAGE_TYPE_BURN
src.set_weight_class(WEIGHT_CLASS_BULKY)
src.attack_sound = 'sound/weapons/gun_flamethrower2.ogg'
active = 1
Expand All @@ -291,7 +291,7 @@
to_chat(user, "<span class='notice'>You douse \the [src]'s sacred flame.</span>")
playsound(loc, 'sound/weapons/gun_flamethrower1.ogg', 50, 1)
src.damage_force = 20
src.damtype = "brute"
src.damage_type = DAMAGE_TYPE_BRUTE
src.set_weight_class(initial(src.w_class))
src.attack_sound = initial(src.attack_sound)
src.active = 0
Expand Down Expand Up @@ -526,7 +526,7 @@
T.visible_message("<span class='danger'>\The [src] turns on.</span>")
playsound(loc, acti_sound, 50, 1)
src.damage_force = 15
src.damtype = "fire"
src.damage_type = DAMAGE_TYPE_BURN
src.set_weight_class(WEIGHT_CLASS_BULKY)
src.attack_sound = 'sound/items/welder.ogg'
src.sharp = 1
Expand All @@ -545,7 +545,7 @@
T.visible_message("<span class='warning'>\The [src] turns off.</span>")
playsound(loc, deac_sound, 50, 1)
src.damage_force = 3
src.damtype = "brute"
src.damage_type = DAMAGE_TYPE_BRUTE
src.set_weight_class(initial(src.w_class))
src.active = 0
src.sharp = 0
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/melee/types/transforming.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
damage_force = VALUE_OR_DEFAULT(active_damage_force, initial(damage_force))
damage_tier = VALUE_OR_DEFAULT(active_damage_tier, initial(damage_tier))
damage_mode = VALUE_OR_DEFAULT(active_damage_mode, initial(damage_mode))
damtype = VALUE_OR_DEFAULT(active_damage_type, initial(damtype))
damage_type = VALUE_OR_DEFAULT(active_damage_type, initial(damage_type))

throw_force = VALUE_OR_DEFAULT(active_throw_force, initial(throw_force))
throw_resist = VALUE_OR_DEFAULT(active_throw_resist, initial(throw_resist))
Expand All @@ -159,7 +159,7 @@
damage_force = VALUE_OR_DEFAULT(inactive_damage_force, initial(damage_force))
damage_tier = VALUE_OR_DEFAULT(inactive_damage_tier, initial(damage_tier))
damage_mode = VALUE_OR_DEFAULT(inactive_damage_mode, initial(damage_mode))
damtype = VALUE_OR_DEFAULT(inactive_damage_type, initial(damtype))
damage_type = VALUE_OR_DEFAULT(inactive_damage_type, initial(damage_type))

throw_force = VALUE_OR_DEFAULT(inactive_throw_force, initial(throw_force))
throw_resist = VALUE_OR_DEFAULT(inactive_throw_resist, initial(throw_resist))
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/storage/boxes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
/obj/item/storage/box/matches/attackby(obj/item/flame/match/W as obj, mob/user as mob)
if(istype(W) && !W.lit && !W.burnt)
W.lit = 1
W.damtype = "burn"
W.damage_type = "burn"
W.icon_state = "match_lit"
START_PROCESSING(SSobj, W)
W.update_icon()
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/tools/weldingtool.dm
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
T.visible_message("<span class='danger'>\The [src] turns on.</span>")
playsound(loc, acti_sound, 50, 1)
src.damage_force = 15
src.damtype = "fire"
src.damage_type = DAMAGE_TYPE_BURN
src.set_weight_class(WEIGHT_CLASS_BULKY)
src.attack_sound = 'sound/items/welder.ogg'
welding = 1
Expand All @@ -275,7 +275,7 @@
T.visible_message("<span class='warning'>\The [src] turns off.</span>")
playsound(loc, deac_sound, 50, 1)
src.damage_force = 3
src.damtype = "brute"
src.damage_type = DAMAGE_TYPE_BRUTE
src.set_weight_class(initial(src.w_class))
src.welding = 0
src.attack_sound = initial(src.attack_sound)
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/weapons/cigs_lighters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
/obj/item/flame/match/proc/burn_out()
lit = 0
burnt = 1
damtype = "brute"
damage_type = DAMAGE_TYPE_BRUTE
icon_state = "match_burnt"
item_state = "cigoff"
name = "burnt match"
Expand Down Expand Up @@ -160,7 +160,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
/obj/item/clothing/mask/smokable/proc/light(var/flavor_text = "[usr] lights the [name].")
if(!src.lit)
src.lit = 1
damtype = "fire"
damage_type = DAMAGE_TYPE_BURN
if(reagents.get_reagent_amount("phoron")) // the phoron explodes when exposed to fire
var/datum/effect_system/reagents_explosion/e = new()
e.set_up(round(reagents.get_reagent_amount("phoron") / 2.5, 1), get_turf(src), 0, 0)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/nullrod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
item_state = "disintegrate"
name = "god hand"
desc = "This hand of yours glows with an awesome power!"
damtype = DAMAGE_TYPE_BURN
damage_type = DAMAGE_TYPE_BURN
attack_verb = list("punched", "cross countered", "pummeled")

/obj/item/nullrod/godhand/Initialize(mapload)
Expand Down
8 changes: 4 additions & 4 deletions code/game/objects/items/weapons/surgery_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,20 @@
name = "laser scalpel"
desc = "A scalpel augmented with a directed laser, for more precise cutting without blood entering the field. This one looks basic and could be improved."
icon_state = "scalpel_laser1_on"
damtype = "fire"
damage_type = DAMAGE_TYPE_BURN

/obj/item/surgical/scalpel/laser2
name = "laser scalpel"
desc = "A scalpel augmented with a directed laser, for more precise cutting without blood entering the field. This one looks somewhat advanced."
icon_state = "scalpel_laser2_on"
damtype = "fire"
damage_type = DAMAGE_TYPE_BURN
damage_force = 12.0

/obj/item/surgical/scalpel/laser3
name = "laser scalpel"
desc = "A scalpel augmented with a directed laser, for more precise cutting without blood entering the field. This one looks to be the pinnacle of precision energy cutlery!"
icon_state = "scalpel_laser3_on"
damtype = "fire"
damage_type = DAMAGE_TYPE_BURN
damage_force = 15.0

/obj/item/surgical/scalpel/manager
Expand Down Expand Up @@ -162,7 +162,7 @@
icon_state = "adv_saw"
item_state = "saw3"
attack_sound = 'sound/weapons/emitter2.ogg'
damtype = DAMAGE_TYPE_SEARING
damage_type = DAMAGE_TYPE_SEARING
w_class = WEIGHT_CLASS_BULKY
origin_tech = list(TECH_BIO = 4, TECH_MATERIAL = 6, TECH_MAGNET = 6)
materials_base = list(MAT_STEEL = 12500)
Expand Down
10 changes: 5 additions & 5 deletions code/game/objects/items/weapons/swords_axes_etc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@
var/mob/living/L = user
L.take_random_targeted_damage(brute = 2*damage_force)
return
var/old_damtype = damtype
var/old_damage_type = damage_type
var/old_attack_verb = attack_verb
var/old_force = damage_force
if(user.a_intent != INTENT_HARM)
damtype = DAMAGE_TYPE_HALLOSS
damage_type = DAMAGE_TYPE_HALLOSS
attack_verb = list("suppressed")
damage_force = on_pain_force
. = ..()
damtype = old_damtype
damage_type = old_damage_type
attack_verb = old_attack_verb
damage_force = old_force
else
Expand Down Expand Up @@ -221,7 +221,7 @@
desc = "A training sword made of wood and shaped like a katana."
icon_state = "bokken"
slot_flags = SLOT_BELT | SLOT_BACK
damtype = DAMAGE_TYPE_HALLOSS
damage_type = DAMAGE_TYPE_HALLOSS
damage_force = 5
throw_force = 5
attack_verb = list("whacked", "smacked", "struck")
Expand Down Expand Up @@ -351,7 +351,7 @@
desc = "A heavy wooden club reinforced with metal studs. Ancient Terran Oni were often depicted carrying this weapon."
icon_state = "kanabo"
slot_flags = SLOT_BACK
damtype = DAMAGE_TYPE_BRUTE
damage_type = DAMAGE_TYPE_BRUTE
damage_force = 15
throw_force = 5
attack_verb = list("battered", "hammered", "struck")
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/obj-defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// todo: maybe the item side should handle this?
run_damage_instance(
weapon.damage_force * (clickchain ? clickchain.damage_multiplier : 1),
weapon.damtype,
weapon.damage_type,
weapon.damage_tier,
weapon.damage_flag,
weapon.damage_mode,
Expand Down Expand Up @@ -96,15 +96,15 @@
/obj/hitsound_melee(obj/item/I)
if(!isnull(material_primary))
var/datum/material/primary = get_primary_material()
. = I.damtype == DAMAGE_TYPE_BURN? primary.sound_melee_burn : primary.sound_melee_brute
. = I.damage_type == DAMAGE_TYPE_BURN? primary.sound_melee_burn : primary.sound_melee_brute
if(!isnull(.))
return
return ..()

/obj/hitsound_throwhit(obj/item/I)
if(!isnull(material_primary))
var/datum/material/primary = get_primary_material()
. = I.damtype == DAMAGE_TYPE_BURN? primary.sound_melee_burn : primary.sound_melee_brute
. = I.damage_type == DAMAGE_TYPE_BURN? primary.sound_melee_burn : primary.sound_melee_brute
if(!isnull(.))
return
return ..()
Expand Down
1 change: 0 additions & 1 deletion code/game/objects/obj.dm
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
var/pry = 0 //Used in attackby() to open doors
//! LEGACY: DO NOT USE
var/in_use = 0 // If we have a user using us, this will be set on. We will check if the user has stopped using us, and thus stop updating and LAGGING EVERYTHING!
var/damtype = "brute"
// todo: /obj/item level, /obj/projectile level, how to deal with armor?
var/armor_penetration = 0
var/show_messages
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/props/projectile_lock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
if(timing)
return PROJECTILE_IMPACT_DELETE

if(istype(proj, /obj/projectile/beam/heavylaser/cannon) || istype(proj, /obj/projectile/beam/emitter) || (proj.damage_force >= 80 && proj.damtype == DAMAGE_TYPE_BURN))
if(istype(proj, /obj/projectile/beam/heavylaser/cannon) || istype(proj, /obj/projectile/beam/emitter) || (proj.damage_force >= 80 && proj.damage_type == DAMAGE_TYPE_BURN))
toggle_lock()
visible_message("<span class='notice'>\The [src] [enabled ? "disengages" : "engages"] its locking mechanism.</span>")

Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/props/puzzledoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
else if(src.density && (user.a_intent == INTENT_HARM))
var/obj/item/W = C
user.setClickCooldown(user.get_attack_speed(W))
if(W.damtype == DAMAGE_TYPE_BRUTE || W.damtype == DAMAGE_TYPE_BURN)
if(W.damage_type == DAMAGE_TYPE_BRUTE || W.damage_type == DAMAGE_TYPE_BURN)
user.do_attack_animation(src)
user.visible_message("<span class='danger'>\The [user] hits \the [src] with \the [W] with no visible effect.</span>")

Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/simulated/wall/wall-defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
// todo: maybe the item side should handle this?
run_damage_instance(
weapon.damage_force * (clickchain ? clickchain.damage_multiplier : 1),
weapon.damtype,
weapon.damage_type,
weapon.damage_tier,
weapon.damage_flag,
weapon.damage_mode,
Expand Down
Loading

0 comments on commit e3b936f

Please sign in to comment.