Skip to content

Commit eb9cc0c

Browse files
authored
Merge pull request #164 from Alliance-codeBase/techdebt
Removes tech debt : Modular Progressive Traitor edition!
2 parents dd8516d + 6908645 commit eb9cc0c

63 files changed

Lines changed: 877 additions & 589 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

code/__DEFINES/uplink.dm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// These are used in uplink_devices.dm to determine whether or not an item is purchasable.
22

33
/// This item is purchasable to traitors
4-
//MASSMETA ADDDITION START (re_traitorsecondary)
4+
//MASSMETA ADDDITION START (progressive_traitor)
55
#define UPLINK_TRAITORS (1 << 0)
6-
//MASSMETA ADDDITION END (re_traitorsecondary)
6+
//MASSMETA ADDDITION END (progressive_traitor)
77

88
/// This item is purchasable to nuke ops
99
#define UPLINK_NUKE_OPS (1 << 1)
@@ -15,7 +15,7 @@
1515
#define UPLINK_INFILTRATORS (1 << 3)
1616

1717
/// Can be randomly given to spies for their bounties
18-
//MASSMETA ADDDITION START (re_traitorsecondary)
18+
//MASSMETA ADDDITION START (progressive_traitor)
1919
/* ORIGINAL:
2020
#define UPLINK_SPY (1 << 3)
2121
#define UPLINK_LONE_OP (1 << 4)
@@ -24,7 +24,7 @@
2424

2525
#define UPLINK_LONE_OP (1 << 5)
2626
// Это вероятно, перемешает все аплинки насмерть. Почините там как нибудь на досуге, ок, да?
27-
//MASSMETA ADDDITION START (re_traitorsecondary)
27+
//MASSMETA ADDDITION START (progressive_traitor)
2828

2929
/// A blanket define for an item being purchasable by all types of nukie
3030
#define UPLINK_ALL_SYNDIE_OPS (UPLINK_NUKE_OPS | UPLINK_LONE_OP | UPLINK_CLOWN_OPS)

code/controllers/configuration/entries/game_options.dm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@
6363
min_val = 0
6464

6565
/// Determines the ideal player count for maximum progression per minute.
66-
// MASSMETA EDIT ADDITION BEGIN (re_traitorsecondary)
66+
// MASSMETA EDIT ADDITION BEGIN (progressive_traitor)
6767
/datum/config_entry/number/traitor_ideal_player_count
6868
default = 20
6969
min_val = 1
70-
// MASSMETA EDIT ADDITION END (re_traitorsecondary)
70+
// MASSMETA EDIT ADDITION END (progressive_traitor)
7171

7272
/// Determines how fast traitors scale in general.
7373
/datum/config_entry/number/traitor_scaling_multiplier
@@ -76,11 +76,11 @@
7676
min_val = 0.01
7777

7878
/// Determines how many potential objectives a traitor can have.
79-
//MASSMETA ADDDITION START (re_traitorsecondary)
79+
//MASSMETA ADDDITION START (progressive_traitor)
8080
/datum/config_entry/number/maximum_potential_objectives
8181
default = 6
8282
min_val = 1
83-
//MASSMETA ADDDITION END (re_traitorsecondary)
83+
//MASSMETA ADDDITION END (progressive_traitor)
8484
/datum/config_entry/number/changeling_scaling_coeff //how much does the amount of players get divided by to determine changelings
8585
default = 6
8686
integer = FALSE

code/controllers/subsystem/traitor.dm

Lines changed: 10 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,12 @@ SUBSYSTEM_DEF(traitor)
1313
/// A list of all uplink items
1414
var/list/uplink_items = list()
1515

16-
/// File to load configurations from.
17-
//MASSMETA ADDDITION START (re_traitorsecondary)
18-
var/configuration_path = "config/traitor_objective.json"
19-
var/progression_scaling_deviance = 20 MINUTES
20-
/// Global configuration data that gets applied to each objective when it is created.
21-
/// Basic objective format
22-
/// '/datum/traitor_objective/path/to/objective': {
23-
/// "global_progression_influence_intensity": 0
24-
/// }
25-
var/configuration_data = list()
26-
27-
//MASSMETA ADDDITION END (re_traitorsecondary)
28-
2916
/// The coefficient multiplied by the current_global_progression for new joining traitors to calculate their progression
3017
var/newjoin_progression_coeff = 1
31-
/// The current progression that all traitors should be at in the round
18+
/// The current progression that all traitors should be at in the round, you can't have less than this
3219
var/current_global_progression = 0
33-
/// The amount of deviance from the current global progression before you start getting 2x the current scaling or no scaling at all
34-
20+
/// The current uplink handlers being managed
21+
var/list/datum/uplink_handler/uplink_handlers = list()
3522
/// The current scaling per minute of progression.
3623
var/current_progression_scaling = 1 MINUTES
3724
/// List of code words for traitors
@@ -43,39 +30,10 @@ SUBSYSTEM_DEF(traitor)
4330
/// Regex of code responses for traitors
4431
var/regex/syndicate_code_response_regex
4532

46-
//MASSMETA ADDDITION START (re_traitorsecondary)
47-
48-
var/list/datum/uplink_handler/uplink_handlers = list()
49-
/// Used to handle the probability of getting an objective.
50-
var/datum/traitor_category_handler/category_handler
51-
/// The current debug handler for objectives. Used for debugging objectives
52-
var/datum/traitor_objective_debug/traitor_debug_panel
53-
/// Used by the debug menu, decides whether newly created objectives should generate progression and telecrystals. Do not modify for non-debug purposes.
54-
var/generate_objectives = TRUE
55-
/// Objectives that have been completed by type. Used for limiting objectives.
56-
var/list/taken_objectives_by_type = list()
57-
/// A list of all existing objectives by type
58-
var/list/all_objectives_by_type = list()
59-
//MASSMETA ADDDITION END (re_traitorsecondary)
6033
/datum/controller/subsystem/traitor/Initialize()
61-
/*
62-
MASSMETA EDIT START (re_traitor_secondary)
63-
ORIGINAL: current_progression_scaling = 1 MINUTES * CONFIG_GET(number/traitor_scaling_multiplier)
64-
*/
65-
category_handler = new()
66-
traitor_debug_panel = new(category_handler)
67-
// MASSMETA EDIT END (re_traitor_secondary)
34+
current_progression_scaling = 1 MINUTES * CONFIG_GET(number/traitor_scaling_multiplier)
6835
for(var/theft_item in subtypesof(/datum/objective_item/steal))
6936
new theft_item
70-
//MASSMETA ADDITION START (re_traitor_secondary)
71-
if(fexists(configuration_path))
72-
var/list/data = json_decode(file2text(file(configuration_path)))
73-
for(var/typepath in data)
74-
var/actual_typepath = text2path(typepath)
75-
if(!actual_typepath)
76-
log_world("[configuration_path] has an invalid type ([typepath]) that doesn't exist in the codebase! Please correct or remove [typepath]")
77-
configuration_data[actual_typepath] = data[typepath]
78-
//MASSMETA ADDITION END (re_traitor_secondary)
7937

