Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction Chain & Damage refactoring #9838

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b648b31
Initial damage procs
PowerfulBacon Sep 2, 2023
08f8598
Converts half of all apply_damage instances to the new apply damage s…
PowerfulBacon Sep 2, 2023
7d9cc2f
Some more damage bits and pieces
PowerfulBacon Sep 3, 2023
40c6bd4
Bunch of damage related stuff
PowerfulBacon Sep 3, 2023
29eadfa
attack clicks
PowerfulBacon Sep 3, 2023
6512d03
Some alien improvements
PowerfulBacon Sep 3, 2023
8070348
Update living_damage_extensions.dm
PowerfulBacon Sep 3, 2023
ddc01b7
Completes 1/3 of the attackby to item_interact refactoring
PowerfulBacon Sep 3, 2023
2487eff
Converts 24 more files from attackby to item_interact
PowerfulBacon Sep 3, 2023
dcab4d9
Some more conversions
PowerfulBacon Sep 3, 2023
1816a37
A bunch more conversions from attackby to item interact
PowerfulBacon Sep 4, 2023
a45b587
Converts some more attackbys into item_interacts
PowerfulBacon Sep 4, 2023
e7ea856
Some more updates
PowerfulBacon Sep 4, 2023
b8ef4f1
Makes the code compile and work
PowerfulBacon Sep 4, 2023
57cc747
Fixes damages not applying to objects
PowerfulBacon Sep 4, 2023
224c6a2
Changes the damage types
PowerfulBacon Sep 5, 2023
95e6207
Moves some stuff out of species
PowerfulBacon Sep 5, 2023
2643781
Some fixes
PowerfulBacon Sep 5, 2023
d0c3c2e
More systemic damage part 1
PowerfulBacon Sep 6, 2023
13daaeb
Some more damage refactors
PowerfulBacon Sep 6, 2023
7563f3d
Damage conversions
PowerfulBacon Sep 8, 2023
10d805a
on_damaged
PowerfulBacon Sep 10, 2023
1376168
Returns the amount of damage dealt
PowerfulBacon Sep 15, 2023
f603e33
Mob attacks
PowerfulBacon Sep 15, 2023
4b67474
Adds in the unit test
PowerfulBacon Sep 15, 2023
a808490
Bunch of adjustBruteLoss conversions
PowerfulBacon Sep 16, 2023
4d720c0
adjustBruteLoss
PowerfulBacon Sep 16, 2023
652e29c
Slime damaging rework
PowerfulBacon Sep 16, 2023
b2e43f6
Update test_mob_attacks.dm
PowerfulBacon Sep 16, 2023
b0981b3
Fixes simplemobs not taking damage, fixes humans not updating their d…
PowerfulBacon Sep 16, 2023
6ac2528
Allows the larvae probability to be rigged in order to make the unit …
PowerfulBacon Sep 16, 2023
a5dca9e
Deal generic attack takes into account simplemob melee damage type
PowerfulBacon Sep 18, 2023
c901d28
Factory boss update health now makes sense
PowerfulBacon Sep 18, 2023
7cec74c
AdjustCloneLoss updates. Changes adjustBruteLoss to adjustBruteLossAb…
PowerfulBacon Sep 18, 2023
dd6b9db
Removes update health
PowerfulBacon Oct 14, 2023
fd91217
Adds in an item damage unit test that fails on all items
PowerfulBacon Oct 14, 2023
4dc4d72
Fixes a space at the start of the line
PowerfulBacon Oct 14, 2023
6ec406b
63 attackby conversions
PowerfulBacon Dec 21, 2023
03e3698
Update floodlight.dm
PowerfulBacon Dec 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion _maps/_basemap.dm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to toggle this back when done!

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//#define LOWMEMORYMODE //uncomment this to load centcom and runtime station and thats it.
#define LOWMEMORYMODE //uncomment this to load centcom and runtime station and thats it.

#include "map_files\generic\CentCom.dmm"

