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

shiptraits attempt2 #337

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include "code\__defines\skills.dm"
#include "code\__defines\spaceman_dmm.dm"
#include "code\__defines\species.dm"
#include "code\__defines\station.dm"
#include "code\__defines\subsystem-priority.dm"
#include "code\__defines\subsystems.dm"
#include "code\__defines\targeting.dm"
Expand Down Expand Up @@ -266,6 +267,7 @@
#include "code\controllers\subsystems\processing\obj.dm"
#include "code\controllers\subsystems\processing\processing.dm"
#include "code\controllers\subsystems\processing\psi.dm"
#include "code\controllers\subsystems\processing\station.dm"
#include "code\controllers\subsystems\processing\temperature.dm"
#include "code\controllers\subsystems\processing\turf.dm"
#include "code\controllers\subsystems\processing\vines.dm"
Expand Down Expand Up @@ -476,6 +478,10 @@
#include "code\datums\repositories\crew\tracking.dm"
#include "code\datums\repositories\crew\vital.dm"
#include "code\datums\repositories\crew\~defines.dm"
#include "code\datums\station_traits\_station_trait.dm"
#include "code\datums\station_traits\negative.dm"
#include "code\datums\station_traits\neutral.dm"
#include "code\datums\station_traits\positive.dm"
#include "code\datums\supplypacks\atmospherics.dm"
#include "code\datums\supplypacks\custodial.dm"
#include "code\datums\supplypacks\dispcarts.dm"
Expand Down
3 changes: 3 additions & 0 deletions code/__defines/station.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define STATION_TRAIT_POSITIVE 1
#define STATION_TRAIT_NEUTRAL 2
#define STATION_TRAIT_NEGATIVE 3
23 changes: 12 additions & 11 deletions code/__defines/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ return;\
// Subsystem init_order, from highest priority to lowest priority
// Subsystems shutdown in the reverse of the order they initialize in
// The numbers just define the ordering, they are meaningless otherwise.
#define SS_INIT_DBCORE 20
#define SS_INIT_INPUT 19
#define SS_INIT_EARLY 18
#define SS_INIT_GARBAGE 17
#define SS_INIT_CHEMISTRY 16
#define SS_INIT_MATERIALS 15
#define SS_INIT_PLANTS 14
#define SS_INIT_ANTAGS 13
#define SS_INIT_CULTURE 12
#define SS_INIT_MISC 11
#define SS_INIT_SKYBOX 10
#define SS_INIT_DBCORE 21
#define SS_INIT_INPUT 20
#define SS_INIT_EARLY 19
#define SS_INIT_GARBAGE 18
#define SS_INIT_CHEMISTRY 17
#define SS_INIT_MATERIALS 16
#define SS_INIT_PLANTS 15
#define SS_INIT_ANTAGS 14
#define SS_INIT_CULTURE 13
#define SS_INIT_MISC 12
#define SS_INIT_SKYBOX 11
#define SS_INIT_STATION 10
#define SS_INIT_MAPPING 9
#define SS_INIT_JOBS 8
#define SS_INIT_CHAR_SETUP 7
Expand Down
3 changes: 3 additions & 0 deletions code/_helpers/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ datum/projectile_data
viewY = text2num(viewrangelist[2])
return list(viewX, viewY)

/proc/has_station_trait(var/trait)
return is_path_in_list(trait, SSstation.station_traits)

/proc/count_living()
var/counter = 0

Expand Down
5 changes: 5 additions & 0 deletions code/_helpers/global_access.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@
return global.SSshuttle;
if("SSskybox")
return global.SSskybox;
if("SSstation")
return global.SSstation;
if("SSstatistics")
return global.SSstatistics;
if("SSstickyban")
Expand Down Expand Up @@ -1020,6 +1022,8 @@
global.SSshuttle=newval;
if("SSskybox")
global.SSskybox=newval;
if("SSstation")
global.SSstation=newval;
if("SSstatistics")
global.SSstatistics=newval;
if("SSstickyban")
Expand Down Expand Up @@ -1843,6 +1847,7 @@
"SSrobots",
"SSshuttle",
"SSskybox",
"SSstation",
"SSstatistics",
"SSstickyban",
"SSsun",
Expand Down
52 changes: 52 additions & 0 deletions code/controllers/subsystems/processing/station.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
PROCESSING_SUBSYSTEM_DEF(station)
name = "Station"
init_order = SS_INIT_STATION
flags = SS_BACKGROUND
runlevels = RUNLEVEL_GAME
wait = 5 SECONDS

///A list of currently active station traits
var/list/station_traits = list()
///Assoc list of trait type || assoc list of traits with weighted value. Used for picking traits from a specific category.
var/list/selectable_traits_by_types = list(STATION_TRAIT_POSITIVE = list(), STATION_TRAIT_NEUTRAL = list(), STATION_TRAIT_NEGATIVE = list())