8038
syndicate_code_phrase = generate_code_phrase(return_list = TRUE)
8139
syndicate_code_phrase_regex = new("([jointext(syndicate_code_phrase, "|")])", "ig")
@@ -84,38 +42,21 @@ SUBSYSTEM_DEF(traitor)
8442
return SS_INIT_SUCCESS
8543

8644
/datum/controller/subsystem/traitor/fire(resumed)
45+
var/previous_progression = current_global_progression
8746
current_global_progression = (STATION_TIME_PASSED()) * CONFIG_GET(number/traitor_scaling_multiplier)
88-
var/progression_scaling_delta = (wait / (1 MINUTES)) * current_progression_scaling
89-
var/player_count = length(GLOB.alive_player_list)
90-
// Has a maximum of 1 minute, however the value can be lower if there are lower players than the ideal
91-
// player count for a traitor to be threatening. Rounds to the nearest 10% of a minute to prevent weird
92-
// values from appearing in the UI. Traitor scaling multiplier bypasses the limit and only multiplies the end value.
93-
// from all of our calculations.
94-
current_progression_scaling = max(min(
95-
(player_count / CONFIG_GET(number/traitor_ideal_player_count)) * 1 MINUTES,
96-
1 MINUTES
97-
), 0.1 MINUTES) * CONFIG_GET(number/traitor_scaling_multiplier)
47+
var/progression_increment = current_global_progression - previous_progression
9848

