-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathpirates.dm
485 lines (410 loc) · 14.5 KB
/
pirates.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
/datum/round_event_control/pirates
name = "Space Pirates"
typepath = /datum/round_event/pirates
weight = 8
max_occurrences = 2
min_players = 20
earliest_start = 30 MINUTES
description = "The crew will either pay up, or face a pirate assault."
// admin_setup = list(/datum/event_admin_setup/listed_options/pirates)
map_flags = EVENT_SPACE_ONLY
track = EVENT_TRACK_MAJOR
tags = list(TAG_COMBAT, TAG_COMMUNAL)
checks_antag_cap = TRUE
/datum/round_event_control/pirates/preRunEvent()
if (!SSmapping.empty_space)
return EVENT_CANT_RUN
return ..()
/datum/round_event/pirates
start_when = 150 //5 minutes to answer
var/datum/comm_message/threat
var/payoff = 0
var/payoff_min = 20000
var/paid_off = FALSE
var/ship_name = "Space Privateers Association"
var/shuttle_spawned = FALSE
/datum/round_event/pirates/setup()
var/the = prob(50) ? "The " : ""
var/start = pick(strings(PIRATE_NAMES_FILE, "ship_name_start"))
var/end = pick(strings(PIRATE_NAMES_FILE, "ship_name_end"))
ship_name = "[the][start] [end]"
setup = TRUE //storytellers
/datum/round_event/pirates/announce(fake)
priority_announce("Incoming subspace communication. Secure channel opened at all communication consoles.", "Incoming Message", SSstation.announcer.get_rand_report_sound())
play_intro_music()
if(fake)
return
threat = new
var/datum/bank_account/D = SSeconomy.get_dep_account(ACCOUNT_CAR)
if(D)
payoff = max(payoff_min, FLOOR(D.account_balance * 0.80, 1000))
threat.title = "Business proposition"
threat.content = "This is [ship_name]. Pay up [payoff] credits or you'll walk the plank."
threat.possible_answers = list("We'll pay.","No way.")
threat.answer_callback = CALLBACK(src, PROC_REF(answered))
SScommunications.send_message(threat,unique = TRUE)
/datum/round_event/pirates/proc/answered()
if(threat && threat.answered == 1 && !paid_off)
var/datum/bank_account/D = SSeconomy.get_dep_account(ACCOUNT_CAR)
if(D)
if(D.adjust_money(-payoff))
priority_announce("Thanks for the credits, landlubbers.",sender_override = ship_name)
paid_off = TRUE
return
else
priority_announce("Trying to cheat us? You'll regret this!",sender_override = ship_name)
if(!shuttle_spawned && !paid_off)
spawn_shuttle()
/**
* Called when the ship is shot down, cancels the event and calls [/datum/round_event/pirates/proc/announce_shot_down] after 20 seconds
*/
/datum/round_event/pirates/proc/shot_down()
addtimer(CALLBACK(src, PROC_REF(announce_shot_down)), 200)
paid_off = TRUE
/**
* Called 20 seconds after [/datum/round_event/pirates/proc/shot_down], announces that it was shot down, and that debris is coming
* spawns a weak wave of meteors as the "debris"
*/
/datum/round_event/pirates/proc/announce_shot_down()
priority_announce("Unidentified ship with trajectory towards the station has exploded, expect debris.")
// small amount of meteors instead of a pirate boarding seems like a good deal
spawn_meteors(2, GLOB.meteors_normal)
/datum/round_event/pirates/start()
if(!paid_off && !shuttle_spawned)
spawn_shuttle()
/datum/round_event/pirates/proc/spawn_shuttle()
shuttle_spawned = TRUE
var/list/candidates = pollGhostCandidates("Do you wish to be considered for pirate crew?", ROLE_TRAITOR)
shuffle_inplace(candidates)
var/datum/map_template/shuttle/pirate/default/ship = new
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/T = locate(x,y,z)
if(!T)
CRASH("Pirate event found no turf to load in")
if(!ship.load(T))
CRASH("Loading pirate ship failed!")
for(var/turf/A in ship.get_affected_turfs(T))
for(var/obj/effect/mob_spawn/human/pirate/spawner in A)
if(candidates.len > 0)
var/mob/M = candidates[1]
spawner.create(M.ckey)
candidates -= M
announce_to_ghosts(M)
else
announce_to_ghosts(spawner)
priority_announce("Unidentified armed ship detected near the station.")
play_intro_music()
///plays Cortez Battle - Paper Mario: The Thousand-Year Door. Uses chatoutput.sendmusic instead of playsound.local because it is more than 90 seconds long
/datum/round_event/pirates/proc/play_intro_music()
for(var/m in GLOB.player_list)
var/mob/M = m
var/client/C = M.client
if(C.prefs.toggles & SOUND_MIDI)
C.tgui_panel?.play_music("https://www.youtube.com/watch?v=MU__2jFQ5EY")
//Shuttle equipment
/obj/machinery/shuttle_scrambler
name = "Data Siphon"
desc = "This heap of machinery steals credits and data from unprotected systems and locks down cargo shuttles."
icon = 'icons/obj/machines/dominator.dmi'
icon_state = "dominator"
density = TRUE
/// Is the machine siphoning right now
var/active = FALSE
/// The amount of money stored in the machine
var/credits_stored = 0
/// The amount of money removed per tick
var/siphon_per_tick = 5
/obj/machinery/shuttle_scrambler/Initialize(mapload)
. = ..()
update_appearance()
/obj/machinery/shuttle_scrambler/process()
if(!active)
return PROCESS_KILL
if(!is_station_level(z))
return
var/datum/bank_account/account = SSeconomy.get_dep_account(ACCOUNT_CAR)
var/siphoned = min(account.account_balance,siphon_per_tick)
account.adjust_money(-siphoned)
credits_stored += siphoned
interrupt_research()
/obj/machinery/shuttle_scrambler/proc/toggle_on(mob/user)
SSshuttle.registerTradeBlockade(src)
AddComponent(/datum/component/gps, "Nautical Signal")
active = TRUE
to_chat(user,span_notice("You toggle [src] [active ? "on":"off"]."))
to_chat(user,span_warning("The scrambling signal can be now tracked by GPS."))
START_PROCESSING(SSobj,src)
/obj/machinery/shuttle_scrambler/interact(mob/user)
if(!active)
if(tgui_alert(user, "Turning the scrambler on will make the shuttle trackable by GPS. Are you sure you want to do it?", "Scrambler", list("Yes", "Cancel")) == "Cancel")
return
if(active || !user.canUseTopic(src, BE_CLOSE))
return
toggle_on(user)
update_appearance(UPDATE_ICON)
send_notification()
else
dump_loot(user)
//interrupt_research
/obj/machinery/shuttle_scrambler/proc/interrupt_research()
for(var/obj/machinery/rnd/server/S in GLOB.machines)
if(S.stat & (NOPOWER|BROKEN))
continue
S.emp_act(1)
new /obj/effect/temp_visual/emp(get_turf(S))
/obj/machinery/shuttle_scrambler/proc/dump_loot(mob/user)
new /obj/item/holochip(drop_location(), credits_stored)
to_chat(user,span_notice("You retrieve the siphoned credits!"))
credits_stored = 0
/obj/machinery/shuttle_scrambler/proc/send_notification()
priority_announce("Data theft signal detected, source registered on local gps units.")
/obj/machinery/shuttle_scrambler/proc/toggle_off(mob/user)
SSshuttle.clearTradeBlockade(src)
active = FALSE
STOP_PROCESSING(SSobj,src)
/obj/machinery/shuttle_scrambler/update_icon_state()
icon_state = active ? "dominator-red" : "dominator"
return ..()
/obj/machinery/shuttle_scrambler/Destroy()
toggle_off()
return ..()
/obj/item/gps/internal/pirate
gpstag = "Nautical Signal"
desc = "You can hear shanties over the static."
/obj/machinery/computer/shuttle/pirate
name = "pirate shuttle console"
shuttleId = "pirateship"
icon_screen = "syndishuttle"
icon_keyboard = "syndie_key"
light_color = LIGHT_COLOR_RED
possible_destinations = "pirateship_away;pirateship_home;pirateship_custom"
/obj/machinery/computer/camera_advanced/shuttle_docker/syndicate/pirate
name = "pirate shuttle navigation computer"
desc = "Used to designate a precise transit location for the pirate shuttle."
shuttleId = "pirateship"
lock_override = CAMERA_LOCK_STATION
shuttlePortId = "pirateship_custom"
x_offset = 9
y_offset = 0
see_hidden = FALSE
/obj/docking_port/mobile/pirate
name = "pirate shuttle"
shuttle_id = "pirateship"
rechargeTime = 3 MINUTES
/obj/machinery/suit_storage_unit/pirate
suit_type = /obj/item/clothing/suit/space
helmet_type = /obj/item/clothing/head/helmet/space
mask_type = /obj/item/clothing/mask/breath
storage_type = /obj/item/tank/internals/oxygen
/obj/machinery/loot_locator
name = "Booty Locator"
desc = "This sophisticated machine scans the nearby space for items of value."
icon = 'icons/obj/machines/research.dmi'
icon_state = "tdoppler"
density = TRUE
var/cooldown = 300
var/next_use = 0
/obj/machinery/loot_locator/interact(mob/user)
if(world.time <= next_use)
to_chat(user,span_warning("[src] is recharging."))
return
next_use = world.time + cooldown
var/atom/movable/AM = find_random_loot()
if(!AM)
say("No valuables located. Try again later.")
else
say("Located: [AM.name] at [get_area_name(AM)]")
/obj/machinery/loot_locator/proc/find_random_loot()
if(!GLOB.exports_list.len)
setupExports()
var/list/possible_loot = list()
for(var/datum/export/pirate/E in GLOB.exports_list)
possible_loot += E
var/datum/export/pirate/P
var/atom/movable/AM
while(!AM && possible_loot.len)
P = pick_n_take(possible_loot)
AM = P.find_loot()
return AM
//Pad & Pad Terminal
/obj/machinery/piratepad
name = "cargo hold pad"
icon = 'icons/obj/telescience.dmi'
icon_state = "lpad-idle-o"
var/idle_state = "lpad-idle-o"
var/warmup_state = "lpad-idle"
var/sending_state = "lpad-beam"
var/cargo_hold_id
/obj/machinery/piratepad/multitool_act(mob/living/user, obj/item/multitool/I)
to_chat(user, span_notice("You register [src] in [I]s buffer."))
multitool_set_buffer(user, I, src)
return TRUE
/obj/machinery/computer/piratepad_control
name = "cargo hold control terminal"
var/status_report = "Ready for delivery."
var/obj/machinery/piratepad/pad
var/warmup_time = 100
var/sending = FALSE
var/points = 0
var/datum/export_report/total_report
var/sending_timer
var/cargo_hold_id
/obj/machinery/computer/piratepad_control/Initialize(mapload)
..()
return INITIALIZE_HINT_LATELOAD
/obj/machinery/computer/piratepad_control/multitool_act(mob/living/user, obj/item/multitool/I)
var/atom/buffer_atom = multitool_get_buffer(user, I)
if(istype(buffer_atom, /obj/machinery/piratepad))
to_chat(user, span_notice("You link [src] with [buffer_atom] in [I]'s buffer."))
pad = buffer_atom
return TRUE
/obj/machinery/computer/piratepad_control/LateInitialize()
. = ..()
if(cargo_hold_id)
for(var/obj/machinery/piratepad/P in GLOB.machines)
if(P.cargo_hold_id == cargo_hold_id)
pad = P
return
else
pad = locate() in range(4,src)
/obj/machinery/computer/piratepad_control/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "CargoHoldTerminal", name)
ui.open()
/obj/machinery/computer/piratepad_control/ui_data(mob/user)
var/list/data = list()
data["points"] = points
data["pad"] = pad ? TRUE : FALSE
data["sending"] = sending
data["status_report"] = status_report
return data
/obj/machinery/computer/piratepad_control/ui_act(action, params)
if(..())
return
if(!pad)
return
switch(action)
if("recalc")
recalc()
. = TRUE
if("send")
start_sending()
. = TRUE
if("stop")
stop_sending()
. = TRUE
/obj/machinery/computer/piratepad_control/proc/recalc()
if(sending)
return
status_report = "Predicted value: "
var/value = 0
var/datum/export_report/ex = new
for(var/atom/movable/AM in get_turf(pad))
if(AM == pad)
continue
export_item_and_contents(AM, EXPORT_PIRATE | EXPORT_CARGO | EXPORT_CONTRABAND | EXPORT_EMAG, apply_limit = FALSE, dry_run = TRUE, external_report = ex)
for(var/datum/export/E in ex.total_amount)
status_report += E.total_printout(ex,notes = FALSE)
status_report += " "
value += ex.total_value[E]
if(!value)
status_report += "0"
/obj/machinery/computer/piratepad_control/proc/send()
if(!sending)
return
var/datum/export_report/ex = new
for(var/atom/movable/AM in get_turf(pad))
if(AM == pad)
continue
export_item_and_contents(AM, EXPORT_PIRATE | EXPORT_CARGO | EXPORT_CONTRABAND | EXPORT_EMAG, apply_limit = FALSE, delete_unsold = FALSE, external_report = ex)
status_report = "Sold: "
var/value = 0
for(var/datum/export/E in ex.total_amount)
var/export_text = E.total_printout(ex,notes = FALSE) //Don't want nanotrasen messages, makes no sense here.
if(!export_text)
continue
status_report += export_text
status_report += " "
value += ex.total_value[E]
if(!total_report)
total_report = ex
else
total_report.exported_atoms += ex.exported_atoms
for(var/datum/export/E in ex.total_amount)
total_report.total_amount[E] += ex.total_amount[E]
total_report.total_value[E] += ex.total_value[E]
points += value
if(!value)
status_report += "Nothing"
pad.visible_message(span_notice("[pad] activates!"))
flick(pad.sending_state,pad)
pad.icon_state = pad.idle_state
sending = FALSE
/obj/machinery/computer/piratepad_control/proc/start_sending()
if(sending)
return
sending = TRUE
status_report = "Sending..."
pad.visible_message(span_notice("[pad] starts charging up."))
pad.icon_state = pad.warmup_state
sending_timer = addtimer(CALLBACK(src, PROC_REF(send)),warmup_time, TIMER_STOPPABLE)
/obj/machinery/computer/piratepad_control/proc/stop_sending()
if(!sending)
return
sending = FALSE
status_report = "Ready for delivery."
pad.icon_state = pad.idle_state
deltimer(sending_timer)
/datum/export/pirate
export_category = EXPORT_PIRATE
//Attempts to find the thing on station
/datum/export/pirate/proc/find_loot()
return
/datum/export/pirate/ransom
cost = 8000
unit_name = "hostage"
export_types = list(/mob/living/carbon/human)
/datum/export/pirate/ransom/find_loot()
var/list/head_minds = SSjob.get_living_heads()
var/list/head_mobs = list()
for(var/datum/mind/M in head_minds)
head_mobs += M.current
if(head_mobs.len)
return pick(head_mobs)
/datum/export/pirate/ransom/get_cost(atom/movable/AM)
var/mob/living/carbon/human/H = AM
if(H.stat != CONSCIOUS || !H.mind || !H.mind.assigned_role) //mint condition only
return 0
else if("pirate" in H.faction) //can't ransom your fellow pirates to CentCom!
return 0
else
if(H.mind.assigned_role in GLOB.command_positions)
return 8000
else
return 3000
/datum/export/pirate/parrot
cost = 5000
unit_name = "alive parrot"
export_types = list(/mob/living/simple_animal/parrot)
/datum/export/pirate/parrot/find_loot()
for(var/mob/living/simple_animal/parrot/P in GLOB.alive_mob_list)
var/turf/T = get_turf(P)
if(T && is_station_level(T.z))
return P
/datum/export/pirate/cash
cost = 1
unit_name = "bills"
export_types = list(/obj/item/stack/spacecash)
/datum/export/pirate/cash/get_amount(obj/O)
var/obj/item/stack/spacecash/C = O
return ..() * C.amount * C.value
/datum/export/pirate/holochip
cost = 1
unit_name = "holochip"
export_types = list(/obj/item/holochip)
/datum/export/pirate/holochip/get_cost(atom/movable/AM)
var/obj/item/holochip/H = AM
return H.credits