Code: Entire object.dm code for debug purposes.
obj/iconholders
weapons
layer = FLOAT_LAYER-1
shirts
layer = FLOAT_LAYER-10
testshirt
icon = 'CShirt_Lightning.dmi'
headgear
layer = FLOAT_LAYER-10
pants
overalls
layer = FLOAT_LAYER-2
suit
icon = 'SuitBlack.dmi'
suit2
icon = 'CShirt_Lightning.dmi'
mob/proc/UpdateInventory()
var/items = 0
for(var/obj/items/O in src)
if(equipment && O.islot && equipment[O.islot]==O)
continue // don't show equipped items
winset(src, "inventory", "current-cell=[++items]")
src << output(O, "inventory")
winset(src, "inventory", "cells=[items]") // cut off any remaining cells
mob/proc/EquipGridder(var/type, var/grid)
var/list/Empty = list("overalls" = "D","shirt" = "Z") //this list is meant to output another object if the equip type is null as noted below.
if(isnull(equipment["[type]"]))
src << output(Empty["[type]"], "[grid]")
else
src << output(equipment["[type]"], "[grid]")
mob/proc/UpdateEquipment()
for(var/islot in equipment)
src.EquipGridder("overalls", "grid2")
src.EquipGridder("shirt", "grid1")
mob
proc/Equip(obj/items/O)
if(!O || !O.islot) return
if(equipment && equipment[O.islot])
Unequip(equipment[O.islot])
if(equipment && equipment[O.islot]) return // unequip failed
if(!equipment) equipment = new
equipment[O.islot] = O
src.overalls = O.refe //DBG -- want to get rid of this. and replace it with something like src.(type) = O.refe but i always get a bad index error.
// switch(O.islot) // the below commented out code works but i would like to avoid a large switch statement if possible.
// if("shirt")
// src.shirt = O.refe
// if("overalls")
// src.overalls = O.refe
src << "You equip [O]."
oview(src) << "[src] equips \a [O]."
Overlay_Build()
UpdateInventory()
UpdateEquipment()
proc/Unequip(obj/items/O)
if(!O || !O.islot) return
if(!equipment || equipment[O.islot]!=O) return // failed
equipment -= O.islot
if(!equipment.len) equipment = null // reclaim the list
src.overalls = 0 //DBG -- want to get rid of this
src << "You unequip [O]."
oview() << "[src] unequips \a [O]."
UpdateInventory()
UpdateEquipment()
Overlay_Build()
obj/items
var/islot // equipment islot
var/refe
verb/Get()
set src in oview(1)
if(src in oview(1)) // sanity check; the verb could come in late
loc = usr
usr << "You pick up [src]."
oview() << "[usr] picks up \a [src]."
usr.UpdateInventory()
verb/Drop()
set src in usr
if(src in usr) // sanity check; the verb could come in late
if(IsEquipped())
usr.Unequip(src)
if(IsEquipped()) return // unequip failed
loc = usr.loc
usr << "You drop [src]."
oview() << "[usr] drops \a [src]."
usr.UpdateInventory()
proc/IsEquipped()
if(islot)
var/mob/M = loc
if(ismob(M) && M.equipment && M.equipment[islot]==src)
return 1
return 0
verb/Equip()
if(islot) usr.Equip(src)
verb/Unequip()
if(islot) usr.Unequip(src)
clothing //Define Clothes
pants
shirts
testshirt
icon = 'CShirt_Lightning.dmi'
icon_state = "invent"
islot = "shirt"
refe = /obj/iconholders/shirts/testshirt
overalls
Suit
icon = 'SuitBlack.dmi'
icon_state = "invent"
islot = "overalls"
refe = /obj/iconholders/overalls/suit
Blug
icon = 'CShirt_Lightning.dmi'
icon_state = "invent"
islot = "shirt"
refe = /obj/iconholders/overalls/suit2
Problem description: I think i commented the right parts of the code for you guys.
So my question is how would i make mob variable change easily without a large switch statement thing (noted by the comment above in the equip proc) and my next question would be is there any other modifications that could be made to make this better?