mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-29 07:59:01 +01:00
Fixes robot stacks transferability
Cleans up transferring between stacks and makes robot stacks transferable with regular ones.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
icon_state = "sheet-glass"
|
||||
matter = null
|
||||
created_window = /obj/structure/window/basic
|
||||
stacktype = /obj/item/stack/sheet/glass
|
||||
|
||||
/obj/item/stack/sheet/glass/attack_self(mob/user as mob)
|
||||
construct_window(user)
|
||||
|
||||
@@ -140,6 +140,7 @@ obj/item/stack/sheet/mineral/iron/New()
|
||||
name = "plastic sheets"
|
||||
icon_state = "sheet-plastic"
|
||||
perunit = 2000
|
||||
stacktype = /obj/item/stack/sheet/mineral/plastic
|
||||
|
||||
/obj/item/stack/sheet/mineral/gold
|
||||
name = "gold"
|
||||
|
||||
@@ -92,6 +92,7 @@ var/global/list/datum/stack_recipe/metal_recipes = list ( \
|
||||
icon_state = "sheet-metal"
|
||||
throwforce = 14.0
|
||||
flags = FPRINT | TABLEPASS | CONDUCT
|
||||
stacktype = /obj/item/stack/sheet/metal
|
||||
|
||||
/obj/item/stack/sheet/metal/New(var/loc, var/amount=null)
|
||||
recipes = metal_recipes
|
||||
@@ -152,6 +153,7 @@ var/global/list/datum/stack_recipe/wood_recipes = list ( \
|
||||
desc = "One can only guess that this is a bunch of wood."
|
||||
singular_name = "wood plank"
|
||||
icon_state = "sheet-wood"
|
||||
stacktype = /obj/item/stack/sheet/wood
|
||||
|
||||
/obj/item/stack/sheet/wood/New(var/loc, var/amount=null)
|
||||
recipes = wood_recipes
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
var/singular_name
|
||||
var/amount = 1
|
||||
var/max_amount //also see stack recipes initialisation, param "max_res_amount" must be equal to this max_amount
|
||||
var/stacktype //determines whether different stack types can merge
|
||||
|
||||
/obj/item/stack/New(var/loc, var/amount=null)
|
||||
..()
|
||||
if (!stacktype)
|
||||
stacktype = type
|
||||
if (amount)
|
||||
src.amount = amount
|
||||
return
|
||||
@@ -184,7 +187,7 @@
|
||||
for (var/obj/item/stack/item in usr.loc)
|
||||
if (item==oldsrc)
|
||||
continue
|
||||
if (!istype(item, oldsrc.type))
|
||||
if (item.stacktype != oldsrc.stacktype)
|
||||
continue
|
||||
if (item.amount>=item.max_amount)
|
||||
continue
|
||||
@@ -193,6 +196,23 @@
|
||||
if(!oldsrc)
|
||||
break
|
||||
|
||||
//attempts to transfer amount to S, and returns the amount actually transferred
|
||||
/obj/item/stack/proc/transfer_to(obj/item/stack/S, var/tamount=null)
|
||||
if (stacktype != S.stacktype)
|
||||
return 0
|
||||
if (isnull(tamount))
|
||||
tamount = src.amount
|
||||
|
||||
var/transfer = min(tamount, src.amount, (S.max_amount - S.amount))
|
||||
|
||||
if (transfer)
|
||||
if (prob(transfer/src.amount *100))
|
||||
S.copy_evidences(src) //have to do this before use() is called, unfortunately
|
||||
if (oldsrc.use(transfer))
|
||||
S.add(transfer)
|
||||
|
||||
return transfer
|
||||
|
||||
/obj/item/stack/attack_hand(mob/user as mob)
|
||||
if (user.get_inactive_hand() == src)
|
||||
var/obj/item/stack/F = new src.type(user, 1)
|
||||
@@ -209,28 +229,27 @@
|
||||
|
||||
/obj/item/stack/attackby(obj/item/W as obj, mob/user as mob)
|
||||
..()
|
||||
if (istype(W, src.type))
|
||||
if (istype(W, /var/obj/item/stack))
|
||||
var/obj/item/stack/S = W
|
||||
if (S.amount >= max_amount)
|
||||
return 1
|
||||
var/to_transfer as num
|
||||
if (user.get_inactive_hand()==src)
|
||||
to_transfer = 1
|
||||
|
||||
var/obj/item/stack/oldsrc = src
|
||||
src = null
|
||||
if (user.get_inactive_hand()==oldsrc)
|
||||
oldsrc.transfer_to(S, 1)
|
||||
else
|
||||
to_transfer = min(src.amount, S.max_amount-S.amount)
|
||||
S.add(to_transfer)
|
||||
oldsrc.transfer_to(S)
|
||||
|
||||
if (S && usr.machine==S)
|
||||
spawn(0) S.interact(usr)
|
||||
src.use(to_transfer)
|
||||
if (src && usr.machine==src)
|
||||
spawn(0) src.interact(usr)
|
||||
if (oldsrc && usr.machine==oldsrc)
|
||||
spawn(0) oldsrc.interact(usr)
|
||||
else return ..()
|
||||
|
||||
/obj/item/stack/proc/copy_evidences(obj/item/stack/from as obj)
|
||||
src.blood_DNA = from.blood_DNA
|
||||
src.fingerprints = from.fingerprints
|
||||
src.fingerprintshidden = from.fingerprintshidden
|
||||
src.fingerprintslast = from.fingerprintslast
|
||||
src.blood_DNA |= from.blood_DNA
|
||||
src.fingerprints |= from.fingerprints
|
||||
src.fingerprintshidden |= from.fingerprintshidden
|
||||
src.fingerprintslast = from.fingerprintslast
|
||||
//TODO bloody overlay
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user