Expand Down
23 changes: 22 additions & 1 deletion beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include "code\__DEFINES\contracts.dm"
#include "code\__DEFINES\cooldowns.dm"
#include "code\__DEFINES\cult.dm"
#include "code\__DEFINES\damage.dm"
#include "code\__DEFINES\departments.dm"
#include "code\__DEFINES\devices.dm"
#include "code\__DEFINES\directional.dm"
Expand All @@ -83,7 +84,6 @@
#include "code\__DEFINES\fov.dm"
#include "code\__DEFINES\ghost.dm"
#include "code\__DEFINES\gravity.dm"
#include "code\__DEFINES\helpers.dm"
#include "code\__DEFINES\html_assistant.dm"
#include "code\__DEFINES\hud.dm"
#include "code\__DEFINES\icon_smoothing.dm"
Expand Down Expand Up @@ -261,6 +261,7 @@
#include "code\__HELPERS\qdel.dm"
#include "code\__HELPERS\radiation.dm"
#include "code\__HELPERS\radio.dm"
#include "code\__HELPERS\random_helper.dm"
#include "code\__HELPERS\randoms.dm"
#include "code\__HELPERS\records.dm"
#include "code\__HELPERS\roundend.dm"
Expand Down Expand Up @@ -2567,6 +2568,26 @@
#include "code\modules\guardian\abilities\minor\snares.dm"
#include "code\modules\guardian\abilities\minor\teleport.dm"
#include "code\modules\guardian\abilities\special\time.dm"
#include "code\modules\health\damage\damage_sources\chemical.dm"
#include "code\modules\health\damage\damage_sources\damage_source.dm"
#include "code\modules\health\damage\damage_sources\living_damage_extensions.dm"
#include "code\modules\health\damage\damage_sources\object_damage_extensions.dm"
#include "code\modules\health\damage\damage_sources\sharp.dm"
#include "code\modules\health\damage\damage_types\brute.dm"
#include "code\modules\health\damage\damage_types\burn.dm"
#include "code\modules\health\damage\damage_types\clone.dm"
#include "code\modules\health\damage\damage_types\damage_source.dm"
#include "code\modules\health\damage\damage_types\stamina.dm"
#include "code\modules\health\damage\damage_types\suffocation.dm"
#include "code\modules\health\damage\damage_types\toxin.dm"
#include "code\modules\health\damage\systemic_damage\apply_bleeding.dm"
#include "code\modules\health\damage\systemic_damage\apply_damage.dm"
#include "code\modules\health\damage\systemic_damage\apply_dismemberment.dm"
#include "code\modules\health\damage\systemic_damage\armour_penetration.dm"
#include "code\modules\health\damage\systemic_damage\calculate_armour.dm"
#include "code\modules\health\damage\systemic_damage\display_attack_message.dm"
#include "code\modules\health\damage\systemic_damage\locate_target.dm"
#include "code\modules\health\damage\systemic_damage\on_damage.dm"
#include "code\modules\holiday\easter.dm"
#include "code\modules\holiday\holidays.dm"
#include "code\modules\holodeck\area_copy.dm"
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
//Returns an integer given a hex input, supports negative values "-ff"
//skips preceding invalid characters
#define hex2num(X) text2num(X, 16)

/// subtypesof(), typesof() without the parent path
#define subtypesof(typepath) ( typesof(typepath) - typepath )
16 changes: 9 additions & 7 deletions code/__DEFINES/combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

//Damage defines //TODO: merge these down to reduce on defines
/// Physical fracturing and warping of the material.
#define BRUTE "brute"
#define BRUTE /datum/damage/brute
/// Scorching and charring of the material.
#define BURN "burn"
#define BURN /datum/damage/burn
/// Poisoning. Mostly caused by reagents.
#define TOX "toxin"
#define TOX /datum/damage/toxin
/// Suffocation.
#define OXY "oxygen"
#define OXY /datum/damage/suffocation
/// Cellular degredation. Rare and difficult to treat.
#define CLONE "clone"
/// Exhaustion and nonlethal damage.
#define STAMINA "stamina"
#define CLONE /datum/damage/clone
/// Stamina damage type
#define STAMINA_DAMTYPE /datum/damage/stamina
/// Brain damage. Should probably be decomissioned and replaced with proper organ damage.
#define BRAIN "brain"

Expand Down Expand Up @@ -42,6 +42,8 @@
#define MELEE "melee"
/// Involves magic.
#define MAGIC "magic"
/// Exhaustion and nonlethal damage.
#define STAMINA "stamina"