99-
var/previous_global_progression = current_global_progression
100-
101-
current_global_progression += progression_scaling_delta
10249
for(var/datum/uplink_handler/handler in uplink_handlers)
10350
if(!handler.has_progression || QDELETED(handler))
10451
uplink_handlers -= handler
105-
var/deviance = (previous_global_progression - handler.progression_points) / progression_scaling_deviance
106-
if(abs(deviance) < 0.01)
107-
// If deviance is less than 1%, just set them to the current global progression
52+
if(handler.progression_points < current_global_progression)
53+
// If we got unsynced somehow, just set them to the current global progression
10854
// Prevents problems with precision errors.
10955
handler.progression_points = current_global_progression
11056
else
111-
//MASSMETA EDIT START (re_traitorsecondary) ORIGINAL: handler.progression_points += progression_increment // Should only really happen if an admin is messing with an individual's progression value
112-
113-
var/amount_to_give = progression_scaling_delta + (progression_scaling_delta * deviance)
114-
amount_to_give = clamp(amount_to_give, 0, progression_scaling_delta * 2)
115-
handler.progression_points += amount_to_give
116-
handler.on_update()
57+
handler.progression_points += progression_increment // Should only really happen if an admin is messing with an individual's progression value
58+
handler.on_update()
11759

118-
//MASSMETA EDIT END (re_traitorsecondary)
11960
/datum/controller/subsystem/traitor/proc/register_uplink_handler(datum/uplink_handler/uplink_handler)
12061
if(!uplink_handler.has_progression)
12162
return
@@ -127,24 +68,3 @@ SUBSYSTEM_DEF(traitor)
12768
/datum/controller/subsystem/traitor/proc/uplink_handler_deleted(datum/uplink_handler/uplink_handler)
12869
SIGNAL_HANDLER
12970
uplink_handlers -= uplink_handler
130-
131-
// MASSMETA ADDITION START (re_traitorsecondary)
132-
/datum/controller/subsystem/traitor/proc/on_objective_taken(datum/traitor_objective/objective)
133-
if(!istype(objective))
134-
return
135-
136-
add_objective_to_list(objective, taken_objectives_by_type)
137-
138-
/datum/controller/subsystem/traitor/proc/get_taken_count(datum/traitor_objective/objective_type)
139-
return length(taken_objectives_by_type[objective_type])
140-
141-
142-
/datum/controller/subsystem/traitor/proc/add_objective_to_list(datum/traitor_objective/objective, list/objective_list)
143-
var/datum/traitor_objective/current_type = objective.type
144-
while(current_type != /datum/traitor_objective)
145-
if(!objective_list[current_type])
146-
objective_list[current_type] = list(objective)
147-
else
148-
objective_list[current_type] += objective
149-
current_type = current_type::parent_type
150-
// MASSMETA ADDITION END (re_traitorsecondary)

code/datums/components/crafting/structures.dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
)
6363
category = CAT_STRUCTURE
6464

65-
//MASSMETA ADDITION START (re_traitorsecondary)
65+
//MASSMETA ADDITION START (progressive_traitor)
6666
/datum/crafting_recipe/syndicate_uplink_beacon
6767
name = "Syndicate Uplink Beacon"
6868
result = /obj/structure/syndicate_uplink_beacon
@@ -76,7 +76,7 @@
7676
)
7777
category = CAT_STRUCTURE
7878
crafting_flags = CRAFT_CHECK_DENSITY | CRAFT_MUST_BE_LEARNED
79-
// MASSMETA ADDITION END (re_traitorsecondary)
79+
// MASSMETA ADDITION END (progressive_traitor)
8080

8181
/datum/crafting_recipe/manucrate
8282
name = "Manufacturing Storage Unit"

code/datums/components/uplink.dm

