Skip to content

Commit 6b0aed5

Browse files
committed
tgstation.dmb - 0 errors, 1 warning (8/3/25 1:02 pm)
sob sob sob sob sob
1 parent ae7ac44 commit 6b0aed5

4 files changed

Lines changed: 67 additions & 9 deletions

File tree

code/controllers/configuration/entries/game_options.dm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@
6262
integer = FALSE
6363
min_val = 0
6464

65+
/// Determines the ideal player count for maximum progression per minute.
66+
// MASSMETA EDIT ADDITION BEGIN (re_traitorsecondary)
67+
/datum/config_entry/number/traitor_ideal_player_count
68+
default = 20
69+
min_val = 1
70+
// MASSMETA EDIT ADDITION END (re_traitorsecondary)
71+
6572
/// Determines how fast traitors scale in general.
6673
/datum/config_entry/number/traitor_scaling_multiplier
6774
default = 1

code/controllers/subsystem/traitor.dm

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ SUBSYSTEM_DEF(traitor)
2828

2929
/// The coefficient multiplied by the current_global_progression for new joining traitors to calculate their progression
3030
var/newjoin_progression_coeff = 1
31-
/// The current progression that all traitors should be at in the round, you can't have less than this
31+
/// The current progression that all traitors should be at in the round
3232
var/current_global_progression = 0
33-
/// The current uplink handlers being managed
33+
/// The amount of deviance from the current global progression before you start getting 2x the current scaling or no scaling at all
3434

3535
//MASSMETA ADDDITION START (re_traitorsecondary)
3636

3737
var/list/datum/uplink_handler/uplink_handlers = list()
38-
/// The current scaling per minute of progression.
38+
/// The current scaling per minute of progression. Has a maximum value of 1 MINUTES.
3939
var/current_progression_scaling = 1 MINUTES
4040
/// Used to handle the probability of getting an objective.
4141
var/datum/traitor_category_handler/category_handler
@@ -72,13 +72,26 @@ SUBSYSTEM_DEF(traitor)
7272
/datum/controller/subsystem/traitor/fire(resumed)
7373
var/previous_progression = current_global_progression
7474
current_global_progression = (STATION_TIME_PASSED()) * CONFIG_GET(number/traitor_scaling_multiplier)
75-
var/progression_increment = current_global_progression - previous_progression
7675
var/progression_scaling_delta = (wait / (1 MINUTES)) * current_progression_scaling
76+
var/player_count = length(GLOB.alive_player_list)
77+
// Has a maximum of 1 minute, however the value can be lower if there are lower players than the ideal
78+
// player count for a traitor to be threatening. Rounds to the nearest 10% of a minute to prevent weird
79+
// values from appearing in the UI. Traitor scaling multiplier bypasses the limit and only multiplies the end value.
80+
// from all of our calculations.
81+
current_progression_scaling = max(min(
82+
(player_count / CONFIG_GET(number/traitor_ideal_player_count)) * 1 MINUTES,
83+
1 MINUTES
84+
), 0.1 MINUTES) * CONFIG_GET(number/traitor_scaling_multiplier)
85+
86+
var/previous_global_progression = current_global_progression
87+
88+
current_global_progression += progression_scaling_delta
7789
for(var/datum/uplink_handler/handler in uplink_handlers)
7890
if(!handler.has_progression || QDELETED(handler))
7991
uplink_handlers -= handler
80-
if(handler.progression_points < current_global_progression)
81-
// If we got unsynced somehow, just set them to the current global progression
92+
var/deviance = (previous_global_progression - handler.progression_points) / progression_scaling_deviance
93+
if(abs(deviance) < 0.01)
94+
// If deviance is less than 1%, just set them to the current global progression
8295
// Prevents problems with precision errors.
8396
handler.progression_points = current_global_progression
8497
else
@@ -87,9 +100,9 @@ SUBSYSTEM_DEF(traitor)
87100
var/amount_to_give = progression_scaling_delta + (progression_scaling_delta * deviance)
88101
amount_to_give = clamp(amount_to_give, 0, progression_scaling_delta * 2)
89102
handler.progression_points += amount_to_give
90-
handler.update_objectives()
91103
handler.on_update()
92-
//MASSMETA EDIT START (re_traitorsecondary)
104+
105+
//MASSMETA EDIT END (re_traitorsecondary)
93106
/datum/controller/subsystem/traitor/proc/register_uplink_handler(datum/uplink_handler/uplink_handler)
94107
if(!uplink_handler.has_progression)
95108
return

code/datums/components/uplink.dm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@
192192
data["joined_population"] = length(GLOB.joined_player_list)
193193
data["maximum_potential_objectives"] = uplink_handler.maximum_potential_objectives
194194
data["progression_scaling_deviance"] = SStraitor.progression_scaling_deviance
195+
data["current_expected_progression"] = SStraitor.current_global_progression
196+
data["progression_scaling_deviance"] = SStraitor.progression_scaling_deviance
197+
data["current_progression_scaling"] = SStraitor.current_progression_scaling
195198

196199
if(uplink_handler.primary_objectives)
197200
var/list/primary_objectives = list()

tgui/packages/tgui/interfaces/Uplink/index.tsx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ type UplinkData = {
5454
progression_points: number;
5555
joined_population?: number;
5656
lockable: BooleanLike;
57+
current_expected_progression: number;
58+
progression_scaling_deviance: number;
5759
current_progression_scaling: number;
5860
uplink_flag: number;
5961
assigned_role: string;
@@ -282,7 +284,17 @@ export class Uplink extends Component<any, UplinkState> {
282284
},
283285
});
284286
}
285-
287+
// Get the difference between the current progression and
288+
// expected progression
289+
let progressionPercentage =
290+
current_expected_progression - progression_points;
291+
// Clamp it down between 0 and 2
292+
progressionPercentage = Math.min(
293+
Math.max(progressionPercentage / progression_scaling_deviance, -1),
294+
1,
295+
);
296+
// Round it and convert it into a percentage
297+
progressionPercentage = Math.round(progressionPercentage * 1000) / 10;
286298
return (
287299
<Window width={700} height={600} theme="syndicate">
288300
<Window.Content>
@@ -312,6 +324,29 @@ export class Uplink extends Component<any, UplinkState> {
312324
</Box>
313325
&nbsp;every minute
314326
</Box>
327+
{Math.abs(progressionPercentage) > 0 && (
328+
<Box mt={0.5}>
329+
Because your threat level is
330+
{progressionPercentage < 0
331+
? ' ahead '
332+
: ' behind '}
333+
of where it should be, you are getting
334+
<Box
335+
as="span"
336+
color={
337+
progressionPercentage < 0
338+
? 'red'
339+
: 'green'
340+
}
341+
ml={1}
342+
mr={1}
343+
>
344+
{progressionPercentage}%
345+
</Box>
346+
{progressionPercentage < 0 ? 'less' : 'more'}{' '}
347+
threat every minute
348+
</Box>
349+
)}
315350
{dangerLevelsTooltip}
316351
</Box>
317352
</Box>

0 commit comments

Comments
 (0)