Merge pull request #13859 from timothyteakettle/unlockable-loadout-items
unlockable loadout items
This commit is contained in:
@@ -1024,3 +1024,25 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
|
||||
verb_tabs |= verb_to_init.category
|
||||
verblist[++verblist.len] = list(verb_to_init.category, verb_to_init.name)
|
||||
src << output("[url_encode(json_encode(verb_tabs))];[url_encode(json_encode(verblist))]", "statbrowser:init_verbs")
|
||||
|
||||
//increment progress for an unlockable loadout item
|
||||
/client/proc/increment_progress(key, amount)
|
||||
if(prefs)
|
||||
var/savefile/S = new /savefile(prefs.path)
|
||||
var/list/unlockable_loadout_data = prefs.unlockable_loadout_data
|
||||
if(!length(unlockable_loadout_data))
|
||||
unlockable_loadout_data = list()
|
||||
unlockable_loadout_data[key] = amount
|
||||
WRITE_FILE(S["unlockable_loadout"], safe_json_encode(unlockable_loadout_data))
|
||||
prefs.unlockable_loadout_data = unlockable_loadout_data
|
||||
return TRUE
|
||||
else
|
||||
if(unlockable_loadout_data[key])
|
||||
unlockable_loadout_data[key] += amount
|
||||
else
|
||||
unlockable_loadout_data[key] = amount
|
||||
WRITE_FILE(S["unlockable_loadout"], safe_json_encode(unlockable_loadout_data))
|
||||
prefs.unlockable_loadout_data = unlockable_loadout_data
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
|
||||
@@ -198,6 +198,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
var/gear_points = 10
|
||||
var/list/gear_categories
|
||||
var/list/loadout_data = list()
|
||||
var/list/unlockable_loadout_data = list()
|
||||
var/loadout_slot = 1 //goes from 1 to MAXIMUM_LOADOUT_SAVES
|
||||
var/gear_category
|
||||
var/gear_subcategory
|
||||
@@ -907,12 +908,14 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
loadout_color_non_poly = loadout_item[LOADOUT_COLOR][1]
|
||||
extra_color_data += "<BR><a href='?_src_=prefs;preference=gear;loadout_color=1;loadout_gear_name=[html_encode(gear.name)];'>Color</a>"
|
||||
extra_color_data += "<span style='border: 1px solid #161616; background-color: [loadout_color_non_poly];'> </span>"
|
||||
else if(gear_points <= 0)
|
||||
else if((gear_points - gear.cost) < 0)
|
||||
class_link = "style='white-space:normal;' class='linkOff'"
|
||||
else if(donoritem)
|
||||
class_link = "style='white-space:normal;background:#ebc42e;' href='?_src_=prefs;preference=gear;toggle_gear_path=[html_encode(name)];toggle_gear=1'"
|
||||
else
|
||||
else if(!istype(gear, /datum/gear/unlockable) || can_use_unlockable(gear))
|
||||
class_link = "style='white-space:normal;' href='?_src_=prefs;preference=gear;toggle_gear_path=[html_encode(name)];toggle_gear=1'"
|
||||
else
|
||||
class_link = "style='white-space:normal;background:#eb2e2e;' class='linkOff'"
|
||||
dat += "<tr style='vertical-align:top;'><td width=15%><a [class_link]>[name]</a>[extra_color_data]</td>"
|
||||
dat += "<td width = 5% style='vertical-align:top'>[gear.cost]</td><td>"
|
||||
if(islist(gear.restricted_roles))
|
||||
@@ -925,7 +928,16 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
dat += "<font size=2>"
|
||||
dat += gear.restricted_roles.Join(";")
|
||||
dat += "</font>"
|
||||
dat += "</td><td><font size=2><i>[gear.description]</i></font></td></tr>"
|
||||
if(!istype(gear, /datum/gear/unlockable))
|
||||
dat += "</td><td><font size=2><i>[gear.description]</i></font></td></tr>"
|
||||
else
|
||||
//we add the user's progress to the description assuming they have progress
|
||||
var/datum/gear/unlockable/unlockable = gear
|
||||
var/progress_made = unlockable_loadout_data[unlockable.progress_key]
|
||||
if(!progress_made)
|
||||
progress_made = 0
|
||||
dat += "</td><td><font size=2><i>[gear.description] Progress: [min(progress_made, unlockable.progress_required)]/[unlockable.progress_required]</i></font></td></tr>"
|
||||
|
||||
dat += "</table>"
|
||||
if(4) // Content preferences
|
||||
dat += "<table><tr><td width='340px' height='300px' valign='top'>"
|
||||
@@ -2675,6 +2687,9 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
if(G.donoritem && !G.donator_ckey_check(user.ckey))
|
||||
to_chat(user, "<span class='danger'>This is an item intended for donator use only. You are not authorized to use this item.</span>")
|
||||
return
|
||||
if(istype(G, /datum/gear/unlockable) && !can_use_unlockable(G))
|
||||
to_chat(user, "<span class='danger'>To use this item, you need to meet the defined requirements!</span>")
|
||||
return
|
||||
if(gear_points >= initial(G.cost))
|
||||
var/list/new_loadout_data = list(LOADOUT_ITEM = "[G.type]")
|
||||
if(length(G.loadout_initial_colors))
|
||||
@@ -2960,6 +2975,11 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
if(find_gear)
|
||||
loadout_data["SAVE_[save_slot]"] -= list(find_gear)
|
||||
|
||||
/datum/preferences/proc/can_use_unlockable(datum/gear/unlockable/unlockable_gear)
|
||||
if(unlockable_loadout_data[unlockable_gear.progress_key] >= unlockable_gear.progress_required)
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
#undef DEFAULT_SLOT_AMT
|
||||
#undef HANDS_SLOT_AMT
|
||||
#undef BACKPACK_SLOT_AMT
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// You do not need to raise this if you are adding new values that have sane defaults.
|
||||
// Only raise this value when changing the meaning/format/name/layout of an existing value
|
||||
// where you would want the updater procs below to run
|
||||
#define SAVEFILE_VERSION_MAX 47
|
||||
#define SAVEFILE_VERSION_MAX 48
|
||||
|
||||
/*
|
||||
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
|
||||
@@ -285,6 +285,9 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
|
||||
S["loadout"] = safe_json_encode(loadout_data)
|
||||
|
||||
if(current_version < 48) //unlockable loadout items but we need to clear bad data from a mistake
|
||||
S["unlockable_loadout"] = list()
|
||||
|
||||
/datum/preferences/proc/load_path(ckey,filename="preferences.sav")
|
||||
if(!ckey)
|
||||
return
|
||||
@@ -427,6 +430,11 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
|
||||
verify_keybindings_valid() // one of these days this will runtime and you'll be glad that i put it in a different proc so no one gets their saves wiped
|
||||
|
||||
if(S["unlockable_loadout"])
|
||||
unlockable_loadout_data = safe_json_decode(S["unlockable_loadout"])
|
||||
else
|
||||
unlockable_loadout_data = list()
|
||||
|
||||
if(needs_update >= 0) //save the updated version
|
||||
var/old_default_slot = default_slot
|
||||
var/old_max_save_slots = max_save_slots
|
||||
@@ -532,6 +540,11 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
WRITE_FILE(S["auto_ooc"], auto_ooc)
|
||||
WRITE_FILE(S["no_tetris_storage"], no_tetris_storage)
|
||||
|
||||
if(length(unlockable_loadout_data))
|
||||
WRITE_FILE(S["unlockable_loadout"], safe_json_encode(unlockable_loadout_data))
|
||||
else
|
||||
WRITE_FILE(S["unlockable_loadout"], safe_json_encode(list()))
|
||||
|
||||
return 1
|
||||
|
||||
/datum/preferences/proc/load_character(slot, bypass_cooldown = FALSE)
|
||||
@@ -736,7 +749,10 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
|
||||
belly_prefs = json_from_file["belly_prefs"]
|
||||
|
||||
//gear loadout
|
||||
loadout_data = safe_json_decode(S["loadout"])
|
||||
if(S["loadout"])
|
||||
loadout_data = safe_json_decode(S["loadout"])
|
||||
else
|
||||
loadout_data = list()
|
||||
|
||||
//try to fix any outdated data if necessary
|
||||
//preference updating will handle saving the updated data for us.
|
||||
|
||||
@@ -195,7 +195,7 @@
|
||||
/obj/machinery/microwave/AltClick(mob/user)
|
||||
. = ..()
|
||||
if(user.canUseTopic(src, !hasSiliconAccessInArea(user)))
|
||||
cook()
|
||||
cook(user)
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/microwave/ui_interact(mob/user)
|
||||
@@ -226,7 +226,7 @@
|
||||
if("eject")
|
||||
eject()
|
||||
if("use")
|
||||
cook()
|
||||
cook(user)
|
||||
if("examine")
|
||||
examine(user)
|
||||
|
||||
@@ -236,7 +236,7 @@
|
||||
AM.forceMove(drop_location())
|
||||
ingredients.Cut()
|
||||
|
||||
/obj/machinery/microwave/proc/cook()
|
||||
/obj/machinery/microwave/proc/cook(mob/user)
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
if(operating || broken > 0 || panel_open || !anchored || dirty == 100)
|
||||
@@ -257,7 +257,7 @@
|
||||
start_can_fail()
|
||||
return
|
||||
break
|
||||
start()
|
||||
start(user)
|
||||
|
||||
/obj/machinery/microwave/proc/turn_on()
|
||||
visible_message("\The [src] turns on.", "<span class='italics'>You hear a microwave humming.</span>")
|
||||
@@ -277,9 +277,9 @@
|
||||
#define MICROWAVE_MUCK 1
|
||||
#define MICROWAVE_PRE 2
|
||||
|
||||
/obj/machinery/microwave/proc/start()
|
||||
/obj/machinery/microwave/proc/start(mob/user)
|
||||
turn_on()
|
||||
loop(MICROWAVE_NORMAL, 10)
|
||||
loop(MICROWAVE_NORMAL, 10, user = user)
|
||||
|
||||
/obj/machinery/microwave/proc/start_can_fail()
|
||||
turn_on()
|
||||
@@ -292,7 +292,7 @@
|
||||
update_icon()
|
||||
loop(MICROWAVE_MUCK, 4)
|
||||
|
||||
/obj/machinery/microwave/proc/loop(type, time, wait = max(12 - 2 * productivity, 2)) // standard wait is 10
|
||||
/obj/machinery/microwave/proc/loop(type, time, wait = max(12 - 2 * productivity, 2), mob/user) // standard wait is 10
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
if(type == MICROWAVE_PRE)
|
||||
pre_fail()
|
||||
@@ -300,7 +300,7 @@
|
||||
if(!time)
|
||||
switch(type)
|
||||
if(MICROWAVE_NORMAL)
|
||||
loop_finish()
|
||||
loop_finish(user)
|
||||
if(MICROWAVE_MUCK)
|
||||
muck_finish()
|
||||
if(MICROWAVE_PRE)
|
||||
@@ -308,16 +308,21 @@
|
||||
return
|
||||
time--
|
||||
use_power(500)
|
||||
addtimer(CALLBACK(src, .proc/loop, type, time, wait), wait)
|
||||
addtimer(CALLBACK(src, .proc/loop, type, time, wait, user), wait)
|
||||
|
||||
/obj/machinery/microwave/proc/loop_finish()
|
||||
/obj/machinery/microwave/proc/loop_finish(mob/user)
|
||||
operating = FALSE
|
||||
|
||||
var/metal = 0
|
||||
var/cooked_food = 0
|
||||
for(var/obj/item/O in ingredients)
|
||||
O.microwave_act(src)
|
||||
var/cooked_result = O.microwave_act(src)
|
||||
if(!istype(cooked_result, /obj/item/reagent_containers/food/snacks/badrecipe))
|
||||
cooked_food += 1
|
||||
if(O.custom_materials?.len)
|
||||
metal += O.custom_materials[SSmaterials.GetMaterialRef(/datum/material/iron)]
|
||||
if(cooked_food && user.client)
|
||||
user.client.increment_progress("cook", cooked_food)
|
||||
|
||||
if(metal)
|
||||
spark()
|
||||
@@ -336,8 +341,8 @@
|
||||
spark()
|
||||
after_finish_loop()
|
||||
|
||||
/obj/machinery/microwave/proc/pre_success()
|
||||
loop(MICROWAVE_NORMAL, 10)
|
||||
/obj/machinery/microwave/proc/pre_success(mob/user)
|
||||
loop(MICROWAVE_NORMAL, 10, user)
|
||||
|
||||
/obj/machinery/microwave/proc/muck_finish()
|
||||
visible_message("<span class='warning'>\The [src] gets covered in muck!</span>")
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
if(points)
|
||||
if(I)
|
||||
I.mining_points += points
|
||||
if(usr.client)
|
||||
usr.client.increment_progress("miner", points)
|
||||
points = 0
|
||||
else
|
||||
to_chat(usr, "<span class='warning'>No ID detected.</span>")
|
||||
|
||||
Reference in New Issue
Block a user