mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-29 16:10:02 +01:00
Multi-z shields (#12568)
This commit is contained in:
@@ -148,3 +148,6 @@
|
||||
icon_state = "broke"
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/machinery/shield_capacitor/multiz
|
||||
max_charge_rate = 1250000 //1250 kW
|
||||
@@ -29,6 +29,8 @@
|
||||
var/time_since_fail = 100
|
||||
var/energy_conversion_rate = 0.0002 //how many renwicks per watt?
|
||||
use_power = 0 //doesn't use APC power
|
||||
var/multiz = FALSE
|
||||
var/multi_unlocked = FALSE
|
||||
|
||||
/obj/machinery/shield_gen/Initialize()
|
||||
for(var/obj/machinery/shield_capacitor/possible_cap in range(1, src))
|
||||
@@ -73,7 +75,7 @@
|
||||
for(var/obj/machinery/shield_capacitor/cap in range(1, src))
|
||||
if(cap.owned_gen)
|
||||
continue
|
||||
if(get_dir(cap, src) == cap.dir && src.anchored)
|
||||
if(get_dir(cap, src) == cap.dir && cap.anchored)
|
||||
owned_capacitor = cap
|
||||
owned_capacitor.owned_gen = src
|
||||
updateDialog()
|
||||
@@ -96,45 +98,30 @@
|
||||
interact(user)
|
||||
|
||||
/obj/machinery/shield_gen/interact(mob/user)
|
||||
if ( (get_dist(src, user) > 1 ) || (stat & (BROKEN)) )
|
||||
if (!istype(user, /mob/living/silicon))
|
||||
user.unset_machine()
|
||||
user << browse(null, "window=shield_generator")
|
||||
return
|
||||
var/t = "<B>Shield Generator Control Console</B><BR><br>"
|
||||
if(locked)
|
||||
t += "<i>Swipe your ID card to begin.</i>"
|
||||
to_chat(user, SPAN_WARNING("The device is locked. Swipe your ID to unlock it."))
|
||||
return
|
||||
if(!anchored)
|
||||
to_chat(user, SPAN_WARNING("The device needs to be bolted to the ground first."))
|
||||
return
|
||||
else
|
||||
t += "[owned_capacitor ? "<font color=green>Charge capacitor connected.</font>" : "<font color=red>Unable to locate charge capacitor!</font>"]<br>"
|
||||
t += "This generator is: [active ? "<font color=green>Online</font>" : "<font color=red>Offline</font>" ] <a href='?src=\ref[src];toggle=1'>[active ? "\[Deactivate\]" : "\[Activate\]"]</a><br>"
|
||||
t += "Field Status: [time_since_fail > 2 ? "<font color=green>Stable</font>" : "<font color=red>Unstable</font>"]<br>"
|
||||
t += "Coverage Radius (restart required): \
|
||||
<a href='?src=\ref[src];change_radius=-50'>---</a> \
|
||||
<a href='?src=\ref[src];change_radius=-5'>--</a> \
|
||||
<a href='?src=\ref[src];change_radius=-1'>-</a> \
|
||||
[field_radius] m \
|
||||
<a href='?src=\ref[src];change_radius=1'>+</a> \
|
||||
<a href='?src=\ref[src];change_radius=5'>++</a> \
|
||||
<a href='?src=\ref[src];change_radius=50'>+++</a><br>"
|
||||
t += "Overall Field Strength: [round(average_field_strength, 0.01)] Renwick ([target_field_strength ? round(100 * average_field_strength / target_field_strength, 0.1) : "NA"]%)<br>"
|
||||
t += "Upkeep Power: [round(field.len * max(average_field_strength * dissipation_rate, min_dissipation) / energy_conversion_rate)] W<br>"
|
||||
t += "Charge Rate: <a href='?src=\ref[src];strengthen_rate=-0.1'>--</a> \
|
||||
[strengthen_rate] Renwick/s \
|
||||
<a href='?src=\ref[src];strengthen_rate=0.1'>++</a><br>"
|
||||
t += "Shield Generation Power: [round(field.len * min(strengthen_rate, target_field_strength - average_field_strength) / energy_conversion_rate)] W<br>"
|
||||
t += "Maximum Field Strength: \
|
||||
<a href='?src=\ref[src];target_field_strength=-10'>\[min\]</a> \
|
||||
<a href='?src=\ref[src];target_field_strength=-5'>--</a> \
|
||||
<a href='?src=\ref[src];target_field_strength=-1'>-</a> \
|
||||
[target_field_strength] Renwick \
|
||||
<a href='?src=\ref[src];target_field_strength=1'>+</a> \
|
||||
<a href='?src=\ref[src];target_field_strength=5'>++</a> \
|
||||
<a href='?src=\ref[src];target_field_strength=10'>\[max\]</a><br>"
|
||||
t += "<hr>"
|
||||
t += "<A href='?src=\ref[src]'>Refresh</A> "
|
||||
t += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
||||
user << browse(t, "window=shield_generator;size=500x400")
|
||||
user.set_machine(src)
|
||||
if(owned_capacitor)
|
||||
if(!(owned_capacitor in range(1, src) && get_dir(owned_capacitor, src) == owned_capacitor.dir && owned_capacitor.anchored))
|
||||
if(owned_capacitor.owned_gen == src)
|
||||
owned_capacitor.owned_gen = null
|
||||
owned_capacitor = null
|
||||
if(!owned_capacitor)
|
||||
for(var/obj/machinery/shield_capacitor/cap in range(1, src))
|
||||
if(cap.owned_gen)
|
||||
continue
|
||||
if(get_dir(cap, src) == cap.dir && cap.anchored)
|
||||
owned_capacitor = cap
|
||||
owned_capacitor.owned_gen = src
|
||||
updateDialog()
|
||||
break
|
||||
return src.ui_interact(user)
|
||||
|
||||
|
||||
|
||||
/obj/machinery/shield_gen/machinery_process()
|
||||
if (!anchored && active)
|
||||
@@ -177,28 +164,7 @@
|
||||
else
|
||||
average_field_strength = 0
|
||||
|
||||
/obj/machinery/shield_gen/Topic(href, href_list[])
|
||||
..()
|
||||
if( href_list["close"] )
|
||||
usr << browse(null, "window=shield_generator")
|
||||
usr.unset_machine()
|
||||
return
|
||||
else if( href_list["toggle"] )
|
||||
if (!active && !anchored)
|
||||
to_chat(usr, "<span class='warning'>The [src] needs to be firmly secured to the floor first.</span>")
|
||||
return
|
||||
toggle()
|
||||
else if( href_list["change_radius"] )
|
||||
field_radius = between(0, field_radius + text2num(href_list["change_radius"]), max_field_radius)
|
||||
else if( href_list["strengthen_rate"] )
|
||||
strengthen_rate = between(0, strengthen_rate + text2num(href_list["strengthen_rate"]), max_strengthen_rate)
|
||||
else if( href_list["target_field_strength"] )
|
||||
target_field_strength = between(1, target_field_strength + text2num(href_list["target_field_strength"]), max_field_strength)
|
||||
|
||||
updateDialog()
|
||||
|
||||
/obj/machinery/shield_gen/ex_act(var/severity)
|
||||
|
||||
if(active)
|
||||
toggle()
|
||||
return ..()
|
||||
@@ -264,3 +230,53 @@
|
||||
T = locate(gen_turf.x + field_radius, gen_turf.y + y_offset, gen_turf.z)
|
||||
if (T)
|
||||
. += T
|
||||
|
||||
/obj/machinery/shield_gen/ui_interact(mob/user)
|
||||
var/datum/vueui/ui = SSvueui.get_open_ui(user, src)
|
||||
if (!ui)
|
||||
ui = new(user, src, "machinery-shields-shield", 480, 400, "Shield Generator", state = interactive_state)
|
||||
ui.open()
|
||||
ui.auto_update_content = TRUE
|
||||
|
||||
/obj/machinery/shield_gen/vueui_data_change(list/data, mob/user, datum/vueui/ui)
|
||||
data = ..() || list()
|
||||
|
||||
data["owned_capacitor"] = owned_capacitor
|
||||
data["active"] = active
|
||||
data["time_since_fail"] = time_since_fail
|
||||
data["multi_unlocked"] = multi_unlocked
|
||||
data["multiz"] = multiz
|
||||
data["field_radius"] = field_radius
|
||||
data["min_field_radius"] = 1
|
||||
data["max_field_radius"] = max_field_radius
|
||||
data["average_field"] = round(average_field_strength, 0.01)
|
||||
data["progress_field"] = (target_field_strength ? round(100 * average_field_strength / target_field_strength, 0.1) : "NA")
|
||||
data["power_take"] = round(field.len * max(average_field_strength * dissipation_rate, min_dissipation) / energy_conversion_rate)
|
||||
data["shield_power"] = round(field.len * min(strengthen_rate, target_field_strength - average_field_strength) / energy_conversion_rate)
|
||||
data["strengthen_rate"] = (strengthen_rate * 10)
|
||||
data["max_strengthen_rate"] = (max_strengthen_rate * 10)
|
||||
data["target_field_strength"] = target_field_strength
|
||||
|
||||
return data
|
||||
|
||||
/obj/machinery/shield_gen/Topic(href, href_list)
|
||||
if (!isturf(loc))
|
||||
return 0
|
||||
|
||||
if(href_list["toggle"])
|
||||
toggle()
|
||||
|
||||
if(href_list["multiz"])
|
||||
multiz = !multiz
|
||||
|
||||
if (href_list["size_set"])
|
||||
field_radius = between(1, text2num(href_list["size_set"]), max_field_radius)
|
||||
|
||||
if (href_list["charge_set"])
|
||||
strengthen_rate = (between(1, text2num(href_list["charge_set"]), (max_strengthen_rate * 10)) / 10)
|
||||
|
||||
if (href_list["field_set"])
|
||||
target_field_strength = between(1, text2num(href_list["field_set"]), 10)
|
||||
|
||||
src.add_fingerprint(usr)
|
||||
return 1
|
||||
@@ -3,10 +3,12 @@
|
||||
|
||||
/obj/machinery/shield_gen/external
|
||||
name = "hull shield generator"
|
||||
multi_unlocked = TRUE
|
||||
|
||||
//NOT MULTIZ COMPATIBLE
|
||||
//Search for space turfs within range that are adjacent to a simulated turf.
|
||||
/obj/machinery/shield_gen/external/get_shielded_turfs()
|
||||
set background = 1
|
||||
var/list/out = list()
|
||||
|
||||
var/turf/gen_turf = get_turf(src)
|
||||
@@ -31,4 +33,53 @@
|
||||
out += T
|
||||
break
|
||||
|
||||
if(multiz)
|
||||
var/connected_levels = list()
|
||||
var/turf/above = getzabove(src)
|
||||
var/turf/below = getzbelow(src)
|
||||
if(above)
|
||||
for(var/turf/z in above)
|
||||
connected_levels += z
|
||||
if(below)
|
||||
for(var/turf/z in below)
|
||||
connected_levels += z
|
||||
for(var/turf/z in connected_levels)
|
||||
for (var/tt in RANGE_TURFS(field_radius, z))
|
||||
T = tt
|
||||
// Ignore station areas.
|
||||
if (the_station_areas[T.loc])
|
||||
continue
|
||||
else if (istype(T, /turf/space) || istype(T, /turf/unsimulated/floor/asteroid) || isopenturf(T))
|
||||
for (var/uu in RANGE_TURFS(1, T))
|
||||
U = uu
|
||||
if (T == U)
|
||||
continue
|
||||
|
||||
if (the_station_areas[U.loc])
|
||||
out += T
|
||||
break
|
||||
return out
|
||||
|
||||
/obj/machinery/shield_gen/external/proc/getzabove(var/turf/location)
|
||||
var/connected = list()
|
||||
var/turf/above = GetAbove(location)
|
||||
|
||||
if(above)
|
||||
connected += above
|
||||
var/connected_levels = getzabove(above)
|
||||
for(var/turf/z as anything in connected_levels)
|
||||
connected += z
|
||||
|
||||
return connected
|
||||
|
||||
/obj/machinery/shield_gen/external/proc/getzbelow(var/turf/location)
|
||||
var/connected = list()
|
||||
var/turf/below = GetBelow(location)
|
||||
|
||||
if(below)
|
||||
connected += below
|
||||
var/connected_levels = getzbelow(below)
|
||||
for(var/turf/z as anything in connected_levels)
|
||||
connected += z
|
||||
|
||||
return connected
|
||||
@@ -0,0 +1,6 @@
|
||||
author: TheGreyWolf
|
||||
|
||||
delete-after: True
|
||||
|
||||
changes:
|
||||
- rscadd: "Added the ability for shield generators to cover multiple z-levels."
|
||||
@@ -14845,14 +14845,14 @@
|
||||
/turf/simulated/floor/lino/grey,
|
||||
/area/hallway/secondary/entry/departure_lounge)
|
||||
"nqU" = (
|
||||
/obj/machinery/shield_capacitor{
|
||||
dir = 8
|
||||
},
|
||||
/obj/effect/floor_decal/industrial/outline/yellow,
|
||||
/obj/structure/cable/cyan{
|
||||
d2 = 2;
|
||||
icon_state = "0-2"
|
||||
},
|
||||
/obj/machinery/shield_capacitor/multiz{
|
||||
dir = 8
|
||||
},
|
||||
/turf/simulated/floor/plating,
|
||||
/area/storage/shields)
|
||||
"nrZ" = (
|
||||
@@ -23314,14 +23314,14 @@
|
||||
/turf/simulated/floor/plating,
|
||||
/area/hallway/secondary/entry/emergency)
|
||||
"uAC" = (
|
||||
/obj/machinery/shield_capacitor{
|
||||
dir = 4
|
||||
},
|
||||
/obj/effect/floor_decal/industrial/outline/yellow,
|
||||
/obj/structure/cable/cyan{
|
||||
d2 = 2;
|
||||
icon_state = "0-2"
|
||||
},
|
||||
/obj/machinery/shield_capacitor/multiz{
|
||||
dir = 4
|
||||
},
|
||||
/turf/simulated/floor/plating,
|
||||
/area/storage/shields)
|
||||
"uAT" = (
|
||||
@@ -23508,7 +23508,7 @@
|
||||
/obj/machinery/power/smes/buildable{
|
||||
RCon_tag = "Surface - Shield Substation";
|
||||
charge = 1e+007;
|
||||
cur_coils = 4;
|
||||
cur_coils = 5;
|
||||
input_attempt = 1;
|
||||
input_level = 500000;
|
||||
output_attempt = 1;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<div>
|
||||
<vui-group>
|
||||
<vui-group-item label="Capacitator status:">
|
||||
<span :class="owned_capacitor ? good : 'red'">{{owned_capacitor ? "Charge capacitor connected" : "Unable to locate charge capacitor"}}</span>
|
||||
</vui-group-item>
|
||||
|
||||
<vui-group-item label="This generator is:">
|
||||
<span :class="active ? 'green' : 'red'">{{active ? "Online" : "Offline"}}</span> <vui-button class="float-right" icon="" :params="{toggle : 1}">Toggle</vui-button>
|
||||
</vui-group-item>
|
||||
|
||||
<vui-group-item v-if="multi_unlocked" label="Multi-level Shields:">
|
||||
<span :class="multiz ? 'green' : 'red'">{{multiz ? "Online" : "Offline"}}</span> <vui-button class="float-right" icon="" :params="{multiz : 1}">Toggle</vui-button>
|
||||
</vui-group-item>
|
||||
|
||||
<vui-group-item label="Field Status:">
|
||||
<span :class="time_since_fail > 2 ? 'green' : 'red'">{{time_since_fail > 2 ? "Stable" : "Unstable"}}</span>
|
||||
</vui-group-item>
|
||||
|
||||
<vui-group-item label="Overall Field Strength:">
|
||||
<span :class="average">{{ average_field }} Renwick ({{ progress_field }}%)</span>
|
||||
</vui-group-item>
|
||||
|
||||
<vui-group-item label="Upkeep Power:">
|
||||
<span :class="average">{{ power_take }} W</span>
|
||||
</vui-group-item>
|
||||
|
||||
<vui-group-item label="Shield Generation Power:">
|
||||
<span :class="average">{{ shield_power }} W</span>
|
||||
</vui-group-item>
|
||||
|
||||
<vui-group-item label="Coverage Radius (restart required):">
|
||||
<div style="clear: both; padding-top: 4px;">
|
||||
<vui-input-numeric width="5em" v-model="field_radius" :button-count="2" :min="min_field_radius" :max="max_field_radius" @input="$toTopic({size_set : field_radius})">{{field_radius}} M </vui-input-numeric>
|
||||
</div>
|
||||
</vui-group-item>
|
||||
|
||||
<vui-group-item label="Charge Rate:">
|
||||
<div style="clear: both; padding-top: 4px;">
|
||||
<vui-input-numeric width="5em" v-model="strengthen_rate" :button-count="1" :min="1" :max="max_strengthen_rate" @input="$toTopic({charge_set : strengthen_rate})">{{strengthen_rate}} Renwick </vui-input-numeric>
|
||||
</div>
|
||||
</vui-group-item>
|
||||
|
||||
<vui-group-item label="Maximum Field strength:">
|
||||
<div style="clear: both; padding-top: 4px;">
|
||||
<vui-input-numeric width="5em" v-model="target_field_strength" :button-count="2" :min="1" :max="10" @input="$toTopic({field_set : target_field_strength})">{{target_field_strength}} </vui-input-numeric>
|
||||
</div>
|
||||
</vui-group-item>
|
||||
</vui-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return this.$root.$data.state;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user