Merge pull request #11998 from Ghommie/Ghommie-cit706

Still unimplemented security level firing pins.
This commit is contained in:
kevinz000
2020-04-25 16:53:39 -07:00
committed by GitHub
2 changed files with 84 additions and 0 deletions
+84
View File
@@ -241,3 +241,87 @@
to_chat(user, "<span class='warning'>The pin beeps, refusing to fire.</span>")
return FALSE
return TRUE
/obj/item/firing_pin/security_level
name = "security level firing pin"
desc = "A sophisticated firing pin that authorizes operation based on its settings and current security level."
icon_state = "firing_pin_sec_level"
var/min_sec_level = SEC_LEVEL_GREEN
var/max_sec_level = SEC_LEVEL_DELTA
var/only_lethals = FALSE
var/can_toggle = TRUE
/obj/item/firing_pin/security_level/Initialize()
. = ..()
fail_message = "<span class='warning'>INVALID SECURITY LEVEL. CURRENT: [uppertext(num2seclevel(GLOB.security_level))]. \
MIN: [uppertext(num2seclevel(min_sec_level))]. MAX: [uppertext(num2seclevel(max_sec_level))]. \
ONLY LETHALS: [only_lethals ? "YES" : "NO"].</span>"
update_icon()
/obj/item/firing_pin/security_level/examine(mob/user)
. = ..()
var/lethal = only_lethals ? "only lethal " : ""
if(min_sec_level != max_sec_level)
. += "<span class='notice'>It's currently set to disallow [lethal]operation when the security level isn't between <b>[num2seclevel(min_sec_level)]</b> and <b>[num2seclevel(max_sec_level)]</b>.</span>"
else
. += "<span class='notice'>It's currently set to disallow [lethal]operation when the security level isn't <b>[num2seclevel(min_sec_level)]</b>.</span>"
if(can_toggle)
. += "<span class='notice'>You can use a <b>multitool</b> to modify its settings.</span>"
/obj/item/firing_pin/security_level/multitool_act(mob/living/user, obj/item/I)
. = TRUE
if(!can_toggle || !user.canUseTopic(src, BE_CLOSE))
return
var/selection = alert(user, "Which setting would you want to modify?", "Firing Pin Settings", "Minimum Level Setting", "Maximum Level Setting", "Lethals Only Toggle")
if(QDELETED(src) || QDELETED(user) || !user.canUseTopic(src, BE_CLOSE))
return
var/static/list/till_designs_pr_isnt_merged = list("green", "blue", "amber", "red", "delta")
switch(selection)
if("Minimum Level Setting")
var/input = input(user, "Input the new minimum level setting.", "Firing Pin Settings", num2seclevel(min_sec_level)) as null|anything in till_designs_pr_isnt_merged
if(!input)
return
min_sec_level = till_designs_pr_isnt_merged.Find(input) - 1
if(min_sec_level > max_sec_level)
max_sec_level = SEC_LEVEL_DELTA
if("Maximum Level Setting")
var/input = input(user, "Input the new maximum level setting.", "Firing Pin Settings", num2seclevel(max_sec_level)) as null|anything in till_designs_pr_isnt_merged
if(!input)
return
max_sec_level = till_designs_pr_isnt_merged.Find(input) - 1
if(max_sec_level < max_sec_level)
min_sec_level = SEC_LEVEL_GREEN
if("Lethals Only Toggle")
only_lethals = !only_lethals
fail_message = "<span class='warning'>INVALID SECURITY LEVEL. CURRENT: [uppertext(num2seclevel(GLOB.security_level))]. \
MIN: [uppertext(num2seclevel(min_sec_level))]. MAX: [uppertext(num2seclevel(max_sec_level))]. \
ONLY LETHALS: [only_lethals ? "YES" : "NO"].</span>"
update_icon()
/obj/item/firing_pin/security_level/update_overlays()
. = ..()
var/offset = 0
for(var/level in list(min_sec_level, max_sec_level))
var/mutable_appearance/overlay = mutable_appearance(icon, "pin_sec_level_overlay")
overlay.pixel_x += offset
offset += 4
switch(level)
if(SEC_LEVEL_GREEN)
overlay.color = "#b2ff59" //light green
if(SEC_LEVEL_BLUE)
overlay.color = "#99ccff" //light blue
if(SEC_LEVEL_AMBER)
overlay.color = "#ffae42" //light yellow/orange
if(SEC_LEVEL_RED)
overlay.color = "#ff3f34" //light red
else
overlay.color = "#fe59c2" //neon fuchsia
. += overlay
var/mutable_appearance/overlay = mutable_appearance(icon, "pin_sec_level_overlay")
overlay.pixel_x += offset
overlay.color = only_lethals ? "#b2ff59" : "#ff3f34"
. += overlay
/obj/item/firing_pin/security_level/pin_auth(mob/living/user)
return (only_lethals && !(gun.chambered?.harmful)) || ISINRANGE(GLOB.security_level, min_sec_level, max_sec_level)