/*
/// Involved in checking the likelihood of applying a wound to a mob.
Expand Down
22 changes: 22 additions & 0 deletions code/__DEFINES/damage.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

GLOBAL_LIST_EMPTY(damage_type_singletons)

#define GET_DAMAGE(damage_type) (length(GLOB.damage_type_singletons) ? GLOB.damage_type_singletons[damage_type] : (create_damage_singletons())[damage_type])

/proc/create_damage_singletons()
GLOB.damage_type_singletons = list()
for (var/type in subtypesof(/datum/damage))
GLOB.damage_type_singletons[type] = new type
return GLOB.damage_type_singletons

GLOBAL_LIST_EMPTY(damage_source_singletons)

#define GET_DAMAGE_SOURCE(source_type) (length(GLOB.damage_source_singletons) ? GLOB.damage_source_singletons[source_type] : (create_source_singletons())[source_type])

/proc/create_source_singletons()
GLOB.damage_source_singletons = list()
for (var/type in subtypesof(/datum/damage_source))
GLOB.damage_source_singletons[type] = new type
return GLOB.damage_source_singletons

#define FIND_DAMAGE_SOURCE locate() in GLOB.damage_source_singletons
4 changes: 0 additions & 4 deletions code/__DEFINES/dcs/signals/signals_atom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
// /atom signals
///from base of atom/proc/Initialize(mapload): sent any time a new atom is created
#define COMSIG_ATOM_CREATED "atom_created"
///! from base of atom/attackby(): (/obj/item, /mob/living, params)
#define COMSIG_PARENT_ATTACKBY "atom_attackby"
///! Return this in response if you don't want afterattack to be called
#define COMPONENT_NO_AFTERATTACK 1
///! from base of atom/attack_hulk(): (/mob/living/carbon/human)
#define COMSIG_ATOM_HULK_ATTACK "hulk_attack"
/// from base of atom/examine(): (/mob, list/examine_text)
Expand Down
4 changes: 2 additions & 2 deletions code/__DEFINES/dcs/signals/signals_mob/signals_human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// All signals send the source datum of the signal as the first argument

// /mob/living/carbon/human signals
#define COMSIG_HUMAN_MELEE_UNARMED_ATTACK "human_melee_unarmed_attack" //! from mob/living/carbon/human/UnarmedAttack(): (atom/target)
#define COMSIG_HUMAN_MELEE_UNARMED_ATTACKBY "human_melee_unarmed_attackby" //! from mob/living/carbon/human/UnarmedAttack(): (mob/living/carbon/human/attacker)
#define COMSIG_HUMAN_MELEE_UNARMED_ATTACK "human_melee_unarmed_attack" //! from mob/living/carbon/human/primary_interact(): (atom/target)
#define COMSIG_HUMAN_MELEE_UNARMED_ATTACKBY "human_melee_unarmed_attackby" //! from mob/living/carbon/human/primary_interact(): (mob/living/carbon/human/attacker)
#define COMSIG_HUMAN_DISARM_HIT "human_disarm_hit" //! Hit by successful disarm attack (mob/living/carbon/human/attacker,zone_targeted)
#define COMSIG_HUMAN_ATTACKED "carbon_attacked" //hit by something that checks shields.

Expand Down
2 changes: 1 addition & 1 deletion code/__DEFINES/dcs/signals/signals_mob/signals_mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define COMSIG_MOB_DROPPED_ITEM "mob_dropped_item" //! from base of /item/dropped(): (/mob/user, /obj/item, loc)
#define COMSIG_MOB_APPLY_DAMGE "mob_apply_damage" //! from base of /mob/living/proc/apply_damage(): (damage, damagetype, def_zone)
#define COMSIG_MOB_ITEM_AFTERATTACK "mob_item_afterattack" //! from base of obj/item/afterattack(): (atom/target, mob/user, proximity_flag, click_parameters)
#define COMSIG_MOB_ATTACK_RANGED "mob_attack_ranged" //! from base of mob/RangedAttack(): (atom/A, params)
#define COMSIG_MOB_ATTACK_RANGED "mob_attack_ranged" //! from base of mob/primary_ranged_attack(): (atom/A, params)
#define COMSIG_MOB_THROW "mob_throw" //! from base of /mob/throw_item(): (atom/target)
#define COMSIG_MOB_UPDATE_SIGHT "mob_update_sight" //! from base of /mob/update_sight(): ()
#define COMSIG_MOB_EXAMINATE "mob_examinate" //from base of /mob/verb/examinate(): (atom/target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
#define COMSIG_ITEM_ATTACK "item_attack" //! from base of obj/item/attack(): (/mob/living/target, /mob/living/user)
#define COMSIG_ITEM_ATTACK_SELF "item_attack_self" //! from base of obj/item/attack_self(): (/mob)
#define COMPONENT_NO_INTERACT 1
#define COMSIG_ITEM_ATTACK_OBJ "item_attack_obj" //! from base of obj/item/attack_obj(): (/obj, /mob)
#define COMPONENT_NO_ATTACK_OBJ 1
#define COMSIG_ITEM_INTERACT_WITH "item_interact_with" //! from base of interact_with(atom/target, mob/user, params)
#define COMPONENT_INTERACTION_SUCCESS (1 << 0)
#define COMSIG_ITEM_PRE_ATTACK "item_pre_attack" //! from base of obj/item/pre_attack(): (atom/target, mob/user, params)
#define COMPONENT_NO_ATTACK 1
#define COMSIG_ITEM_AFTERATTACK "item_afterattack" //! from base of obj/item/afterattack(): (atom/target, mob/user, params)
#define COMSIG_ITEM_EQUIPPED "item_equip" //! from base of obj/item/equipped(): (/mob/equipper, slot)
#define COMSIG_ITEM_DROPPED "item_drop" //! from base of obj/item/dropped(): (mob/user)
#define COMSIG_ITEM_PICKUP "item_pickup" //! from base of obj/item/pickup(): (/mob/taker)
#define COMSIG_ITEM_ATTACK_ZONE "item_attack_zone" //! from base of mob/living/carbon/attacked_by(): (mob/living/carbon/target, mob/living/user, hit_zone)
#define COMSIG_ITEM_ATTACK_ZONE "item_attack_zone" //! from base of mob/living/carbon/on_attacked(): (mob/living/carbon/target, mob/living/user, hit_zone)
#define COMSIG_ITEM_IMBUE_SOUL "item_imbue_soul" //! return a truthy value to prevent ensouling, checked in /obj/effect/proc_holder/spell/targeted/lichdom/cast(): (mob/user)
#define COMSIG_ITEM_MARK_RETRIEVAL "item_mark_retrieval" //! called before marking an object for retrieval, checked in /obj/effect/proc_holder/spell/targeted/summonitem/cast() : (mob/user)
#define COMPONENT_BLOCK_MARK_RETRIEVAL 1
Expand Down
2 changes: 0 additions & 2 deletions code/__DEFINES/helpers.dm

This file was deleted.

19 changes: 19 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,22 @@

/// Messages when (something) lays an egg
#define EGG_LAYING_MESSAGES list("lays an egg.","squats down and croons.","begins making a huge racket.","begins clucking raucously.")

/// Update the health of a specific target
#define UPDATE_HEALTH(target) \
if (target.health_dirty == HEALTH_DIRTY_NOT_DIRTY) {\
target.health_dirty = HEALTH_DIRTY_QUEUED;\
spawn(0) {\
if (target.health_dirty == HEALTH_DIRTY_NOT_DIRTY) { return ; }\
target.updatehealth();\
}\
}

#define RESOLVE_HEALTH(target) if (target.health_dirty == HEALTH_DIRTY_QUEUED) {\
target.updatehealth();\
}

/// Health does not need updating
#define HEALTH_DIRTY_NOT_DIRTY 0
/// Health needs updating and has not been queued
#define HEALTH_DIRTY_QUEUED 1
8 changes: 8 additions & 0 deletions code/__HELPERS/random_helper.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// Rig probability
GLOBAL_VAR_INIT(rigged_prob, null)

/proc/safe_prob(probability)
if (!isnull(GLOB.rigged_prob))
return GLOB.rigged_prob
return prob(probability)
6 changes: 3 additions & 3 deletions code/_onclick/ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@
A.attack_ai(src)

/*
AI has no need for the UnarmedAttack() and RangedAttack() procs,
AI has no need for the primary_interact() and primary_ranged_attack() procs,
because the AI code is not generic; attack_ai() is used instead.
The below is only really for safety, or you can alter the way
it functions and re-insert it above.
*/
/mob/living/silicon/ai/UnarmedAttack(atom/A)
/mob/living/silicon/ai/primary_interact(atom/A)
A.attack_ai(src)
/mob/living/silicon/ai/RangedAttack(atom/A)
/mob/living/silicon/ai/primary_ranged_attack(atom/A)
A.attack_ai(src)

