forked from muspellsson/omega-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command2.c
1219 lines (1132 loc) · 31.2 KB
/
command2.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
/* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
/* command2.c */
/* This file contains toplevel commands called from command1.c */
#ifndef MSDOS_SUPPORTED_ANTIQUE
#include <unistd.h>
#include <ctype.h>
#endif
#include "glob.h"
/* no op a turn.... */
void rest(void)
{
if (random_range(20) == 1) {
switch(random_range(10)) {
case 0: print3(" Time passes slowly.... "); break;
case 1: print3(" Tick. Tock. Tick. Tock. "); break;
case 2: print3(" Ho Hum. "); break;
case 3: print3(" Beauty Sleep. Well, in your case, Ugly Sleep. "); break;
case 4: print3(" And with Strange Aeons, even Death may die. "); break;
case 5: print3(" La Di Da. "); break;
case 6: print3(" Time keeps on tickin' tickin' -- into the future.... ");
break;
case 7: print3(" Boooring! "); break;
case 8: print3(" You think I like watching you sleep? "); break;
case 9: print3(" You sure have an early bedtime! "); break;
}
morewait();
}
}
/* read a scroll, book, tome, etc. */
void peruse(void)
{
int index;
struct object *obj;
clearmsg();
if (Player.status[BLINDED] > 0)
print3("You're blind -- you can't read!!!");
else if (Player.status[AFRAID] > 0)
print3("You are too afraid to stop to read a scroll!");
else {
index = getitem_prompt("Read -- ", SCROLL);
if (index == ABORT)
setgamestatus(SKIP_MONSTERS);
else {
obj = Player.possessions[index];
if (obj->objchar != SCROLL) {
print3("There's nothing written on ");
nprint3(itemid(obj));
}
else {
nprint1("You carefully unfurl the scroll....");
morewait();
item_use(obj);
dispose_lost_objects(1,obj);
}
}
}
}
void quaff(void)
{
int index;
struct object *obj;
clearmsg();
index = getitem_prompt("Quaff -- ", POTION);
if (index == ABORT)
setgamestatus(SKIP_MONSTERS);
else {
obj = Player.possessions[index];
if (obj->objchar != POTION) {
print3("You can't drink ");
nprint3(itemid(obj));
}
else {
print1("You drink it down.... ");
item_use(obj);
morewait();
dispose_lost_objects(1,obj);
}
}
}
void activate(void)
{
int index = ABORT;
char response;
clearmsg();
print1("Activate -- item [i] or artifact [a] or quit [ESCAPE]?");
do response = (char) mcigetc();
while ((response != 'i') && (response != 'a') && (response != ESCAPE));
if (response != ESCAPE) {
if (response == 'i')
index = getitem_prompt("Activate -- ", THING);
else if (response == 'a')
index = getitem_prompt("Activate -- ", ARTIFACT);
if (index != ABORT) {
clearmsg();
print1("You activate it.... ");
morewait();
item_use(Player.possessions[index]);
}
else setgamestatus(SKIP_MONSTERS);
}
else setgamestatus(SKIP_MONSTERS);
}
void eat (void)
{
int index;
struct object *obj;
clearmsg();
index = getitem_prompt("Eat -- ", FOOD);
if (index == ABORT)
{
setgamestatus(SKIP_MONSTERS);
}
else
{
obj = Player.possessions[index];
if ((obj->objchar != FOOD) && (obj->objchar != CORPSE))
{
print3("You can't eat ");
nprint3(itemid(obj));
}
else
{
if (obj->usef == I_FOOD) Player.food = max(0, Player.food+obj->aux);
item_use(obj);
dispose_lost_objects(1,obj);
if (Current_Dungeon == E_COUNTRYSIDE)
{
Time += 100;
hourly_check();
}
}
}
foodcheck();
}
/* search all adjacent spots for secrecy */
void search(int *searchval)
{
int i;
if (Player.status[AFRAID] > 0)
print3("You are too terror-stricken to stop to search for anything.");
else {
if (!gamestatusp(FAST_MOVE)) {
setgamestatus(FAST_MOVE);
*searchval = Searchnum;
}
for (i=0;i<9;i++)
searchat(Player.x+Dirs[0][i],Player.y+Dirs[1][i]);
drawvision(Player.x,Player.y);
}
}
/* pick up a thing where the player is */
void pickup(void)
{
if (Level->site[Player.x][Player.y].things == NULL)
print3("There's nothing there!");
else if (Player.status[SHADOWFORM])
print3("You can't really interact with the real world in your shadowy state.");
else
pickup_at(Player.x,Player.y);
}
#ifndef MSDOS_SUPPORTED_ANTIQUE
/* floor inventory */
void floor_inv(void)
{
pol ol = Level->site[Player.x][Player.y].things;
setgamestatus(SKIP_MONSTERS);
menuclear();
while (ol != NULL) {
if (ol->thing == NULL) print3("***Error; null thing on things list***");
else {
menuprint(itemid(ol->thing));
menuprint("\n");
}
ol = ol->next;
}
showmenu();
morewait();
xredraw();
}
#endif
void drop(void)
{
int index,n;
clearmsg();
index = getitem_prompt("Drop -- ", CASH);
if (index == ABORT)
setgamestatus(SKIP_MONSTERS);
else {
if (index == CASHVALUE) drop_money();
else if ((! Player.possessions[index]->used) ||
(! cursed(Player.possessions[index]))) {
if (Player.possessions[index]->number == 1) {
p_drop_at(Player.x,Player.y,1,Player.possessions[index]);
conform_lost_objects(1,Player.possessions[index]);
}
else {
n = getnumber(Player.possessions[index]->number);
p_drop_at(Player.x,Player.y,n,Player.possessions[index]);
conform_lost_objects(n,Player.possessions[index]);
}
}
else {
print3("You can't seem to get rid of: ");
nprint3(itemid(Player.possessions[index]));
}
}
calc_melee();
}
/* talk to the animals -- learn their languages.... */
void talk(void)
{
int dx,dy,index=0;
char response;
struct monster *m;
clearmsg();
print1("Talk --");
index = getdir();
if (index == ABORT)
setgamestatus(SKIP_MONSTERS);
else {
dx = Dirs[0][index];
dy = Dirs[1][index];
if ((! inbounds(Player.x+dx, Player.y+dy)) ||
(Level->site[Player.x+dx][Player.y+dy].creature == NULL)) {
print3("There's nothing there to talk to!!!");
setgamestatus(SKIP_MONSTERS);
}
else {
m = Level->site[Player.x+dx][Player.y+dy].creature;
menuclear();
strcpy(Str1," Talk to ");
strcat(Str1,m->monstring);
strcat(Str1,":");
menuprint(Str1);
menuprint("\na: Greet.");
menuprint("\nb: Threaten.");
menuprint("\nc: Surrender.");
menuprint("\nESCAPE: Clam up.");
showmenu();
do response = menugetc();
while ((response != 'a') &&
(response != 'b') &&
(response != 'c') &&
(response != ESCAPE));
switch(response) {
case 'a': monster_talk(m); break;
case 'b': threaten(m); break;
case 'c': surrender(m); break;
default: setgamestatus(SKIP_MONSTERS); break;
}
}
}
xredraw();
}
/* try to deactivate a trap */
void disarm(void)
{
int x,y,index=0;
pob o;
clearmsg();
print1("Disarm -- ");
index = getdir();
if (index == ABORT)
setgamestatus(SKIP_MONSTERS);
else {
x = Dirs[0][index]+Player.x;
y = Dirs[1][index]+Player.y;
if (! inbounds(x,y))
print3("Whoa, off the map...");
else if (Level->site[x][y].locchar != TRAP)
print3("You can't see a trap there!");
else {
if (random_range(50+difficulty()*5) <
Player.dex*2+Player.level*3+Player.rank[THIEVES]*10) {
print1("You disarmed the trap!");
if (random_range(100) < Player.dex+Player.rank[THIEVES]*10) {
o = ((pob) checkmalloc(sizeof(objtype)));
switch(Level->site[x][y].p_locf) {
case L_TRAP_DART:
*o=Objects[OB_TRAP_DART];
break;
case L_TRAP_DISINTEGRATE:
*o=Objects[OB_TRAP_DISINTEGRATE];
break;
case L_TRAP_SLEEP_GAS:
*o=Objects[OB_TRAP_SLEEP];
break;
case L_TRAP_TELEPORT:
*o=Objects[OB_TRAP_TELEPORT];
break;
case L_TRAP_ABYSS:
*o=Objects[OB_TRAP_ABYSS];
break;
case L_TRAP_FIRE:
*o=Objects[OB_TRAP_FIRE];
break;
case L_TRAP_SNARE:
*o=Objects[OB_TRAP_SNARE];
break;
case L_TRAP_ACID:
*o=Objects[OB_TRAP_ACID];
break;
case L_TRAP_MANADRAIN:
*o=Objects[OB_TRAP_MANADRAIN];
break;
default:
/* DAG can't use free_obj() as object not initialized */
free(o);
o = NULL;
break;
}
if (o != NULL) {
print2("You manage to retrieve the trap components!");
morewait();
Objects[o->id].known = 1;
o->known = 1;
gain_item(o);
gain_experience(25);
}
}
Level->site[x][y].p_locf = L_NO_OP;
Level->site[x][y].locchar = FLOOR;
lset(x, y, CHANGED);
gain_experience(5);
}
else if (random_range(10+difficulty()*2) > Player.dex) {
print1("You accidentally set off the trap!");
Player.x = x; Player.y = y;
p_movefunction(Level->site[x][y].p_locf);
}
else print1("You failed to disarm the trap.");
}
}
}
/* is it more blessed to give, or receive? */
void give(void)
{
int index;
int dx,dy,dindex=0;
struct monster *m;
pob obj;
clearmsg();
print1("Give to monster --");
dindex = getdir();
if (dindex == ABORT)
setgamestatus(SKIP_MONSTERS);
else {
dx = Dirs[0][dindex];
dy = Dirs[1][dindex];
if (! inbounds(Player.x+dx, Player.y+dy))
print3("Whoa, off the map...");
else if (Level->site[Player.x+dx][Player.y+dy].creature == NULL) {
print3("There's nothing there to give something to!!!");
setgamestatus(SKIP_MONSTERS);
}
else {
m = Level->site[Player.x+dx][Player.y+dy].creature;
clearmsg();
index = getitem_prompt("Give what? ", CASH);
if (index == ABORT)
setgamestatus(SKIP_MONSTERS);
else if (index == CASHVALUE) give_money(m);
else if (! cursed(Player.possessions[index])) {
obj = copy_obj( Player.possessions[index] );
obj->used = FALSE;
conform_lost_objects(1,Player.possessions[index]);
obj->number = 1;
print2("Given: ");
nprint2(itemid(obj));
morewait();
/* WDT bug fix: I moved the print above the givemonster
* call. If that turns out looking ugly, I should change it to
* a sprintf or strcat. At any rate, it was wrong before because
* it was accessing an object which had already been freed as part
* of givemonster. */
givemonster(m,obj);
calc_melee();
}
else {
print3("You can't even give away: ");
nprint3(itemid(Player.possessions[index]));
}
}
}
}
/* zap a wand, of course */
void zapwand(void)
{
int index;
struct object *obj;
clearmsg();
if (Player.status[AFRAID] > 0)
print3("You are so terror-stricken you can't hold a wand straight!");
else {
index = getitem_prompt("Zap -- ", STICK);
if (index == ABORT)
setgamestatus(SKIP_MONSTERS);
else {
obj = Player.possessions[index];
if (obj->objchar != STICK) {
print3("You can't zap: ");
nprint3(itemid(obj));
}
else
if (obj->charge < 1)
print3("Fizz.... Pflpt. Out of charges. ");
else {
obj->charge--;
item_use(obj);
}
}
}
}
/* cast a spell */
void magic(void)
{
int index,drain;
clearmsg();
if (Player.status[AFRAID] > 0)
print3("You are too afraid to concentrate on a spell!");
else {
index = getspell();
xredraw();
if (index == ABORT)
setgamestatus(SKIP_MONSTERS);
else {
drain = Spells[index].powerdrain;
if (Lunarity == 1) drain = drain / 2;
else if (Lunarity == -1) drain = drain *2;
if (drain > Player.mana)
if (Lunarity == -1 && Player.mana >= drain/2)
print3("The contrary moon has made that spell too draining! ");
else
print3("You lack the power for that spell! ");
else {
Player.mana -= drain;
cast_spell(index);
}
}
}
dataprint();
}
/* go upstairs ('<' command) */
void upstairs(void)
{
if (Level->site[Player.x][Player.y].locchar != STAIRS_UP)
print3("Not here!");
else if (Level->site[Player.x][Player.y].p_locf == L_ESCALATOR)
p_movefunction(Level->site[Player.x][Player.y].p_locf);
else {
if (gamestatusp(MOUNTED))
print2("You manage to get your horse upstairs.");
print1("You ascend a level.");
if (Level->depth <= 1) {
if (Level->environment == E_SEWERS)
change_environment(E_CITY);
else change_environment(E_COUNTRYSIDE);
}
else change_level(Level->depth,Level->depth-1,FALSE);
roomcheck();
}
setgamestatus(SKIP_MONSTERS);
}
/* go downstairs ('>' command) */
void downstairs(void)
{
if (Level->site[Player.x][Player.y].locchar != STAIRS_DOWN)
print3("Not here!");
else if (Level->site[Player.x][Player.y].p_locf == L_ENTER_CIRCLE ||
Level->site[Player.x][Player.y].p_locf == L_ENTER_COURT)
p_movefunction(Level->site[Player.x][Player.y].p_locf);
else {
if (gamestatusp(MOUNTED))
print2("You manage to get your horse downstairs.");
if (Current_Environment == Current_Dungeon) {
print1("You descend a level.");
change_level(Level->depth,Level->depth+1,FALSE);
roomcheck();
}
else if ((Current_Environment == E_CITY) ||
(Last_Environment == E_CITY))
change_environment(E_SEWERS);
else if (Current_Environment != Current_Dungeon)
print3("This stairway is deviant. You can't use it.");
}
setgamestatus(SKIP_MONSTERS);
}
/* set various player options */
/* have to redefine in odefs for next full recompile */
void setoptions(void)
{
int slot = 1,to,done = FALSE;
int response;
clearmsg();
menuclear();
display_options();
move_slot(1,1,NUMOPTIONS);
clearmsg();
print1("Currently selected option is preceded by highlit >>");
print2("Move selected option with '>' and '<', ESCAPE to quit.");
do {
response = mcigetc();
switch(response) {
case 'j':
case '>':
#ifdef KEY_DOWN
case KEY_DOWN:
#endif
to = slot + 1;
#ifndef COMPRESS_SAVE_FILES
if (to == 8) /* COMPRESS_OPTION */
to = 9;
#endif
slot = move_slot(slot,to,NUMOPTIONS+1);
break;
case 'k':
case '<':
#ifdef KEY_UP
case KEY_UP:
#endif
to = slot - 1;
#ifndef COMPRESS_SAVE_FILES
if (to == 8) /* COMPRESS_OPTION */
to = 7;
#endif
if (to > 0)
slot = move_slot(slot,to,NUMOPTIONS+1);
break;
#ifdef KEY_HOME
case KEY_HOME:
slot = move_slot(slot,1,NUMOPTIONS+1);
break;
#endif
#ifdef KEY_LL
case KEY_LL:
slot = move_slot(slot,NUMOPTIONS,NUMOPTIONS+1);
break;
#endif
case 't':
if (slot <= NUMTFOPTIONS)
optionset(pow2(slot-1));
else if (slot == VERBOSITY_LEVEL)
Verbosity = TERSE;
else print3("'T' is meaningless for this option.");
break;
case 'f':
if (slot <= NUMTFOPTIONS)
optionreset(pow2(slot-1));
else print3("'F' is meaningless for this option.");
break;
case 'm':
if (slot == VERBOSITY_LEVEL)
Verbosity = MEDIUM;
else print3("'M' is meaningless for this option.");
break;
case 'v':
if (slot == VERBOSITY_LEVEL)
Verbosity = VERBOSE;
else print3("'V' is meaningless for this option.");
break;
case '1':case '2':case '3':case '4':case '5':
case '6':case '7':case '8':case'9':
if (slot == SEARCH_DURATION)
Searchnum = response - '0';
else print3("A number is meaningless for this option.");
break;
case ESCAPE:
done = TRUE;
break;
default: print3("That response is meaningless for this option."); break;
}
display_option_slot(slot);
move_slot(slot,slot,NUMOPTIONS+1);
} while (! done);
if (optionp(SHOW_COLOUR))
colour_on();
else
colour_off();
#if !defined(MSDOS_SUPPORTED_ANTIQUE) && !defined(AMIGA)
xredraw();
#endif
}
/* name an item */
void callitem(void)
{
int index;
pob obj;
clearmsg();
setgamestatus(SKIP_MONSTERS);
index = getitem_prompt("Call -- ", NULL_ITEM);
if (index == CASHVALUE) print3("Can't rename cash!");
else if (index != ABORT) {
obj = Player.possessions[index];
if (obj->known)
print3("That item is already identified!");
else {
print1("Call it:");
obj->objstr = salloc(msgscanstring());
clearmsg();
print2("Also call all similar items by that name? [yn] ");
if (ynq2() == 'y') {
Objects[obj->id].objstr = obj->objstr;
}
}
}
}
/* open a door */
void opendoor(void)
{
int dir;
int ox,oy;
clearmsg();
print1("Open --");
dir = getdir();
if (dir == ABORT)
setgamestatus(SKIP_MONSTERS);
else {
ox = Player.x + Dirs[0][dir];
oy = Player.y + Dirs[1][dir];
if (Level->site[ox][oy].locchar == OPEN_DOOR) {
print3("That door is already open!");
setgamestatus(SKIP_MONSTERS);
}
else if (Level->site[ox][oy].locchar == PORTCULLIS) {
print1("You try to lift the massive steel portcullis....");
if (random_range(100) < Player.str) {
print2("Incredible. You bust a gut and lift the portcullis.");
Level->site[ox][oy].locchar = FLOOR;
lset(ox, oy, CHANGED);
}
else {
print2("Argh. You ruptured yourself.");
p_damage(Player.str,UNSTOPPABLE,"a portcullis");
}
}
else if ((Level->site[ox][oy].locchar != CLOSED_DOOR) ||
loc_statusp(ox,oy,SECRET)) {
print3("You can't open that!");
setgamestatus(SKIP_MONSTERS);
}
else if (Level->site[ox][oy].aux == LOCKED)
print3("That door seems to be locked.");
else {
Level->site[ox][oy].locchar = OPEN_DOOR;
lset(ox, oy, CHANGED);
}
}
}
/* Try to destroy some location */
void bash_location(void)
{
int dir;
int ox,oy;
clearmsg();
print1("Bashing --");
dir = getdir();
if (dir == ABORT)
setgamestatus(SKIP_MONSTERS);
else {
ox = Player.x + Dirs[0][dir];
oy = Player.y + Dirs[1][dir];
if ((Current_Environment == E_CITY) &&
(ox == 0) &&
(oy == 0)) {
print1("Back Door WIZARD Mode!");
print2("You will invalidate your score if you proceed.");
morewait();
if (cinema_confirm("You are about to enable WIZARD Mode.")=='y') {
print2("You feel like a cheater.");
setgamestatus(CHEATED);
}
else print2("A sudden tension goes out of the air....");
}
else {
if (Level->site[ox][oy].locchar == WALL) {
print1("You hurl yourself at the wall!");
p_damage(Player.str,NORMAL_DAMAGE,"a suicidal urge");
}
else if (Level->site[ox][oy].locchar == OPEN_DOOR) {
print1("You hurl yourself through the open door!");
print2("Yaaaaah! ... thud.");
morewait();
Player.x = ox;
Player.y = oy;
p_damage(3,UNSTOPPABLE,"silliness");
p_movefunction(Level->site[Player.x][Player.y].p_locf);
setgamestatus(SKIP_MONSTERS); /* monsters are surprised... */
}
else if (Level->site[ox][oy].locchar == CLOSED_DOOR) {
if (loc_statusp(ox,oy,SECRET)) {
print1("You found a secret door!");
lreset(ox,oy,SECRET);
lset(ox, oy, CHANGED);
}
if (Level->site[ox][oy].aux == LOCKED) {
if (random_range(50+difficulty()*10) < Player.str) {
Player.x = ox;
Player.y = oy;
print2("You blast the door off its hinges!");
Level->site[ox][oy].locchar = FLOOR;
lset(ox, oy, CHANGED);
p_movefunction(Level->site[Player.x][Player.y].p_locf);
setgamestatus(SKIP_MONSTERS); /* monsters are surprised... */
}
else {
print1("Crash! The door holds.");
if (random_range(30) > Player.str)
p_damage(max(1,statmod(Player.str)),UNSTOPPABLE,"a door");
}
}
else {
Player.x = ox;
Player.y = oy;
print2("You bash open the door!");
if (random_range(30) > Player.str)
p_damage(1,UNSTOPPABLE,"a door");
Level->site[ox][oy].locchar = OPEN_DOOR;
lset(ox, oy, CHANGED);
p_movefunction(Level->site[Player.x][Player.y].p_locf);
setgamestatus(SKIP_MONSTERS); /* monsters are surprised... */
}
}
else if (Level->site[ox][oy].locchar == STATUE) {
statue_random(ox,oy);
}
else if (Level->site[ox][oy].locchar == PORTCULLIS) {
print1("Really, you don't have a prayer.");
if (random_range(1000) < Player.str) {
print2("The portcullis flies backwards into a thousand fragments.");
print3("Wow. What a stud.");
gain_experience(100);
Level->site[ox][oy].locchar = FLOOR;
Level->site[ox][oy].p_locf = L_NO_OP;
lset(ox, oy, CHANGED);
}
else {
print2("You only hurt yourself on the 3'' thick steel bars.");
p_damage(Player.str,UNSTOPPABLE,"a portcullis");
}
}
else if (Level->site[ox][oy].locchar == ALTAR) {
if ((Player.patron > 0)&&(Level->site[ox][oy].aux == Player.patron)) {
print1("You have a vision! An awesome angel hovers over the altar.");
print2("The angel says: 'You twit, don't bash your own altar!'");
print3("The angel slaps you upside the head for your presumption.");
p_damage(Player.hp-1,UNSTOPPABLE,"an annoyed angel");
}
else if (Level->site[ox][oy].aux == 0) {
print1("The feeble powers of the minor godling are not enough to");
print2("protect his altar! The altar crumbles away to dust.");
print3("You feel almost unbearably smug.");
Level->site[ox][oy].locchar = RUBBLE;
Level->site[ox][oy].p_locf = L_RUBBLE;
lset(ox, oy, CHANGED);
gain_experience(5);
}
else {
print1("You have successfully annoyed a major deity. Good job.");
print2("Zzzzap! A bolt of godsfire strikes!");
if (Player.rank[PRIESTHOOD] > 0)
print3("Your own deity's aegis defends you from the bolt!");
p_damage(max(0,random_range(100)-Player.rank[PRIESTHOOD]*20),
UNSTOPPABLE,
"a bolt of godsfire");
if (Player.rank[PRIESTHOOD]*20+Player.pow+Player.level >
random_range(200)) {
morewait();
print1("The altar crumbles...");
Level->site[ox][oy].locchar = RUBBLE;
Level->site[ox][oy].p_locf = L_RUBBLE;
lset(ox, oy, CHANGED);
morewait();
if (Player.rank[PRIESTHOOD]) {
print2("You sense your deity's pleasure with you.");
morewait();
print3("You are surrounded by a golden glow.");
cleanse(1);
heal(10);
}
gain_experience(500);
}
}
}
else {
print3("You restrain yourself from total silliness.");
setgamestatus(SKIP_MONSTERS);
}
}
}
}
/* attempt destroy an item */
void bash_item(void)
{
int item;
pob obj;
clearmsg();
item = getitem_prompt("Destroy an item -- ", NULL_ITEM);
if (item == ABORT)
setgamestatus(SKIP_MONSTERS);
else if (item == CASHVALUE)
{
print3("You can't destroy cash!");
setgamestatus(SKIP_MONSTERS);
}
else
{
obj = Player.possessions[item];
if (Player.str+random_range(20) > obj->fragility+random_range(20)) {
/* damage_item() can free object, but need these after... */
int oid;
unsigned char olevel;
olevel = obj->level;
oid = obj->id;
if ( damage_item(obj) )
{
if ( OB_POTION_CHAOS == oid )
{
Player.alignment += random_range(10);
if ( Player.alignment < 0 )
{
print2("You feel a sense of inner constraint!");
gain_experience(olevel * olevel * 5);
}
else
print2("You feel wonderfully lawful!");
/* In either case, chaotic or lawful, destroying a PoCh is
* lawful. */
Player.alignment += random_range(10);
}
else if ( OB_SCROLL_LAW == oid )
{
Player.alignment -= random_range(10);
if ( Player.alignment < 0 )
{
print2("You feel deliciously chaotic!");
gain_experience(olevel * olevel * 5);
}
else
print2("You feel a sense of inner turmoil!");
Player.alignment -= random_range(10);
}
else if (Player.alignment < 0)
{
print2("That was fun....");
gain_experience(olevel * olevel * 5);
}
}
}
else {
if (obj->objchar == WEAPON) {
print2("The weapon turned in your hand -- you hit yourself!");
p_damage(random_range(obj->dmg+abs(obj->plus)),
NORMAL_DAMAGE,
"a failure at vandalism");
}
else if (obj->objchar == ARTIFACT) {
print2("Uh Oh -- Now you've gotten it angry....");
p_damage(obj->level*10,
UNSTOPPABLE,
"an enraged artifact");
}
else {
print2("Ouch! Damn thing refuses to break...");
p_damage(1,UNSTOPPABLE,"a failure at vandalism");
}
}
}
}
/* guess what this does */
/* if force is true, exiting due to some problem - don't bomb out */
void save(int compress, int force)
{
char fname[100];
int pos, ok = TRUE;
clearmsg();
if (gamestatusp(ARENA_MODE)) {
if (force) {
resetgamestatus(ARENA_MODE);
change_environment(E_CITY);
}
else {
print3("Can't save the game in the arena!");
setgamestatus(SKIP_MONSTERS);
ok = FALSE;
}
}
else if (Current_Environment == E_ABYSS) {
if (force)
change_environment(E_COUNTRYSIDE);
else {
print3("Can't save the game in the Adept's Challenge!");
setgamestatus(SKIP_MONSTERS);
ok = FALSE;
}
}
else if (Current_Environment == E_TACTICAL_MAP) {
if (force)
change_environment(E_COUNTRYSIDE);
else {
/* WDT MARK! I understand this, but it's wrong. */
print3("Can't save the game in the tactical map!");
setgamestatus(SKIP_MONSTERS);
ok = FALSE;
}
}
if (!force && ok) {
ok = (cinema_confirm("You're about to save and exit.") == 'y');
}
if (force || ok) {
sprintf(Str1, "Enter savefile name [default %s]: ", SaveFileName );
print1(Str1);
strcpy(fname,msgscanstring());
if (fname[0] == '\0') {
/* no file name entered, use default. DAG */
strcpy( fname, SaveFileName );
}
#ifdef MSDOS
for (pos = 0; fname[pos] && isalnum(fname[pos]); pos++)
;
#else
for (pos = 0; fname[pos] && isprint(fname[pos]) && !isspace(fname[pos]);
pos++)
;