Get rid of a shitload of fluff, rework fluff system to work over MySQL, toss in an example of how it should work.

This commit is contained in:
Rob Nelson
2013-08-31 11:23:21 -07:00
parent 3a5d12fef5
commit 2b334d2b8f
6 changed files with 174 additions and 20 deletions

View File

@@ -0,0 +1,27 @@
/**
* N3X15's Testing Shit
*
* Used to test this on /fail/station. Not used, so left out. A decent example though.
*/
/obj/item/clothing/suit/storage/labcoat/custom/N3X15
icon = 'icons/mob/custom/N3X15/suits.dmi'
custom = 1
/obj/item/clothing/suit/storage/labcoat/custom/N3X15/robotics
name = "Robotics Research Labcoat"
desc = "A suit that protects against nothing, but looks fashionable. Well, apart from the crappy portrait drawn on the back with permanent marker."
base_icon_state = "labcoat_tox"
/obj/item/clothing/under/custom/N3X15
icon = 'icons/mob/custom/N3X15/suits.dmi' // Cheating.
custom = 1
/obj/item/clothing/under/custom/N3X15/robotics
desc = "It's slimming black with reinforced seams; great for industrial work."
name = "roboticist's jumpsuit"
icon_state = "robotics"
item_state = "robotics"
color = "robotics"

View File

@@ -0,0 +1,23 @@
////////////////////////////////////////////////////////////////////////////////
// ALL CUSTOM ITEMS MUST USE THEIR OWN DMI SO IT DOESN'T FUCK UP THE TREE.
//
// FOR FUCK'S SAKE, DO NOT ADD IN YOUR TERRIBLE FUCKING CUSTOM ITEMS TO BASE DMIS.
//
// GOOD IDEA:
//
// icons/
// mob/
// custom/
// N3X15.dmi
//
//
// FUCKING NO:
//
// icons/
// mob/
// head.dmi
//
// *** IF I SEE THIS SORT OF SHIT IN THE TREE I WILL NOT ACCEPT YOUR PULL. ***
////////////////////////////////////////////////////////////////////////////////
/obj/item/var/custom=0 // Set to override DMI locations in creature overlays, etc.

View File