/datum/controller/subsystem/processing/station/Initialize()

// We don't need station traits if doing unit tests.
#ifndef UNIT_TEST
SetupTraits()
#endif

return ..()

///Rolls for the amount of traits and adds them to the traits list
/datum/controller/subsystem/processing/station/proc/SetupTraits()
station_traits = list() // In case of re-rolls to avoid 999 traits
for(var/i in subtypesof(/datum/station_trait))
var/datum/station_trait/trait_typepath = i
selectable_traits_by_types[initial(trait_typepath.trait_type)][trait_typepath] = initial(trait_typepath.weight)

var/positive_trait_count = pick(14;0, 5;1, 1;2)
var/neutral_trait_count = pick(12;0, 6;1, 2;2)
var/negative_trait_count = pick(14;0, 5;1, 1;2)

pick_traits(STATION_TRAIT_POSITIVE, positive_trait_count)
pick_traits(STATION_TRAIT_NEUTRAL, neutral_trait_count)
pick_traits(STATION_TRAIT_NEGATIVE, negative_trait_count)

///Picks traits of a specific category (e.g. bad or good) and a specified amount, then initializes them and adds them to the list of traits.
/datum/controller/subsystem/processing/station/proc/pick_traits(trait_type, amount)
if(!amount)
return
for(var/iterator in 1 to amount)
var/datum/station_trait/picked_trait = pickweight(selectable_traits_by_types[trait_type]) //Rolls from the table for the specific trait type
if(!picked_trait) // Empty!
break
selectable_traits_by_types[trait_type] -= picked_trait // No duplicates
picked_trait = new picked_trait()
station_traits += picked_trait
if(!picked_trait.blacklist)
continue
for(var/i in picked_trait.blacklist)
var/datum/station_trait/trait_to_remove = i
selectable_traits_by_types[initial(trait_to_remove.trait_type)] -= trait_to_remove
1 change: 1 addition & 0 deletions code/controllers/subsystems/supply.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SUBSYSTEM_DEF(supply)

//supply points
var/points = 50
var/pack_price_modifier = 1 //The modifier multiplied to the value of cargo pack prices.
var/points_per_process = 1
var/points_per_slip = 2
var/point_sources = list()
Expand Down
16 changes: 16 additions & 0 deletions code/controllers/subsystems/ticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ SUBSYSTEM_DEF(ticker)

var/list/bad_modes = list() //Holds modes we tried to start and failed to.
var/revotes_allowed = 0 //How many times a game mode revote might be attempted before giving up.
var/list/round_start_events


var/end_game_state = END_GAME_NOT_OVER
var/delay_end = 0 //Can be set true to postpone restart.
Expand Down Expand Up @@ -97,6 +99,11 @@ SUBSYSTEM_DEF(ticker)
if(job && job.create_record)
CreateModularRecord(H)

for(var/I in round_start_events)
var/datum/callback/cb = I
cb.InvokeAsync()
LAZYCLEARLIST(round_start_events)

callHook("roundstart")

spawn(0)//Forking here so we dont have to wait for this to finish
Expand All @@ -116,6 +123,15 @@ SUBSYSTEM_DEF(ticker)
config.ooc_allowed = 0
to_world("<B>OOC чат отключен!</B>")

/datum/controller/subsystem/ticker/proc/OnRoundstart(datum/callback/cb)
if(!HasRoundStarted())
LAZYADD(round_start_events, cb)
else
cb.InvokeAsync()

/datum/controller/subsystem/ticker/proc/HasRoundStarted()
return GAME_STATE >= RUNLEVEL_GAME

/datum/controller/subsystem/ticker/proc/playing_tick()
mode.process()
var/mode_finished = mode_finished()
Expand Down
31 changes: 31 additions & 0 deletions code/datums/station_traits/_station_trait.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
///Base class of station traits. These are used to influence rounds in one way or the other by influencing the levers of the station.
/datum/station_trait
///Name of the trait
var/name = "unnamed station trait"
///The type of this trait. Used to classify how this trait influences the station
var/trait_type = STATION_TRAIT_NEUTRAL
///Whether or not this trait uses process()
var/trait_processes = FALSE
///Chance relative to other traits of its type to be picked
var/weight = 10
///Does this trait show in the centcom report?
var/show_in_report = FALSE
///What message to show in the centcom report?
var/report_message
///What traits are incompatible with this one?
var/blacklist


/datum/station_trait/New()
. = ..()
SSticker.OnRoundstart(CALLBACK(src, .proc/on_round_start))
if(trait_processes)
START_PROCESSING(SSstation, src)

///Proc ran when round starts. Use this for roundstart effects.
/datum/station_trait/proc/on_round_start()
return

