forked from angband/angband
/
borg4.c
9649 lines (8125 loc) · 310 KB
/
borg4.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
/* File: borg4.c */
/* Purpose: Notice and Power code for the Borg -BEN- */
#include "angband.h"
#include "object/tvalsval.h"
#include "cave.h"
#include "files.h"
#ifdef ALLOW_BORG
#include "borg1.h"
#include "borg2.h"
#include "borg3.h"
#include "borg4.h"
/*
* Note that we assume that any item with quantity zero does not exist,
* thus, when simulating possible worlds, we do not actually have to
* "optimize" empty slots.
*
*/
/*
* The "notice" functions examine various aspects of the player inventory,
* the player equipment, or the home contents, and extract various numerical
* quantities based on those aspects, adjusting them for various "abilities",
* such as the ability to cast certain spells, etc.
*
* The "power" functions use the numerical quantities described above, and
* use them to do two different things: (1) rank the "value" of having
* various abilities relative to the possible "money" reward of carrying
* sellable items instead, and (2) rank the value of various abilities
* relative to each other, which is used to determine what to wear/buy,
* and in what order to wear/buy those items.
*
* These functions use some very heuristic values, by the way...
*
* We should probably take account of things like possible enchanting
* (especially when in town), and items which may be found soon.
*
* We consider several things:
* (1) the actual "power" of the current weapon and bow
* (2) the various "flags" imparted by the equipment
* (3) the various abilities imparted by the equipment
* (4) the penalties induced by heavy armor or gloves or edged weapons
* (5) the abilities required to enter the "max_depth" dungeon level
* (6) the various abilities of some useful inventory items
*
* Note the use of special "item counters" for evaluating the value of
* a collection of items of the given type. Basically, the first item
* of the given type is always the most valuable, with subsequent items
* being worth less, until the "limit" is reached, after which point any
* extra items are only worth as much as they can be sold for.
*/
/*
* Helper function -- notice the player equipment
*/
static void borg_notice_aux1(void)
{
int i, hold;
const struct player_race *rb_ptr = p_ptr->race;
const struct player_class *cb_ptr = p_ptr->class;
int extra_blows = 0;
int extra_shots = 0;
int extra_might = 0;
int my_num_fire;
bitflag f[OF_SIZE];
borg_item *item;
/* Recalc some Variables */
borg_skill[BI_ARMOR] = 0;
borg_skill[BI_SPEED] = 110;
/* Start with a single blow per turn */
borg_skill[BI_BLOWS] = 1;
/* Start with a single shot per turn */
my_num_fire = 1;
/* Reset the "ammo" tval */
my_ammo_tval = -1;
/* Reset the "ammo" sides for darts*/
my_ammo_sides = 4;
/* Reset the shooting power */
my_ammo_power = 0;
/* Reset the count of ID needed immediately */
my_need_id = 0;
/* Base infravision (purely racial) */
borg_skill[BI_INFRA] = rb_ptr->infra;
/* Base skill -- disarming */
borg_skill[BI_DIS] = rb_ptr->r_skills[SKILL_DISARM] + cb_ptr->c_skills[SKILL_DISARM];
/* Base skill -- magic devices */
borg_skill[BI_DEV] = rb_ptr->r_skills[SKILL_DEVICE] + cb_ptr->c_skills[SKILL_DEVICE];
/* Base skill -- saving throw */
borg_skill[BI_SAV] = rb_ptr->r_skills[SKILL_SAVE] + cb_ptr->c_skills[SKILL_SAVE];
/* Base skill -- stealth */
borg_skill[BI_STL] = rb_ptr->r_skills[SKILL_STEALTH] + cb_ptr->c_skills[SKILL_STEALTH];
/* Base skill -- searching ability */
borg_skill[BI_SRCH] = rb_ptr->r_skills[SKILL_SEARCH] + cb_ptr->c_skills[SKILL_SEARCH];
/* Base skill -- searching frequency */
borg_skill[BI_SRCHFREQ] = rb_ptr->r_skills[SKILL_SEARCH_FREQUENCY] + cb_ptr->c_skills[SKILL_SEARCH_FREQUENCY];
/* Base skill -- combat (normal) */
borg_skill[BI_THN] = rb_ptr->r_skills[SKILL_TO_HIT_MELEE] + cb_ptr->c_skills[SKILL_TO_HIT_MELEE];
/* Base skill -- combat (shooting) */
borg_skill[BI_THB] = rb_ptr->r_skills[SKILL_TO_HIT_BOW] + cb_ptr->c_skills[SKILL_TO_HIT_BOW];
/* Base skill -- combat (throwing) */
borg_skill[BI_THT] = rb_ptr->r_skills[SKILL_TO_HIT_THROW] + cb_ptr->c_skills[SKILL_TO_HIT_THROW];
/** Racial Skills **/
/* Extract the player flags */
player_flags(f);
/* Good flags */
if (rf_has(f, OF_SLOW_DIGEST)) borg_skill[BI_SDIG] = TRUE;
if (rf_has(f, OF_FEATHER)) borg_skill[BI_FEATH] = TRUE;
if (rf_has(f, OF_REGEN)) borg_skill[BI_REG] = TRUE;
if (rf_has(f, OF_TELEPATHY)) borg_skill[BI_ESP] = TRUE;
if (rf_has(f, OF_SEE_INVIS)) borg_skill[BI_SINV] = TRUE;
if (rf_has(f, OF_FREE_ACT)) borg_skill[BI_FRACT] = TRUE;
if (rf_has(f, OF_HOLD_LIFE)) borg_skill[BI_HLIFE] = TRUE;
/* Weird flags */
/* Bad flags */
if (rf_has(f, OF_IMPACT)) borg_skill[BI_W_IMPACT] = TRUE;
if (rf_has(f, OF_AGGRAVATE)) borg_skill[BI_CRSAGRV] = TRUE;
if (rf_has(f, OF_TELEPORT)) borg_skill[BI_CRSTELE] = TRUE;
if (rf_has(f, OF_IMPAIR_HP)) borg_skill[BI_CRSHPIMP] = TRUE;
if (rf_has(f, OF_IMPAIR_MANA)) borg_skill[BI_CRSMPIMP] = TRUE;
if (rf_has(f, OF_AFRAID))
{
borg_skill[BI_CRSFEAR] = TRUE;
}
if (rf_has(f, OF_VULN_FIRE)) borg_skill[BI_CRSFVULN] = TRUE;
if (rf_has(f, OF_VULN_ACID)) borg_skill[BI_CRSAVULN] = TRUE;
if (rf_has(f, OF_VULN_COLD)) borg_skill[BI_CRSCVULN] = TRUE;
if (rf_has(f, OF_VULN_ELEC)) borg_skill[BI_CRSEVULN] = TRUE;
/* Immunity flags */
if (rf_has(f, OF_IM_FIRE)) borg_skill[BI_IFIRE] = TRUE;
if (rf_has(f, OF_IM_ACID)) borg_skill[BI_IACID] = TRUE;
if (rf_has(f, OF_IM_COLD)) borg_skill[BI_ICOLD] = TRUE;
if (rf_has(f, OF_IM_ELEC)) borg_skill[BI_IELEC] = TRUE;
/* Resistance flags */
if (rf_has(f, OF_RES_ACID)) borg_skill[BI_RACID] = TRUE;
if (rf_has(f, OF_RES_ELEC)) borg_skill[BI_RELEC] = TRUE;
if (rf_has(f, OF_RES_FIRE)) borg_skill[BI_RFIRE] = TRUE;
if (rf_has(f, OF_RES_COLD)) borg_skill[BI_RCOLD] = TRUE;
if (rf_has(f, OF_RES_POIS)) borg_skill[BI_RPOIS] = TRUE;
if (rf_has(f, OF_RES_FEAR)) borg_skill[BI_RFEAR] = TRUE;
if (rf_has(f, OF_RES_LIGHT)) borg_skill[BI_RLITE] = TRUE;
if (rf_has(f, OF_RES_DARK)) borg_skill[BI_RDARK] = TRUE;
if (rf_has(f, OF_RES_BLIND)) borg_skill[BI_RBLIND] = TRUE;
if (rf_has(f, OF_RES_CONFU)) borg_skill[BI_RCONF] = TRUE;
if (rf_has(f, OF_RES_SOUND)) borg_skill[BI_RSND] = TRUE;
if (rf_has(f, OF_RES_SHARD)) borg_skill[BI_RSHRD] = TRUE;
if (rf_has(f, OF_RES_NEXUS)) borg_skill[BI_RNXUS] = TRUE;
if (rf_has(f, OF_RES_NETHR)) borg_skill[BI_RNTHR] = TRUE;
if (rf_has(f, OF_RES_CHAOS)) borg_skill[BI_RKAOS] = TRUE;
if (rf_has(f, OF_RES_DISEN)) borg_skill[BI_RDIS] = TRUE;
/* Sustain flags */
if (rf_has(f, OF_SUST_STR)) borg_skill[BI_SSTR] = TRUE;
if (rf_has(f, OF_SUST_INT)) borg_skill[BI_SINT] = TRUE;
if (rf_has(f, OF_SUST_WIS)) borg_skill[BI_SWIS] = TRUE;
if (rf_has(f, OF_SUST_DEX)) borg_skill[BI_SDEX] = TRUE;
if (rf_has(f, OF_SUST_CON)) borg_skill[BI_SCON] = TRUE;
if (rf_has(f, OF_SUST_CHR)) borg_skill[BI_SCHR] = TRUE;
/* I am pretty sure the CF_flags will be caught by the
* code above when the player flags are checked
*/
/* Clear the stat modifiers */
for (i = 0; i < 6; i++) my_stat_add[i] = 0;
/* Scan the usable inventory */
for (i = INVEN_WIELD; i < INVEN_TOTAL; i++)
{
item = &borg_items[i];
/* Skip empty items */
if (!item->iqty) continue;
/* Does the borg need to get an ID for it? */
if (streq(item->note, "magical") ||
streq(item->note, "ego") ||
streq(item->note, "splendid") ||
streq(item->note, "excellent")) my_need_id ++;
/* track number of items the borg has on him */
/* Count up how many artifacts the borg has on him */
borg_has_on[item->kind] += item->iqty;
if (item->name1)
borg_artifact[item->name1] = item->iqty;
/* Affect stats */
if (of_has(item->flags, OF_STR)) my_stat_add[A_STR] += item->pval;
if (of_has(item->flags, OF_INT)) my_stat_add[A_INT] += item->pval;
if (of_has(item->flags, OF_WIS)) my_stat_add[A_WIS] += item->pval;
if (of_has(item->flags, OF_DEX)) my_stat_add[A_DEX] += item->pval;
if (of_has(item->flags, OF_CON)) my_stat_add[A_CON] += item->pval;
if (of_has(item->flags, OF_CHR)) my_stat_add[A_CHR] += item->pval;
/* various slays */
if (of_has(item->flags, OF_SLAY_ANIMAL)) borg_skill[BI_WS_ANIMAL] = TRUE;
if (of_has(item->flags, OF_SLAY_EVIL)) borg_skill[BI_WS_EVIL] = TRUE;
if (of_has(item->flags, OF_SLAY_UNDEAD)) borg_skill[BI_WS_UNDEAD] = TRUE;
if (of_has(item->flags, OF_SLAY_DEMON)) borg_skill[BI_WS_DEMON] = TRUE;
if (of_has(item->flags, OF_SLAY_ORC)) borg_skill[BI_WS_ORC] = TRUE;
if (of_has(item->flags, OF_SLAY_TROLL)) borg_skill[BI_WS_TROLL] = TRUE;
if (of_has(item->flags, OF_SLAY_GIANT)) borg_skill[BI_WS_GIANT] = TRUE;
if (of_has(item->flags, OF_SLAY_DRAGON)) borg_skill[BI_WS_DRAGON] = TRUE;
if (of_has(item->flags, OF_KILL_UNDEAD)) borg_skill[BI_WK_UNDEAD] = TRUE;
if (of_has(item->flags, OF_KILL_DEMON)) borg_skill[BI_WK_DEMON] = TRUE;
if (of_has(item->flags, OF_KILL_DRAGON)) borg_skill[BI_WK_DRAGON] = TRUE;
if (of_has(item->flags, OF_IMPACT)) borg_skill[BI_W_IMPACT] = TRUE;
if (of_has(item->flags, OF_BRAND_ACID)) borg_skill[BI_WB_ACID] = TRUE;
if (of_has(item->flags, OF_BRAND_ELEC)) borg_skill[BI_WB_ELEC] = TRUE;
if (of_has(item->flags, OF_BRAND_FIRE)) borg_skill[BI_WB_FIRE] = TRUE;
if (of_has(item->flags, OF_BRAND_COLD)) borg_skill[BI_WB_COLD] = TRUE;
if (of_has(item->flags, OF_BRAND_POIS)) borg_skill[BI_WB_POIS] = TRUE;
/* Affect infravision */
if (of_has(item->flags, OF_INFRA)) borg_skill[BI_INFRA] += item->pval;
/* Affect stealth */
if (of_has(item->flags, OF_STEALTH)) borg_skill[BI_STL] += item->pval;
/* Affect searching ability (factor of five) */
if (of_has(item->flags, OF_SEARCH)) borg_skill[BI_SRCH] += (item->pval * 5);
/* Affect searching frequency (factor of five) */
if (of_has(item->flags, OF_SEARCH)) borg_skill[BI_SRCHFREQ] += (item->pval * 5);
/* Affect digging (factor of 20) */
if (of_has(item->flags, OF_TUNNEL)) borg_skill[BI_DIG] += (item->pval * 20);
/* Affect speed */
if (of_has(item->flags, OF_SPEED)) borg_skill[BI_SPEED] += item->pval;
/* Affect blows */
if (of_has(item->flags, OF_BLOWS)) extra_blows += item->pval;
/* Boost shots */
if (of_has(item->flags, OF_SHOTS)) extra_shots++;
/* Boost might */
if (of_has(item->flags, OF_MIGHT)) extra_might++;
/* Various flags */
if (of_has(item->flags, OF_SLOW_DIGEST)) borg_skill[BI_SDIG] = TRUE;
if (of_has(item->flags, OF_AGGRAVATE)) borg_skill[BI_CRSAGRV] = TRUE;
if (of_has(item->flags, OF_TELEPORT)) borg_skill[BI_CRSTELE] = TRUE;
if (of_has(item->flags, OF_IMPAIR_HP)) borg_skill[BI_CRSHPIMP] = TRUE;
if (of_has(item->flags, OF_IMPAIR_MANA)) borg_skill[BI_CRSMPIMP] = TRUE;
if (of_has(item->flags, OF_AFRAID))
{
borg_skill[BI_CRSFEAR] = TRUE;
}
if (of_has(item->flags, OF_VULN_FIRE)) borg_skill[BI_CRSFVULN] = TRUE;
if (of_has(item->flags, OF_VULN_ACID)) borg_skill[BI_CRSAVULN] = TRUE;
if (of_has(item->flags, OF_VULN_COLD)) borg_skill[BI_CRSCVULN] = TRUE;
if (of_has(item->flags, OF_VULN_ELEC)) borg_skill[BI_CRSEVULN] = TRUE;
if (of_has(item->flags, OF_REGEN)) borg_skill[BI_REG] = TRUE;
if (of_has(item->flags, OF_TELEPATHY)) borg_skill[BI_ESP] = TRUE;
if (of_has(item->flags, OF_SEE_INVIS)) borg_skill[BI_SINV] = TRUE;
if (of_has(item->flags, OF_FEATHER)) borg_skill[BI_FEATH] = TRUE;
if (of_has(item->flags, OF_FREE_ACT)) borg_skill[BI_FRACT] = TRUE;
if (of_has(item->flags, OF_HOLD_LIFE)) borg_skill[BI_HLIFE] = TRUE;
/* Item makes player glow or has a light radius */
if (of_has(item->flags, OF_LIGHT))
{
/* Special case for Torches/Lantern of Brightness, they are not perm. */
if (item->tval != TV_LIGHT &&
item->sval != SV_LIGHT_TORCH &&
item->sval != SV_LIGHT_LANTERN) borg_skill[BI_LIGHT] ++;
}
/* Artifact-- borgs do not gain the knowlege of some flags until
* after the *ID*. So we allow the borg to know that the
* item does have lite even if its not *ID*
*/
if ((item->name1 >=1 && item->name1 <= 3) || /* Phial, Star, Arkenstone */
item->name1 == 7 || /* Planatir */
item->name1 == 14 || /* Elfstone */
item->name1 == 15) /* Jewel */
borg_skill[BI_LIGHT] ++;
/* Immunity flags */
/* if you are immune you automaticly resist */
if (of_has(item->flags, OF_IM_FIRE))
{
borg_skill[BI_IFIRE] = TRUE;
borg_skill[BI_RFIRE] = TRUE;
borg_skill[BI_TRFIRE] = TRUE;
}
if (of_has(item->flags, OF_IM_ACID))
{
borg_skill[BI_IACID] = TRUE;
borg_skill[BI_RACID] = TRUE;
borg_skill[BI_TRACID] = TRUE;
}
if (of_has(item->flags, OF_IM_COLD))
{
borg_skill[BI_ICOLD] = TRUE;
borg_skill[BI_RCOLD] = TRUE;
borg_skill[BI_TRCOLD] = TRUE;
}
if (of_has(item->flags, OF_IM_ELEC))
{
borg_skill[BI_IELEC] = TRUE;
borg_skill[BI_RELEC] = TRUE;
borg_skill[BI_TRELEC] = TRUE;
}
/* Resistance flags */
if (of_has(item->flags, OF_RES_ACID)) borg_skill[BI_RACID] = TRUE;
if (of_has(item->flags, OF_RES_ELEC)) borg_skill[BI_RELEC] = TRUE;
if (of_has(item->flags, OF_RES_FIRE)) borg_skill[BI_RFIRE] = TRUE;
if (of_has(item->flags, OF_RES_COLD)) borg_skill[BI_RCOLD] = TRUE;
if (of_has(item->flags, OF_RES_POIS)) borg_skill[BI_RPOIS] = TRUE;
if (of_has(item->flags, OF_RES_CONFU)) borg_skill[BI_RCONF] = TRUE;
if (of_has(item->flags, OF_RES_SOUND)) borg_skill[BI_RSND] = TRUE;
if (of_has(item->flags, OF_RES_LIGHT)) borg_skill[BI_RLITE] = TRUE;
if (of_has(item->flags, OF_RES_DARK)) borg_skill[BI_RDARK] = TRUE;
if (of_has(item->flags, OF_RES_CHAOS)) borg_skill[BI_RKAOS] = TRUE;
if (of_has(item->flags, OF_RES_DISEN)) borg_skill[BI_RDIS] = TRUE;
if (of_has(item->flags, OF_RES_SHARD)) borg_skill[BI_RSHRD] = TRUE;
if (of_has(item->flags, OF_RES_NEXUS)) borg_skill[BI_RNXUS] = TRUE;
if (of_has(item->flags, OF_RES_BLIND)) borg_skill[BI_RBLIND] = TRUE;
if (of_has(item->flags, OF_RES_NETHR)) borg_skill[BI_RNTHR] = TRUE;
/* Sustain flags */
if (of_has(item->flags, OF_SUST_STR)) borg_skill[BI_SSTR] = TRUE;
if (of_has(item->flags, OF_SUST_INT)) borg_skill[BI_SINT] = TRUE;
if (of_has(item->flags, OF_SUST_WIS)) borg_skill[BI_SWIS] = TRUE;
if (of_has(item->flags, OF_SUST_DEX)) borg_skill[BI_SDEX] = TRUE;
if (of_has(item->flags, OF_SUST_CON)) borg_skill[BI_SCON] = TRUE;
if (of_has(item->flags, OF_SUST_CHR)) borg_skill[BI_SCHR] = TRUE;
/* Hack -- Net-zero The borg will miss read acid damaged items such as
* Leather Gloves [2,-2] and falsely assume they help his power.
* this hack rewrites the bonus to an extremely negative value
* thus encouraging him to remove the non-helpful-non-harmful but
* heavy-none-the-less item.
*/
if ((!item->name1 && !item->name2) &&
item->ac >= 1 && item->to_a + item->ac <= 0)
{
item->to_a = -20;
}
/* Modify the base armor class */
borg_skill[BI_ARMOR] += item->ac;
/* Apply the bonuses to armor class */
borg_skill[BI_ARMOR] += item->to_a;
/* Hack -- do not apply "weapon" bonuses */
if (i == INVEN_WIELD) continue;
/* Hack -- do not apply "bow" bonuses */
if (i == INVEN_BOW) continue;
/* Apply the bonuses to hit/damage */
borg_skill[BI_TOHIT] += item->to_h;
borg_skill[BI_TODAM] += item->to_d;
}
/* Update "stats" */
for (i = 0; i < 6; i++)
{
int add, use, ind;
add = my_stat_add[i];
if (op_ptr->opt[OPT_birth_maximize])
{
/* Modify the stats for race/class */
add += (p_ptr->race->r_adj[i] + p_ptr->class->c_adj[i]);
}
/* Extract the new "use_stat" value for the stat */
use = modify_stat_value(my_stat_cur[i], add);
/* Save the stat */
my_stat_use[i] = use;
/* Values: 3, ..., 17 */
if (use <= 18) ind = (use - 3);
/* Ranges: 18/00-18/09, ..., 18/210-18/219 */
else if (use <= 18+219) ind = (15 + (use - 18) / 10);
/* Range: 18/220+ */
else ind = (37);
/* Save the index */
if (ind > 37)
my_stat_ind[i] = 37;
else
my_stat_ind[i] = ind;
borg_skill[BI_STR+i] = my_stat_ind[i];
borg_skill[BI_CSTR+i] = borg_stat[i];
}
/* 'Mana' is actually the 'mana adjustment' */
if (p_ptr->class->spell_book == TV_PRAYER_BOOK)
{
borg_skill[BI_SP_ADJ] =
((adj_mag_mana[my_stat_ind[A_WIS]] * borg_skill[BI_CLEVEL]) / 2);
borg_skill[BI_FAIL1] = adj_mag_stat[my_stat_ind[A_WIS]];
borg_skill[BI_FAIL2] = adj_mag_fail[my_stat_ind[A_WIS]];
}
if (p_ptr->class->spell_book == TV_MAGIC_BOOK)
{
borg_skill[BI_SP_ADJ] =
((adj_mag_mana[my_stat_ind[A_INT]] * borg_skill[BI_CLEVEL]) / 2);
borg_skill[BI_FAIL1] = adj_mag_stat[my_stat_ind[A_INT]];
borg_skill[BI_FAIL2] = adj_mag_fail[my_stat_ind[A_INT]];
}
/* Bloating slows the player down (a little) */
if (borg_skill[BI_ISGORGED]) borg_skill[BI_SPEED] -= 10;
/* Actual Modifier Bonuses (Un-inflate stat bonuses) */
borg_skill[BI_ARMOR] += ((int)(adj_dex_ta[my_stat_ind[A_DEX]]) - 128);
borg_skill[BI_TODAM] += ((int)(adj_str_td[my_stat_ind[A_STR]]) - 128);
borg_skill[BI_TOHIT] += ((int)(adj_dex_th[my_stat_ind[A_DEX]]) - 128);
borg_skill[BI_TOHIT] += ((int)(adj_str_th[my_stat_ind[A_STR]]) - 128);
/* Obtain the "hold" value */
hold = adj_str_hold[my_stat_ind[A_STR]];
/** Examine the "current bow" **/
item = &borg_items[INVEN_BOW];
/* attacking with bare hands */
if (item->iqty == 0)
{
item->ds = 0;
item->dd = 0;
item->to_d = 0;
item->to_h = 0;
item->weight = 0;
}
/* Real bonuses */
borg_skill[BI_BTOHIT] = item->to_h;
borg_skill[BI_BTODAM] = item->to_d;
/* It is hard to carholdry a heavy bow */
if (hold < item->weight / 10)
{
borg_skill[BI_HEAVYBOW] = TRUE;
/* Hard to wield a heavy bow */
borg_skill[BI_TOHIT] += 2 * (hold - item->weight / 10);
}
/* Compute "extra shots" if needed */
if (item->iqty && (hold >= item->weight / 10))
{
/* Take note of required "tval" for missiles */
switch (item->sval)
{
case SV_SLING:
my_ammo_tval = TV_SHOT;
my_ammo_sides = 3;
my_ammo_power = 2;
break;
case SV_SHORT_BOW:
my_ammo_tval = TV_ARROW;
my_ammo_sides = 4;
my_ammo_power = 2;
break;
case SV_LONG_BOW:
my_ammo_tval = TV_ARROW;
my_ammo_sides = 4;
my_ammo_power = 3;
break;
case SV_LIGHT_XBOW:
my_ammo_tval = TV_BOLT;
my_ammo_sides = 5;
my_ammo_power = 3;
break;
case SV_HEAVY_XBOW:
my_ammo_tval = TV_BOLT;
my_ammo_sides = 5;
my_ammo_power = 4;
break;
}
/* Add in extra power */
my_ammo_power += extra_might;
/* Hack -- Reward High Level Rangers using Bows */
if (player_has(PF_EXTRA_SHOT) && (my_ammo_tval == TV_ARROW))
{
/* Extra shot at level 20 */
if (borg_skill[BI_CLEVEL] >= 20) my_num_fire++;
/* Extra shot at level 40 */
if (borg_skill[BI_CLEVEL] >= 40) my_num_fire++;
}
/* Add in the "bonus shots" */
my_num_fire += extra_shots;
/* Require at least one shot */
if (my_num_fire < 1) my_num_fire = 1;
}
borg_skill[BI_SHOTS] = my_num_fire;
/* Calculate "average" damage per "normal" shot (times 2) */
borg_skill[BI_BMAXDAM] = (my_ammo_sides + borg_skill[BI_BTODAM]) * my_ammo_power;
borg_skill[BI_BMAXDAM] *= borg_skill[BI_SHOTS];
/* Examine the "main weapon" */
item = &borg_items[INVEN_WIELD];
/* attacking with bare hands */
if (item->iqty == 0)
{
item->ds = 0;
item->dd = 0;
item->to_d = 0;
item->to_h = 0;
item->weight = 0;
}
/* Real values */
borg_skill[BI_WTOHIT] = item->to_h;
borg_skill[BI_WTODAM] = item->to_d;
/* It is hard to hold a heavy weapon */
if (hold < item->weight / 10)
{
borg_skill[BI_HEAVYWEPON] = TRUE;
/* Hard to wield a heavy weapon */
borg_skill[BI_TOHIT] += 2 * (hold - item->weight / 10);
}
/* Normal weapons */
if (item->iqty && (hold >= item->weight / 10))
{
int str_index, dex_index;
int div;
/* Enforce a minimum "weight" (tenth pounds) */
div = ((item->weight < p_ptr->class->min_weight) ? p_ptr->class->min_weight : item->weight);
/* Get the strength vs weight */
str_index = (adj_str_blow[my_stat_ind[A_STR]] * p_ptr->class->att_multiply / div);
/* Maximal value */
if (str_index > 11) str_index = 11;
/* Index by dexterity */
dex_index = (adj_dex_blow[my_stat_ind[A_DEX]]);
/* Maximal value */
if (dex_index > 11) dex_index = 11;
/* Use the blows table */
borg_skill[BI_BLOWS] = blows_table[str_index][dex_index];
/* Maximal value */
if (borg_skill[BI_BLOWS] > p_ptr->class->max_attacks) borg_skill[BI_BLOWS] = p_ptr->class->max_attacks;
/* Add in the "bonus blows" */
borg_skill[BI_BLOWS] += extra_blows;
/* Require at least one blow */
if (borg_skill[BI_BLOWS] < 1) borg_skill[BI_BLOWS] = 1;
/* Boost digging skill by weapon weight */
borg_skill[BI_DIG] += (item->weight / 10);
}
/* Calculate "max" damage per "normal" blow */
/* and assume we can enchant up to +8 if borg_skill[BI_CLEVEL] > 25 */
borg_skill[BI_WMAXDAM] =
(item->dd * item->ds + borg_skill[BI_TODAM] + borg_skill[BI_WTODAM]);
/* Calculate base damage, used to calculating slays */
borg_skill[BI_WBASEDAM] =
(item->dd * item->ds);
/* Hack -- Reward High Level Warriors with Res Fear */
if (player_has(PF_BRAVERY_30))
{
/* Resist fear at level 30 */
if (borg_skill[BI_CLEVEL] >= 30) borg_skill[BI_RFEAR] = TRUE;
}
/* Affect Skill -- stealth (bonus one) */
borg_skill[BI_STL] += 1;
/* Affect Skill -- disarming (DEX and INT) */
borg_skill[BI_DIS] += adj_dex_dis[my_stat_ind[A_DEX]];
borg_skill[BI_DIS] += adj_int_dis[my_stat_ind[A_INT]];
/* Affect Skill -- magic devices (INT) */
borg_skill[BI_DEV] += adj_int_dev[my_stat_ind[A_INT]];
/* Affect Skill -- saving throw (WIS) */
borg_skill[BI_SAV] += adj_wis_sav[my_stat_ind[A_WIS]];
/* Affect Skill -- digging (STR) */
borg_skill[BI_DIG] += adj_str_dig[my_stat_ind[A_STR]];
/* Affect Skill -- disarming (Level, by Class) */
borg_skill[BI_DIS] += (cb_ptr->x_skills[SKILL_DISARM] * borg_skill[BI_MAXCLEVEL] / 10);
/* Affect Skill -- magic devices (Level, by Class) */
borg_skill[BI_DEV] += (cb_ptr->x_skills[SKILL_DEVICE] * borg_skill[BI_MAXCLEVEL] / 10);
/* Affect Skill -- saving throw (Level, by Class) */
borg_skill[BI_SAV] += (cb_ptr->x_skills[SKILL_SAVE] * borg_skill[BI_MAXCLEVEL] / 10);
/* Affect Skill -- stealth (Level, by Class) */
borg_skill[BI_STL] += (cb_ptr->x_skills[SKILL_STEALTH] * borg_skill[BI_MAXCLEVEL] / 10);
/* Affect Skill -- search ability (Level, by Class) */
borg_skill[BI_SRCH] += (cb_ptr->x_skills[SKILL_SEARCH] * borg_skill[BI_MAXCLEVEL] / 10);
/* Affect Skill -- search frequency (Level, by Class) */
borg_skill[BI_SRCHFREQ] += (cb_ptr->x_skills[SKILL_SEARCH_FREQUENCY] * borg_skill[BI_MAXCLEVEL] / 10);
/* Affect Skill -- combat (normal) (Level, by Class) */
borg_skill[BI_THN] += (cb_ptr->x_skills[SKILL_TO_HIT_MELEE] * borg_skill[BI_MAXCLEVEL] / 10);
/* Affect Skill -- combat (shooting) (Level, by Class) */
borg_skill[BI_THB] += (cb_ptr->x_skills[SKILL_TO_HIT_BOW] * borg_skill[BI_MAXCLEVEL] / 10);
/* Affect Skill -- combat (throwing) (Level, by Class) */
borg_skill[BI_THT] += (cb_ptr->x_skills[SKILL_TO_HIT_THROW] * borg_skill[BI_MAXCLEVEL] / 10);
/* Limit Skill -- stealth from 0 to 30 */
if (borg_skill[BI_STL] > 30) borg_skill[BI_STL] = 30;
if (borg_skill[BI_STL] < 0) borg_skill[BI_STL] = 0;
/* Limit Skill -- digging from 1 up */
if (borg_skill[BI_DIG] < 1) borg_skill[BI_DIG] = 1;
/*** Some penalties to consider ***/
/* Fear from spell or effect or flag */
if (borg_skill[BI_ISAFRAID] || borg_skill[BI_CRSFEAR])
{
borg_skill[BI_TOHIT] -= 20;
borg_skill[BI_ARMOR] += 8;
borg_skill[BI_DEV] = borg_skill[BI_DEV] * 95 / 100;
}
/* priest weapon penalty for non-blessed edged weapons */
if (player_has(PF_BLESS_WEAPON) &&
((item->tval == TV_SWORD || item->tval == TV_POLEARM) &&
!of_has(item->flags, OF_BLESSED)))
{
/* Reduce the real bonuses */
borg_skill[BI_TOHIT] -= 2;
borg_skill[BI_TODAM] -= 2;
}
/*** Count needed enchantment ***/
/* Assume no enchantment needed */
my_need_enchant_to_a = 0;
my_need_enchant_to_h = 0;
my_need_enchant_to_d = 0;
my_need_brand_weapon = 0;
/* Hack -- enchant all the equipment (weapons) */
for (i = INVEN_WIELD; i <= INVEN_BOW; i++)
{
item = &borg_items[i];
/* Skip empty items */
if (!item->iqty) continue;
/* Skip "unknown" items */
if (!item->ident) continue;
/* Most classes store the enchants until they get
* a 3x shooter (like a long bow).
* --Important: Also look in borg7.c for the enchanting.
* --We do not want the bow enchanted by mistake.
*/
if (i == INVEN_BOW && /* bow */
my_ammo_power < 3 && /* 3x shooter */
(!item->name1 && !item->name2)) /* Not Ego or Artifact */
continue;
/* Enchant all weapons (to hit) */
if ((borg_prayer_legal_fail(7, 3, 65) ||
borg_spell_legal_fail(7, 3, 65) ||
amt_enchant_weapon >=1 ) )
{
if (item->to_h < borg_enchant_limit)
{
my_need_enchant_to_h += (borg_enchant_limit - item->to_h);
}
/* Enchant all weapons (to damage) */
if (item->to_d < borg_enchant_limit)
{
my_need_enchant_to_d += (borg_enchant_limit - item->to_d);
}
}
else /* I dont have the spell or *enchant* */
{
if (item->to_h < 8)
{
my_need_enchant_to_h += (8 - item->to_h);
}
/* Enchant all weapons (to damage) */
if (item->to_d < 8)
{
my_need_enchant_to_d += (8 - item->to_d);
}
}
}
/* Hack -- enchant all the equipment (armor) */
for (i = INVEN_BODY; i <= INVEN_FEET; i++)
{
item = &borg_items[i];
/* Skip empty items */
if (!item->iqty) continue;
/* Skip "unknown" items */
if (!item->ident) continue;
/* Note need for enchantment */
if ((borg_prayer_legal_fail(7, 4, 65) ||
borg_spell_legal_fail(7, 2, 65) ||
amt_enchant_armor >=1 ))
{
if (item->to_a < borg_enchant_limit)
{
my_need_enchant_to_a += (borg_enchant_limit - item->to_a);
}
}
else
{
if (item->to_a < 8)
{
my_need_enchant_to_a += (8 - item->to_a);
}
}
}
/* Examine the lite */
item = &borg_items[INVEN_LIGHT];
/* Assume normal lite radius */
borg_skill[BI_CURLITE] = 0;
/* Glowing player has light */
if (borg_skill[BI_LIGHT]) borg_skill[BI_CURLITE] = borg_skill[BI_LIGHT];
/* Lite */
if (item->tval == TV_LIGHT)
{
if (of_has(item->flags, OF_LIGHT))
borg_skill[BI_CURLITE] = borg_skill[BI_CURLITE] + item->pval;
}
/* Special way to handle See Inv */
if (borg_see_inv >= 1) borg_skill[BI_SINV] = TRUE;
if (borg_skill[BI_CDEPTH] == 0 && /* only in town. Allow him to recall down */
(borg_prayer_legal(2, 3) ||
borg_spell_legal(2, 6))) borg_skill[BI_SINV] = TRUE;
/* Very special handling of Free Action.
* If the person has perfect Savings throw, he can be
* considered ok on Free Action. This can free up an
* equipment slot.
*/
if (borg_skill[BI_SAV] >= 100) borg_skill[BI_FRACT] = TRUE;
/* Special case for RBlindness. Perfect saves and the
* resistances for light and dark are good enough for RBlind
*/
if (borg_skill[BI_SAV] >= 100 && borg_skill[BI_RDARK] &&
borg_skill[BI_RLITE]) borg_skill[BI_RBLIND] = TRUE;
/*** Quiver needs to be evaluated ***/
/* Hack -- ignore invalid missiles */
for (i = QUIVER_START; i < QUIVER_END; i++)
{
item = &borg_items[i];
/* Skip empty items */
if (!item->iqty) break;
if (item->tval != my_ammo_tval) continue;
/* Count missiles */
borg_skill[BI_AMISSILES] += item->iqty;
/* Only enchant ammo if we have a good shooter,
* otherwise, store the enchants in the home.
*/
if (my_ammo_power >= 3)
{
if ((borg_equips_artifact(EFF_FIREBRAND, INVEN_BOW) ||
borg_spell_legal_fail(7, 5, 65)) &&
item->iqty >=5 &&
/* Skip artifacts and ego-items */
!item->name2 &&
!item->name1 &&
item->ident &&
item->tval == my_ammo_tval)
{
my_need_brand_weapon +=10L;
}
/* if we have loads of cash (as we will at level 35), */
/* enchant missiles */
if (borg_skill[BI_CLEVEL] > 35)
{
if ((borg_spell_legal_fail(7, 3, 65) || borg_prayer_legal_fail(7, 3, 65))
&& item->iqty >= 5)
{
if (item->to_h < 10)
{
my_need_enchant_to_h += (10 - item->to_h);
}
if (item->to_d < 10)
{
my_need_enchant_to_d += (10 - item->to_d);
}
}
else
{
if (item->to_h < 8)
{
my_need_enchant_to_h += (8 - item->to_h);
}
if (item->to_d < 8)
{
my_need_enchant_to_d += (8 - item->to_d);
}
}
}
} /* Ammo Power > 3 */
} /* Quiver */
}
/*
* Helper function -- notice the player inventory
*/
static void borg_notice_aux2(void)
{
int i;
borg_item *item;
/*** Reset counters ***/
/* Reset basic */
amt_food_lowcal = 0;
amt_food_hical = 0;
/* Reset healing */
amt_slow_poison =0;
amt_cure_confusion = 0;
amt_cure_blind = 0;
/* Reset stat potions */
for (i = 0; i < 6; i++) amt_inc_stat[i] = 0;
/* Reset books */
amt_book[0] = 0;
amt_book[1] = 0;
amt_book[2] = 0;
amt_book[3] = 0;
amt_book[4] = 0;
amt_book[5] = 0;
amt_book[6] = 0;
amt_book[7] = 0;
amt_book[8] = 0;
/* Reset various */
amt_add_stat[A_STR] = 0;
amt_add_stat[A_INT] = 0;
amt_add_stat[A_WIS] = 0;
amt_add_stat[A_DEX] = 0;
amt_add_stat[A_CON] = 0;
amt_add_stat[A_CHR] = 0;
amt_fix_stat[A_STR] = 0;
amt_fix_stat[A_INT] = 0;
amt_fix_stat[A_WIS] = 0;
amt_fix_stat[A_DEX] = 0;
amt_fix_stat[A_CON] = 0;
amt_fix_stat[A_CHR] = 0;
amt_fix_stat[6] = 0;
amt_fix_exp = 0;
amt_cool_staff = 0;
amt_cool_wand = 0;
amt_digger = 0;
/* Reset enchantment */
amt_enchant_to_a = 0;
amt_enchant_to_d = 0;
amt_enchant_to_h = 0;
amt_brand_weapon = 0;
amt_enchant_weapon = 0;
amt_enchant_armor = 0;
/* Reset number of Ego items needing *ID* */
amt_ego = 0;
/*** Process the inventory ***/
/* Scan the inventory */
for (i = 0; i < INVEN_MAX_PACK; i++)
{
item = &borg_items[i];
/* Skip empty items */
if (!item->iqty) continue;
/* Does the borg need to get an ID for it? */
if (item->note && (strstr(item->note, "magical") || strstr(item->note, "special") ||
strstr(item->note, "ego") ||streq(item->note, "splendid") ||streq(item->note, "excellent"))) my_need_id ++;
/* Hack -- skip un-aware items */
if (!item->kind) continue;
/* count up the items on the borg (do not count artifacts */
/* that are not being wielded) */
borg_has[item->kind] += item->iqty;
/* Analyze the item */
switch (item->tval)
{
/* Books */
case TV_MAGIC_BOOK:
case TV_PRAYER_BOOK:
/* Skip incorrect books */
if (item->tval != p_ptr->class->spell_book) break;
/* Count the books */
amt_book[item->sval] += item->iqty;
break;