Adds new achieve for CEs getting 3 MW on a station powernet

A lot of shit had to happen in order to make this work.
I had to add a new specification to powernets to mark what Z-level they exist on, to ensure that I only scan powernets that're on the station Z-level.

Additionally, SSachievements now is SS_BACKGROUND instead of SS_NO_FIRE, since I didn't want to have this CE achievement bullshit happen in the middle of the very important SSmachine tick.
This commit is contained in:
Gary Lafortune
2020-01-28 20:15:35 -06:00
parent 0e73a996bc
commit 01e949c01d
5 changed files with 36 additions and 12 deletions

View File

@@ -1,10 +1,11 @@
SUBSYSTEM_DEF(achievements)
name = "Achievements"
flags = SS_NO_FIRE
flags = SS_BACKGROUND
var/list/achievements = list()
var/list/cached_achievements = list()
var/list/browsers = list()
var/list/achievementsEarned = list()
var/mob/living/carbon/human/CE // The current guy that SSachievements believes to be the CE.
/datum/controller/subsystem/achievements/Initialize(timeofday)
for(var/i in subtypesof(/datum/achievement))
@@ -47,6 +48,23 @@ SUBSYSTEM_DEF(achievements)
qdel(ridOldChieves)
return ..()
/datum/controller/subsystem/achievements/fire(resumed)
//The solar panel achievement
if(!CE)
for(var/x in GLOB.player_list)
if(ishuman(x))
var/mob/living/carbon/human/H = x
if(H?.mind.assigned_role == "Chief Engineer")
CE = H
break
else
for(var/n in SSmachines.powernets)
var/datum/powernet/net = n
if(net.z == 2) // If the powernet is on the station z-level
if(net.avail == 3000 && CE.stat != DEAD && CE.client) // If there's 3 MW available (Value is in kW)
unlock_achievement(/datum/achievement/engineering/scotty, CE.client)
//Ad-hoc procs
/datum/controller/subsystem/achievements/proc/unlock_achievement(achievementPath, client/C)
var/datum/achievement/achievement = get_achievement(achievementPath)
if(!achievement)

View File

@@ -18,7 +18,7 @@ SUBSYSTEM_DEF(machines)
for(var/obj/structure/cable/PC in GLOB.cable_list)
if(!PC.powernet)
var/datum/powernet/NewPN = new()
var/datum/powernet/NewPN = new(PC.loc.z)
NewPN.add_cable(PC)
propagate_network(PC,PC.powernet)
@@ -53,7 +53,7 @@ SUBSYSTEM_DEF(machines)
for(var/A in cables)
var/obj/structure/cable/PC = A
if(!PC.powernet)
var/datum/powernet/NewPN = new()
var/datum/powernet/NewPN = new(PC.loc.z)
NewPN.add_cable(PC)
propagate_network(PC,PC.powernet)

View File

@@ -246,6 +246,10 @@
name = "Honest Work"
desc = "Set up one of the solar arrays as part of the Engineering team."
id = ENGINEERING + 2
/datum/achievement/engineering/scotty
name = "\"I'm givin' it all she's got, Captain!\""
desc = "As Chief Engineer, produce more than three megawatts of power."
id = ENGINEERING + 3
//end-engineering
#undef GREENTEXT

View File

@@ -260,7 +260,7 @@ By design, d1 is the smallest direction and d2 is the highest
if(C.d1 == (direction^3) || C.d2 == (direction^3)) //we've got a diagonally matching cable
if(!C.powernet) //if the matching cable somehow got no powernet, make him one (should not happen for cables)
var/datum/powernet/newPN = new()
var/datum/powernet/newPN = new(C.loc.z)
newPN.add_cable(C)
if(powernet) //if we already have a powernet, then merge the two powernets
@@ -280,7 +280,7 @@ By design, d1 is the smallest direction and d2 is the highest
continue
if(C.d1 == (direction^12) || C.d2 == (direction^12)) //we've got a diagonally matching cable
if(!C.powernet) //if the matching cable somehow got no powernet, make him one (should not happen for cables)
var/datum/powernet/newPN = new()
var/datum/powernet/newPN = new(C.loc.z)
newPN.add_cable(C)
if(powernet) //if we already have a powernet, then merge the two powernets
@@ -308,7 +308,7 @@ By design, d1 is the smallest direction and d2 is the highest
if(C.d1 == fdir || C.d2 == fdir) //we've got a matching cable in the neighbor turf
if(!C.powernet) //if the matching cable somehow got no powernet, make him one (should not happen for cables)
var/datum/powernet/newPN = new()
var/datum/powernet/newPN = new(C.loc.z)
newPN.add_cable(C)
if(powernet) //if we already have a powernet, then merge the two powernets
@@ -321,7 +321,7 @@ By design, d1 is the smallest direction and d2 is the highest
var/list/to_connect = list()
if(!powernet) //if we somehow have no powernet, make one (should not happen for cables)
var/datum/powernet/newPN = new()
var/datum/powernet/newPN = new(loc.z)
newPN.add_cable(src)
//first let's add turf cables to our powernet
@@ -410,7 +410,7 @@ By design, d1 is the smallest direction and d2 is the highest
var/list/powerlist = power_list(T1,src,0,0) //find the other cables that ended in the centre of the turf, with or without a powernet
if(powerlist.len>0)
var/datum/powernet/PN = new()
var/datum/powernet/PN = new(loc.z)
propagate_network(powerlist[1],PN) //propagates the new powernet beginning at the source cable
if(PN.is_empty()) //can happen with machines made nodeless when smoothing cables
@@ -418,7 +418,7 @@ By design, d1 is the smallest direction and d2 is the highest
/obj/structure/cable/proc/auto_propogate_cut_cable(obj/O)
if(O && !QDELETED(O))
var/datum/powernet/newPN = new()// creates a new powernet...
var/datum/powernet/newPN = new(loc.z)// creates a new powernet...
propagate_network(O, newPN)//... and propagates it to the other side of the cable
// cut the cable's powernet at this cable and updates the powergrid
@@ -620,7 +620,7 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
C.update_icon()
//create a new powernet with the cable, if needed it will be merged later
var/datum/powernet/PN = new()
var/datum/powernet/PN = new(loc.z)
PN.add_cable(C)
C.mergeConnectedNetworks(C.d2) //merge the powernet with adjacents powernets
@@ -692,7 +692,7 @@ GLOBAL_LIST_INIT(cable_coil_recipes, list (new/datum/stack_recipe("cable restrai
NC.update_icon()
//create a new powernet with the cable, if needed it will be merged later
var/datum/powernet/newPN = new()
var/datum/powernet/newPN = new(loc.z)
newPN.add_cable(NC)
NC.mergeConnectedNetworks(NC.d2) //merge the powernet with adjacents powernets

View File

@@ -14,9 +14,11 @@
var/viewload = 0 // the load as it appears on the power console (gradually updated)
var/netexcess = 0 // excess power on the powernet (typically avail-load)///////
var/delayedload = 0 // load applied to powernet between power ticks.
var/z = 0 // the Z coordinate of this powernet. Only used by some random achievement, at the moment.
/datum/powernet/New()
/datum/powernet/New(newz)
SSmachines.powernets += src
z = newz
/datum/powernet/Destroy()
//Go away references, you suck!