Skip to content

Commit

Permalink
https://github.com/tgstation/tgstation/pull/79207
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapu1178 committed Nov 17, 2024
1 parent a865025 commit b41fcfe
Show file tree
Hide file tree
Showing 20 changed files with 264 additions and 328 deletions.
9 changes: 8 additions & 1 deletion code/__DEFINES/dcs/signals/signals_mob/signals_mob_main.dm
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,15 @@
///from base of mob/create_mob_hud(): ()
#define COMSIG_MOB_HUD_CREATED "mob_hud_created"

///from base of /mob/living/proc/apply_damage(): (damage, damagetype, def_zone)
/// from /mob/living/proc/apply_damage(): (list/damage_mods, damage, damagetype, def_zone, sharpness, attack_direction, attacking_item)
/// allows you to add multiplicative damage modifiers to the damage mods argument to adjust incoming damage
/// not sent if the apply damage call was forced
#define COMSIG_MOB_APPLY_DAMAGE_MODIFIERS "mob_apply_damage_modifiers"
/// from base of /mob/living/proc/apply_damage(): (damage, damagetype, def_zone, blocked, sharpness, attack_direction, attacking_item)
#define COMSIG_MOB_APPLY_DAMAGE "mob_apply_damage"
/// from /mob/living/proc/apply_damage(): (damage, damagetype, def_zone, blocked, sharpness, attack_direction, attacking_item)
/// works like above but after the damage is actually inflicted
#define COMSIG_MOB_AFTER_APPLY_DAMAGE "mob_after_apply_damage"
///from base of /mob/living/attack_alien(): (user)
#define COMSIG_MOB_ATTACK_ALIEN "mob_attack_alien"
///from base of /mob/throw_item(): (atom/target)
Expand Down
7 changes: 7 additions & 0 deletions code/datums/components/explodable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,17 @@

if(!def_zone)
return

if(damagetype != BURN) //Don't bother if it's not fire.
return

if(isbodypart(def_zone))
var/obj/item/bodypart/hitting = def_zone
def_zone = hitting.body_zone

if(!is_hitting_zone(def_zone)) //You didn't hit us! ha!
return

detonate()

/datum/component/explodable/proc/on_equip(datum/source, mob/equipper, slot)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/revolution/revolution.dm
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
owner.current.visible_message(span_deconversion_message("The frame beeps contentedly, suppressing the disloyal personality traits from the MMI before initalizing it."), null, null, null, owner.current)
to_chat(owner, span_userdanger("The frame's firmware detects and suppresses your unwanted personality traits! You feel more content with the leadership around these parts."))

//blunt trauma deconversions call this through species.dm spec_attacked_by()
//blunt trauma deconversions
/datum/antagonist/rev/proc/remove_revolutionary(borged, deconverter)
owner.current.log_message("has been deconverted from the revolution by [ismob(deconverter) ? key_name(deconverter) : deconverter]!", LOG_ATTACK, color="#960000")
if(borged)
Expand Down
91 changes: 61 additions & 30 deletions code/modules/mob/living/carbon/damage_procs.dm
Original file line number Diff line number Diff line change
@@ -1,43 +1,74 @@


/mob/living/carbon/apply_damage(damage, damagetype = BRUTE, def_zone = null, blocked = FALSE, forced = FALSE, spread_damage = FALSE, sharpness = NONE, attack_direction = null, cap_loss_at = 0)
SEND_SIGNAL(src, COMSIG_MOB_APPLY_DAMAGE, damage, damagetype, def_zone)
var/hit_percent = (100-blocked)/100
if(!damage || (!forced && hit_percent <= 0))
return 0
/mob/living/carbon/apply_damage(
damage = 0,
damagetype = BRUTE,
def_zone = null,
blocked = 0,
forced = FALSE,
spread_damage = FALSE,
sharpness = NONE,
attack_direction = null,
obj/item/attacking_item = null,
)
// Spread damage should always have def zone be null
if(spread_damage)
def_zone = null

// Otherwise if def zone is null, we'll get a random bodypart / zone to hit.
// ALso we'll automatically covnert string def zones into bodyparts to pass into parent call.
else if(!isbodypart(def_zone))
var/random_zone = def_zone ? deprecise_zone(def_zone) : get_random_valid_zone(def_zone)
def_zone = get_bodypart(random_zone) || bodyparts[1]

. = ..()
// Taking brute or burn to bodyparts gives a damage flash
if(def_zone && (damagetype == BRUTE || damagetype == BURN))
damageoverlaytemp += .

return .

/mob/living/carbon/human/apply_damage(
damage = 0,
damagetype = BRUTE,
def_zone = null,
blocked = 0,
forced = FALSE,
spread_damage = FALSE,
sharpness = NONE,
attack_direction = null,
obj/item/attacking_item = null,
)

// Add relevant DR modifiers into blocked value to pass to parent
blocked += physiology?.damage_resistance
return ..()

var/obj/item/bodypart/BP = null
if(!spread_damage)
if(isbodypart(def_zone)) //we specified a bodypart object
BP = def_zone
else
if(!def_zone)
def_zone = ran_zone(def_zone)
BP = get_bodypart(deprecise_zone(def_zone))
if(!BP)
BP = bodyparts[1]
/mob/living/carbon/human/get_incoming_damage_modifier(
damage = 0,
damagetype = BRUTE,
def_zone = null,
sharpness = NONE,
attack_direction = null,
attacking_item,
)
. = ..()

