Improved Meteor Shields (#27937)

* Improved meteor shield sat control and coverage calculation.

* Cheaper shield satellites.

* Register completion as it happens.

* Corrected a horrible, terrible mistake.

* Update code/game/objects/effects/meteors.dm

Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

---------

Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>
This commit is contained in:
Charlie Nolan
2025-01-15 19:48:59 +00:00
committed by GitHub
parent f682d8d5bf
commit 471383bcc1
6 changed files with 396 additions and 135 deletions
+135 -23
View File
@@ -1,9 +1,19 @@
#define MIN_ZOOM 1
#define MAX_ZOOM 8
#define MIN_TAB_INDEX 0
#define MAX_TAB_INDEX 1
//Station Shield
// A chain of satellites encircles the station
// Satellites be actived to generate a shield that will block unorganic matter from passing it.
/datum/station_goal/station_shield
name = "Station Shield"
var/coverage_goal = 5000
var/coverage_goal = 75
var/last_coverage = 0
var/is_testing = FALSE
var/thrown = 0
var/list/defended = list()
var/list/collisions = list()
/datum/station_goal/station_shield/get_report()
return {"<b>Station Shield construction</b><br>
@@ -22,17 +32,33 @@
/datum/station_goal/station_shield/check_completion()
if(..())
return TRUE
if(get_coverage() >= coverage_goal)
return TRUE
return FALSE
return last_coverage >= coverage_goal
/datum/station_goal/proc/get_coverage()
var/list/coverage = list()
for(var/obj/machinery/satellite/meteor_shield/A in GLOB.machines)
if(!A.active || !is_station_level(A.z))
continue
coverage |= view(A.kill_range, A)
return length(coverage)
/datum/station_goal/station_shield/proc/update_coverage(success, turf/where)
if(success)
defended += list(list("x" = where.x, "y" = where.y))
else
collisions += list(list("x" = where.x, "y" = where.y))
if(length(defended) > last_coverage)
last_coverage = length(defended)
if(length(defended) + length(collisions) >= 100)
last_coverage = length(defended)
is_testing = FALSE
/datum/station_goal/station_shield/proc/simulate_meteors()
if(is_testing)
return FALSE
is_testing = TRUE
thrown = 0
defended = list()
collisions = list()
START_PROCESSING(SSprocessing, src)
/datum/station_goal/station_shield/process()
spawn_meteor(list(/obj/effect/meteor/fake = 1))
thrown++
if(thrown >= 100)
return PROCESS_KILL
/obj/item/circuitboard/computer/sat_control
board_name = "Satellite Network Control"
@@ -45,7 +71,20 @@
circuit = /obj/item/circuitboard/computer/sat_control
icon_screen = "accelerator"
icon_keyboard = "rd_key"
var/notice
/// A notice to display to the user.
var/notice = ""
/// The color to use for the notice.
var/notice_color = "white"
/// Before world.time reaches this, the notice will not automatically update to show the testing status.
var/freeze_notice_until = 0
/// The X offset of the UI map
var/offset_x = 0
/// The Y offset of the UI map
var/offset_y = 0
/// The zoom of the UI map
var/zoom = 1
/// The ID of the currently opened UI tab
var/tab_index = 0
/obj/machinery/computer/sat_control/attack_hand(mob/user)
if(..())
@@ -61,6 +100,11 @@
ui = new(user, src, "SatelliteControl", name)
ui.open()
/obj/machinery/computer/sat_control/ui_assets(mob/user)
return list(
get_asset_datum(/datum/asset/simple/nanomaps)
)
/obj/machinery/computer/sat_control/ui_data(mob/user)
var/list/data = list()
@@ -69,16 +113,32 @@
data["satellites"] += list(list(
"id" = S.id,
"active" = S.active,
"mode" = S.mode
"mode" = S.mode,
"x" = S.x,
"y" = S.y
))
update_notice()
data["notice"] = notice
data["notice_color"] = notice_color
data["zoom"] = zoom
data["offsetX"] = offset_x
data["offsetY"] = offset_y
data["tabIndex"] = tab_index
var/datum/station_goal/station_shield/G = locate() in SSticker.mode.station_goals
var/datum/station_goal/station_shield/G = locate() in SSticker.mode?.station_goals
if(G)
data["meteor_shield"] = 1
data["meteor_shield_coverage"] = G.get_coverage()
data["meteor_shield_coverage_max"] = G.coverage_goal
data["meteor_shield_coverage_percentage"] = (G.get_coverage() / G.coverage_goal) * 100
data["has_goal"] = 1
data["coverage"] = G.last_coverage
data["coverage_goal"] = G.coverage_goal
data["testing"] = G.is_testing
data["thrown"] = G.thrown
data["defended"] = G.defended
data["collisions"] = G.collisions
var/list/fake_meteors = list()
if(G.is_testing)
for(var/obj/effect/meteor/fake/meteor in GLOB.meteor_list)
fake_meteors += list(list("x" = meteor.x, "y" = meteor.y))
data["fake_meteors"] = fake_meteors
return data
/obj/machinery/computer/sat_control/ui_act(action, params)
@@ -86,18 +146,64 @@
return
switch(action)
if("begin_test")
var/datum/station_goal/station_shield/G = locate() in SSticker.mode?.station_goals
if(G)
G.simulate_meteors()
if("toggle")
toggle(text2num(params["id"]))
. = TRUE
if("set_tab_index")
var/new_tab_index = text2num(params["tab_index"])
if(isnull(new_tab_index) || new_tab_index < MIN_TAB_INDEX || new_tab_index > MAX_TAB_INDEX)
return
tab_index = new_tab_index
if("set_zoom")
var/new_zoom = text2num(params["zoom"])
if(isnull(new_zoom) || new_zoom < MIN_ZOOM || new_zoom > MAX_ZOOM)
return
zoom = new_zoom
if("set_offset")
var/new_offset_x = text2num(params["offset_x"])
var/new_offset_y = text2num(params["offset_y"])
if(isnull(new_offset_x) || isnull(new_offset_y))
return
offset_x = new_offset_x
offset_y = new_offset_y
/obj/machinery/computer/sat_control/proc/toggle(id)
for(var/obj/machinery/satellite/S in GLOB.machines)
if(S.id == id && atoms_share_level(src, S))
if(!S.toggle())
notice = "You can only activate satellites which are in space"
else
notice = null
notice_color = "red"
freeze_notice_until = world.time + 5 SECONDS
/obj/machinery/computer/sat_control/proc/update_notice()
var/datum/station_goal/station_shield/G = locate() in SSticker.mode?.station_goals
if(!G)
return
if(freeze_notice_until >= world.time)
return
if(G.is_testing && G.thrown < 100)
notice = "Throwing simulated meteors ([G.thrown]/100)..."
notice_color = "white"
return
var/total_meteors = length(G.defended) + length(G.collisions)
if(total_meteors == 0)
notice = "No simulation yet."
notice_color = "red"
return
if(G.is_testing)
notice = "Waiting for simulated meteors ([total_meteors]/100)..."
notice_color = "white"
return
notice = "Test complete. [100 - G.last_coverage] collisions out of 100 meteors."
notice_color = (G.last_coverage > G.coverage_goal) ? "blue" : "red"
/obj/machinery/satellite
name = "Defunct Satellite"
@@ -171,9 +277,10 @@
if(get_dist(M, src) > kill_range)
continue
if(!emagged && space_los(M))
Beam(get_turf(M), icon_state = "sat_beam", time = 5, maxdistance = kill_range)
if(istype(M, /obj/effect/space_dust/meaty))
new /obj/item/food/meatsteak(get_turf(M))
if(!istype(M, /obj/effect/meteor/fake))
Beam(get_turf(M), icon_state = "sat_beam", time = 5, maxdistance = kill_range)
if(istype(M, /obj/effect/space_dust/meaty))
new /obj/item/food/meatsteak(get_turf(M))
qdel(M)
/obj/machinery/satellite/meteor_shield/toggle(user)
@@ -203,3 +310,8 @@
if(active)
change_meteor_chance(2)
return TRUE
#undef MIN_ZOOM
#undef MAX_ZOOM
#undef MIN_TAB_INDEX
#undef MAX_TAB_INDEX
@@ -585,9 +585,10 @@
containername = "dna samplers crate"
/datum/supply_packs/misc/station_goal/shield_sat
name = "Shield Generator Satellite"
cost = 250
name = "Shield Generator Satellites"
cost = 100
contains = list(
/obj/machinery/satellite/meteor_shield,
/obj/machinery/satellite/meteor_shield,
/obj/machinery/satellite/meteor_shield,
/obj/machinery/satellite/meteor_shield