-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
fugitive_event.dm
157 lines (137 loc) · 6.64 KB
/
fugitive_event.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#define TEAM_BACKSTORY_SIZE 4
/datum/round_event_control/fugitives
name = "Spawn Fugitives"
typepath = /datum/round_event/ghost_role/fugitives
max_occurrences = 1
min_players = 20
earliest_start = 30 MINUTES //deadchat sink, lets not even consider it early on.
category = EVENT_CATEGORY_INVASION
description = "Fugitives will hide on the station, followed by hunters."
map_flags = EVENT_SPACE_ONLY
/datum/round_event/ghost_role/fugitives
minimum_required = 1
role_name = "fugitive"
fakeable = FALSE
/datum/round_event/ghost_role/fugitives/spawn_role()
var/turf/landing_turf = find_maintenance_spawn(atmos_sensitive = TRUE, require_darkness = FALSE)
if(isnull(landing_turf))
return MAP_ERROR
var/list/possible_backstories = list()
var/list/candidates = SSpolling.poll_ghost_candidates(check_jobban = ROLE_FUGITIVE, role = ROLE_FUGITIVE, alert_pic = /obj/item/card/id/advanced/prisoner, jump_target = landing_turf)
if(!length(candidates))
return NOT_ENOUGH_PLAYERS
if(length(candidates) < TEAM_BACKSTORY_SIZE || prob(30 - (length(candidates) * 2))) //Solo backstories are always considered if a larger backstory cannot be filled out. Otherwise, it's a rare chance that gets rarer if more people sign up.
possible_backstories += list(FUGITIVE_BACKSTORY_WALDO, FUGITIVE_BACKSTORY_INVISIBLE) //less common as it comes with magicks and is kind of immershun shattering
if(length(candidates) >= TEAM_BACKSTORY_SIZE)//group refugees
possible_backstories += list(FUGITIVE_BACKSTORY_PRISONER, FUGITIVE_BACKSTORY_CULTIST, FUGITIVE_BACKSTORY_SYNTH)
var/backstory = pick(possible_backstories)
var/member_size = 3
var/leader
switch(backstory)
if(FUGITIVE_BACKSTORY_SYNTH)
leader = pick_n_take(candidates)
if(FUGITIVE_BACKSTORY_WALDO, FUGITIVE_BACKSTORY_INVISIBLE)
member_size = 0 //solo refugees have no leader so the member_size gets bumped to one a bit later
var/list/members = list()
var/list/spawned_mobs = list()
if(isnull(leader))
member_size++ //if there is no leader role, then the would be leader is a normal member of the team.
for(var/i in 1 to member_size)
members += pick_n_take(candidates)
for(var/mob/dead/selected in members)
var/mob/living/carbon/human/S = gear_fugitive(selected, landing_turf, backstory)
spawned_mobs += S
if(!isnull(leader))
gear_fugitive_leader(leader, landing_turf, backstory)
//after spawning
playsound(src, 'sound/weapons/emitter.ogg', 50, TRUE)
new /obj/item/storage/toolbox/mechanical(landing_turf) //so they can actually escape maint
var/hunter_backstory = pick(
HUNTER_PACK_COPS,
HUNTER_PACK_RUSSIAN,
HUNTER_PACK_BOUNTY,
HUNTER_PACK_PSYKER,
)
addtimer(CALLBACK(src, PROC_REF(check_spawn_hunters), hunter_backstory, 10 MINUTES), 1 MINUTES)
role_name = "fugitive hunter"
return SUCCESSFUL_SPAWN
/datum/round_event/ghost_role/fugitives/proc/gear_fugitive(mob/dead/selected, turf/landing_turf, backstory) //spawns normal fugitive
var/datum/mind/player_mind = new /datum/mind(selected.key)
player_mind.active = TRUE
var/mob/living/carbon/human/S = new(landing_turf)
player_mind.transfer_to(S)
player_mind.set_assigned_role(SSjob.GetJobType(/datum/job/fugitive))
player_mind.special_role = ROLE_FUGITIVE
player_mind.add_antag_datum(/datum/antagonist/fugitive)
var/datum/antagonist/fugitive/fugitiveantag = player_mind.has_antag_datum(/datum/antagonist/fugitive)
fugitiveantag.greet(backstory)
switch(backstory)
if(FUGITIVE_BACKSTORY_PRISONER)
S.equipOutfit(/datum/outfit/prisoner)
if(FUGITIVE_BACKSTORY_CULTIST)
S.equipOutfit(/datum/outfit/yalp_cultist)
if(FUGITIVE_BACKSTORY_WALDO)
S.equipOutfit(/datum/outfit/waldo)
if(FUGITIVE_BACKSTORY_SYNTH)
S.equipOutfit(/datum/outfit/synthetic)
if(FUGITIVE_BACKSTORY_INVISIBLE)
S.equipOutfit(/datum/outfit/invisible_man)
message_admins("[ADMIN_LOOKUPFLW(S)] has been made into a Fugitive by an event.")
S.log_message("was spawned as a Fugitive by an event.", LOG_GAME)
spawned_mobs += S
return S
///special spawn for one member. it can be used for a special mob or simply to give one normal member special items.
/datum/round_event/ghost_role/fugitives/proc/gear_fugitive_leader(mob/dead/leader, turf/landing_turf, backstory)
var/datum/mind/player_mind = new /datum/mind(leader.key)
player_mind.active = TRUE
//if you want to add a fugitive with a special leader in the future, make this switch with the backstory
var/mob/living/carbon/human/S = gear_fugitive(leader, landing_turf, backstory)
var/obj/item/choice_beacon/augments/A = new(landing_turf)
S.put_in_hands(A)
new /obj/item/autosurgeon(landing_turf)
/datum/round_event/ghost_role/fugitives/proc/check_spawn_hunters(backstory, remaining_time)
//if the emergency shuttle has been called, spawn hunters now to give them a chance
if(remaining_time == 0 || !EMERGENCY_IDLE_OR_RECALLED)
spawn_hunters(backstory)
return
addtimer(CALLBACK(src, PROC_REF(check_spawn_hunters), backstory, remaining_time - 1 MINUTES), 1 MINUTES)
/datum/round_event/ghost_role/fugitives/proc/spawn_hunters(backstory)
var/list/candidates = SSpolling.poll_ghost_candidates("Do you wish to be considered for a group of [span_notice(backstory)]?", check_jobban = ROLE_FUGITIVE_HUNTER, alert_pic = /obj/machinery/sleeper, role_name_text = backstory)
shuffle_inplace(candidates)
var/datum/map_template/shuttle/hunter/ship
switch(backstory)
if(HUNTER_PACK_COPS)
ship = new /datum/map_template/shuttle/hunter/space_cop
if(HUNTER_PACK_RUSSIAN)
ship = new /datum/map_template/shuttle/hunter/russian
if(HUNTER_PACK_BOUNTY)
ship = new /datum/map_template/shuttle/hunter/bounty
if(HUNTER_PACK_PSYKER)
ship = new /datum/map_template/shuttle/hunter/psyker
var/x = rand(TRANSITIONEDGE,world.maxx - TRANSITIONEDGE - ship.width)
var/y = rand(TRANSITIONEDGE,world.maxy - TRANSITIONEDGE - ship.height)
var/z = SSmapping.empty_space.z_value
var/turf/placement_turf = locate(x,y,z)
if(!placement_turf)
CRASH("Fugitive Hunters (Created from fugitive event) found no turf to load in")
if(!ship.load(placement_turf))
CRASH("Loading [backstory] ship failed!")
for(var/turf/shuttle_turf in ship.get_affected_turfs(placement_turf))
for(var/obj/effect/mob_spawn/ghost_role/human/fugitive/spawner in shuttle_turf)
if(length(candidates))
var/mob/our_candidate = candidates[1]
var/mob/spawned_mob = spawner.create_from_ghost(our_candidate)
candidates -= our_candidate
notify_ghosts(
"[spawner.prompt_name] has awoken: [spawned_mob]!",
source = spawned_mob,
header = "Come look!",
)
else
notify_ghosts(
"[spawner.prompt_name] spawner has been created!",
source = spawner,
header = "Spawn Here!",
)
priority_announce("Unidentified ship detected near the station.")
#undef TEAM_BACKSTORY_SIZE