mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-27 17:41:50 +00:00
## About The Pull Request Given the existence of basic mobs with hand slots, it feels like throwing and giving items shouldn't be something exclusive to carbon mobs, so I've pulled things around to make this happen. The only basic mobs with hands at time of writing are gorillas and dextrous holoparasites, but the inability to throw things when you're a gorilla just doesn't seem right to me. Some more details about what I've done here: - Made the dextrous component optionally enable throwing for the mob it's added to. - Moved offer/give item functionality to /mob/living (I can't see any reason why only carbon mobs should have this option) - Moved throwing and give item hotkeys from carbon to "human" (where all the other /mob/living hotkeys go) and, as a result, removed carbon hotkeys (nothing is left in them). - Moved throwing code and item offering code to its own file because living.dm is 3000+ lines long and should probably be broken up some day (I'm not brave enough for that) - Cleaned up an unused global signal that hasn't been used since dogs got moved to basic mobs. - Other miscellaneous cleanup where I noticed it. - In terms of testing: Tested using gorillas (only checked the dextrous holoparasite to confirm the button and hotkeys worked). Things that were working: - Can throw items if the mob is set up to allow it. - Can give items as a gorilla to a human, as a human to a gorilla, and as a human to a human. - Can give a high five to a gorilla (and the gorilla can receive it). Gorillas can't give a high five back, though (they don't have the emote), this already ballooned in scope, someone else can make that happen. - There are an alarmingly high amount of niche emote-into-item-into-giving behaviours I suspect half the playerbase or more aren't even aware of (does anyone offer their hand to someone to get them up off of the ground?) and I don't know if I broke any of them with this, but the fact high fives work gives me some hope they're probably still fine. ## Why It's Good For The Game Lets gorillas and dextrous holoparasites throw things and give things, but most importantly sets up more framework for any future dextrous basic mobs to also be able to do this. There's no real reason to keep this functionality confined to carbon mobs when dextrous basic mobs are a thing. ## Changelog 🆑 add: Gorillas can now throw things and offer items to players. refactor: Moved throwing and offering item code to be based on living mobs, not just carbon mobs. /🆑 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
86 lines
3.3 KiB
Plaintext
86 lines
3.3 KiB
Plaintext
/**
|
|
* # High Fiver Element
|
|
*
|
|
* Attach to an item to make it offer a "high five" when offered to people
|
|
*/
|
|
/datum/element/high_fiver
|
|
|
|
/datum/element/high_fiver/Attach(datum/target)
|
|
. = ..()
|
|
if(!isitem(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
|
|
RegisterSignal(target, COMSIG_ITEM_OFFERING, PROC_REF(on_offer))
|
|
RegisterSignal(target, COMSIG_ITEM_OFFER_TAKEN, PROC_REF(on_offer_taken))
|
|
|
|
/datum/element/high_fiver/Detach(datum/source, ...)
|
|
. = ..()
|
|
UnregisterSignal(source, list(COMSIG_ITEM_OFFERING, COMSIG_ITEM_OFFER_TAKEN))
|
|
|
|
/// Signal proc for [COMSIG_ITEM_OFFERING] to set up the high-five on offer
|
|
/datum/element/high_fiver/proc/on_offer(obj/item/source, mob/living/offerer)
|
|
SIGNAL_HANDLER
|
|
|
|
offerer.visible_message(
|
|
span_notice("[offerer] raises [offerer.p_their()] arm, looking for a high-five!"),
|
|
span_notice("You post up, looking for a high-five!"),
|
|
vision_distance = 2,
|
|
)
|
|
offerer.apply_status_effect(/datum/status_effect/offering/no_item_received/high_five, source, /atom/movable/screen/alert/give/highfive)
|
|
|
|
return COMPONENT_OFFER_INTERRUPT
|
|
|
|
/// Signal proc for [COMSIG_ITEM_OFFER_TAKEN] to continue through with the high-five on take
|
|
/datum/element/high_fiver/proc/on_offer_taken(obj/item/source, mob/living/offerer, mob/living/taker)
|
|
SIGNAL_HANDLER
|
|
|
|
var/open_hands_taker = 0
|
|
var/slappers_giver = 0
|
|
// see how many hands the taker has open for high'ing
|
|
for(var/hand in taker.held_items)
|
|
if(isnull(hand))
|
|
open_hands_taker++
|
|
|
|
// see how many hands the offerer is using for high'ing
|
|
for(var/obj/item/slap_check in offerer.held_items)
|
|
if(slap_check.item_flags & HAND_ITEM)
|
|
slappers_giver++
|
|
|
|
var/high_ten = (slappers_giver >= 2)
|
|
var/descriptor = "high-[high_ten ? "ten" : "five"]"
|
|
|
|
if(open_hands_taker <= 0)
|
|
to_chat(taker, span_warning("You can't [descriptor] [offerer] with no open hands!"))
|
|
taker.add_mood_event(descriptor, /datum/mood_event/high_five_full_hand) // not so successful now!
|
|
return COMPONENT_OFFER_INTERRUPT
|
|
|
|
playsound(offerer, 'sound/items/weapons/slap.ogg', min(50 * slappers_giver, 300), TRUE, 1)
|
|
offerer.add_mob_memory(/datum/memory/high_five, deuteragonist = taker, high_five_type = descriptor, high_ten = high_ten)
|
|
taker.add_mob_memory(/datum/memory/high_five, deuteragonist = offerer, high_five_type = descriptor, high_ten = high_ten)
|
|
|
|
if(high_ten)
|
|
to_chat(taker, span_nicegreen("You give high-tenning [offerer] your all!"))
|
|
offerer.visible_message(
|
|
span_notice("[taker] enthusiastically high-tens [offerer]!"),
|
|
span_nicegreen("Wow! You're high-tenned [taker]!"),
|
|
span_hear("You hear a sickening sound of flesh hitting flesh!"),
|
|
ignored_mobs = taker,
|
|
)
|
|
|
|
offerer.add_mood_event(descriptor, /datum/mood_event/high_ten)
|
|
taker.add_mood_event(descriptor, /datum/mood_event/high_ten)
|
|
else
|
|
to_chat(taker, span_nicegreen("You high-five [offerer]!"))
|
|
offerer.visible_message(
|
|
span_notice("[taker] high-fives [offerer]!"),
|
|
span_nicegreen("All right! You're high-fived by [taker]!"),
|
|
span_hear("You hear a sickening sound of flesh hitting flesh!"),
|
|
ignored_mobs = taker,
|
|
)
|
|
|
|
offerer.add_mood_event(descriptor, /datum/mood_event/high_five)
|
|
taker.add_mood_event(descriptor, /datum/mood_event/high_five)
|
|
|
|
offerer.remove_status_effect(/datum/status_effect/offering/no_item_received/high_five)
|
|
return COMPONENT_OFFER_INTERRUPT
|