The rest of the offering stuff

This commit is contained in:
keronshb
2021-10-13 22:13:33 -04:00
parent e07d39bb8b
commit 6331ced3e5
11 changed files with 190 additions and 79 deletions
+32 -31
View File
@@ -161,57 +161,58 @@
return index && hand_bodyparts[index]
/**
* Proc called when giving an item to another player
* Proc called when offering 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)
var/obj/item/offered_item = get_active_held_item()
if(!offered_item)
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)
if(IS_DEAD_OR_INCAP(src))
to_chat(src, span_warning("You're unable to offer anything in your current state!"))
return
for(var/mob/living/carbon/C in targets)
var/atom/movable/screen/alert/give/G = C.throw_alert("[src]", /atom/movable/screen/alert/give)
if(!G)
return
G.setup(C, src, receiving)
if(has_status_effect(STATUS_EFFECT_OFFERING))
to_chat(src, span_warning("You're already offering up something!"))
return
if(offered_item.on_offered(src)) // see if the item interrupts with its own behavior
return
visible_message(span_notice("[src] is offering [offered_item]."), \
span_notice("You offer [offered_item]."), null, 2)
apply_status_effect(STATUS_EFFECT_OFFERING, offered_item)
/**
* 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
* Handles checking if the player taking the item has open slots and is in range of the offerer
* 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
* * offerer - The person giving the original item
* * I - The item being given by the offerer
*/
/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>")
/mob/living/carbon/proc/take(mob/living/carbon/offerer, obj/item/I)
clear_alert("[offerer]")
if(get_dist(src, offerer) > 1)
to_chat(src, span_warning("[offerer] is out of range!"))
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>")
if(!I || offerer.get_active_held_item() != I)
to_chat(src, span_warning("[offerer] is no longer holding the item they were offering!"))
return
if(!get_empty_held_indexes())
to_chat(src, "<span class='warning'>You have no empty hands!</span>")
return
if(I.on_offer_taken(giver, src)) // see if the item has special behavior for being accepted
if(I.on_offer_taken(offerer, src)) // see if the item has special behavior for being accepted
return
if(!giver.temporarilyRemoveItemFromInventory(I))
visible_message("<span class='notice'>[src] tries to hand over [I] but it's stuck to them....", \
if(!offerer.temporarilyRemoveItemFromInventory(I))
visible_message("<span class='notice'>[offerer] 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
visible_message(span_notice("[src] takes [I] from [offerer]"), \
span_notice("You take [I] from [offerer]"))
put_in_hands(I)