Merge pull request #14103 from Arturlang/give_hotkey

[READY]Give hotkey, but citadel
This commit is contained in:
silicons
2021-01-21 01:41:29 -07:00
committed by GitHub
4 changed files with 104 additions and 2 deletions

View File

@@ -60,3 +60,14 @@
/datum/keybinding/carbon/select_harm_intent/down(client/user)
user.mob?.a_intent_change(INTENT_HARM)
return TRUE
/datum/keybinding/carbon/give
hotkey_keys = list("CtrlG")
name = "Give_Item"
full_name = "Give item"
description = "Give the item you're currently holding"
/datum/keybinding/carbon/give/down(client/user)
var/mob/living/carbon/C = user.mob
C.give()
return TRUE

View File

@@ -159,3 +159,57 @@
/mob/living/carbon/proc/get_holding_bodypart_of_item(obj/item/I)
var/index = get_held_index_of_item(I)
return index && hand_bodyparts[index]
/**
* Proc called when giving an item to another player
*
* This handles creating an alert and adding an overlay to it
*/
/mob/living/carbon/proc/give(target)
var/obj/item/receiving = get_active_held_item()
if(!receiving)
to_chat(src, "<span class='warning'>You're not holding anything to give!</span>")
return
visible_message("<span class='notice'>[src] is offering [receiving]</span>", \
"<span class='notice'>You offer [receiving]</span>", null, 2)
var/mob/living/carbon/targets = list()
if(!target)
for(var/mob/living/carbon/C in orange(1, src))
if(!CanReach(C))
return
targets += C
else
targets += target
if(!targets)
return
for(var/mob/living/carbon/C in targets)
var/obj/screen/alert/give/G = C.throw_alert("[src]", /obj/screen/alert/give)
if(!G)
return
G.setup(C, src, receiving)
/**
* Proc called when the player clicks the give alert
*
* Handles checking if the player taking the item has open slots and is in range of the giver
* Also deals with the actual transferring of the item to the players hands
* Arguments:
* * giver - The person giving the original item
* * I - The item being given by the giver
*/
/mob/living/carbon/proc/take(mob/living/carbon/giver, obj/item/I)
clear_alert("[giver]")
if(get_dist(src, giver) > 1)
to_chat(src, "<span class='warning'>[giver] is out of range! </span>")
return
if(!I || giver.get_active_held_item() != I)
to_chat(src, "<span class='warning'>[giver] is no longer holding the item they were offering! </span>")
return
if(!get_empty_held_indexes())
to_chat(src, "<span class='warning'>You have no empty hands!</span>")
return
if(!giver.temporarilyRemoveItemFromInventory(I))
visible_message("<span class='notice'>[src] tries to hand over [I] but it's stuck to them....", \
"<span class'notice'> You make a fool of yourself trying to give away an item stuck to your hands")
return
put_in_hands(I)