Lines changed: 2 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666
RegisterSignal(parent, COMSIG_RADIO_NEW_MESSAGE, PROC_REF(new_message))
6767
else if(istype(parent, /obj/item/pen))
6868
RegisterSignal(parent, COMSIG_PEN_ROTATED, PROC_REF(pen_rotation))
69-
else if(istype(parent, /obj/item/uplink/replacement))
70-
RegisterSignal(parent, COMSIG_MOVABLE_HEAR, PROC_REF(on_heard))
7169

7270
if(owner)
7371
src.owner = owner
@@ -81,17 +79,13 @@
8179
src.active = enabled
8280
if(!uplink_handler_override)
8381
uplink_handler = new()
84-
//MASSMETA ADDITION START (re_traitorsecondary)
85-
uplink_handler.has_objectives = FALSE
86-
//MASSMETA ADDITION END (re_traitorsecondary)
8782
uplink_handler.uplink_flag = uplink_flag
8883
uplink_handler.telecrystals = starting_tc
8984
uplink_handler.has_progression = has_progression
9085
uplink_handler.purchase_log = purchase_log
9186
else
9287
uplink_handler = uplink_handler_override
9388
RegisterSignal(uplink_handler, COMSIG_UPLINK_HANDLER_ON_UPDATE, PROC_REF(handle_uplink_handler_update))
94-
RegisterSignal(uplink_handler, COMSIG_UPLINK_HANDLER_REPLACEMENT_ORDERED, PROC_REF(handle_uplink_replaced))
9589
if(!lockable)
9690
active = TRUE
9791
locked = FALSE
@@ -102,21 +96,6 @@
10296
SIGNAL_HANDLER
10397
SStgui.update_uis(src)
10498

105-
// MASSMETA ADDITION START (re_traitorsecondary)
106-
/// When a new uplink is made via the syndicate beacon it locks all lockable uplinks and destroys replacement uplinks
107-
/datum/component/uplink/proc/handle_uplink_replaced()
108-
SIGNAL_HANDLER
109-
if(lockable)
110-
lock_uplink()
111-
if(!istype(parent, /obj/item/uplink/replacement))
112-
return
113-
var/obj/item/uplink_item = parent
114-
do_sparks(number = 3, cardinal_only = FALSE, source = uplink_item)
115-
uplink_item.visible_message(span_warning("The [uplink_item] suddenly combusts!"), vision_distance = COMBAT_MESSAGE_RANGE)
116-
new /obj/effect/decal/cleanable/ash(get_turf(uplink_item))
117-
qdel(uplink_item)
118-
// MASSMETA ADDITION END (re_traitorsecondary)
119-
12099
/datum/component/uplink/InheritComponent(datum/component/uplink/uplink)
121100
lockable |= uplink.lockable
122101
active |= uplink.active
@@ -190,10 +169,6 @@
190169
data["telecrystals"] = uplink_handler.telecrystals
191170
data["progression_points"] = uplink_handler.progression_points
192171
data["joined_population"] = length(GLOB.joined_player_list)
193-
data["maximum_potential_objectives"] = uplink_handler.maximum_potential_objectives
194-
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
197172
data["current_progression_scaling"] = SStraitor.current_progression_scaling
198173

199174
if(uplink_handler.primary_objectives)
@@ -208,27 +183,7 @@
208183
primary_objectives += list(task_data)
209184
data["primary_objectives"] = primary_objectives
210185

