forked from muspellsson/omega-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaux1.c
972 lines (902 loc) · 27.5 KB
/
aux1.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
/* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
/* aux1.c */
/* auxiliary functions for those in com.c, also see aux2.c and aux3.c */
#include "glob.h"
/* check to see if too much tunneling has been done in this level */
void tunnelcheck(void)
{
if ((Level->depth == 0 && Current_Environment != E_DLAIR) ||
Current_Environment == E_ASTRAL)
return;
Level->tunnelled++;
if ((Level->tunnelled) > (Level->level_length)/4)
mprint("Dust and stone fragments fall on you from overhead.");
if ((Level->tunnelled) >(Level->level_length)/2)
mprint("You hear groaning and creaking noises.");
if ((Level->tunnelled) > (3*(Level->level_length))/4)
mprint("The floor trembles and you hear a loud grinding screech.");
if ((Level->tunnelled) > Level->level_length) {
mprint("With a scream of tortured stone, the entire dungeon caves in!!!");
gain_experience(5000);
if (Player.status[SHADOWFORM]) {
change_environment(E_COUNTRYSIDE);
switch (Country[Player.x][Player.y].base_terrain_type)
{
case CASTLE:
case STARPEAK:
case CAVES:
case VOLCANO:
Country[Player.x][Player.y].current_terrain_type = MOUNTAINS;
break;
case DRAGONLAIR:
Country[Player.x][Player.y].current_terrain_type = DESERT;
break;
case MAGIC_ISLE:
Country[Player.x][Player.y].current_terrain_type = CHAOS_SEA;
break;
case PALACE:
Country[Player.x][Player.y].current_terrain_type = JUNGLE;
break;
}
Country[Player.x][Player.y].base_terrain_type =
Country[Player.x][Player.y].current_terrain_type;
c_set(Player.x, Player.y, CHANGED);
print1("In your shadowy state, you float back up to the surface.");
return;
}
mprint("You are flattened into an unpleasant jellylike substance.");
p_death("dungeon cave-in");
}
}
/* displays a room's name */
void showroom(int i)
{
strcpy(Str1,"");
strcpy(Str2,"");
switch(Current_Environment) {
case E_MANSION:
strcpy(Str2,"A luxurious mansion: ");
break;
case E_HOUSE:
strcpy(Str2,"A house: ");
break;
case E_HOVEL:
strcpy(Str2,"A hovel: ");
break;
case E_CITY:
strcpy(Str2,"The City of Rampart");
break;
case E_VILLAGE:
switch(Villagenum) {
case 1: strcpy(Str2,"The Village of Star View"); break;
case 2: strcpy(Str2,"The Village of Woodmere"); break;
case 3: strcpy(Str2,"The Village of Stormwatch"); break;
case 4: strcpy(Str2,"The Village of Thaumaris"); break;
case 5: strcpy(Str2,"The Village of Skorch"); break;
case 6: strcpy(Str2,"The Village of Whorfen"); break;
}
break;
case E_CAVES:
strcpy(Str2,"The Goblin Caves: ");
break;
case E_CASTLE:
strcpy(Str2,"The Archmage's Castle: ");
break;
case E_ASTRAL:
strcpy(Str2,"The Astral Plane: ");
break;
case E_VOLCANO:
strcpy(Str2,"The Volcano: ");
break;
case E_PALACE:
strcpy(Str2,"The Palace Dungeons: ");
break;
case E_SEWERS:
strcpy(Str2,"The Sewers: ");
break;
case E_TACTICAL_MAP:
strcpy(Str2,"The Tactical Map ");
break;
default:
strcpy(Str2,"");
break;
}
if (Current_Environment == Current_Dungeon) {
strcpy(Str1,"Level ");
if (Level->depth < 10) {
Str1[6] = Level->depth + '0';
Str1[7] = 0;
}
else {
Str1[6] = (Level->depth / 10) + '0';
Str1[7] = (Level->depth % 10) + '0';
Str1[8] = 0;
}
strcat(Str1," (");
strcat(Str1,roomname(i));
strcat(Str1,")");
}
else if (strlen(Str2) == 0 || Current_Environment == E_MANSION ||
Current_Environment == E_HOUSE || Current_Environment == E_HOVEL)
strcpy(Str1,roomname(i));
strcat(Str2,Str1);
locprint(Str2);
}
int player_on_sanctuary(void)
{
if ((Player.x==Player.sx) &&
(Player.y==Player.sy))
return(TRUE);
else {
if (Player.patron) {
if ((Level->site[Player.x][Player.y].locchar == ALTAR) &&
(Level->site[Player.x][Player.y].aux == Player.patron))
return(TRUE);
else return(FALSE);
}
else return(FALSE);
}
}
/* check a move attempt, maybe attack something, return TRUE if ok to move. */
/* x y is the proposed place to move to */
int p_moveable(int x, int y)
{
setgamestatus(SKIP_MONSTERS);
if (! inbounds(x,y)) return (FALSE);
else if (Player.status[SHADOWFORM]) {
switch(Level->site[x][y].p_locf) {
case L_CHAOS: case L_ABYSS: case L_VOID:
return cinema_confirm("That looks dangerous.") == 'y';
default:
resetgamestatus(SKIP_MONSTERS);
return(TRUE);
}
}
else if (loc_statusp(x,y,SECRET)) {
if (!gamestatusp(FAST_MOVE)) print3("Ouch!");
return(FALSE);
}
else if (Level->site[x][y].creature != NULL) {
if (! gamestatusp(FAST_MOVE)) {
fight_monster(Level->site[x][y].creature);
resetgamestatus(SKIP_MONSTERS);
return(FALSE);
}
else return(FALSE);
}
else if ((Level->site[x][y].locchar == WALL) ||
(Level->site[x][y].locchar == STATUE) ||
(Level->site[x][y].locchar == PORTCULLIS) ||
(Level->site[x][y].locchar == CLOSED_DOOR) ||
(gamestatusp(FAST_MOVE) &&
((Level->site[x][y].locchar == HEDGE) ||
(Level->site[x][y].locchar == LAVA) ||
(Level->site[x][y].locchar == ABYSS) ||
(Level->site[x][y].locchar == VOID_CHAR) ||
(Level->site[x][y].locchar == FIRE) ||
(Level->site[x][y].locchar == WHIRLWIND) ||
(Level->site[x][y].locchar == WATER) ||
(Level->site[x][y].locchar == LIFT) ||
(Level->site[x][y].locchar == TRAP)))) {
if (! gamestatusp(FAST_MOVE)) print3("Ouch!");
return(FALSE);
}
else if (optionp(CONFIRM)) {
if ((Level->site[x][y].locchar == HEDGE) ||
(Level->site[x][y].locchar == LAVA) ||
(Level->site[x][y].locchar == FIRE) ||
(Level->site[x][y].locchar == WHIRLWIND) ||
(Level->site[x][y].locchar == ABYSS) ||
(Level->site[x][y].locchar == VOID_CHAR) ||
(Level->site[x][y].locchar == WATER) ||
(Level->site[x][y].locchar == RUBBLE) ||
(Level->site[x][y].locchar == LIFT) ||
(Level->site[x][y].locchar == TRAP)) {
/* horses WILL go into water... */
if (gamestatusp(MOUNTED)) {
if (Level->site[x][y].locchar != WATER ||
Level->site[x][y].p_locf != L_WATER) {
print1("You can't convince your steed to continue.");
setgamestatus(SKIP_MONSTERS);
return(FALSE);
}
else return(TRUE);
}
else if (cinema_confirm("Look where you're about to step!") == 'y') resetgamestatus(SKIP_MONSTERS);
else setgamestatus(SKIP_MONSTERS);
return(!gamestatusp(SKIP_MONSTERS));
}
else {
resetgamestatus(SKIP_MONSTERS);
return(TRUE);
}
}
else {
resetgamestatus(SKIP_MONSTERS);
return(TRUE);
}
}
/* check a move attempt in the countryside */
int p_country_moveable(int x, int y)
{
if (! inbounds(x,y)) return (FALSE);
else if (optionp(CONFIRM)) {
if ((Country[x][y].current_terrain_type == CHAOS_SEA) ||
(Country[x][y].current_terrain_type == MOUNTAINS))
return(cinema_confirm("That's dangerous terrain, and slow going.")=='y');
else return(TRUE);
}
else return(TRUE);
}
/* search once particular spot */
void searchat(int x, int y)
{
int i;
if (inbounds(x,y) && (random_range(3) || Player.status[ALERT])) {
if (loc_statusp(x,y,SECRET)) {
lreset(x,y,SECRET);
lset(x, y, CHANGED);
if ((Level->site[x][y].locchar==OPEN_DOOR) ||
(Level->site[x][y].locchar==CLOSED_DOOR)) {
mprint("You find a secret door!");
for(i=0;i<=8;i++) { /* FIXED! 12/25/98 */
lset(x+Dirs[0][i],y+Dirs[1][i],STOPS);
lset(x+Dirs[0][i], y+Dirs[1][i], CHANGED);
}
}
else mprint("You find a secret passage!");
drawvision(Player.x,Player.y);
}
if ((Level->site[x][y].p_locf >= TRAP_BASE) &&
(Level->site[x][y].locchar != TRAP) &&
(Level->site[x][y].p_locf <= TRAP_BASE+NUMTRAPS)) {
Level->site[x][y].locchar = TRAP;
lset(x, y, CHANGED);
mprint("You find a trap!");
drawvision(Player.x,Player.y);
resetgamestatus(FAST_MOVE);
}
}
}
/* This is to be called whenever anything might change player performance in
melee, such as changing weapon, statistics, etc. */
void calc_melee(void)
{
calc_weight();
Player.maxweight = (Player.str * Player.agi * 10);
Player.absorption = Player.status[PROTECTION];
Player.defense = 2 * statmod(Player.agi)+(Player.level/2);
Player.hit = Player.level + statmod(Player.dex)+1;
Player.dmg = statmod(Player.str)+3;
Player.speed = 5 - min(4,(statmod(Player.agi)/2));
if (Player.status[HASTED] > 0) Player.speed = Player.speed / 2;
if (Player.status[SLOWED] > 0) Player.speed = Player.speed * 2;
if (Player.itemweight > 0)
switch(Player.maxweight / Player.itemweight) {
case 0: Player.speed+=6; break;
case 1: Player.speed+=3; break;
case 2: Player.speed+=2; break;
case 3: Player.speed+=1; break;
}
if (Player.status[ACCURATE]) Player.hit+=20;
if (Player.status[HERO]) Player.hit+=Player.dex;
if (Player.status[HERO]) Player.dmg+=Player.str;
if (Player.status[HERO]) Player.defense+=Player.agi;
if (Player.status[HERO]) Player.speed=Player.speed / 2;
Player.speed = max(1,min(25,Player.speed));
if (gamestatusp(MOUNTED)) {
Player.speed = 3;
Player.hit += 10;
Player.dmg += 10;
}
#ifdef INCLUDE_MONKS
else if (Player.rank[MONKS] > 0)
{
/* monks are faster when not in armor or on horseback */
if (Player.possessions[O_ARMOR] == NULL) {
Player.speed += (min(0,(Player.rank[MONKS] -1)));
}
}
#endif
/* weapon */
/* have to check for used since it could be a 2h weapon just carried
in one hand */
if (Player.possessions[O_WEAPON_HAND] != NULL)
if (Player.possessions[O_WEAPON_HAND]->used &&
((Player.possessions[O_WEAPON_HAND]->objchar==WEAPON)||
(Player.possessions[O_WEAPON_HAND]->objchar==MISSILEWEAPON))) {
Player.hit +=
Player.possessions[O_WEAPON_HAND]->hit +
Player.possessions[O_WEAPON_HAND]->plus;
Player.dmg +=
Player.possessions[O_WEAPON_HAND]->dmg +
Player.possessions[O_WEAPON_HAND]->plus;
}
#ifdef INCLUDE_MONKS
if (Player.rank[MONKS] > 0)
{
/* monks */
/* aren't monks just obscene? PGM */
if (Player.possessions[O_WEAPON_HAND] == NULL) /*barehanded*/
{
/* all monks get a bonus in unarmed combat */
Player.hit += ( Player.rank[MONKS] * Player.level );
Player.dmg += ( Player.rank[MONKS] * Player.level );
Player.defense += ( Player.rank[MONKS] * Player.level );
if (Player.rank[MONKS] == MONK_GRANDMASTER)
{
/* Grandmaster does 3x damage in unarmed combat. */
Player.dmg *= 3;
}
}
}
#endif
/* shield or defensive weapon */
if (Player.possessions[O_SHIELD] != NULL) {
Player.defense +=
Player.possessions[O_SHIELD]->aux +
Player.possessions[O_SHIELD]->plus;
}
/* armor */
if (Player.possessions[O_ARMOR] != NULL) {
Player.absorption += Player.possessions[O_ARMOR]->dmg;
Player.defense +=
Player.possessions[O_ARMOR]->plus -
Player.possessions[O_ARMOR]->aux;
}
if (strlen(Player.meleestr) > 2*maneuvers())
default_maneuvers();
comwinprint();
showflags();
dataprint();
}
/* player attacks monster m */
void fight_monster(struct monster *m)
{
int hitmod = 0;
int reallyfight = TRUE;
if (Player.status[AFRAID]) {
print3("You are much too afraid to fight!");
reallyfight = FALSE;
}
else if (player_on_sanctuary()) {
print3("You restrain yourself from desecrating this holy place.");
reallyfight = FALSE;
}
else if (Player.status[SHADOWFORM]) {
print3("Your attack has no effect in your shadowy state.");
reallyfight = FALSE;
}
else if ((Player.status[BERSERK]<1) && (! m_statusp(m,HOSTILE))) {
if (optionp(BELLICOSE)) reallyfight = TRUE;
else reallyfight = 'y'==cinema_confirm("You're attacking without provokation.");
}
else reallyfight = TRUE;
if (reallyfight) {
if (Lunarity == 1) hitmod += Player.level;
else if (Lunarity == -1) hitmod -= (Player.level / 2);
if (! m->attacked) Player.alignment -= 2; /* chaotic action */
m_status_set(m,AWAKE);
m_status_set(m,HOSTILE);
m->attacked = TRUE;
Player.hit += hitmod;
tacplayer(m);
Player.hit -= hitmod;
}
}
/* Attempt to break an object o */
int damage_item(pob o)
{
/* special case -- break star gem */
if (o->id == OB_STARGEM) {
print1("The Star Gem shatters into a million glistening shards....");
if (Current_Environment == E_STARPEAK) {
if (! gamestatusp(KILLED_LAWBRINGER))
print2("You hear an agonizing scream of anguish and despair.");
morewait();
print1("A raging torrent of energy escapes in an explosion of magic!");
print2("The energy flows to the apex of Star Peak where there is");
morewait();
clearmsg();
print1("an enormous explosion!");
morewait();
annihilate(1);
print3("You seem to gain strength in the chaotic glare of magic!");
Player.str = max(Player.str, Player.maxstr + 5); /* FIXED! 12/25/98 */
Player.pow = max(Player.pow, Player.maxpow + 5); /* ditto */
Player.alignment -= 200;
dispose_lost_objects(1,o);
}
else {
morewait();
print1("The shards coalesce back together again, and vanish");
print2("with a muted giggle.");
dispose_lost_objects(1,o);
Objects[o->id].uniqueness = UNIQUE_UNMADE; /* FIXED! 12/30/98 */
}
return 1;
}
else {
if (o->fragility < random_range(30)) {
if (o->objchar == STICK && o->charge > 0) {
strcpy(Str1,"Your ");
strcat(Str1,(o->blessing >= 0 ? o->truename : o->cursestr));
strcat(Str1," explodes!");
print1(Str1);
morewait();
nprint1(" Ka-Blamm!!!");
/* general case. Some sticks will eventually do special things */
morewait();
manastorm(Player.x, Player.y, o->charge*o->level*10);
dispose_lost_objects(1,o);
return 1;
}
else if ((o->blessing > 0) && (o->level > random_range(10))) {
strcpy(Str1,"Your ");
strcat(Str1,itemid(o));
strcat(Str1," glows strongly.");
print1(Str1);
return 0;
}
else if ((o->blessing < -1) && (o->level > random_range(10))) {
strcpy(Str1,"You hear an evil giggle from your ");
strcat(Str1,itemid(o));
print1(Str1);
return 0;
}
else if (o->plus > 0) {
strcpy(Str1,"Your ");
strcat(Str1,itemid(o));
strcat(Str1," glows and then fades.");
print1(Str1);
o->plus--;
return 0;
}
else {
if (o->blessing > 0) print1("You hear a faint despairing cry!");
else if (o->blessing < 0) print1("You hear an agonized scream!");
strcpy(Str1,"Your ");
strcat(Str1,itemid(o));
strcat(Str1," shatters in a thousand lost fragments!");
print2(Str1);
morewait();
dispose_lost_objects(1,o);
return 1;
}
}
return 0;
}
}
/* do dmg points of damage of type dtype, from source fromstring */
void p_damage(int dmg, int dtype, char *fromstring)
{
if (gamestatusp(FAST_MOVE)) {
drawvision(Player.x,Player.y);
resetgamestatus(FAST_MOVE);
}
if (! p_immune(dtype)) {
if (dtype == NORMAL_DAMAGE) Player.hp -= max(1,(dmg-Player.absorption));
else Player.hp -= dmg;
if (Player.hp < 1) p_death(fromstring);
}
else mprint("You resist the effects!");
dataprint();
}
/* game over, you lose! */
void p_death(char *fromstring)
{
Player.hp = -1;
print3("You died!");
morewait();
display_death(fromstring);
player_dump();
#ifdef SAVE_LEVELS
kill_all_levels();
#endif
endgraf();
exit(0);
}
/* move the cursor around, like for firing a wand, sets x and y to target */
void setspot(int *x, int *y)
{
char c = ' ';
mprint("Targeting.... ? for help");
omshowcursor(*x,*y);
while ((c != '.') && (c != ESCAPE)) {
c = lgetc();
switch(c) {
case 'h':case '4': movecursor(x,y,-1,0); break;
case 'j':case '2': movecursor(x,y,0,1); break;
case 'k':case '8': movecursor(x,y,0,-1); break;
case 'l':case '6': movecursor(x,y,1,0); break;
case 'b':case '1': movecursor(x,y,-1,1); break;
case 'n':case '3': movecursor(x,y,1,1); break;
case 'y':case '7': movecursor(x,y,-1,-1); break;
case 'u':case '9': movecursor(x,y,1,-1); break;
case '?':
clearmsg();
mprint("Use vi keys or numeric keypad to move cursor to target.");
mprint("Hit the '.' key when done, or ESCAPE to abort.");
break;
}
}
if (c==ESCAPE) *x = *y= ABORT;
screencheck(Player.x,Player.y);
}
/* get a direction: return index into Dirs array corresponding to direction */
int getdir(void)
{
while (1) {
mprint("Select direction [hjklyubn, ESCAPE to quit]: ");
switch (mgetc()) {
case '4':
case 'h':
case 'H': return(5);
case '2':
case 'j':
case 'J': return(6);
case '8':
case 'k':
case 'K': return(7);
case '6':
case 'l':
case 'L': return(4);
case '7':
case 'y':
case 'Y': return(3);
case '9':
case 'u':
case 'U': return(1);
case '1':
case 'b':
case 'B': return(2);
case '3':
case 'n':
case 'N': return(0);
case ESCAPE: return(ABORT);
default: print3("That's not a direction! ");
}
}
}
/* functions describes monster m's state for examine function */
char *mstatus_string(struct monster *m)
{
if (m_statusp(m, M_INVISIBLE) && !Player.status[TRUESIGHT])
strcpy(Str2, "Some invisible creature");
else if (m->uniqueness == COMMON) {
if (m->hp < Monsters[m->id].hp / 3)
strcpy(Str2,"a grievously injured ");
else if (m->hp < Monsters[m->id].hp / 2)
strcpy(Str2,"a severely injured ");
else if (m->hp < Monsters[m->id].hp)
strcpy(Str2,"an injured ");
else strcpy(Str2,getarticle(m->monstring));
if (m->level > Monsters[m->id].level) {
strcat(Str2," (level ");
strcat(Str2,wordnum(m->level+1-Monsters[m->id].level));
strcat(Str2,") ");
}
strcat(Str2,m->monstring);
}
else {
strcpy(Str2,m->monstring);
if (m->hp < Monsters[m->id].hp / 3)
strcat(Str2," who is grievously injured ");
else if (m->hp < Monsters[m->id].hp / 2)
strcat(Str2," who is severely injured ");
else if (m->hp < Monsters[m->id].hp)
strcat(Str2," who is injured ");
}
return(Str2);
}
/* for the examine function */
void describe_player(void)
{
if (Player.hp < (Player.maxhp /5))
print1("A grievously injured ");
else if (Player.hp < (Player.maxhp /2))
print1("A seriously wounded ");
else if (Player.hp < Player.maxhp)
print1("A somewhat bruised ");
else print1("A fit ");
if (Player.status[SHADOWFORM])
nprint1("shadow");
else
nprint1(levelname(Player.level));
nprint1(" named ");
nprint1(Player.name);
if (gamestatusp(MOUNTED))
nprint1(" (riding a horse.)");
}
/* access to player experience... */
/* share out experience among guild memberships */
void gain_experience(int amount)
{
int i,count=0,share;
Player.xp += (long) amount;
gain_level(); /* actually, check to see if should gain level */
for(i=0;i<NUMRANKS;i++)
if (Player.guildxp[i] > 0) count++;
share = amount/(max(count,1));
for(i=0;i<NUMRANKS;i++)
if (Player.guildxp[i] > 0) Player.guildxp[i]+=share;
}
/* try to hit a monster in an adjacent space. If there are none
return FALSE. Note if you're berserk you get to attack ALL
adjacent monsters! */
int goberserk(void)
{
int wentberserk=FALSE,i;
char meleestr[80];
strcpy(meleestr,Player.meleestr);
strcpy(Player.meleestr,"lLlClH");
for(i=0;i<8;i++)
if (Level->site[Player.x+Dirs[0][i]][Player.y+Dirs[1][i]].creature
!= NULL) {
wentberserk=TRUE;
fight_monster(Level->site[Player.x+Dirs[0][i]][Player.y+Dirs[1][i]].creature);
morewait();
}
strcpy(Player.meleestr,meleestr);
return(wentberserk);
}
/* identifies a trap for examine() by its aux value */
char *trapid(int trapno)
{
switch (trapno) {
case L_TRAP_SIREN:return("A siren trap");
case L_TRAP_DART:return("A dart trap");
case L_TRAP_PIT:return("A pit");
case L_TRAP_SNARE:return("A snare");
case L_TRAP_BLADE:return("A blade trap");
case L_TRAP_FIRE:return("A fire trap");
case L_TRAP_TELEPORT:return("A teleport trap");
case L_TRAP_DISINTEGRATE:return("A disintegration trap");
case L_TRAP_DOOR:return("A trap door");
case L_TRAP_MANADRAIN:return("A manadrain trap");
case L_TRAP_ACID:return("An acid shower trap");
case L_TRAP_SLEEP_GAS:return("A sleep gas trap");
case L_TRAP_ABYSS:return("A concealed entrance to the abyss");
default: return("A completely inoperative trap.");
}
}
/* checks current food status of player, every hour, and when food is eaten */
void foodcheck(void)
{
if (Player.food > 48) {
print3("You vomit up your huge meal.");
Player.food = 12;
}
else if (Player.food == 30)
print3("Time for a smackerel of something.");
else if (Player.food == 20)
print3("You feel hungry.");
else if (Player.food == 12)
print3("You are ravenously hungry.");
else if (Player.food == 3) {
print3("You feel weak.");
if (gamestatusp(FAST_MOVE)) {
drawvision(Player.x,Player.y);
resetgamestatus(FAST_MOVE);
}
}
else if (Player.food < 0) {
if (gamestatusp(FAST_MOVE)) {
drawvision(Player.x,Player.y);
resetgamestatus(FAST_MOVE);
}
print3("You're starving!");
p_damage(-5*Player.food,UNSTOPPABLE,"starvation");
}
showflags();
}
/* see whether room should be illuminated */
void roomcheck(void)
{
static int oldroomno = -1;
#ifdef MSDOS_SUPPORTED_ANTIQUE
static int oldlevel = -1;
#else
static plv oldlevel = NULL;
#endif
int roomno = Level->site[Player.x][Player.y].roomnumber;
if ((roomno == RS_CAVERN) ||
(roomno == RS_SEWER_DUCT) ||
(roomno == RS_KITCHEN) ||
(roomno == RS_BATHROOM) ||
(roomno == RS_BEDROOM) ||
(roomno == RS_DININGROOM) ||
(roomno == RS_CLOSET) ||
(roomno > ROOMBASE))
if ((! loc_statusp(Player.x,Player.y,LIT)) &&
(! Player.status[BLINDED]) &&
(Player.status[ILLUMINATION] || (difficulty() < 6))) {
showroom(Level->site[Player.x][Player.y].roomnumber);
spreadroomlight(Player.x,Player.y,roomno);
levelrefresh();
}
if ((oldroomno != roomno) ||
#ifdef MSDOS_SUPPORTED_ANTIQUE
(oldlevel != Level->depth)) {
#else
(oldlevel != Level)) {
#endif
showroom(roomno);
oldroomno = roomno;
#ifdef MSDOS_SUPPORTED_ANTIQUE
oldlevel = Level->depth;
#else
oldlevel = Level;
#endif
}
}
/* ask for mercy */
void surrender(struct monster *m)
{
int i;
long bestitem,bestvalue;
switch(random_range(4)) {
case 0: print1("You grovel at the monster's feet..."); break;
case 1: print1("You cry 'uncle'!"); break;
case 2: print1("You beg for mercy."); break;
case 3: print1("You yield to the monster."); break;
}
if (m->id == GUARD) {
if (m_statusp(m,HOSTILE))
monster_talk(m);
else {
print2("The guard (bored): Have you broken a law? [yn] ");
if (ynq2() == 'y') {
print2("The guard grabs you, and drags you to court.");
morewait();
send_to_jail();
}
else print2("Then don't bother me. Scat!");
}
}
else if ((m->talkf==M_NO_OP) ||
(m->talkf==M_TALK_STUPID))
print3("Your plea is ignored.");
else {
morewait();
print1("Your surrender is accepted.");
if (Player.cash > 0) nprint1(" All your gold is taken....");
Player.cash = 0;
bestvalue = 0;
bestitem = ABORT;
for (i=1;i<MAXITEMS;i++)
if (Player.possessions[i] != NULL)
if (bestvalue < true_item_value(Player.possessions[i])) {
bestitem = i;
bestvalue = true_item_value(Player.possessions[i]);
}
if (bestitem != ABORT) {
print2("You also give away your best item... ");
nprint2(itemid(Player.possessions[bestitem]));
nprint2(".");
morewait();
givemonster(m,Player.possessions[bestitem]);
morewait(); /* msgs come from givemonster */
conform_unused_object(Player.possessions[bestitem]);
Player.possessions[bestitem] = NULL;
}
print2("You feel less experienced... ");
Player.xp = max(0,Player.xp - m->xpv);
nprint2("The monster seems more experienced!");
m->level = (min(10,m->level+1));
m->hp += m->level*20;
m->hit += m->level;
m->dmg += m->level;
m->ac += m->level;
m->xpv += m->level*10;
morewait();
clearmsg();
if ((m->talkf == M_TALK_EVIL) && random_range(10)) {
print1("It continues to attack you, laughing evilly!");
m_status_set(m,HOSTILE);
m_status_reset(m,GREEDY);
}
else if (m->id == HORNET || m->id == GUARD)
print1("It continues to attack you. ");
else {
print1("The monster leaves, chuckling to itself....");
m_teleport(m);
}
}
dataprint();
}
/* threaten a monster */
void threaten(struct monster *m)
{
char response;
switch(random_range(4)) {
case 0:mprint("You demand that your opponent surrender!"); break;
case 1:mprint("You threaten to do bodily harm to it."); break;
case 2:mprint("You attempt to bluster it into submission."); break;
case 3:mprint("You try to cow it with your awesome presence."); break;
}
morewait(); /* FIXED! 12/25/98 */
if (! m_statusp(m,HOSTILE)) {
print3("You only annoy it with your futile demand.");
m_status_set(m,HOSTILE);
}
else if (((m->level*2 > Player.level) && (m->hp > Player.dmg)) ||
(m->uniqueness != COMMON))
print1("It sneers contemptuously at you.");
else if ((m->talkf != M_TALK_GREEDY) &&
(m->talkf != M_TALK_HUNGRY) &&
(m->talkf != M_TALK_EVIL) &&
(m->talkf != M_TALK_MAN) &&
(m->talkf != M_TALK_BEG) &&
(m->talkf != M_TALK_THIEF) &&
(m->talkf != M_TALK_MERCHANT) &&
(m->talkf != M_TALK_IM))
print1("Your demand is ignored");
else {
print1("It yields to your mercy.");
Player.alignment+=3;
print2("Kill it, rob it, or free it? [krf] ");
do response = (char) mcigetc();
while ((response != 'k')&&(response != 'r')&&(response !='f'));
if (response == 'k') {
m_death(m);
print2("You treacherous rogue!");
Player.alignment -= 13;
}
else if (response == 'r') {
Player.alignment-=2;
print2("It drops its treasure and flees.");
m_dropstuff(m);
m_remove( m );
}
else {
Player.alignment+=2;
print2("'If you love something set it free ... '");
if (random_range(100)==13) {
morewait();
print2("'...If it doesn't come back, hunt it down and kill it.'");
}
print3("It departs with a renewed sense of its own mortality.");
m_remove( m );
}
}
}
/* name of the player's experience level */
char *levelname(int level)
{
switch(level) {
case 0:strcpy(Str3,"neophyte");break;
case 1:strcpy(Str3,"beginner");break;
case 2:strcpy(Str3,"tourist");break;
case 3:strcpy(Str3,"traveller");break;
case 4:strcpy(Str3,"wayfarer");break;
case 5:strcpy(Str3,"peregrinator");break;
case 6:strcpy(Str3,"wanderer");break;
case 7:strcpy(Str3,"hunter");break;
case 8:strcpy(Str3,"scout");break;
case 9:strcpy(Str3,"trailblazer");break;
case 10:strcpy(Str3,"discoverer");break;
case 11:strcpy(Str3,"explorer");break;
case 12:strcpy(Str3,"senior explorer");break;
case 13:strcpy(Str3,"ranger");break;
case 14:strcpy(Str3,"ranger captain");break;
case 15:strcpy(Str3,"ranger knight");break;
case 16:strcpy(Str3,"adventurer");break;
case 17:strcpy(Str3,"experienced adventurer");break;
case 18:strcpy(Str3,"skilled adventurer");break;
case 19:strcpy(Str3,"master adventurer");break;
case 20:strcpy(Str3,"hero");break;
case 21:strcpy(Str3,"superhero");break;
case 22:strcpy(Str3,"demigod");break;
default:
if (level < 100) {
strcpy(Str3,"Order ");
Str3[6] = ((level/10)-2) + '0';
Str3[7] = 0;
strcat(Str3," Master of Omega");
}
else strcpy(Str3,"Ultimate Master of Omega");
break;
}
return(Str3);
}