var/damage_amount = forced ? damage : damage * hit_percent
switch(damagetype)
if(BRUTE)
if(BP)
BP.receive_damage(damage_amount, 0, sharpness = sharpness)
else //no bodypart, we deal damage with a more general method.
adjustBruteLoss(damage_amount, forced = forced)
. *= physiology.brute_mod
if(BURN)
if(BP)
BP.receive_damage(0, damage_amount, sharpness = sharpness)
else
adjustFireLoss(damage_amount, forced = forced)
. *= physiology.burn_mod
if(TOX)
adjustToxLoss(damage_amount, forced = forced)
if(OXY)
adjustOxyLoss(damage_amount, forced = forced)
. *= physiology.tox_mod
if(CLONE)
adjustCloneLoss(damage_amount, forced = forced)
. *= physiology.clone_mod
if(STAMINA)
CRASH("apply_damage tried to adjust stamina loss!")
return TRUE
. *= physiology.stamina_mod
if(BRAIN)
. *= physiology.brain_mod

return .


//These procs fetch a cumulative total damage from all bodyparts
Expand Down
4 changes: 0 additions & 4 deletions code/modules/mob/living/carbon/human/damage_procs.dm

This file was deleted.

36 changes: 0 additions & 36 deletions code/modules/mob/living/carbon/human/human_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,42 +131,6 @@

return FALSE

/mob/living/carbon/human/attacked_by(obj/item/I, mob/living/user)
var/target_zone = deprecise_zone(user.zone_selected) //our intended target

var/obj/item/bodypart/affecting = get_bodypart(target_zone)
if (!affecting || affecting.is_stump)
to_chat(user, span_danger("They do not have a [parse_zone(target_zone)]"))
return MOB_ATTACKEDBY_FAIL

// If we aren't being hit by ourself, roll for accuracy.
if(user != src)
var/bodyzone_modifier = GLOB.bodyzone_gurps_mods[target_zone]
var/roll
if(HAS_TRAIT(user, TRAIT_PERFECT_ATTACKER))
roll = SUCCESS
else
roll = user.stat_roll(10, /datum/rpg_skill/skirmish, bodyzone_modifier, -7, src).outcome

var/hit_zone
switch(roll)
if(CRIT_FAILURE)
visible_message(span_danger("\The [user] swings at [src] with \the [I], narrowly missing!"))
return MOB_ATTACKEDBY_MISS

if(FAILURE)
hit_zone = get_random_valid_zone()
else
hit_zone = target_zone

affecting = get_bodypart(hit_zone)

SEND_SIGNAL(I, COMSIG_ITEM_ATTACK_ZONE, src, user, affecting)

// the attacked_by code varies among species
return dna.species.spec_attacked_by(I, user, affecting, src)


/mob/living/carbon/human/attack_hulk(mob/living/carbon/human/user)
. = ..()
if(!.)
Expand Down
41 changes: 28 additions & 13 deletions code/modules/mob/living/carbon/human/physiology.dm
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
//Stores several modifiers in a way that isn't cleared by changing species

/datum/physiology
var/brute_mod = 1 // % of brute damage taken from all sources
var/burn_mod = 1 // % of burn damage taken from all sources
var/tox_mod = 1 // % of toxin damage taken from all sources
var/oxy_mod = 1 // % of oxygen damage taken from all sources
var/clone_mod = 1 // % of clone damage taken from all sources
var/stamina_mod = 1 // % of stamina damage taken from all sources
var/brain_mod = 1 // % of brain damage taken from all sources

var/pressure_mod = 1 // % of brute damage taken from low or high pressure (stacks with brute_mod)
var/heat_mod = 1 // % of burn damage taken from heat (stacks with burn_mod)
var/cold_mod = 1 // % of burn damage taken from cold (stacks with burn_mod)

var/damage_resistance = 0 // %damage reduction from all sources
/// Multiplier to brute damage received.
/// IE: A brute mod of 0.9 = 10% less brute damage.
/// Only applies to damage dealt via [apply_damage][/mob/living/proc/apply_damage] unless factored in manually.
var/brute_mod = 1
/// Multiplier to burn damage received
var/burn_mod = 1
/// Multiplier to toxin damage received
var/tox_mod = 1
/// Multiplier to oxygen damage received
var/oxy_mod = 1
/// Multiplier to clone damage received
var/clone_mod = 1
/// Multiplier to stamina damage received
var/stamina_mod = 1
/// Multiplier to brain damage received
var/brain_mod = 1

/// Multiplier to damage taken from high / low pressure exposure, stacking with the brute modifier
var/pressure_mod = 1
/// Multiplier to damage taken from high temperature exposure, stacking with the burn modifier
var/heat_mod = 1
/// Multiplier to damage taken from low temperature exposure, stacking with the toxin modifier
var/cold_mod = 1

/// Flat damage reduction from taking damage
/// Unlike the other modifiers, this is not a multiplier.
/// IE: DR of 10 = 10% less damage.
var/damage_resistance = 0

var/siemens_coeff = 1 // resistance to shocks

Expand Down
Loading

0 comments on commit b41fcfe

Please sign in to comment.