/atom/proc/attack_ai(mob/user)
Expand Down
19 changes: 10 additions & 9 deletions code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
check whether you're adjacent to the target, then pass off the click to whoever
is receiving it.
The most common are:
* mob/UnarmedAttack(atom,adjacent) - used here only when adjacent, with no item in hand; in the case of humans, checks gloves
* mob/primary_interact(atom,adjacent) - used here only when adjacent, with no item in hand; in the case of humans, checks gloves
* atom/attackby(item,user) - used only when adjacent
* item/afterattack(atom,user,adjacent,params) - used both ranged and adjacent
* mob/RangedAttack(atom,params) - used only ranged, only used for tk and laser eyes but could be changed
* mob/primary_ranged_attack(atom,params) - used only ranged, only used for tk and laser eyes but could be changed
*/
/mob/proc/ClickOn( atom/A, params )
if(world.time <= next_click)
Expand Down Expand Up @@ -133,11 +133,11 @@
//User itself, current loc, and user inventory
if(A in DirectAccess())
if(W)
W.melee_attack_chain(src, A, params)
W.use_on(src, A, params)
else
if(ismob(A))
changeNext_move(CLICK_CD_MELEE)
UnarmedAttack(A)
primary_interact(A)
return

//Can't reach anything else in lockers or other weirdness
Expand All @@ -147,16 +147,16 @@
//Standard reach turf to turf or reaching inside storage
if(CanReach(A,W))
if(W)
W.melee_attack_chain(src, A, params)
W.use_on(src, A, params)
else
if(ismob(A))
changeNext_move(CLICK_CD_MELEE)
UnarmedAttack(A,1)
primary_interact(A,1)
else
if(W)
W.afterattack(A,src,0,params)
else
RangedAttack(A,params)
primary_ranged_attack(A,params)

