Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storytellers #6463

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
32 changes: 32 additions & 0 deletions citadel.dme
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@
#include "code\__DEFINES\fishing\aquarium.dm"
#include "code\__DEFINES\fishing\fish.dm"
#include "code\__DEFINES\fishing\fishing.dm"
#include "code\__DEFINES\game\objectives.dm"
#include "code\__DEFINES\game\storytellers.dm"
#include "code\__DEFINES\game\system.dm"
#include "code\__DEFINES\hardsuits\breaches.dm"
#include "code\__DEFINES\interface\skin.dm"
#include "code\__DEFINES\interface\verbs.dm"
Expand Down Expand Up @@ -581,6 +584,7 @@
#include "code\controllers\subsystem\spatial_grids.dm"
#include "code\controllers\subsystem\statpanel.dm"
#include "code\controllers\subsystem\status_effects.dm"
#include "code\controllers\subsystem\storyteller.dm"
#include "code\controllers\subsystem\sun.dm"
#include "code\controllers\subsystem\supply.dm"
#include "code\controllers\subsystem\tgui.dm"
Expand Down Expand Up @@ -1044,6 +1048,27 @@
#include "code\game\atoms\movable\vv.dm"
#include "code\game\atoms\movable\special\overlay.dm"
#include "code\game\atoms\movable\special\render.dm"
#include "code\game\backend\game\game_entity.dm"
#include "code\game\backend\game\game_faction.dm"
#include "code\game\backend\game\game_location.dm"
#include "code\game\backend\game\game_objective.dm"
#include "code\game\backend\game\entities\basic.dm"
#include "code\game\backend\game\entities\character.dm"
#include "code\game\backend\game\locations\movable_entity.dm"
#include "code\game\backend\game\locations\overmap_entity.dm"
#include "code\game\backend\game\locations\specific_turf.dm"
#include "code\game\backend\game\objectives\secure.dm"
#include "code\game\backend\game\objectives\survive.dm"
#include "code\game\backend\game\objectives\overmaps\overmap_unary.dm"
#include "code\game\backend\storyteller\storyteller_driver.dm"
#include "code\game\backend\storyteller\storyteller_entity.dm"
#include "code\game\backend\storyteller\storyteller_faction.dm"
#include "code\game\backend\storyteller\storyteller_location.dm"
#include "code\game\backend\storyteller\storyteller_pawn.dm"
#include "code\game\backend\storyteller\storyteller_role.dm"
#include "code\game\backend\storyteller\storyteller_state.dm"
#include "code\game\backend\storyteller\entity\overmap_standalone.dm"
#include "code\game\backend\storyteller\entity\sector_spawn.dm"
#include "code\game\backend\world\world_faction.dm"
#include "code\game\backend\world\world_location.dm"
#include "code\game\click\adjacency.dm"
Expand All @@ -1062,6 +1087,11 @@
#include "code\game\click\reachability.dm"
#include "code\game\click\rig.dm"
#include "code\game\click\telekinesis.dm"
#include "code\game\content\factions\generic\generic_factions.dm"
#include "code\game\content\factions\generic\frontier\frontier_factions.dm"
#include "code\game\content\factions\species\species_factions.dm"
#include "code\game\content\factions\species\moth\moth_factions.dm"
#include "code\game\content\factions\species\vox\vox_factions.dm"
#include "code\game\content\enigmas\unsorted\cursedform.dm"
#include "code\game\content\enigmas\unsorted\deadringer.dm"
#include "code\game\content\enigmas\unsorted\telecube.dm"
Expand Down Expand Up @@ -2093,6 +2123,7 @@
#include "code\modules\admin\admin.dm"
#include "code\modules\admin\admin_attack_log.dm"
#include "code\modules\admin\admin_memo.dm"
#include "code\modules\admin\admin_panel.dm"
#include "code\modules\admin\admin_ranks.dm"
#include "code\modules\admin\admin_secrets.dm"
#include "code\modules\admin\admin_tools.dm"
Expand All @@ -2119,6 +2150,7 @@
#include "code\modules\admin\callproc\callproc.dm"
#include "code\modules\admin\DB ban\functions.dm"
#include "code\modules\admin\functions\modify_traits.dm"
#include "code\modules\admin\panels\game.dm"
#include "code\modules\admin\permissionverbs\permissionedit.dm"
#include "code\modules\admin\secrets\admin_secrets\admin_logs.dm"
#include "code\modules\admin\secrets\admin_secrets\alter_narsie.dm"
Expand Down
3 changes: 2 additions & 1 deletion code/__DEFINES/controllers/_subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ DEFINE_BITFIELD(runlevels, list(
#define INIT_ORDER_XENOARCH -50
#define INIT_ORDER_CIRCUIT -60
#define INIT_ORDER_AI -70
#define INIT_ORDER_CHAT -100 //! Should be last to ensure chat remains smooth during init.
#define INIT_ORDER_STORYTELLER -900
#define INIT_ORDER_CHAT -1000 //! Should be last to ensure chat remains smooth during init.


/**
Expand Down
17 changes: 17 additions & 0 deletions code/__DEFINES/game/objectives.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2023 Citadel Station developers. *//

//* Objective completion status

/// default - unknown
#define GAME_OBJECTIVE_UNKNOWN 0
/// got the target/whatever
#define GAME_OBJECTIVE_SUCCESS 1
/// didn't yet get the target/whatever
#define GAME_OBJECTIVE_INCOMPLETE 2
/// failed to get the target (e.g. not physically able to anymore)
#define GAME_OBJECTIVE_FAILURE 3
/// target is no longer valid, but it isn't a failure
#define GAME_OBJECTIVE_VOIDED 4
/// cataclysmic failure
#define GAME_ObJECTIVE_BACKFIRED 5
12 changes: 12 additions & 0 deletions code/__DEFINES/game/storytellers.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2023 Citadel Station developers. *//

//* persistent state keys *//

// none right now

//* local state keys *//

// none right now

#warn impl

Check warning on line 12 in code/__DEFINES/game/storytellers.dm

View workflow job for this annotation

GitHub Actions / Run Linters

#warn impl
13 changes: 13 additions & 0 deletions code/__DEFINES/game/system.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 silicons *//

//* Tracking levels; determines how detailed to get with tracking something.

/// just say what, don't track
#define GAME_SYSTEM_TRACKING_LEVEL_NONE 0
/// say roughly where (ship, planet, etc)
#define GAME_SYSTEM_TRACKING_LEVEL_SECTOR 1
/// say roughly where on the map (area, etc)
#define GAME_SYSTEM_TRACKING_LEVEL_AREA 2
/// give exact location
#define GAME_SYSTEM_TRACKING_LEVEL_PINPOINT 3
39 changes: 21 additions & 18 deletions code/__HELPERS/unsorted/contents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,15 @@
var/list/processing_list = list(src)
var/i = 0
var/lim = 1
if(target)
. = list()
while(i < lim)
var/atom/A = processing_list[++i]
/**
* Byond does not allow things to be in multiple contents, or double parent-child hierarchies, so only += is needed.
* This is also why we don't need to check against assembled as we go along.
*/
processing_list += A.contents
lim = processing_list.len
if(istype(A, target))
. += A
else
while(i < lim)
var/atom/A = processing_list[++i]
processing_list += A.contents
lim = processing_list.len
return processing_list
while(i < lim)
var/atom/A = processing_list[++i]
processing_list += A.contents
lim = processing_list.len
return processing_list

/**
* Gets all contents of contents and returns them all in a list, ignoring atoms that match a typecache
*/
/atom/proc/get_all_contents_ignoring(list/ignore_typecache)
if(!length(ignore_typecache))
return get_all_contents()
Expand All @@ -37,3 +27,16 @@
processing += A.contents
lim = processing.len
. += A

/**
* checks if something is in our contents or the contents of our contents up to infinite depth
*
* todo: add depth limit
*/
/atom/proc/is_in_nested_contents(atom/movable/thing)
var/atom/iter = thing.loc
while(iter)
if(iter == src)
return TRUE
iter = iter.loc
return FALSE
89 changes: 89 additions & 0 deletions code/controllers/subsystem/storyteller.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* Storyteller system
*
* Runs the round's default content, determines when to do stuff, etc
*
* todo:
* * SSevents should only tick event instances & hold event data; we handle the triggering/etc
*/
SUBSYSTEM_DEF(storyteller)
name = "Storyteller"
wait = 30 SECONDS
init_order = INIT_ORDER_STORYTELLER

/// driver template
var/datum/storyteller_driver/storyteller_driver
/// current state
var/datum/storyteller_state/storyteller_state

/// factions by ID
var/list/world_faction_lookup

#warn world factions

Check warning on line 22 in code/controllers/subsystem/storyteller.dm

View workflow job for this annotation

GitHub Actions / Run Linters

#warn world factions

// todo: configured time & some randomization
var/legacy_intercept_time = 15 MINUTES

#warn impl

Check warning on line 27 in code/controllers/subsystem/storyteller.dm

View workflow job for this annotation

GitHub Actions / Run Linters

#warn impl

/datum/controller/subsystem/storyteller/Initialize()
create_factions()
create_state()
create_driver()
pregame_cycle()
return ..()

// todo: Recover()

/datum/controller/subsystem/storyteller/proc/create_factions()
world_faction_lookup = list()
world_factions = list()

Check failure on line 40 in code/controllers/subsystem/storyteller.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "world_factions"
for(var/datum/world_faction/faction as anything in subtypesof(/datum/world_faction))
if(initial(faction.abstract_type) == faction)
continue
faction = new faction
world_faction_lookup[faction.id] = faction

/datum/controller/subsystem/storyteller/proc/create_state()
storyteller_state = new

/datum/controller/subsystem/storyteller/proc/create_driver()
storyteller_driver = new
// todo: verify map values are valid
storyteller_driver.primary_faction_id = SSmapping.loaded_station.world_faction_id
storyteller_driver.world_location_ids = SSmapping.loaded_station.world_location_ids
#warn impl

Check warning on line 55 in code/controllers/subsystem/storyteller.dm

View workflow job for this annotation

GitHub Actions / Run Linters

#warn impl

/**
* called at some point before roundstart, probably during init
*/
/datum/controller/subsystem/storyteller/proc/pregame_cycle()

SSticker.OnRoundstart(CALLBACK(src, PROC_REF(roundstart_cycle)))

/**
* called on roundstart, right after everyone's loaded in
*/
/datum/controller/subsystem/storyteller/proc/roundstart_cycle()

addtimer(CALLBACK(src, PROC_REF(trigger_intercept_cycle)), legacy_intercept_time)


// todo: this is a bad proc
/datum/controller/subsystem/storyteller/proc/trigger_intercept_cycle()
intercept_cycle()

/**
* called at configured intercept time
*/
/datum/controller/subsystem/storyteller/proc/intercept_cycle()

/**
* called every minute
*/
/datum/controller/subsystem/storyteller/proc/midround_cycle()

/**
* called right before roundend completion is declared
*/
/datum/controller/subsystem/storyteller/proc/roundend_cycle()
16 changes: 15 additions & 1 deletion code/controllers/subsystem/ticker.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/**
* Ticker Subsystem
*
* While the Storyteller and World subsystems handle providing round content and storing IC definitions,
* we actually **tick** the round's flow, handling critical things like startup/shutdown of a given round.
*/
SUBSYSTEM_DEF(ticker)
name = "Ticker"
wait = 20
wait = 2 SECONDS
init_order = INIT_ORDER_TICKER
runlevels = RUNLEVEL_LOBBY | RUNLEVEL_SETUP | RUNLEVEL_GAME | RUNLEVEL_POSTGAME

Expand Down Expand Up @@ -68,6 +74,13 @@
var/static/list/round_start_events
var/static/list/round_end_events

//* Game State
/// game factions
var/list/datum/game_faction/game_factions
/// objectives that need ticking
var/list/datum/game_objective/game_objectives_ticking
#warn hook stuff

Check warning on line 82 in code/controllers/subsystem/ticker.dm

View workflow job for this annotation

GitHub Actions / Run Linters

#warn hook stuff

/datum/controller/subsystem/ticker/Initialize()
if(!syndicate_code_phrase)
syndicate_code_phrase = generate_code_phrase()
Expand Down Expand Up @@ -536,6 +549,7 @@
roundend_callbacks.InvokeAsync()
LAZYCLEARLIST(round_end_events)

#warn roundend stuff

Check warning on line 552 in code/controllers/subsystem/ticker.dm

View workflow job for this annotation

GitHub Actions / Run Linters

#warn roundend stuff

for(var/mob/Player in GLOB.player_list)
if(Player.mind && !isnewplayer(Player))
Expand Down
Loading
Loading