211-
// MASSMETA ADDITION START (re_traitorsecondary)
212-
if(uplink_handler.has_objectives)
213-
var/list/potential_objectives = list()
214-
for(var/index in 1 to uplink_handler.potential_objectives.len)
215-
var/datum/traitor_objective/objective = uplink_handler.potential_objectives[index]
216-
var/list/objective_data = objective.uplink_ui_data(user)
217-
objective_data["id"] = index
218-
potential_objectives += list(objective_data)
219-
220-
var/list/active_objectives = list()
221-
for(var/index in 1 to uplink_handler.active_objectives.len)
222-
var/datum/traitor_objective/objective = uplink_handler.active_objectives[index]
223-
var/list/objective_data = objective.uplink_ui_data(user)
224-
objective_data["id"] = index
225-
active_objectives += list(objective_data)
226-
227-
228-
data["potential_objectives"] = potential_objectives
229-
data["active_objectives"] = active_objectives
230-
data["completed_final_objective"] = uplink_handler.final_objective
231-
// MASSMETA ADDITION END (re_traitorsecondary)
186+
232187
var/list/stock_list = uplink_handler.item_stock.Copy()
233188
var/list/extra_purchasable_stock = list()
234189
var/list/extra_purchasable = list()
@@ -269,9 +224,6 @@
269224
var/list/data = list()
270225
data["uplink_flag"] = uplink_handler.uplink_flag
271226
data["has_progression"] = uplink_handler.has_progression
272-
// MASSMETA ADDITION START (re_traitorsecondary)
273-
data["has_objectives"] = uplink_handler.has_objectives
274-
// MASSMETA ADDITION END (re_traitorsecondary)
275227
data["lockable"] = lockable
276228
data["assigned_role"] = uplink_handler.assigned_role
277229
data["assigned_species"] = uplink_handler.assigned_species
@@ -313,57 +265,12 @@
313265
if(!lockable)
314266
return TRUE
315267
lock_uplink()
316-
//MASSMETA EDIT START (re_traitorsecondary)
317-
/* if("renegotiate_objectives")
318-
uplink_handler.replace_objectives?.Invoke()
319-
SStgui.update_uis(src)
320-
RETURN TRUE */
321268
if("renegotiate_objectives")
322269
uplink_handler.replace_objectives?.Invoke()
323270
SStgui.update_uis(src)
324-
//MASSMETA EDIT END (re_traitorsecondary)
325-
//MASSMETA ADDITION START (re_traitorsecondary)
326-
if(!uplink_handler.has_objectives)
327-
return TRUE
328-
329-
if(uplink_handler.owner?.current != ui.user || !uplink_handler.can_take_objectives)
330-
return TRUE
331-
332-
switch(action)
333-
if("regenerate_objectives")
334-
uplink_handler.generate_objectives()
335-
return TRUE
336-
337-
var/list/objectives
338-
switch(action)
339-
if("start_objective")
340-
objectives = uplink_handler.potential_objectives
341-
if("objective_act", "finish_objective", "objective_abort")
342-
objectives = uplink_handler.active_objectives
343-
344-
if(!objectives)
345-
return
346-
347-
var/objective_index = round(text2num(params["index"]))
348-
if(objective_index < 1 || objective_index > length(objectives))
349-
return TRUE
350-
var/datum/traitor_objective/objective = objectives[objective_index]
351-
352-
// Objective actions
353-
switch(action)
354-
if("start_objective")
355-
uplink_handler.take_objective(ui.user, objective)
356-
if("objective_act")
357-
uplink_handler.ui_objective_act(ui.user, objective, params["objective_action"])
358-
if("finish_objective")
359-
if(!objective.finish_objective(ui.user))
360-
return
361-
uplink_handler.complete_objective(objective)
362-
if("objective_abort")
363-
uplink_handler.abort_objective(objective)
364-
//MASSMETA ADDITION START (re_traitorsecondary)
365271
return TRUE
366272

273+
367274
/// Proc that locks uplinks
368275
/datum/component/uplink/proc/lock_uplink()
369276
active = FALSE
@@ -509,17 +416,6 @@
509416

510417
return returnable_code
511418

512-
/// Proc that unlocks a locked replacement uplink when it hears the unlock code from their datum
513-
/datum/component/uplink/proc/on_heard(datum/source, list/hearing_args)
514-
SIGNAL_HANDLER
515-
if(!locked)
516-
return
517-
if(!findtext(hearing_args[HEARING_RAW_MESSAGE], unlock_code))
518-
return
519-
var/atom/replacement_uplink = parent
520-
locked = FALSE
521-
replacement_uplink.balloon_alert_to_viewers("beep", vision_distance = COMBAT_MESSAGE_RANGE)
522-
523419
/datum/component/uplink/proc/failsafe(atom/source)
524420
if(!parent)
525421
return

0 commit comments

Comments
 (0)