[MIRROR] Admins can now customize the space vines event. Also fixes a space vine event bugs. [MDB IGNORE] (#20586)

* Admins can now customize the space vines event. Also fixes a space vine event bugs.

* skyrat edit

---------

Co-authored-by: NamelessFairy <40036527+NamelessFairy@users.noreply.github.com>
Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-04-17 14:54:31 -07:00
committed by GitHub
co-authored by NamelessFairy lessthanthree
parent 8ecf92bf50
commit 8e3d8cafbe
6 changed files with 159 additions and 32 deletions
+21 -1
View File
@@ -106,7 +106,7 @@
/datum/event_admin_setup/input_number
///Text shown when admins are queried about what number to set.
var/input_text = ""
var/input_text = "Unset text"
///The value the number will be set to by default
var/default_value
///The highest value setable by the admin.
@@ -159,3 +159,23 @@
chosen = FALSE
else
return ADMIN_CANCEL_EVENT
/datum/event_admin_setup/multiple_choice
///Text shown to the admin when queried about which options they want to pick.
var/input_text = "Unset Text"
///The minimum number of choices an admin must make for this event.
var/min_choices = 1
///The maximum number of choices that the admin can make for this event.
var/max_choices = 50
///List of choices returned by this setup to the event.
var/list/choices = list()
/datum/event_admin_setup/multiple_choice/proc/get_options()
SHOULD_CALL_PARENT(FALSE)
CRASH("Unimplemented get_options() on [event_control]'s admin setup.")
/datum/event_admin_setup/multiple_choice/prompt_admins()
var/list/options = get_options()
choices = tgui_input_checkboxes(usr, input_text, event_control.name, options, min_choices, max_choices)
if(isnull(choices))
return ADMIN_CANCEL_EVENT
@@ -1,4 +1,15 @@
/* SKYRAT EDIT REMOVAL
/// SKYRAT EDIT REMOVAL BEGIN
/*
///A list of the possible mutations for a vine
GLOBAL_LIST_INIT(vine_mutations_list, init_vine_mutation_list())
/proc/init_vine_mutation_list()
var/list/mutation_list = list()
init_subtypes(/datum/spacevine_mutation/, mutation_list)
for(var/datum/spacevine_mutation/mutation as anything in mutation_list)
mutation_list[mutation] = IDEAL_MAX_SEVERITY - mutation.severity // the ideal maximum potency is used for weighting
return mutation_list
/datum/spacevine_controller
///Canonical list of all the vines we "own"
var/list/obj/structure/spacevine/vines
@@ -10,8 +21,6 @@
var/spread_multiplier = 5 // corresponds to artifical kudzu with production speed of 1, approaches 10% of total vines will spread per second
///Maximum spreading limit (ie. how many kudzu can there be) for this controller
var/spread_cap = 30 // corresponds to artifical kudzu with production speed of 3.5
///A list of the possible mutations for a vine
var/static/list/vine_mutations_list
///The chance that we will develop a new mutation
var/mutativeness = 1
///Maximum sum of mutation severities
@@ -27,11 +36,6 @@
if(event)
event.announce_to_ghosts(vine)
START_PROCESSING(SSobj, src)
if(!vine_mutations_list)
vine_mutations_list = list()
init_subtypes(/datum/spacevine_mutation/, vine_mutations_list)
for(var/datum/spacevine_mutation/mutation as anything in vine_mutations_list)
vine_mutations_list[mutation] = IDEAL_MAX_SEVERITY - mutation.severity // the ideal maximum potency is used for weighting
if(potency != null)
mutativeness = potency * MUTATIVENESS_SCALE_FACTOR // If potency is 100, 20 mutativeness; if 1: 0.2 mutativeness
max_mutation_severity = round(potency * MAX_SEVERITY_LINEAR_COEFF + MAX_SEVERITY_CONSTANT_TERM) // If potency is 100, 25 max mutation severity; if 1, 10 max mutation severity
@@ -67,20 +71,24 @@
growth_queue += vine
vines += vine
vine.master = src
for(var/datum/spacevine_mutation/mutation in muts)
mutation.add_mutation_to_vinepiece(vine)
for(var/mutation_type in muts)
for(var/datum/spacevine_mutation/mutation in GLOB.vine_mutations_list)
if(istype(mutation, mutation_type))
mutation.add_mutation_to_vinepiece(vine)
break
if(parent)
vine.mutations |= parent.mutations
vine.trait_flags |= parent.trait_flags
var/parentcolor = parent.atom_colours[FIXED_COLOUR_PRIORITY]
vine.add_atom_colour(parentcolor, FIXED_COLOUR_PRIORITY)
if(prob(mutativeness))
var/datum/spacevine_mutation/random_mutate = pick_weight(vine_mutations_list - vine.mutations)
var/total_severity = random_mutate.severity
for(var/datum/spacevine_mutation/mutation as anything in vine.mutations)
total_severity += mutation.severity
if(total_severity <= max_mutation_severity)
random_mutate.add_mutation_to_vinepiece(vine)
var/datum/spacevine_mutation/random_mutate = pick_weight(GLOB.vine_mutations_list - vine.mutations)
if(!isnull(random_mutate)) //If this vine has every single mutation don't attempt to add a null mutation.
var/total_severity = random_mutate.severity
for(var/datum/spacevine_mutation/mutation as anything in vine.mutations)
total_severity += mutation.severity
if(total_severity <= max_mutation_severity)
random_mutate.add_mutation_to_vinepiece(vine)
for(var/datum/spacevine_mutation/mutation in vine.mutations)
mutation.on_birth(vine)
@@ -153,3 +161,4 @@
return TRUE
return FALSE
*/
/// SKYRAT EDIT REMOVAL END
+91 -7
View File
@@ -9,23 +9,107 @@
description = "Kudzu begins to overtake the station. Might spawn man-traps."
min_wizard_trigger_potency = 4
max_wizard_trigger_potency = 7
admin_setup = list(
/datum/event_admin_setup/set_location/spacevine,
/datum/event_admin_setup/multiple_choice/spacevine,
/datum/event_admin_setup/input_number/spacevine_potency,
/datum/event_admin_setup/input_number/spacevine_production,
)
/datum/round_event/spacevine
fakeable = FALSE
///Override location the vines will spawn in.
var/turf/override_turf
///used to confirm if admin selected mutations should be used or not.
var/mutations_overridden = FALSE
///Admin selected mutations that the kudzu will spawn with, can be set to none to act as mutationless kudzu.
var/list/override_mutations = list()
///Potency of the spawned kudzu.
var/potency
///Production value of the spawned kuduz.
var/production
/datum/round_event/spacevine/start()
var/list/turfs = list() //list of all the empty floor turfs in the hallway areas
var/obj/structure/spacevine/vine = new()
for(var/area/station/hallway/area in GLOB.areas)
for(var/turf/floor as anything in area.get_contained_turfs())
if(floor.Enter(vine))
turfs += floor
if(override_turf)
turfs += override_turf
else
var/obj/structure/spacevine/vine = new()
qdel(vine)
for(var/area/station/hallway/area in GLOB.areas)
for(var/turf/open/floor in area.get_contained_turfs())
if(floor.Enter(vine))
turfs += floor
qdel(vine)
if(length(turfs)) //Pick a turf to spawn at if we can
var/turf/floor = pick(turfs)
new /datum/spacevine_controller(floor, list(pick(subtypesof(/datum/spacevine_mutation))), rand(50,100), rand(1,4), src) //spawn a controller at turf with randomized stats and a single random mutation
var/list/selected_mutations = list()
if(mutations_overridden == FALSE)
selected_mutations = list(pick(subtypesof(/datum/spacevine_mutation)))
else
selected_mutations = override_mutations
if(isnull(potency))
potency = rand(50,100)
if(isnull(production))
production = rand(1, 4)
new /datum/spacevine_controller(floor, selected_mutations, potency, production, src) //spawn a controller at turf with randomized stats and a single random mutation
/datum/event_admin_setup/set_location/spacevine
input_text = "Spawn vines at current location?"
/datum/event_admin_setup/set_location/spacevine/apply_to_event(datum/round_event/spacevine/event)
event.override_turf = chosen_turf
/datum/event_admin_setup/multiple_choice/spacevine
input_text = "Select starting mutations."
min_choices = 0
/datum/event_admin_setup/multiple_choice/spacevine/prompt_admins()
var/customize_mutations = tgui_alert(usr, "Select mutations?", event_control.name, list("Custom", "Random", "Cancel"))
switch(customize_mutations)
if("Custom")
return ..()
if("Random")
choices = list("[pick(subtypesof(/datum/spacevine_mutation))]")
else
return ADMIN_CANCEL_EVENT
/datum/event_admin_setup/multiple_choice/spacevine/get_options()
return subtypesof(/datum/spacevine_mutation/)
/datum/event_admin_setup/multiple_choice/spacevine/apply_to_event(datum/round_event/spacevine/event)
var/list/type_choices = list()
for(var/choice in choices)
type_choices += text2path(choice)
event.mutations_overridden = TRUE
event.override_mutations = type_choices
/datum/event_admin_setup/input_number/spacevine_potency
input_text = "Set vine's potency (effects mutation frequency + max severity)"
max_value = 100
/datum/event_admin_setup/input_number/spacevine_potency/prompt_admins()
default_value = rand(50, 100)
return ..()
/datum/event_admin_setup/input_number/spacevine_potency/apply_to_event(datum/round_event/spacevine/event)
event.potency = chosen_value
/datum/event_admin_setup/input_number/spacevine_production
input_text = "Set vine's production (effects spreading cap + speed) (lower is faster)"
min_value = 1
max_value = 10
/datum/event_admin_setup/input_number/spacevine_production/prompt_admins()
default_value = rand(1, 4)
return ..()
/datum/event_admin_setup/input_number/spacevine_production/apply_to_event(datum/round_event/spacevine/event)
event.production = chosen_value
*/
@@ -311,18 +311,18 @@
return expected_damage
/datum/spacevine_mutation/woodening
/datum/spacevine_mutation/hardened
name = "Hardened"
hue = "#997700"
quality = NEGATIVE
severity = SEVERITY_ABOVE_AVERAGE
/datum/spacevine_mutation/woodening/on_grow(obj/structure/spacevine/holder)
/datum/spacevine_mutation/hardened/on_grow(obj/structure/spacevine/holder)
if(holder.growth_stage)
holder.set_density(TRUE)
holder.modify_max_integrity(100)
/datum/spacevine_mutation/woodening/on_hit(obj/structure/spacevine/holder, mob/living/hitter, obj/item/item, expected_damage)
/datum/spacevine_mutation/hardened/on_hit(obj/structure/spacevine/holder, mob/living/hitter, obj/item/item, expected_damage)
if(item?.get_sharpness())
return expected_damage * 0.5
return expected_damage
+9 -4
View File
@@ -6,10 +6,11 @@
* message - The message inside the window
* title - The title of the window
* list/items - The list of items to display
* min_checked - The minimum number of checkboxes that must be checked (defaults to 1)
* max_checked - The maximum number of checkboxes that can be checked (optional)
* timeout - The timeout for the input (optional)
*/
/proc/tgui_input_checkboxes(mob/user, message, title = "Select", list/items, max_checked = 50, timeout = 0)
/proc/tgui_input_checkboxes(mob/user, message, title = "Select", list/items, min_checked = 1, max_checked = 50, timeout = 0)
if (!user)
user = usr
if(!length(items))
@@ -22,7 +23,7 @@
return
if(!user.client.prefs.read_preference(/datum/preference/toggle/tgui_input))
return input(user, message, title) as null|anything in items
var/datum/tgui_checkbox_input/input = new(user, message, title, items, max_checked, timeout)
var/datum/tgui_checkbox_input/input = new(user, message, title, items, min_checked, max_checked, timeout)
input.ui_interact(user)
input.wait()
if (input)
@@ -45,13 +46,16 @@
var/timeout
/// Whether the input was closed
var/closed
/// Minimum number of checkboxes that must be checked
var/min_checked
/// Maximum number of checkboxes that can be checked
var/max_checked
/datum/tgui_checkbox_input/New(mob/user, message, title, list/items, max_checked, timeout)
/datum/tgui_checkbox_input/New(mob/user, message, title, list/items, min_checked, max_checked, timeout)
src.title = title
src.message = message
src.items = items.Copy()
src.min_checked = min_checked
src.max_checked = max_checked
if (timeout)
@@ -94,6 +98,7 @@
var/list/data = list()
data["items"] = items
data["min_checked"] = min_checked
data["max_checked"] = max_checked
data["large_buttons"] = user.client.prefs.read_preference(/datum/preference/toggle/tgui_input_large)
data["message"] = message
@@ -110,7 +115,7 @@
switch(action)
if("submit")
var/list/selections = params["entry"]
if(length(selections) > 0 && length(selections) <= max_checked)
if(length(selections) >= min_checked && length(selections) <= max_checked)
set_choices(selections)
closed = TRUE
SStgui.close_uis(src)
@@ -12,13 +12,21 @@ type Data = {
message: string;
title: string;
timeout: number;
min_checked: number;
max_checked: number;
};
/** Renders a list of checkboxes per items for input. */
export const CheckboxInput = (props, context) => {
const { data } = useBackend<Data>(context);
const { items = [], max_checked, message, timeout, title } = data;
const {
items = [],
min_checked,
max_checked,
message,
timeout,
title,
} = data;
const [selections, setSelections] = useLocalState<string[]>(
context,
@@ -50,6 +58,7 @@ export const CheckboxInput = (props, context) => {
<Stack.Item>
<NoticeBox info textAlign="center">
{decodeHtmlEntities(message)}{' '}
{min_checked > 0 && ` (Min: ${min_checked})`}
{max_checked < 50 && ` (Max: ${max_checked})`}
</NoticeBox>
</Stack.Item>