Skip to content

Commit

Permalink
Clockwork Slabs can now focus on a specific component to produce (#22781
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ChangelingRain authored and Razharas committed Jan 23, 2017
1 parent 8dc403d commit 709788e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 22 deletions.
20 changes: 17 additions & 3 deletions code/game/gamemodes/clock_cult/clock_items/clockwork_slab.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
var/list/stored_components = list(BELLIGERENT_EYE = 0, VANGUARD_COGWHEEL = 0, GEIS_CAPACITOR = 0, REPLICANT_ALLOY = 0, HIEROPHANT_ANSIBLE = 0)
var/busy //If the slab is currently being used by something
var/production_time = 0
var/target_component_id //the target component ID to create, if any
var/no_cost = FALSE //If the slab is admin-only and needs no components and has no scripture locks
var/speed_multiplier = 1 //multiples how fast this slab recites scripture
var/nonhuman_usable = FALSE //if the slab can be used by nonhumans, defaults to off
Expand Down Expand Up @@ -127,14 +128,16 @@
var/mob/living/L
L = get_atom_on_turf(src, /mob/living)
if(istype(L) && is_servant_of_ratvar(L) && (nonhuman_usable || ishuman(L)))
var/component_to_generate = get_weighted_component_id(src) //more likely to generate components that we have less of
var/component_to_generate = target_component_id
if(!component_to_generate)
component_to_generate = get_weighted_component_id(src) //more likely to generate components that we have less of
stored_components[component_to_generate]++
update_slab_info(src)
for(var/obj/item/clockwork/slab/S in L.GetAllContents()) //prevent slab abuse today
if(S == src)
continue
S.production_time = production_time + 50 //set it to our next production plus five seconds, so that if you hold the same slabs, the same one will always generate
L << "<span class='warning'>Your slab cl[pick("ank", "ink", "unk", "ang")]s as it produces a new component.</span>"
L << "<span class='warning'>Your slab cl[pick("ank", "ink", "unk", "ang")]s as it produces a </span><span class='[get_component_span(component_to_generate)]'>component</span><span class='warning'>.</span>"

/obj/item/clockwork/slab/examine(mob/user)
..()
Expand Down Expand Up @@ -400,6 +403,10 @@

data["selected"] = selected_scripture

data["target_comp"] = "<font color=#B18B25>NONE</font>"
if(target_component_id)
data["target_comp"] = "<font color=[get_component_color_bright(target_component_id)]>[get_component_acronym(target_component_id)]</font>"

generate_all_scripture()

data["scripture"] = list()
Expand Down Expand Up @@ -439,6 +446,13 @@
addtimer(CALLBACK(src, .proc/recite_scripture, text2path(params["category"]), usr, FALSE), 0)
if("select")
selected_scripture = params["category"]
if("component")
var/list/components = list("Random Components")
for(var/i in clockwork_component_cache)
components["[get_component_name(i)] [(clockwork_component_cache[i])]"] = i
var/input_component = input("Choose a component type.", "Target Component") as null|anything in components
if(input_component && !..())
target_component_id = components[input_component]
if("bind")
var/datum/clockwork_scripture/path = text2path(params["category"]) //we need a path and not a string
var/found_index = quickbound.Find(path)
Expand All @@ -449,7 +463,7 @@
quickbound[found_index] = null //otherwise, leave it as a null so the scripture maintains position
update_quickbind()
else
var/target_index = input("Position of [initial(path.name)], 1 to 5?", text("Input")) as num|null
var/target_index = input("Position of [initial(path.name)], 1 to 5?", "Input") as num|null
if(isnum(target_index) && target_index > 0 && target_index < 6 && !..())
var/datum/clockwork_scripture/S
if(LAZYLEN(quickbound) >= target_index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
break
if(linkedwall && wall_generation_cooldown <= world.time)
wall_generation_cooldown = world.time + (CACHE_PRODUCTION_TIME * get_efficiency_mod(TRUE))
generate_cache_component(null, src)
var/component_id = generate_cache_component(null, src)
playsound(linkedwall, 'sound/magic/clockwork/fellowship_armory.ogg', rand(15, 20), 1, -3, 1, 1)
visible_message("<span class='warning'>Something cl[pick("ank", "ink", "unk", "ang")]s around inside of [src]...</span>")
visible_message("<span class='[get_component_span(component_id)]'>Something</span><span class='warning'> cl[pick("ank", "ink", "unk", "ang")]s around inside of [src]...</span>")

/obj/structure/destructible/clockwork/cache/attackby(obj/item/I, mob/living/user, params)
if(!is_servant_of_ratvar(user))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,6 @@
if(component_to_generate)
generate_cache_component(component_to_generate, src)
production_time = world.time + (production_cooldown * get_efficiency_mod(TRUE)) //go on cooldown
visible_message("<span class='warning'>[src] hums as it produces a [get_component_name(component_to_generate)].</span>")
visible_message("<span class='warning'>[src] hums as it produces a </span><span class='[get_component_span(component_to_generate)]'>component</span><span class='warning'>.</span>")
else
forced_disable(FALSE) //we shouldn't actually ever get here, as we should cancel out way before this
32 changes: 16 additions & 16 deletions tgui/assets/tgui.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tgui/src/interfaces/clockwork_slab.ract
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<ui-display>
<ui-button action='toggle'>{{data.recollection ? "Recital":"Recollection"}}</ui-button>
<ui-button action='component'>Target Component: {{{data.target_comp}}}</ui-button>
</ui-display>
{{#if data.recollection}}
<ui-display>
Expand Down

0 comments on commit 709788e

Please sign in to comment.