///type of info the roundstart report has on this trait, if any.
/datum/station_trait/proc/get_report()
return "[name] - [report_message]"
45 changes: 45 additions & 0 deletions code/datums/station_traits/negative.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/datum/station_trait/slow_shuttle
name = "Slow Shuttle"
trait_type = STATION_TRAIT_NEGATIVE
weight = 2
show_in_report = TRUE
report_message = "Из-за отдаленности до станции снабжения, доставка грузов на шаттле замедленна."
blacklist = list(/datum/station_trait/quick_shuttle)

/datum/station_trait/slow_shuttle/on_round_start()
SSsupply.movetime = 1500

/datum/station_trait/disabled_lighting
name = "Overloaded Lighting"
trait_type = STATION_TRAIT_NEGATIVE
weight = 3
show_in_report = TRUE
report_message = "Корабль пережил легкий электрический шторм, и поэтому некоторые лампы могут потребовать замены."

/datum/station_trait/disabled_lighting/on_round_start()
for(var/obj/machinery/power/apc/C in SSmachines.machinery)
if(!C.is_critical && (C.z in GLOB.using_map.station_levels))
C.overload_lighting(25) // Every fourth light

/datum/station_trait/cargo_penalty
name = "Cargo Penalty"
trait_type = STATION_TRAIT_NEGATIVE
weight = 3
show_in_report = TRUE
report_message = "Ваш корабль израсходовал квоту снабжения, количество очков снабжения - урезано."

/datum/station_trait/cargo_penalty/on_round_start()
SSsupply.points *= 0.5 // Normally you have 50.


/datum/station_trait/cargo_highcost
name = "Cargo Highcost"
trait_type = STATION_TRAIT_NEGATIVE
weight = 3
show_in_report = TRUE
report_message = "В связи с изменением цен на товары, стоимость заказов пересмотрена - сверьтесь с прайсом"
blacklist = list(/datum/station_trait/cargo_lowcost)

/datum/station_trait/cargo_highcost/on_round_start()
var/costamp = pick(1.3,1.4,1.5,1.6,1.8,1.9,2,2.1)
SSsupply.pack_price_modifier *= costamp
6 changes: 6 additions & 0 deletions code/datums/station_traits/neutral.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/datum/station_trait/unnatural_atmosphere
name = "Unnatural Atmospherical Properties"
trait_type = STATION_TRAIT_NEUTRAL
weight = 3
show_in_report = TRUE
report_message = "Планеты вашей системы обладают необычными атмосферными характеристиками."
39 changes: 39 additions & 0 deletions code/datums/station_traits/positive.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/datum/station_trait/exploration_grant
name = "Exploration Grant"
trait_type = STATION_TRAIT_POSITIVE
weight = 3
show_in_report = TRUE
report_message = "Ваш корабль был выбран для получения специального гранта. Дополнительные очки будут отправлены в ваш отдел снабжения."

/datum/station_trait/exploration_grant/on_round_start()
SSsupply.points *= 2 // Normally you have 50.

/datum/station_trait/quick_shuttle
name = "Quick Shuttle"
trait_type = STATION_TRAIT_POSITIVE
weight = 3
show_in_report = TRUE
report_message = "Близкое расположение нашей станции снабжения, позволяет быстрее доставлять грузы на шаттле."
blacklist = list(/datum/station_trait/slow_shuttle)

/datum/station_trait/quick_shuttle/on_round_start()
SSsupply.movetime = 900

/datum/station_trait/premium_crewbox
name = "Premium Survival Boxes"
trait_type = STATION_TRAIT_POSITIVE
weight = 2
show_in_report = TRUE
report_message = "Crew survival boxes оснащенные дополнительным оборудованием."

/datum/station_trait/cargo_lowcost
name = "Cargo Lowcost"
trait_type = STATION_TRAIT_POSITIVE
weight = 3
show_in_report = TRUE
report_message = "В связи с изменением цен на товары, стоимость заказов пересмотрена - сверьтесь с прайсом"
blacklist = list(/datum/station_trait/cargo_highcost)

/datum/station_trait/cargo_lowcost/on_round_start()
var/costamp = pick(0.9,0.8)
SSsupply.pack_price_modifier *= costamp
8 changes: 6 additions & 2 deletions code/datums/supplypacks/supplypack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
switch(security_level)
if(SUPPLY_SECURITY_ELEVATED)
if(security_state.all_security_levels.len > 1)
security_level = security_state.all_security_levels[2]
security_level = security_state.all_security_levels[2]
else
security_level = security_state.high_security_level
security_level = security_state.high_security_level
if(SUPPLY_SECURITY_HIGH)
security_level = security_state.high_security_level
if(!istype(security_level))
Expand All @@ -42,6 +42,10 @@
var/decl/supply_method/sm = get_supply_method(supply_method)
return sm.spawn_contents(src, location)

/decl/hierarchy/supply_pack/proc/get_cost()
. = cost
. *= SSsupply.pack_price_modifier

/*
//SUPPLY PACKS
//NOTE: only secure crate types use the access var (and are lockable)
Expand Down
Loading