forked from Baystation12/Baystation12
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Baystation12#14401 from atlantiscze/2016-10-13-Shi…
…elds Advanced Shield Generators
- Loading branch information
Showing
35 changed files
with
1,635 additions
and
978 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#define SHIELD_DAMTYPE_PHYSICAL 1 // Physical damage - bullets, meteors, various hand objects - aka. "brute" damtype. | ||
#define SHIELD_DAMTYPE_EM 2 // Electromagnetic damage - Ion weaponry, stun beams, ... | ||
#define SHIELD_DAMTYPE_HEAT 3 // Heat damage - Lasers, fire | ||
|
||
#define ENERGY_PER_HP (50 KILOWATTS)// Base amount energy that will be deducted from the generator's internal reserve per 1 HP of damage taken | ||
#define ENERGY_UPKEEP_PER_TILE 100 // Base upkeep per tile protected. Multiplied by various enabled shield modes. Without them the field does literally nothing. | ||
|
||
// This shield model is slightly inspired by Sins of a Solar Empire series. In short, shields are designed to analyze what hits them, and adapt themselves against that type of damage. | ||
// This means shields will become increasingly effective against things like emitters - as they will adapt to heat damage, however they will be vulnerable to brute and EM damage. | ||
// In a theoretical assault scenario, it is best to combine all damage types, so mitigation can't build up. The value is capped to prevent full scale invulnerability. | ||
|
||
#define MAX_MITIGATION_BASE 50 // % Base maximal reachable mitigation. | ||
#define MAX_MITIGATION_RESEARCH 10 // % Added to MAX_MITIGATION_BASE when generator is built using more advanced components. This value is added for each "tier" of used component, ie. basic one has 1, the best one has 3. Actual maximum should be 80% in this case (with best components). Make sure you won't get above 100%! | ||
#define MITIGATION_HIT_GAIN 5 // Mitigation gain per hit of respective damage type. | ||
#define MITIGATION_HIT_LOSS 4 // Mitigation loss per hit. If we get hit once by EM damage type, EM mitigation will grow, while Physical and Heat mitigation values drop. | ||
#define MITIGATION_LOSS_PASSIVE 0.5 // Mitigation of all damage types will drop by this every tick, up to 0. | ||
|
||
// Shield modes allow you to calibrate the field to fit specific needs. It is, for example, possible to create a field that will block airflow, but let people pass by calibrating it | ||
// properly. Each enabled shield mode adds up to the upkeep power usage, however. The following defines are a multiplier - 1.5 means the power usage will be increased 1.5x. | ||
|
||
#define MODEUSAGE_HYPERKINETIC // Blocks meteors and projectile based weapons. Relatively low as the shields are primarily intended as an anti-meteor countermeasure. | ||
#define MODEUSAGE_PHOTONIC // Blocks energy weapons, and makes the field opaque. | ||
#define MODEUSAGE_NONHUMANS // Blocks most organic lifeforms, with an exception being humanoid mobs. Typical uses include carps. | ||
#define MODEUSAGE_HUMANOIDS // Blocks humanoid mobs. | ||
#define MODEUSAGE_ANORGANIC // Blocks silicon-based mobs (cyborgs, drones, FBPs, IPCs, ..) | ||
#define MODEUSAGE_ATMOSPHERIC // Blocks airflow. | ||
#define MODEUSAGE_HULL 1 // Enables hull shielding mode, which changes a square shaped field into a field that covers external hull only. | ||
#define MODEUSAGE_BYPASS // Attempts to counter shield diffusers. Puts very large EM strain on the shield when doing so. Has to be hacked. | ||
#define MODEUSAGE_OVERCHARGE 3 // Overcharges the shield, causing it to shock anyone who touches a field segment. Best used with MODE_ORGANIC_HUMANOIDS. Has to be hacked. | ||
#define MODEUSAGE_MODULATE 2 // Modulates the shield, enabling the mitigation system. | ||
|
||
// Relevant mode bitflags (maximal of 16 flags due to current BYOND limitations) | ||
#define MODEFLAG_HYPERKINETIC 1 | ||
#define MODEFLAG_PHOTONIC 2 | ||
#define MODEFLAG_NONHUMANS 4 | ||
#define MODEFLAG_HUMANOIDS 8 | ||
#define MODEFLAG_ANORGANIC 16 | ||
#define MODEFLAG_ATMOSPHERIC 32 | ||
#define MODEFLAG_HULL 64 | ||
#define MODEFLAG_BYPASS 128 | ||
#define MODEFLAG_OVERCHARGE 256 | ||
#define MODEFLAG_MODULATE 512 | ||
|
||
// Return codes for shield hits. | ||
#define SHIELD_ABSORBED 1 // The shield has completely absorbed the hit | ||
#define SHIELD_BREACHED_MINOR 2 // The hit was absorbed, but a small gap will be created in the field (1-3 tiles) | ||
#define SHIELD_BREACHED_MAJOR 3 // Same as above, with 2-5 tile gap | ||
#define SHIELD_BREACHED_CRITICAL 4 // Same as above, with 4-8 tile gap | ||
#define SHIELD_BREACHED_FAILURE 5 // Same as above, with 8-16 tile gap. Occurs when the hit exhausts all remaining shield energy. | ||
|
||
#define SHIELD_OFF 0 // The shield is offline | ||
#define SHIELD_DISCHARGING 1 // The shield is shutting down and discharging. | ||
#define SHIELD_RUNNING 2 // The shield is running | ||
|
||
#define SHIELD_SHUTDOWN_DISPERSION_RATE (500 KILOWATTS) // The rate at which shield energy disperses when shutdown is initiated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/datum/wires/shield_generator | ||
holder_type = /obj/machinery/power/shield_generator/ | ||
wire_count = 5 | ||
|
||
var/const/SHIELDGEN_WIRE_POWER = 1 // Cut to disable power input into the generator. Pulse does nothing. Mend to restore. | ||
var/const/SHIELDGEN_WIRE_HACK = 2 // Pulse to hack the generator, enabling hacked modes. Cut to unhack. Mend does nothing. | ||
var/const/SHIELDGEN_WIRE_CONTROL = 4 // Cut to lock most shield controls. Mend to unlock them. Pulse does nothing. | ||
var/const/SHIELDGEN_WIRE_AICONTROL = 8 // Cut to disable AI control. Mend to restore. | ||
var/const/SHIELDGEN_WIRE_NOTHING = 16 // A blank wire that doesn't have any specific function | ||
|
||
/datum/wires/shield_generator/CanUse() | ||
var/obj/machinery/power/shield_generator/S = holder | ||
if(S.panel_open) | ||
return 1 | ||
return 0 | ||
|
||
/datum/wires/shield_generator/UpdateCut(index, mended) | ||
var/obj/machinery/power/shield_generator/S = holder | ||
switch(index) | ||
if(SHIELDGEN_WIRE_POWER) | ||
S.input_cut = !mended | ||
if(SHIELDGEN_WIRE_HACK) | ||
if(!mended) | ||
S.hacked = 0 | ||
if(S.check_flag(MODEFLAG_BYPASS)) | ||
S.toggle_flag(MODEFLAG_BYPASS) | ||
if(S.check_flag(MODEFLAG_OVERCHARGE)) | ||
S.toggle_flag(MODEFLAG_OVERCHARGE) | ||
if(SHIELDGEN_WIRE_CONTROL) | ||
S.mode_changes_locked = !mended | ||
if(SHIELDGEN_WIRE_AICONTROL) | ||
S.ai_control_disabled = !mended | ||
|
||
/datum/wires/shield_generator/UpdatePulsed(var/index) | ||
var/obj/machinery/power/shield_generator/S = holder | ||
switch(index) | ||
if(SHIELDGEN_WIRE_HACK) | ||
S.hacked = 1 | ||
|
||
/datum/wires/shield_generator/GetInteractWindow() | ||
var/obj/machinery/power/shield_generator/S = holder | ||
. += ..() | ||
. += "<BR>A red light labeled \"Safety Override\" is [S.hacked ? "blinking" : "off"]." | ||
. += "<BR>A green light labeled \"Power Connection\" is [S.input_cut ? "off" : "on"]." | ||
. += "<BR>A blue light labeled \"Network Control\" is [S.ai_control_disabled ? "off" : "on"]." | ||
. += "<BR>A yellow light labeled \"Interface Connection\" is [S.mode_changes_locked ? "off" : "on"].<BR>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,61 @@ | ||
#define METEOR_DELAY 6000 | ||
|
||
#define METEOR_DELAY 30 MINUTES // This should be enough for crew to set up. | ||
#define METEOR_DELAY_MULTIPLIER 5 // 5x larger duration between waves. That ensures the mode is less of a instant destruction of the station, and more of a continous stress. | ||
// In general, a PVE oriented game mode. A middle ground between Extended and actual antagonist based rounds. | ||
/datum/game_mode/meteor | ||
name = "Meteor" | ||
round_description = "The space station has been stuck in a major meteor shower." | ||
extended_round_description = "The station is on an unavoidable collision course with an asteroid field. The station will be continuously slammed with meteors, venting hallways, rooms, and ultimately destroying a majority of the basic life functions of the entire structure. Coordinate with your fellow crew members to survive the inevitable destruction of the station and get back home in one piece!" | ||
round_description = "The space station is about to enter an asteroid belt!" | ||
extended_round_description = "The station is on an unavoidable collision course with an asteroid field. You have only a moment to prepare before the station is barraged by dust and meteors. As if it was not enough, all kinds of negative events seem to happen more frequently. Good Luck." | ||
config_tag = "meteor" | ||
required_players = 0 | ||
votable = 0 | ||
deny_respawn = 1 | ||
var/next_wave = METEOR_DELAY | ||
required_players = 5 // Definitely not good for low-pop | ||
votable = 1 | ||
var/next_wave = INFINITY // Set in post_setup() correctly to take into account potential longer pre-start times. | ||
var/alert_sent = 0 | ||
var/meteor_severity = 1 // Slowly increases the tension at the beginning of meteor strikes. Prevents "tunguska on first wave" style problems. | ||
var/alert_title | ||
var/alert_text | ||
var/start_text | ||
|
||
event_delay_mod_moderate = 0.5 // As a bonus, more frequent events. | ||
event_delay_mod_major = 0.5 | ||
|
||
/datum/game_mode/meteor/post_setup() | ||
defer_powernet_rebuild = 2//Might help with the lag | ||
..() | ||
alert_title = "Automated Beacon AB-[rand(10, 99)]" | ||
alert_text = "This is an automatic warning. Your facility: [using_map.full_name] is on a collision course with a nearby asteroid belt. Estimated time until impact is: [METEOR_DELAY / 240] MINUTES. Please perform necessary actions to secure your ship or station from the threat. Have a nice day." | ||
start_text = "This is an automatic warning. Your facility: [using_map.full_name] has entered an asteroid belt. For your safety, please consider changing course or using protective equipment. Have a nice day." | ||
next_wave = round_duration_in_ticks + METEOR_DELAY | ||
|
||
/datum/game_mode/meteor/process() | ||
if(world.time >= next_wave) | ||
next_wave = world.time + meteor_wave_delay | ||
spawn() spawn_meteors(6, meteors_normal) | ||
|
||
/datum/game_mode/meteor/declare_completion() | ||
var/text | ||
var/survivors = 0 | ||
for(var/mob/living/player in player_list) | ||
if(player.stat != DEAD) | ||
var/area/A = get_area(player) | ||
if(!A) | ||
continue | ||
if(is_type_in_list(A, using_map.post_round_safe_areas)) | ||
text += "<br><b><font size=2>[player.real_name] escaped in an emergenchy vehicle.</font></b>" | ||
else | ||
text += "<br><font size=1>[player.real_name] survived but is stranded without any hope of rescue.</font>" | ||
survivors++ | ||
|
||
if(survivors) | ||
to_world("<span class='notice'><B>The following survived the meteor storm</B></span>:[text]") | ||
else | ||
to_world("<span class='notice'><B>Nobody survived the meteor storm!</B></span>") | ||
// Send an alert halfway through the round. | ||
if((round_duration_in_ticks >= (next_wave / 2)) && !alert_sent) | ||
alert_sent = 1 | ||
command_announcement.Announce(alert_text, alert_title) | ||
// And then another one when the meteors start flying around. | ||
if((round_duration_in_ticks >= next_wave) && (alert_sent == 1)) | ||
alert_sent = 2 | ||
command_announcement.Announce(start_text, alert_title) | ||
|
||
if(round_duration_in_ticks >= next_wave) | ||
next_wave = round_duration_in_ticks + (meteor_wave_delay * METEOR_DELAY_MULTIPLIER) | ||
// Starts as barely noticeable dust impact, ends as barrage of most severe meteor types the code has to offer. Have fun. | ||
spawn() | ||
spawn_meteors(meteor_severity, get_meteor_types(), pick(cardinal)) | ||
if(prob(25)) | ||
meteor_severity = min(meteor_severity + 1, 10) | ||
|
||
/datum/game_mode/meteor/proc/get_meteor_types() | ||
switch(meteor_severity) | ||
if(1 to 3) | ||
return meteors_dust | ||
if(4 to 6) | ||
return meteors_normal | ||
if(7 to 9) | ||
return meteors_threatening | ||
if(10) | ||
return meteors_catastrophic | ||
// Just in case we /somehow/ get here (looking at you, varedit) | ||
return meteors_normal | ||
|
||
feedback_set_details("round_end_result","end - evacuation") | ||
feedback_set("round_end_result",survivors) | ||
|
||
..() | ||
return 1 | ||
|
||
#undef METEOR_DELAY | ||
|
||
#undef METEOR_DELAY_MULTIPLIER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.