-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathforest.c
More file actions
829 lines (714 loc) · 26.7 KB
/
Copy pathforest.c
File metadata and controls
829 lines (714 loc) · 26.7 KB
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
/*
* Part of Astonia Server (c) Daniel Brockhaus. Please read license.txt.
*/
#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 "store.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 "database.h"
#include "mem.h"
#include "player.h"
#include "skill.h"
#include "expire.h"
#include "clan.h"
#include "chat.h"
#include "los.h"
#include "shrine.h"
#include "area3.h"
#include "sector.h"
#include "consistency.h"
#include "questlog.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},
{{"imp", NULL}, "A nice little guy. He's got a peculiar sense of humor, but he's very helpful.", 0},
{{"repeat", NULL}, NULL, 2}};
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;
// 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 | CF_PLAYERLIKE))) return 0;
//if (char_dist(cn,co)>16) 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++;
}
}
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 imp_driver_data {
int last_talk;
int current_victim;
int mode;
int backtime;
};
// note: the ppd is borrowed from area3 - the missions interact...
void imp_driver(int cn, int ret, int lastact) {
struct imp_driver_data *dat;
struct area3_ppd *ppd;
int co, in, talkdir = 0, didsay = 0;
struct msg *msg, *next;
dat = set_data(cn, DRD_IMPDRIVER, sizeof(struct imp_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) > 20) {
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->imp_state) {
case 0:
say(cn, "A human. Now this is interesting. What could a human be doing here?");
ppd->imp_state++;
didsay = 1;
break;
case 1:
say(cn, "Should I tell him about the treasure? Ah, let's wait and see.");
ppd->imp_state++;
didsay = 1;
break;
case 2:
break;
case 3:
say(cn, "Nicely done, %s. Thou might not be bright, but at least thou knowest how to fight.", ch[co].name);
ppd->imp_state++;
didsay = 1;
ppd->imp_kills = 0;
questlog_done(co, 22);
break;
case 4:
say(cn, "Now do be a dear and run back to William.");
ppd->imp_state++;
didsay = 1;
ppd->william_state = 3;
break;
case 5:
if (questlog_isdone(co, 23)) {
ppd->imp_state = 11;
break;
}
break;
case 6:
say(cn, "Hullo human! There is more to be done here I know thine worth. Find him who is old and in need of thy help.");
ppd->imp_state++;
didsay = 1;
break;
case 7:
if (ppd->hermit_state > 3) ppd->imp_state++; // fall thru...
else break;
case 8:
if (ppd->hermit_state == 4 && (!(in = has_item(co, IID_HARDKILL)) || it[in].drdata[37] < 38)) {
if (in) say(cn, "Listen, human, for this might save thine life: The spider queen is beyond the strength of thine holy weapon. Thou needst find another stone circle. Find the skeleton ruin and go eastward.");
else say(cn, "Listen, human, for this might save thine life: Thou needst a holy weapon, otherwise thine task will remain unfulfilled.");
didsay = 1;
}
ppd->imp_state++;
break;
case 9:
if (ppd->hermit_state > 4) ppd->imp_state++; // fall thru...
else break;
case 10:
say(cn, "Thou art truly worthy, dear human called %s. Now, I shall tell thee how to find the treasure. Find the southernmost stone where the single skeleton lurks. Dig a hole and thou shalt find the key to a treasure.", ch[co].name);
ppd->imp_state++;
didsay = 1;
break;
case 11:
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;
dat->mode = 1;
dat->backtime = ticker + TICKS * 8;
}
}
}
// got an item?
if (msg->type == NT_GIVE) {
co = msg->dat1;
if ((in = ch[cn].citem)) { // we still have it
// let it vanish, then
destroy_item(ch[cn].citem);
ch[cn].citem = 0;
}
}
if (msg->type == NT_SEEHIT) {
co = msg->dat2;
if (co && (ch[co].flags & CF_PLAYER) && ch[co].hp < ch[co].value[1][V_HP] * POWERSCALE / 2 && !RANDOM(4)) {
ch[cn].flags &= ~CF_INVISIBLE;
set_sector(ch[cn].x, ch[cn].y);
dat->mode = 1;
dat->backtime = ticker + TICKS * 3;
say(cn, "Ooh. Don't die, dear human.");
if (do_heal(cn, co)) {
remove_message(cn, msg);
return;
}
}
}
remove_message(cn, msg);
}
// do something. whenever possible, call do_idle with as high a tick count
// as reasonable when doing nothing.
if (dat->mode == 1 && ticker > dat->backtime) dat->mode = 0;
if (dat->mode == 0) {
if (!(ch[cn].flags & CF_INVISIBLE)) {
ch[cn].flags |= CF_INVISIBLE;
set_sector(ch[cn].x, ch[cn].y);
}
} else if (dat->mode == 1) {
if ((ch[cn].flags & CF_INVISIBLE)) {
ch[cn].flags &= ~CF_INVISIBLE;
set_sector(ch[cn].x, ch[cn].y);
}
}
if (talkdir) turn(cn, talkdir);
if (spell_self_driver(cn)) return;
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 william_driver_data {
int last_talk;
int current_victim;
};
// note: the ppd is borrowed from area3 - the missions interact...
void william_driver(int cn, int ret, int lastact) {
struct imp_driver_data *dat;
struct area3_ppd *ppd;
int co, in, talkdir = 0, didsay = 0;
struct msg *msg, *next;
dat = set_data(cn, DRD_WILLIAMDRIVER, sizeof(struct william_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->william_state) {
case 0:
say(cn, "Greetings, %s. So nice of thee to visit. I am called %s.", ch[co].name, ch[cn].name);
if (questlog_isdone(co, 22)) {
ppd->william_state = 3;
break;
}
questlog_open(co, 22);
ppd->william_state++;
didsay = 1;
break;
case 1:
say(cn, "The \260c4imp\260c0 asked me to tell you to go east and then northeast and hunt some bears.");
ppd->william_state++;
didsay = 1;
break;
case 2:
break; // waiting for imp
case 3:
if (questlog_isdone(co, 23)) {
ppd->william_state = 7;
break;
}
say(cn, "Ah, hello %s. The \260c4imp\260c0 told me thou hast done him a favor. That's nice of thee.", ch[co].name);
questlog_open(co, 23);
ppd->william_state++;
didsay = 1;
break;
case 4:
say(cn, "Now if I may be so bold as to make a request of my own? It might sound strange to thee, friend, but I can make a nice stew from praying mantisses. I'd pay thee handsomely if thou couldst hunt one of them down and bring it to me.");
ppd->william_state++;
didsay = 1;
break;
case 5:
say(cn, "They live in the northern corner of the forest, close to a large clearing. Thou needst go east, then north and then north-west to get there.");
ppd->william_state++;
didsay = 1;
break;
case 6:
break; // waiting for mantiss
case 7:
break; // quest 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->william_state <= 2) {
dat->last_talk = 0;
ppd->william_state = 0;
}
if (ppd && ppd->william_state >= 3 && ppd->william_state <= 6) {
dat->last_talk = 0;
ppd->william_state = 3;
}
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_AREA16_MANTIS && ppd && ppd->william_state == 6) {
int tmp;
destroy_item(in);
ch[cn].citem = 0;
ppd->william_state = 7;
ppd->imp_state = 6;
say(cn, "Ah. I thank thee, %s. This will make a nice stew. Here, take these 20 gold coins.", ch[co].name);
tmp = questlog_done(co, 23);
destroy_item_byID(co, IID_AREA16_MANTIS);
if (tmp == 1) {
ch[co].gold += 2000;
ch[co].flags |= CF_ITEMS;
}
} else {
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 (hour >= 20 || hour < 6) {
if (secure_move_driver(cn, 176, 120, DX_RIGHT, ret, lastact)) return;
} else {
if (secure_move_driver(cn, ch[cn].tmpx, ch[cn].tmpy, DX_RIGHT, ret, lastact)) return;
}
}
do_idle(cn, TICKS);
}
struct hermit_driver_data {
int last_talk;
int current_victim;
};
// note: the ppd is borrowed from area3 - the missions interact...
void hermit_driver(int cn, int ret, int lastact) {
struct imp_driver_data *dat;
struct area3_ppd *ppd;
int co, in, talkdir = 0, didsay = 0;
struct msg *msg, *next;
dat = set_data(cn, DRD_HERMITDRIVER, sizeof(struct hermit_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->hermit_state) {
case 0:
say(cn, "My greetings to thee, %s. 'Tis most fortunate to see such a formidable hero as thyself. Be aware that I am in dire need of thine help.", ch[co].name);
questlog_open(co, 24);
ppd->hermit_state++;
didsay = 1;
break;
case 1:
say(cn, "Not long ago, some foul demons invaded this once so peaceful forest. They did not linger for long, but after they left the spiders in the western part of the forest started to grow and grow and grow.");
ppd->hermit_state++;
didsay = 1;
break;
case 2:
say(cn, "They did not only grow in size, but also in aggressiveness. Before, they used to feed on other insects, but now they lust human blood. Therefore I lay this quest upon thee, %s, to go to their lair and slay their queen.", ch[co].name);
ppd->hermit_state++;
didsay = 1;
break;
case 3:
say(cn, "Be wary, and prepare thyself well, for the queen can only be slain by a holy weapon of sufficient strength. Now go, %s, and do what needs be done. Thou canst reach their lair by going south and turning north-west at the old ruin.", ch[co].name);
ppd->hermit_state++;
didsay = 1;
break;
case 4:
break;
case 5:
say(cn, "I thank thee, %s, for thy brave deed. Forever shall I keep the memory of thy courage in my heart.", ch[co].name);
ppd->hermit_state++;
didsay = 1;
questlog_done(co, 24);
break;
case 6:
say(cn, "I know not why these demons have come, nor whence they came from. But I ask thee, %s, fight them whereever they show their ugly hides.", ch[co].name);
ppd->hermit_state++;
didsay = 1;
break;
case 7:
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->hermit_state <= 4) {
dat->last_talk = 0;
ppd->hermit_state = 0;
}
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
// let it vanish, then
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);
}
void monster_dead(int cn, int co) {
struct area3_ppd *ppd;
int bit = 0, in;
if (!co) return;
if (!(ch[co].flags & CF_PLAYER)) return;
if ((ch[cn].sprite == 306) && (ppd = set_data(co, DRD_AREA3_PPD, sizeof(struct area3_ppd))) && ppd->imp_state == 2) {
ppd->imp_kills++;
if (ppd->imp_kills > 20) ppd->imp_state = 3;
}
if ((ch[cn].flags & CF_HARDKILL) && (ppd = set_data(co, DRD_AREA3_PPD, sizeof(struct area3_ppd))) && ppd->hermit_state == 4) {
ppd->hermit_state = 5;
log_char(co, LOG_SYSTEM, 0, "Thou hast slain the spider queen.");
}
if (ch[co].x >= 182 && ch[co].y >= 185 && ch[co].x <= 192 && ch[co].y <= 192) bit = 8;
if (hour == 0 && bit && (in = ch[co].item[WN_RHAND]) && it[in].driver == 0 && !(it[in].drdata[36] & bit)) {
it[in].ID = IID_HARDKILL;
it[in].drdata[37] += 6;
it[in].drdata[36] |= bit;
it[in].flags |= IF_QUEST;
log_char(co, LOG_SYSTEM, 0, "Your %s starts to glow.", it[in].name);
}
}
void chest(int in, int cn) {
int in2;
struct area3_ppd *ppd;
if (!cn) return;
if (ch[cn].citem) {
log_char(cn, LOG_SYSTEM, 0, "Please empty your hand (mouse cursor) first.");
return;
}
if (it[in].drdata[0] == 0) {
if (!has_item(cn, IID_AREA16_ROBBERKEY)) {
log_char(cn, LOG_SYSTEM, 0, "The chest is locked and you don't have the right key.");
return;
}
ppd = set_data(cn, DRD_AREA3_PPD, sizeof(struct area3_ppd));
if (!ppd || (ppd->imp_flags & 1) || !(in2 = create_money_item(9733))) {
log_char(cn, LOG_SYSTEM, 0, "The chest is empty.");
return;
}
ppd->imp_flags |= 1;
} else {
if (!has_item(cn, IID_AREA16_SKELLYKEY)) {
log_char(cn, LOG_SYSTEM, 0, "The chest is locked and you don't have the right key.");
return;
}
ppd = set_data(cn, DRD_AREA3_PPD, sizeof(struct area3_ppd));
if (!ppd || (ppd->imp_flags & 2) || !(in2 = create_money_item(17587))) {
log_char(cn, LOG_SYSTEM, 0, "The chest is empty.");
return;
}
ppd->imp_flags |= 2;
}
if (ch[cn].flags & CF_PLAYER) dlog(cn, in2, "took from forest chest");
ch[cn].citem = in2;
it[in2].carried = cn;
ch[cn].flags |= CF_ITEMS;
log_char(cn, LOG_SYSTEM, 0, "You found a nice sum of money!");
}
int ch_driver(int nr, int cn, int ret, int lastact) {
switch (nr) {
case CDR_FORESTIMP:
imp_driver(cn, ret, lastact);
return 1;
case CDR_FORESTMONSTER:
char_driver(CDR_SIMPLEBADDY, CDT_DRIVER, cn, ret, lastact);
return 1;
case CDR_FORESTWILLIAM:
william_driver(cn, ret, lastact);
return 1;
case CDR_FORESTHERMIT:
hermit_driver(cn, ret, lastact);
return 1;
default:
return 0;
}
}
int it_driver(int nr, int in, int cn) {
switch (nr) {
case IDR_FORESTCHEST:
chest(in, cn);
return 1;
default:
return 0;
}
}
int ch_died_driver(int nr, int cn, int co) {
switch (nr) {
case CDR_FORESTIMP:
return 1;
case CDR_FORESTMONSTER:
monster_dead(cn, co);
return 1;
default:
return 0;
}
}
int ch_respawn_driver(int nr, int cn) {
switch (nr) {
case CDR_FORESTIMP:
return 1;
case CDR_FORESTMONSTER:
return 1;
default:
return 0;
}
}