forked from eddoww/Astonia-3.5
/
area3.c
1675 lines (1360 loc) · 54.2 KB
/
area3.c
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
/*
* $Id: area3.c,v 1.12 2007/09/21 10:58:36 devel Exp $ (c) 2005 D.Brockhaus
*
* $Log: area3.c,v $
* Revision 1.12 2007/09/21 10:58:36 devel
* gatekeeper door doesnt allow running heal any more
*
* Revision 1.11 2007/08/13 18:52:01 devel
* fixed some warnings
*
* Revision 1.10 2007/08/09 11:10:45 devel
* added statistics to reskin shrooms
*
* Revision 1.9 2007/07/13 15:47:16 devel
* clog -> charlog
*
* Revision 1.8 2007/06/22 13:00:53 devel
* added caligar quest to kelly
*
* Revision 1.7 2007/02/24 14:09:54 devel
* NWO first checkin, feb 24
*
* Revision 1.6 2006/12/08 10:33:55 devel
* fixed bug in carlos driver
*
* Revision 1.5 2006/09/23 10:01:21 devel
* made kelly give military exp for creeper quest onl once
*
* Revision 1.4 2006/09/21 11:22:52 devel
* added questlog
*
* Revision 1.3 2006/09/14 09:55:22 devel
* added questlog
*
* Revision 1.2 2005/12/04 17:34:24 ssim
* increased exp for carlos' quest
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include "server.h"
#include "log.h"
#include "notify.h"
#include "direction.h"
#include "do.h"
#include "path.h"
#include "error.h"
#include "drdata.h"
#include "see.h"
#include "death.h"
#include "talk.h"
#include "effect.h"
#include "tool.h"
#include "date.h"
#include "map.h"
#include "create.h"
#include "light.h"
#include "drvlib.h"
#include "libload.h"
#include "quest_exp.h"
#include "item_id.h"
#include "area3.h"
#include "los.h"
#include "military.h"
#include "consistency.h"
#include "staffer_ppd.h"
#include "misc_ppd.h"
#include "skill.h"
#include "database.h"
#include "questlog.h"
#include "statistics.h"
#include "player.h"
// library helper functions needed for init
int ch_driver(int nr,int cn,int ret,int lastact); // character driver (decides next action)
int it_driver(int nr,int in,int cn); // item driver (special cases for use)
int ch_died_driver(int nr,int cn,int co); // called when a character dies
int ch_respawn_driver(int nr,int cn); // called when an NPC is about to respawn
// EXPORTED - character/item driver
int driver(int type,int nr,int obj,int ret,int lastact)
{
switch(type) {
case CDT_DRIVER: return ch_driver(nr,obj,ret,lastact);
case CDT_ITEM: return it_driver(nr,obj,ret);
case CDT_DEAD: return ch_died_driver(nr,obj,ret);
case CDT_RESPAWN: return ch_respawn_driver(nr,obj);
default: return 0;
}
}
//-----------------------
struct qa
{
char *word[20];
char *answer;
int answer_code;
};
struct qa qa[]={
{{"how","are","you",NULL},"I'm fine!",0},
{{"hello",NULL},"Hello, %s!",0},
{{"hi",NULL},"Hi, %s!",0},
{{"greetings",NULL},"Greetings, %s!",0},
{{"hail",NULL},"And hail to you, %s!",0},
{{"what's","up",NULL},"Everything that isn't nailed down.",0},
{{"what","is","up",NULL},"Everything that isn't nailed down.",0},
{{"repeat",NULL},NULL,2},
{{"restart",NULL},NULL,2},
{{"please","repeat",NULL},NULL,2},
{{"please","restart",NULL},NULL,2},
{{"aye",NULL},NULL,3},
{{"nay",NULL},NULL,4},
{{"list",NULL},NULL,5},
{{"money",NULL},NULL,6},
};
void lowerstrcpy(char *dst,char *src)
{
while (*src) *dst++=tolower(*src++);
*dst=0;
}
int analyse_text_driver(int cn,int type,char *text,int co)
{
char word[256];
char wordlist[20][256];
int n,w,q,name=0;
// ignore game messages
if (type==LOG_SYSTEM || type==LOG_INFO) return 0;
// ignore our own talk
if (cn==co) return 0;
if (!(ch[co].flags&CF_PLAYER)) return 0;
if (char_dist(cn,co)>12) return 0;
if (!char_see_char(cn,co)) return 0;
while (isalpha(*text)) text++;
while (isspace(*text)) text++;
while (isalpha(*text)) text++;
if (*text==':') text++;
while (isspace(*text)) text++;
if (*text=='"') text++;
n=w=0;
while (*text) {
switch (*text) {
case ' ':
case ',':
case ':':
case '?':
case '!':
case '"':
case '.': if (n) {
word[n]=0;
lowerstrcpy(wordlist[w],word);
if (strcasecmp(wordlist[w],ch[cn].name)) { if (w<20) w++; }
else name=1;
}
n=0; text++;
break;
default: word[n++]=*text++;
if (n>250) return 0;
break;
}
}
if (w) {
for (q=0; q<sizeof(qa)/sizeof(struct qa); q++) {
for (n=0; n<w && qa[q].word[n]; n++) {
//say(cn,"word = '%s'",wordlist[n]);
if (strcmp(wordlist[n],qa[q].word[n])) break;
}
if (n==w && !qa[q].word[n]) {
if (qa[q].answer) say(cn,qa[q].answer,ch[co].name,ch[cn].name);
else return qa[q].answer_code;
return 1;
}
}
}
return 0;
}
struct seymour_driver_data
{
int last_talk;
int current_victim;
};
void seymour_driver(int cn,int ret,int lastact)
{
struct seymour_driver_data *dat;
struct area3_ppd *ppd;
int co,in,talkdir=0,didsay=0;
struct msg *msg,*next;
dat=set_data(cn,DRD_SEYMOURDRIVER,sizeof(struct seymour_driver_data));
if (!dat) return; // oops...
// loop through our messages
for (msg=ch[cn].msg; msg; msg=next) {
next=msg->next;
// did we see someone?
if (msg->type==NT_CHAR) {
co=msg->dat1;
// dont talk to other NPCs
if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; }
// dont talk to players without connection
if (ch[co].driver==CDR_LOSTCON) { remove_message(cn,msg); continue; }
// only talk every ten seconds
if (ticker<dat->last_talk+TICKS*5) { remove_message(cn,msg); continue; }
if (ticker<dat->last_talk+TICKS*10 && dat->current_victim && dat->current_victim!=co) { remove_message(cn,msg); continue; }
// dont talk to someone we cant see, and dont talk to ourself
if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; }
// dont talk to someone far away
if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; }
// get current status with player
ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (ppd) {
switch(ppd->seymour_state) {
case 0: say(cn,"Welcome to Aston, %s! I am %s, Staff Sergeant of the Seyan'Du, the late emperor's personal guard.",ch[co].name,ch[cn].name);
questlog_open(co,10);
ppd->seymour_state++; didsay=1;
break;
case 1: say(cn,"There are but few of us left. Most died in the defense when the underworld opened and the monsters stormed the imperial palace.");
ppd->seymour_state++; didsay=1;
break;
case 2: say(cn,"Do be wary when thou approachest the palace. It is still in ruins, and monsters appear there from time to time.");
ppd->seymour_state++; didsay=1;
break;
case 3: say(cn,"Some greedy folks tried to loot it, but few have returned with their spoils. Ah, be that as it may. I talk too much.");
ppd->seymour_state++; didsay=1;
break;
case 4: say(cn,"My captain said I was to hire strong looking adventurers for Imperial service. Never before have the Seyan'Du asked for help. But now we do. Oh, what has become of this world?");
ppd->seymour_state++; didsay=1;
break;
case 5: say(cn,"Our emperor murdered, nine of ten killed. Oh my, oh my.");
ppd->seymour_state++; didsay=1;
break;
case 6: say(cn,"%s, the Seyan'Du are offering you rank and status, in exchange for some missions. The first of these missions is to find out more about a certain Loisan.",ch[co].name);
ppd->seymour_state++; didsay=1;
break;
case 7: say(cn,"It seems he lived in Cameron for a while and moved here a few weeks later. After he left Cameron, skeletons have been haunting that place. Now, he has left Aston, and we're having trouble with zombies.");
ppd->seymour_state++; didsay=1;
break;
case 8: say(cn,"As a first step, I want you to go back to Cameron and search Loisan's house there. I have heard rumors that he was working on strange human skulls, and I want you to acquire one of those and bring it to me.");
ppd->seymour_state++; didsay=1;
break;
case 9: break;
case 10: if (questlog_isdone(co,11)) { ppd->seymour_state=12; break; }
say(cn,"Your next mission, %s, is to search Loisan's house here in Aston. It is on this street, on the western side. As far as we know, he's been using silver skulls here, and I want you to bring me one of those. You might also want to talk to the Governor of Aston for additional missions.",get_army_rank_string(co));
questlog_open(co,11);
ppd->seymour_state++; didsay=1;
break;
case 11: break;
case 12: ppd->seymour_state=14; //fall through intended
case 13: ppd->seymour_state=14; //fall through intended
case 14: if (questlog_isdone(co,12)) { ppd->seymour_state=16; break; }
say(cn,"Alright, now that we have the skulls he was using, it would be nice to know what became of Loisan. If you can find him, his body, or proof of his whereabouts, bring it to me.");
questlog_open(co,12);
ppd->seymour_state++; didsay=1;
break;
case 15: break;
case 16: say(cn,"Kelly, my superior, mentioned that she needs some fighters. Please go to her and offer your service. And do not forget to report to the Governor from time to time.");
ppd->seymour_state++; didsay=1;
break;
case 17: break;
}
if (didsay) {
dat->last_talk=ticker;
talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
dat->current_victim=co;
}
}
}
// talk back
if (msg->type==NT_TEXT) {
co=msg->dat3;
if (ticker>dat->last_talk+TICKS*10 && dat->current_victim) dat->current_victim=0;
if (dat->current_victim && dat->current_victim!=co) { remove_message(cn,msg); continue; }
switch((didsay=analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,co))) {
case 2: ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (ppd && ppd->seymour_state<=9) { dat->last_talk=0; ppd->seymour_state=0; }
if (ppd && ppd->seymour_state>=10 && ppd->seymour_state<=11) { dat->last_talk=0; ppd->seymour_state=10; }
if (ppd && ppd->seymour_state>=12 && ppd->seymour_state<=13) { dat->last_talk=0; ppd->seymour_state=12; }
if (ppd && ppd->seymour_state>=14 && ppd->seymour_state<=15) { dat->last_talk=0; ppd->seymour_state=14; }
if (ppd && ppd->seymour_state>=16 && ppd->seymour_state<=17) { dat->last_talk=0; ppd->seymour_state=16; }
break;
}
if (didsay) {
talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
dat->current_victim=co;
}
}
// got an item?
if (msg->type==NT_GIVE) {
co=msg->dat1;
if ((in=ch[cn].citem)) { // we still have it
ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (it[in].ID==IID_AREA2_LOISANNOTE && ppd->seymour_state==15) {
int tmp;
say(cn,"So he is dead. Ah, well. Thank you, %s.",ch[co].name);
tmp=questlog_done(co,12);
destroy_item_byID(co,IID_AREA2_LOISANNOTE);
ppd->seymour_state=16;
if (tmp==1) give_military_pts(cn,co,2,1);
// let it vanish, then
destroy_item(ch[cn].citem);
ch[cn].citem=0;
} else if (it[in].ID==IID_AREA2_ZOMBIESKULL1 && ppd->seymour_state==9) {
say(cn,"A strange skull indeed, %s.",ch[co].name);
questlog_done(co,10);
ppd->seymour_state=10;
if (!get_army_rank_int(co)) {
set_army_rank(co,1);
say(cn,"Welcome to the Imperial Army, %s %s!",get_army_rank_string(co),ch[co].name);
}
// let it vanish, then
destroy_item(ch[cn].citem);
ch[cn].citem=0;
} else if (it[in].ID==IID_AREA2_ZOMBIESKULL2 && ppd->seymour_state==11) {
int tmp;
say(cn,"Ah. Well done, %s.",ch[co].name);
tmp=questlog_done(co,11);
ppd->seymour_state=12;
if (tmp==1) give_military_pts(cn,co,1,1);
// let it vanish, then
destroy_item(ch[cn].citem);
ch[cn].citem=0;
} else {
say(cn,"Thou hast better use for this than I do. Well, if there is a use for it at all.");
if (!give_char_item(co,ch[cn].citem)) destroy_item(ch[cn].citem);
ch[cn].citem=0;
}
}
}
remove_message(cn,msg);
}
// do something. whenever possible, call do_idle with as high a tick count
// as reasonable when doing nothing.
if (talkdir) turn(cn,talkdir);
if (dat->last_talk+TICKS*30<ticker) {
if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_DOWN,ret,lastact)) return;
}
do_idle(cn,TICKS);
}
struct kelly_driver_data
{
int last_talk;
int current_victim;
};
int collect_heads(int cn,int co)
{
int n,in,cnt=0,sum=0;
for (n=30; n<INVENTORYSIZE; n++) {
if ((in=ch[co].item[n]) && it[in].ID==IID_AREA15_HEAD) {
cnt++;
sum+=125+it[in].drdata[0]*75;
ch[co].item[n]=0;
destroy_item(in);
}
}
if (cnt) {
say(cn,"Ah. %d heads. I'll give you %.2fG for them.",cnt,sum/100.0);
ch[co].gold+=sum; stats_update(co,0,sum);
ch[co].flags|=CF_ITEMS;
return 1;
}
return 0;
}
void kelly_driver(int cn,int ret,int lastact)
{
struct kelly_driver_data *dat;
struct area3_ppd *ppd;
int co,in,talkdir=0,didsay=0,cnt;
struct msg *msg,*next;
dat=set_data(cn,DRD_KELLYDRIVER,sizeof(struct kelly_driver_data));
if (!dat) return; // oops...
// loop through our messages
for (msg=ch[cn].msg; msg; msg=next) {
next=msg->next;
// did we see someone?
if (msg->type==NT_CHAR) {
co=msg->dat1;
// dont talk to other NPCs
if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; }
// dont talk to players without connection
if (ch[co].driver==CDR_LOSTCON) { remove_message(cn,msg); continue; }
// only talk every ten seconds
if (ticker<dat->last_talk+TICKS*5) { remove_message(cn,msg); continue; }
if (ticker<dat->last_talk+TICKS*10 && dat->current_victim && dat->current_victim!=co) { remove_message(cn,msg); continue; }
// dont talk to someone we cant see, and dont talk to ourself
if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; }
// dont talk to someone far away
if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; }
// get current status with player
ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (ppd) {
switch(ppd->kelly_state) {
case 0: quiet_say(cn,"Greetings, %s! I am %s, First Sergeant of the Seyan'Du, the late emperor's personal guard.",ch[co].name,ch[cn].name);
ppd->kelly_state++; didsay=1;
break;
case 1: if (ppd->seymour_state>=16) ppd->kelly_state++; // fall through...
else break;
case 2: quiet_say(cn,"Listen, %s. There have been some attacks from beings we call Stone Creepers. They come from the depths below the city. One known entrance is in the park.",get_army_rank_string(co));
questlog_open(co,13);
ppd->kelly_state++; didsay=1;
break;
case 3: quiet_say(cn,"During the last raid, one huge creeper was seen. It did as much damage as all the others together. Go there, and slay it. As proof of thy deed, bring me its head.");
ppd->kelly_state++; didsay=1;
break;
case 4: quiet_say(cn,"That will be all, %s. Dismissed!",get_army_rank_string(co));
ppd->kelly_state++; didsay=1;
break;
case 5: break; // waiting for creeper head
case 6: if (questlog_isdone(co,14)) { ppd->kelly_state=10; break; }
quiet_say(cn,"I have another mission for thee, %s. Scouts have found an underground park, which can be entered through a hole in the northern part of the forest in the southern corner of Aston.",ch[co].name);
questlog_open(co,14);
ppd->kelly_state++; didsay=1;
break;
case 7: quiet_say(cn,"They found a strange shrine there. I suspect there are several of them. Thou are to go there and find them all. Report back when thou hast found at least one.");
ppd->kelly_state++; didsay=1;
break;
case 8: quiet_say(cn,"Dismissed, %s. And good luck. Thou shalt need it.",get_army_rank_string(co));
ppd->kelly_state++; didsay=1;
break;
case 9: cnt=ppd->kelly_found1+ppd->kelly_found2+ppd->kelly_found3;
if (cnt>ppd->kelly_found_cnt) {
if (cnt!=1) quiet_say(cn,"Well done. I see thou hast discovered %d shrines, %s.",cnt,ch[co].name);
else quiet_say(cn,"Well done. I see thou hast discovered %d shrine, %s.",cnt,ch[co].name);
give_military_pts(cn,co,(cnt-ppd->kelly_found_cnt)*2,(cnt-ppd->kelly_found_cnt)*EXP_AREA3_SHRINE);
ppd->kelly_found_cnt=cnt;
didsay=1;
}
if (ppd->kelly_found_cnt==3) {
quiet_say(cn,"I guess there are just three of them. Good work, %s.",get_army_rank_string(co));
ppd->kelly_state++;
didsay=1;
questlog_done(co,14);
}
break;
case 10: quiet_say(cn,"I tell thee, %s, all these findings are most unsettling. I think we have but scratched on the surface of this underground world, and I fear what we are yet to find.",ch[co].name);
ppd->kelly_state++; didsay=1;
break;
case 11: quiet_say(cn,"The Imperial Army, the little that is left of it, is exploring the underworld, but our losses are heavy. All of a sudden, holes open everywhere, and monsters start pouring out. We needst find out where they come from, and why they attack us all of a sudden.");
ppd->kelly_state++; didsay=1;
break;
case 12: quiet_say(cn,"The future seemed so bright when Seyan was still alive and Ishtar was here to teach us.");
ppd->kelly_state++; didsay=1;
break;
case 13: if (ch[co].level>=22) ppd->kelly_state++; // fall thru intended
else break;
case 14: if (questlog_isdone(co,15)) { ppd->kelly_state=19; break; }
quiet_say(cn,"We have lost contact with our outpost in the swamp north of Aston. I want thee to go there and deliver a full report when thou getst back. Dismissed, %s.",get_army_rank_string(co));
questlog_open(co,15);
ppd->kelly_state++; didsay=1;
break;
case 15: if (ppd->clara_state>=5) ppd->kelly_state++; // fall through...
else break;
case 16: quiet_say(cn,"So Clara is well? 'Tis is good to hear, %s. I thank thee.",ch[co].name);
questlog_done(co,15);
give_military_pts(cn,co,3,1);
ppd->kelly_state++; didsay=1;
break;
case 17: quiet_say(cn,"I think Clara is right that we should not send reinforcements yet. But these swamp beasts worry me. I will pay thee for each swamp beast head thou bringst me. The larger the head, the larger the bounty.");
ppd->kelly_state++; didsay=1;
break;
case 18: quiet_say(cn,"Remember to report to Clara again, %s. Dismissed.",ch[co].name);
ppd->kelly_state++; didsay=1;
break;
case 19: if (collect_heads(cn,co)) didsay=1;
if (ch[co].level>=56) ppd->kelly_state++; // fall thru intended
else break;
case 20: if (questlog_count(co,60)) {
ppd->kelly_state=26;
break;
}
if (questlog_count(co,54)) {
ppd->kelly_state=21;
break;
}
quiet_say(cn,"Hello again, %s.",ch[co].name);
questlog_open(co,54);
questlog_open(co,60);
ppd->kelly_state++; didsay=1;
break;
case 21: quiet_say(cn,"I have another mission for you. An important plaque containing the signatures of every Emporer who has ruled over Aston has been stolen from Wesley's bank vault.");
ppd->kelly_state++; didsay=1;
break;
case 22: quiet_say(cn,"He found a note that was signed 'Grendom Carmin', a member of the Carmin Clan, who were a group of destructive mages, banished from Aston by the Imperial Army.");
ppd->kelly_state++; didsay=1;
break;
case 23: quiet_say(cn,"They settled in a forest to the south west of Aston and a wall was built so they could not come back.");
ppd->kelly_state++; didsay=1;
break;
case 24: quiet_say(cn,"Go to Gwendylon with this letter. He will teleport you there. I have a contact named Glori collecting information on the area. See what she knows, and get that plaque back at all costs! Dismissed!");
if (!has_item(co,IID_CALIGARLETTER)) {
in=create_item("caligar_letter");
if (in && !give_char_item(co,in)) destroy_item(in);
}
ppd->kelly_state++; didsay=1;
break;
case 25: break; // waiting for caligar plaque
case 26: break; // all done
}
if (didsay) {
dat->last_talk=ticker;
talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
dat->current_victim=co;
}
}
}
// talk back
if (msg->type==NT_TEXT) {
co=msg->dat3;
if (ticker>dat->last_talk+TICKS*10 && dat->current_victim) dat->current_victim=0;
if (dat->current_victim && dat->current_victim!=co) { remove_message(cn,msg); continue; }
switch((didsay=analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,co))) {
case 2: ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (ppd && ppd->kelly_state<=5) { dat->last_talk=0; ppd->kelly_state=0; }
if (ppd && ppd->kelly_state>5 && ppd->kelly_state<=9) { dat->last_talk=0; ppd->kelly_state=6; }
if (ppd && ppd->kelly_state>=10 && ppd->kelly_state<=13) { dat->last_talk=0; ppd->kelly_state=10; }
if (ppd && ppd->kelly_state>=14 && ppd->kelly_state<=15) { dat->last_talk=0; ppd->kelly_state=14; }
if (ppd && ppd->kelly_state>=17 && ppd->kelly_state<=19) { dat->last_talk=0; ppd->kelly_state=17; }
if (ppd && ppd->kelly_state>=21 && ppd->kelly_state<=25) { dat->last_talk=0; ppd->kelly_state=21; }
break;
}
if (didsay) {
talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
dat->current_victim=co;
}
}
// got an item?
if (msg->type==NT_GIVE) {
co=msg->dat1;
if ((in=ch[cn].citem)) { // we still have it
ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (it[in].ID==IID_AREA2_CREEPERHEAD && ppd->kelly_state<=5) {
int tmp;
quiet_say(cn,"Ah. Well done, %s.",ch[co].name);
ppd->kelly_state=6;
tmp=questlog_done(co,13);
destroy_item_byID(co,IID_AREA2_CREEPERHEAD);
if (tmp==1) give_military_pts(cn,co,4,1);
// let it vanish, then
destroy_item(ch[cn].citem);
ch[cn].citem=0;
} else if (it[in].ID==IID_CALIGARPLAQUE && ppd->kelly_state==25) {
questlog_done(co,60);
quiet_say(cn,"Oh thank you so much, %s! I don't think I can ever repay you for your effort. However, I can give you these 5,000 gold coins.",ch[co].name);
ch[co].gold+=5000*100; stats_update(co,0,5000*100);
ch[co].flags|=CF_ITEMS;
ppd->kelly_state=26;
// let it vanish, then
destroy_item(ch[cn].citem);
ch[cn].citem=0;
} else {
say(cn,"Thou hast better use for this than I do. Well, if there is a use for it at all.");
if (!give_char_item(co,ch[cn].citem)) destroy_item(ch[cn].citem);
ch[cn].citem=0;
}
}
}
remove_message(cn,msg);
}
// do something. whenever possible, call do_idle with as high a tick count
// as reasonable when doing nothing.
if (talkdir) turn(cn,talkdir);
if (dat->last_talk+TICKS*30<ticker) {
if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_RIGHT,ret,lastact)) return;
}
do_idle(cn,TICKS);
}
//----------------
struct astro1_driver_data
{
int last_talk;
int state;
};
void astro1_driver(int cn,int ret,int lastact)
{
struct astro1_driver_data *dat;
struct msg *msg,*next;
dat=set_data(cn,DRD_ASTRO1DRIVER,sizeof(struct astro1_driver_data));
if (!dat) return; // oops...
// loop through our messages
for (msg=ch[cn].msg; msg; msg=next) {
next=msg->next;
remove_message(cn,msg);
}
// do something. whenever possible, call do_idle with as high a tick count
// as reasonable when doing nothing.
if (ticker>dat->last_talk+TICKS*10) {
switch(dat->state) {
case 0: quiet_say(cn,"The moon, oh so bright and splendid it seemed. Oh, yes.");
dat->state++; break;
case 1: quiet_say(cn,"From my starting point, I moved the telescope to the south-east.");
dat->state++; break;
case 2: quiet_say(cn,"Then I noticed two triangle-shaped boulders. I continued moving south-east.");
dat->state++; break;
case 3: quiet_say(cn,"Some time later, there were one triangle-shaped boulder and one round like a circle. There, I started moving the telescope south-west.");
dat->state++; break;
case 4: quiet_say(cn,"A triangle-shaped boulder there was, and a square one. I turned the telescope south-east again.");
dat->state++; break;
case 5: quiet_say(cn,"Soon after, the perfectly round boulders caught my eye. Perfect circles. I marvelled at their sight - and got hungry, so I stopped to get some food.");
dat->state++; break;
case 6: quiet_say(cn,"After I got the food, I went back to the triangle-shaped and the square boulder. This time, I moved the telescope south-west.");
dat->state++; break;
case 7: quiet_say(cn,"There, I saw two boulders, both perfectly round, like circles. I continued moving south-west.");
dat->state++; break;
case 8: quiet_say(cn,"I moved the telescope past a triangle-shaped boulder, still going south-west.");
dat->state++; break;
case 9: quiet_say(cn,"At the sight of a round boulder, I started moving the telescope south-east.");
dat->state++; break;
case 10: quiet_say(cn,"After looking some more, I spotted the perfect squares. From there on, I moved north-east.");
dat->state++; break;
case 11: quiet_say(cn,"Some time later, I noticed another square and turned south-east again.");
dat->state++; break;
case 12: quiet_say(cn,"But then I got interrupted by my colleague, who wanted to have a heated discussion about something I don't remember. I offered him some food to quiet him and continued my observations.");
dat->state++; break;
case 13: quiet_say(cn,"And there it was, the very thing I was looking for. Oh, it was so beautiful!");
dat->state++; break;
case 14: quiet_say(cn,"Now what did I say last? I better start over at the beginning!");
dat->state=0; break;
default: dat->state=0;
}
dat->last_talk=ticker;
}
if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_DOWN,ret,lastact)) return;
do_idle(cn,TICKS);
}
struct astro2_driver_data
{
int last_talk;
int current_victim;
};
void astro2_driver(int cn,int ret,int lastact)
{
struct astro2_driver_data *dat;
struct area3_ppd *ppd;
int co,in,talkdir=0,didsay=0;
struct msg *msg,*next;
dat=set_data(cn,DRD_ASTRO2DRIVER,sizeof(struct astro2_driver_data));
if (!dat) return; // oops...
// loop through our messages
for (msg=ch[cn].msg; msg; msg=next) {
next=msg->next;
// did we see someone?
if (msg->type==NT_CHAR) {
co=msg->dat1;
// dont talk to other NPCs
if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; }
// dont talk to players without connection
if (ch[co].driver==CDR_LOSTCON) { remove_message(cn,msg); continue; }
// only talk every ten seconds
if (ticker<dat->last_talk+TICKS*5) { remove_message(cn,msg); continue; }
if (ticker<dat->last_talk+TICKS*10 && dat->current_victim && dat->current_victim!=co) { remove_message(cn,msg); continue; }
// dont talk to someone we cant see, and dont talk to ourself
if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; }
// dont talk to someone far away
if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; }
// get current status with player
ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (ppd) {
switch(ppd->astro2_state) {
case 0: say(cn,"Ah. Hello %s. I am %s, the astronomer.",ch[co].name,ch[cn].name);
questlog_open(co,16);
ppd->astro2_state++; didsay=1;
break;
case 1: say(cn,"Me and my colleagues, we've been watching the moon from our big telescope in the garden south-east of here.");
ppd->astro2_state++; didsay=1;
break;
case 2: say(cn,"But a few days ago, some strange creatures invaded the garden, and drove us away. We had to leave our notes behind.");
ppd->astro2_state++; didsay=1;
break;
case 3: say(cn,"Could thou try to get those notes back? I'd... well, I'd pay thee handsomely!");
ppd->astro2_state++; didsay=1;
break;
case 4: break;
case 5: break;
}
if (didsay) {
dat->last_talk=ticker;
talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
dat->current_victim=co;
}
}
}
// talk back
if (msg->type==NT_TEXT) {
co=msg->dat3;
if (ticker>dat->last_talk+TICKS*10 && dat->current_victim) dat->current_victim=0;
if (dat->current_victim && dat->current_victim!=co) { remove_message(cn,msg); continue; }
switch((didsay=analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,co))) {
case 2: ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (ppd && ppd->astro2_state<=4) ppd->astro2_state=0;
break;
}
if (didsay) {
dat->last_talk=ticker;
talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
dat->current_victim=co;
}
}
// got an item?
if (msg->type==NT_GIVE) {
co=msg->dat1;
if ((in=ch[cn].citem)) { // we still have it
ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (it[in].ID==IID_AREA2_ASTRONOTE && ppd->astro2_state<=4) {
int tmp;
say(cn,"Oh, jolly good! Thou gotst them back.");
ppd->astro2_state=5;
// let it vanish, then
destroy_item(ch[cn].citem);
ch[cn].citem=0;
tmp=questlog_done(co,16);
destroy_item_byID(co,IID_AREA2_ASTRONOTE);
if (tmp==1) {
in=create_money_item(MONEY_AREA3_MOONIES);
if (!give_char_item(co,in)) destroy_item(in);
}
} else {
say(cn,"Thou hast better use for this than I do. Well, if there is a use for it at all.");
if (!give_char_item(co,ch[cn].citem)) destroy_item(ch[cn].citem);
ch[cn].citem=0;
}
}
}
remove_message(cn,msg);
}
// do something. whenever possible, call do_idle with as high a tick count
// as reasonable when doing nothing.
if (ch[cn].citem) {
charlog(cn,"oops: destroying item %s",it[ch[cn].citem].name);
destroy_item(ch[cn].citem);
ch[cn].citem=0;
}
if (talkdir) turn(cn,talkdir);
if (dat->last_talk+TICKS*30<ticker) {
if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_DOWN,ret,lastact)) return;
}
do_idle(cn,TICKS);
}
struct thomas_driver_data
{
int last_talk;
int current_victim;
};
void thomas_driver(int cn,int ret,int lastact)
{
struct thomas_driver_data *dat;
struct area3_ppd *ppd;
int co,in,talkdir=0,didsay=0;
struct msg *msg,*next;
dat=set_data(cn,DRD_THOMASDRIVER,sizeof(struct thomas_driver_data));
if (!dat) return; // oops...
// loop through our messages
for (msg=ch[cn].msg; msg; msg=next) {
next=msg->next;
// did we see someone?
if (msg->type==NT_CHAR) {
co=msg->dat1;
// dont talk to other NPCs
if (!(ch[co].flags&CF_PLAYER)) { remove_message(cn,msg); continue; }
// dont talk to players without connection
if (ch[co].driver==CDR_LOSTCON) { remove_message(cn,msg); continue; }
// only talk every ten seconds
if (ticker<dat->last_talk+TICKS*5) { remove_message(cn,msg); continue; }
if (ticker<dat->last_talk+TICKS*10 && dat->current_victim && dat->current_victim!=co) { remove_message(cn,msg); continue; }
// dont talk to someone we cant see, and dont talk to ourself
if (!char_see_char(cn,co) || cn==co) { remove_message(cn,msg); continue; }
// dont talk to someone far away
if (char_dist(cn,co)>10) { remove_message(cn,msg); continue; }
// get current status with player
ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (ppd) {
switch(ppd->crypt_state) {
case 0: if (ch[co].level>18) {
say(cn,"Be greeted, %s. Please go inside, my master wishes to talk to thee.",ch[co].name);
ppd->crypt_state++; didsay=1;
}
break;
case 1: break;
}
if (didsay) {
dat->last_talk=ticker;
talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
dat->current_victim=co;
}
}
}
// talk back
if (msg->type==NT_TEXT) {
co=msg->dat3;
if (ticker>dat->last_talk+TICKS*10 && dat->current_victim) dat->current_victim=0;
if (dat->current_victim && dat->current_victim!=co) { remove_message(cn,msg); continue; }
switch((didsay=analyse_text_driver(cn,msg->dat1,(char*)msg->dat2,co))) {
case 2: ppd=set_data(co,DRD_AREA3_PPD,sizeof(struct area3_ppd));
if (ppd && ppd->crypt_state<=1) ppd->crypt_state=0;
break;
}
if (didsay) {
dat->last_talk=ticker;
talkdir=offset2dx(ch[cn].x,ch[cn].y,ch[co].x,ch[co].y);
dat->current_victim=co;
}
}
// got an item?
if (msg->type==NT_GIVE) {
co=msg->dat1;
if ((in=ch[cn].citem)) { // we still have it
say(cn,"Thou hast better use for this than I do. Well, if there is a use for it at all.");
if (!give_char_item(co,ch[cn].citem)) destroy_item(ch[cn].citem);
ch[cn].citem=0;
}
}
remove_message(cn,msg);
}
// do something. whenever possible, call do_idle with as high a tick count
// as reasonable when doing nothing.
if (ch[cn].citem) {
charlog(cn,"oops: destroying item %s",it[ch[cn].citem].name);
destroy_item(ch[cn].citem);
ch[cn].citem=0;
}
if (talkdir) turn(cn,talkdir);
if (dat->last_talk+TICKS*30<ticker) {
if (secure_move_driver(cn,ch[cn].tmpx,ch[cn].tmpy,DX_DOWN,ret,lastact)) return;
}
do_idle(cn,TICKS);
}
struct sir_jones_driver_data
{
int last_talk;
int current_victim;
};
void sir_jones_driver(int cn,int ret,int lastact)
{
struct sir_jones_driver_data *dat;
struct area3_ppd *ppd;
int co,in,talkdir=0,didsay=0;
struct msg *msg,*next;