Added a button admins can press to motivate mechanics to perform their duties (#27361)

* mechanic motivation collar

* now works as internals

* add logging

* add zlevel check, require 80% charge
This commit is contained in:
DamianX
2020-08-05 15:33:58 +02:00
committed by GitHub
parent fd320bc634
commit 036a826299
9 changed files with 162 additions and 2 deletions

View File

@@ -502,3 +502,6 @@ var/global/list/ties = list(/obj/item/clothing/accessory/tie/blue,/obj/item/clot
//Observers
var/global_poltergeist_cooldown = 300 //30s by default, badmins can var-edit this to reduce the poltergeist cooldown globally
var/list/all_machines = list()
var/list/machinery_rating_cache = list() // list of type path -> number

View File

@@ -44,6 +44,17 @@ var/datum/subsystem/more_init/SSmore_init
S.init_cams()
init_wizard_apprentice_setups()
machinery_rating_cache = cache_machinery_components_rating()
/proc/cache_machinery_components_rating()
var/list/cache = list()
for(var/obj/machinery/machine in all_machines)
if(!cache[machine.type])
var/rating = 0
for(var/obj/item/weapon/stock_parts/SP in machine.component_parts)
rating += SP.rating
cache[machine.type] = rating
return cache
/proc/init_wizard_apprentice_setups()
for (var/setup_type in subtypesof(/datum/wizard_apprentice_setup))

View File

@@ -166,6 +166,7 @@ Class Procs:
..()
/obj/machinery/New()
all_machines += src // Machines are only removed from this upon destruction
machines += src
//if(ticker) initialize()
return ..()
@@ -181,7 +182,7 @@ Class Procs:
to_chat(user, "<span class='info'>Its maintenance panel is open.</span>")
/obj/machinery/Destroy()
all_machines -= src
machines.Remove(src)
power_machines.Remove(src)

View File

@@ -897,6 +897,7 @@ var/global/floorIsLava = 0
<A href='?src=\ref[src];secretsfun=bomberdestroy'>Make Bomberman Bombs actually destroy structures</A><BR>
<A href='?src=\ref[src];secretsfun=bombernohurt'>Make Bomberman Bombs harmless to players (default)</A><BR>
<A href='?src=\ref[src];secretsfun=bombernodestroy'>Make Bomberman Bombs harmless to the environment (default)</A><BR>
<A href='?src=\ref[src];secretsfun=mechanics_motivator'>Incentivize Mechanics to do their job</A><BR>
<B>Final Solutions</B><BR>
<I>(Warning, these will end the round!)</I><BR>
<BR>

View File

@@ -4010,6 +4010,24 @@
B.destroy_environnement = 0
message_admins("[key_name_admin(usr)] disabled the environnement damage of the Bomberman Bomb Dispensers currently in the world.")
log_admin("[key_name_admin(usr)] disabled the environnement damage of the Bomberman Bomb Dispensers currently in the world.")
if("mechanics_motivator")
if(!world.has_round_started())
to_chat(usr, "The round has not started yet,")
return
var/equipped_count = 0
for(var/mob/living/dude in player_list)
if(dude.mind?.assigned_role != "Mechanic")
continue
var/obj/item/current_mask = dude.get_item_by_slot(slot_wear_mask)
if(current_mask)
if(istype(current_mask, /obj/item/clothing/mask/explosive_collar/mechanic))
continue
dude.drop_item(current_mask, dude.loc, TRUE)
var/obj/item/clothing/mask/explosive_collar/mechanic/cool_necklace = new
dude.equip_to_slot(cool_necklace, slot_wear_mask)
equipped_count++
to_chat(usr, "<span class='notice'>Equipped [equipped_count] mechanics with cool necklaces.</span>")
log_admin("[key_name(usr)] equipped [equipped_count] Mechanics with cool necklaces.")
if("togglebombmethod")
feedback_inc("admin_secrets_fun_used",1)
feedback_add_details("admin_secrets_fun_used","BM")

View File

@@ -2,6 +2,132 @@
body_parts_covered = 0
ignore_flip = TRUE
/obj/item/clothing/mask/explosive_collar
name = "explosive collar"
icon = 'icons/obj/clothing/explosive_collar.dmi'
icon_override ='icons/mob/explosive_collar.dmi'
icon_state = "bombcollaroff"
desc = "It doesn't let go."
ignore_flip = TRUE
canremove = FALSE
clothing_flags = MASKINTERNALS
var/primed = FALSE
var/scheduled_explosion_time
var/condition_for_release_text = ""
/obj/item/clothing/mask/explosive_collar/examine(mob/user)
if(primed)
to_chat(user, "<span class='notice'>Its screen reads <span class='binaryradio'>[worldtime2text(scheduled_explosion_time)]</span>.</span>")
else
to_chat(user, "<span class='notice'>Its screen is turned off.</span>")
/obj/item/clothing/mask/explosive_collar/update_icon()
icon_state = primed ? "bombcollaron" : "bombcollaroff"
/obj/item/clothing/mask/explosive_collar/acidable()
return FALSE
/obj/item/clothing/mask/explosive_collar/proc/explode()
var/mob/living/carbon/victim = loc
if(istype(victim) && victim.is_wearing_item(src, slot_wear_mask))
var/datum/organ/external/head/head_organ = victim.get_organ(LIMB_HEAD)
if(head_organ)
head_organ.explode()
explosion(src, -1, -1, 0, 1)
say("Conditions were not met.")
visible_message("<span class='danger'>\The [src] explodes!</span>")
qdel(src)
/obj/item/clothing/mask/explosive_collar/proc/deactivate()
canremove = TRUE
primed = FALSE
processing_objects -= src
update_icon()
say("Conditions were met.")
var/mob/living/carbon/victim = loc
if(istype(victim) && victim.is_wearing_item(src, slot_wear_mask))
victim.drop_item(src)
/obj/item/clothing/mask/explosive_collar/proc/activate()
if(primed)
return
canremove = FALSE
primed = TRUE
processing_objects += src
if(condition_for_release_text)
say("Condition for release: [condition_for_release_text].")
update_icon()
/obj/item/clothing/mask/explosive_collar/process()
if(world.time >= scheduled_explosion_time)
switch(condition_is_fullfilled())
if(null) // Not implemented, just do nothing
return PROCESS_KILL
if(TRUE)
deactivate()
if(FALSE)
explode()
/obj/item/clothing/mask/explosive_collar/proc/condition_is_fullfilled()
return null // Implement this for subtypes
/obj/item/clothing/mask/explosive_collar/equipped(mob/user, slot, hand_index = 0)
if(primed || slot != slot_wear_mask)
return
activate()
/obj/item/clothing/mask/explosive_collar/mechanic
var/time_until_explosion = 30 MINUTES
condition_for_release_text = "Most APCs must be charged or charging, and/or 20 machines must be upgraded within the time limit"
/obj/item/clothing/mask/explosive_collar/mechanic/examine(mob/user)
..()
if(condition_for_release_text)
to_chat(user, "<span class='bold'>Condition for release: [condition_for_release_text].</span>")
/obj/item/clothing/mask/explosive_collar/mechanic/activate()
scheduled_explosion_time = time_until_explosion + world.time
..()
/obj/item/clothing/mask/explosive_collar/mechanic/deactivate()
..()
slot_flags = NONE // Prevent second-hand griff
/proc/is_power_good_enough()
var/const/good_apcs_percentage_required = 51
var/total_apcs = 0
var/good_apcs = 0
for(var/obj/machinery/power/apc/some_apc in power_machines)
if(!some_apc.z != map.zMainStation)
continue
total_apcs++
var/obj/item/weapon/cell/battery = some_apc.get_cell()
var/const/minimum_power_cell_charge_percent = 80
if(battery?.percent() > minimum_power_cell_charge_percent || some_apc.charging)
good_apcs++
return (100*good_apcs/total_apcs) >= good_apcs_percentage_required
/proc/how_many_machines_are_upgraded()
var/machines_upgraded = 0
for(var/obj/machinery/machine in all_machines)
var/cached_rating = machinery_rating_cache[machine.type]
if(isnull(cached_rating))
continue
var/rating = 0
for(var/obj/item/weapon/stock_parts/SP in machine.component_parts)
rating += SP.rating
if(rating > cached_rating)
machines_upgraded++
return machines_upgraded
/obj/item/clothing/mask/explosive_collar/mechanic/condition_is_fullfilled()
var/power_is_good_enough = is_power_good_enough()
var/const/minimum_machines_to_upgrade = 20
var/enough_machines_were_upgraded = how_many_machines_are_upgraded() >= minimum_machines_to_upgrade
return power_is_good_enough || enough_machines_were_upgraded
/obj/item/clothing/mask/necklace/xeno_claw
name = "xeno necklace"
desc = "A necklace made out of some cable coils and a xenomorph's claws."

View File

@@ -495,8 +495,8 @@
update_hidden_item_icons(W)
W.hud_layerise()
W.equipped(src, slot)
W.forceMove(src)
W.equipped(src, slot)
if(client)
client.screen |= W

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B