Accessory overhaul

This commit is contained in:
Markolie
2015-02-08 14:29:10 +01:00
parent f13459223c
commit 8fae0f029f
38 changed files with 952 additions and 839 deletions
+14 -1
View File
@@ -480,6 +480,19 @@
if(B.contents.len < B.storage_slots && w_class <= B.max_w_class)
return 1
return 0
if(slot_tie)
if(!H.w_uniform)
if(!disable_warning)
H << "<span class='warning'>You need a jumpsuit before you can attach this [name].</span>"
return 0
var/obj/item/clothing/under/uniform = H.w_uniform
if(uniform.accessories.len && uniform.can_attach_accessory(src))
if (!disable_warning)
H << "<span class='warning'>You already have an accessory of this type attached to your [uniform].</span>"
return 0
if( !(slot_flags & SLOT_TIE) )
return 0
return 1
return 0 //Unsupported slot
//END HUMAN
@@ -551,7 +564,7 @@
if( src in usr )
attack_self(usr)
return
else if(istype(src, /obj/item/clothing/tie))
else if(istype(src, /obj/item/clothing/accessory))
if(istype(src.loc,/obj/item/clothing/under))
attack_self(usr)
+1 -1
View File
@@ -79,7 +79,7 @@
/obj/item/device/lightreplacer,
/obj/item/device/taperecorder,
/obj/item/device/hailer,
/obj/item/clothing/tie/holobadge,
/obj/item/clothing/accessory/holobadge,
/obj/structure/closet/crate/secure,
/obj/structure/closet/secure_closet,
/obj/machinery/librarycomp,
@@ -66,7 +66,7 @@
/obj/item/weapon/plastique/afterattack(atom/target as obj|turf, mob/user as mob, flag)
if (!flag)
return
if (ismob(target) || istype(target, /turf/unsimulated) || istype(target, /turf/simulated/shuttle) || istype(target, /obj/item/weapon/storage/) || istype(target, /obj/machinery/door/airlock/hatch/gamma))
if (ismob(target) || istype(target, /turf/unsimulated) || istype(target, /turf/simulated/shuttle) || istype(target, /obj/item/weapon/storage) || istype(target, /obj/item/clothing/accessory/storage) || istype(target, /obj/item/clothing/under))
return
user << "Planting explosives..."
@@ -104,7 +104,7 @@
/obj/item/device/paicard,
/obj/item/device/violin,
/obj/item/weapon/storage/belt/utility/full,
/obj/item/clothing/tie/horrible)
/obj/item/clothing/accessory/horrible)
if(!ispath(gift_type,/obj/item)) return
@@ -121,7 +121,7 @@
/obj/item/weapon/storage/firstaid/tactical/New()
..()
if (empty) return
new /obj/item/clothing/tie/stethoscope( src )
new /obj/item/clothing/accessory/stethoscope( src )
new /obj/item/weapon/surgicaldrill(src)
new /obj/item/weapon/reagent_containers/hypospray/combat(src)
new /obj/item/weapon/reagent_containers/pill/bicaridine(src)
@@ -198,7 +198,7 @@
/obj/item/weapon/storage/pill_bottle/inaprovaline
name = "Pill bottle (inaprovaline)"
desc = "Contains pills used to stabilize patients."
desc = "Contains pills used to stabilize paaccessorynts."
New()
..()
@@ -0,0 +1,85 @@
//A storage item intended to be used by other items to provide storage functionality.
//Types that use this should consider overriding emp_act() and hear_talk(), unless they shield their contents somehow.
/obj/item/weapon/storage/internal
var/obj/item/master_item
/obj/item/weapon/storage/internal/New(obj/item/MI)
master_item = MI
loc = master_item
name = master_item.name
verbs -= /obj/item/verb/verb_pickup //make sure this is never picked up.
..()
/obj/item/weapon/storage/internal/attack_hand()
return //make sure this is never picked up
/obj/item/weapon/storage/internal/mob_can_equip()
return 0 //make sure this is never picked up
//Helper procs to cleanly implement internal storages - storage items that provide inventory slots for other items.
//These procs are completely optional, it is up to the master item to decide when it's storage get's opened by calling open()
//However they are helpful for allowing the master item to pretend it is a storage item itself.
//If you are using these you will probably want to override attackby() as well.
//See /obj/item/clothing/suit/storage for an example.
//items that use internal storage have the option of calling this to emulate default storage MouseDrop behaviour.
//returns 1 if the master item's parent's MouseDrop() should be called, 0 otherwise. It's strange, but no other way of
//doing it without the ability to call another proc's parent, really.
/obj/item/weapon/storage/internal/proc/handle_mousedrop(mob/user as mob, obj/over_object as obj)
if (ishuman(user) || ismonkey(user)) //so monkeys can take off their backpacks -- Urist
if (istype(user.loc,/obj/mecha)) // stops inventory actions in a mech
return 0
if(over_object == user && Adjacent(user)) // this must come before the screen objects only block
src.open(user)
return 0
if (!( istype(over_object, /obj/screen) ))
return 1
//makes sure master_item is equipped before putting it in hand, so that we can't drag it into our hand from miles away.
//there's got to be a better way of doing this...
if (!(master_item.loc == user) || (master_item.loc && master_item.loc.loc == user))
return 0
if (!( user.restrained() ) && !( user.stat ))
switch(over_object.name)
if("r_hand")
user.u_equip(master_item)
user.put_in_r_hand(master_item)
if("l_hand")
user.u_equip(master_item)
user.put_in_l_hand(master_item)
master_item.add_fingerprint(user)
return 0
return 0
//items that use internal storage have the option of calling this to emulate default storage attack_hand behaviour.
//returns 1 if the master item's parent's attack_hand() should be called, 0 otherwise.
//It's strange, but no other way of doing it without the ability to call another proc's parent, really.
/obj/item/weapon/storage/internal/proc/handle_attack_hand(mob/user as mob)
if(ishuman(user))
var/mob/living/carbon/human/H = user
if(H.l_store == master_item && !H.get_active_hand()) //Prevents opening if it's in a pocket.
H.put_in_hands(master_item)
H.l_store = null
return 0
if(H.r_store == master_item && !H.get_active_hand())
H.put_in_hands(master_item)
H.r_store = null
return 0
src.add_fingerprint(user)
if (master_item.loc == user)
src.open(user)
return 0
for(var/mob/M in range(1, master_item.loc))
if (M.s_active == src)
src.close(M)
return 1
/obj/item/weapon/storage/internal/Adjacent(var/atom/neighbor)
return master_item.Adjacent(neighbor)
@@ -104,12 +104,12 @@
New()
..()
new /obj/item/clothing/tie/medal/gold/heroism(src)
new /obj/item/clothing/tie/medal/silver/security(src)
new /obj/item/clothing/tie/medal/silver/valor(src)
new /obj/item/clothing/tie/medal/nobel_science(src)
new /obj/item/clothing/tie/medal/bronze_heart(src)
new /obj/item/clothing/tie/medal/conduct(src)
new /obj/item/clothing/tie/medal/conduct(src)
new /obj/item/clothing/tie/medal/conduct(src)
new /obj/item/clothing/tie/medal/gold/captain(src)
new /obj/item/clothing/accessory/medal/gold/heroism(src)
new /obj/item/clothing/accessory/medal/silver/security(src)
new /obj/item/clothing/accessory/medal/silver/valor(src)
new /obj/item/clothing/accessory/medal/nobel_science(src)
new /obj/item/clothing/accessory/medal/bronze_heart(src)
new /obj/item/clothing/accessory/medal/conduct(src)
new /obj/item/clothing/accessory/medal/conduct(src)
new /obj/item/clothing/accessory/medal/conduct(src)
new /obj/item/clothing/accessory/medal/gold/captain(src)
@@ -22,6 +22,7 @@
var/allow_quick_gather //Set this variable to allow the object to have the 'toggle mode' verb, which quickly collects all items from a tile.
var/collection_mode = 1; //0 = pick one at a time, 1 = pick all on tile
var/foldable = null // BubbleWrap - if set, can be folded (when empty) into a sheet of cardboard
var/use_sound = "rustle" //sound played when used. null for no sound.
/obj/item/weapon/storage/MouseDrop(obj/over_object as obj)
if (ishuman(usr) || ismonkey(usr)) //so monkeys can take off their backpacks -- Urist
@@ -100,6 +101,15 @@
if(user.s_active == src)
user.s_active = null
return
/obj/item/weapon/storage/proc/open(mob/user as mob)
if (src.use_sound)
playsound(src.loc, src.use_sound, 50, 1, -5)
orient2hud(user)
if (user.s_active)
user.s_active.close(user)
show_to(user)
/obj/item/weapon/storage/proc/close(mob/user as mob)
@@ -450,6 +460,39 @@
del(src)
//BubbleWrap END
//Returns the storage depth of an atom. This is the number of storage items the atom is contained in before reaching toplevel (the area).
//Returns -1 if the atom was not found on container.
/atom/proc/storage_depth(atom/container)
var/depth = 0
var/atom/cur_atom = src
while (cur_atom && !(cur_atom in container.contents))
if (isarea(cur_atom))
return -1
if (istype(cur_atom.loc, /obj/item/weapon/storage))
depth++
cur_atom = cur_atom.loc
if (!cur_atom)
return -1 //inside something with a null loc.
return depth
//Like storage depth, but returns the depth to the nearest turf
//Returns -1 if no top level turf (a loc was null somewhere, or a non-turf atom's loc was an area somehow).
/atom/proc/storage_depth_turf()
var/depth = 0
var/atom/cur_atom = src
while (cur_atom && !isturf(cur_atom))
if (isarea(cur_atom))
return -1
if (istype(cur_atom.loc, /obj/item/weapon/storage))
depth++
cur_atom = cur_atom.loc
if (!cur_atom)
return -1 //inside something with a null loc.
return depth
-224
View File
@@ -1,224 +0,0 @@
/obj/item/clothing/suit/storage
var/list/can_hold = new/list() //List of objects which this item can store (if set, it can't store anything else)
var/list/cant_hold = new/list() //List of objects which this item can't store (in effect only if can_hold isn't set)
var/max_w_class = 2 //Max size of objects that this object can store (in effect only if can_hold isn't set)
var/max_combined_w_class = 4 //The sum of the w_classes of all the items in this storage item.
var/storage_slots = 2 //The number of storage slots in this container.
var/obj/screen/storage/boxes = null
var/obj/screen/close/closer = null
/obj/item/clothing/suit/storage/proc/return_inv()
var/list/L = list( )
L += src.contents
for(var/obj/item/weapon/storage/S in src)
L += S.return_inv()
for(var/obj/item/weapon/gift/G in src)
L += G.gift
if (istype(G.gift, /obj/item/weapon/storage))
L += G.gift:return_inv()
return L
/obj/item/clothing/suit/storage/proc/show_to(mob/user as mob)
user.client.screen -= src.boxes
user.client.screen -= src.closer
user.client.screen -= src.contents
user.client.screen += src.boxes
user.client.screen += src.closer
user.client.screen += src.contents
user.s_active = src
return
/obj/item/clothing/suit/storage/proc/hide_from(mob/user as mob)
if(!user.client)
return
user.client.screen -= src.boxes
user.client.screen -= src.closer
user.client.screen -= src.contents
return
/obj/item/clothing/suit/storage/proc/close(mob/user as mob)
src.hide_from(user)
user.s_active = null
return
//This proc draws out the inventory and places the items on it. tx and ty are the upper left tile and mx, my are the bottm right.
//The numbers are calculated from the bottom-left The bottom-left slot being 1,1.
/obj/item/clothing/suit/storage/proc/orient_objs(tx, ty, mx, my)
var/cx = tx
var/cy = ty
src.boxes.screen_loc = text("[tx]:,[ty] to [mx],[my]")
for(var/obj/O in src.contents)
O.screen_loc = text("[cx],[cy]")
O.layer = 20
cx++
if (cx > mx)
cx = tx
cy--
src.closer.screen_loc = text("[mx+1],[my]")
return
//This proc draws out the inventory and places the items on it. It uses the standard position.
/obj/item/clothing/suit/storage/proc/standard_orient_objs(var/rows,var/cols)
var/cx = 4
var/cy = 2+rows
src.boxes.screen_loc = text("4:16,2:16 to [4+cols]:16,[2+rows]:16")
for(var/obj/O in src.contents)
O.screen_loc = text("[cx]:16,[cy]:16")
O.layer = 20
cx++
if (cx > (4+cols))
cx = 4
cy--
src.closer.screen_loc = text("[4+cols+1]:16,2:16")
return
//This proc determins the size of the inventory to be displayed. Please touch it only if you know what you're doing.
/obj/item/clothing/suit/storage/proc/orient2hud(mob/user as mob)
//var/mob/living/carbon/human/H = user
var/row_num = 0
var/col_count = min(7,storage_slots) -1
if (contents.len > 7)
row_num = round((contents.len-1) / 7) // 7 is the maximum allowed width.
src.standard_orient_objs(row_num,col_count)
return
//This proc is called when you want to place an item into the storage item.
/obj/item/clothing/suit/storage/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W,/obj/item/weapon/evidencebag) && src.loc != user)
return
..()
if(isrobot(user))
user << "\blue You're a robot. No."
return //Robots can't interact with storage items.
if(src.loc == W)
return //Means the item is already in the storage item
if(contents.len >= storage_slots)
user << "\red \The [src] is full, make some space."
return //Storage item is full
if(can_hold.len)
var/ok = 0
for(var/A in can_hold)
if(istype(W, text2path(A) ))
ok = 1
break
if(!ok)
user << "\red \The [src] cannot hold \the [W]."
return
for(var/A in cant_hold) //Check for specific items which this container can't hold.
if(istype(W, text2path(A) ))
user << "\red \The [src] cannot hold \the [W]."
return
if (W.w_class > max_w_class)
user << "\red \The [W] is too big for \the [src]"
return
var/sum_w_class = W.w_class
for(var/obj/item/I in contents)
sum_w_class += I.w_class //Adds up the combined w_classes which will be in the storage item if the item is added to it.
if(sum_w_class > max_combined_w_class)
user << "\red \The [src] is full, make some space."
return
if(W.w_class >= src.w_class && (istype(W, /obj/item/weapon/storage)))
if(!istype(src, /obj/item/weapon/storage/backpack/holding)) //bohs should be able to hold backpacks again. The override for putting a boh in a boh is in backpack.dm.
user << "\red \The [src] cannot hold \the [W] as it's a storage item of the same size."
return //To prevent the stacking of the same sized items.
user.u_equip(W)
playsound(src.loc, "rustle", 50, 1, -5)
W.loc = src
if ((user.client && user.s_active != src))
user.client.screen -= W
src.orient2hud(user)
W.dropped(user)
add_fingerprint(user)
show_to(user)
/obj/item/weapon/storage/dropped(mob/user as mob)
return
/obj/item/clothing/suit/storage/MouseDrop(atom/over_object)
if(ishuman(usr))
var/mob/living/carbon/human/M = usr
if (!( istype(over_object, /obj/screen) ))
return ..()
playsound(src.loc, "rustle", 50, 1, -5)
if ((!( M.restrained() ) && !( M.stat ) && M.wear_suit == src))
if (over_object.name == "r_hand")
M.u_equip(src)
M.put_in_r_hand(src)
// if (!( M.r_hand ))
// M.u_equip(src)
// M.r_hand = src
else if (over_object.name == "l_hand")
M.u_equip(src)
M.put_in_l_hand(src)
// if (!( M.l_hand ))
// M.u_equip(src)
// M.l_hand = src
M.update_inv_wear_suit()
src.add_fingerprint(usr)
return
if( (over_object == usr && in_range(src, usr) || usr.contents.Find(src)) && usr.s_active)
usr.s_active.close(usr)
src.show_to(usr)
return
/obj/item/clothing/suit/storage/attack_paw(mob/user as mob)
//playsound(src.loc, "rustle", 50, 1, -5) // what
return src.attack_hand(user)
/obj/item/clothing/suit/storage/attack_hand(mob/user as mob)
playsound(src.loc, "rustle", 50, 1, -5)
src.orient2hud(user)
if (src.loc == user)
if (user.s_active)
user.s_active.close(user)
src.show_to(user)
else
..()
for(var/mob/M in range(1))
if (M.s_active == src)
src.close(M)
src.add_fingerprint(user)
return
/obj/item/clothing/suit/storage/New()
src.boxes = new /obj/screen/storage( )
src.boxes.name = "storage"
src.boxes.master = src
src.boxes.icon_state = "block"
src.boxes.screen_loc = "7,7 to 10,8"
src.boxes.layer = 19
src.closer = new /obj/screen/close( )
src.closer.master = src
src.closer.icon_state = "x"
src.closer.layer = 20
orient2hud()
return
/obj/item/clothing/suit/emp_act(severity)
if(!istype(src.loc, /mob/living))
for(var/obj/O in contents)
O.emp_act(severity)
..()
/obj/item/clothing/suit/hear_talk(mob/M, var/msg)
for (var/atom/A in src)
if(istype(A,/obj/))
var/obj/O = A
O.hear_talk(M, msg)
@@ -248,7 +248,7 @@
new /obj/item/clothing/under/rank/centcom_officer(src)
new /obj/item/clothing/suit/armor/vest/fluff/deus_blueshield(src)
new /obj/item/clothing/shoes/centcom(src)
new /obj/item/clothing/tie/blue(src)
new /obj/item/clothing/accessory/blue(src)
return
/obj/structure/closet/secure_closet/ntrep
@@ -281,7 +281,7 @@
New()
..()
new /obj/item/clothing/tie/armband/cargo(src)
new /obj/item/clothing/accessory/armband/cargo(src)
new /obj/item/device/encryptionkey/headset_cargo(src)
return
@@ -289,7 +289,7 @@
New()
..()
new /obj/item/clothing/tie/armband/engine(src)
new /obj/item/clothing/accessory/armband/engine(src)
new /obj/item/device/encryptionkey/headset_eng(src)
return
@@ -297,7 +297,7 @@
New()
..()
new /obj/item/clothing/tie/armband/science(src)
new /obj/item/clothing/accessory/armband/science(src)
new /obj/item/device/encryptionkey/headset_sci(src)
return
@@ -305,7 +305,7 @@
New()
..()
new /obj/item/clothing/tie/armband/medgreen(src)
new /obj/item/clothing/accessory/armband/medgreen(src)
new /obj/item/device/encryptionkey/headset_med(src)
return
@@ -339,7 +339,7 @@
new /obj/item/ammo_box/c38(src)
new /obj/item/weapon/gun/projectile/revolver/detective(src)
new /obj/item/taperoll/police(src)
new /obj/item/clothing/tie/holster/armpit(src)
new /obj/item/clothing/accessory/holster/armpit(src)
return
/obj/structure/closet/secure_closet/detective/update_icon()
+2 -2
View File
@@ -90,7 +90,7 @@ FLOOR SAFES
var/mob/living/carbon/human/user = usr
var/canhear = 0
if(istype(user.l_hand, /obj/item/clothing/tie/stethoscope) || istype(user.r_hand, /obj/item/clothing/tie/stethoscope))
if(istype(user.l_hand, /obj/item/clothing/accessory/stethoscope) || istype(user.r_hand, /obj/item/clothing/accessory/stethoscope))
canhear = 1
if(href_list["open"])
@@ -155,7 +155,7 @@ FLOOR SAFES
user << "<span class='notice'>[I] won't fit in [src].</span>"
return
else
if(istype(I, /obj/item/clothing/tie/stethoscope))
if(istype(I, /obj/item/clothing/accessory/stethoscope))
user << "Hold [I] in one of your hands while you manipulate the dial."
return