Skip to content
This repository has been archived by the owner on May 30, 2022. It is now read-only.

Commit

Permalink
Unlockable Flock Structures! Also Endgame! (#63)
Browse files Browse the repository at this point in the history
* tah-dah

* also relays get unlocked at 1000 compute

* added a break statement on finding the wanted structure

* we do a little coding

* achievements and cheats

* Update code/datums/abilities/flock/flockmind.dm

Co-authored-by: stonepillars <65367576+stonepillars@users.noreply.github.com>

* added friendly name to the unlockable structure datum, instead of calling initial()

* whoops

Co-authored-by: stonepillars <65367576+stonepillars@users.noreply.github.com>
  • Loading branch information
amylizzle and stonepillars authored Apr 6, 2022
1 parent 8c7c291 commit 666f821
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 22 deletions.
32 changes: 20 additions & 12 deletions code/datums/abilities/flock/flockmind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,6 @@
targeted = 0

/datum/targetable/flockmindAbility/createStructure/cast()
var/resourcecost = null
var/structurewantedtype = null
var/turf/T = get_turf(holder.owner)
if(!istype(T, /turf/simulated/floor/feather))
boutput(holder.owner, "<span class='alert'>You aren't above a flocktile.</span>")//todo maybe make this flock themed?
Expand All @@ -389,21 +387,31 @@
if(locate(/obj/flock_structure) in T)
boutput(holder.owner, "<span class='alert'>There is already a flock structure on this flocktile!</span>")
return 1

for (var/atom/O in T.contents)
if (O.density && !isflock(O))
boutput(holder.owner, "<span class='alert'>That tile has something that blocks tealprint creation!</span>")
return 1

var/list/friendlyNames = list()
var/mob/living/intangible/flock/flockmind/F = holder.owner
for(var/datum/unlockable_flock_structure/ufs as anything in F.flock.unlockableStructures)
if(ufs.check_unlocked())
friendlyNames += ufs.friendly_name


//todo: replace with FANCY tgui/chui window with WHEELS and ICONS and stuff!
var/structurewanted = tgui_input_list(holder.owner, "Select which structure you would like to create", "Tealprint selection", list("Collector", "Sentinel"))
var/structurewanted = tgui_input_list(holder.owner, "Select which structure you would like to create", "Tealprint selection", friendlyNames)

if (!structurewanted)
return TRUE
switch(structurewanted)
if("Collector")
structurewantedtype = /obj/flock_structure/collector
resourcecost = 200
if("Sentinel")
structurewantedtype = /obj/flock_structure/sentinel
resourcecost = 300
var/obj/flock_structure/structurewantedtype = null
for(var/datum/unlockable_flock_structure/ufs as anything in F.flock.unlockableStructures)
if(ufs.friendly_name == structurewanted)
structurewantedtype = ufs.structType
break

if(structurewantedtype)
var/mob/living/intangible/flock/F = holder.owner
F.createstructure(structurewantedtype, resourcecost)
F.createstructure(structurewantedtype, initial(structurewantedtype.resourcecost))


32 changes: 23 additions & 9 deletions code/datums/flock/flock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
var/list/annotation_viewers = list()
var/list/annotations = list() // key is atom ref, value is image
var/list/obj/flock_structure/structures = list()
var/list/datum/unlockable_flock_structure/unlockableStructures = list()
///list of strings that lets flock record achievements for structure unlocks
var/list/achievements = list()
var/mob/living/intangible/flock/flockmind/flockmind
var/snoop_clarity = 80 // how easily we can see silicon messages, how easily silicons can see this flock's messages
var/snooping = 0 //are both sides of communication currently accessible?
Expand All @@ -27,6 +30,8 @@
src.name = "[pick(consonants_lower)][pick(vowels_lower)].[pick(consonants_lower)][pick(vowels_lower)]"
flocks[src.name] = src
processing_items |= src
for(var/DT in childrentypesof(/datum/unlockable_flock_structure))
src.unlockableStructures += new DT(src)

/datum/flock/ui_status(mob/user)
// only flockminds and admins allowed
Expand Down Expand Up @@ -321,6 +326,14 @@
aH.updateCompute()
// STRUCTURES

///This function only notifies the flock of the unlock, actual unlock logic is handled in the datum
/datum/flock/proc/notifyUnlockStructure(var/datum/unlockable_flock_structure/SD)
flock_speak(null, "New structure devised: [SD.friendly_name]", src)

///This function only notifies the flock of the relock, actual unlock logic is handled in the datum
/datum/flock/proc/notifyRelockStructure(var/datum/unlockable_flock_structure/SD)
flock_speak(null, "Alert, structure tealprint disabled: [SD.friendly_name]", src)

/datum/flock/proc/registerStructure(var/atom/movable/S)
if(isflockstructure(S))
src.structures |= S
Expand Down Expand Up @@ -447,24 +460,25 @@
// tile got killed, remove it
floors_no_longer_existing |= T
continue
// check adjacent tiles to see if we've been surrounded and can start generating, or if we're no longer surrounded and can't generate
// var/validNeighbors = 0
// var/list/neighbors = getNeighbors(T, cardinal)
// for(var/turf/simulated/floor/feather/F in neighbors)
// validNeighbors += 1
// if(validNeighbors < 4 && T.generating)
// T.off()
// else if(validNeighbors >= 4 && !T.generating)
// T.on()

if(floors_no_longer_existing.len > 0)
src.all_owned_tiles -= floors_no_longer_existing

for(var/datum/unlockable_flock_structure/ufs as anything in src.unlockableStructures)
ufs.process()

/datum/flock/proc/convert_turf(var/turf/T, var/converterName)
src.unreserveTurf(converterName)
src.claimTurf(flock_convert_turf(T))
playsound(T, "sound/items/Deconstruct.ogg", 70, 1)

///Unlock an achievement (string) if it isn't already unlocked
/datum/flock/proc/achieve(var/str)
src.achievements |= str

///Unlock an achievement (string) if it isn't already unlocked
/datum/flock/proc/hasAchieved(var/str)
return (str in src.achievements)
////////////////////
// GLOBAL PROCS!!
////////////////////
Expand Down
55 changes: 55 additions & 0 deletions code/datums/flock/flockunlockable.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
ABSTRACT_TYPE(/datum/unlockable_flock_structure)
/**
* Subclass this for every new building type you add
* Override the check_unlocked() function to do whatever unlock logic you have
* If you're looking for a specific event, I recommend /datum/flock.achievements
*/
/datum/unlockable_flock_structure
var/structType = null
var/datum/flock/my_flock = null
var/unlocked = FALSE
var/friendly_name

New(var/datum/flock/F)
..()
if(F)
src.my_flock = F
var/obj/flock_structure/sT = src.structType //this is a gross hack, but needed for resolving flock_id
friendly_name = initial(sT.flock_id)

proc/process()
if(src.check_unlocked())
if(!src.unlocked)
src.my_flock.notifyUnlockStructure(src)
src.unlocked = TRUE
else if(src.unlocked)
src.my_flock.notifyRelockStructure(src)
src.unlocked = FALSE

///Returns true when unlock condition is met, false when it isn't.
proc/check_unlocked()
return FALSE

/datum/unlockable_flock_structure/relay
structType = /obj/flock_structure/relay

check_unlocked()
return src.my_flock.total_compute() > 1000

/datum/unlockable_flock_structure/collector
structType = /obj/flock_structure/collector

check_unlocked()
return TRUE

/datum/unlockable_flock_structure/sentinel
structType = /obj/flock_structure/sentinel

check_unlocked()
return TRUE

/datum/unlockable_flock_structure/compute
structType = /obj/flock_structure/compute

check_unlocked()
return src.my_flock.hasAchieved("cheatmode")
1 change: 1 addition & 0 deletions code/obj/flock/structure/collector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
desc = "Seems to be pulsing."
flock_id = "Collector"
health = 60
resourcecost = 200
/// does it draw from the local apc if its strong enough.
var/drawfromgrid = 0
/// is it active?
Expand Down
8 changes: 7 additions & 1 deletion code/obj/flock/structure/flock_structure_ghost.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@
/obj/flock_structure/ghost/New(var/atom/location, building = null, var/datum/flock/F = null, goal = 0)
..(location, F)
if(building)
var/atom/b = building
var/obj/flock_structure/b = building
icon = initial(b.icon)
icon_state = initial(b.icon_state)
src.color = COLOR_MATRIX_FLOCKMIND
src.alpha = 104
src.goal = goal //???? wuh
src.building = building
src.bound_width = initial(b.bound_width)
src.bound_height = initial(b.bound_height)
src.pixel_x = initial(b.pixel_x)
src.pixel_y = initial(b.pixel_y)
src.bound_x = initial(b.bound_x)
src.bound_y = initial(b.bound_y)
else
flock_speak(null, "ERROR: No Structure Tealprint Assigned, Deleting", flock)
qdel(src) //no exist if building null
Expand Down
2 changes: 2 additions & 0 deletions code/obj/flock/structure/flock_structure_parent.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
var/datum/flock/flock = null
//base compute provided
var/compute = 0
//resource cost for building
var/resourcecost = 50
/// can flockdrones pass through this akin to a grille? need to set USE_CANPASS to make this work however
var/passthrough = FALSE
/// not everything needs a group so dont check for everysingle god damn structure
Expand Down
1 change: 1 addition & 0 deletions code/obj/flock/structure/relay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
flock_id = "Signal Relay Broadcast Amplifier"
build_time = 30
health = 5000
resourcecost = 1000
bound_width = 160
bound_height = 160
pixel_x = -64
Expand Down
1 change: 1 addition & 0 deletions code/obj/flock/structure/sentinel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
icon_state = "sentinel"
flock_id = "Sentinel"
health = 80
resourcecost = 300
var/charge_status = NOT_CHARGED
/// 0-100 charge percent
var/charge = 0
Expand Down
1 change: 1 addition & 0 deletions goonstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ var/datum/preMapLoad/preMapLoad = new
#include "code\datums\flock\flock.dm"
#include "code\datums\flock\flockprotection.dm"
#include "code\datums\flock\flocktilegroup.dm"
#include "code\datums\flock\flockunlockable.dm"
#include "code\datums\gamemodes\arcfiend.dm"
#include "code\datums\gamemodes\assday_classic.dm"
#include "code\datums\gamemodes\battle_royale.dm"
Expand Down

0 comments on commit 666f821

Please sign in to comment.