-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
computer.cpp
1808 lines (1654 loc) · 73.3 KB
/
computer.cpp
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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "computer.h"
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <string>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <utility>
#include "avatar.h"
#include "coordinate_conversions.h"
#include "debug.h"
#include "event_bus.h"
#include "explosion.h"
#include "field.h"
#include "game.h"
#include "input.h"
#include "item_factory.h"
#include "json.h"
#include "line.h"
#include "map.h"
#include "map_iterator.h"
#include "mapdata.h"
#include "messages.h"
#include "mission.h"
#include "monster.h"
#include "mtype.h"
#include "output.h"
#include "overmap.h"
#include "overmap_ui.h"
#include "overmapbuffer.h"
#include "player.h"
#include "rng.h"
#include "sounds.h"
#include "string_formatter.h"
#include "text_snippets.h"
#include "timed_event.h"
#include "translations.h"
#include "trap.h"
#include "color.h"
#include "creature.h"
#include "enums.h"
#include "game_constants.h"
#include "int_id.h"
#include "item.h"
#include "omdata.h"
#include "string_id.h"
#include "type_id.h"
#include "basecamp.h"
#include "colony.h"
#include "point.h"
const mtype_id mon_manhack( "mon_manhack" );
const mtype_id mon_secubot( "mon_secubot" );
const mtype_id mon_turret_rifle( "mon_turret_rifle" );
const skill_id skill_computer( "computer" );
const species_id ZOMBIE( "ZOMBIE" );
const species_id HUMAN( "HUMAN" );
const efftype_id effect_amigara( "amigara" );
int alerts = 0;
computer_option::computer_option()
: name( "Unknown" ), action( COMPACT_NULL ), security( 0 )
{
}
computer_option::computer_option( const std::string &N, computer_action A, int S )
: name( N ), action( A ), security( S )
{
}
computer::computer( const std::string &new_name, int new_security )
: name( new_name ), mission_id( -1 ), security( new_security ),
access_denied( _( "ERROR! Access denied!" ) )
{
}
computer::computer( const computer &rhs )
{
*this = rhs;
}
computer::~computer() = default;
computer &computer::operator=( const computer &rhs )
{
security = rhs.security;
name = rhs.name;
access_denied = rhs.access_denied;
mission_id = rhs.mission_id;
options = rhs.options;
failures = rhs.failures;
w_terminal = catacurses::window();
w_border = catacurses::window();
return *this;
}
void computer::set_security( int Security )
{
security = Security;
}
void computer::add_option( const computer_option &opt )
{
options.emplace_back( opt );
}
void computer::add_option( const std::string &opt_name, computer_action action,
int security )
{
add_option( computer_option( opt_name, action, security ) );
}
void computer::add_failure( const computer_failure &failure )
{
failures.emplace_back( failure );
}
void computer::add_failure( computer_failure_type failure )
{
add_failure( computer_failure( failure ) );
}
void computer::set_access_denied_msg( const std::string &new_msg )
{
access_denied = new_msg;
}
void computer::shutdown_terminal()
{
// So yeah, you can reset the term by logging off.
// Otherwise, it's persistent across all terms.
// Decided to go easy on people for now.
alerts = 0;
werase( w_terminal );
w_terminal = catacurses::window();
werase( w_border );
w_border = catacurses::window();
}
void computer::use()
{
if( !w_border ) {
w_border = catacurses::newwin( FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH,
point( TERMX > FULL_SCREEN_WIDTH ? ( TERMX - FULL_SCREEN_WIDTH ) / 2 : 0,
TERMY > FULL_SCREEN_HEIGHT ? ( TERMY - FULL_SCREEN_HEIGHT ) / 2 : 0 ) );
}
if( !w_terminal ) {
w_terminal = catacurses::newwin( getmaxy( w_border ) - 2, getmaxx( w_border ) - 2,
point( getbegx( w_border ) + 1, getbegy( w_border ) + 1 ) );
}
draw_border( w_border );
wrefresh( w_border );
// Login
print_line( _( "Logging into %s..." ), _( name ) );
if( security > 0 ) {
if( calendar::turn < next_attempt ) {
print_error( _( "Access is temporary blocked for security purposes." ) );
query_any( _( "Please contact the system administrator." ) );
reset_terminal();
return;
}
print_error( access_denied.c_str() );
switch( query_ynq( _( "Bypass security?" ) ) ) {
case 'q':
case 'Q':
shutdown_terminal();
return;
case 'n':
case 'N':
query_any( _( "Shutting down... press any key." ) );
shutdown_terminal();
return;
case 'y':
case 'Y':
if( !hack_attempt( g->u ) ) {
if( failures.empty() ) {
query_any( _( "Maximum login attempts exceeded. Press any key..." ) );
shutdown_terminal();
return;
}
activate_random_failure();
shutdown_terminal();
return;
} else { // Successful hack attempt
security = 0;
query_any( _( "Login successful. Press any key..." ) );
reset_terminal();
}
}
} else { // No security
query_any( _( "Login successful. Press any key..." ) );
reset_terminal();
}
// Main computer loop
while( true ) {
//reset_terminal();
size_t options_size = options.size();
print_newline();
print_line( "%s - %s", _( name ), _( "Root Menu" ) );
#if defined(__ANDROID__)
input_context ctxt( "COMPUTER_MAINLOOP" );
#endif
for( size_t i = 0; i < options_size; i++ ) {
print_line( "%d - %s", i + 1, _( options[i].name ) );
#if defined(__ANDROID__)
ctxt.register_manual_key( '1' + i, options[i].name );
#endif
}
print_line( "Q - %s", _( "Quit and Shut Down" ) );
print_newline();
#if defined(__ANDROID__)
ctxt.register_manual_key( 'Q', _( "Quit and Shut Down" ) );
#endif
char ch;
do {
// TODO: use input context
ch = inp_mngr.get_input_event().get_first_input();
} while( ch != 'q' && ch != 'Q' && ( ch < '1' || ch - '1' >= static_cast<char>( options_size ) ) );
if( ch == 'q' || ch == 'Q' ) {
break; // Exit from main computer loop
} else { // We selected an option other than quit.
ch -= '1'; // So '1' -> 0; index in options.size()
computer_option current = options[ch];
// Once you trip the security, you have to roll every time you want to do something
if( ( current.security + ( alerts ) ) > 0 ) {
print_error( _( "Password required." ) );
if( query_bool( _( "Hack into system?" ) ) ) {
if( !hack_attempt( g->u, current.security ) ) {
activate_random_failure();
shutdown_terminal();
return;
} else {
// Successfully hacked function
options[ch].security = 0;
activate_function( current.action );
}
}
} else { // No need to hack, just activate
activate_function( current.action );
}
reset_terminal();
} // Done processing a selected option.
}
shutdown_terminal(); // This should have been done by now, but just in case.
}
bool computer::hack_attempt( player &p, int Security )
{
if( Security == -1 ) {
Security = security; // Set to main system security if no value passed
}
const int hack_skill = p.get_skill_level( skill_computer );
// Every time you dig for lab notes, (or, in future, do other suspicious stuff?)
// +2 dice to the system's hack-resistance
// So practical max files from a given terminal = 5, at 10 Computer
if( alerts > 0 ) {
Security += ( alerts * 2 );
}
p.moves -= 10 * ( 5 + Security * 2 ) / std::max( 1, hack_skill + 1 );
int player_roll = hack_skill;
///\EFFECT_INT <8 randomly penalizes hack attempts, 50% of the time
if( p.int_cur < 8 && one_in( 2 ) ) {
player_roll -= rng( 0, 8 - p.int_cur );
///\EFFECT_INT >8 randomly benefits hack attempts, 33% of the time
} else if( p.int_cur > 8 && one_in( 3 ) ) {
player_roll += rng( 0, p.int_cur - 8 );
}
///\EFFECT_COMPUTER increases chance of successful hack attempt, vs Security level
bool successful_attempt = ( dice( player_roll, 6 ) >= dice( Security, 6 ) );
p.practice( skill_computer, successful_attempt ? ( 15 + Security * 3 ) : 7 );
return successful_attempt;
}
std::string computer::save_data() const
{
std::ostringstream data;
data.imbue( std::locale::classic() );
data
<< string_replace( name, " ", "_" ) << ' '
<< security << ' '
<< mission_id << ' '
<< options.size() << ' ';
for( auto &elem : options ) {
data
<< string_replace( elem.name, " ", "_" ) << ' '
<< static_cast<int>( elem.action ) << ' '
<< elem.security << ' ';
}
data << failures.size() << ' ';
for( auto &elem : failures ) {
data << static_cast<int>( elem.type ) << ' ';
}
data << string_replace( access_denied, " ", "_" ) << ' ';
return data.str();
}
void computer::load_data( const std::string &data )
{
options.clear();
failures.clear();
std::istringstream dump( data );
dump.imbue( std::locale::classic() );
dump >> name >> security >> mission_id;
name = string_replace( name, "_", " " );
// Pull in options
int optsize;
dump >> optsize;
for( int n = 0; n < optsize; n++ ) {
std::string tmpname;
int tmpaction;
int tmpsec;
dump >> tmpname >> tmpaction >> tmpsec;
add_option( string_replace( tmpname, "_", " " ), static_cast<computer_action>( tmpaction ),
tmpsec );
}
// Pull in failures
int failsize;
dump >> failsize;
for( int n = 0; n < failsize; n++ ) {
int tmpfail;
dump >> tmpfail;
add_failure( static_cast<computer_failure_type>( tmpfail ) );
}
std::string tmp_access_denied;
dump >> tmp_access_denied;
// For backwards compatibility, only set the access denied message if it
// isn't empty. This is to avoid the message becoming blank when people
// load old saves.
if( !tmp_access_denied.empty() ) {
access_denied = string_replace( tmp_access_denied, "_", " " );
}
}
static item *pick_usb()
{
const int pos = g->inv_for_id( itype_id( "usb_drive" ), _( "Choose drive:" ) );
if( pos != INT_MIN ) {
return &g->u.i_at( pos );
}
return nullptr;
}
static void remove_submap_turrets()
{
for( monster &critter : g->all_monsters() ) {
// Check 1) same overmap coords, 2) turret, 3) hostile
if( ms_to_omt_copy( g->m.getabs( critter.pos() ) ) == ms_to_omt_copy( g->m.getabs( g->u.pos() ) ) &&
( critter.type->id == mon_turret_rifle ) &&
critter.attitude_to( g->u ) == Creature::Attitude::A_HOSTILE ) {
g->remove_zombie( critter );
}
}
}
void computer::activate_function( computer_action action )
{
// Token move cost for any action, if an action takes longer decrement moves further.
g->u.moves -= 30;
switch( action ) {
case COMPACT_NULL: // Unknown action.
case NUM_COMPUTER_ACTIONS: // Suppress compiler warning [-Wswitch]
break;
// OPEN_DISARM falls through to just OPEN
case COMPACT_OPEN_DISARM:
remove_submap_turrets();
/* fallthrough */
case COMPACT_OPEN:
g->m.translate_radius( t_door_metal_locked, t_floor, 25.0, g->u.pos(), true );
query_any( _( "Doors opened. Press any key..." ) );
break;
//LOCK AND UNLOCK are used to build more complex buildings
// that can have multiple doors that can be locked and be
// unlocked by different computers.
//Simply uses translate_radius which take a given radius and
// player position to determine which terrain tiles to edit.
case COMPACT_LOCK:
g->m.translate_radius( t_door_metal_c, t_door_metal_locked, 8.0, g->u.pos(), true );
query_any( _( "Lock enabled. Press any key..." ) );
break;
// UNLOCK_DISARM falls through to just UNLOCK
case COMPACT_UNLOCK_DISARM:
remove_submap_turrets();
/* fallthrough */
case COMPACT_UNLOCK:
g->m.translate_radius( t_door_metal_locked, t_door_metal_c, 8.0, g->u.pos(), true );
query_any( _( "Lock disabled. Press any key..." ) );
break;
//Toll is required for the church computer/mechanism to function
case COMPACT_TOLL:
sounds::sound( g->u.pos(), 120, sounds::sound_t::music,
//~ the sound of a church bell ringing
_( "Bohm... Bohm... Bohm..." ), true, "environment", "church_bells" );
break;
case COMPACT_SAMPLE:
g->u.moves -= 30;
for( int x = 0; x < MAPSIZE_X; x++ ) {
for( int y = 0; y < MAPSIZE_Y; y++ ) {
if( g->m.ter( point( x, y ) ) == t_sewage_pump ) {
for( int x1 = x - 1; x1 <= x + 1; x1++ ) {
for( int y1 = y - 1; y1 <= y + 1; y1++ ) {
if( g->m.furn( point( x1, y1 ) ) == f_counter ) {
bool found_item = false;
item sewage( "sewage", calendar::turn );
auto candidates = g->m.i_at( point( x1, y1 ) );
for( auto &candidate : candidates ) {
int capa = candidate.get_remaining_capacity_for_liquid( sewage );
if( capa <= 0 ) {
continue;
}
item &elem = candidate;
capa = std::min( sewage.charges, capa );
if( elem.contents.empty() ) {
elem.put_in( sewage );
elem.contents.front().charges = capa;
} else {
elem.contents.front().charges += capa;
}
found_item = true;
break;
}
if( !found_item ) {
g->m.add_item_or_charges( point( x1, y1 ), sewage );
}
}
}
}
}
}
}
break;
case COMPACT_RELEASE:
g->events().send<event_type::releases_subspace_specimens>();
sounds::sound( g->u.pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ), false, "environment",
"alarm" );
g->m.translate_radius( t_reinforced_glass, t_thconc_floor, 25.0, g->u.pos(), true );
query_any( _( "Containment shields opened. Press any key..." ) );
break;
// COMPACT_RELEASE_DISARM falls through to just COMPACT_RELEASE_BIONICS
case COMPACT_RELEASE_DISARM:
remove_submap_turrets();
/* fallthrough */
case COMPACT_RELEASE_BIONICS:
sounds::sound( g->u.pos(), 40, sounds::sound_t::alarm, _( "an alarm sound!" ), false, "environment",
"alarm" );
g->m.translate_radius( t_reinforced_glass, t_thconc_floor, 3.0, g->u.pos(), true );
query_any( _( "Containment shields opened. Press any key..." ) );
break;
case COMPACT_TERMINATE:
g->events().send<event_type::terminates_subspace_specimens>();
for( int x = 0; x < MAPSIZE_X; x++ ) {
for( int y = 0; y < MAPSIZE_Y; y++ ) {
tripoint p( x, y, g->u.posz() );
monster *const mon = g->critter_at<monster>( p );
if( mon &&
( ( g->m.ter( point( x, y - 1 ) ) == t_reinforced_glass &&
g->m.ter( point( x, y + 1 ) ) == t_concrete_wall ) ||
( g->m.ter( point( x, y + 1 ) ) == t_reinforced_glass &&
g->m.ter( point( x, y - 1 ) ) == t_concrete_wall ) ) ) {
mon->die( &g->u );
}
}
}
query_any( _( "Subjects terminated. Press any key..." ) );
break;
case COMPACT_PORTAL: {
g->events().send<event_type::opens_portal>();
tripoint tmp = g->u.pos();
int &i = tmp.x;
int &j = tmp.y;
for( i = 0; i < MAPSIZE_X; i++ ) {
for( j = 0; j < MAPSIZE_Y; j++ ) {
int numtowers = 0;
tripoint tmp2 = tmp;
int &xt = tmp2.x;
int &yt = tmp2.y;
for( xt = i - 2; xt <= i + 2; xt++ ) {
for( yt = j - 2; yt <= j + 2; yt++ ) {
if( g->m.ter( tmp2 ) == t_radio_tower ) {
numtowers++;
}
}
}
if( numtowers >= 4 ) {
if( g->m.tr_at( tmp ).id == trap_str_id( "tr_portal" ) ) {
g->m.remove_trap( tmp );
} else {
g->m.trap_set( tmp, tr_portal );
}
}
}
}
}
break;
case COMPACT_CASCADE: {
if( !query_bool( _( "WARNING: Resonance cascade carries severe risk! Continue?" ) ) ) {
return;
}
g->events().send<event_type::causes_resonance_cascade>();
std::vector<tripoint> cascade_points;
for( const tripoint &dest : g->m.points_in_radius( g->u.pos(), 10 ) ) {
if( g->m.ter( dest ) == t_radio_tower ) {
cascade_points.push_back( dest );
}
}
explosion_handler::resonance_cascade( random_entry( cascade_points, g->u.pos() ) );
}
break;
case COMPACT_RESEARCH: {
// TODO: seed should probably be a member of the computer, or better: of the computer action.
// It is here to ensure one computer reporting the same text on each invocation.
const int seed = g->get_levx() + g->get_levy() + g->get_levz() + alerts;
std::string log = SNIPPET.get( SNIPPET.assign( "lab_notes", seed ) );
if( log.empty() ) {
log = _( "No data found." );
} else {
g->u.moves -= 70;
}
print_text( "%s", log );
// One's an anomaly
if( alerts == 0 ) {
query_any( _( "Local data-access error logged, alerting helpdesk. Press any key..." ) );
alerts ++;
} else {
// Two's a trend.
query_any(
_( "Warning: anomalous archive-access activity detected at this node. Press any key..." ) );
alerts ++;
}
}
break;
case COMPACT_RADIO_ARCHIVE: {
g->u.moves -= 300;
sfx::fade_audio_channel( sfx::channel::radio, 100 );
sfx::play_ambient_variant_sound( "radio", "inaudible_chatter", 100, sfx::channel::radio,
2000 );
print_text( "Accessing archive. Playing audio recording nr %d.\n%s", rng( 1, 9999 ),
SNIPPET.random_from_category( "radio_archive" ) );
if( one_in( 3 ) ) {
query_any( _( "Warning: resticted data access. Attempt logged. Press any key..." ) );
alerts ++;
} else {
query_any( _( "Press any key..." ) );
}
sfx::fade_audio_channel( sfx::channel::radio, 100 );
}
break;
case COMPACT_MAPS: {
g->u.moves -= 30;
const tripoint center = g->u.global_omt_location();
overmap_buffer.reveal( center.xy(), 40, 0 );
query_any(
_( "Surface map data downloaded. Local anomalous-access error logged. Press any key..." ) );
remove_option( COMPACT_MAPS );
alerts ++;
}
break;
case COMPACT_MAP_SEWER: {
g->u.moves -= 30;
const tripoint center = g->u.global_omt_location();
for( int i = -60; i <= 60; i++ ) {
for( int j = -60; j <= 60; j++ ) {
point offset( i, j );
const oter_id &oter = overmap_buffer.ter( center + offset );
if( is_ot_match( "sewer", oter, ot_match_type::type ) ||
is_ot_match( "sewage", oter, ot_match_type::prefix ) ) {
overmap_buffer.set_seen( center + offset, true );
}
}
}
query_any( _( "Sewage map data downloaded. Press any key..." ) );
remove_option( COMPACT_MAP_SEWER );
}
break;
case COMPACT_MAP_SUBWAY: {
g->u.moves -= 30;
const tripoint center = g->u.global_omt_location();
for( int i = -60; i <= 60; i++ ) {
for( int j = -60; j <= 60; j++ ) {
point offset( i, j );
const oter_id &oter = overmap_buffer.ter( center + offset );
if( is_ot_match( "subway", oter, ot_match_type::type ) ||
is_ot_match( "lab_train_depot", oter, ot_match_type::contains ) ) {
overmap_buffer.set_seen( center + offset, true );
}
}
}
query_any( _( "Subway map data downloaded. Press any key..." ) );
remove_option( COMPACT_MAP_SUBWAY );
}
break;
case COMPACT_MISS_LAUNCH: {
// Target Acquisition.
tripoint target = ui::omap::choose_point( 0 );
if( target == overmap::invalid_tripoint ) {
add_msg( m_info, _( "Target acquisition canceled." ) );
return;
}
// TODO: Z
target.z = 0;
if( query_yn( _( "Confirm nuclear missile launch." ) ) ) {
add_msg( m_info, _( "Nuclear missile launched!" ) );
//Remove the option to fire another missile.
options.clear();
} else {
add_msg( m_info, _( "Nuclear missile launch aborted." ) );
return;
}
g->refresh_all();
//Put some smoke gas and explosions at the nuke location.
const tripoint nuke_location = { g->u.pos() - point( 12, 0 ) };
for( const auto &loc : g->m.points_in_radius( nuke_location, 5, 0 ) ) {
if( one_in( 4 ) ) {
g->m.add_field( loc, fd_smoke, rng( 1, 9 ) );
}
}
//Only explode once. But make it large.
explosion_handler::explosion( nuke_location, 2000, 0.7, true );
//...ERASE MISSILE, OPEN SILO, DISABLE COMPUTER
// For each level between here and the surface, remove the missile
for( int level = g->get_levz(); level <= 0; level++ ) {
map tmpmap;
tmpmap.load( tripoint( g->get_levx(), g->get_levy(), level ), false );
if( level < 0 ) {
tmpmap.translate( t_missile, t_hole );
} else {
tmpmap.translate( t_metal_floor, t_hole );
}
tmpmap.save();
}
const oter_id oter = overmap_buffer.ter( target );
g->events().send<event_type::launches_nuke>( oter );
for( int x = target.x - 2; x <= target.x + 2; x++ ) {
for( int y = target.y - 2; y <= target.y + 2; y++ ) {
// give it a nice rounded shape
if( !( x == ( target.x - 2 ) && ( y == ( target.y - 2 ) ) ) &&
!( x == ( target.x - 2 ) && ( y == ( target.y + 2 ) ) ) &&
!( x == ( target.x + 2 ) && ( y == ( target.y - 2 ) ) ) &&
!( x == ( target.x + 2 ) && ( y == ( target.y + 2 ) ) ) ) {
// TODO: Z
explosion_handler::nuke( tripoint( x, y, 0 ) );
}
}
}
activate_failure( COMPFAIL_SHUTDOWN );
}
break;
case COMPACT_MISS_DISARM: // TODO: stop the nuke from creating radioactive clouds.
if( query_yn( _( "Disarm missile." ) ) ) {
g->events().send<event_type::disarms_nuke>();
add_msg( m_info, _( "Nuclear missile disarmed!" ) );
//disable missile.
options.clear();
activate_failure( COMPFAIL_SHUTDOWN );
} else {
add_msg( m_neutral, _( "Nuclear missile remains active." ) );
return;
}
break;
case COMPACT_LIST_BIONICS: {
g->u.moves -= 30;
std::vector<std::string> names;
int more = 0;
for( int x = 0; x < MAPSIZE_X; x++ ) {
for( int y = 0; y < MAPSIZE_Y; y++ ) {
for( auto &elem : g->m.i_at( point( x, y ) ) ) {
if( elem.is_bionic() ) {
if( static_cast<int>( names.size() ) < TERMY - 8 ) {
names.push_back( elem.tname() );
} else {
more++;
}
}
}
}
}
reset_terminal();
print_newline();
print_line( _( "Bionic access - Manifest:" ) );
print_newline();
for( auto &name : names ) {
print_line( "%s", name );
}
if( more > 0 ) {
print_line( ngettext( "%d OTHER FOUND...", "%d OTHERS FOUND...", more ), more );
}
print_newline();
query_any( _( "Press any key..." ) );
}
break;
case COMPACT_ELEVATOR_ON:
for( int x = 0; x < MAPSIZE_X; x++ ) {
for( int y = 0; y < MAPSIZE_Y; y++ ) {
if( g->m.ter( point( x, y ) ) == t_elevator_control_off ) {
g->m.ter_set( point( x, y ), t_elevator_control );
}
}
}
query_any( _( "Elevator activated. Press any key..." ) );
break;
case COMPACT_AMIGARA_LOG: {
g->u.moves -= 30;
reset_terminal();
print_line( _( "NEPower Mine(%d:%d) Log" ), g->get_levx(), g->get_levy() );
print_text( "%s", SNIPPET.get( SNIPPET.assign( "amigara1" ) ) );
if( !query_bool( _( "Continue reading?" ) ) ) {
return;
}
g->u.moves -= 30;
reset_terminal();
print_line( _( "NEPower Mine(%d:%d) Log" ), g->get_levx(), g->get_levy() );
print_text( "%s", SNIPPET.get( SNIPPET.assign( "amigara2" ) ) );
if( !query_bool( _( "Continue reading?" ) ) ) {
return;
}
g->u.moves -= 30;
reset_terminal();
print_line( _( "NEPower Mine(%d:%d) Log" ), g->get_levx(), g->get_levy() );
print_text( "%s", SNIPPET.get( SNIPPET.assign( "amigara3" ) ) );
if( !query_bool( _( "Continue reading?" ) ) ) {
return;
}
reset_terminal();
for( int i = 0; i < 10; i++ ) {
print_gibberish_line();
}
print_newline();
print_newline();
print_newline();
print_line( _( "AMIGARA PROJECT" ) );
print_newline();
print_newline();
if( !query_bool( _( "Continue reading?" ) ) ) {
return;
}
g->u.moves -= 30;
reset_terminal();
print_line( _( "SITE %d%d%d\n"
"PERTINENT FOREMAN LOGS WILL BE PREPENDED TO NOTES" ),
g->get_levx(), g->get_levy(), abs( g->get_levz() ) );
print_text( "%s", SNIPPET.get( SNIPPET.assign( "amigara4" ) ) );
print_gibberish_line();
print_gibberish_line();
print_newline();
print_error( _( "FILE CORRUPTED, PRESS ANY KEY..." ) );
inp_mngr.wait_for_any_key();
reset_terminal();
break;
}
case COMPACT_AMIGARA_START:
g->timed_events.add( TIMED_EVENT_AMIGARA, calendar::turn + 1_minutes );
if( !g->u.has_artifact_with( AEP_PSYSHIELD ) ) {
g->u.add_effect( effect_amigara, 2_minutes );
}
// Disable this action to prevent further amigara events, which would lead to
// further amigara monster, which would lead to further artifacts.
remove_option( COMPACT_AMIGARA_START );
break;
case COMPACT_COMPLETE_DISABLE_EXTERNAL_POWER:
for( auto miss : g->u.get_active_missions() ) {
static const mission_type_id commo_2 = mission_type_id( "MISSION_OLD_GUARD_NEC_COMMO_2" );
if( miss->mission_id() == commo_2 ) {
print_error( _( "--ACCESS GRANTED--" ) );
print_error( _( "Mission Complete!" ) );
miss->step_complete( 1 );
inp_mngr.wait_for_any_key();
return;
//break;
}
}
print_error( _( "ACCESS DENIED" ) );
inp_mngr.wait_for_any_key();
break;
case COMPACT_REPEATER_MOD:
if( g->u.has_amount( "radio_repeater_mod", 1 ) ) {
for( auto miss : g->u.get_active_missions() ) {
static const mission_type_id commo_3 = mission_type_id( "MISSION_OLD_GUARD_NEC_COMMO_3" ),
commo_4 = mission_type_id( "MISSION_OLD_GUARD_NEC_COMMO_4" );
if( miss->mission_id() == commo_3 || miss->mission_id() == commo_4 ) {
miss->step_complete( 1 );
print_error( _( "Repeater mod installed..." ) );
print_error( _( "Mission Complete!" ) );
g->u.use_amount( "radio_repeater_mod", 1 );
inp_mngr.wait_for_any_key();
options.clear();
activate_failure( COMPFAIL_SHUTDOWN );
break;
}
}
} else {
print_error( _( "You do not have a repeater mod to install..." ) );
inp_mngr.wait_for_any_key();
break;
}
break;
case COMPACT_DOWNLOAD_SOFTWARE:
if( item *const usb = pick_usb() ) {
mission *miss = mission::find( mission_id );
if( miss == nullptr ) {
debugmsg( _( "Computer couldn't find its mission!" ) );
return;
}
g->u.moves -= 30;
item software( miss->get_item_id(), 0 );
software.mission_id = mission_id;
usb->contents.clear();
usb->put_in( software );
print_line( _( "Software downloaded." ) );
} else {
print_error( _( "USB drive required!" ) );
}
inp_mngr.wait_for_any_key();
break;
case COMPACT_BLOOD_ANAL:
g->u.moves -= 70;
for( const tripoint &dest : g->m.points_in_radius( g->u.pos(), 2 ) ) {
if( g->m.ter( dest ) == t_centrifuge ) {
map_stack items = g->m.i_at( dest );
if( items.empty() ) {
print_error( _( "ERROR: Please place sample in centrifuge." ) );
} else if( items.size() > 1 ) {
print_error( _( "ERROR: Please remove all but one sample from centrifuge." ) );
} else if( items.only_item().contents.empty() ) {
print_error( _( "ERROR: Please only use container with blood sample." ) );
} else if( items.only_item().contents.front().typeId() != "blood" ) {
print_error( _( "ERROR: Please only use blood samples." ) );
} else { // Success!
const item &blood = items.only_item().contents.front();
const mtype *mt = blood.get_mtype();
if( mt == nullptr || mt->id == mtype_id::NULL_ID() ) {
print_line( _( "Result: Human blood, no pathogens found." ) );
} else if( mt->in_species( ZOMBIE ) ) {
if( mt->in_species( HUMAN ) ) {
print_line( _( "Result: Human blood. Unknown pathogen found." ) );
} else {
print_line( _( "Result: Unknown blood type. Unknown pathogen found." ) );
}
print_line( _( "Pathogen bonded to erythrocytes and leukocytes." ) );
if( query_bool( _( "Download data?" ) ) ) {
if( item *const usb = pick_usb() ) {
item software( "software_blood_data", 0 );
usb->contents.clear();
usb->put_in( software );
print_line( _( "Software downloaded." ) );
} else {
print_error( _( "USB drive required!" ) );
}
}
} else {
print_line( _( "Result: Unknown blood type. Test non-conclusive." ) );
}
}
}
}
query_any( _( "Press any key..." ) );
break;
case COMPACT_DATA_ANAL:
g->u.moves -= 30;
for( const tripoint &dest : g->m.points_in_radius( g->u.pos(), 2 ) ) {
if( g->m.ter( dest ) == t_floor_blue ) {
print_error( _( "PROCESSING DATA" ) );
map_stack items = g->m.i_at( dest );
if( items.empty() ) {
print_error( _( "ERROR: Please place memory bank in scan area." ) );
} else if( items.size() > 1 ) {
print_error( _( "ERROR: Please only scan one item at a time." ) );
} else if( items.only_item().typeId() != "usb_drive" &&
items.only_item().typeId() != "black_box" ) {
print_error( _( "ERROR: Memory bank destroyed or not present." ) );
} else if( items.only_item().typeId() == "usb_drive" && items.only_item().contents.empty() ) {
print_error( _( "ERROR: Memory bank is empty." ) );
} else { // Success!
if( items.only_item().typeId() == "black_box" ) {
print_line( _( "Memory Bank: Military Hexron Encryption\nPrinting Transcript\n" ) );
item transcript( "black_box_transcript", calendar::turn );
g->m.add_item_or_charges( point( g->u.posx(), g->u.posy() ), transcript );
} else {
print_line( _( "Memory Bank: Unencrypted\nNothing of interest.\n" ) );
}
}
}
}
query_any( _( "Press any key..." ) );
break;
case COMPACT_DISCONNECT:
reset_terminal();
print_line( _( "\n"
"ERROR: NETWORK DISCONNECT \n"
"UNABLE TO REACH NETWORK ROUTER OR PROXY. PLEASE CONTACT YOUR\n"
"SYSTEM ADMINISTRATOR TO RESOLVE THIS ISSUE.\n"
" \n" ) );
query_any( _( "Press any key to continue..." ) );
break;
case COMPACT_EMERG_MESS:
print_line( _( "GREETINGS CITIZEN. A BIOLOGICAL ATTACK HAS TAKEN PLACE AND A STATE OF \n"
"EMERGENCY HAS BEEN DECLARED. EMERGENCY PERSONNEL WILL BE AIDING YOU \n"
"SHORTLY. TO ENSURE YOUR SAFETY PLEASE FOLLOW THE STEPS BELOW. \n"
"\n"
"1. DO NOT PANIC. \n"
"2. REMAIN INSIDE THE BUILDING. \n"
"3. SEEK SHELTER IN THE BASEMENT. \n"
"4. USE PROVIDED GAS MASKS. \n"
"5. AWAIT FURTHER INSTRUCTIONS. \n"
"\n"
" \n" ) );
query_any( _( "Press any key to continue..." ) );
break;
case COMPACT_EMERG_REF_CENTER:
reset_terminal();
mark_refugee_center();
reset_terminal();
break;
case COMPACT_TOWER_UNRESPONSIVE:
print_line( _( " WARNING, RADIO TOWER IS UNRESPONSIVE. \n"
" \n"
" BACKUP POWER INSUFFICIENT TO MEET BROADCASTING REQUIREMENTS. \n"
" IN THE EVENT OF AN EMERGENCY, CONTACT LOCAL NATIONAL GUARD \n"
" UNITS TO RECEIVE PRIORITY WHEN GENERATORS ARE BEING DEPLOYED. \n"
" \n"
" \n" ) );