Files
Polaris/code/modules/mob/holder.dm
Neerti 828dacf485 Centralizes weight class definitions
A lot of new defines are now in inventory_sizes.dm, which contains;
All the size identifiers (the thing that tells the game if something is bulky, or w/e).
Storage costs for all the sizes, which are exponents of two, as previously.
A few constants for inventory size.

Also changes all storage item's capacity definitions by basing it off of how many 'normal slots' exist for it.  This allows one to change the definition for all of the defines in the file, and everything will follow along without needing to change 500 files.  In testing, I made all ITEMSIZE_COST_* defines doubled, and nothing had broke.

The benefit of doing all of this is that it makes adding new weight classes in the future much simpler, and makes knowing how much space a container has easier, as seeing ITEMSIZE_COST_NORMAL * 7 means it can hold seven normal items.
2016-09-22 00:51:51 -04:00

182 lines
4.9 KiB
Plaintext

var/list/holder_mob_icon_cache = list()
//Helper object for picking dionaea (and other creatures) up.
/obj/item/weapon/holder
name = "holder"
desc = "You shouldn't ever see this."
icon = 'icons/obj/objects.dmi'
slot_flags = SLOT_HEAD | SLOT_HOLSTER
show_messages = 1
sprite_sheets = list(
"Teshari" = 'icons/mob/species/seromi/head.dmi'
)
origin_tech = null
item_icons = list(
slot_l_hand_str = 'icons/mob/items/lefthand_holder.dmi',
slot_r_hand_str = 'icons/mob/items/righthand_holder.dmi',
)
pixel_y = 8
var/mob/living/held_mob
/obj/item/weapon/holder/New()
..()
processing_objects.Add(src)
/obj/item/weapon/holder/Destroy()
processing_objects.Remove(src)
..()
/obj/item/weapon/holder/process()
update_state()
drop_items()
/obj/item/weapon/holder/dropped()
..()
spawn(1)
update_state()
/obj/item/weapon/holder/proc/update_state()
if(istype(loc,/turf) || !(contents.len))
if(held_mob)
held_mob.forceMove(loc)
drop_items()
qdel(src)
/obj/item/weapon/holder/proc/drop_items()
for(var/atom/movable/M in contents)
if(M == held_mob)
continue
M.forceMove(get_turf(src))
/obj/item/weapon/holder/onDropInto(var/atom/movable/AM)
if(ismob(loc)) // Bypass our holding mob and drop directly to its loc
return loc.loc
return ..()
/obj/item/weapon/holder/GetID()
for(var/mob/M in contents)
var/obj/item/I = M.GetIdCard()
if(I)
return I
return null
/obj/item/weapon/holder/GetAccess()
var/obj/item/I = GetID()
return I ? I.GetAccess() : ..()
/obj/item/weapon/holder/proc/sync(var/mob/living/M)
dir = 2
overlays.Cut()
icon = M.icon
icon_state = M.icon_state
item_state = M.item_state
color = M.color
name = M.name
desc = M.desc
overlays |= M.overlays
var/mob/living/carbon/human/H = loc
if(istype(H))
if(H.l_hand == src)
H.update_inv_l_hand()
else if(H.r_hand == src)
H.update_inv_r_hand()
else
H.regenerate_icons()
//Mob specific holders.
/obj/item/weapon/holder/diona
origin_tech = list(TECH_MAGNET = 3, TECH_BIO = 5)
slot_flags = SLOT_HEAD | SLOT_OCLOTHING | SLOT_HOLSTER
/obj/item/weapon/holder/drone
origin_tech = list(TECH_MAGNET = 3, TECH_ENGINEERING = 5)
/obj/item/weapon/holder/mouse
w_class = ITEMSIZE_TINY
/obj/item/weapon/holder/borer
origin_tech = list(TECH_BIO = 6)
/obj/item/weapon/holder/attackby(obj/item/weapon/W as obj, mob/user as mob)
for(var/mob/M in src.contents)
M.attackby(W,user)
//Mob procs and vars for scooping up
/mob/living/var/holder_type
/mob/living/MouseDrop(var/atom/over_object)
var/mob/living/carbon/human/H = over_object
if(holder_type && istype(H) && !H.lying && Adjacent(H) && (src.a_intent == I_HELP && H.a_intent == I_HELP))
if(!issmall(H) || !istype(src, /mob/living/carbon/human))
get_scooped(H, (usr == src))
return
return ..()
/mob/living/proc/get_scooped(var/mob/living/carbon/grabber, var/self_grab)
if(!holder_type || buckled || pinned.len)
return
if(self_grab)
if(src.incapacitated()) return
else
if(grabber.incapacitated()) return
var/obj/item/weapon/holder/H = new holder_type(get_turf(src))
H.held_mob = src
src.forceMove(H)
grabber.put_in_hands(H)
if(self_grab)
grabber << "<span class='notice'>\The [src] clambers onto you!</span>"
src << "<span class='notice'>You climb up onto \the [grabber]!</span>"
grabber.equip_to_slot_if_possible(H, slot_back, 0, 1)
else
grabber << "<span class='notice'>You scoop up \the [src]!</span>"
src << "<span class='notice'>\The [grabber] scoops you up!</span>"
grabber.status_flags |= PASSEMOTES
H.sync(src)
return H
/obj/item/weapon/holder/human
icon = 'icons/mob/holder_complex.dmi'
var/list/generate_for_slots = list(slot_l_hand_str, slot_r_hand_str, slot_back_str)
slot_flags = SLOT_BACK
/obj/item/weapon/holder/human/sync(var/mob/living/M)
// Generate appropriate on-mob icons.
var/mob/living/carbon/human/owner = M
if(istype(owner) && owner.species)
var/skin_colour = rgb(owner.r_skin, owner.g_skin, owner.b_skin)
var/hair_colour = rgb(owner.r_hair, owner.g_hair, owner.b_hair)
var/eye_colour = rgb(owner.r_eyes, owner.g_eyes, owner.b_eyes)
var/species_name = lowertext(owner.species.get_bodytype(owner))
for(var/cache_entry in generate_for_slots)
var/cache_key = "[owner.species]-[cache_entry]-[skin_colour]-[hair_colour]"
if(!holder_mob_icon_cache[cache_key])
// Generate individual icons.
var/icon/mob_icon = icon(icon, "[species_name]_holder_[cache_entry]_base")
mob_icon.Blend(skin_colour, ICON_ADD)
var/icon/hair_icon = icon(icon, "[species_name]_holder_[cache_entry]_hair")
hair_icon.Blend(hair_colour, ICON_ADD)
var/icon/eyes_icon = icon(icon, "[species_name]_holder_[cache_entry]_eyes")
eyes_icon.Blend(eye_colour, ICON_ADD)
// Blend them together.
mob_icon.Blend(eyes_icon, ICON_OVERLAY)
mob_icon.Blend(hair_icon, ICON_OVERLAY)
// Add to the cache.
holder_mob_icon_cache[cache_key] = mob_icon
item_icons[cache_entry] = holder_mob_icon_cache[cache_key]
// Handle the rest of sync().
..(M)