mirror of
https://github.com/KabKebab/GS13.git
synced 2026-07-19 03:50:32 +01:00
nightmares have objectives now
This commit is contained in:
@@ -1,4 +1,20 @@
|
||||
#define LIGHTSTOBREAK_MINIMUM 25
|
||||
#define LIGHTSTOBREAK_MAXIMUM 75
|
||||
#define LIGHTSTOBREAK_THRESHOLD 50
|
||||
#define LIGHTSTOBREAK_AREA_MIN 1
|
||||
#define LIGHTSTOBREAK_AREA_MAX 2
|
||||
|
||||
/datum/antagonist/nightmare
|
||||
name = "Nightmare"
|
||||
show_in_antagpanel = FALSE
|
||||
show_name_in_check_antagonists = TRUE
|
||||
show_name_in_check_antagonists = TRUE
|
||||
|
||||
/datum/antagonist/nightmare/on_gain()
|
||||
owner.objectives += forge_objective()
|
||||
owner.objectives += new /datum/objective/survive
|
||||
|
||||
/datum/antagonist/nightmare/proc/forge_objective()
|
||||
var/datum/objective/break_lights/O = new
|
||||
O.mode = prob(50) ? TRUE : FALSE
|
||||
antag_memory = "<b>Objectives:<br>1.</b> [O.apply_rules()]<br><b>2.</b> Stay alive until the end."
|
||||
return O
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/datum/objective/break_lights
|
||||
var/mode = FALSE //If true, break all lights in determined area
|
||||
var/list/area_targets = list() //Which areas we have to keep lights broken
|
||||
target_amount = LIGHTSTOBREAK_AREA_MIN
|
||||
var/lightsbroken = 0
|
||||
|
||||
var/safe_areas = list(
|
||||
/area/space,
|
||||
/area/maintenance/solars,
|
||||
/area/maintenance/central, //HOP/Conference room APC
|
||||
/area/ai_monitored,
|
||||
/area/shuttle,
|
||||
/area/engine/engine_smes,
|
||||
/area/security/prison, //If you get unlucky, you'll have to break the lights in armory
|
||||
/area/security/execution)
|
||||
|
||||
/datum/objective/break_lights/proc/apply_rules()
|
||||
if(mode)
|
||||
var/list/valid_areas = list()
|
||||
for(var/obj/machinery/power/apc/C in GLOB.apcs_list)
|
||||
if(C.cell && is_station_level(C.z))
|
||||
var/is_safearea = 1
|
||||
for(var/A in safe_areas)
|
||||
if(istype(C.area, A))
|
||||
is_safearea = 0
|
||||
break
|
||||
if(is_safearea)
|
||||
valid_areas += C.area
|
||||
var/I = rand(LIGHTSTOBREAK_AREA_MIN, LIGHTSTOBREAK_AREA_MAX)
|
||||
for(var/N in 1 to I)
|
||||
var/area2add = pick(valid_areas)
|
||||
if(!locate(area2add) in area_targets)
|
||||
area_targets += area2add
|
||||
else
|
||||
target_amount = rand(LIGHTSTOBREAK_MINIMUM, LIGHTSTOBREAK_MAXIMUM)
|
||||
if(prob(50))
|
||||
if(target_amount > LIGHTSTOBREAK_THRESHOLD)
|
||||
target_amount = LIGHTSTOBREAK_MAXIMUM
|
||||
else if(target_amount > LIGHTSTOBREAK_THRESHOLD)
|
||||
target_amount = LIGHTSTOBREAK_THRESHOLD
|
||||
explanation_text = update_explanation_text()
|
||||
return explanation_text
|
||||
|
||||
/datum/objective/break_lights/update_explanation_text()
|
||||
..()
|
||||
if(mode)
|
||||
if(!area_targets.len)
|
||||
return "Uh oh! Something broke! Report this."
|
||||
. += "There must not be any light sources in the "
|
||||
if(area_targets.len == 1)
|
||||
var/area/A = area_targets[1]
|
||||
. += "[A.name]"
|
||||
else if(area_targets.len == 2)
|
||||
var/area/A = area_targets[1]
|
||||
var/area/B = area_targets[2]
|
||||
. += "[A.name] and [B.name]"
|
||||
else //Won't get here because of define values, but during development you can get here. leaving this here for future purposes
|
||||
var/i = 1
|
||||
for(var/area/A in area_targets)
|
||||
if(i != area_targets.len) . += "[A.name], "
|
||||
else . += "and [A.name]"
|
||||
|
||||
. += " before the end."
|
||||
else
|
||||
. += "Break at least [target_amount] lights with your light eater."
|
||||
|
||||
/datum/objective/break_lights/check_completion()
|
||||
if(completed)
|
||||
return TRUE //An attempt to stop this from being called twice
|
||||
if(!mode)
|
||||
if(lightsbroken >= target_amount)
|
||||
completed = TRUE
|
||||
else
|
||||
var/list/valid_turfs = list()
|
||||
for(var/area/target in area_targets)
|
||||
var/I = 0
|
||||
var/list/cached_area = get_area_turfs(target.type)
|
||||
for(var/turf/A in cached_area)
|
||||
if(!is_station_level(A.z))
|
||||
continue
|
||||
valid_turfs += A
|
||||
I++
|
||||
var/E = 0
|
||||
var/D = 0
|
||||
for(var/turf/T in valid_turfs)
|
||||
D++
|
||||
for(var/atom/C in T.contents)
|
||||
E++
|
||||
/*if(!C?.visibility) //Doesn't compile, add this another time
|
||||
continue*/
|
||||
if(C.light_range > 0)
|
||||
if(C.light_power <= SHADOW_SPECIES_LIGHT_THRESHOLD*2) //Give some leniency for not destroying that unbreakable requests console
|
||||
completed = TRUE
|
||||
else
|
||||
completed = FALSE
|
||||
break
|
||||
if(!completed)
|
||||
break
|
||||
|
||||
return completed
|
||||
|
||||
/datum/objective/break_lights/area
|
||||
mode = TRUE
|
||||
|
||||
|
||||
#undef LIGHTSTOBREAK_MINIMUM
|
||||
#undef LIGHTSTOBREAK_MAXIMUM
|
||||
#undef LIGHTSTOBREAK_THRESHOLD
|
||||
#undef LIGHTSTOBREAK_AREA_MIN
|
||||
#undef LIGHTSTOBREAK_AREA_MAX
|
||||
Reference in New Issue
Block a user