Files
Bubberstation/code/modules/events/carp_migration.dm
NamelessFairy 105dff5058 Refactors admin event setup (again) (#73801)
## About The Pull Request

Requested by @tralezab 

Admin event setups now use a list rather than a single setup. This means
common functionality list setting position and picking an option from a
list can be applied to events that have multiple customizable factors
rather than needing to making entirely overridden subtypes for every
event.

Adds a few new subtypes of event_admin_setup:
- input_number for setting a number value. An example can be found in
the heart attack event.
- set_location for causing an event to occur in a specific location. An
example can be found in the stray cargo pod event.
- question, yes no question that returns true/false. An example of its
usage can be found in immovable rod
- candidate_check, a more niche subtype used to block events that do not
function unless theres a specific number of valid candidates. An example
of its usage can be found in the disease events.

While doing the refactor I also implemented some simple extra options
for some of the refactored events. Classic Disease now has an option for
admins to roll **any** disease rather than just the "safe" ones. And
shuttle catastrophe now allows admins to select which shuttle is used.
## Why It's Good For The Game

Cuts back on duplicate lines of code a lot, should make adding more
customization to events slightly easier. Also more admin customization.
## Changelog
🆑
refactor: Admin event setup's have been refactored to use lists.
fix: When admins customize the pirate event all options will be
available rather than just options that have not been randomly rolled.
fix: The stray meteor event no longer runtimes when customized by
admins.
admin: Admins can now select the shuttle brought in by the shuttle
catastrophe event.
admin: Admins can now randomize the disease outbreak classic event to
roll any disease type, including transformation diseases so have fun
with that.
/🆑
2023-03-08 09:50:59 -07:00

103 lines
4.1 KiB
Plaintext

/datum/round_event_control/carp_migration
name = "Carp Migration"
typepath = /datum/round_event/carp_migration
weight = 15
min_players = 12
earliest_start = 10 MINUTES
max_occurrences = 6
category = EVENT_CATEGORY_ENTITIES
description = "Summons a school of space carp."
min_wizard_trigger_potency = 0
max_wizard_trigger_potency = 3
admin_setup = list(/datum/event_admin_setup/carp_migration)
/datum/round_event_control/carp_migration/New()
. = ..()
if(!HAS_TRAIT(SSstation, STATION_TRAIT_CARP_INFESTATION))
return
weight *= 3
max_occurrences *= 2
earliest_start *= 0.5
/datum/round_event/carp_migration
announce_when = 3
start_when = 50
/// Set to true when we announce something to ghosts, to prevent duplicate announcements
var/hasAnnounced = FALSE
/// Most common mob type to spawn, must be a child of /mob/living/basic/carp
var/carp_type = /mob/living/basic/carp
/// Rarer mob type to spawn, must also be a child of /mob/living/basic/carp. If one of these is created, it will take priority to show ghosts.
var/boss_type = /mob/living/basic/carp/mega
/// What to describe detecting near the station
var/fluff_signal = "Unknown biological entities"
/// Associated lists of z level to a list of points to travel to, so that grouped fish move to the same places
var/list/z_migration_paths = list()
/datum/round_event/carp_migration/setup()
start_when = rand(40, 60)
/datum/round_event/carp_migration/announce(fake)
priority_announce("[fluff_signal] have been detected near [station_name()], please stand-by.", "Lifesign Alert")
/datum/round_event/carp_migration/start()
// Stores the most recent fish we spawn
var/mob/living/basic/carp/fish
for(var/obj/effect/landmark/carpspawn/spawn_point in GLOB.landmarks_list)
if(prob(95))
fish = new carp_type(spawn_point.loc)
else
fish = new boss_type(spawn_point.loc)
fishannounce(fish) //Prefer to announce the megacarps over the regular fishies
var/z_level_key = "[spawn_point.z]"
if (!z_migration_paths[z_level_key])
z_migration_paths[z_level_key] = pick_carp_migration_points(z_level_key)
if (z_migration_paths[z_level_key]) // Still possible we failed to set anything here if we're unlucky
fish.migrate_to(z_migration_paths[z_level_key])
fishannounce(fish)
/// Generate two locations for carp to travel to, one in the station and one off in space
/datum/round_event/carp_migration/proc/pick_carp_migration_points(z_level_key)
var/list/valid_areas = list()
var/list/station_areas = GLOB.the_station_areas
for (var/area/potential_area as anything in SSmapping.areas_in_z[z_level_key])
if (!is_type_in_list(potential_area, station_areas))
continue
valid_areas += potential_area
var/turf/station_turf = get_safe_random_station_turf(valid_areas)
if (!station_turf)
return list()
var/turf/exit_turf = get_edge_target_turf(station_turf, pick(GLOB.alldirs))
return list(WEAKREF(station_turf), WEAKREF(exit_turf))
/datum/round_event/carp_migration/proc/fishannounce(atom/fish)
if (!hasAnnounced)
announce_to_ghosts(fish) //Only anounce the first fish
hasAnnounced = TRUE
/datum/event_admin_setup/carp_migration
/// Admin set list of turfs for carp to travel to for each z level
var/list/targets_per_z = list()
/datum/event_admin_setup/carp_migration/prompt_admins()
targets_per_z = list()
if (tgui_alert(usr, "Direct carp to your current location? Only applies to your current Z level.", "Carp Direction", list("Yes", "No")) != "Yes")
return
record_admin_location()
while (tgui_alert(usr, "Add additional locations? Only applies to your current Z level.", "More Carp Direction", list("Yes", "No")) == "Yes")
record_admin_location()
/// Stores the admin's current location corresponding to the z level of that location
/datum/event_admin_setup/carp_migration/proc/record_admin_location()
var/turf/aimed_turf = get_turf(usr)
var/z_level_key = "[aimed_turf.z]"
if (!targets_per_z[z_level_key])
targets_per_z[z_level_key] = list()
targets_per_z[z_level_key] += WEAKREF(aimed_turf)
/datum/event_admin_setup/carp_migration/apply_to_event(datum/round_event/carp_migration/event)
event.z_migration_paths = targets_per_z