mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-26 09:32:21 +00:00
## About The Pull Request 1. Having a broken arm will affect your accuracy when firing a weapon with that arm, even potentially causing damage to you if it's a weapon with recoil. This effect is not applied under the effects of a painkiller. 2. The sister effect of this (punching someone with a broken arm) now also has an interact with painkillers (it can no longer block your attack). 3. Being drunk heavily affects ranged weapon accuracy, unless you're the bartender 4. A lot of hand handling cleanup, using new macros to make it a lot more readable at a glance ## Why It's Good For The Game We have this system for modifying firearm accuracy but we don't really use it commonly, and I feel like it slots in well with a lot of places For broken arms, it adds some more depth to the wound system, in the same way that trying to punch someone with a broken arm causes pain. (I actually want to expand this to melee weapon accuracy and attacking with melee weapons in general, but that's for a later time) For drunkenness, it just adds to the drunk shenanigans. It also slightly reduces the effectiveness of drinks as combat healing chemicals, such as quadsec - makes it a bit more of a trade off. ## Changelog 🆑 Melbert balance: Having a broken arm affects your accuracy with ranged weapons fired with that arm. Utilizing a painkiller will nullify this effect, however. balance: Painkillers will prevent your punches from being cancelled due to having a broken arm. You'll still take damage, though. balance: Being drunk now affects your accuracy with ranged weapon. The bartender is immune to this effect via their skillchip. code: A lot of code involving left and right hand handling has been cleaned up, easier to read. Report any oddities, like left and rights being flipped /🆑
51 lines
1.9 KiB
Plaintext
51 lines
1.9 KiB
Plaintext
/**
|
|
* Basic handling for showing held items in a mob's hands
|
|
*/
|
|
/datum/component/basic_inhands
|
|
/// Layer index we show our inhands upon
|
|
var/display_layer
|
|
/// Y offset to apply to inhands
|
|
var/y_offset
|
|
/// X offset to apply to inhands, is inverted for the left hand
|
|
var/x_offset
|
|
/// What overlays are we currently showing?
|
|
var/list/cached_overlays
|
|
|
|
/datum/component/basic_inhands/Initialize(display_layer = 1, y_offset = 0, x_offset = 0)
|
|
. = ..()
|
|
if (!isliving(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
src.display_layer = display_layer
|
|
src.y_offset = y_offset
|
|
src.x_offset = x_offset
|
|
cached_overlays = list()
|
|
|
|
/datum/component/basic_inhands/RegisterWithParent()
|
|
. = ..()
|
|
RegisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(on_updated_overlays))
|
|
RegisterSignal(parent, COMSIG_MOB_UPDATE_HELD_ITEMS, PROC_REF(on_updated_held_items))
|
|
|
|
/datum/component/basic_inhands/UnregisterFromParent()
|
|
. = ..()
|
|
UnregisterSignal(parent, list(COMSIG_ATOM_UPDATE_OVERLAYS, COMSIG_MOB_UPDATE_HELD_ITEMS))
|
|
|
|
/// When your overlays update, add your held overlays
|
|
/datum/component/basic_inhands/proc/on_updated_overlays(atom/parent_atom, list/overlays)
|
|
SIGNAL_HANDLER
|
|
overlays += cached_overlays
|
|
|
|
/// When your number of held items changes, regenerate held icons
|
|
/datum/component/basic_inhands/proc/on_updated_held_items(mob/living/holding_mob)
|
|
SIGNAL_HANDLER
|
|
var/list/held_overlays = list()
|
|
for(var/obj/item/held in holding_mob.held_items)
|
|
var/is_right = IS_RIGHT_INDEX(holding_mob.get_held_index_of_item(held))
|
|
var/icon_file = is_right ? held.righthand_file : held.lefthand_file
|
|
var/mutable_appearance/held_overlay = held.build_worn_icon(default_layer = HANDS_LAYER, default_icon_file = icon_file, isinhands = TRUE)
|
|
held_overlay.pixel_y += y_offset
|
|
held_overlay.pixel_x += x_offset * (is_right ? 1 : -1)
|
|
held_overlays += held_overlay
|
|
|
|
cached_overlays = held_overlays
|
|
holding_mob.update_appearance(UPDATE_OVERLAYS)
|