//Is the atom obscured by a PREVENT_CLICK_UNDER_1 object above it
/atom/proc/IsObscured()
Expand Down Expand Up @@ -259,7 +259,7 @@
proximity_flag is not currently passed to attack_hand, and is instead used
in human click code to allow glove touches only at melee range.
*/
/mob/proc/UnarmedAttack(atom/A, proximity_flag)
/mob/proc/primary_interact(atom/A, proximity_flag)
if(ismob(A))
changeNext_move(CLICK_CD_MELEE)
return
Expand All @@ -272,8 +272,9 @@
for things like ranged glove touches, spitting alien acid/neurotoxin,
animals lunging, etc.
*/
/mob/proc/RangedAttack(atom/A, params)
/mob/proc/primary_ranged_attack(atom/A, params)
SEND_SIGNAL(src, COMSIG_MOB_ATTACK_RANGED, A, params)

/*
Restrained ClickOn

Expand Down
8 changes: 4 additions & 4 deletions code/_onclick/cyborg.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

// cyborgs are prohibited from using storage items so we can I think safely remove (A.loc in contents)
if(A == loc || (A in loc) || (A in contents))
W.melee_attack_chain(src, A, params)
W.use_on(src, A, params)
return

if(!isturf(loc))
Expand All @@ -79,7 +79,7 @@
// cyborgs are prohibited from using storage items so we can I think safely remove (A.loc && isturf(A.loc.loc))
if(isturf(A) || isturf(A.loc))
if(A.Adjacent(src)) // see adjacent.dm
W.melee_attack_chain(src, A, params)
W.use_on(src, A, params)
return
else
W.afterattack(A, src, 0, params)
Expand Down Expand Up @@ -167,9 +167,9 @@
clicks, you can do so here, but you will have to
change attack_robot() above to the proper function
*/
/mob/living/silicon/robot/UnarmedAttack(atom/A)
/mob/living/silicon/robot/primary_interact(atom/A)
A.attack_robot(src)
/mob/living/silicon/robot/RangedAttack(atom/A)
/mob/living/silicon/robot/primary_ranged_attack(atom/A)
A.attack_robot(src)

/atom/proc/attack_robot(mob/user)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/pai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
var/mob/living/silicon/pai/pAI = usr
var/mob/living/carbon/holder = get(pAI.card.loc, /mob/living/carbon)
if(holder)
pAI.hostscan.attack(holder, pAI)
pAI.hostscan.attack_mob_target(holder, pAI)
else
to_chat(usr, "<span class='warning'>You are not being carried by anyone!</span>")
return 0
Expand Down
Loading
Loading