-
Notifications
You must be signed in to change notification settings - Fork 89
/
npctalk.cpp
1915 lines (1739 loc) · 56.1 KB
/
npctalk.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 "npc.h"
#include "output.h"
#include "game.h"
#include "dialogue.h"
#include "rng.h"
#include "line.h"
#include "keypress.h"
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
// Every OWED_VAL that the NPC owes you counts as +1 towards convincing
#define OWED_VAL 250
// Some aliases to help with gen_responses
#define RESPONSE(txt) ret.push_back(talk_response());\
ret.back().text = txt
#define SELECT_MISS(txt, index) ret.push_back(talk_response());\
ret.back().text = txt;\
ret.back().mission_index = index
#define SELECT_TEMP(txt, index) ret.push_back(talk_response());\
ret.back().text = txt;\
ret.back().tempvalue = index
#define TRIAL(tr, diff) ret.back().trial = tr;\
ret.back().difficulty = diff
#define SUCCESS(topic) ret.back().success = topic
#define FAILURE(topic) ret.back().failure = topic
#define SUCCESS_OPINION(T, F, V, A, O) ret.back().opinion_success =\
npc_opinion(T, F, V, A, O)
#define FAILURE_OPINION(T, F, V, A, O) ret.back().opinion_failure =\
npc_opinion(T, F, V, A, O)
#define SUCCESS_ACTION(func) ret.back().effect_success = func
#define FAILURE_ACTION(func) ret.back().effect_failure = func
#define SUCCESS_MISSION(type) ret.back().miss = type
std::string dynamic_line(talk_topic topic, game *g, npc *p);
std::vector<talk_response> gen_responses(talk_topic topic, game *g, npc *p);
int topic_category(talk_topic topic);
talk_topic special_talk(char ch);
int trial_chance(talk_response response, player *u, npc *p);
bool trade(game *g, npc *p, int cost, std::string deal);
void npc::talk_to_u(game *g)
{
// This is necessary so that we don't bug the player over and over
if (attitude == NPCATT_TALK)
attitude = NPCATT_NULL;
else if (attitude == NPCATT_FLEE) {
g->add_msg("%s is fleeing you!", name.c_str());
return;
} else if (attitude == NPCATT_KILL) {
g->add_msg("%s is hostile!", name.c_str());
return;
}
dialogue d;
d.alpha = &g->u;
d.beta = this;
d.topic_stack.push_back(chatbin.first_topic);
if (is_leader())
d.topic_stack.push_back(TALK_LEADER);
else if (is_friend())
d.topic_stack.push_back(TALK_FRIEND);
int most_difficult_mission = 0;
for (int i = 0; i < chatbin.missions.size(); i++) {
mission_type *type = g->find_mission_type(chatbin.missions[i]);
if (type->urgent && type->difficulty > most_difficult_mission) {
d.topic_stack.push_back(TALK_MISSION_DESCRIBE);
chatbin.mission_selected = i;
most_difficult_mission = type->difficulty;
}
}
most_difficult_mission = 0;
bool chosen_urgent = false;
for (int i = 0; i < chatbin.missions_assigned.size(); i++) {
mission_type *type = g->find_mission_type(chatbin.missions_assigned[i]);
if ((type->urgent && !chosen_urgent) ||
(type->difficulty > most_difficult_mission &&
(type->urgent || !chosen_urgent) )) {
chosen_urgent = type->urgent;
d.topic_stack.push_back(TALK_MISSION_INQUIRE);
chatbin.mission_selected = i;
most_difficult_mission = type->difficulty;
}
}
if (d.topic_stack.back() == TALK_NONE)
d.topic_stack.back() = pick_talk_topic(&(g->u));
moves -= 100;
decide_needs();
d.win = newwin(25, 80, 0, 0);
wborder(d.win, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
for (int i = 1; i < 24; i++)
mvwputch(d.win, i, 41, c_ltgray, LINE_XOXO);
mvwputch(d.win, 0, 41, c_ltgray, LINE_OXXX);
mvwputch(d.win, 24, 41, c_ltgray, LINE_XXOX);
mvwprintz(d.win, 1, 1, c_white, "Dialogue with %s", name.c_str());
mvwprintz(d.win, 1, 43, c_white, "Your response:");
// Main dialogue loop
do {
talk_topic next = d.opt(d.topic_stack.back(), g);
if (next == TALK_NONE) {
int cat = topic_category(d.topic_stack.back());
do
d.topic_stack.pop_back();
while (cat != -1 && topic_category(d.topic_stack.back()) == cat);
}
if (next == TALK_DONE || d.topic_stack.empty())
d.done = true;
else if (next != TALK_NONE)
d.topic_stack.push_back(next);
} while (!d.done);
delwin(d.win);
g->refresh_all();
}
std::string dynamic_line(talk_topic topic, game *g, npc *p)
{
// First, a sanity test for mission stuff
if (topic >= TALK_MISSION_START && topic <= TALK_MISSION_END) {
if (topic == TALK_MISSION_START)
return "Used TALK_MISSION_START - not meant to be used!";
if (topic == TALK_MISSION_END)
return "Used TALK_MISSION_END - not meant to be used!";
if (p->chatbin.mission_selected == -1)
return "mission_selected = -1; BUG!";
int id = -1;
if (topic == TALK_MISSION_INQUIRE || topic == TALK_MISSION_ACCEPTED ||
topic == TALK_MISSION_SUCCESS || topic == TALK_MISSION_ADVICE ||
topic == TALK_MISSION_FAILURE || topic == TALK_MISSION_SUCCESS_LIE) {
if (p->chatbin.mission_selected >= p->chatbin.missions_assigned.size())
return "mission_selected is too high; BUG!";
id = p->chatbin.missions_assigned[ p->chatbin.mission_selected ];
} else {
if (p->chatbin.mission_selected >= p->chatbin.missions.size())
return "mission_selected is too high; BUG!";
id = p->chatbin.missions[ p->chatbin.mission_selected ];
}
// Mission stuff is a special case, so we'll handle it up here
mission *miss = g->find_mission(id);
mission_type *type = miss->type;
std::string ret = mission_dialogue(mission_id(type->id), topic);
if (topic == TALK_MISSION_SUCCESS && miss->follow_up != MISSION_NULL)
return ret + " And I have more I'd like you to do.";
return ret;
}
switch (topic) {
case TALK_NONE:
case TALK_DONE:
return "";
case TALK_MISSION_LIST:
if (p->chatbin.missions.empty()) {
if (p->chatbin.missions_assigned.empty())
return "I don't have any jobs for you.";
else
return "I don't have any more jobs for you.";
} else if (p->chatbin.missions.size() == 1) {
if (p->chatbin.missions_assigned.empty())
return "I just have one job for you. Want to hear about it?";
else
return "I have other one job for you. Want to hear about it?";
} else if (p->chatbin.missions_assigned.empty())
return "I have several jobs for you. Which should I describe?";
else
return "I have several more jobs for you. Which should I describe?";
case TALK_MISSION_LIST_ASSIGNED:
if (p->chatbin.missions_assigned.empty())
return "You're not working on anything for me right now.";
else if (p->chatbin.missions_assigned.size() == 1)
return "What about it?";
else
return "Which job?";
case TALK_MISSION_REWARD:
return "Sure, here you go!";
case TALK_SHELTER:
switch (rng(1, 2)) {
case 1: return "Well, I guess it's just us.";
case 2: return "At least we've got shelter.";
}
case TALK_SHELTER_PLANS:
return "I don't know, look for supplies and other survivors I guess.";
case TALK_SHARE_EQUIPMENT:
if (p->has_disease(DI_ASKED_FOR_ITEM))
return "You just asked me for stuff; ask later.";
return "Why should I share my equipment with you?";
case TALK_GIVE_EQUIPMENT:
return "Okay, here you go.";
case TALK_DENY_EQUIPMENT:
if (p->op_of_u.anger >= p->hostile_anger_level() - 4)
return "<no>, and if you ask again, <ill_kill_you>!";
else
return "<no><punc> <fuck_you>!";
case TALK_TRAIN: {
if (g->u.backlog.type == ACT_TRAIN)
return "Shall we resume?";
std::vector<skill> trainable = p->skills_offered_to( &(g->u) );
std::vector<itype_id> styles = p->styles_offered_to( &(g->u) );
if (trainable.empty() && styles.empty())
return "Sorry, but it doesn't seem I have anything to teach you.";
else
return "Here's what I can teach you...";
} break;
case TALK_TRAIN_START:
if (g->cur_om.is_safe(g->om_location().x, g->om_location().y))
return "Alright, let's begin.";
else
return "It's not safe here. Let's get to safety first.";
break;
case TALK_TRAIN_FORCE:
return "Alright, let's begin.";
case TALK_SUGGEST_FOLLOW:
if (p->has_disease(DI_INFECTION))
return "Not until I get some antibiotics...";
if (p->has_disease(DI_ASKED_TO_FOLLOW))
return "You asked me recently; ask again later.";
return "Why should I travel with you?";
case TALK_AGREE_FOLLOW:
return "You got it, I'm with you!";
case TALK_DENY_FOLLOW:
return "Yeah... I don't think so.";
case TALK_LEADER:
return "What is it?";
case TALK_LEAVE:
return "You're really leaving?";
case TALK_PLAYER_LEADS:
return "Alright. You can lead now.";
case TALK_LEADER_STAYS:
return "No. I'm the leader here.";
case TALK_HOW_MUCH_FURTHER: {
int dist = rl_dist(g->om_location(), point(p->goalx, p->goaly));
std::stringstream response;
dist *= 100;
if (dist >= 1300) {
int miles = dist / 52; // *100, e.g. quarter mile is "25"
miles -= miles % 25; // Round to nearest quarter-mile
int fullmiles = (miles - miles % 100) / 100; // Left of the decimal point
if (fullmiles > 0)
response << fullmiles;
response << "." << miles << " miles.";
} else
response << dist << " feet.";
return response.str();
}
case TALK_FRIEND:
return "What is it?";
case TALK_COMBAT_COMMANDS: {
std::stringstream status;
status << "*is "; // Prepending * makes this an action, not a phrase
switch (p->combat_rules.engagement) {
case ENGAGE_NONE: status << "not engaging enemies."; break;
case ENGAGE_CLOSE: status << "engaging nearby enemies."; break;
case ENGAGE_WEAK: status << "engaging weak enemies."; break;
case ENGAGE_HIT: status << "engaging enemies you attack."; break;
case ENGAGE_ALL: status << "engaging all enemies."; break;
}
status << " " << (p->male ? "He" : "She") << " will " <<
(p->combat_rules.use_guns ? "" : "not ") << "use firearms.";
status << " " << (p->male ? "He" : "She") << " will " <<
(p->combat_rules.use_grenades ? "" : "not ") << "use grenades.";
return status.str();
}
case TALK_COMBAT_ENGAGEMENT:
return "What should I do?";
case TALK_STRANGER_NEUTRAL:
if (p->myclass == NC_TRADER)
return "Hello! Would you care to see my goods?";
return "Hello there.";
case TALK_STRANGER_WARY:
return "Okay, no sudden movements...";
case TALK_STRANGER_SCARED:
return "Keep your distance!";
case TALK_STRANGER_FRIENDLY:
if (p->myclass == NC_TRADER)
return "Hello! Would you care to see my goods?";
return "Hey there, <name_g>.";
case TALK_STRANGER_AGGRESSIVE:
if (!g->u.unarmed_attack())
return "<drop_it>";
else
return "This is my territory, <name_b>.";
case TALK_MUG:
if (!g->u.unarmed_attack())
return "<drop_it>";
else
return "<hands_up>";
case TALK_DESCRIBE_MISSION:
switch (p->mission) {
case NPC_MISSION_RESCUE_U:
return "I'm here to save you!";
case NPC_MISSION_SHELTER:
return "I'm holing up here for safety.";
case NPC_MISSION_SHOPKEEP:
return "I run the shop here.";
case NPC_MISSION_MISSING:
return "Well, I was lost, but you found me...";
case NPC_MISSION_KIDNAPPED:
return "Well, I was kidnapped, but you saved me...";
case NPC_MISSION_NULL:
switch (p->myclass) {
case NC_HACKER:
return "I'm looking for some choice systems to hack.";
case NC_DOCTOR:
return "I'm looking for wounded to help.";
case NC_TRADER:
return "I'm collecting gear and selling it.";
case NC_NINJA:
if (!p->styles.empty()) {
std::stringstream ret;
ret << "I am a wandering master of " <<
g->itypes[p->styles[0]]->name.c_str() << ".";
return ret.str();
} else
return "I am looking for a master to train my fighting techniques.";
case NC_COWBOY:
return "Just looking for some wrongs to right.";
case NC_SCIENTIST:
return "I'm looking for clues concerning these monsters' origins...";
case NC_BOUNTY_HUNTER:
return "I'm a killer for hire.";
case NC_NONE:
return "I'm just wandering.";
default:
return "ERROR: Someone forgot to code an npc_class text.";
} // switch (p->myclass)
default:
return "ERROR: Someone forgot to code an npc_mission text.";
} // switch (p->mission)
break;
case TALK_WEAPON_DROPPED: {
std::stringstream ret;
ret << "*drops " << (p->male ? "his" : "her") << " weapon.";
return ret.str();
}
case TALK_DEMAND_LEAVE:
return "Now get out of here, before I kill you.";
case TALK_SIZE_UP: {
int ability = g->u.per_cur * 3 + g->u.int_cur;
if (ability <= 10)
return "&You can't make anything out.";
std::stringstream info;
info << "&";
int str_range = int(100 / ability);
int str_min = int(p->str_max / str_range) * str_range;
info << "Str " << str_min << " - " << str_min + str_range;
if (ability >= 40) {
int dex_range = int(160 / ability);
int dex_min = int(p->dex_max / dex_range) * dex_range;
info << " Dex " << dex_min << " - " << dex_min + dex_range;
}
if (ability >= 50) {
int int_range = int(200 / ability);
int int_min = int(p->int_max / int_range) * int_range;
info << " Int " << int_min << " - " << int_min + int_range;
}
if (ability >= 60) {
int per_range = int(240 / ability);
int per_min = int(p->per_max / per_range) * per_range;
info << " Per " << per_min << " - " << per_min + per_range;
}
return info.str();
} break;
case TALK_LOOK_AT: {
std::stringstream look;
look << "&" << p->short_description();
return look.str();
} break;
case TALK_OPINION: {
std::stringstream opinion;
opinion << "&" << p->opinion_text();
return opinion.str();
} break;
}
return "I don't know what to say. (BUG)";
}
std::vector<talk_response> gen_responses(talk_topic topic, game *g, npc *p)
{
std::vector<talk_response> ret;
int selected = p->chatbin.mission_selected;
mission *miss = NULL;
if (selected != -1 && selected < p->chatbin.missions_assigned.size())
miss = g->find_mission( p->chatbin.missions_assigned[selected] );
switch (topic) {
case TALK_MISSION_LIST:
if (p->chatbin.missions.empty()) {
RESPONSE("Oh, okay.");
SUCCESS(TALK_NONE);
} else if (p->chatbin.missions.size() == 1) {
SELECT_MISS("Tell me about it.", 0);
SUCCESS(TALK_MISSION_OFFER);
RESPONSE("Never mind, I'm not interested.");
SUCCESS(TALK_NONE);
} else {
for (int i = 0; i < p->chatbin.missions.size(); i++) {
SELECT_MISS(g->find_mission_type( p->chatbin.missions[i] )->name, i);
SUCCESS(TALK_MISSION_OFFER);
}
RESPONSE("Never mind, I'm not interested.");
SUCCESS(TALK_NONE);
}
break;
case TALK_MISSION_LIST_ASSIGNED:
if (p->chatbin.missions_assigned.empty()) {
RESPONSE("Never mind then.");
SUCCESS(TALK_NONE);
} else if (p->chatbin.missions_assigned.size() == 1) {
SELECT_MISS("I have news.", 0);
SUCCESS(TALK_MISSION_INQUIRE);
RESPONSE("Never mind.");
SUCCESS(TALK_NONE);
} else {
for (int i = 0; i < p->chatbin.missions_assigned.size(); i++) {
SELECT_MISS(g->find_mission_type( p->chatbin.missions_assigned[i] )->name,
i);
SUCCESS(TALK_MISSION_INQUIRE);
}
RESPONSE("Never mind.");
SUCCESS(TALK_NONE);
}
break;
case TALK_MISSION_DESCRIBE:
RESPONSE("What's the matter?");
SUCCESS(TALK_MISSION_OFFER);
RESPONSE("I don't care.");
SUCCESS(TALK_MISSION_REJECTED);
break;
case TALK_MISSION_OFFER:
RESPONSE("I'll do it!");
SUCCESS(TALK_MISSION_ACCEPTED);
SUCCESS_ACTION(&talk_function::assign_mission);
RESPONSE("Not interested.");
SUCCESS(TALK_MISSION_REJECTED);
break;
case TALK_MISSION_ACCEPTED:
RESPONSE("Not a problem.");
SUCCESS(TALK_NONE);
RESPONSE("Got any advice?");
SUCCESS(TALK_MISSION_ADVICE);
RESPONSE("Can you share some equipment?");
SUCCESS(TALK_SHARE_EQUIPMENT);
RESPONSE("I'll be back soon!");
SUCCESS(TALK_DONE);
break;
case TALK_MISSION_ADVICE:
RESPONSE("Sounds good, thanks.");
SUCCESS(TALK_NONE);
RESPONSE("Sounds good. Bye!");
SUCCESS(TALK_DONE);
break;
case TALK_MISSION_REJECTED:
RESPONSE("I'm sorry.");
SUCCESS(TALK_NONE);
RESPONSE("Whatever. Bye.");
SUCCESS(TALK_DONE);
break;
case TALK_MISSION_INQUIRE: {
int id = p->chatbin.missions_assigned[ p->chatbin.mission_selected ];
if (g->mission_failed(id)) {
RESPONSE("I'm sorry... I failed.");
SUCCESS(TALK_MISSION_FAILURE);
SUCCESS_OPINION(-1, 0, -1, 1, 0);
RESPONSE("Not yet.");
TRIAL(TALK_TRIAL_LIE, 10 + p->op_of_u.trust * 3);
SUCCESS(TALK_NONE);
FAILURE(TALK_MISSION_FAILURE);
FAILURE_OPINION(-3, 0, -1, 2, 0);
} else if (!g->mission_complete(id, p->id)) {
mission_type *type = g->find_mission_type(id);
RESPONSE("Not yet.");
SUCCESS(TALK_NONE);
if (type->goal == MGOAL_KILL_MONSTER) {
RESPONSE("Yup, I killed it.");
TRIAL(TALK_TRIAL_LIE, 10 + p->op_of_u.trust * 5);
SUCCESS(TALK_MISSION_SUCCESS);
SUCCESS_ACTION(&talk_function::mission_success);
FAILURE(TALK_MISSION_SUCCESS_LIE);
FAILURE_OPINION(-5, 0, -1, 5, 0);
FAILURE_ACTION(&talk_function::mission_failure);
}
RESPONSE("No. I'll get back to it, bye!");
SUCCESS(TALK_DONE);
} else {
// TODO: Lie about mission
mission_type *type = g->find_mission_type(id);
switch (type->goal) {
case MGOAL_FIND_ITEM:
case MGOAL_FIND_ANY_ITEM:
RESPONSE("Yup! Here it is!");
SUCCESS(TALK_MISSION_SUCCESS);
SUCCESS_ACTION(&talk_function::mission_success);
break;
case MGOAL_GO_TO:
case MGOAL_FIND_NPC:
RESPONSE("Here I am.");
SUCCESS(TALK_MISSION_SUCCESS);
SUCCESS_ACTION(&talk_function::mission_success);
break;
case MGOAL_FIND_MONSTER:
RESPONSE("Here it is!");
SUCCESS(TALK_MISSION_SUCCESS);
SUCCESS_ACTION(&talk_function::mission_success);
break;
case MGOAL_KILL_MONSTER:
RESPONSE("I killed it.");
SUCCESS(TALK_MISSION_SUCCESS);
SUCCESS_ACTION(&talk_function::mission_success);
break;
default:
RESPONSE("Mission success! I don't know what else to say.");
SUCCESS(TALK_MISSION_SUCCESS);
SUCCESS_ACTION(&talk_function::mission_success);
break;
}
}
} break;
case TALK_MISSION_SUCCESS:
RESPONSE("Glad to help. I need no payment.");
SUCCESS(TALK_NONE);
SUCCESS_OPINION(miss->value / (OWED_VAL * 4), -1,
miss->value / (OWED_VAL * 2), -1, 0 - miss->value);
SUCCESS_ACTION(&talk_function::clear_mission);
RESPONSE("How about some items as payment?");
SUCCESS(TALK_MISSION_REWARD);
SUCCESS_ACTION(&talk_function::mission_reward);
SELECT_TEMP("Maybe you can teach me something as payment.", 0);
SUCCESS(TALK_TRAIN);
SUCCESS_ACTION(&talk_function::clear_mission);
RESPONSE("Alright, well, you owe me one.");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::clear_mission);
RESPONSE("Glad to help. I need no payment. Bye!");
SUCCESS(TALK_DONE);
SUCCESS_ACTION(&talk_function::clear_mission);
SUCCESS_OPINION(p->op_of_u.owed / (OWED_VAL * 4), -1,
p->op_of_u.owed / (OWED_VAL * 2), -1, 0 - miss->value);
break;
case TALK_MISSION_SUCCESS_LIE:
RESPONSE("Well, um, sorry.");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::clear_mission);
case TALK_MISSION_FAILURE:
RESPONSE("I'm sorry. I did what I could.");
SUCCESS(TALK_NONE);
break;
case TALK_MISSION_REWARD:
RESPONSE("Thank you.");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::clear_mission);
RESPONSE("Thanks, bye.");
SUCCESS(TALK_DONE);
SUCCESS_ACTION(&talk_function::clear_mission);
break;
case TALK_SHELTER:
RESPONSE("What should we do now?");
SUCCESS(TALK_SHELTER_PLANS);
RESPONSE("Can I do anything for you?");
SUCCESS(TALK_MISSION_LIST);
if (!p->is_following()) {
RESPONSE("Want to travel with me?");
SUCCESS(TALK_SUGGEST_FOLLOW);
}
if (p->chatbin.missions_assigned.size() == 1) {
RESPONSE("About that job...");
SUCCESS(TALK_MISSION_INQUIRE);
} else if (p->chatbin.missions_assigned.size() >= 2) {
RESPONSE("About one of those jobs...");
SUCCESS(TALK_MISSION_LIST_ASSIGNED);
}
RESPONSE("I can't leave the shelter without equipment...");
SUCCESS(TALK_SHARE_EQUIPMENT);
RESPONSE("Well, bye.");
SUCCESS(TALK_DONE);
break;
case TALK_SHELTER_PLANS:
// TODO: Add "follow me"
RESPONSE("Hmm, okay. Bye.");
SUCCESS(TALK_DONE);
break;
case TALK_SHARE_EQUIPMENT:
if (p->has_disease(DI_ASKED_FOR_ITEM)) {
RESPONSE("Okay, fine.");
SUCCESS(TALK_NONE);
} else {
int score = p->op_of_u.trust + p->op_of_u.value * 3 +
p->personality.altruism * 2;
int missions_value = p->assigned_missions_value(g);
RESPONSE("Because I'm your friend!");
TRIAL(TALK_TRIAL_PERSUADE, 10 + score);
SUCCESS(TALK_GIVE_EQUIPMENT);
SUCCESS_ACTION(&talk_function::give_equipment);
SUCCESS_OPINION(0, 0, -1, 0, score * 300);
FAILURE(TALK_DENY_EQUIPMENT);
FAILURE_OPINION(0, 0, -1, 0, 0);
if (missions_value >= 1) {
RESPONSE("Well, I am helping you out...");
TRIAL(TALK_TRIAL_PERSUADE, 12 + (.8 * score) + missions_value / OWED_VAL);
SUCCESS(TALK_GIVE_EQUIPMENT);
SUCCESS_ACTION(&talk_function::give_equipment);
FAILURE(TALK_DENY_EQUIPMENT);
FAILURE_OPINION(0, 0, -1, 0, 0);
}
RESPONSE("I'll give it back!");
TRIAL(TALK_TRIAL_LIE, score * 1.5);
SUCCESS(TALK_GIVE_EQUIPMENT);
SUCCESS_ACTION(&talk_function::give_equipment);
SUCCESS_OPINION(0, 0, -1, 0, score * 300);
FAILURE(TALK_DENY_EQUIPMENT);
FAILURE_OPINION(0, -1, -1, 1, 0);
RESPONSE("Give it to me, or else!");
TRIAL(TALK_TRIAL_INTIMIDATE, 40);
SUCCESS(TALK_GIVE_EQUIPMENT);
SUCCESS_ACTION(&talk_function::give_equipment);
SUCCESS_OPINION(-3, 2, -2, 2,
(g->u.intimidation() + p->op_of_u.fear -
p->personality.bravery - p->intimidation()) * 500);
FAILURE(TALK_DENY_EQUIPMENT);
FAILURE_OPINION(-3, 1, -3, 5, 0);
RESPONSE("Eh, never mind.");
SUCCESS(TALK_NONE);
RESPONSE("Never mind, I'll do without. Bye.");
SUCCESS(TALK_DONE);
}
break;
case TALK_GIVE_EQUIPMENT:
RESPONSE("Thank you!");
SUCCESS(TALK_NONE);
RESPONSE("Thanks! But can I have some more?");
SUCCESS(TALK_SHARE_EQUIPMENT);
RESPONSE("Thanks, see you later!");
SUCCESS(TALK_DONE);
break;
case TALK_DENY_EQUIPMENT:
RESPONSE("Okay, okay, sorry.");
SUCCESS(TALK_NONE);
RESPONSE("Seriously, give me more stuff!");
SUCCESS(TALK_SHARE_EQUIPMENT);
RESPONSE("Okay, fine, bye.");
SUCCESS(TALK_DONE);
break;
case TALK_TRAIN: {
if (g->u.backlog.type == ACT_TRAIN) {
std::stringstream resume;
resume << "Yes, let's resume training " <<
(g->u.backlog.index > 0 ?
skill_name(g->u.backlog.index) :
g->itypes[ 0 - g->u.backlog.index ]->name);
SELECT_TEMP( resume.str(), g->u.backlog.index);
SUCCESS(TALK_TRAIN_START);
}
std::vector<skill> trainable = p->skills_offered_to( &(g->u) );
std::vector<itype_id> styles = p->styles_offered_to( &(g->u) );
if (trainable.empty() && styles.empty()) {
RESPONSE("Oh, okay."); // Nothing to learn here
SUCCESS(TALK_NONE);
}
int printed = 0;
int shift = p->chatbin.tempvalue;
bool more = trainable.size() + styles.size() - shift > 9;
for (int i = shift; i < trainable.size() && printed < 9; i++) {
//shift--;
printed++;
std::stringstream skilltext;
skill trained = trainable[i];
skilltext << skill_name(trained) << ": " << g->u.sklevel[trained] <<
" -> " << g->u.sklevel[trained] + 1 << "(cost " <<
200 * (g->u.sklevel[trained] + 1) << ")";
SELECT_TEMP( skilltext.str(), trainable[i] );
SUCCESS(TALK_TRAIN_START);
}
if (shift < 0)
shift = 0;
for (int i = 0; i < styles.size() && printed < 9; i++) {
printed++;
SELECT_TEMP( g->itypes[styles[i]]->name + " (cost 800)",
0 - styles[i] );
SUCCESS(TALK_TRAIN_START);
}
if (more) {
SELECT_TEMP("More...", shift + 9);
SUCCESS(TALK_TRAIN);
}
if (shift > 0) {
int newshift = shift - 9;
if (newshift < 0)
newshift = 0;
SELECT_TEMP("Back...", newshift);
SUCCESS(TALK_TRAIN);
}
RESPONSE("Eh, never mind.");
SUCCESS(TALK_NONE);
} break;
case TALK_TRAIN_START:
if (g->cur_om.is_safe(g->om_location().x, g->om_location().y)) {
RESPONSE("Sounds good.");
SUCCESS(TALK_DONE);
SUCCESS_ACTION(&talk_function::start_training);
RESPONSE("On second thought, never mind.");
SUCCESS(TALK_NONE);
} else {
RESPONSE("Okay. Lead the way.");
SUCCESS(TALK_DONE);
SUCCESS_ACTION(&talk_function::lead_to_safety);
RESPONSE("No, we'll be okay here.");
SUCCESS(TALK_TRAIN_FORCE);
RESPONSE("On second thought, never mind.");
SUCCESS(TALK_NONE);
}
break;
case TALK_TRAIN_FORCE:
RESPONSE("Sounds good.");
SUCCESS(TALK_DONE);
SUCCESS_ACTION(&talk_function::start_training);
RESPONSE("On second thought, never mind.");
SUCCESS(TALK_NONE);
break;
case TALK_SUGGEST_FOLLOW:
if (p->has_disease(DI_INFECTION)) {
RESPONSE("Understood. I'll get those antibiotics.");
SUCCESS(TALK_NONE);
} else if (p->has_disease(DI_ASKED_TO_FOLLOW)) {
RESPONSE("Right, right, I'll ask later.");
SUCCESS(TALK_NONE);
} else {
int strength = 3 * p->op_of_u.fear + p->op_of_u.value + p->op_of_u.trust +
(10 - p->personality.bravery);
int weakness = 3 * p->personality.altruism + p->personality.bravery -
p->op_of_u.fear + p->op_of_u.value;
int friends = 2 * p->op_of_u.trust + 2 * p->op_of_u.value -
2 * p->op_of_u.anger + p->op_of_u.owed / 50;
RESPONSE("I can keep you safe.");
TRIAL(TALK_TRIAL_PERSUADE, strength * 2);
SUCCESS(TALK_AGREE_FOLLOW);
SUCCESS_ACTION(&talk_function::follow);
SUCCESS_OPINION(1, 0, 1, 0, 0);
FAILURE(TALK_DENY_FOLLOW);
FAILURE_ACTION(&talk_function::deny_follow);
FAILURE_OPINION(0, 0, -1, 1, 0);
RESPONSE("You can keep me safe.");
TRIAL(TALK_TRIAL_PERSUADE, weakness * 2);
SUCCESS(TALK_AGREE_FOLLOW);
SUCCESS_ACTION(&talk_function::follow);
SUCCESS_OPINION(0, 0, -1, 0, 0);
FAILURE(TALK_DENY_FOLLOW);
FAILURE_ACTION(&talk_function::deny_follow);
FAILURE_OPINION(0, -1, -1, 1, 0);
RESPONSE("We're friends, aren't we?");
TRIAL(TALK_TRIAL_PERSUADE, friends * 1.5);
SUCCESS(TALK_AGREE_FOLLOW);
SUCCESS_ACTION(&talk_function::follow);
SUCCESS_OPINION(2, 0, 0, -1, 0);
FAILURE(TALK_DENY_FOLLOW);
FAILURE_ACTION(&talk_function::deny_follow);
FAILURE_OPINION(-1, -2, -1, 1, 0);
RESPONSE("!I'll kill you if you don't.");
TRIAL(TALK_TRIAL_INTIMIDATE, strength * 2);
SUCCESS(TALK_AGREE_FOLLOW);
SUCCESS_ACTION(&talk_function::follow);
SUCCESS_OPINION(-4, 3, -1, 4, 0);
FAILURE(TALK_DENY_FOLLOW);
FAILURE_OPINION(-4, 0, -5, 10, 0);
}
break;
case TALK_AGREE_FOLLOW:
RESPONSE("Awesome!");
SUCCESS(TALK_NONE);
RESPONSE("Okay, let's go!");
SUCCESS(TALK_DONE);
break;
case TALK_DENY_FOLLOW:
RESPONSE("Oh, okay.");
SUCCESS(TALK_NONE);
break;
case TALK_LEADER: {
int persuade = p->op_of_u.fear + p->op_of_u.value + p->op_of_u.trust -
p->personality.bravery - p->personality.aggression;
if (p->has_destination()) {
RESPONSE("How much further?");
SUCCESS(TALK_HOW_MUCH_FURTHER);
}
RESPONSE("I'm going to go my own way for a while.");
SUCCESS(TALK_LEAVE);
if (!p->has_disease(DI_ASKED_TO_LEAD)) {
RESPONSE("I'd like to lead for a while.");
TRIAL(TALK_TRIAL_PERSUADE, persuade);
SUCCESS(TALK_PLAYER_LEADS);
SUCCESS_ACTION(&talk_function::follow);
FAILURE(TALK_LEADER_STAYS);
FAILURE_OPINION(0, 0, -1, -1, 0);
RESPONSE("Step aside. I'm leader now.");
TRIAL(TALK_TRIAL_INTIMIDATE, 40);
SUCCESS(TALK_PLAYER_LEADS);
SUCCESS_ACTION(&talk_function::follow);
SUCCESS_OPINION(-1, 1, -1, 1, 0);
FAILURE(TALK_LEADER_STAYS);
FAILURE_OPINION(-1, 0, -1, 1, 0);
}
RESPONSE("Can I do anything for you?");
SUCCESS(TALK_MISSION_LIST);
RESPONSE("Let's trade items.");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::start_trade);
RESPONSE("Let's go.");
SUCCESS(TALK_DONE);
} break;
case TALK_LEAVE:
RESPONSE("Nah, I'm just kidding.");
SUCCESS(TALK_NONE);
RESPONSE("Yeah, I'm sure. Bye.");
SUCCESS_ACTION(&talk_function::leave);
SUCCESS(TALK_DONE);
break;
case TALK_PLAYER_LEADS:
RESPONSE("Good. Something else...");
SUCCESS(TALK_FRIEND);
RESPONSE("Alright, let's go.");
SUCCESS(TALK_DONE);
break;
case TALK_LEADER_STAYS:
RESPONSE("Okay, okay.");
SUCCESS(TALK_NONE);
break;
case TALK_HOW_MUCH_FURTHER:
RESPONSE("Okay, thanks.");
SUCCESS(TALK_NONE);
RESPONSE("Let's keep moving.");
SUCCESS(TALK_DONE);
break;
case TALK_FRIEND:
RESPONSE("Combat commands...");
SUCCESS(TALK_COMBAT_COMMANDS);
RESPONSE("Can I do anything for you?");
SUCCESS(TALK_MISSION_LIST);
SELECT_TEMP("Can you teach me anything?", 0);
SUCCESS(TALK_TRAIN);
RESPONSE("Let's trade items.");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::start_trade);
RESPONSE("Let's go.");
SUCCESS(TALK_DONE);
break;
case TALK_COMBAT_COMMANDS: {
RESPONSE("Change your engagement rules...");
SUCCESS(TALK_COMBAT_ENGAGEMENT);
if (p->combat_rules.use_guns) {
RESPONSE("Don't use guns anymore.");
SUCCESS(TALK_COMBAT_COMMANDS);
SUCCESS_ACTION(&talk_function::toggle_use_guns);
} else {
RESPONSE("You can use guns.");
SUCCESS(TALK_COMBAT_COMMANDS);
SUCCESS_ACTION(&talk_function::toggle_use_guns);
}
if (p->combat_rules.use_grenades) {
RESPONSE("Don't use grenades anymore.");
SUCCESS(TALK_COMBAT_COMMANDS);
SUCCESS_ACTION(&talk_function::toggle_use_grenades);
} else {
RESPONSE("You can use grenades.");
SUCCESS(TALK_COMBAT_COMMANDS);
SUCCESS_ACTION(&talk_function::toggle_use_grenades);
}
RESPONSE("Never mind.");
SUCCESS(TALK_NONE);
} break;
case TALK_COMBAT_ENGAGEMENT: {
if (p->combat_rules.engagement != ENGAGE_NONE) {
RESPONSE("Don't fight unless your life depends on it.");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::set_engagement_none);
}
if (p->combat_rules.engagement != ENGAGE_CLOSE) {
RESPONSE("Attack enemies that get too close.");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::set_engagement_close);
}
if (p->combat_rules.engagement != ENGAGE_WEAK) {
RESPONSE("Attack enemies that you can kill easily.");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::set_engagement_weak);
}
if (p->combat_rules.engagement != ENGAGE_HIT) {
RESPONSE("Attack only enemies that I attack first.");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::set_engagement_hit);
}
if (p->combat_rules.engagement != ENGAGE_ALL) {
RESPONSE("Attack anything you want.");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::set_engagement_all);
}
RESPONSE("Never mind.");
SUCCESS(TALK_NONE);
} break;
case TALK_STRANGER_NEUTRAL:
case TALK_STRANGER_WARY:
case TALK_STRANGER_SCARED:
case TALK_STRANGER_FRIENDLY:
if (topic == TALK_STRANGER_NEUTRAL || topic == TALK_STRANGER_FRIENDLY) {
RESPONSE("Another survivor! We should travel together.");
SUCCESS(TALK_SUGGEST_FOLLOW);
RESPONSE("What are you doing?");
SUCCESS(TALK_DESCRIBE_MISSION);
RESPONSE("Care to trade?");
SUCCESS(TALK_NONE);
SUCCESS_ACTION(&talk_function::start_trade);