@@ -1,9 +1,126 @@
/proc/EquipCustomItems(mob/living/carbon/human/M)
testing("\[CustomItem\] Checking for custom items for [M.ckey] ([M.real_name])...")
if(!establish_db_connection())
return
// SCHEMA
/**
* CustomUserItems
*
* cuiCKey VARCHAR(36) NOT NULL,
* cuiRealName VARCHAR(60) NOT NULL,
* cuiPath VARCHAR(255) NOT NULL,
* cuiDescription TEXT NOT NULL,
* cuiReason TEXT NOT NULL,
* cuiPropAdjust TEXT NOT NULL,
* cuiJobMask TEXT NOT NULL,
* PRIMARY KEY(cuiCkey,cuiRealName,cuiPath)
*/
// Grab the info we want.
var/DBQuery/query = dbcon.NewQuery("SELECT cuiPath, cuiPropAdjust, cuiJobMask FROM CustomUserItems WHERE cuiCKey='[M.ckey]' AND (cuiRealName='[M.real_name]' OR cuiRealName='*')")
query.Execute()
while(query.NextRow())
var/path = text2path(query.item[1])
var/propadjust = query.item[2]
var/jobmask = query.item[3]
testing("\[CustomItem\] Setting up [path] for [M.ckey] ([M.real_name]). jobmask=[jobmask];propadjust=[propadjust]")
var/ok=0
if(jobmask!="*")
var/allowed_jobs = text2list(jobmask,",")
var/alt_blocked=0
if(M.mind.role_alt_title)
if(!(M.mind.role_alt_title in allowed_jobs))
alt_blocked=1
if(!(M.mind.assigned_role in allowed_jobs) || alt_blocked)
testing("Failed to apply custom item for [M.ckey]: Role(s) [M.mind.assigned_role][M.mind.role_alt_title ? " (nor "+M.mind.role_alt_title+")" : ""] are not in allowed_jobs ([english_list(allowed_jobs)])")
continue
var/obj/item/Item = new path()
testing("Adding new custom item [query.item[1]] to [key_name_admin(M)]...")
if(istype(Item,/obj/item/weapon/card/id))
var/obj/item/weapon/card/id/I = Item
for(var/obj/item/weapon/card/id/C in M)
//default settings
I.name = "[M.real_name]'s ID Card ([M.mind.role_alt_title ? M.mind.role_alt_title : M.mind.assigned_role])"
I.registered_name = M.real_name
I.access = C.access
I.assignment = C.assignment
I.blood_type = C.blood_type
I.dna_hash = C.dna_hash
I.fingerprint_hash = C.fingerprint_hash
//I.pin = C.pin
//replace old ID
del(C)
ok = M.equip_if_possible(I, slot_wear_id, 0) //if 1, last argument deletes on fail
break
testing("Replaced ID!")
else if(istype(M.back,/obj/item/weapon/storage) && M.back:contents.len < M.back:storage_slots) // Try to place it in something on the mob's back
Item.loc = M.back
ok = 1
testing("Added to [M.back.name]!")
M << "\blue Your [Item.name] has been added to your [M.back.name]."
else
for(var/obj/item/weapon/storage/S in M.contents) // Try to place it in any item that can store stuff, on the mob.
if (S.contents.len < S.storage_slots)
Item.loc = S
ok = 1
testing("Added to [S]!")
M << "\blue Your [Item.name] has been added to your [S.name]."
break
//skip:
if (ok == 0) // Finally, since everything else failed, place it on the ground
testing("Plopped onto the ground!")
Item.loc = get_turf(M.loc)
HackProperties(Item,propadjust)
// This is hacky, but since it's difficult as fuck to make a proper parser in BYOND without killing the server, here it is. - N3X
/proc/HackProperties(var/mob/living/carbon/human/M,var/obj/item/I,var/script)
/*
A=string:b lol {REALNAME} {ROLE} {ROLE_ALT};
B=icon:icons/dmi/lol.dmi:STATE;
B=number:29;
*/
var/list/statements=text2list(script,";")
if(statements.len==0)
return // Don't even bother.
for(var/statement in statements)
var/list/assignmentChunks = text2list(statement,"=")
var/varname = assignmentChunks[1]
//var/operator = "="
var/list/typeChunks=text2list(script,":")
var/desiredType=typeChunks[1]
//var/value
switch(desiredType)
if("string")
var/output = typeChunks[2]
output = replacetext(output,"{REALNAME}", M.real_name)
output = replacetext(output,"{ROLE}", M.mind.assigned_role)
output = replacetext(output,"{ROLE_ALT}", "[M.mind.role_alt_title ? M.mind.role_alt_title : M.mind.assigned_role]")
I.vars[varname]=output
if("number")
I.vars[varname]=text2num(typeChunks[2])
if("icon")
if(typeChunks.len==2)
I.vars[varname]=new /icon(typeChunks[2])
if(typeChunks.len==3)
I.vars[varname]=new /icon(typeChunks[2],typeChunks[3])
//switch this out to use a database at some point
//list of ckey/ real_name and item paths
//gives item to specific people when they join if it can
//for multiple items just add mutliple entries, unless i change it to be a listlistlist
//yes, it has to be an item, you can't pick up nonitems
/* Old as fuck, not SQL-based, hardcoded keys.
/proc/EquipCustomItems(mob/living/carbon/human/M)
// load lines
var/file = file2text("config/custom_items.txt")
@@ -70,4 +187,5 @@
skip:
if (ok == 0) // Finally, since everything else failed, place it on the ground
Item.loc = get_turf(M.loc)
Item.loc = get_turf(M.loc)
*/