parsing from file work, still working on mobloading.
This commit is contained in:
@@ -8,35 +8,20 @@
|
||||
#define LOADING_TO_HUMAN 1
|
||||
|
||||
/proc/handle_roundstart_items(mob/living/M)
|
||||
world << "handle_roundstart_items([M])"
|
||||
if(!istype(M) || !M.ckey || !M.mind)
|
||||
world << "handle_roundstart_items: [M] has either no ckey or no mind!"
|
||||
if(!M.mind)
|
||||
world << "[M] has no mind!"
|
||||
return FALSE
|
||||
var/list/items = parse_custom_items_by_key_and_job(M.ckey, M.mind.assigned_role)
|
||||
if(M.mind.special_role)
|
||||
var/list/items_special = parse_custom_items_by_key_and_job(M.ckey, M.mind.special_role) //And this way you can have snowflake antags!
|
||||
for(var/thing in items_special)
|
||||
if(!items[thing])
|
||||
items[thing] = items_special[thing] //don't have it, make it have it!
|
||||
else
|
||||
items[thing] += items_special[thing] //More~
|
||||
if(isnull(items))
|
||||
world << "handle_roundstart_items: itemlist null."
|
||||
return FALSE
|
||||
return load_itemlist_to_mob(M, items, TRUE, TRUE, FALSE)
|
||||
return load_itemlist_to_mob(M, parse_custom_roundstart_items(M.ckey, M.name, M.mind.assigned_role, M.mind.special_role), TRUE, TRUE, FALSE)
|
||||
|
||||
//Just incase there's extra mob selections in the future.....
|
||||
/proc/load_itemlist_to_mob(mob/living/L, list/itemlist, drop_on_floor_if_full = TRUE, load_to_all_slots = TRUE, replace_slots = FALSE)
|
||||
world << "load_itemlist_to_mob([L], [itemlist], [drop_on_floor_if_full], [load_to_all_slots], [replace_slots])"
|
||||
to_chat(world, "load_itemlist_to_mob([L], [itemlist], [drop_on_floor_if_full], [load_to_all_slots], [replace_slots])")
|
||||
if(!istype(L) || !islist(itemlist))
|
||||
return FALSE
|
||||
var/loading_mode = DROP_TO_FLOOR
|
||||
var/turf/current_turf = get_turf(L)
|
||||
if(ishuman(L))
|
||||
loading_mode = LOADING_TO_HUMAN
|
||||
world << "load_itemlist_to_mob:loading_mode [loading_mode] current_turf [current_turf]"
|
||||
to_chat(world, "load_itemlist_to_mob:loading_mode [loading_mode] current_turf [current_turf]")
|
||||
switch(loading_mode)
|
||||
if(DROP_TO_FLOOR)
|
||||
for(var/I in itemlist)
|
||||
|
||||
@@ -13,63 +13,64 @@ GLOBAL_LIST(custom_item_list)
|
||||
GLOB.custom_item_list = list()
|
||||
var/list/file_lines = world.file2list(custom_filelist)
|
||||
for(var/line in file_lines)
|
||||
try //Lazy as fuck.
|
||||
if(length(line) == 0) //Emptyline, no one cares.
|
||||
continue
|
||||
if(copytext(line,1,3) == "//") //Commented line, ignore.
|
||||
continue
|
||||
var/ckey_str_sep = findtext(line, "|") //Process our stuff..
|
||||
var/char_str_sep = findtext(line, "|", ckey_str_sep+1)
|
||||
var/job_str_sep = findtext(line, "|", char_str_sep+1)
|
||||
var/item_str_sep = findtext(line, "|", job_str_sep+1)
|
||||
var/ckey_str = ckey(copytext(line, 1, ckey_str_sep))
|
||||
var/char_str = copytext(line, ckey_str_sep+1, char_str_sep)
|
||||
var/job_str = copytext(line, char_str_sep+1, job_str_sep)
|
||||
var/item_str = copytext(line, job_str_sep+1, item_str_sep)
|
||||
if(!ckey_str || !!char_str || !job_str || !item_str || !length(ckey_str) || !length(char_str) || !length(job_str) || !length(item_str))
|
||||
throw EXCEPTION("Errored Line")
|
||||
to_chat(world, "DEBUG: Line process: [line]")
|
||||
to_chat(world, "DEBUG: [ckey_str_sep], [char_str_sep], [job_str_sep], [item_str_sep], [ckey_str], [char_str], [job_str], [item_str].")
|
||||
if(!islist(GLOB.custom_item_list[ckey_str]))
|
||||
GLOB.custom_item_list[ckey_str] = list() //Initialize list for this ckey if it isn't initialized..
|
||||
var/list/characters = splittext(char_str, "/")
|
||||
for(var/character in characters)
|
||||
if(!islist(GLOB.custom_item_list[ckey_str][character]))
|
||||
GLOB.custom_item_list[ckey_str][character] = list()
|
||||
var/list/jobs = splittext(job_str, "/")
|
||||
world << "DEBUG: Job string processed."
|
||||
world << "DEBUG: JOBS: [english_list(jobs)]"
|
||||
for(var/job in jobs)
|
||||
for(var/character in characters)
|
||||
if(!islist(GLOB.custom_item_list[ckey_str][character][job]))
|
||||
GLOB.custom_item_list[ckey_str][character][job] = list() //Initialize item list for this job of this ckey if not already initialized.
|
||||
var/list/item_strings = splittext(item_str, ";") //Get item strings in format of /path/to/item=amount
|
||||
for(var/item_string in item_strings)
|
||||
var/path_str_sep = findtext(item_string, "=")
|
||||
var/path = copytext(item_string, 1, path_str_sep) //Path to spawn
|
||||
var/amount = copytext(item_string, path_str_sep+1) //Amount to spawn
|
||||
world << "DEBUG: Item string [item_string] processed"
|
||||
amount = text2num(amount)
|
||||
path = text2path(path)
|
||||
if(!ispath(path) || !isnum(amount))
|
||||
throw EXCEPTION("Errored line")
|
||||
world << "DEBUG: [path_str_sep], [path], [amount]"
|
||||
for(var/character in characters)
|
||||
for(var/job in jobs)
|
||||
if(!GLOB.custom_item_list[ckey_str][character][job][path]) //Doesn't exist, make it exist!
|
||||
GLOB.custom_item_list[ckey_str][character][job][path] = amount
|
||||
else
|
||||
GLOB.custom_item_list[ckey_str][character][job][path] += amount //Exists, we want more~
|
||||
catch //Uh oh.
|
||||
var/msg = "Error processing line in [custom_filelist]. Line : [line]"
|
||||
message_admins(msg)
|
||||
log_game(msg)
|
||||
stack_trace(msg)
|
||||
if(length(line) == 0) //Emptyline, no one cares.
|
||||
continue
|
||||
if(copytext(line,1,3) == "//") //Commented line, ignore.
|
||||
continue
|
||||
var/ckey_str_sep = findtext(line, "|") //Process our stuff..
|
||||
var/char_str_sep = findtext(line, "|", ckey_str_sep+1)
|
||||
var/job_str_sep = findtext(line, "|", char_str_sep+1)
|
||||
var/item_str_sep = findtext(line, "|", job_str_sep+1)
|
||||
var/ckey_str = ckey(copytext(line, 1, ckey_str_sep))
|
||||
var/char_str = copytext(line, ckey_str_sep+1, char_str_sep)
|
||||
var/job_str = copytext(line, char_str_sep+1, job_str_sep)
|
||||
var/item_str = copytext(line, job_str_sep+1, item_str_sep)
|
||||
if(!ckey_str || !char_str || !job_str || !item_str || !length(ckey_str) || !length(char_str) || !length(job_str) || !length(item_str))
|
||||
log_admin("Errored custom_items_whitelist line: [line] - Component/separator missing!")
|
||||
to_chat(world, "DEBUG: Line process: [line]")
|
||||
to_chat(world, "DEBUG: [ckey_str_sep], [char_str_sep], [job_str_sep], [item_str_sep], [ckey_str], [char_str], [job_str], [item_str].")
|
||||
if(!islist(GLOB.custom_item_list[ckey_str]))
|
||||
GLOB.custom_item_list[ckey_str] = list() //Initialize list for this ckey if it isn't initialized..
|
||||
var/list/characters = splittext(char_str, "/")
|
||||
for(var/character in characters)
|
||||
if(!islist(GLOB.custom_item_list[ckey_str][character]))
|
||||
GLOB.custom_item_list[ckey_str][character] = list()
|
||||
var/list/jobs = splittext(job_str, "/")
|
||||
world << "DEBUG: Job string processed."
|
||||
world << "DEBUG: JOBS: [english_list(jobs)]"
|
||||
for(var/job in jobs)
|
||||
for(var/character in characters)
|
||||
if(!islist(GLOB.custom_item_list[ckey_str][character][job]))
|
||||
GLOB.custom_item_list[ckey_str][character][job] = list() //Initialize item list for this job of this ckey if not already initialized.
|
||||
var/list/item_strings = splittext(item_str, ";") //Get item strings in format of /path/to/item=amount
|
||||
for(var/item_string in item_strings)
|
||||
var/path_str_sep = findtext(item_string, "=")
|
||||
var/path = copytext(item_string, 1, path_str_sep) //Path to spawn
|
||||
var/amount = copytext(item_string, path_str_sep+1) //Amount to spawn
|
||||
world << "DEBUG: Item string [item_string] processed"
|
||||
amount = text2num(amount)
|
||||
path = text2path(path)
|
||||
if(!ispath(path) || !isnum(amount))
|
||||
log_admin("Errored custom_items_whitelist line: [line] - Path/number for item missing or invalid.")
|
||||
world << "DEBUG: [path_str_sep], [path], [amount]"
|
||||
for(var/character in characters)
|
||||
for(var/job in jobs)
|
||||
if(!GLOB.custom_item_list[ckey_str][character][job][path]) //Doesn't exist, make it exist!
|
||||
GLOB.custom_item_list[ckey_str][character][job][path] = amount
|
||||
else
|
||||
GLOB.custom_item_list[ckey_str][character][job][path] += amount //Exists, we want more~
|
||||
return GLOB.custom_item_list
|
||||
|
||||
/proc/parse_custom_roundstart_items(ckey, char_name = "ANY", job_name = "ANY")
|
||||
|
||||
|
||||
/proc/debug_roundstart_items()
|
||||
reload_custom_roundstart_items_list()
|
||||
/proc/parse_custom_roundstart_items(ckey, char_name = "ANY", job_name = "ANY", special_role)
|
||||
var/list/ret = list()
|
||||
if(GLOB.custom_item_list[ckey])
|
||||
for(var/char in GLOB.custom_item_list[ckey])
|
||||
if((char_name == char) || (char_name == "ANY") || (char == "ANY"))
|
||||
for(var/job in GLOB.custom_item_list[ckey][char])
|
||||
if((job_name == job) || (job == "ANY") || (job_name == "ANY") || (special_role && (job == special_role)))
|
||||
for(var/item_path in GLOB.custom_item_list[ckey][char][job])
|
||||
if(ret[item_path])
|
||||
ret[item_path] += GLOB.custom_item_list[ckey][char][job][item_path]
|
||||
else
|
||||
ret[item_path] = GLOB.custom_item_list[ckey][char][job][item_path]
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user