mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 21:18:37 +01:00
Converts table_smash component into an element (#94585)
## About The Pull Request <img width="573" height="30" alt="firefox_EhVA73C1LZ" src="https://github.com/user-attachments/assets/f77baf9c-2585-4cb7-a08f-5ce8322b0a54" /> ## Why It's Good For The Game Less overhead and memory usage. ## Changelog 🆑 refactor: refactors table_smash component into an element /🆑
This commit is contained in:
@@ -1,64 +1,64 @@
|
||||
/// Component which allows mobs to be smashed onto this surface like a wrestling move
|
||||
/datum/component/table_smash
|
||||
/datum/element/table_smash
|
||||
element_flags = ELEMENT_BESPOKE
|
||||
argument_hash_start_idx = 2
|
||||
/// If true, mobs will be placed gently on the table even if they're in an aggressive grab
|
||||
var/gentle_push
|
||||
/// Callback invoked after a hostile table action
|
||||
var/datum/callback/after_smash
|
||||
|
||||
/datum/component/table_smash/Initialize(gentle_push = FALSE, after_smash = null)
|
||||
/datum/element/table_smash/Attach(datum/target, gentle_push = FALSE)
|
||||
. = ..()
|
||||
if (!isobj(parent))
|
||||
return COMPONENT_INCOMPATIBLE
|
||||
if (!isobj(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
|
||||
src.gentle_push = gentle_push
|
||||
src.after_smash = after_smash
|
||||
|
||||
/datum/component/table_smash/RegisterWithParent()
|
||||
RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_interaction))
|
||||
RegisterSignal(parent, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_item_interaction))
|
||||
RegisterSignal(target, COMSIG_ATOM_ATTACK_HAND, PROC_REF(on_interaction))
|
||||
RegisterSignal(target, COMSIG_ATOM_ITEM_INTERACTION, PROC_REF(on_item_interaction))
|
||||
|
||||
var/static/list/loc_connections = list(
|
||||
COMSIG_LIVING_DISARM_COLLIDE = PROC_REF(on_pushed_into),
|
||||
COMSIG_LIVING_DISARM_COLLIDE = TYPE_PROC_REF(/obj/structure/table, on_pushed_into),
|
||||
)
|
||||
AddComponent(/datum/component/connect_loc_behalf, parent, loc_connections)
|
||||
target.AddComponent(/datum/component/connect_loc_behalf, target, loc_connections)
|
||||
|
||||
/datum/component/table_smash/UnregisterFromParent()
|
||||
UnregisterSignal(parent, list(COMSIG_ATOM_ATTACK_HAND, COMSIG_ATOM_ITEM_INTERACTION))
|
||||
/datum/element/table_smash/Detach(datum/source, ...)
|
||||
. = ..()
|
||||
UnregisterSignal(source, list(COMSIG_ATOM_ATTACK_HAND, COMSIG_ATOM_ITEM_INTERACTION))
|
||||
|
||||
/// Called when someone clicks on our surface
|
||||
/datum/component/table_smash/proc/on_interaction(obj/table, mob/user)
|
||||
/datum/element/table_smash/proc/on_interaction(datum/source, mob/user)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if (!table.Adjacent(user) || !user.pulling)
|
||||
var/obj/source_obj = source
|
||||
if (!source_obj.Adjacent(user) || !user.pulling)
|
||||
return
|
||||
|
||||
if (!isliving(user.pulling))
|
||||
if (!(user.pulling.pass_flags & PASSTABLE))
|
||||
return
|
||||
|
||||
user.Move_Pulled(table)
|
||||
user.Move_Pulled(source_obj)
|
||||
|
||||
if (user.pulling.loc == table.loc)
|
||||
user.visible_message(span_notice("[user] places [user.pulling] onto [table]."),
|
||||
span_notice("You place [user.pulling] onto [table]."))
|
||||
if (user.pulling.loc == source_obj.loc)
|
||||
user.visible_message(span_notice("[user] places [user.pulling] onto [source_obj]."),
|
||||
span_notice("You place [user.pulling] onto [source_obj]."))
|
||||
user.stop_pulling()
|
||||
|
||||
return COMPONENT_CANCEL_ATTACK_CHAIN
|
||||
|
||||
var/mob/living/pushed_mob = user.pulling
|
||||
if (pushed_mob.buckled)
|
||||
if (pushed_mob.buckled == table)
|
||||
//Already buckled to the table, you probably meant to unbuckle them
|
||||
if (pushed_mob.buckled == source_obj)
|
||||
//Already buckled to the object, you probably meant to unbuckle them
|
||||
return
|
||||
|
||||
to_chat(user, span_warning("[pushed_mob] is buckled to [pushed_mob.buckled]!"))
|
||||
return COMPONENT_CANCEL_ATTACK_CHAIN
|
||||
|
||||
INVOKE_ASYNC(src, PROC_REF(perform_table_smash), table, user)
|
||||
INVOKE_ASYNC(src, PROC_REF(perform_table_smash), source_obj, user)
|
||||
return COMPONENT_CANCEL_ATTACK_CHAIN
|
||||
|
||||
/// We have a mob being pressed onto the table, but how strongly?
|
||||
/datum/component/table_smash/proc/perform_table_smash(obj/table, mob/living/user)
|
||||
/datum/element/table_smash/proc/perform_table_smash(obj/structure/table/table, mob/living/user)
|
||||
var/mob/living/pushed_mob = user.pulling
|
||||
if (user.combat_mode)
|
||||
switch(user.grab_state)
|
||||
@@ -67,23 +67,23 @@
|
||||
return
|
||||
if (GRAB_AGGRESSIVE)
|
||||
if (gentle_push)
|
||||
tableplace(user, pushed_mob)
|
||||
tableplace(user, pushed_mob, table)
|
||||
else
|
||||
tablepush(user, pushed_mob)
|
||||
tablepush(user, pushed_mob, table)
|
||||
if (GRAB_NECK to GRAB_KILL)
|
||||
tablelimbsmash(user, pushed_mob)
|
||||
tablelimbsmash(user, pushed_mob, table)
|
||||
else
|
||||
pushed_mob.visible_message(span_notice("[user] begins to place [pushed_mob] onto [table]..."), \
|
||||
span_userdanger("[user] begins to place [pushed_mob] onto [table]..."))
|
||||
if (do_after(user, 3.5 SECONDS, target = pushed_mob))
|
||||
tableplace(user, pushed_mob)
|
||||
tableplace(user, pushed_mob, table)
|
||||
else
|
||||
return
|
||||
|
||||
user.stop_pulling()
|
||||
|
||||
/// Called when someone clicks on our surface with an item
|
||||
/datum/component/table_smash/proc/on_item_interaction(obj/table, mob/living/user, obj/item/item, modifiers)
|
||||
/datum/element/table_smash/proc/on_item_interaction(obj/structure/table/table, mob/living/user, obj/item/item, modifiers)
|
||||
SIGNAL_HANDLER
|
||||
if (!istype(item, /obj/item/riding_offhand))
|
||||
return NONE
|
||||
@@ -97,7 +97,7 @@
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
|
||||
/// Called when someone clicks on our surface using a fireman's carry
|
||||
/datum/component/table_smash/proc/riding_offhand_act(mob/living/user, obj/item/riding_offhand/riding_item)
|
||||
/datum/element/table_smash/proc/riding_offhand_act(mob/living/user, obj/item/riding_offhand/riding_item, obj/structure/table/table)
|
||||
var/mob/living/carried_mob = riding_item.rider
|
||||
if (user.combat_mode)
|
||||
user.unbuckle_mob(carried_mob)
|
||||
@@ -117,25 +117,24 @@
|
||||
if (istype(potential_spine))
|
||||
tableplace_delay *= potential_spine.athletics_boost_multiplier
|
||||
|
||||
carried_mob.visible_message(span_notice("[user] begins to[skills_space] place [carried_mob] onto [parent]..."),
|
||||
span_userdanger("[user] begins to[skills_space] place [carried_mob] onto [parent]..."))
|
||||
carried_mob.visible_message(span_notice("[user] begins to[skills_space] place [carried_mob] onto [table]..."),
|
||||
span_userdanger("[user] begins to[skills_space] place [carried_mob] onto [table]..."))
|
||||
if (!do_after(user, tableplace_delay, target = carried_mob))
|
||||
return ITEM_INTERACT_BLOCKING
|
||||
user.unbuckle_mob(carried_mob)
|
||||
tableplace(user, carried_mob)
|
||||
tableplace(user, carried_mob, table)
|
||||
return ITEM_INTERACT_SUCCESS
|
||||
|
||||
/// Gently place the mob onto the table
|
||||
/datum/component/table_smash/proc/tableplace(mob/living/user, mob/living/pushed_mob)
|
||||
var/obj/table = parent
|
||||
/datum/element/table_smash/proc/tableplace(mob/living/user, mob/living/pushed_mob, obj/structure/table/table)
|
||||
pushed_mob.forceMove(table.loc)
|
||||
pushed_mob.set_resting(TRUE, TRUE)
|
||||
pushed_mob.visible_message(span_notice("[user] places [pushed_mob] onto [parent]."), \
|
||||
span_notice("[user] places [pushed_mob] onto [parent]."))
|
||||
log_combat(user, pushed_mob, "places", null, "onto [parent]")
|
||||
pushed_mob.visible_message(span_notice("[user] places [pushed_mob] onto [table]."), \
|
||||
span_notice("[user] places [pushed_mob] onto [table]."))
|
||||
log_combat(user, pushed_mob, "placed", null, "onto [table]")
|
||||
|
||||
/// Aggressively smash the mob onto the table
|
||||
/datum/component/table_smash/proc/tablepush(mob/living/user, mob/living/pushed_mob)
|
||||
/datum/element/table_smash/proc/tablepush(mob/living/user, mob/living/pushed_mob, obj/structure/table/table)
|
||||
if (HAS_TRAIT(user, TRAIT_PACIFISM))
|
||||
to_chat(user, span_danger("Throwing [pushed_mob] onto the table might hurt them!"))
|
||||
return
|
||||
@@ -146,7 +145,6 @@
|
||||
if (!obj.CanAllowThrough(pushed_mob))
|
||||
return
|
||||
|
||||
var/obj/table = parent
|
||||
pushed_mob.Move(table.loc)
|
||||
passtable_off(pushed_mob, passtable_key)
|
||||
if (pushed_mob.loc != table.loc) //Something prevented the tabling
|
||||
@@ -156,16 +154,15 @@
|
||||
pushed_mob.apply_damage(10, BRUTE)
|
||||
pushed_mob.apply_damage(40, STAMINA)
|
||||
playsound(pushed_mob, 'sound/effects/tableslam.ogg', 90, TRUE)
|
||||
pushed_mob.visible_message(span_danger("[user] slams [pushed_mob] onto \the [parent]!"), \
|
||||
span_userdanger("[user] slams you onto \the [parent]!"))
|
||||
log_combat(user, pushed_mob, "tabled", null, "onto [parent]")
|
||||
pushed_mob.visible_message(span_danger("[user] slams [pushed_mob] onto \the [table]!"), \
|
||||
span_userdanger("[user] slams you onto \the [table]!"))
|
||||
log_combat(user, pushed_mob, "tabled", null, "onto [table]")
|
||||
pushed_mob.add_mood_event("table", /datum/mood_event/table)
|
||||
SEND_SIGNAL(user, COMSIG_LIVING_TABLE_SLAMMING, pushed_mob, parent)
|
||||
after_smash?.Invoke(pushed_mob)
|
||||
SEND_SIGNAL(user, COMSIG_LIVING_TABLE_SLAMMING, pushed_mob, table)
|
||||
table.after_smash(pushed_mob)
|
||||
|
||||
/// Even more aggressively smash a single part of a mob onto the table
|
||||
/datum/component/table_smash/proc/tablelimbsmash(mob/living/user, mob/living/pushed_mob)
|
||||
var/obj/table = parent
|
||||
/datum/element/table_smash/proc/tablelimbsmash(mob/living/user, mob/living/pushed_mob, obj/structure/table/table)
|
||||
pushed_mob.Knockdown(3 SECONDS)
|
||||
var/obj/item/bodypart/banged_limb = pushed_mob.get_bodypart(user.zone_selected) || pushed_mob.get_bodypart(BODY_ZONE_HEAD)
|
||||
var/extra_wound = 0
|
||||
@@ -174,24 +171,28 @@
|
||||
pushed_mob.apply_damage(30, BRUTE, banged_limb, wound_bonus = extra_wound)
|
||||
pushed_mob.apply_damage(60, STAMINA)
|
||||
playsound(pushed_mob, 'sound/effects/bang.ogg', 90, TRUE)
|
||||
pushed_mob.visible_message(span_danger("[user] smashes [pushed_mob]'s [banged_limb.plaintext_zone] against \the [parent]!"),
|
||||
span_userdanger("[user] smashes your [banged_limb.plaintext_zone] against \the [parent]"))
|
||||
log_combat(user, pushed_mob, "head slammed", null, "against [parent]")
|
||||
pushed_mob.visible_message(span_danger("[user] smashes [pushed_mob]'s [banged_limb.plaintext_zone] against \the [table]!"),
|
||||
span_userdanger("[user] smashes your [banged_limb.plaintext_zone] against \the [table]"))
|
||||
log_combat(user, pushed_mob, "head slammed", null, "against [table]")
|
||||
pushed_mob.add_mood_event("table", /datum/mood_event/table_limbsmash, banged_limb)
|
||||
table.take_damage(50)
|
||||
SEND_SIGNAL(user, COMSIG_LIVING_TABLE_LIMB_SLAMMING, pushed_mob, parent)
|
||||
after_smash?.Invoke(pushed_mob)
|
||||
SEND_SIGNAL(user, COMSIG_LIVING_TABLE_LIMB_SLAMMING, pushed_mob, table)
|
||||
table.after_smash(pushed_mob)
|
||||
|
||||
/// Called when someone is shoved into our tile
|
||||
/datum/component/table_smash/proc/on_pushed_into(turf/source, mob/living/shover, mob/living/target, shove_flags, obj/item/weapon)
|
||||
/obj/structure/table/proc/on_pushed_into(datum/source, mob/living/shover, mob/living/target, shove_flags, obj/item/weapon)
|
||||
SIGNAL_HANDLER
|
||||
if((shove_flags & SHOVE_KNOCKDOWN_BLOCKED) || !(shove_flags & SHOVE_BLOCKED))
|
||||
return
|
||||
target.Knockdown(SHOVE_KNOCKDOWN_TABLE, daze_amount = 3 SECONDS)
|
||||
target.visible_message(span_danger("[shover.name] shoves [target.name] onto \the [parent]!"),
|
||||
span_userdanger("You're shoved onto \the [parent] by [shover.name]!"), span_hear("You hear aggressive shuffling followed by a loud thud!"), COMBAT_MESSAGE_RANGE, shover)
|
||||
to_chat(shover, span_danger("You shove [target.name] onto \the [parent]!"))
|
||||
target.throw_at(parent, 1, 1, null, FALSE) //1 speed throws with no spin are basically just forcemoves with a hard collision check
|
||||
log_combat(shover, target, "shoved", "onto [parent] (table)[weapon ? " with [weapon]" : ""]")
|
||||
after_smash?.Invoke(target)
|
||||
target.visible_message(span_danger("[shover.name] shoves [target.name] onto \the [src]!"),
|
||||
span_userdanger("You're shoved onto \the [src] by [shover.name]!"), span_hear("You hear aggressive shuffling followed by a loud thud!"), COMBAT_MESSAGE_RANGE, shover)
|
||||
to_chat(shover, span_danger("You shove [target.name] onto \the [src]!"))
|
||||
target.throw_at(src, 1, 1, null, FALSE) //1 speed throws with no spin are basically just forcemoves with a hard collision check
|
||||
log_combat(shover, target, "shoved", "onto [src] (table)[weapon ? " with [weapon]" : ""]")
|
||||
after_smash(target)
|
||||
return COMSIG_LIVING_SHOVE_HANDLED
|
||||
|
||||
/// What happens after something gets smashed onto this table
|
||||
/obj/structure/table/proc/after_smash(mob/living/smashed_onto)
|
||||
return
|
||||
@@ -50,7 +50,7 @@
|
||||
AddElement(/datum/element/elevation, pixel_shift = 12)
|
||||
AddElement(/datum/element/give_turf_traits, string_list(turf_traits))
|
||||
AddElement(/datum/element/footstep_override, footstep = footstep, priority = STEP_SOUND_TABLE_PRIORITY)
|
||||
AddComponent(/datum/component/table_smash)
|
||||
AddElement(/datum/element/table_smash)
|
||||
|
||||
/obj/structure/platform/add_context(atom/source, list/context, obj/item/held_item, mob/living/user)
|
||||
. = ..()
|
||||
|
||||
@@ -91,10 +91,10 @@
|
||||
make_climbable()
|
||||
AddElement(/datum/element/give_turf_traits, string_list(turf_traits))
|
||||
AddElement(/datum/element/footstep_override, priority = STEP_SOUND_TABLE_PRIORITY)
|
||||
AddComponent(/datum/component/table_smash, gentle_push = slam_gently, after_smash = CALLBACK(src, PROC_REF(after_smash)))
|
||||
AddElement(/datum/element/table_smash, gentle_push = slam_gently)
|
||||
|
||||
/// Called after someone is harmfully smashed into us
|
||||
/obj/structure/table/proc/after_smash(mob/living/smashed)
|
||||
/obj/structure/table/after_smash(mob/living/smashed_onto)
|
||||
return // This is mostly for our children
|
||||
|
||||
/// Applies additional properties based on the frame used to construct this table.
|
||||
@@ -633,7 +633,7 @@
|
||||
canSmoothWith = SMOOTH_GROUP_WOOD_TABLES
|
||||
custom_materials = list(/datum/material/wood = SHEET_MATERIAL_AMOUNT)
|
||||
|
||||
/obj/structure/table/wood/after_smash(mob/living/smashed)
|
||||
/obj/structure/table/wood/after_smash(mob/living/smashed_onto)
|
||||
if(QDELETED(src) || prob(66))
|
||||
return
|
||||
visible_message(
|
||||
@@ -642,9 +642,9 @@
|
||||
)
|
||||
|
||||
playsound(src, 'sound/effects/wounds/crack2.ogg', 50, TRUE)
|
||||
smashed.Knockdown(10 SECONDS)
|
||||
smashed.Paralyze(2 SECONDS)
|
||||
smashed.apply_damage(20, BRUTE)
|
||||
smashed_onto.Knockdown(10 SECONDS)
|
||||
smashed_onto.Paralyze(2 SECONDS)
|
||||
smashed_onto.apply_damage(20, BRUTE)
|
||||
deconstruct(FALSE)
|
||||
|
||||
/obj/structure/table/wood/narsie_act(total_override = TRUE)
|
||||
@@ -855,7 +855,7 @@
|
||||
canSmoothWith = SMOOTH_GROUP_BRONZE_TABLES
|
||||
can_flip = FALSE
|
||||
|
||||
/obj/structure/table/bronze/after_smash(mob/living/pushed_mob)
|
||||
/obj/structure/table/bronze/after_smash(mob/living/smashed_onto)
|
||||
playsound(src, 'sound/effects/magic/clockwork/fellowship_armory.ogg', 50, TRUE)
|
||||
|
||||
/obj/structure/table/reinforced/rglass
|
||||
|
||||
+1
-1
@@ -1324,7 +1324,6 @@
|
||||
#include "code\datums\components\supermatter_crystal.dm"
|
||||
#include "code\datums\components\swabbing.dm"
|
||||
#include "code\datums\components\swarming.dm"
|
||||
#include "code\datums\components\table_smash.dm"
|
||||
#include "code\datums\components\tackle.dm"
|
||||
#include "code\datums\components\tactical.dm"
|
||||
#include "code\datums\components\takes_reagent_appearance.dm"
|
||||
@@ -1665,6 +1664,7 @@
|
||||
#include "code\datums\elements\surgery_aid.dm"
|
||||
#include "code\datums\elements\swabbable.dm"
|
||||
#include "code\datums\elements\swimming_tile.dm"
|
||||
#include "code\datums\elements\table_smash.dm"
|
||||
#include "code\datums\elements\tenacious.dm"
|
||||
#include "code\datums\elements\tiny_mob_hunter.dm"
|
||||
#include "code\datums\elements\tool_flash.dm"
|
||||
|
||||
Reference in New Issue
Block a user